Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    r65cdc1e r6b0b624  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  9 14:45:00 2017
    13 // Update Count     : 126
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:52:59 2017
     13// Update Count     : 124
    1414//
    1515
     
    2727class Declaration : public BaseSyntaxNode {
    2828  public:
    29         std::string name;
    30         LinkageSpec::Spec linkage;
    31         bool extension = false;
    32 
    3329        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    3430        Declaration( const Declaration &other );
     
    5753        static void dumpIds( std::ostream &os );
    5854        static Declaration *declFromId( UniqueId id );
    59 
    60   private:
     55  private:
     56        std::string name;
    6157        Type::StorageClasses storageClasses;
     58        LinkageSpec::Spec linkage;
    6259        UniqueId uniqueId;
     60        bool extension = false;
    6361};
    6462
    6563class DeclarationWithType : public Declaration {
    6664  public:
     65        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
     66        DeclarationWithType( const DeclarationWithType &other );
     67        virtual ~DeclarationWithType();
     68
     69        std::string get_mangleName() const { return mangleName; }
     70        DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
     71
     72        std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
     73
     74        int get_scopeLevel() const { return scopeLevel; }
     75        DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
     76
     77        ConstantExpr *get_asmName() const { return asmName; }
     78        DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }
     79
     80        std::list< Attribute * >& get_attributes() { return attributes; }
     81        const std::list< Attribute * >& get_attributes() const { return attributes; }
     82
     83        Type::FuncSpecifiers get_funcSpec() const { return fs; }
     84        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
     85
     86        virtual DeclarationWithType *clone() const = 0;
     87        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     88
     89        virtual Type *get_type() const = 0;
     90        virtual void set_type(Type *) = 0;
     91  private:
    6792        // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    6893        std::string mangleName;
     
    7297        ConstantExpr *asmName;
    7398        std::list< Attribute * > attributes;
    74 
    75         DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    76         DeclarationWithType( const DeclarationWithType &other );
    77         virtual ~DeclarationWithType();
    78 
    79         std::string get_mangleName() const { return mangleName; }
    80         DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
    81 
    82         std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
    83 
    84         int get_scopeLevel() const { return scopeLevel; }
    85         DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
    86 
    87         ConstantExpr *get_asmName() const { return asmName; }
    88         DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }
    89 
    90         std::list< Attribute * >& get_attributes() { return attributes; }
    91         const std::list< Attribute * >& get_attributes() const { return attributes; }
    92 
    93         Type::FuncSpecifiers get_funcSpec() const { return fs; }
    94         //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    95 
    96         virtual DeclarationWithType *clone() const = 0;
    97         virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
    98 
    99         virtual Type *get_type() const = 0;
    100         virtual void set_type(Type *) = 0;
    101 
    102   private:
    10399        Type::FuncSpecifiers fs;
    104100};
     
    107103        typedef DeclarationWithType Parent;
    108104  public:
    109         Type *type;
    110         Initializer *init;
    111         Expression *bitfieldWidth;
    112 
    113105        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    114106                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    130122        virtual void print( std::ostream &os, int indent = 0 ) const;
    131123        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     124  private:
     125        Type *type;
     126        Initializer *init;
     127        Expression *bitfieldWidth;
    132128};
    133129
     
    135131        typedef DeclarationWithType Parent;
    136132  public:
    137         FunctionType *type;
    138         CompoundStmt *statements;
    139 
    140133        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    141134                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    156149        virtual void print( std::ostream &os, int indent = 0 ) const;
    157150        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     151  private:
     152        FunctionType *type;
     153        CompoundStmt *statements;
    158154};
    159155
     
    161157        typedef Declaration Parent;
    162158  public:
    163         Type *base;
    164         std::list< TypeDecl* > parameters;
    165         std::list< DeclarationWithType* > assertions;
    166 
    167159        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    168160        NamedTypeDecl( const NamedTypeDecl &other );
     
    179171        virtual void print( std::ostream &os, int indent = 0 ) const;
    180172        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     173  protected:
     174  private:
     175        Type *base;
     176        std::list< TypeDecl* > parameters;
     177        std::list< DeclarationWithType* > assertions;
    181178};
    182179
     
    185182  public:
    186183        enum Kind { Any, Dtype, Ftype, Ttype };
    187 
    188         Type * init;
    189         bool sized;
    190 
    191184        /// Data extracted from a type decl
    192185        struct Data {
     
    223216  private:
    224217        Kind kind;
     218        Type * init;
     219        bool sized;
    225220};
    226221
     
    228223        typedef NamedTypeDecl Parent;
    229224  public:
    230         TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); }
     225        TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
    231226        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    232227
     
    242237        typedef Declaration Parent;
    243238  public:
     239        AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
     240        AggregateDecl( const AggregateDecl &other );
     241        virtual ~AggregateDecl();
     242
     243        std::list<Declaration*>& get_members() { return members; }
     244        std::list<TypeDecl*>& get_parameters() { return parameters; }
     245
     246        std::list< Attribute * >& get_attributes() { return attributes; }
     247        const std::list< Attribute * >& get_attributes() const { return attributes; }
     248
     249        bool has_body() const { return body; }
     250        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
     251
     252        virtual void print( std::ostream &os, int indent = 0 ) const;
     253        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     254  protected:
     255        virtual std::string typeString() const = 0;
     256
     257  private:
    244258        std::list<Declaration*> members;
    245259        std::list<TypeDecl*> parameters;
    246260        bool body;
    247261        std::list< Attribute * > attributes;
    248 
    249         AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    250         AggregateDecl( const AggregateDecl &other );
    251         virtual ~AggregateDecl();
    252 
    253         std::list<Declaration*>& get_members() { return members; }
    254         std::list<TypeDecl*>& get_parameters() { return parameters; }
    255 
    256         std::list< Attribute * >& get_attributes() { return attributes; }
    257         const std::list< Attribute * >& get_attributes() const { return attributes; }
    258 
    259         bool has_body() const { return body; }
    260         AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    261 
    262         virtual void print( std::ostream &os, int indent = 0 ) const;
    263         virtual void printShort( std::ostream &os, int indent = 0 ) const;
    264   protected:
    265         virtual std::string typeString() const = 0;
    266262};
    267263
     
    337333class AsmDecl : public Declaration {
    338334  public:
    339         AsmStmt *stmt;
    340 
    341335        AsmDecl( AsmStmt *stmt );
    342336        AsmDecl( const AsmDecl &other );
     
    351345        virtual void print( std::ostream &os, int indent = 0 ) const;
    352346        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     347  private:
     348        AsmStmt *stmt;
    353349};
    354350
Note: See TracChangeset for help on using the changeset viewer.