Ignore:
Timestamp:
Mar 16, 2017, 8:19:39 AM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
26ba208
Parents:
6e8bd43
Message:

move type StorageClasses? from DeclarationNode? to Type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r6e8bd43 r64b6913  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 15 23:36:49 2017
    13 // Update Count     : 997
     12// Last Modified On : Thu Mar 16 07:59:40 2017
     13// Update Count     : 1003
    1414//
    1515
     
    3333
    3434// These must remain in the same order as the corresponding DeclarationNode enumerations.
    35 const char * DeclarationNode::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" };
    3635const char * DeclarationNode::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };
    3736const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" };
     
    181180
    182181
    183 DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) {
     182DeclarationNode * DeclarationNode::newStorageClass( Type::StorageClasses sc ) {
    184183        DeclarationNode * newnode = new DeclarationNode;
    185184        newnode->storageClasses = sc;
     
    458457        if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ?
    459458                if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ?
    460                         for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { // find duplicates
     459                        for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates
    461460                                if ( storageClasses[i] && src->storageClasses[i] ) {
    462                                         appendError( error, string( "duplicate " ) + StorageClasses::Names[i] );
     461                                        appendError( error, string( "duplicate " ) + Type::StorageClasses::Names[i] );
    463462                                } // if
    464463                        } // for
    465464                        // src is the new item being added and has a single bit
    466465                } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ?
    467                         appendError( error, string( "conflicting " ) + StorageClasses::Names[ffs( storageClasses.val ) - 1] +
    468                                                  " & " + StorageClasses::Names[ffs( src->storageClasses.val ) - 1] );
     466                        appendError( error, string( "conflicting " ) + Type::StorageClasses::Names[ffs( storageClasses.val ) - 1] +
     467                                                 " & " + Type::StorageClasses::Names[ffs( src->storageClasses.val ) - 1] );
    469468                        src->storageClasses.val = 0;                            // FIX to preserve invariant of one basic storage specifier
    470469                } // if
     
    970969                                } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    971970                                        StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
    972                                         auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );
     971                                        auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    973972                                        obj->location = cur->location;
    974973                                        * out++ = obj;
     
    976975                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    977976                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
    978                                         auto obj = new ObjectDecl( "", DeclarationNode::StorageClasses(), linkage, nullptr, inst, nullptr );
     977                                        auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    979978                                        obj->location = cur->location;
    980979                                        * out++ = obj;
     
    10231022                assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." );
    10241023                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1025                 TypeDecl * ret = new TypeDecl( *name, DeclarationNode::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );
     1024                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );
    10261025                buildList( variable.assertions, ret->get_assertions() );
    10271026                return ret;
Note: See TracChangeset for help on using the changeset viewer.