Sha256: 69ae0dc093a983328eab1c85cdd99a7bc594339f47abea5c81edad2dae419965

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# encoding: utf-8
# frozen_string_literal: true

require "carbon/compiler/node/definition/function/parameter"
require "carbon/compiler/node/definition/function/parameters"
require "carbon/compiler/node/definition/function/body"
require "carbon/compiler/node/definition/function/name"

module Carbon
  module Compiler
    module Node
      module Definition
        # 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.
        class Function < Base
          attributes _name: 0, parameters: 1, type: 2, body: 3

          # If this definition is a behavior definition.  Functions are the
          # only behavior definitions in a module.
          #
          # @return [true]
          def behavior?
            true
          end

          # The name of the function.  This is used in place of an actual
          # node for various reasons.
          #
          # @return [String]
          def name
            @children[0].name.value
          end

          def generics
            @children[0].generics
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carbon-compiler-0.2.0 lib/carbon/compiler/node/definition/function.rb