Class: Red::CallNode::Method::ImplicitReceiver
- Inherits:
-
Red::CallNode::Method
- Object
- String
- Red::CallNode
- Red::CallNode::Method
- Red::CallNode::Method::ImplicitReceiver
- Defined in:
- lib/red/nodes/call_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(function_sexp, *arguments_array_sexp) ⇒ ImplicitReceiver
constructor
- :vcall
-
[:fcall, :foo, (:array, expression, expression, …)].
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(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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/red/nodes/call_nodes.rb', line 74 def initialize(function_sexp, *arguments_array_sexp) = 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 += [[:block_string]] if [:block_string] arguments = args_array.join(",") case function_sexp when :require basename = File.basename((arguments_array_sexp.assoc(:array).assoc(:str).last rescue '')) dirname = File.dirname((arguments_array_sexp.assoc(:array).assoc(:str).last rescue '')) filename = File.join(@@red_filepath, dirname, basename) unless @@red_required.include?(basename) @@red_required |= [basename] file = Dir.glob('%s.red' % filename)[0] || Dir.glob('%s.rb' % filename)[0] || Dir.glob(filename)[0] || Dir.glob('%s/../../source/%s.red' % [File.dirname(__FILE__),basename])[0] || Dir.glob('%s/../../source/%s.rb' % [File.dirname(__FILE__),basename])[0] || Dir.glob('%s/../../source/%s' % [File.dirname(__FILE__),basename])[0] stored_filepath = @@red_filepath @@red_filepath = File.dirname(file) self << hush_warnings { File.read(file).translate_to_sexp_array }.red! @@red_filepath = stored_filepath else self << "false"; end when :[] self << "this.m$%s(%s)" % [function, arguments] when :block_given? self << "m$block_given_bool(%s.__block__)" % (@@red_block_arg || 'nil') else if Red.debug error_function = arguments.empty? ? 'n' : 'm' self << "((this.m$%s&&this.m$%s(%s))||(window.m$%s&&window.m%s(%s))||$%s(this,'%s'))" % [function,function,arguments,function,function,arguments,error_function,function_sexp] else arguments = ','+arguments unless arguments.empty? self << "(this.m$%s||window.m$%s).call(this%s)" % [function, function, arguments] end @@red_methods |= [function_sexp] unless @@red_import end end |