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.
-
#return_stamp ⇒ Object
readonly
Returns the value of attribute return_stamp.
Instance Method Summary collapse
- #append_block(block) ⇒ Object
- #entry_block ⇒ Object
-
#initialize(name:, parameters: [], blocks: [], return_stamp: nil) ⇒ Function
constructor
A new instance of Function.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, parameters: [], blocks: [], return_stamp: nil) ⇒ Function
Returns a new instance of Function.
9 10 11 12 13 14 |
# File 'lib/kumi/ir/base/function.rb', line 9 def initialize(name:, parameters: [], blocks: [], return_stamp: nil) @name = name.to_sym @parameters = parameters.map(&:to_sym) @blocks = blocks.map { |b| ensure_block(b) } @return_stamp = return_stamp 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 |
#return_stamp ⇒ Object (readonly)
Returns the value of attribute return_stamp.
7 8 9 |
# File 'lib/kumi/ir/base/function.rb', line 7 def return_stamp @return_stamp end |
Instance Method Details
#append_block(block) ⇒ Object
20 21 22 |
# File 'lib/kumi/ir/base/function.rb', line 20 def append_block(block) @blocks << ensure_block(block) end |
#entry_block ⇒ Object
16 17 18 |
# File 'lib/kumi/ir/base/function.rb', line 16 def entry_block @blocks.first end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/kumi/ir/base/function.rb', line 24 def to_h { name:, parameters:, return_stamp:, blocks: @blocks.map { |b| { name: b.name, instructions: b.instructions.map(&:to_h) } } } end |