Class: Riml::AST_Rewriter::DeserializeVarAssignment
- Inherits:
-
Riml::AST_Rewriter
- Object
- Riml::AST_Rewriter
- Riml::AST_Rewriter::DeserializeVarAssignment
- Defined in:
- lib/riml/ast_rewriter.rb
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, #max_recursion_lvl, #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
975 976 977 |
# File 'lib/riml/ast_rewriter.rb', line 975 def match?(node) AssignNode === node && AssignNode === node.rhs && node.operator == '=' end |
#replace(node) ⇒ Object
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/riml/ast_rewriter.rb', line 979 def replace(node) orig_assign = node.dup assigns = [] while assign_node = (AssignNode === node && node.rhs) assigns.unshift([node.lhs, node.rhs]) node = assign_node end assigns = assigns[0..0].concat(assigns[1..-1].map! { |(lhs, rhs)| [lhs, rhs.lhs] }) assigns.map! do |(lhs, rhs)| AssignNode.new('=', lhs, rhs) end new_assigns = Nodes.new(assigns) new_assigns.parent = orig_assign.parent orig_assign.replace_with(new_assigns) establish_parents(new_assigns) end |