class SyntaxTree::YARV::SetGlobal
### Summary
‘setglobal` sets the value of a global variable to a value popped off the top of the stack.
### Usage
~~~ruby $global = 5 ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5210 def initialize(name) @name = name end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5226 def ==(other) other.is_a?(SetGlobal) && other.name == name end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5238 def call(vm) # Evaluating the name of the global variable because there isn't a # reflection API for global variables. eval("#{name} = vm.pop", binding, __FILE__, __LINE__) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5222 def deconstruct_keys(_keys) { name: name } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5214 def disasm(fmt) fmt.instruction("setglobal", [fmt.object(name)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5218 def to_a(_iseq) [:setglobal, name] end