Class: ASTTransform::AbstractTransformation
- Inherits:
-
Parser::AST::Processor
- Object
- Parser::AST::Processor
- ASTTransform::AbstractTransformation
- Includes:
- TransformationHelper
- Defined in:
- lib/ast_transform/abstract_transformation.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#on_ast_thunk(node) ⇒ Object
Thunks are framework-owned IR: descend into the body so passes that don't know about thunks still process the wrapped statements.
-
#process(node) ⇒ Object
Used internally by Parser::AST::Processor to process each node.
-
#run(node) ⇒ Parser::AST::Node
Runs this transformation on
node.
Methods included from TransformationHelper
Instance Method Details
#on_ast_thunk(node) ⇒ Object
Thunks are framework-owned IR: descend into the body so passes that don't know about thunks still process the wrapped statements. Without this, Processor's handler_missing default would pass the node through opaquely, hiding the body from every later transformation. The token (first child) is not a node and passes through untouched.
30 31 32 |
# File 'lib/ast_transform/abstract_transformation.rb', line 30 def on_ast_thunk(node) node.updated(nil, [node.children[0], *process_all(node.children.drop(1))]) end |
#process(node) ⇒ Object
Used internally by Parser::AST::Processor to process each node. DO NOT OVERRIDE.
20 21 22 23 24 |
# File 'lib/ast_transform/abstract_transformation.rb', line 20 def process(node) return node unless node.is_a?(Parser::AST::Node) process_node(node) end |
#run(node) ⇒ Parser::AST::Node
Runs this transformation on node.
Note: If you want to add one-time checks to the transformation, override this, then call super.
15 16 17 |
# File 'lib/ast_transform/abstract_transformation.rb', line 15 def run(node) process(node) end |