Class: SyntaxTree::YARV::SetGlobal
Overview
Summary
setglobal sets the value of a global variable to a value popped off the
top of the stack.
Usage
$global = 5
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
#initialize(name) ⇒ SetGlobal
Returns a new instance of SetGlobal.
5210
5211
5212
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5210
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5208
5209
5210
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5208
def name
@name
end
|
Instance Method Details
#==(other) ⇒ Object
5226
5227
5228
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5226
def ==(other)
other.is_a?(SetGlobal) && other.name == name
end
|
#call(vm) ⇒ Object
5238
5239
5240
5241
5242
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5238
def call(vm)
eval("#{name} = vm.pop", binding, __FILE__, __LINE__)
end
|
#deconstruct_keys(_keys) ⇒ Object
5222
5223
5224
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5222
def deconstruct_keys(_keys)
{ name: name }
end
|
#disasm(fmt) ⇒ Object
5214
5215
5216
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5214
def disasm(fmt)
fmt.instruction("setglobal", [fmt.object(name)])
end
|
#length ⇒ Object
5230
5231
5232
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5230
def length
2
end
|
#pops ⇒ Object
5234
5235
5236
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5234
def pops
1
end
|
#to_a(_iseq) ⇒ Object
5218
5219
5220
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5218
def to_a(_iseq)
[:setglobal, name]
end
|