Class: Red::CallNode::Method::ExplicitReceiver

Inherits:
Red::CallNode::Method show all
Defined in:
lib/red/nodes/call_nodes.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from String

#%, #*, #+, #<<, #<=>, #==, #=~, #[], #[]=, #capitalize, #capitalize!, #casecmp, #center, #chomp, #chomp!, #chop, #chop!, #concat, #count, #crypt, #delete, #delete!, #downcase, #downcase!, #each, #each_byte, #each_line, #empty?, #eql?, #gsub, #gsub!, #hash, #hex, #include?, #index, #insert, #inspect, #intern, #length, #ljust, #lstrip, #lstrip!, #match, #next, #next!, #oct, #replace, #reverse, #reverse!, #rindex, #rjust, #rstrip, #rstrip!, #scan, #size, #slice, #slice!, #split, #squeeze, #strip, #strip!, #strip_scripts, #sub, #sub!, #succ, #succ!, #sum, #swapcase, #swapcase!, #to_f, #to_i, #to_s, #to_str, #to_sym, #tr, #tr!, #tr_s, #tr_s!, #upcase, #upcase!, #upto

Constructor Details

#initialize(receiver_sexp, function_sexp, *arguments_array_sexp) ⇒ ExplicitReceiver

:call, expression, :foo, (:array, expression, expression, …)


56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/red/nodes/call_nodes.rb', line 56

def initialize(receiver_sexp, function_sexp, *arguments_array_sexp)
  options     = arguments_array_sexp.pop
  receiver    = receiver_sexp.red!(:as_receiver => true)
  function    = (METHOD_ESCAPE[function_sexp] || function_sexp).red!
  args_array  = arguments_array_sexp.last.is_sexp?(:array) ? arguments_array_sexp.last[1..-1].map {|argument_sexp| argument_sexp.red!(:as_argument => true)} : []
  args_array += [options[:block_string]] if options[:block_string]
  arguments   = args_array.join(",")
  self << "%s.m$%s(%s)" % [receiver, function, arguments]
  unless @@red_import
    @@red_methods |= [function_sexp]
    @@red_methods |= ([arguments_array_sexp.last[1].last.to_sym] rescue []) if function_sexp == :send && arguments_array_sexp.last.is_sexp?(:array)
  end
end