Changeset 64b6913 for src/SynTree/Type.h


Ignore:
Timestamp:
Mar 16, 2017, 8:19:39 AM (7 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/SynTree/Type.h

    r6e8bd43 r64b6913  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 15 23:28:33 2017
    13 // Update Count     : 89
     12// Last Modified On : Thu Mar 16 07:45:29 2017
     13// Update Count     : 90
    1414//
    1515
     
    2424class Type : public BaseSyntaxNode {
    2525  public:
     26        // enum must remain in the same order as the corresponding bit fields.
     27
     28        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };
     29        union StorageClasses {
     30                static const char * Names[];
     31                unsigned int val;
     32                struct {
     33                        bool is_extern : 1;
     34                        bool is_static : 1;
     35                        bool is_auto : 1;
     36                        bool is_register : 1;
     37                        bool is_threadlocal : 1;
     38                };
     39
     40                StorageClasses() : val( 0 ) {}
     41                StorageClasses( unsigned int val ) : val( val ) {}
     42                bool operator[]( unsigned int i ) const { return val & (1 << i); }
     43                bool any() const { return val != 0; }
     44                void print( std::ostream & os ) const {
     45                        if ( (*this).any() ) {                                          // any storage classes ?
     46                                for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) {
     47                                        if ( (*this)[i] ) {
     48                                                os << StorageClasses::Names[i] << ' ';
     49                                        } // if
     50                                } // for
     51                        } // if
     52                }
     53        }; // StorageClasses
     54
    2655        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
    2756        union Qualifiers {
Note: See TracChangeset for help on using the changeset viewer.