Ignore:
Timestamp:
Jun 19, 2018, 2:11:38 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
9a7a3b6
Parents:
704d11e
Message:

Add nodes for global scope type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r704d11e r47498bd  
    253253        return newnode;
    254254} // DeclarationNode::newFromTypedef
     255
     256DeclarationNode * DeclarationNode::newFromGlobalScope() {
     257        DeclarationNode * newnode = new DeclarationNode;
     258        newnode->type = new TypeData( TypeData::GlobalScope );
     259        return newnode;
     260}
    255261
    256262DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) {
     
    9981004                try {
    9991005                        Declaration * decl = cur->build();
    1000                         if ( decl ) {
    1001                                 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    1002                                         dwt->location = cur->location;
    1003                                         * out++ = dwt;
    1004                                 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    1005                                         StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->name );
    1006                                         auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    1007                                         obj->location = cur->location;
    1008                                         * out++ = obj;
    1009                                         delete agg;
    1010                                 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    1011                                         UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->name );
    1012                                         auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    1013                                         obj->location = cur->location;
    1014                                         * out++ = obj;
    1015                                 } // if
     1006                        assert( decl );
     1007                        if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
     1008                                dwt->location = cur->location;
     1009                                * out++ = dwt;
     1010                        } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
     1011                                // xxx - this might be where anonymous struct members are added - should be conditional on struct name
     1012                                StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->name );
     1013                                auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
     1014                                obj->location = cur->location;
     1015                                * out++ = obj;
     1016                                delete agg;
     1017                        } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
     1018                                UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->name );
     1019                                auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
     1020                                obj->location = cur->location;
     1021                                * out++ = obj;
    10161022                        } // if
    10171023                } catch( SemanticErrorException &e ) {
Note: See TracChangeset for help on using the changeset viewer.