Class: SyntaxTree::YARV::AdjustStack
Overview
### Summary
‘adjuststack` accepts a single integer argument and removes that many elements from the top of the stack.
### Usage
~~~ruby x = [true] x ||= nil x ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
Returns a new instance of AdjustStack.
72
73
74
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 72
def initialize(number)
@number = number
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
70
71
72
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 70
def number
@number
end
|
Instance Method Details
#==(other) ⇒ Object
88
89
90
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 88
def ==(other)
other.is_a?(AdjustStack) && other.number == number
end
|
#call(vm) ⇒ Object
100
101
102
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 100
def call(vm)
vm.pop(number)
end
|
#deconstruct_keys(_keys) ⇒ Object
84
85
86
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 84
def deconstruct_keys(_keys)
{ number: number }
end
|
#disasm(fmt) ⇒ Object
76
77
78
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 76
def disasm(fmt)
fmt.instruction("adjuststack", [fmt.object(number)])
end
|
#length ⇒ Object
92
93
94
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 92
def length
2
end
|
#pops ⇒ Object
96
97
98
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 96
def pops
number
end
|
#to_a(_iseq) ⇒ Object
80
81
82
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 80
def to_a(_iseq)
[:adjuststack, number]
end
|