Class: Riml::AST_Rewriter::ClassDefinitionToFunctions
- Inherits:
-
Riml::AST_Rewriter
- Object
- Riml::AST_Rewriter
- Riml::AST_Rewriter::ClassDefinitionToFunctions
- Defined in:
- lib/riml/ast_rewriter.rb
Defined Under Namespace
Classes: DefNodeToPrivateFunction, ExtendObjectWithMethods, InitializeSuperToObjectExtension, InsertInitializeMethod, PrivateFunctionCallToPassObjExplicitly, RegisterPrivateFunctions, SelfToDictName, SelfToDictNameInAssignments, SelfToObjArgumentInPrivateFunction, SuperToSuperclassFunction
Constant Summary
Constants included from Constants
Constants::BUILTIN_COMMANDS, Constants::BUILTIN_FUNCTIONS, Constants::COMPARISON_OPERATORS, Constants::COMPILED_STRING_LOCATION, Constants::DEFINE_KEYWORDS, Constants::END_KEYWORDS, Constants::IGNORECASE_CAPABLE_OPERATORS, Constants::KEYWORDS, Constants::REGISTERS, Constants::RIML_CLASS_COMMANDS, Constants::RIML_COMMANDS, Constants::RIML_END_KEYWORDS, Constants::RIML_FILE_COMMANDS, Constants::RIML_KEYWORDS, Constants::SPECIAL_VARIABLE_PREFIXES, Constants::SPLAT_LITERAL, Constants::UNKNOWN_LOCATION_INFO, Constants::VIML_COMMANDS, Constants::VIML_END_KEYWORDS, Constants::VIML_KEYWORDS
Instance Attribute Summary
Attributes inherited from Riml::AST_Rewriter
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, #reorder_includes_based_on_class_dependencies!, #resolve_class_dependencies!, #resolve_class_dependencies?, #rewrite, #rewrite_included_and_sourced_files!, #rewrite_on_match, #watch_for_class_pickup
Constructor Details
This class inherits a constructor from Riml::AST_Rewriter
Instance Method Details
#match?(node) ⇒ Boolean
395 396 397 |
# File 'lib/riml/ast_rewriter.rb', line 395 def match?(node) ClassDefinitionNode === node end |
#max_recursion_lvl ⇒ Object
429 430 431 |
# File 'lib/riml/ast_rewriter.rb', line 429 def max_recursion_lvl 1 end |
#replace(node) ⇒ Object
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/riml/ast_rewriter.rb', line 399 def replace(node) classes[node.full_name] = node RegisterPrivateFunctions.new(node.expressions, classes).rewrite_on_match DefNodeToPrivateFunction.new(node.expressions, 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.nodes.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 SelfToDictNameInAssignments.new(dict_name).rewrite_on_match(constructor) SuperToSuperclassFunction.new(node, classes).rewrite_on_match PrivateFunctionCallToPassObjExplicitly.new(node, classes).rewrite_on_match SplatsToCallFunctionInCallingContext.new(node, classes).rewrite_on_match SelfToDictName.new(dict_name).rewrite_on_match(constructor) constructor.expressions.nodes.push( ReturnNode.new(GetVariableNode.new(nil, dict_name)) ) reestablish_parents(constructor) end |