class SyntaxTree::YARV::SetConstant
### Summary
‘setconstant` pops two values off the stack: the value to set the constant to and the constant base to set it in.
### Usage
~~~ruby Constant = 1 ~~~
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5015 def initialize(name) @name = name end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5031 def ==(other) other.is_a?(SetConstant) && other.name == name end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5043 def call(vm) value, parent = vm.pop(2) parent.const_set(name, value) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5027 def deconstruct_keys(_keys) { name: name } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5019 def disasm(fmt) fmt.instruction("setconstant", [fmt.object(name)]) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5035 def length 2 end
pops()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5039 def pops 2 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 5023 def to_a(_iseq) [:setconstant, name] end