Class: Peruby::Op::Goto

Inherits:
Base
  • Object
show all
Defined in:
lib/peruby/op/call.rb

Overview

Tail-call style goto &sub preserving the current @_ cells.

Instance Method Summary collapse

Methods inherited from Base

#argument_cells, #local_slot, #lvalue, #run_subroutine, #to_callable, #warning_directive?

Constructor Details

#initialize(name) ⇒ Goto

Returns a new instance of Goto.



352
353
354
# File 'lib/peruby/op/call.rb', line 352

def initialize(name)
  @name = name
end

Instance Method Details

#run(env, _context) ⇒ Object

Raises:



356
357
358
359
360
361
# File 'lib/peruby/op/call.rb', line 356

def run(env, _context)
  code = env.runtime.stash.glob(@name).code || env.runtime.stash.glob("#{env.package}::#{@name}").code
  raise PerlError, "Undefined subroutine &#{@name} called" unless code

  throw :peruby_return, GotoRequest.new(code)
end