Changeset 6cef439 for src


Ignore:
Timestamp:
Mar 6, 2024, 12:34:15 PM (19 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
b93c544, e72fc60
Parents:
1df26c3
Message:

Return 'TypeData *' from some parse rules. Moved TypeData construction over to that file.

Location:
src/Parser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r1df26c3 r6cef439  
    177177}
    178178
     179DeclarationNode * DeclarationNode::newFromTypeData( TypeData * type ) {
     180        DeclarationNode * newnode = new DeclarationNode;
     181        newnode->type = type;
     182        return newnode;
     183} // DeclarationNode::newFromTypeData
     184
    179185DeclarationNode * DeclarationNode::newStorageClass( ast::Storage::Classes sc ) {
    180186        DeclarationNode * newnode = new DeclarationNode;
     
    188194        return newnode;
    189195} // DeclarationNode::newFuncSpecifier
    190 
    191 DeclarationNode * DeclarationNode::newTypeQualifier( ast::CV::Qualifiers tq ) {
    192         DeclarationNode * newnode = new DeclarationNode;
    193         newnode->type = new TypeData();
    194         newnode->type->qualifiers = tq;
    195         return newnode;
    196 } // DeclarationNode::newQualifier
    197 
    198 DeclarationNode * DeclarationNode::newBasicType( BasicType bt ) {
    199         DeclarationNode * newnode = new DeclarationNode;
    200         newnode->type = new TypeData( TypeData::Basic );
    201         newnode->type->basictype = bt;
    202         return newnode;
    203 } // DeclarationNode::newBasicType
    204 
    205 DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) {
    206         DeclarationNode * newnode = new DeclarationNode;
    207         newnode->type = new TypeData( TypeData::Basic );
    208         newnode->type->complextype = ct;
    209         return newnode;
    210 } // DeclarationNode::newComplexType
    211 
    212 DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) {
    213         DeclarationNode * newnode = new DeclarationNode;
    214         newnode->type = new TypeData( TypeData::Basic );
    215         newnode->type->signedness = sn;
    216         return newnode;
    217 } // DeclarationNode::newSignedNess
    218 
    219 DeclarationNode * DeclarationNode::newLength( Length lnth ) {
    220         DeclarationNode * newnode = new DeclarationNode;
    221         newnode->type = new TypeData( TypeData::Basic );
    222         newnode->type->length = lnth;
    223         return newnode;
    224 } // DeclarationNode::newLength
    225 
    226 DeclarationNode * DeclarationNode::newForall( DeclarationNode * forall ) {
    227         DeclarationNode * newnode = new DeclarationNode;
    228         newnode->type = new TypeData( TypeData::Unknown );
    229         newnode->type->forall = forall;
    230         return newnode;
    231 } // DeclarationNode::newForall
    232 
    233 DeclarationNode * DeclarationNode::newFromGlobalScope() {
    234         DeclarationNode * newnode = new DeclarationNode;
    235         newnode->type = new TypeData( TypeData::GlobalScope );
    236         return newnode;
    237 }
    238 
    239 DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) {
    240         DeclarationNode * newnode = new DeclarationNode;
    241         newnode->type = new TypeData( TypeData::Qualified );
    242         newnode->type->qualified.parent = parent->type;
    243         newnode->type->qualified.child = child->type;
    244         parent->type = nullptr;
    245         child->type = nullptr;
    246         delete parent;
    247         delete child;
    248         return newnode;
    249 }
    250196
    251197DeclarationNode * DeclarationNode::newAggregate( ast::AggregateDecl::Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     
    312258}
    313259
    314 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) {
    315         DeclarationNode * newnode = new DeclarationNode;
    316         newnode->type = new TypeData( TypeData::SymbolicInst );
    317         newnode->type->symbolic.name = name;
    318         newnode->type->symbolic.isTypedef = true;
    319         newnode->type->symbolic.params = nullptr;
    320         return newnode;
    321 } // DeclarationNode::newFromTypedef
    322 
    323 DeclarationNode * DeclarationNode::newFromTypeGen( const string * name, ExpressionNode * params ) {
    324         DeclarationNode * newnode = new DeclarationNode;
    325         newnode->type = new TypeData( TypeData::SymbolicInst );
    326         newnode->type->symbolic.name = name;
    327         newnode->type->symbolic.isTypedef = false;
    328         newnode->type->symbolic.actuals = params;
    329         return newnode;
    330 } // DeclarationNode::newFromTypeGen
    331 
    332260DeclarationNode * DeclarationNode::newTypeParam( ast::TypeDecl::Kind tc, const string * name ) {
    333261        DeclarationNode * newnode = newName( name );
     
    423351        return newnode;
    424352}
    425 
    426 DeclarationNode * DeclarationNode::newVtableType( DeclarationNode * decl ) {
    427         DeclarationNode * newnode = new DeclarationNode;
    428         newnode->type = new TypeData( TypeData::Vtable );
    429         newnode->setBase( decl->type );
    430         return newnode;
    431 }
    432 
    433 DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) {
    434         DeclarationNode * newnode = new DeclarationNode;
    435         newnode->type = new TypeData( TypeData::Builtin );
    436         newnode->type->builtintype = bt;
    437         return newnode;
    438 } // DeclarationNode::newBuiltinType
    439353
    440354DeclarationNode * DeclarationNode::newFunction( const string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) {
  • src/Parser/DeclarationNode.h

    r1df26c3 r6cef439  
    4040        static const char * builtinTypeNames[];
    4141
     42        static DeclarationNode * newFromTypeData( TypeData * );
    4243        static DeclarationNode * newStorageClass( ast::Storage::Classes );
    4344        static DeclarationNode * newFuncSpecifier( ast::Function::Specs );
    44         static DeclarationNode * newTypeQualifier( ast::CV::Qualifiers );
    45         static DeclarationNode * newBasicType( BasicType );
    46         static DeclarationNode * newComplexType( ComplexType );
    47         static DeclarationNode * newSignedNess( Signedness );
    48         static DeclarationNode * newLength( Length );
    49         static DeclarationNode * newBuiltinType( BuiltinType );
    50         static DeclarationNode * newForall( DeclarationNode * );
    51         static DeclarationNode * newFromTypedef( const std::string * );
    52         static DeclarationNode * newFromGlobalScope();
    53         static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * );
    5445        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    5546        static DeclarationNode * newAggregate( ast::AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
     
    5950        static DeclarationNode * newEnumInLine( const std::string name );
    6051        static DeclarationNode * newName( const std::string * );
    61         static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params );
    6252        static DeclarationNode * newTypeParam( ast::TypeDecl::Kind, const std::string * );
    6353        static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts );
     
    7060        static DeclarationNode * newTuple( DeclarationNode * members );
    7161        static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false );
    72         static DeclarationNode * newVtableType( DeclarationNode * expr );
    7362        static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    7463        static DeclarationNode * newDirectiveStmt( StatementNode * stmt ); // gcc external directive statement
     
    163152}; // DeclarationNode
    164153
    165 ast::Type * buildType( TypeData * type );
    166 
    167154static inline ast::Type * maybeMoveBuildType( const DeclarationNode * orig ) {
    168155        ast::Type * ret = orig ? orig->buildType() : nullptr;
  • src/Parser/ExpressionNode.cc

    r1df26c3 r6cef439  
    2929#include "DeclarationNode.h"       // for DeclarationNode
    3030#include "InitializerNode.h"       // for InitializerNode
     31#include "TypeData.h"              // for addType, build_basic_type, build_c...
    3132#include "parserutility.h"         // for notZeroExpr
    3233
     
    316317                                v2 );
    317318                        ret = build_compoundLiteral( location,
    318                                 DeclarationNode::newBasicType(
    319                                         DeclarationNode::Int128
    320                                 )->addType(
    321                                         DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ),
     319                                DeclarationNode::newFromTypeData(
     320                                        addType(
     321                                                build_basic_type( DeclarationNode::Int128 ),
     322                                                build_signedness( DeclarationNode::Unsigned ) ) ),
    322323                                new InitializerNode(
    323                                         (InitializerNode *)(new InitializerNode( new ExpressionNode( v2 == 0 ? ret2 : ret ) ))->set_last( new InitializerNode( new ExpressionNode( v2 == 0 ? ret : ret2 ) ) ), true )
     324                                        (new InitializerNode( new ExpressionNode( v2 == 0 ? ret2 : ret ) ))->set_last( new InitializerNode( new ExpressionNode( v2 == 0 ? ret : ret2 ) ) ), true )
    324325                        );
    325326                } else {                                                                                // explicit length, (length_type)constant
  • src/Parser/TypeData.cc

    r1df26c3 r6cef439  
    478478}
    479479
    480 
    481480TypeData * TypeData::getLastBase() {
    482481        TypeData * cur = this;
     
    487486void TypeData::setLastBase( TypeData * newBase ) {
    488487        getLastBase()->base = newBase;
     488}
     489
     490
     491TypeData * build_type_qualifier( ast::CV::Qualifiers tq ) {
     492        TypeData * type = new TypeData;
     493        type->qualifiers = tq;
     494        return type;
     495}
     496
     497TypeData * build_basic_type( DeclarationNode::BasicType basic ) {
     498        TypeData * type = new TypeData( TypeData::Basic );
     499        type->basictype = basic;
     500        return type;
     501}
     502
     503TypeData * build_complex_type( DeclarationNode::ComplexType complex ) {
     504        TypeData * type = new TypeData( TypeData::Basic );
     505        type->complextype = complex;
     506        return type;
     507}
     508
     509TypeData * build_signedness( DeclarationNode::Signedness signedness ) {
     510        TypeData * type = new TypeData( TypeData::Basic );
     511        type->signedness = signedness;
     512        return type;
     513}
     514
     515TypeData * build_builtin_type( DeclarationNode::BuiltinType bit ) {
     516        TypeData * type = new TypeData( TypeData::Builtin );
     517        type->builtintype = bit;
     518        return type;
     519}
     520
     521TypeData * build_length( DeclarationNode::Length length ) {
     522        TypeData * type = new TypeData( TypeData::Basic );
     523        type->length = length;
     524        return type;
     525}
     526
     527TypeData * build_forall( DeclarationNode * forall ) {
     528        TypeData * type = new TypeData( TypeData::Unknown );
     529        type->forall = forall;
     530        return type;
     531}
     532
     533TypeData * build_global_scope() {
     534        return new TypeData( TypeData::GlobalScope );
     535}
     536
     537TypeData * build_qualified_type( TypeData * parent, TypeData * child ) {
     538        TypeData * type = new TypeData( TypeData::Qualified );
     539        type->qualified.parent = parent;
     540        type->qualified.child = child;
     541        return type;
     542}
     543
     544TypeData * build_typedef( const std::string * name ) {
     545        TypeData * type = new TypeData( TypeData::SymbolicInst );
     546        type->symbolic.name = name;
     547        type->symbolic.isTypedef = true;
     548        type->symbolic.actuals = nullptr;
     549        return type;
     550}
     551
     552TypeData * build_type_gen( const std::string * name, ExpressionNode * params ) {
     553        TypeData * type = new TypeData( TypeData::SymbolicInst );
     554        type->symbolic.name = name;
     555        type->symbolic.isTypedef = false;
     556        type->symbolic.actuals = params;
     557        return type;
     558}
     559
     560TypeData * build_vtable_type( TypeData * base ) {
     561        TypeData * type = new TypeData( TypeData::Vtable );
     562        type->base = base;
     563        return type;
    489564}
    490565
     
    627702                return rtype;
    628703        } // if
     704}
     705
     706TypeData * addType( TypeData * ltype, TypeData * rtype ) {
     707        std::vector<ast::ptr<ast::Attribute>> attributes;
     708        return addType( ltype, rtype, attributes );
    629709}
    630710
  • src/Parser/TypeData.h

    r1df26c3 r6cef439  
    116116};
    117117
     118
     119TypeData * build_type_qualifier( ast::CV::Qualifiers );
     120TypeData * build_basic_type( DeclarationNode::BasicType );
     121TypeData * build_complex_type( DeclarationNode::ComplexType );
     122TypeData * build_signedness( DeclarationNode::Signedness );
     123TypeData * build_builtin_type( DeclarationNode::BuiltinType );
     124TypeData * build_length( DeclarationNode::Length );
     125TypeData * build_forall( DeclarationNode * );
     126TypeData * build_global_scope();
     127TypeData * build_qualified_type( TypeData *, TypeData * );
     128TypeData * build_typedef( const std::string * name );
     129TypeData * build_type_gen( const std::string * name, ExpressionNode * params );
     130TypeData * build_vtable_type( TypeData * );
     131
    118132TypeData * addQualifiers( TypeData * ltype, TypeData * rtype );
    119133TypeData * addType( TypeData * ltype, TypeData * rtype, std::vector<ast::ptr<ast::Attribute>> & );
     134TypeData * addType( TypeData * ltype, TypeData * rtype );
    120135TypeData * cloneBaseType( TypeData * type, TypeData * other );
    121136TypeData * makeNewBase( TypeData * type );
     137
    122138
    123139ast::Type * typebuild( const TypeData * );
     
    144160void buildKRFunction( const TypeData::Function_t & function );
    145161
     162static inline ast::Type * maybeMoveBuildType( TypeData * type ) {
     163        ast::Type * ret = type ? typebuild( type ) : nullptr;
     164        delete type;
     165        return ret;
     166}
     167
    146168// Local Variables: //
    147169// tab-width: 4 //
  • src/Parser/TypedefTable.cc

    r1df26c3 r6cef439  
    2020#include <string>                                                                               // for string
    2121#include <iostream>                                                                             // for iostream
     22
     23struct TypeData;
    2224
    2325#include "ExpressionNode.h"                                                             // for LabelNode
  • src/Parser/parser.yy

    r1df26c3 r6cef439  
    317317
    318318%union {
     319        // A raw token can be used.
    319320        Token tok;
     321
     322        // The general node types hold some generic node or list of nodes.
     323        DeclarationNode * decl;
     324        InitializerNode * init;
    320325        ExpressionNode * expr;
    321         DeclarationNode * decl;
    322         ast::AggregateDecl::Aggregate aggKey;
    323         ast::TypeDecl::Kind tclass;
    324326        StatementNode * stmt;
    325327        ClauseNode * clause;
    326         ast::WaitForStmt * wfs;
    327     ast::WaitUntilStmt::ClauseNode * wucn;
     328        TypeData * type;
     329
     330        // Special "nodes" containing compound information.
    328331        CondCtl * ifctl;
    329332        ForCtrl * forctl;
    330333        LabelNode * labels;
    331         InitializerNode * init;
     334
     335        // Various flags and single values that become fields later.
     336        ast::AggregateDecl::Aggregate aggKey;
     337        ast::TypeDecl::Kind tclass;
    332338        OperKinds oper;
    333         std::string * str;
    334339        bool is_volatile;
    335340        EnumHiding enum_hiding;
    336341        ast::ExceptionKind except_kind;
     342        // String passes ownership with it.
     343        std::string * str;
     344
     345        // Narrower node types are used to avoid constant unwrapping.
     346        ast::WaitForStmt * wfs;
     347        ast::WaitUntilStmt::ClauseNode * wucn;
    337348        ast::GenericExpr * genexpr;
    338349}
     
    464475
    465476%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type
    466 %type<decl> vtable vtable_opt default_opt
     477%type<type> basic_type_name_type
     478%type<type> vtable vtable_opt default_opt
    467479
    468480%type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
     
    519531%type<decl> type_declarator type_declarator_name type_declaring_list
    520532
    521 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name
     533%type<decl> type_declaration_specifier type_type_specifier
     534%type<type> type_name typegen_name
    522535%type<decl> typedef_name typedef_declaration typedef_expression
    523536
     
    532545%type<expr> type_parameters_opt type_list array_type_list // array_dimension_list
    533546
    534 %type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
     547%type<decl> type_qualifier forall type_qualifier_list_opt type_qualifier_list
     548%type<type> type_qualifier_name
    535549%type<decl> type_specifier type_specifier_nobody
    536550
     
    687701                { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); }
    688702        | TYPEDIMname                                                                           // CFA, generic length argument
    689                 // { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( DeclarationNode::newFromTypedef( $1 ) ) ) ); }
    690                 // { $$ = new ExpressionNode( build_varref( $1 ) ); }
    691703                { $$ = new ExpressionNode( build_dimensionref( yylloc, $1 ) ); }
    692704        | tuple
     
    696708                { $$ = new ExpressionNode( new ast::StmtExpr( yylloc, dynamic_cast<ast::CompoundStmt *>( maybeMoveBuild( $2 ) ) ) ); }
    697709        | type_name '.' identifier                                                      // CFA, nested type
    698                 { $$ = new ExpressionNode( build_qualified_expr( yylloc, $1, build_varref( yylloc, $3 ) ) ); }
     710                { $$ = new ExpressionNode( build_qualified_expr( yylloc, DeclarationNode::newFromTypeData( $1 ), build_varref( yylloc, $3 ) ) ); }
    699711        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
    700712                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    978990                { $$ = new ExpressionNode( build_keyword_cast( yylloc, $2, $5 ) ); }
    979991        | '(' VIRTUAL ')' cast_expression                                       // CFA
    980                 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); }
     992                { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $4 ), nullptr ) ); }
    981993        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    982994                { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); }
     
    22152227type_qualifier:
    22162228        type_qualifier_name
     2229                { $$ = DeclarationNode::newFromTypeData( $1 ); }
    22172230        | attribute                                                                                     // trick handles most attribute locations
    22182231        ;
     
    22202233type_qualifier_name:
    22212234        CONST
    2222                 { $$ = DeclarationNode::newTypeQualifier( ast::CV::Const ); }
     2235                { $$ = build_type_qualifier( ast::CV::Const ); }
    22232236        | RESTRICT
    2224                 { $$ = DeclarationNode::newTypeQualifier( ast::CV::Restrict ); }
     2237                { $$ = build_type_qualifier( ast::CV::Restrict ); }
    22252238        | VOLATILE
    2226                 { $$ = DeclarationNode::newTypeQualifier( ast::CV::Volatile ); }
     2239                { $$ = build_type_qualifier( ast::CV::Volatile ); }
    22272240        | ATOMIC
    2228                 { $$ = DeclarationNode::newTypeQualifier( ast::CV::Atomic ); }
     2241                { $$ = build_type_qualifier( ast::CV::Atomic ); }
    22292242
    22302243                // forall must be a CV qualifier because it can appear in places where SC qualifiers are disallowed.
     
    22332246                //   void bar( static int ); // static disallowed (gcc/CFA)
    22342247        | forall
    2235                 { $$ = DeclarationNode::newForall( $1 ); }
     2248                { $$ = build_forall( $1 ); }
    22362249        ;
    22372250
     
    22832296
    22842297basic_type_name:
     2298        basic_type_name_type
     2299                { $$ = DeclarationNode::newFromTypeData( $1 ); }
     2300        ;
     2301
     2302// Just an intermediate value for conversion.
     2303basic_type_name_type:
    22852304        VOID
    2286                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     2305                { $$ = build_basic_type( DeclarationNode::Void ); }
    22872306        | BOOL                                                                                          // C99
    2288                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); }
     2307                { $$ = build_basic_type( DeclarationNode::Bool ); }
    22892308        | CHAR
    2290                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); }
     2309                { $$ = build_basic_type( DeclarationNode::Char ); }
    22912310        | INT
    2292                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); }
     2311                { $$ = build_basic_type( DeclarationNode::Int ); }
    22932312        | INT128
    2294                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); }
     2313                { $$ = build_basic_type( DeclarationNode::Int128 ); }
    22952314        | UINT128
    2296                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ); }
     2315                { $$ = addType( build_basic_type( DeclarationNode::Int128 ), build_signedness( DeclarationNode::Unsigned ) ); }
    22972316        | FLOAT
    2298                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
     2317                { $$ = build_basic_type( DeclarationNode::Float ); }
    22992318        | DOUBLE
    2300                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Double ); }
     2319                { $$ = build_basic_type( DeclarationNode::Double ); }
    23012320        | uuFLOAT80
    2302                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat80 ); }
     2321                { $$ = build_basic_type( DeclarationNode::uuFloat80 ); }
    23032322        | uuFLOAT128
    2304                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uuFloat128 ); }
     2323                { $$ = build_basic_type( DeclarationNode::uuFloat128 ); }
    23052324        | uFLOAT16
    2306                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat16 ); }
     2325                { $$ = build_basic_type( DeclarationNode::uFloat16 ); }
    23072326        | uFLOAT32
    2308                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32 ); }
     2327                { $$ = build_basic_type( DeclarationNode::uFloat32 ); }
    23092328        | uFLOAT32X
    2310                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat32x ); }
     2329                { $$ = build_basic_type( DeclarationNode::uFloat32x ); }
    23112330        | uFLOAT64
    2312                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64 ); }
     2331                { $$ = build_basic_type( DeclarationNode::uFloat64 ); }
    23132332        | uFLOAT64X
    2314                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat64x ); }
     2333                { $$ = build_basic_type( DeclarationNode::uFloat64x ); }
    23152334        | uFLOAT128
    2316                 { $$ = DeclarationNode::newBasicType( DeclarationNode::uFloat128 ); }
     2335                { $$ = build_basic_type( DeclarationNode::uFloat128 ); }
    23172336        | DECIMAL32
    23182337                { SemanticError( yylloc, "_Decimal32 is currently unimplemented." ); $$ = nullptr; }
     
    23222341                { SemanticError( yylloc, "_Decimal128 is currently unimplemented." ); $$ = nullptr; }
    23232342        | COMPLEX                                                                                       // C99
    2324                 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); }
     2343                { $$ = build_complex_type( DeclarationNode::Complex ); }
    23252344        | IMAGINARY                                                                                     // C99
    2326                 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
     2345                { $$ = build_complex_type( DeclarationNode::Imaginary ); }
    23272346        | SIGNED
    2328                 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); }
     2347                { $$ = build_signedness( DeclarationNode::Signed ); }
    23292348        | UNSIGNED
    2330                 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); }
     2349                { $$ = build_signedness( DeclarationNode::Unsigned ); }
    23312350        | SHORT
    2332                 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); }
     2351                { $$ = build_length( DeclarationNode::Short ); }
    23332352        | LONG
    2334                 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
     2353                { $$ = build_length( DeclarationNode::Long ); }
    23352354        | VA_LIST                                                                                       // GCC, __builtin_va_list
    2336                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     2355                { $$ = build_builtin_type( DeclarationNode::Valist ); }
    23372356        | AUTO_TYPE
    2338                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }
     2357                { $$ = build_builtin_type( DeclarationNode::AutoType ); }
    23392358        | vtable
    23402359        ;
     
    23482367vtable:
    23492368        VTABLE '(' type_name ')' default_opt
    2350                 { $$ = DeclarationNode::newVtableType( $3 ); }
    2351                 // { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
     2369                { $$ = build_vtable_type( $3 ); }
    23522370        ;
    23532371
     
    23992417                { $$ = DeclarationNode::newTypeof( $3, true ); }
    24002418        | ZERO_T                                                                                        // CFA
    2401                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     2419                { $$ = DeclarationNode::newFromTypeData( build_builtin_type( DeclarationNode::Zero ) ); }
    24022420        | ONE_T                                                                                         // CFA
    2403                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
     2421                { $$ = DeclarationNode::newFromTypeData( build_builtin_type( DeclarationNode::One ) ); }
    24042422        ;
    24052423
     
    24572475type_type_specifier:                                                                    // typedef types
    24582476        type_name
     2477                { $$ = DeclarationNode::newFromTypeData( $1 ); }
    24592478        | type_qualifier_list type_name
    2460                 { $$ = $2->addQualifiers( $1 ); }
     2479                { $$ = DeclarationNode::newFromTypeData( $2 )->addQualifiers( $1 ); }
    24612480        | type_type_specifier type_qualifier
    24622481                { $$ = $1->addQualifiers( $2 ); }
     
    24652484type_name:
    24662485        TYPEDEFname
    2467                 { $$ = DeclarationNode::newFromTypedef( $1 ); }
     2486                { $$ = build_typedef( $1 ); }
    24682487        | '.' TYPEDEFname
    2469                 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), DeclarationNode::newFromTypedef( $2 ) ); }
     2488                { $$ = build_qualified_type( build_global_scope(), build_typedef( $2 ) ); }
    24702489        | type_name '.' TYPEDEFname
    2471                 { $$ = DeclarationNode::newQualifiedType( $1, DeclarationNode::newFromTypedef( $3 ) ); }
     2490                { $$ = build_qualified_type( $1, build_typedef( $3 ) ); }
    24722491        | typegen_name
    24732492        | '.' typegen_name
    2474                 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), $2 ); }
     2493                { $$ = build_qualified_type( build_global_scope(), $2 ); }
    24752494        | type_name '.' typegen_name
    2476                 { $$ = DeclarationNode::newQualifiedType( $1, $3 ); }
     2495                { $$ = build_qualified_type( $1, $3 ); }
    24772496        ;
    24782497
    24792498typegen_name:                                                                                   // CFA
    24802499        TYPEGENname
    2481                 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
     2500                { $$ = build_type_gen( $1, nullptr ); }
    24822501        | TYPEGENname '(' ')'
    2483                 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); }
     2502                { $$ = build_type_gen( $1, nullptr ); }
    24842503        | TYPEGENname '(' type_list ')'
    2485                 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); }
     2504                { $$ = build_type_gen( $1, $3 ); }
    24862505        ;
    24872506
     
    25192538          '{' field_declaration_list_opt '}' type_parameters_opt
    25202539                {
    2521                         DeclarationNode::newFromTypedef( $3 );
     2540                        DeclarationNode::newFromTypeData( build_typedef( $3 ) );
    25222541                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
    25232542                }
     
    25292548          '{' field_declaration_list_opt '}' type_parameters_opt
    25302549                {
    2531                         DeclarationNode::newFromTypeGen( $3, nullptr );
     2550                        DeclarationNode::newFromTypeData( build_type_gen( $3, nullptr ) );
    25322551                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
    25332552                }
     
    25542573                        // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is
    25552574                        // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and
    2556                         // delete newFromTypeGen.
    2557                         if ( $3->type->kind == TypeData::SymbolicInst && ! $3->type->symbolic.isTypedef ) {
    2558                                 $$ = $3->addQualifiers( $2 );
     2575                        if ( $3->kind == TypeData::SymbolicInst && ! $3->symbolic.isTypedef ) {
     2576                                $$ = DeclarationNode::newFromTypeData( $3 )->addQualifiers( $2 );
    25592577                        } else {
    2560                                 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 );
    2561                                 $3->type->symbolic.name = nullptr;                      // copied to $$
    2562                                 $3->type->symbolic.actuals = nullptr;
     2578                                $$ = DeclarationNode::newAggregate( $1, $3->symbolic.name, $3->symbolic.actuals, nullptr, false )->addQualifiers( $2 );
     2579                                $3->symbolic.name = nullptr;                    // copied to $$
     2580                                $3->symbolic.actuals = nullptr;
    25632581                                delete $3;
    25642582                        }
     
    27852803        | ENUM attribute_list_opt type_name
    27862804                {
    2787                         typedefTable.makeTypedef( *$3->type->symbolic.name, "enum_type_nobody 2" );
    2788                         $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 );
     2805                        typedefTable.makeTypedef( *$3->symbolic.name, "enum_type_nobody 2" );
     2806                        $$ = DeclarationNode::newEnum( $3->symbolic.name, nullptr, false, false )->addQualifiers( $2 );
    27892807                }
    27902808        ;
     
    27942812                { $$ = DeclarationNode::newEnumValueGeneric( $2, $3 ); }
    27952813        | INLINE type_name
    2796                 { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); }
     2814                { $$ = DeclarationNode::newEnumInLine( *$2->symbolic.name ); }
    27972815        | enumerator_list ',' visible_hide_opt identifier_or_type_name enumerator_value_opt
    27982816                { $$ = $1->set_last( DeclarationNode::newEnumValueGeneric( $4, $5 ) ); }
     
    28392857cfa_parameter_list_ellipsis_opt:                                                // CFA, abstract + real
    28402858        // empty
    2841                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     2859                { $$ = DeclarationNode::newFromTypeData( build_basic_type( DeclarationNode::Void ) ); }
    28422860        | ELLIPSIS
    28432861                { $$ = nullptr; }
     
    37753793                { $$ = $1->addQualifiers( $2 ); }
    37763794        | '&' MUTEX paren_identifier attribute_list_opt
    3777                 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( ast::CV::Mutex ),
     3795                { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newFromTypeData( build_type_qualifier( ast::CV::Mutex ) ),
    37783796                                                                                                                        OperKinds::AddressOf ) )->addQualifiers( $4 ); }
    37793797        | identifier_parameter_ptr
     
    38263844                { $$ = $1->addQualifiers( $2 ); }
    38273845        | '&' MUTEX typedef_name attribute_list_opt
    3828                 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( ast::CV::Mutex ),
     3846                { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newFromTypeData( build_type_qualifier( ast::CV::Mutex ) ),
    38293847                                                                                                                        OperKinds::AddressOf ) )->addQualifiers( $4 ); }
    38303848        | type_parameter_ptr
     
    40104028        abstract_parameter_ptr
    40114029        | '&' MUTEX attribute_list_opt
    4012                 { $$ = DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( ast::CV::Mutex ), OperKinds::AddressOf )->addQualifiers( $3 ); }
     4030                { $$ = DeclarationNode::newPointer( DeclarationNode::newFromTypeData( build_type_qualifier( ast::CV::Mutex ) ), OperKinds::AddressOf )->addQualifiers( $3 ); }
    40134031        | abstract_parameter_array attribute_list_opt
    40144032                { $$ = $1->addQualifiers( $2 ); }
Note: See TracChangeset for help on using the changeset viewer.