Class: Red::CallNode::MethodNode
- Inherits:
-
Object
- Object
- Red::CallNode::MethodNode
- Defined in:
- lib/red/call_nodes.rb
Overview
:nodoc:
Direct Known Subclasses
Defined Under Namespace
Classes: ExplicitNode, ImplicitNode
Instance Method Summary collapse
Instance Method Details
#compile_node(options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/red/call_nodes.rb', line 41 def compile_node( = {}) call_to_returned_function = [DefinitionNode::InstanceMethodNode, CallNode::BlockNode].include?(@receiver.class) ? :call : false receiver = @receiver.compile_node function = @function.compile_node arguments = @arguments.compile_nodes(:as_argument => true, :quotes => "'") return ("$%s(%s)" % [receiver = ((receiver == '$-') || (receiver == 'id' && @@red_library == :Prototype) ? nil : receiver), arguments.first]).gsub('$$','$').gsub('$class','$$') if @receiver.is_a?(VariableNode::GlobalVariableNode) && function == '-' case function.to_sym when :-, :+, :<, :>, :%, :*, :/, :^, :==, :===, :instanceof "%s %s %s" % [receiver, function, arguments.first] when :raise "throw(%s)" % [arguments.first] when :new "new %s(%s)" % [receiver, arguments.join(', ')] when :[] if ([:symbol, :string].include?(@arguments.first.data_type) rescue false) arguments = @arguments.compile_nodes(:quotes => "", :as_argument => true) "%s.%s" else "%s[%s]" end % [receiver, arguments.first] when call_to_returned_function "(%s)(%s)" % [receiver, arguments] else receiver += '.' unless receiver.empty? "%s%s(%s)" % [receiver, function, arguments.join(', ')] end end |