Class: SyntaxTree::YARV::Jump
Overview
Summary
jump unconditionally jumps to the label given as its only argument.
Usage
x = 0
if x == 0
puts "0"
else
puts "2"
end
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#canonical, #falls_through?, #leaves?, #pops, #pushes, #side_effects?
Constructor Details
#initialize(label) ⇒ Jump
Returns a new instance of Jump.
2273
2274
2275
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2273
def initialize(label)
@label = label
end
|
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
2271
2272
2273
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2271
def label
@label
end
|
Instance Method Details
#==(other) ⇒ Object
2289
2290
2291
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2289
def ==(other)
other.is_a?(Jump) && other.label == label
end
|
#branch_targets ⇒ Object
2301
2302
2303
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2301
def branch_targets
[label]
end
|
#call(vm) ⇒ Object
2297
2298
2299
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2297
def call(vm)
vm.jump(label)
end
|
#deconstruct_keys(_keys) ⇒ Object
2285
2286
2287
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2285
def deconstruct_keys(_keys)
{ label: label }
end
|
#disasm(fmt) ⇒ Object
2277
2278
2279
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2277
def disasm(fmt)
fmt.instruction("jump", [fmt.label(label)])
end
|
#length ⇒ Object
2293
2294
2295
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2293
def length
2
end
|
#to_a(_iseq) ⇒ Object
2281
2282
2283
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 2281
def to_a(_iseq)
[:jump, label.name]
end
|