Class: SyntaxTree::YARV::NewArrayKwSplat
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::NewArrayKwSplat
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
‘newarraykwsplat` is a specialized version of `newarray` that takes a ** splat argument. It pops `number` values off the stack and pushes the array onto the stack.
### Usage
~~~ruby
- “string”, **{ foo: “bar” }
-
~~~
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(number) ⇒ NewArrayKwSplat
constructor
A new instance of NewArrayKwSplat.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(number) ⇒ NewArrayKwSplat
Returns a new instance of NewArrayKwSplat.
2419 2420 2421 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2419 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
2417 2418 2419 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2417 def number @number end |
Instance Method Details
#==(other) ⇒ Object
2435 2436 2437 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2435 def ==(other) other.is_a?(NewArrayKwSplat) && other.number == number end |
#call(vm) ⇒ Object
2451 2452 2453 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2451 def call(vm) vm.push(vm.pop(number)) end |
#deconstruct_keys(_keys) ⇒ Object
2431 2432 2433 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2431 def deconstruct_keys(_keys) { number: number } end |
#disasm(fmt) ⇒ Object
2423 2424 2425 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2423 def disasm(fmt) fmt.instruction("newarraykwsplat", [fmt.object(number)]) end |
#length ⇒ Object
2439 2440 2441 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2439 def length 2 end |
#pops ⇒ Object
2443 2444 2445 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2443 def pops number end |
#pushes ⇒ Object
2447 2448 2449 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2447 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2427 2428 2429 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2427 def to_a(_iseq) [:newarraykwsplat, number] end |