Class: Peruby::Op::ConstantDef
Overview
Constant subroutine installed by use constant.
Instance Method Summary collapse
-
#initialize(name, value) ⇒ ConstantDef
constructor
A new instance of ConstantDef.
- #run(env, _context) ⇒ Object
Methods inherited from Base
#argument_cells, #local_slot, #lvalue, #run_subroutine, #to_callable, #warning_directive?
Constructor Details
#initialize(name, value) ⇒ ConstantDef
Returns a new instance of ConstantDef.
36 37 38 39 |
# File 'lib/peruby/op/call.rb', line 36 def initialize(name, value) @name = name @value = value end |
Instance Method Details
#run(env, _context) ⇒ Object
41 42 43 44 45 |
# File 'lib/peruby/op/call.rb', line 41 def run(env, _context) package = @name.include?('::') ? @name.rpartition('::').first : env.package env.runtime.stash.glob(@name).code = Code.new(@name, @value, env.capture, package, '') env.runtime.stash.touch end |