Class: SyntaxTree::YARV::Jump
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::Jump
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
jump unconditionally jumps to the label given as its only argument.
### Usage
~~~ruby x = 0 if x == 0
puts "0"
else
puts "2"
end ~~~
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(label) ⇒ Jump
constructor
A new instance of Jump.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(label) ⇒ Jump
2364 2365 2366 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2364 def initialize(label) @label = label end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
2362 2363 2364 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2362 def label @label end |
Instance Method Details
#==(other) ⇒ Object
2380 2381 2382 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2380 def ==(other) other.is_a?(Jump) && other.label == label end |
#call(vm) ⇒ Object
2400 2401 2402 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2400 def call(vm) vm.jump(label) end |
#canonical ⇒ Object
2396 2397 2398 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2396 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
2376 2377 2378 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2376 def deconstruct_keys(_keys) { label: label } end |
#disasm(fmt) ⇒ Object
2368 2369 2370 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2368 def disasm(fmt) fmt.instruction("jump", [fmt.label(label)]) end |
#length ⇒ Object
2384 2385 2386 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2384 def length 2 end |
#pops ⇒ Object
2388 2389 2390 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2388 def pops 0 end |
#pushes ⇒ Object
2392 2393 2394 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2392 def pushes 0 end |
#to_a(_iseq) ⇒ Object
2372 2373 2374 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2372 def to_a(_iseq) [:jump, label.name] end |