class Riml::AST_Rewriter::ClassDefinitionToFunctions::PrivateFunctionCallToPassObjExplicitly
Public Instance Methods
match?(node)
click to toggle source
# File lib/riml/ast_rewriter.rb, line 498 def match?(node) CallNode === node && node.name.instance_of?(DictGetDotNode) && !node.name.dict.is_a?(ListOrDictGetNode) && node.name.dict.scope_modifier.nil? && node.name.dict.name == 'self' && (node.name.keys & ast.private_function_names).size == 1 end
replace(node)
click to toggle source
# File lib/riml/ast_rewriter.rb, line 506 def replace(node) node.scope_modifier = 's:' # find function that I'm in n = node until n.instance_of?(DefNode) n = n.parent end if n.original_name == 'initialize' node.arguments.unshift(GetVariableNode.new(nil, ast.constructor_obj_name)) elsif n.private_function node.arguments.unshift(GetVariableNode.new('a:', ast.constructor_obj_name)) else node.arguments.unshift(GetVariableNode.new(nil, 'self')) end func_name = node.name.keys.first node.name = "#{ast.name}_#{func_name}" reestablish_parents(node) end