Class: SyntaxTree::YARV::InstructionSequence::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/instruction_sequence.rb

Overview

This represents the destination of instructions that jump. Initially it does not track its position so that when we perform optimizations the indices don’t get messed up.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Label

Returns a new instance of Label.



106
107
108
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 106

def initialize(name = nil)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



99
100
101
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 99

def name
  @name
end

#nodeObject

When we’re serializing the instruction sequence, we need to be able to look up the label from the branch instructions and then access the subsequent node. So we’ll store the reference here.



104
105
106
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 104

def node
  @node
end

Instance Method Details

#inspectObject



114
115
116
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 114

def inspect
  name.inspect
end

#patch!(name) ⇒ Object



110
111
112
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 110

def patch!(name)
  @name = name
end