Class: SyntaxTree::YARV::SetConstant
Overview
Summary
setconstant pops two values off the stack: the value to set the
constant to and the constant base to set it in.
Usage
Constant = 1
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
Returns a new instance of SetConstant.
5162
5163
5164
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5162
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5160
5161
5162
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5160
def name
@name
end
|
Instance Method Details
#==(other) ⇒ Object
5178
5179
5180
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5178
def ==(other)
other.is_a?(SetConstant) && other.name == name
end
|
#call(vm) ⇒ Object
5190
5191
5192
5193
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5190
def call(vm)
value, parent = vm.pop(2)
parent.const_set(name, value)
end
|
#deconstruct_keys(_keys) ⇒ Object
5174
5175
5176
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5174
def deconstruct_keys(_keys)
{ name: name }
end
|
#disasm(fmt) ⇒ Object
5166
5167
5168
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5166
def disasm(fmt)
fmt.instruction("setconstant", [fmt.object(name)])
end
|
#length ⇒ Object
5182
5183
5184
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5182
def length
2
end
|
#pops ⇒ Object
5186
5187
5188
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5186
def pops
2
end
|
#to_a(_iseq) ⇒ Object
5170
5171
5172
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5170
def to_a(_iseq)
[:setconstant, name]
end
|