Changeset 65cdc1e


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

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    rcbce272 r65cdc1e  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 27 21:42:38 2017
    13 // Update Count     : 567
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  2 11:12:00 2017
     13// Update Count     : 568
    1414//
    1515
     
    4040// type.
    4141
    42 Type::Qualifiers noQualifiers;                          // no qualifiers on constants
     42extern const Type::Qualifiers noQualifiers;             // no qualifiers on constants
    4343
    4444static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
  • src/SynTree/Declaration.cc

    rcbce272 r65cdc1e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:49:18 2017
    13 // Update Count     : 24
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:38:00 2017
     13// Update Count     : 25
    1414//
    1515
     
    2828
    2929Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage )
    30                 : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) {
     30                : name( name ), linkage( linkage ), storageClasses( scs ), uniqueId( 0 ) {
    3131}
    3232
    3333Declaration::Declaration( const Declaration &other )
    34         : BaseSyntaxNode( other ), name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage ), uniqueId( other.uniqueId ) {
     34        : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), storageClasses( other.storageClasses ), uniqueId( other.uniqueId ) {
    3535}
    3636
  • 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
  • src/SynTree/Expression.h

    rcbce272 r65cdc1e  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 24 16:27:00 2017
    13 // Update Count     : 43
     12// Last Modified On : Fri Aug  8 11:54:00 2017
     13// Update Count     : 44
    1414//
    1515
     
    2929class Expression : public BaseSyntaxNode{
    3030  public:
     31        Type * result;
     32        TypeSubstitution * env;
     33        Expression * argName; // if expression is used as an argument, it can be "designated" by this name
     34        bool extension = false;
     35
    3136        Expression( Expression * _aname = nullptr );
    3237        Expression( const Expression & other );
     
    4954        virtual Expression * acceptMutator( Mutator & m ) = 0;
    5055        virtual void print( std::ostream & os, int indent = 0 ) const;
    51   protected:
    52         Type * result;
    53         TypeSubstitution * env;
    54         Expression * argName; // if expression is used as an argument, it can be "designated" by this name
    55         bool extension = false;
    5656};
    5757
     
    7979class ApplicationExpr : public Expression {
    8080  public:
     81        Expression * function;
     82
    8183        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    8284        ApplicationExpr( const ApplicationExpr & other );
     
    9294        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    9395        virtual void print( std::ostream & os, int indent = 0 ) const;
     96
    9497  private:
    95         Expression * function;
    9698        std::list<Expression *> args;
    9799        InferredParams inferParams;
     
    103105class UntypedExpr : public Expression {
    104106  public:
     107        Expression * function;
     108        std::list<Expression*> args;
     109
    105110        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr );
    106111        UntypedExpr( const UntypedExpr & other );
     
    123128        virtual void print( std::ostream & os, int indent = 0 ) const;
    124129        virtual void printArgs(std::ostream & os, int indent = 0) const;
    125   private:
    126         Expression * function;
    127         std::list<Expression*> args;
    128130};
    129131
     
    131133class NameExpr : public Expression {
    132134  public:
     135        std::string name;
     136
    133137        NameExpr( std::string name, Expression *_aname = nullptr );
    134138        NameExpr( const NameExpr & other );
     
    142146        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    143147        virtual void print( std::ostream & os, int indent = 0 ) const;
    144   private:
    145         std::string name;
    146148};
    147149
     
    152154class AddressExpr : public Expression {
    153155  public:
     156        Expression * arg;
     157
    154158        AddressExpr( Expression * arg, Expression *_aname = nullptr );
    155159        AddressExpr( const AddressExpr & other );
     
    163167        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    164168        virtual void print( std::ostream & os, int indent = 0 ) const;
    165   private:
    166         Expression * arg;
    167169};
    168170
     
    170172class LabelAddressExpr : public Expression {
    171173  public:
     174        Expression * arg;
     175
    172176        LabelAddressExpr( Expression * arg );
    173177        LabelAddressExpr( const LabelAddressExpr & other );
     
    181185        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    182186        virtual void print( std::ostream & os, int indent = 0 ) const;
    183   private:
    184         Expression * arg;
    185187};
    186188
     
    188190class CastExpr : public Expression {
    189191  public:
     192        Expression * arg;
     193
    190194        CastExpr( Expression * arg, Expression *_aname = nullptr );
    191195        CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr );
     
    200204        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    201205        virtual void print( std::ostream & os, int indent = 0 ) const;
    202   private:
    203         Expression * arg;
    204206};
    205207
     
    207209class VirtualCastExpr : public Expression {
    208210  public:
     211        Expression * arg;
     212
    209213        VirtualCastExpr( Expression * arg, Type * toType );
    210214        VirtualCastExpr( const VirtualCastExpr & other );
     
    218222        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    219223        virtual void print( std::ostream & os, int indent = 0 ) const;
    220   private:
    221         Expression * arg;
    222224};
    223225
     
    225227class UntypedMemberExpr : public Expression {
    226228  public:
     229        Expression * member;
     230        Expression * aggregate;
     231
    227232        UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr );
    228233        UntypedMemberExpr( const UntypedMemberExpr & other );
     
    238243        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    239244        virtual void print( std::ostream & os, int indent = 0 ) const;
    240   private:
    241         Expression * member;
    242         Expression * aggregate;
    243245};
    244246
     
    247249class MemberExpr : public Expression {
    248250  public:
     251        DeclarationWithType * member;
     252        Expression * aggregate;
     253
    249254        MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr );
    250255        MemberExpr( const MemberExpr & other );
     
    260265        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    261266        virtual void print( std::ostream & os, int indent = 0 ) const;
    262   private:
    263         DeclarationWithType * member;
    264         Expression * aggregate;
    265267};
    266268
     
    269271class VariableExpr : public Expression {
    270272  public:
     273        DeclarationWithType * var;
     274
    271275        VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr );
    272276        VariableExpr( const VariableExpr & other );
     
    280284        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    281285        virtual void print( std::ostream & os, int indent = 0 ) const;
    282   private:
    283         DeclarationWithType * var;
    284286};
    285287
     
    287289class ConstantExpr : public Expression {
    288290  public:
     291        Constant constant;
     292
    289293        ConstantExpr( Constant constant, Expression *_aname = nullptr );
    290294        ConstantExpr( const ConstantExpr & other );
     
    298302        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    299303        virtual void print( std::ostream & os, int indent = 0 ) const;
    300   private:
    301         Constant constant;
    302304};
    303305
     
    305307class SizeofExpr : public Expression {
    306308  public:
     309        Expression * expr;
     310        Type * type;
     311        bool isType;
     312
    307313        SizeofExpr( Expression * expr, Expression *_aname = nullptr );
    308314        SizeofExpr( const SizeofExpr & other );
     
    321327        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    322328        virtual void print( std::ostream & os, int indent = 0 ) const;
    323   private:
     329};
     330
     331/// AlignofExpr represents an alignof expression
     332class AlignofExpr : public Expression {
     333  public:
    324334        Expression * expr;
    325335        Type * type;
    326336        bool isType;
    327 };
    328 
    329 /// AlignofExpr represents an alignof expression
    330 class AlignofExpr : public Expression {
    331   public:
     337
    332338        AlignofExpr( Expression * expr, Expression *_aname = nullptr );
    333339        AlignofExpr( const AlignofExpr & other );
     
    346352        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    347353        virtual void print( std::ostream & os, int indent = 0 ) const;
    348   private:
    349         Expression * expr;
    350         Type * type;
    351         bool isType;
    352354};
    353355
     
    355357class UntypedOffsetofExpr : public Expression {
    356358  public:
     359        Type * type;
     360        std::string member;
     361
    357362        UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr );
    358363        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
     
    368373        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    369374        virtual void print( std::ostream & os, int indent = 0 ) const;
    370   private:
    371         Type * type;
    372         std::string member;
    373375};
    374376
     
    376378class OffsetofExpr : public Expression {
    377379  public:
     380        Type * type;
     381        DeclarationWithType * member;
     382
    378383        OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr );
    379384        OffsetofExpr( const OffsetofExpr & other );
     
    389394        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    390395        virtual void print( std::ostream & os, int indent = 0 ) const;
    391   private:
    392         Type * type;
    393         DeclarationWithType * member;
    394396};
    395397
     
    397399class OffsetPackExpr : public Expression {
    398400public:
     401        StructInstType * type;
     402
    399403        OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 );
    400404        OffsetPackExpr( const OffsetPackExpr & other );
     
    407411        virtual void accept( Visitor & v ) { v.visit( this ); }
    408412        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    409 
    410         virtual void print( std::ostream & os, int indent = 0 ) const;
    411 
    412 private:
    413         StructInstType * type;
     413        virtual void print( std::ostream & os, int indent = 0 ) const;
    414414};
    415415
     
    417417class AttrExpr : public Expression {
    418418  public:
     419        Expression * attr;
     420        Expression * expr;
     421        Type * type;
     422        bool isType;
     423
    419424        AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr );
    420425        AttrExpr( const AttrExpr & other );
     
    435440        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    436441        virtual void print( std::ostream & os, int indent = 0 ) const;
    437   private:
    438         Expression * attr;
    439         Expression * expr;
    440         Type * type;
    441         bool isType;
    442442};
    443443
     
    445445class LogicalExpr : public Expression {
    446446  public:
     447        Expression * arg1;
     448        Expression * arg2;
     449
    447450        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr );
    448451        LogicalExpr( const LogicalExpr & other );
     
    459462        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    460463        virtual void print( std::ostream & os, int indent = 0 ) const;
     464
    461465  private:
     466        bool isAnd;
     467};
     468
     469/// ConditionalExpr represents the three-argument conditional ( p ? a : b )
     470class ConditionalExpr : public Expression {
     471  public:
    462472        Expression * arg1;
    463473        Expression * arg2;
    464         bool isAnd;
    465 };
    466 
    467 /// ConditionalExpr represents the three-argument conditional ( p ? a : b )
    468 class ConditionalExpr : public Expression {
    469   public:
     474        Expression * arg3;
     475
    470476        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr );
    471477        ConditionalExpr( const ConditionalExpr & other );
     
    483489        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    484490        virtual void print( std::ostream & os, int indent = 0 ) const;
    485   private:
     491};
     492
     493/// CommaExpr represents the sequence operator ( a, b )
     494class CommaExpr : public Expression {
     495  public:
    486496        Expression * arg1;
    487497        Expression * arg2;
    488         Expression * arg3;
    489 };
    490 
    491 /// CommaExpr represents the sequence operator ( a, b )
    492 class CommaExpr : public Expression {
    493   public:
     498
    494499        CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr );
    495500        CommaExpr( const CommaExpr & other );
     
    505510        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    506511        virtual void print( std::ostream & os, int indent = 0 ) const;
    507   private:
    508         Expression * arg1;
    509         Expression * arg2;
    510512};
    511513
     
    513515class TypeExpr : public Expression {
    514516  public:
     517        Type * type;
     518
    515519        TypeExpr( Type * type );
    516520        TypeExpr( const TypeExpr & other );
     
    524528        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    525529        virtual void print( std::ostream & os, int indent = 0 ) const;
    526   private:
    527         Type * type;
    528530};
    529531
     
    531533class AsmExpr : public Expression {
    532534  public:
     535        Expression * inout;
     536        ConstantExpr * constraint;
     537        Expression * operand;
     538
    533539        AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    534540        AsmExpr( const AsmExpr & other );
     
    548554        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    549555        virtual void print( std::ostream & os, int indent = 0 ) const;
    550   private:
     556
    551557        // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints
    552         Expression * inout;
    553         ConstantExpr * constraint;
    554         Expression * operand;
    555558};
    556559
     
    559562class ImplicitCopyCtorExpr : public Expression {
    560563public:
    561         ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    562         ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
    563         virtual ~ImplicitCopyCtorExpr();
    564 
    565         ApplicationExpr * get_callExpr() const { return callExpr; }
    566         void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }
    567 
    568         std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
    569         std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    570         std::list< Expression * > & get_dtors() { return dtors; }
    571 
    572         virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }
    573         virtual void accept( Visitor & v ) { v.visit( this ); }
    574         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    575         virtual void print( std::ostream & os, int indent = 0 ) const;
    576   private:
    577564        ApplicationExpr * callExpr;
    578565        std::list< ObjectDecl * > tempDecls;
    579566        std::list< ObjectDecl * > returnDecls;
    580567        std::list< Expression * > dtors;
     568
     569        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
     570        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
     571        virtual ~ImplicitCopyCtorExpr();
     572
     573        ApplicationExpr * get_callExpr() const { return callExpr; }
     574        void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }
     575
     576        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     577        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
     578        std::list< Expression * > & get_dtors() { return dtors; }
     579
     580        virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }
     581        virtual void accept( Visitor & v ) { v.visit( this ); }
     582        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     583        virtual void print( std::ostream & os, int indent = 0 ) const;
    581584};
    582585
     
    584587class ConstructorExpr : public Expression {
    585588public:
     589        Expression * callExpr;
     590
    586591        ConstructorExpr( Expression * callExpr );
    587592        ConstructorExpr( const ConstructorExpr & other );
     
    595600        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    596601        virtual void print( std::ostream & os, int indent = 0 ) const;
    597 private:
    598         Expression * callExpr;
    599602};
    600603
     
    602605class CompoundLiteralExpr : public Expression {
    603606  public:
     607        Initializer * initializer;
     608
    604609        CompoundLiteralExpr( Type * type, Initializer * initializer );
    605610        CompoundLiteralExpr( const CompoundLiteralExpr & other );
     
    613618        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    614619        virtual void print( std::ostream & os, int indent = 0 ) const;
    615   private:
    616         Initializer * initializer;
    617620};
    618621
     
    620623class RangeExpr : public Expression {
    621624  public:
     625        Expression * low, * high;
     626
    622627        RangeExpr( Expression * low, Expression * high );
    623628        RangeExpr( const RangeExpr & other );
     
    632637        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    633638        virtual void print( std::ostream & os, int indent = 0 ) const;
    634   private:
    635         Expression * low, * high;
    636639};
    637640
     
    639642class UntypedTupleExpr : public Expression {
    640643  public:
     644        std::list<Expression*> exprs;
     645
    641646        UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
    642647        UntypedTupleExpr( const UntypedTupleExpr & other );
     
    649654        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    650655        virtual void print( std::ostream & os, int indent = 0 ) const;
    651   private:
    652         std::list<Expression*> exprs;
    653656};
    654657
     
    656659class TupleExpr : public Expression {
    657660  public:
     661        std::list<Expression*> exprs;
     662
    658663        TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
    659664        TupleExpr( const TupleExpr & other );
     
    666671        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    667672        virtual void print( std::ostream & os, int indent = 0 ) const;
    668   private:
    669         std::list<Expression*> exprs;
    670673};
    671674
     
    673676class TupleIndexExpr : public Expression {
    674677  public:
     678        Expression * tuple;
     679        unsigned int index;
     680
    675681        TupleIndexExpr( Expression * tuple, unsigned int index );
    676682        TupleIndexExpr( const TupleIndexExpr & other );
     
    686692        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    687693        virtual void print( std::ostream & os, int indent = 0 ) const;
    688   private:
    689         Expression * tuple;
    690         unsigned int index;
    691694};
    692695
     
    694697class TupleAssignExpr : public Expression {
    695698  public:
     699        StmtExpr * stmtExpr = nullptr;
     700
    696701        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
    697702        TupleAssignExpr( const TupleAssignExpr & other );
     
    705710        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    706711        virtual void print( std::ostream & os, int indent = 0 ) const;
    707   private:
    708         StmtExpr * stmtExpr = nullptr;
    709712};
    710713
     
    712715class StmtExpr : public Expression {
    713716public:
     717        CompoundStmt * statements;
     718        std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression
     719        std::list< Expression * > dtors; // destructor(s) for return variable(s)
     720
    714721        StmtExpr( CompoundStmt * statements );
    715722        StmtExpr( const StmtExpr & other );
     
    726733        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    727734        virtual void print( std::ostream & os, int indent = 0 ) const;
    728 private:
    729         CompoundStmt * statements;
    730         std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression
    731         std::list< Expression * > dtors; // destructor(s) for return variable(s)
    732735};
    733736
    734737class UniqueExpr : public Expression {
    735738public:
     739        Expression * expr;
     740        ObjectDecl * object;
     741        VariableExpr * var;
     742
    736743        UniqueExpr( Expression * expr, long long idVal = -1 );
    737744        UniqueExpr( const UniqueExpr & other );
     
    753760        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    754761        virtual void print( std::ostream & os, int indent = 0 ) const;
     762
    755763private:
    756         Expression * expr;
    757         ObjectDecl * object;
    758         VariableExpr * var;
    759764        int id;
    760765        static long long count;
     
    773778class UntypedInitExpr : public Expression {
    774779public:
     780        Expression * expr;
     781        std::list<InitAlternative> initAlts;
     782
    775783        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    776784        UntypedInitExpr( const UntypedInitExpr & other );
     
    786794        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    787795        virtual void print( std::ostream & os, int indent = 0 ) const;
    788 private:
    789         Expression * expr;
    790         std::list<InitAlternative> initAlts;
    791796};
    792797
    793798class InitExpr : public Expression {
    794799public:
     800        Expression * expr;
     801        Designation * designation;
     802
    795803        InitExpr( Expression * expr, Designation * designation );
    796804        InitExpr( const InitExpr & other );
     
    807815        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    808816        virtual void print( std::ostream & os, int indent = 0 ) const;
    809 private:
    810         Expression * expr;
    811         Designation * designation;
    812817};
    813818
  • src/SynTree/Initializer.h

    rcbce272 r65cdc1e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:52:02 2017
    13 // Update Count     : 21
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 10:19:00 2017
     13// Update Count     : 22
    1414//
    1515
     
    2727class Designation : public BaseSyntaxNode {
    2828public:
     29        std::list< Expression * > designators;
     30
    2931        Designation( const std::list< Expression * > & designators );
    3032        Designation( const Designation & other );
     
    3739        virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
    3840        virtual void print( std::ostream &os, int indent = 0 ) const;
    39 private:
    40         std::list< Expression * > designators;
    4141};
    4242
     
    6363class SingleInit : public Initializer {
    6464  public:
     65        //Constant *value;
     66        Expression *value;      // has to be a compile-time constant
     67
    6568        SingleInit( Expression *value, bool maybeConstructed = false );
    6669        SingleInit( const SingleInit &other );
     
    7477        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    7578        virtual void print( std::ostream &os, int indent = 0 ) const;
    76   private:
    77         //Constant *value;
    78         Expression *value;      // has to be a compile-time constant
    7979};
    8080
     
    8383class ListInit : public Initializer {
    8484  public:
     85        std::list<Initializer *> initializers;  // order *is* important
     86        std::list<Designation *> designations;  // order/length is consistent with initializers
     87
    8588        ListInit( const std::list<Initializer*> &initializers,
    8689                          const std::list<Designation *> &designators = {}, bool maybeConstructed = false );
     
    102105        virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    103106        virtual void print( std::ostream &os, int indent = 0 ) const;
    104   private:
    105         std::list<Initializer *> initializers;  // order *is* important
    106         std::list<Designation *> designations;  // order/length is consistent with initializers
    107107};
    108108
     
    113113class ConstructorInit : public Initializer {
    114114  public:
     115        Statement * ctor;
     116        Statement * dtor;
     117
    115118        ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
    116119        ConstructorInit( const ConstructorInit &other );
     
    130133
    131134  private:
    132         Statement * ctor;
    133         Statement * dtor;
    134135        // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback
    135136        // if an appropriate constructor definition is not found by the resolver
  • src/SynTree/Statement.h

    rcbce272 r65cdc1e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:54:32 2017
    13 // Update Count     : 68
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug  3 14:08:00 2017
     13// Update Count     : 69
    1414//
    1515
     
    2626class Statement : public BaseSyntaxNode {
    2727  public:
     28        std::list<Label> labels;
     29
    2830        Statement( std::list<Label> labels );
    2931        virtual ~Statement();
     
    3638        virtual Statement *acceptMutator( Mutator &m ) = 0;
    3739        virtual void print( std::ostream &os, int indent = 0 ) const;
    38   protected:
    39         std::list<Label> labels;
    4040};
    4141
    4242class CompoundStmt : public Statement {
    4343  public:
     44        std::list<Statement*> kids;
     45
    4446        CompoundStmt( std::list<Label> labels );
    4547        CompoundStmt( const CompoundStmt &other );
     
    5456        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    5557        virtual void print( std::ostream &os, int indent = 0 ) const;
    56   private:
    57         std::list<Statement*> kids;
    5858};
    5959
     
    6767        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    6868        virtual void print( std::ostream &os, int indent = 0 ) const;
    69 
    70   private:
    7169};
    7270
    7371class ExprStmt : public Statement {
    7472  public:
     73        Expression *expr;
     74
    7575        ExprStmt( std::list<Label> labels, Expression *expr );
    7676        ExprStmt( const ExprStmt &other );
     
    8484        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    8585        virtual void print( std::ostream &os, int indent = 0 ) const;
    86   private:
    87         Expression *expr;
    8886};
    8987
    9088class AsmStmt : public Statement {
    9189  public:
     90        bool voltile;
     91        ConstantExpr *instruction;
     92        std::list<Expression *> output, input;
     93        std::list<ConstantExpr *> clobber;
     94        std::list<Label> gotolabels;
     95
    9296        AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    9397        AsmStmt( const AsmStmt &other );
     
    111115        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    112116        virtual void print( std::ostream &os, int indent = 0 ) const;
    113   private:
    114         bool voltile;
    115         ConstantExpr *instruction;
    116         std::list<Expression *> output, input;
    117         std::list<ConstantExpr *> clobber;
    118         std::list<Label> gotolabels;
    119117};
    120118
    121119class IfStmt : public Statement {
    122120  public:
     121        Expression *condition;
     122        Statement *thenPart;
     123        Statement *elsePart;
     124
    123125        IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart );
    124126        IfStmt( const IfStmt &other );
     
    136138        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    137139        virtual void print( std::ostream &os, int indent = 0 ) const;
    138   private:
    139         Expression *condition;
    140         Statement *thenPart;
    141         Statement *elsePart;
    142140};
    143141
    144142class SwitchStmt : public Statement {
    145143  public:
     144        Expression * condition;
     145
    146146        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
    147147        SwitchStmt( const SwitchStmt &other );
     
    159159        virtual void print( std::ostream &os, int indent = 0 ) const;
    160160  private:
     161        std::list<Statement *> statements;
     162};
     163
     164class CaseStmt : public Statement {
     165  public:
    161166        Expression * condition;
    162         std::list<Statement *> statements;
    163 };
    164 
    165 class CaseStmt : public Statement {
    166   public:
     167        std::list<Statement *> stmts;
     168
    167169        CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    168170        CaseStmt( const CaseStmt &other );
     
    186188        virtual void print( std::ostream &os, int indent = 0 ) const;
    187189  private:
    188         Expression * condition;
    189         std::list<Statement *> stmts;
    190190        bool _isDefault;
    191191};
     
    193193class WhileStmt : public Statement {
    194194  public:
     195        Expression *condition;
     196        Statement *body;
     197        bool isDoWhile;
     198
    195199        WhileStmt( std::list<Label> labels, Expression *condition,
    196200               Statement *body, bool isDoWhile = false );
     
    209213        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    210214        virtual void print( std::ostream &os, int indent = 0 ) const;
    211   private:
     215};
     216
     217class ForStmt : public Statement {
     218  public:
     219        std::list<Statement *> initialization;
    212220        Expression *condition;
     221        Expression *increment;
    213222        Statement *body;
    214         bool isDoWhile;
    215 };
    216 
    217 class ForStmt : public Statement {
    218   public:
     223
    219224        ForStmt( std::list<Label> labels, std::list<Statement *> initialization,
    220225             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
     
    235240        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    236241        virtual void print( std::ostream &os, int indent = 0 ) const;
    237   private:
    238         std::list<Statement *> initialization;
    239         Expression *condition;
    240         Expression *increment;
    241         Statement *body;
    242242};
    243243
     
    245245  public:
    246246        enum Type { Goto = 0, Break, Continue };
     247
     248        // originalTarget kept for error messages.
     249        const Label originalTarget;
     250        Label target;
     251        Expression *computedTarget;
     252        Type type;
    247253
    248254        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
     
    265271  private:
    266272        static const char *brType[];
    267         Label originalTarget;  // can give better error messages if we remember the label name that the user entered
    268         Label target;
    269         Expression *computedTarget;
    270         Type type;
    271273};
    272274
    273275class ReturnStmt : public Statement {
    274276  public:
     277        Expression *expr;
     278
    275279        ReturnStmt( std::list<Label> labels, Expression *expr );
    276280        ReturnStmt( const ReturnStmt &other );
     
    284288        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    285289        virtual void print( std::ostream &os, int indent = 0 ) const;
    286   private:
    287         Expression *expr;
    288290};
    289291
     
    291293  public:
    292294        enum Kind { Terminate, Resume };
     295
     296        const Kind kind;
     297        Expression * expr;
     298        Expression * target;
    293299
    294300        ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr );
     
    306312        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    307313        virtual void print( std::ostream &os, int indent = 0 ) const;
    308   private:
    309         Kind kind;
    310         Expression * expr;
    311         Expression * target;
    312314};
    313315
    314316class TryStmt : public Statement {
    315317  public:
     318        CompoundStmt *block;
     319        std::list<CatchStmt *> handlers;
     320        FinallyStmt *finallyBlock;
     321
    316322        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    317323        TryStmt( const TryStmt &other );
     
    329335        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    330336        virtual void print( std::ostream &os, int indent = 0 ) const;
    331 
    332   private:
    333         CompoundStmt *block;
    334         std::list<CatchStmt *> handlers;
    335         FinallyStmt *finallyBlock;
    336337};
    337338
     
    339340  public:
    340341        enum Kind { Terminate, Resume };
     342
     343        const Kind kind;
     344        Declaration *decl;
     345        Expression *cond;
     346        Statement *body;
    341347
    342348        CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl,
     
    357363        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    358364        virtual void print( std::ostream &os, int indent = 0 ) const;
    359 
    360   private:
    361         Kind kind;
    362         Declaration *decl;
    363         Expression *cond;
    364         Statement *body;
    365365};
    366366
    367367class FinallyStmt : public Statement {
    368368  public:
     369        CompoundStmt *block;
     370
    369371        FinallyStmt( std::list<Label> labels, CompoundStmt *block );
    370372        FinallyStmt( const FinallyStmt &other );
     
    378380        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    379381        virtual void print( std::ostream &os, int indent = 0 ) const;
    380   private:
    381         CompoundStmt *block;
    382382};
    383383
     
    386386class DeclStmt : public Statement {
    387387  public:
     388        Declaration *decl;
     389
    388390        DeclStmt( std::list<Label> labels, Declaration *decl );
    389391        DeclStmt( const DeclStmt &other );
     
    397399        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    398400        virtual void print( std::ostream &os, int indent = 0 ) const;
    399   private:
    400         Declaration *decl;
    401401};
    402402
     
    407407class ImplicitCtorDtorStmt : public Statement {
    408408  public:
     409        // Non-owned pointer to the constructor/destructor statement
     410        Statement * callStmt;
     411
    409412        ImplicitCtorDtorStmt( Statement * callStmt );
    410413        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
     
    418421        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    419422        virtual void print( std::ostream &os, int indent = 0 ) const;
    420 
    421   private:
    422         // Non-owned pointer to the constructor/destructor statement
    423         Statement * callStmt;
    424423};
    425424
  • src/SynTree/Type.cc

    rcbce272 r65cdc1e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 08:42:47 2017
    13 // Update Count     : 28
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  2 11:11:00 2017
     13// Update Count     : 29
    1414//
    1515
     
    8888}
    8989
     90// Empty Variable declarations:
     91const Type::FuncSpecifiers noFuncSpecifiers;
     92const Type::StorageClasses noStorageClasses;
     93const Type::Qualifiers noQualifiers;
     94
    9095std::ostream & operator<<( std::ostream & out, const Type * type ) {
    9196        if ( type ) {
  • src/SynTree/Type.h

    rcbce272 r65cdc1e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:53:29 2017
    13 // Update Count     : 151
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:25:00 2017
     13// Update Count     : 152
    1414//
    1515
     
    127127        }; // Qualifiers
    128128
     129        typedef std::list<TypeDecl *> ForallList;
     130
     131        Qualifiers tq;
     132        ForallList forall;
     133        std::list< Attribute * > attributes;
     134
    129135        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
    130136        Type( const Type & other );
     
    145151        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
    146152
    147         typedef std::list<TypeDecl *> ForallList;
    148153        ForallList& get_forall() { return forall; }
    149154
     
    165170        virtual Type *acceptMutator( Mutator & m ) = 0;
    166171        virtual void print( std::ostream & os, int indent = 0 ) const;
    167   private:
    168         Qualifiers tq;
    169         ForallList forall;
    170         std::list< Attribute * > attributes;
    171 };
    172 
    173 extern Type::Qualifiers noQualifiers;                           // no qualifiers on constants
     172};
     173
     174extern const Type::FuncSpecifiers noFuncSpecifiers;
     175extern const Type::StorageClasses noStorageClasses;
     176extern const Type::Qualifiers noQualifiers;                     // no qualifiers on constants
    174177
    175178class VoidType : public Type {
     
    211214                LongDoubleImaginary,
    212215                NUMBER_OF_BASIC_TYPES
    213         };
     216        } kind;
    214217
    215218        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
     
    226229
    227230        bool isInteger() const;
    228   private:
    229         Kind kind;
    230231};
    231232
    232233class PointerType : public Type {
    233234  public:
     235        Type *base;
     236
     237        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
     238        Expression *dimension;
     239        bool isVarLen;
     240        bool isStatic;
     241
    234242        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    235243        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     
    252260        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    253261        virtual void print( std::ostream & os, int indent = 0 ) const;
    254   private:
     262};
     263
     264class ArrayType : public Type {
     265  public:
    255266        Type *base;
    256 
    257         // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    258267        Expression *dimension;
    259268        bool isVarLen;
    260269        bool isStatic;
    261 };
    262 
    263 class ArrayType : public Type {
    264   public:
     270
    265271        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    266272        ArrayType( const ArrayType& );
     
    282288        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    283289        virtual void print( std::ostream & os, int indent = 0 ) const;
    284   private:
    285         Type *base;
    286         Expression *dimension;
    287         bool isVarLen;
    288         bool isStatic;
    289290};
    290291
    291292class FunctionType : public Type {
    292293  public:
     294        std::list<DeclarationWithType*> returnVals;
     295        std::list<DeclarationWithType*> parameters;
     296
     297        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
     298        // This could be because of
     299        // - an ellipsis in a prototype declaration
     300        // - an unprototyped declaration
     301        bool isVarArgs;
     302
    293303        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    294304        FunctionType( const FunctionType& );
     
    305315        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    306316        virtual void print( std::ostream & os, int indent = 0 ) const;
    307   private:
    308         std::list<DeclarationWithType*> returnVals;
    309         std::list<DeclarationWithType*> parameters;
    310 
    311         // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
    312         // This could be because of
    313         // - an ellipsis in a prototype declaration
    314         // - an unprototyped declaration
    315         bool isVarArgs;
    316317};
    317318
    318319class ReferenceToType : public Type {
    319320  public:
     321        std::list< Expression* > parameters;
     322        std::string name;
     323        bool hoistType;
     324
    320325        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    321326        ReferenceToType( const ReferenceToType & other );
     
    336341  protected:
    337342        virtual std::string typeString() const = 0;
    338         std::list< Expression* > parameters;
    339         std::string name;
    340   private:
    341         bool hoistType;
    342343};
    343344
     
    345346        typedef ReferenceToType Parent;
    346347  public:
     348        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
     349        // where the structure used in this type is actually defined
     350        StructDecl *baseStruct;
     351
    347352        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
    348353        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    368373  private:
    369374        virtual std::string typeString() const;
    370 
    371         // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
    372         // where the structure used in this type is actually defined
    373         StructDecl *baseStruct;
    374375};
    375376
     
    377378        typedef ReferenceToType Parent;
    378379  public:
     380        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
     381        // where the union used in this type is actually defined
     382        UnionDecl *baseUnion;
     383
    379384        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
    380385        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    400405  private:
    401406        virtual std::string typeString() const;
    402 
     407};
     408
     409class EnumInstType : public ReferenceToType {
     410        typedef ReferenceToType Parent;
     411  public:
    403412        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    404413        // where the union used in this type is actually defined
    405         UnionDecl *baseUnion;
    406 };
    407 
    408 class EnumInstType : public ReferenceToType {
    409         typedef ReferenceToType Parent;
    410   public:
     414        EnumDecl *baseEnum = nullptr;
     415
    411416        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    412417        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    423428  private:
    424429        virtual std::string typeString() const;
    425 
    426         // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    427         // where the union used in this type is actually defined
    428         EnumDecl *baseEnum = nullptr;
    429430};
    430431
     
    432433        typedef ReferenceToType Parent;
    433434  public:
     435        // this member is filled in by the validate pass, which instantiates the members of the correponding
     436        // aggregate with the actual type parameters specified for this use of the context
     437        std::list< Declaration* > members;
     438
    434439        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    435440        TraitInstType( const TraitInstType & other );
     
    445450  private:
    446451        virtual std::string typeString() const;
    447 
    448         // this member is filled in by the validate pass, which instantiates the members of the correponding
    449         // aggregate with the actual type parameters specified for this use of the context
    450         std::list< Declaration* > members;
    451452};
    452453
     
    454455        typedef ReferenceToType Parent;
    455456  public:
     457        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
     458        // where the type used here is actually defined
     459        TypeDecl *baseType;
     460        bool isFtype;
     461
    456462        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    457463        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    472478  private:
    473479        virtual std::string typeString() const;
    474         // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
    475         // where the type used here is actually defined
    476         TypeDecl *baseType;
    477         bool isFtype;
    478480};
    479481
    480482class TupleType : public Type {
    481483  public:
     484        std::list<Type *> types;
     485        std::list<Declaration *> members;
     486
    482487        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    483488        TupleType( const TupleType& );
     
    508513        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    509514        virtual void print( std::ostream & os, int indent = 0 ) const;
    510   private:
    511         std::list<Type *> types;
    512         std::list<Declaration *> members;
    513515};
    514516
    515517class TypeofType : public Type {
    516518  public:
     519        Expression *expr;
     520
    517521        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    518522        TypeofType( const TypeofType& );
     
    528532        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    529533        virtual void print( std::ostream & os, int indent = 0 ) const;
    530   private:
     534};
     535
     536class AttrType : public Type {
     537  public:
     538        std::string name;
    531539        Expression *expr;
    532 };
    533 
    534 class AttrType : public Type {
    535   public:
     540        Type *type;
     541        bool isType;
     542
    536543        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    537544        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    554561        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    555562        virtual void print( std::ostream & os, int indent = 0 ) const;
    556   private:
    557         std::string name;
    558         Expression *expr;
    559         Type *type;
    560         bool isType;
    561563};
    562564
  • src/SynTree/TypeDecl.cc

    rcbce272 r65cdc1e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:49:58 2017
    13 // Update Count     : 5
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:35:00 2017
     13// Update Count     : 6
    1414//
    1515
     
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), kind( kind ), init( init ), sized( kind == Any || kind == Ttype ) {
     20TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) {
    2121}
    2222
    23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) {
     23TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) {
    2424}
    2525
Note: See TracChangeset for help on using the changeset viewer.