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.



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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



108
109
110
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 108

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.



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

def node
  @node
end

Instance Method Details

#inspectObject



123
124
125
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 123

def inspect
  name.inspect
end

#patch!(name) ⇒ Object



119
120
121
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 119

def patch!(name)
  @name = name
end