Class: Peruby::Op::Call
Overview
User subroutine invocation.
Instance Method Summary collapse
-
#initialize(name, arguments) ⇒ Call
constructor
A new instance of Call.
- #run(env, context) ⇒ Object
- #scalar_callable ⇒ Object
- #to_callable ⇒ Object
Methods inherited from Base
#argument_cells, #local_slot, #lvalue, #run_subroutine, #warning_directive?
Constructor Details
#initialize(name, arguments) ⇒ Call
Returns a new instance of Call.
75 76 77 78 |
# File 'lib/peruby/op/call.rb', line 75 def initialize(name, arguments) @name = name @arguments = arguments end |
Instance Method Details
#run(env, context) ⇒ Object
80 81 82 83 |
# File 'lib/peruby/op/call.rb', line 80 def run(env, context) code = resolve(env) env.runtime.call(code, @arguments.argument_cells(env, code.prototype), context) end |
#scalar_callable ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/peruby/op/call.rb', line 93 def scalar_callable arguments = @arguments.argument_callable lambda do |env| code = resolve(env) env.runtime.call(code, arguments.call(env, code.prototype), :scalar) end end |
#to_callable ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/peruby/op/call.rb', line 85 def to_callable arguments = @arguments.argument_callable lambda do |env, context| code = resolve(env) env.runtime.call(code, arguments.call(env, code.prototype), context) end end |