Class: Peruby::Op::Local

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

Overview

Dynamically localizes a package variable or aggregate element.

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(target, assignment) ⇒ Local

Returns a new instance of Local.



521
522
523
524
# File 'lib/peruby/op/variable.rb', line 521

def initialize(target, assignment)
  @target = target
  @assignment = assignment
end

Instance Method Details

#run(env, context) ⇒ Object



526
527
528
529
530
531
# File 'lib/peruby/op/variable.rb', line 526

def run(env, context)
  @target.localize(env, env.runtime.local_stack)
  return @assignment.run(env, context) if @assignment

  nil
end