Class: SyntaxTree::YARV::NewArray
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::NewArray
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
newarray puts a new array initialized with number values from the stack. It pops number values off the stack and pushes the array onto the stack.
### Usage
~~~ruby
- “string”
-
~~~
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(number) ⇒ NewArray
constructor
A new instance of NewArray.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(number) ⇒ NewArray
2186 2187 2188 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2186 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
2184 2185 2186 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2184 def number @number end |
Instance Method Details
#call(vm) ⇒ Object
2214 2215 2216 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2214 def call(vm) vm.push(vm.pop(number)) end |
#canonical ⇒ Object
2210 2211 2212 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2210 def canonical self end |
#disasm(fmt) ⇒ Object
2190 2191 2192 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2190 def disasm(fmt) fmt.instruction("newarray", [fmt.object(number)]) end |
#length ⇒ Object
2198 2199 2200 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2198 def length 2 end |
#pops ⇒ Object
2202 2203 2204 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2202 def pops number end |
#pushes ⇒ Object
2206 2207 2208 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2206 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2194 2195 2196 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2194 def to_a(_iseq) [:newarray, number] end |