Class: Rubycc::Front::AST::Parameter

Inherits:
Data
  • Object
show all
Defined in:
lib/rubycc/front/ast.rb

Overview

A single function parameter. name is the identifier String, or nil for an unnamed parameter in a prototype (e.g. "int f(int, int);"). type is the parameter's Rubycc::Type (int, char or a pointer; never void, except as a pointer's target). const is true when the parameter object is top-level const-qualified ("int f(const int x)"), computed after the array/function-to-pointer adjustment, so the generator can reject writes to it.

incoming_type is the type the caller hands over when that differs from the declared one, and nil (the common case) when the two coincide. Only an old-style (identifier-list) definition can separate them: such a function has no prototype, so its arguments arrive default-argument promoted (6.9.1p10 with 6.5.2.2p6) — a float parameter is passed a double, a char/short/_Bool parameter an int — and the body still sees the narrow object it declared. #abi_type is what the calling convention and the function's own type are built from; type is what the body reads and writes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, token:, const:, incoming_type: nil) ⇒ Parameter

Returns a new instance of Parameter.



474
475
476
# File 'lib/rubycc/front/ast.rb', line 474

def initialize(name:, type:, token:, const:, incoming_type: nil)
  super
end

Instance Attribute Details

#constObject (readonly)

Returns the value of attribute const

Returns:

  • (Object)

    the current value of const



473
474
475
# File 'lib/rubycc/front/ast.rb', line 473

def const
  @const
end

#incoming_typeObject (readonly)

Returns the value of attribute incoming_type

Returns:

  • (Object)

    the current value of incoming_type



473
474
475
# File 'lib/rubycc/front/ast.rb', line 473

def incoming_type
  @incoming_type
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



473
474
475
# File 'lib/rubycc/front/ast.rb', line 473

def name
  @name
end

#tokenObject (readonly)

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



473
474
475
# File 'lib/rubycc/front/ast.rb', line 473

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



473
474
475
# File 'lib/rubycc/front/ast.rb', line 473

def type
  @type
end

Instance Method Details

#abi_typeObject

The type this parameter occupies an ABI slot as.



479
480
481
# File 'lib/rubycc/front/ast.rb', line 479

def abi_type
  incoming_type || type
end