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
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5162 def initialize(name) @name = name end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5178 def ==(other) other.is_a?(SetConstant) && other.name == name end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5190 def call(vm) value, parent = vm.pop(2) parent.const_set(name, value) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5174 def deconstruct_keys(_keys) { name: name } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5166 def disasm(fmt) fmt.instruction("setconstant", [fmt.object(name)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5170 def to_a(_iseq) [:setconstant, name] end