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.
2366 2367 2368 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2366 def initialize(number) @number = number end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
2364 2365 2366 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2364 def number @number end |
Instance Method Details
#==(other) ⇒ Object
2382 2383 2384 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2382 def ==(other) other.is_a?(NewArrayKwSplat) && other.number == number end |
#call(vm) ⇒ Object
2398 2399 2400 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2398 def call(vm) vm.push(vm.pop(number)) end |
#deconstruct_keys(_keys) ⇒ Object
2378 2379 2380 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2378 def deconstruct_keys(_keys) { number: number } end |
#disasm(fmt) ⇒ Object
2370 2371 2372 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2370 def disasm(fmt) fmt.instruction("newarraykwsplat", [fmt.object(number)]) end |
#length ⇒ Object
2386 2387 2388 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2386 def length 2 end |
#pops ⇒ Object
2390 2391 2392 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2390 def pops number end |
#pushes ⇒ Object
2394 2395 2396 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2394 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2374 2375 2376 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2374 def to_a(_iseq) [:newarraykwsplat, number] end |