Class: SyntaxTree::YARV::GetGlobal
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::GetGlobal
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
getglobal pushes the value of a global variables onto the stack.
### Usage
~~~ruby $$ ~~~
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(name) ⇒ GetGlobal
constructor
A new instance of GetGlobal.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(name) ⇒ GetGlobal
1610 1611 1612 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1610 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
1608 1609 1610 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1608 def name @name end |
Instance Method Details
#call(vm) ⇒ Object
1638 1639 1640 1641 1642 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1638 def call(vm) # Evaluating the name of the global variable because there isn't a # reflection API for global variables. vm.push(eval(name.to_s, binding, __FILE__, __LINE__)) end |
#canonical ⇒ Object
1634 1635 1636 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1634 def canonical self end |
#disasm(fmt) ⇒ Object
1614 1615 1616 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1614 def disasm(fmt) fmt.instruction("getglobal", [fmt.object(name)]) end |
#length ⇒ Object
1622 1623 1624 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1622 def length 2 end |
#pops ⇒ Object
1626 1627 1628 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1626 def pops 0 end |
#pushes ⇒ Object
1630 1631 1632 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1630 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1618 1619 1620 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1618 def to_a(_iseq) [:getglobal, name] end |