Class: Red::CallNode::Method::ImplicitReceiver

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!, #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(function_sexp, *arguments_array_sexp) ⇒ ImplicitReceiver

:vcall
:fcall, :foo, (:array, expression, expression, …)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/red/nodes/call_nodes.rb', line 74

def initialize(function_sexp, *arguments_array_sexp)
  options     = arguments_array_sexp.pop
  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(",")
  case function_sexp
  when :require
    #cached_import_status = @@red_import
    #@@red_import = true
    self << hush_warnings { File.read((arguments_array_sexp.assoc(:array).assoc(:str).last rescue '')).translate_to_sexp_array }.red!
    #@@red_import = cached_import_status
  when :[]
    self << "this.m$%s(%s)" % [function, arguments]
  when :block_given?
    self << "m$blockGivenBool(%s._block)" % @@red_block_arg
  else
    arguments = ','+arguments unless arguments.empty?
    self << "(this.m$%s||m$%s).call(this%s)" % [function, function, arguments]
    @@red_methods |= [function_sexp] unless @@red_import
  end
end