Documentation
¶
Index ¶
- type CommentOptimizer
- type CompoundOptimizer
- type ExpressionInversionOptimizer
- type ExpressionOptimizer
- type Optimizer
- type StaticExpressionOptimizer
- func (o *StaticExpressionOptimizer) Optimize(prog ast.Node) error
- func (o *StaticExpressionOptimizer) OptimizeExpression(e ast.Expression) ast.Expression
- func (o *StaticExpressionOptimizer) OptimizeExpressionNonRecursive(exp ast.Expression) ast.Expression
- func (o *StaticExpressionOptimizer) Visit(node ast.Node, visitType int) error
- type VariableNameOptimizer
- func (o *VariableNameOptimizer) GetReversalTable() map[string]string
- func (o *VariableNameOptimizer) InitializeByFrequency(node ast.Node, ignore []string)
- func (o *VariableNameOptimizer) Optimize(prog ast.Node) error
- func (o *VariableNameOptimizer) OptimizeVarName(in string) string
- func (o *VariableNameOptimizer) SetBlacklist(bl []string)
- func (o *VariableNameOptimizer) Visit(node ast.Node, visitType int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommentOptimizer ¶ added in v0.0.7
type CommentOptimizer struct {
}
CommentOptimizer removes all comments from the code
type CompoundOptimizer ¶
type CompoundOptimizer struct {
// contains filtered or unexported fields
}
CompoundOptimizer wraps all other optimizers and executes them
func NewCompoundOptimizer ¶
func NewCompoundOptimizer() *CompoundOptimizer
NewCompoundOptimizer creates a new compound optimizer
type ExpressionInversionOptimizer ¶ added in v0.0.9
type ExpressionInversionOptimizer struct {
}
ExpressionInversionOptimizer inverts negated expressions to shorten them
func (ExpressionInversionOptimizer) Optimize ¶ added in v0.0.9
func (o ExpressionInversionOptimizer) Optimize(prog ast.Node) error
Optimize is needed to implement Optimizer
func (ExpressionInversionOptimizer) OptimizeExpression ¶ added in v0.0.9
func (o ExpressionInversionOptimizer) OptimizeExpression(e ast.Expression) ast.Expression
OptimizeExpression optimizes a single expression Optimize() in contrast can only optimize whole programms
type ExpressionOptimizer ¶ added in v0.0.10
type ExpressionOptimizer interface {
// OptimizeExpression optimizes the given expression. The expression is mutated
OptimizeExpression(prog ast.Expression) ast.Expression
}
ExpressionOptimizer is an additional optimizer interface, for optimizing single expressions
type Optimizer ¶
type Optimizer interface {
// Optimize optimizes the given ast. The ast is mutated (obviously)
Optimize(prog ast.Node) error
}
Optimizer is the common interface for all optimizers
type StaticExpressionOptimizer ¶
type StaticExpressionOptimizer struct {
}
StaticExpressionOptimizer evaluates static expressions at compile-time
func NewStaticExpressionOptimizer ¶
func NewStaticExpressionOptimizer() *StaticExpressionOptimizer
NewStaticExpressionOptimizer returns a new StaticExpressionOptimizer
func (*StaticExpressionOptimizer) Optimize ¶
func (o *StaticExpressionOptimizer) Optimize(prog ast.Node) error
Optimize is required to implement Optimizer
func (*StaticExpressionOptimizer) OptimizeExpression ¶ added in v0.0.10
func (o *StaticExpressionOptimizer) OptimizeExpression(e ast.Expression) ast.Expression
OptimizeExpression optimizes a single expression recursively
func (*StaticExpressionOptimizer) OptimizeExpressionNonRecursive ¶ added in v0.0.10
func (o *StaticExpressionOptimizer) OptimizeExpressionNonRecursive(exp ast.Expression) ast.Expression
OptimizeExpressionNonRecursive optimizes a single expression if no optimization is possible, nil is returned
type VariableNameOptimizer ¶
type VariableNameOptimizer struct {
// contains filtered or unexported fields
}
VariableNameOptimizer replaces variable names with sorter names Names of external variables will be left unchanged Replacements are case-insensitive. "var" and "VaR" will be replaced with the same replacement
func NewVariableNameOptimizer ¶
func NewVariableNameOptimizer() *VariableNameOptimizer
NewVariableNameOptimizer returns a new VariableNameOptimizer
func (*VariableNameOptimizer) GetReversalTable ¶ added in v0.0.13
func (o *VariableNameOptimizer) GetReversalTable() map[string]string
GetReversalTable returns a map that can be used to translated the shortened names back to the original names
func (*VariableNameOptimizer) InitializeByFrequency ¶ added in v0.1.11
func (o *VariableNameOptimizer) InitializeByFrequency(node ast.Node, ignore []string)
InitializeByFrequency will initialize the replacement-table based on the frequency of each variable in the input ast The most frequent variable will get the replacement a, the second most frequent gets b and so on. If two variables are equally frequent, the variable defined earlier wins. This way the most frequent variables will get the shortest replacements variables listed in ignore (can be nil) are ignored
func (*VariableNameOptimizer) Optimize ¶
func (o *VariableNameOptimizer) Optimize(prog ast.Node) error
Optimize is needed to implement Optimizer
func (*VariableNameOptimizer) OptimizeVarName ¶ added in v0.0.10
func (o *VariableNameOptimizer) OptimizeVarName(in string) string
OptimizeVarName replaces a variable name with a new one (if it does not reference an external variable) the same input name will always result in the same output name
func (*VariableNameOptimizer) SetBlacklist ¶ added in v0.1.7
func (o *VariableNameOptimizer) SetBlacklist(bl []string)
SetBlacklist sets a list of output variable-names that shall never be produced by the optimizer