Class: Chelsy::Function

Inherits:
Declarative show all
Defined in:
lib/chelsy/ast.rb

Overview

== 6.9.1 Function definition

Instance Attribute Summary collapse

Attributes inherited from Declarative

#storage

Attributes inherited from Element

#fragments, #post_fragments

Instance Method Summary collapse

Methods inherited from Declarative

#extern?, #init, #static?

Constructor Details

#initialize(name, return_type, params, inline: false, **rest, &block) ⇒ Function

Returns a new instance of Function.



1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
# File 'lib/chelsy/ast.rb', line 1142

def initialize(name, return_type, params, inline: false, **rest, &block)
  @name = Syntax::Ident.ensure(name)
  @return_type = Syntax::Type.ensure(return_type)
  @params = ParamList.new(params)

  @body = Block.new
  block.call(@body)

  super(**rest)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



1140
1141
1142
# File 'lib/chelsy/ast.rb', line 1140

def body
  @body
end

#nameObject (readonly)

Returns the value of attribute name.



1140
1141
1142
# File 'lib/chelsy/ast.rb', line 1140

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



1140
1141
1142
# File 'lib/chelsy/ast.rb', line 1140

def params
  @params
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



1140
1141
1142
# File 'lib/chelsy/ast.rb', line 1140

def return_type
  @return_type
end