Class: Kumi::IR::Base::Block
- Inherits:
-
Object
- Object
- Kumi::IR::Base::Block
- Includes:
- Enumerable
- Defined in:
- lib/kumi/ir/base/block.rb
Instance Attribute Summary collapse
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #append(instr) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(name:, instructions: []) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(name:, instructions: []) ⇒ Block
Returns a new instance of Block.
11 12 13 14 |
# File 'lib/kumi/ir/base/block.rb', line 11 def initialize(name:, instructions: []) @name = name.to_sym @instructions = instructions.dup end |
Instance Attribute Details
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
9 10 11 |
# File 'lib/kumi/ir/base/block.rb', line 9 def instructions @instructions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/kumi/ir/base/block.rb', line 9 def name @name end |
Instance Method Details
#append(instr) ⇒ Object
20 21 22 23 24 |
# File 'lib/kumi/ir/base/block.rb', line 20 def append(instr) raise ArgumentError, "instruction required" unless instr.is_a?(Instruction) @instructions << instr instr end |
#each(&block) ⇒ Object
16 17 18 |
# File 'lib/kumi/ir/base/block.rb', line 16 def each(&block) @instructions.each(&block) end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/kumi/ir/base/block.rb', line 26 def empty? @instructions.empty? end |