Class: AbstractMapper::Optimizer Private
- Inherits:
-
Object
- Object
- AbstractMapper::Optimizer
- Defined in:
- lib/abstract_mapper/optimizer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Optimizes the immutable abstract syntax tree (AST) using comfigurable collection of applicable rules.
Instance Attribute Summary collapse
-
#rules ⇒ AbstractMapper::Rules
readonly
private
The collection of applicable optimization rules.
Class Method Summary collapse
- .initialize(rules) ⇒ Object private
-
.new(rules = Rules.new) ⇒ AbstractMapper::Optimizer
Creates the optimizer.
-
.update(tree) ⇒ AbstractMapper::Branch
private
Recursively optimizes the AST from root to leafs.
Instance Attribute Details
#rules ⇒ AbstractMapper::Rules (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The collection of applicable optimization rules.
17 18 19 |
# File 'lib/abstract_mapper/optimizer.rb', line 17 def rules @rules end |
Class Method Details
.initialize(rules) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 |
# File 'lib/abstract_mapper/optimizer.rb', line 29 def initialize(rules) @rules = rules IceNine.deep_freeze(self) end |
.new(rules = Rules.new) ⇒ AbstractMapper::Optimizer
Creates the optimizer
|
# File 'lib/abstract_mapper/optimizer.rb', line 19
|
.update(tree) ⇒ AbstractMapper::Branch
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Recursively optimizes the AST from root to leafs
40 41 42 43 44 |
# File 'lib/abstract_mapper/optimizer.rb', line 40 def update(tree) return tree unless tree.is_a? AST::Branch new_tree = tree.update { rules[tree] } new_tree.update { new_tree.map(&method(:update)) } end |