Class: Kumi::IR::Base::Function
- Inherits:
-
Object
- Object
- Kumi::IR::Base::Function
- Defined in:
- lib/kumi/ir/base/function.rb
Direct Known Subclasses
Kumi::IR::Buf::Function, DF::Function, Loop::Function, Vec::Function
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
- #append_block(block) ⇒ Object
- #entry_block ⇒ Object
-
#initialize(name:, parameters: [], blocks: []) ⇒ Function
constructor
A new instance of Function.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, parameters: [], blocks: []) ⇒ Function
Returns a new instance of Function.
9 10 11 12 13 |
# File 'lib/kumi/ir/base/function.rb', line 9 def initialize(name:, parameters: [], blocks: []) @name = name.to_sym @parameters = parameters.map(&:to_sym) @blocks = blocks.map { |b| ensure_block(b) } end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
7 8 9 |
# File 'lib/kumi/ir/base/function.rb', line 7 def blocks @blocks end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/kumi/ir/base/function.rb', line 7 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/kumi/ir/base/function.rb', line 7 def parameters @parameters end |
Instance Method Details
#append_block(block) ⇒ Object
19 20 21 |
# File 'lib/kumi/ir/base/function.rb', line 19 def append_block(block) @blocks << ensure_block(block) end |
#entry_block ⇒ Object
15 16 17 |
# File 'lib/kumi/ir/base/function.rb', line 15 def entry_block @blocks.first end |
#to_h ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/kumi/ir/base/function.rb', line 23 def to_h { name:, parameters:, blocks: @blocks.map { |b| { name: b.name, instructions: b.instructions.map(&:to_h) } } } end |