Class: Rubycc::Front::AST::CompoundLiteral

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

Overview

A compound literal "( type-name ) { initializer-list }" (ISO C 6.5.2.5). type is the resolved Rubycc::Type of the unnamed object the literal denotes, with any inferred "[]" array bound already completed by the parser (so "(int)1,2,3" carries int); initializer is the AST::InitializerList that fills it. In block scope the object has automatic storage lasting the enclosing block, so the literal is an lvalue: the generator lays it out on a stack object, initializes it, and yields the object's value the same way a variable of type would (a struct/union as its base address, an array decayed to an element pointer, a scalar as a load) — which is what lets "&(T)...", "(T)....member", a by-value argument and an assignment right-hand side all work. A compound literal in a static-storage-duration (file-scope) initializer is diagnosed as unsupported by the generator. token is the opening "(".

Instance Attribute Summary collapse

Instance Attribute Details

#initializerObject (readonly)

Returns the value of attribute initializer

Returns:

  • (Object)

    the current value of initializer



177
178
179
# File 'lib/rubycc/front/ast.rb', line 177

def initializer
  @initializer
end

#tokenObject (readonly)

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



177
178
179
# File 'lib/rubycc/front/ast.rb', line 177

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



177
178
179
# File 'lib/rubycc/front/ast.rb', line 177

def type
  @type
end