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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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
2470 2471 2472 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2470 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
2468 2469 2470 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2468 def number @number end |
Instance Method Details
#==(other) ⇒ Object
2486 2487 2488 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2486 def ==(other) other.is_a?(NewArray) && other.number == number end |
#call(vm) ⇒ Object
2506 2507 2508 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2506 def call(vm) vm.push(vm.pop(number)) end |
#canonical ⇒ Object
2502 2503 2504 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2502 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
2482 2483 2484 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2482 def deconstruct_keys(_keys) { number: number } end |
#disasm(fmt) ⇒ Object
2474 2475 2476 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2474 def disasm(fmt) fmt.instruction("newarray", [fmt.object(number)]) end |
#length ⇒ Object
2490 2491 2492 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2490 def length 2 end |
#pops ⇒ Object
2494 2495 2496 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2494 def pops number end |
#pushes ⇒ Object
2498 2499 2500 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2498 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2478 2479 2480 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2478 def to_a(_iseq) [:newarray, number] end |