Class: SyntaxTree::YARV::GetSpecial
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::GetSpecial
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
getspecial pushes the value of a special local variable onto the stack.
### Usage
~~~ruby 1 if (a == 1) .. (b == 2) ~~~
Constant Summary collapse
- SVAR_LASTLINE =
$_
0- SVAR_BACKREF =
$~
1- SVAR_FLIPFLOP_START =
flipflop
2
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(key, type) ⇒ GetSpecial
constructor
A new instance of GetSpecial.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(key, type) ⇒ GetSpecial
Returns a new instance of GetSpecial.
1871 1872 1873 1874 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1871 def initialize(key, type) @key = key @type = type end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
1869 1870 1871 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1869 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1869 1870 1871 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1869 def type @type end |
Instance Method Details
#call(vm) ⇒ Object
1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1900 def call(vm) case key when SVAR_LASTLINE raise NotImplementedError, "getspecial SVAR_LASTLINE" when SVAR_BACKREF raise NotImplementedError, "getspecial SVAR_BACKREF" when SVAR_FLIPFLOP_START vm.frame_svar.svars[SVAR_FLIPFLOP_START] end end |
#canonical ⇒ Object
1896 1897 1898 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1896 def canonical self end |
#disasm(fmt) ⇒ Object
1876 1877 1878 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1876 def disasm(fmt) fmt.instruction("getspecial", [fmt.object(key), fmt.object(type)]) end |
#length ⇒ Object
1884 1885 1886 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1884 def length 3 end |
#pops ⇒ Object
1888 1889 1890 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1888 def pops 0 end |
#pushes ⇒ Object
1892 1893 1894 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1892 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1880 1881 1882 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1880 def to_a(_iseq) [:getspecial, key, type] end |