Class: Carbon::Compiler::Node::Definition::Function

Inherits:
Base
  • Object
show all
Defined in:
lib/carbon/compiler/node/definition/function.rb,
lib/carbon/compiler/node/definition/function/body.rb,
lib/carbon/compiler/node/definition/function/name.rb,
lib/carbon/compiler/node/definition/function/parameter.rb,
lib/carbon/compiler/node/definition/function/parameters.rb

Overview

A function definition. This contains information about the arguments to be passed to the function, the “klass” (type) or return type of the function, the body of a function (if an extern function, this is null), and the associated Project::Function information, when tied.

Defined Under Namespace

Classes: Body, Name, Parameter, Parameters

Instance Attribute Summary

Attributes inherited from Base

#children, #location

Instance Method Summary collapse

Methods inherited from Base

#[], #accept, #attributes!, #data, #data?, #each, #identity?, #initialize, #map!, mapping, #merge!, #type!, #update!

Constructor Details

This class inherits a constructor from Carbon::Compiler::Node::Base

Instance Method Details

#behavior?true

If this definition is a behavior definition. Functions are the only behavior definitions in a module.

Returns:

  • (true)


25
26
27
# File 'lib/carbon/compiler/node/definition/function.rb', line 25

def behavior?
  true
end

#genericsObject



37
38
39
# File 'lib/carbon/compiler/node/definition/function.rb', line 37

def generics
  @children[0].generics
end

#nameString

The name of the function. This is used in place of an actual node for various reasons.

Returns:

  • (String)


33
34
35
# File 'lib/carbon/compiler/node/definition/function.rb', line 33

def name
  @children[0].name.value
end