Changeset 68fe077a for src/SynTree


Ignore:
Timestamp:
Mar 16, 2017, 8:23:42 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
git-author:
Peter A. Buhr <pabuhr@…> (03/16/17 08:19:39)
git-committer:
Peter A. Buhr <pabuhr@…> (03/16/17 08:23:42)
Message:

move type StorageClasses? from DeclarationNode? to Type

Location:
src/SynTree
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    r6e8bd43 r68fe077a  
    1010// Created On       : Sun May 17 23:56:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:31:47 2017
    13 // Update Count     : 19
     12// Last Modified On : Thu Mar 16 07:49:07 2017
     13// Update Count     : 20
    1414//
    1515
     
    2020
    2121
    22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {
     22AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, Type::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {
    2323}
    2424
  • src/SynTree/Declaration.cc

    r6e8bd43 r68fe077a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:31:11 2017
    13 // Update Count     : 23
     12// Last Modified On : Thu Mar 16 07:49:18 2017
     13// Update Count     : 24
    1414//
    1515
     
    2727static IdMapType idMap;
    2828
    29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage )
     29Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage )
    3030                : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) {
    3131}
     
    6666
    6767
    68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
     68AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
    6969}
    7070
  • src/SynTree/Declaration.h

    r6e8bd43 r68fe077a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:40:42 2017
    13 // Update Count     : 113
     12// Last Modified On : Thu Mar 16 07:48:23 2017
     13// Update Count     : 117
    1414//
    1515
     
    2828class Declaration : public BaseSyntaxNode {
    2929  public:
    30         Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage );
     30        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    3131        Declaration( const Declaration &other );
    3232        virtual ~Declaration();
     
    3535        void set_name( std::string newValue ) { name = newValue; }
    3636
    37         DeclarationNode::StorageClasses get_storageClasses() const { return storageClasses; }
     37        Type::StorageClasses get_storageClasses() const { return storageClasses; }
    3838
    3939        LinkageSpec::Spec get_linkage() const { return linkage; }
     
    5656  private:
    5757        std::string name;
    58         DeclarationNode::StorageClasses storageClasses;
     58        Type::StorageClasses storageClasses;
    5959        LinkageSpec::Spec linkage;
    6060        UniqueId uniqueId;
     
    6464class DeclarationWithType : public Declaration {
    6565  public:
    66         DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs );
     66        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs );
    6767        DeclarationWithType( const DeclarationWithType &other );
    6868        virtual ~DeclarationWithType();
     
    104104        typedef DeclarationWithType Parent;
    105105  public:
    106         ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
     106        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    107107                                const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );
    108108        ObjectDecl( const ObjectDecl &other );
     
    132132        typedef DeclarationWithType Parent;
    133133  public:
    134         FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
     134        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    135135                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );
    136136        FunctionDecl( const FunctionDecl &other );
     
    158158        typedef Declaration Parent;
    159159  public:
    160         NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type );
     160        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    161161        NamedTypeDecl( const NamedTypeDecl &other );
    162162        virtual ~NamedTypeDecl();
     
    193193        };
    194194
    195         TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind );
     195        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind );
    196196        TypeDecl( const TypeDecl &other );
    197197
     
    214214        typedef NamedTypeDecl Parent;
    215215  public:
    216         TypedefDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
     216        TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
    217217        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    218218
  • src/SynTree/DeclarationWithType.cc

    r6e8bd43 r68fe077a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:32:14 2017
    13 // Update Count     : 23
     12// Last Modified On : Thu Mar 16 07:49:27 2017
     13// Update Count     : 24
    1414//
    1515
     
    1919#include "Common/utility.h"
    2020
    21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs )
     21DeclarationWithType::DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs )
    2222        : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) {
    2323}
  • src/SynTree/FunctionDecl.cc

    r6e8bd43 r68fe077a  
    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:33:43 2017
    13 // Update Count     : 72
     12// Last Modified On : Thu Mar 16 07:49:35 2017
     13// Update Count     : 73
    1414//
    1515
     
    2626extern bool translation_unit_nomain;
    2727
    28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )
     28FunctionDecl::FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )
    2929        : Parent( name, scs, linkage, attributes, fs ), type( type ), statements( statements ) {
    3030        // hack forcing the function "main" to have Cforall linkage to replace main even if it is inside an extern
  • src/SynTree/NamedTypeDecl.cc

    r6e8bd43 r68fe077a  
    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:25:41 2017
    13 // Update Count     : 12
     12// Last Modified On : Thu Mar 16 07:49:44 2017
     13// Update Count     : 13
    1414//
    1515
     
    1818#include "Common/utility.h"
    1919
    20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *base )
     20NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
    2121        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
    2222
  • src/SynTree/ObjectDecl.cc

    r6e8bd43 r68fe077a  
    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:26:22 2017
    13 // Update Count     : 57
     12// Last Modified On : Thu Mar 16 07:49:51 2017
     13// Update Count     : 58
    1414//
    1515
     
    2222#include "Statement.h"
    2323
    24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )
     24ObjectDecl::ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )
    2525        : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
    2626}
  • src/SynTree/Type.cc

    r6e8bd43 r68fe077a  
    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:14:35 2017
    13 // Update Count     : 19
     12// Last Modified On : Thu Mar 16 07:57:45 2017
     13// Update Count     : 20
    1414//
    1515
     
    5959}
    6060
     61// These must remain in the same order as the corresponding bit fields.
     62const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" };
    6163const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
    6264
  • src/SynTree/Type.h

    r6e8bd43 r68fe077a  
    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 {
  • src/SynTree/TypeDecl.cc

    r6e8bd43 r68fe077a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:39:09 2017
    13 // Update Count     : 4
     12// Last Modified On : Thu Mar 16 07:49:58 2017
     13// Update Count     : 5
    1414//
    1515
     
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {
     20TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {
    2121}
    2222
Note: See TracChangeset for help on using the changeset viewer.