Class: Riml::AST_Rewriter::ClassDefinitionToFunctions
- Inherits:
-
Riml::AST_Rewriter
- Object
- Riml::AST_Rewriter
- Riml::AST_Rewriter::ClassDefinitionToFunctions
- Defined in:
- lib/ast_rewriter.rb
Defined Under Namespace
Classes: DefNodeToPrivateFunction, ExtendObjectWithMethods, InitializeSuperToObjectExtension, InsertInitializeMethod, PrivateFunctionCallToPassObjExplicitly, RegisterPrivateFunctions, SelfToDictName, SelfToObjArgumentInPrivateFunction, SuperToSuperclassFunction
Constant Summary
Constants included from Constants
Constants::BUILTIN_COMMANDS, Constants::BUILTIN_FUNCTIONS, Constants::COMPARISON_OPERATORS, Constants::DEFINE_KEYWORDS, Constants::END_KEYWORDS, Constants::IGNORECASE_CAPABLE_OPERATORS, Constants::KEYWORDS, Constants::REGISTERS, Constants::RIML_COMMANDS, Constants::RIML_END_KEYWORDS, Constants::RIML_KEYWORDS, Constants::SPECIAL_VARIABLE_PREFIXES, Constants::SPLAT_LITERAL, Constants::VIML_COMMANDS, Constants::VIML_END_KEYWORDS, Constants::VIML_KEYWORDS
Instance Attribute Summary
Attributes inherited from Riml::AST_Rewriter
#ast, #classes, #rewritten_included_and_sourced_files
Instance Method Summary collapse
Methods inherited from Riml::AST_Rewriter
#add_SID_function!, #add_SID_function?, #do_establish_parents, #do_rewrite_on_match, #establish_parents, #initialize, #recursive?, #rewrite, #rewrite_included_and_sourced_files!, #rewrite_on_match
Constructor Details
This class inherits a constructor from Riml::AST_Rewriter
Instance Method Details
#match?(node) ⇒ Boolean
194 195 196 |
# File 'lib/ast_rewriter.rb', line 194 def match?(node) ClassDefinitionNode === node end |
#replace(node) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/ast_rewriter.rb', line 198 def replace(node) classes[node.full_name] = node RegisterPrivateFunctions.new(node, classes).rewrite_on_match DefNodeToPrivateFunction.new(node, classes).rewrite_on_match InsertInitializeMethod.new(node, classes).rewrite_on_match constructor = node.constructor constructor.name = node.constructor_name constructor.original_name = 'initialize' constructor.scope_modifier = node.scope_modifier # set up dictionary variable at top of function dict_name = node.constructor_obj_name constructor.expressions.unshift( AssignNode.new('=', GetVariableNode.new(nil, dict_name), DictionaryNode.new({})) ) InitializeSuperToObjectExtension.new(constructor, classes, node).rewrite_on_match ExtendObjectWithMethods.new(node, classes).rewrite_on_match SelfToDictName.new(dict_name).rewrite_on_match(constructor) SuperToSuperclassFunction.new(node, classes).rewrite_on_match PrivateFunctionCallToPassObjExplicitly.new(node, classes).rewrite_on_match constructor.expressions.push( ReturnNode.new(GetVariableNode.new(nil, dict_name)) ) reestablish_parents(constructor) end |