Ignore:
Timestamp:
Aug 9, 2017, 3:21:58 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
0ec9229
Parents:
cbce272
Message:

Syntax Nodes give public access to the fields with effective public access.X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    rcbce272 r65cdc1e  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Aug  8 13:25:00 2017
    13 // Update Count     : 125
     12// Last Modified On : Wed Aug  9 14:45:00 2017
     13// Update Count     : 126
    1414//
    1515
     
    2727class Declaration : public BaseSyntaxNode {
    2828  public:
     29        std::string name;
     30        LinkageSpec::Spec linkage;
     31        bool extension = false;
     32
    2933        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    3034        Declaration( const Declaration &other );
     
    5357        static void dumpIds( std::ostream &os );
    5458        static Declaration *declFromId( UniqueId id );
    55   private:
    56         std::string name;
     59
     60  private:
    5761        Type::StorageClasses storageClasses;
    58         LinkageSpec::Spec linkage;
    5962        UniqueId uniqueId;
    60         bool extension = false;
    6163};
    6264
    6365class DeclarationWithType : public Declaration {
    6466  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:
    9267        // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    9368        std::string mangleName;
     
    9772        ConstantExpr *asmName;
    9873        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:
    99103        Type::FuncSpecifiers fs;
    100104};
     
    103107        typedef DeclarationWithType Parent;
    104108  public:
     109        Type *type;
     110        Initializer *init;
     111        Expression *bitfieldWidth;
     112
    105113        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    106114                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    122130        virtual void print( std::ostream &os, int indent = 0 ) const;
    123131        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    124   private:
    125         Type *type;
    126         Initializer *init;
    127         Expression *bitfieldWidth;
    128132};
    129133
     
    131135        typedef DeclarationWithType Parent;
    132136  public:
     137        FunctionType *type;
     138        CompoundStmt *statements;
     139
    133140        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    134141                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    149156        virtual void print( std::ostream &os, int indent = 0 ) const;
    150157        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    151   private:
    152         FunctionType *type;
    153         CompoundStmt *statements;
    154158};
    155159
     
    157161        typedef Declaration Parent;
    158162  public:
     163        Type *base;
     164        std::list< TypeDecl* > parameters;
     165        std::list< DeclarationWithType* > assertions;
     166
    159167        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    160168        NamedTypeDecl( const NamedTypeDecl &other );
     
    171179        virtual void print( std::ostream &os, int indent = 0 ) const;
    172180        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;
    178181};
    179182
     
    182185  public:
    183186        enum Kind { Any, Dtype, Ftype, Ttype };
     187
     188        Type * init;
     189        bool sized;
     190
    184191        /// Data extracted from a type decl
    185192        struct Data {
     
    216223  private:
    217224        Kind kind;
    218         Type * init;
    219         bool sized;
    220225};
    221226
     
    237242        typedef Declaration Parent;
    238243  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:
    258244        std::list<Declaration*> members;
    259245        std::list<TypeDecl*> parameters;
    260246        bool body;
    261247        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;
    262266};
    263267
     
    333337class AsmDecl : public Declaration {
    334338  public:
     339        AsmStmt *stmt;
     340
    335341        AsmDecl( AsmStmt *stmt );
    336342        AsmDecl( const AsmDecl &other );
     
    345351        virtual void print( std::ostream &os, int indent = 0 ) const;
    346352        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    347   private:
    348         AsmStmt *stmt;
    349353};
    350354
Note: See TracChangeset for help on using the changeset viewer.