Class: Cry::Codegen::CrystalFunction::Declaration
- Inherits:
-
Object
- Object
- Cry::Codegen::CrystalFunction::Declaration
- Defined in:
- lib/cry/codegen/crystal_function.rb
Instance Attribute Summary collapse
-
#arg_names ⇒ Object
Returns the value of attribute arg_names.
-
#arg_types ⇒ Object
Returns the value of attribute arg_types.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ret_type ⇒ Object
Returns the value of attribute ret_type.
Instance Method Summary collapse
-
#initialize(decl: 'fun') ⇒ Declaration
constructor
A new instance of Declaration.
- #source ⇒ Object
Constructor Details
#initialize(decl: 'fun') ⇒ Declaration
Returns a new instance of Declaration.
7 8 9 10 11 |
# File 'lib/cry/codegen/crystal_function.rb', line 7 def initialize(decl: 'fun') @arg_names = [] @arg_types = [] @decl = decl end |
Instance Attribute Details
#arg_names ⇒ Object
Returns the value of attribute arg_names.
5 6 7 |
# File 'lib/cry/codegen/crystal_function.rb', line 5 def arg_names @arg_names end |
#arg_types ⇒ Object
Returns the value of attribute arg_types.
5 6 7 |
# File 'lib/cry/codegen/crystal_function.rb', line 5 def arg_types @arg_types end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/cry/codegen/crystal_function.rb', line 5 def name @name end |
#ret_type ⇒ Object
Returns the value of attribute ret_type.
5 6 7 |
# File 'lib/cry/codegen/crystal_function.rb', line 5 def ret_type @ret_type end |
Instance Method Details
#source ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/cry/codegen/crystal_function.rb', line 13 def source raise 'name is not set' unless @name raise 'size of arg_names and arg_types are not same' unless @arg_names.size == @arg_types.size args = arg_names.zip(arg_types).map do |n, t| "#{n} : #{t}" end.join(', ') "#{@decl} #{@name}(#{args}) : #{@ret_type}" end |