Class: SyntaxTree::YARV::InstructionSequence::InstructionList
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::InstructionSequence::InstructionList
- Includes:
- Enumerable
- Defined in:
- lib/syntax_tree/yarv/instruction_sequence.rb
Overview
When the list of instructions is first being created, it’s stored as a linked list. This is to make it easier to perform peephole optimizations and other transformations like instruction specialization.
Defined Under Namespace
Classes: Node
Instance Attribute Summary collapse
-
#head_node ⇒ Object
readonly
Returns the value of attribute head_node.
-
#tail_node ⇒ Object
readonly
Returns the value of attribute tail_node.
Instance Method Summary collapse
- #each(&_blk) ⇒ Object
- #each_node ⇒ Object
-
#initialize ⇒ InstructionList
constructor
A new instance of InstructionList.
- #push(instruction) ⇒ Object
Constructor Details
#initialize ⇒ InstructionList
Returns a new instance of InstructionList.
48 49 50 51 |
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 48 def initialize @head_node = nil @tail_node = nil end |
Instance Attribute Details
#head_node ⇒ Object (readonly)
Returns the value of attribute head_node.
46 47 48 |
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 46 def head_node @head_node end |
#tail_node ⇒ Object (readonly)
Returns the value of attribute tail_node.
46 47 48 |
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 46 def tail_node @tail_node end |
Instance Method Details
#each(&_blk) ⇒ Object
53 54 55 56 |
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 53 def each(&_blk) return to_enum(__method__) unless block_given? each_node { |node| yield node.value } end |
#each_node ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/syntax_tree/yarv/instruction_sequence.rb', line 58 def each_node return to_enum(__method__) unless block_given? node = head_node while node yield node, node.value node = node.next_node end end |