Changeset ddfd945


Ignore:
Timestamp:
Mar 16, 2017, 8:47:36 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:
fb04321
Parents:
26ba208
Message:

move type FuncSpecifiers? from DeclarationNode? to Type

Location:
src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:06:05 2017
    13 // Update Count     : 337
     12// Last Modified On : Thu Mar 16 08:35:33 2017
     13// Update Count     : 338
    1414//
    1515
     
    301301                                                                                                         functionNesting > 0 ? Type::StorageClasses() : Type::StorageClasses( Type::Static ),
    302302                                                                                                         LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ),
    303                                                                                                          std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );
     303                                                                                                         std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) );
    304304                layoutDecl->fixUniqueId();
    305305                return layoutDecl;
  • src/Parser/DeclarationNode.cc

    r26ba208 rddfd945  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:59:40 2017
    13 // Update Count     : 1003
     12// Last Modified On : Thu Mar 16 08:37:57 2017
     13// Update Count     : 1006
    1414//
    1515
     
    3333
    3434// These must remain in the same order as the corresponding DeclarationNode enumerations.
    35 const char * DeclarationNode::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };
    3635const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" };
    3736const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" };
     
    186185} // DeclarationNode::newStorageClass
    187186
    188 DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) {
     187DeclarationNode * DeclarationNode::newFuncSpecifier( Type::FuncSpecifiers fs ) {
    189188        DeclarationNode * newnode = new DeclarationNode;
    190189        newnode->funcSpecs = fs;
     
    448447void DeclarationNode::checkSpecifiers( DeclarationNode * src ) {
    449448        if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) {      // duplicates ?
    450                 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { // find duplicates
     449                for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates
    451450                        if ( funcSpecs[i] && src->funcSpecs[i] ) {
    452                                 appendError( error, string( "duplicate " ) + FuncSpecifiers::Names[i] );
     451                                appendError( error, string( "duplicate " ) + Type::FuncSpecifiers::Names[i] );
    453452                        } // if
    454453                } // for
  • src/Parser/ParseNode.h

    r26ba208 rddfd945  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:46:33 2017
    13 // Update Count     : 772
     12// Last Modified On : Thu Mar 16 08:32:43 2017
     13// Update Count     : 776
    1414//
    1515
     
    201201class DeclarationNode : public ParseNode {
    202202  public:
    203         enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };
    204         union FuncSpecifiers {
    205                 static const char * Names[];
    206                 unsigned int val;
    207                 struct {
    208                         bool is_inline : 1;
    209                         bool is_noreturn : 1;
    210                         bool is_fortran : 1;
    211                 };
    212                 FuncSpecifiers() : val( 0 ) {}
    213                 FuncSpecifiers( unsigned int val ) : val( val ) {}
    214                 bool operator[]( unsigned int i ) const { return val & (1 << i); }
    215                 bool any() const { return val != 0; }
    216                 void print( std::ostream & os ) const {
    217                         if ( (*this).any() ) {                                          // any function specifiers ?
    218                                 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) {
    219                                         if ( (*this)[i] ) {
    220                                                 os << FuncSpecifiers::Names[i] << ' ';
    221                                         } // if
    222                                 } // for
    223                         } // if
    224                 }
    225         }; // FuncSpecifiers
    226 
    227203        enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType };
    228204        enum ComplexType { Complex, Imaginary, NoComplexType };
     
    242218
    243219        static DeclarationNode * newStorageClass( Type::StorageClasses );
    244         static DeclarationNode * newFuncSpecifier( FuncSpecifiers );
     220        static DeclarationNode * newFuncSpecifier( Type::FuncSpecifiers );
    245221        static DeclarationNode * newTypeQualifier( Type::Qualifiers );
    246222        static DeclarationNode * newBasicType( BasicType );
     
    339315        TypeData * type;
    340316
     317        Type::FuncSpecifiers funcSpecs;
    341318        Type::StorageClasses storageClasses;
    342         FuncSpecifiers funcSpecs;
    343319
    344320        ExpressionNode * bitfieldWidth;
  • src/Parser/TypeData.cc

    r26ba208 rddfd945  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:54:50 2017
    13 // Update Count     : 558
     12// Last Modified On : Thu Mar 16 08:32:42 2017
     13// Update Count     : 559
    1414//
    1515
     
    778778} // buildTypeof
    779779
    780 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {
     780Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {
    781781        if ( td->kind == TypeData::Function ) {
    782782                if ( td->function.idList ) {                                    // KR function ?
     
    814814                        break;
    815815                  default:
    816                         ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );
     816                        ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );
    817817                } // switch
    818818        } else {
  • src/Parser/TypeData.h

    r26ba208 rddfd945  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:53:41 2017
    13 // Update Count     : 184
     12// Last Modified On : Thu Mar 16 08:32:39 2017
     13// Update Count     : 185
    1414//
    1515
     
    109109TupleType * buildTuple( const TypeData * );
    110110TypeofType * buildTypeof( const TypeData * );
    111 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
     111Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
    112112FunctionType * buildFunction( const TypeData * );
    113113void buildKRFunction( const TypeData::Function_t & function );
  • src/Parser/parser.yy

    r26ba208 rddfd945  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:00:59 2017
    13 // Update Count     : 2309
     12// Last Modified On : Thu Mar 16 08:36:17 2017
     13// Update Count     : 2310
    1414//
    1515
     
    14601460                // Put function specifiers here to simplify parsing rules, but separate them semantically.
    14611461        | INLINE                                                                                        // C99
    1462                 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }
     1462                { $$ = DeclarationNode::newFuncSpecifier( Type::Inline ); }
    14631463        | FORTRAN                                                                                       // C99
    1464                 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }
     1464                { $$ = DeclarationNode::newFuncSpecifier( Type::Fortran ); }
    14651465        | NORETURN                                                                                      // C11
    1466                 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }
     1466                { $$ = DeclarationNode::newFuncSpecifier( Type::Noreturn ); }
    14671467        ;
    14681468
  • src/SymTab/Autogen.cc

    r26ba208 rddfd945  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:03:35 2017
    13 // Update Count     : 56
     12// Last Modified On : Thu Mar 16 08:37:22 2017
     13// Update Count     : 59
    1414//
    1515
     
    165165                LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen;
    166166                FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ),
    167                                                                                                 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );
     167                                                                                                std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) );
    168168                decl->fixUniqueId();
    169169                return decl;
     
    720720                                        TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl );
    721721                                        newDecl->get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,
    722                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
     722                                                                                                                                                   std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    723723                                        newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
    724                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
     724                                                                                                                                                   std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    725725                                        newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,
    726                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
     726                                                                                                                                                   std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    727727                                        newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
    728                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
     728                                                                                                                                                   std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    729729                                        typeParams.push_back( newDecl );
    730730                                        done.insert( ty->get_baseType() );
  • src/SynTree/Declaration.h

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:48:23 2017
    13 // Update Count     : 117
     12// Last Modified On : Thu Mar 16 08:34:11 2017
     13// Update Count     : 118
    1414//
    1515
     
    6464class DeclarationWithType : public Declaration {
    6565  public:
    66         DeclarationWithType( const std::string &name, Type::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, Type::FuncSpecifiers fs );
    6767        DeclarationWithType( const DeclarationWithType &other );
    6868        virtual ~DeclarationWithType();
     
    8282        const std::list< Attribute * >& get_attributes() const { return attributes; }
    8383
    84         DeclarationNode::FuncSpecifiers get_funcSpec() const { return fs; }
    85         //void set_functionSpecifiers( DeclarationNode::FuncSpecifiers newValue ) { fs = newValue; }
     84        Type::FuncSpecifiers get_funcSpec() const { return fs; }
     85        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    8686
    8787        virtual DeclarationWithType *clone() const = 0;
     
    9898        ConstantExpr *asmName;
    9999        std::list< Attribute * > attributes;
    100         DeclarationNode::FuncSpecifiers fs;
     100        Type::FuncSpecifiers fs;
    101101};
    102102
     
    105105  public:
    106106        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    107                                 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );
     107                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    108108        ObjectDecl( const ObjectDecl &other );
    109109        virtual ~ObjectDecl();
     
    133133  public:
    134134        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    135                                   const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );
     135                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    136136        FunctionDecl( const FunctionDecl &other );
    137137        virtual ~FunctionDecl();
  • src/SynTree/DeclarationWithType.cc

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:49:27 2017
    13 // Update Count     : 24
     12// Last Modified On : Thu Mar 16 08:34:35 2017
     13// Update Count     : 25
    1414//
    1515
     
    1919#include "Common/utility.h"
    2020
    21 DeclarationWithType::DeclarationWithType( const std::string &name, Type::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, Type::FuncSpecifiers fs )
    2222        : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) {
    2323}
  • src/SynTree/FunctionDecl.cc

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:49:35 2017
    13 // Update Count     : 73
     12// Last Modified On : Thu Mar 16 08:33:41 2017
     13// Update Count     : 74
    1414//
    1515
     
    2626extern bool translation_unit_nomain;
    2727
    28 FunctionDecl::FunctionDecl( const std::string &name, Type::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, Type::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/ObjectDecl.cc

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:49:51 2017
    13 // Update Count     : 58
     12// Last Modified On : Thu Mar 16 08:34:27 2017
     13// Update Count     : 59
    1414//
    1515
     
    2222#include "Statement.h"
    2323
    24 ObjectDecl::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 )
     24ObjectDecl::ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, Type::FuncSpecifiers fs )
    2525        : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
    2626}
  • src/SynTree/Type.cc

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:57:45 2017
    13 // Update Count     : 20
     12// Last Modified On : Thu Mar 16 08:32:44 2017
     13// Update Count     : 22
    1414//
    1515
     
    6060
    6161// These must remain in the same order as the corresponding bit fields.
     62const char * Type::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn" };
    6263const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" };
    6364const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
  • src/SynTree/Type.h

    r26ba208 rddfd945  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:45:29 2017
    13 // Update Count     : 90
     12// Last Modified On : Thu Mar 16 08:28:02 2017
     13// Update Count     : 91
    1414//
    1515
     
    2525  public:
    2626        // enum must remain in the same order as the corresponding bit fields.
     27
     28        enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };
     29        union FuncSpecifiers {
     30                static const char * Names[];
     31                unsigned int val;
     32                struct {
     33                        bool is_inline : 1;
     34                        bool is_noreturn : 1;
     35                        bool is_fortran : 1;
     36                };
     37                FuncSpecifiers() : val( 0 ) {}
     38                FuncSpecifiers( unsigned int val ) : val( val ) {}
     39                bool operator[]( unsigned int i ) const { return val & (1 << i); }
     40                bool any() const { return val != 0; }
     41                void print( std::ostream & os ) const {
     42                        if ( (*this).any() ) {                                          // any function specifiers ?
     43                                for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) {
     44                                        if ( (*this)[i] ) {
     45                                                os << FuncSpecifiers::Names[i] << ' ';
     46                                        } // if
     47                                } // for
     48                        } // if
     49                }
     50        }; // FuncSpecifiers
    2751
    2852        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };
Note: See TracChangeset for help on using the changeset viewer.