Changeset 07de76b for src/SynTree


Ignore:
Timestamp:
Dec 16, 2019, 2:30:41 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
bffcd66
Parents:
ab5c0008
git-author:
Peter A. Buhr <pabuhr@…> (12/16/19 14:23:00)
git-committer:
Peter A. Buhr <pabuhr@…> (12/16/19 14:30:41)
Message:

remove file TypeVar.h* and put TypeVar::Kind into TypeDecl, move LinkageSpec.* from directory Parse to SynTree

Location:
src/SynTree
Files:
9 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    rab5c0008 r07de76b  
    1010// Created On       : Sun May 17 23:56:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:31:55 2019
    13 // Update Count     : 29
     12// Last Modified On : Fri Dec 13 23:10:22 2019
     13// Update Count     : 30
    1414//
    1515
     
    2222#include "Declaration.h"         // for AggregateDecl, TypeDecl, Declaration
    2323#include "Initializer.h"
    24 #include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
     24#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
    2525#include "Type.h"                // for Type, Type::StorageClasses
    2626
  • src/SynTree/Declaration.h

    rab5c0008 r07de76b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 16:48:20 2019
    13 // Update Count     : 149
     12// Last Modified On : Fri Dec 13 23:11:22 2019
     13// Update Count     : 157
    1414//
    1515
     
    2424#include "BaseSyntaxNode.h"      // for BaseSyntaxNode
    2525#include "Mutator.h"             // for Mutator
    26 #include "Parser/LinkageSpec.h"  // for Spec, Cforall
     26#include "LinkageSpec.h"         // for Spec, Cforall
    2727#include "SynTree.h"             // for UniqueId
    2828#include "SynTree/Type.h"        // for Type, Type::StorageClasses, Type::Fu...
     
    4343        bool extension = false;
    4444
    45         Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    46         Declaration( const Declaration &other );
     45        Declaration( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
     46        Declaration( const Declaration & other );
    4747        virtual ~Declaration();
    4848
    49         const std::string &get_name() const { return name; }
     49        const std::string & get_name() const { return name; }
    5050        void set_name( std::string newValue ) { name = newValue; }
    5151
     
    5858
    5959        bool get_extension() const { return extension; }
    60         Declaration *set_extension( bool exten ) { extension = exten; return this; }
     60        Declaration * set_extension( bool exten ) { extension = exten; return this; }
    6161
    6262        void fixUniqueId( void );
    63         virtual Declaration *clone() const override = 0;
     63        virtual Declaration * clone() const override = 0;
    6464        virtual void accept( Visitor & v ) override = 0;
    6565        virtual void accept( Visitor & v ) const override = 0;
    66         virtual Declaration *acceptMutator( Mutator &m ) override = 0;
    67         virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0;
    68         virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0;
     66        virtual Declaration * acceptMutator( Mutator & m ) override = 0;
     67        virtual void print( std::ostream & os, Indenter indent = {} ) const override = 0;
     68        virtual void printShort( std::ostream & os, Indenter indent = {} ) const = 0;
    6969
    7070        UniqueId uniqueId;
     
    8080        int scopeLevel = 0;
    8181
    82         Expression *asmName;
     82        Expression * asmName;
    8383        std::list< Attribute * > attributes;
    8484        bool isDeleted = false;
    8585
    86         DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    87         DeclarationWithType( const DeclarationWithType &other );
     86        DeclarationWithType( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
     87        DeclarationWithType( const DeclarationWithType & other );
    8888        virtual ~DeclarationWithType();
    8989
     
    9696        DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
    9797
    98         Expression *get_asmName() const { return asmName; }
    99         DeclarationWithType * set_asmName( Expression *newValue ) { asmName = newValue; return this; }
     98        Expression * get_asmName() const { return asmName; }
     99        DeclarationWithType * set_asmName( Expression * newValue ) { asmName = newValue; return this; }
    100100
    101101        std::list< Attribute * >& get_attributes() { return attributes; }
     
    105105        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    106106
    107         virtual DeclarationWithType *clone() const override = 0;
    108         virtual DeclarationWithType *acceptMutator( Mutator &m )  override = 0;
     107        virtual DeclarationWithType * clone() const override = 0;
     108        virtual DeclarationWithType * acceptMutator( Mutator & m )  override = 0;
    109109
    110110        virtual Type * get_type() const = 0;
     
    118118        typedef DeclarationWithType Parent;
    119119  public:
    120         Type *type;
    121         Initializer *init;
    122         Expression *bitfieldWidth;
    123 
    124         ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
     120        Type * type;
     121        Initializer * init;
     122        Expression * bitfieldWidth;
     123
     124        ObjectDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression * bitfieldWidth, Type * type, Initializer * init,
    125125                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    126         ObjectDecl( const ObjectDecl &other );
     126        ObjectDecl( const ObjectDecl & other );
    127127        virtual ~ObjectDecl();
    128128
    129129        virtual Type * get_type() const override { return type; }
    130         virtual void set_type(Type *newType) override { type = newType; }
    131 
    132         Initializer *get_init() const { return init; }
    133         void set_init( Initializer *newValue ) { init = newValue; }
    134 
    135         Expression *get_bitfieldWidth() const { return bitfieldWidth; }
    136         void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; }
     130        virtual void set_type(Type * newType) override { type = newType; }
     131
     132        Initializer * get_init() const { return init; }
     133        void set_init( Initializer * newValue ) { init = newValue; }
     134
     135        Expression * get_bitfieldWidth() const { return bitfieldWidth; }
     136        void set_bitfieldWidth( Expression * newValue ) { bitfieldWidth = newValue; }
    137137
    138138        static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init );
    139139
    140         virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); }
    141         virtual void accept( Visitor & v ) override { v.visit( this ); }
    142         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    143         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    144         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    145         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     140        virtual ObjectDecl * clone() const override { return new ObjectDecl( *this ); }
     141        virtual void accept( Visitor & v ) override { v.visit( this ); }
     142        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     143        virtual DeclarationWithType * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     144        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     145        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    146146};
    147147
     
    149149        typedef DeclarationWithType Parent;
    150150  public:
    151         FunctionType *type;
    152         CompoundStmt *statements;
     151        FunctionType * type;
     152        CompoundStmt * statements;
    153153        std::list< Expression * > withExprs;
    154154
    155         FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
     155        FunctionDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType * type, CompoundStmt * statements,
    156156                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    157         FunctionDecl( const FunctionDecl &other );
     157        FunctionDecl( const FunctionDecl & other );
    158158        virtual ~FunctionDecl();
    159159
     
    162162
    163163        FunctionType * get_functionType() const { return type; }
    164         void set_functionType( FunctionType *newValue ) { type = newValue; }
    165         CompoundStmt *get_statements() const { return statements; }
    166         void set_statements( CompoundStmt *newValue ) { statements = newValue; }
     164        void set_functionType( FunctionType * newValue ) { type = newValue; }
     165        CompoundStmt * get_statements() const { return statements; }
     166        void set_statements( CompoundStmt * newValue ) { statements = newValue; }
    167167        bool has_body() const { return NULL != statements; }
    168168
    169169        static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements );
    170170
    171         virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
    172         virtual void accept( Visitor & v ) override { v.visit( this ); }
    173         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    174         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    175         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    176         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     171        virtual FunctionDecl * clone() const override { return new FunctionDecl( *this ); }
     172        virtual void accept( Visitor & v ) override { v.visit( this ); }
     173        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     174        virtual DeclarationWithType * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     175        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     176        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    177177};
    178178
     
    180180        typedef Declaration Parent;
    181181  public:
    182         Type *base;
    183         std::list< TypeDecl* > parameters;
    184         std::list< DeclarationWithType* > assertions;
    185 
    186         NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    187         NamedTypeDecl( const NamedTypeDecl &other );
     182        Type * base;
     183        std::list< TypeDecl * > parameters;
     184        std::list< DeclarationWithType * > assertions;
     185
     186        NamedTypeDecl( const std::string & name, Type::StorageClasses scs, Type * type );
     187        NamedTypeDecl( const NamedTypeDecl & other );
    188188        virtual ~NamedTypeDecl();
    189189
    190         Type *get_base() const { return base; }
    191         void set_base( Type *newValue ) { base = newValue; }
    192         std::list< TypeDecl* >& get_parameters() { return parameters; }
    193         std::list< DeclarationWithType* >& get_assertions() { return assertions; }
     190        Type * get_base() const { return base; }
     191        void set_base( Type * newValue ) { base = newValue; }
     192        std::list< TypeDecl* > & get_parameters() { return parameters; }
     193        std::list< DeclarationWithType * >& get_assertions() { return assertions; }
    194194
    195195        virtual const char * typeString() const = 0;
    196196
    197         virtual NamedTypeDecl *clone() const override = 0;
    198         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    199         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     197        virtual NamedTypeDecl * clone() const override = 0;
     198        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     199        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    200200};
    201201
     
    203203        typedef NamedTypeDecl Parent;
    204204  public:
    205         enum Kind { Dtype, Ftype, Ttype, NUMBER_OF_KINDS };
    206 
     205        enum Kind { Dtype, Otype, Ftype, Ttype, NUMBER_OF_KINDS };
     206
     207        Kind kind;
     208        bool sized;
    207209        Type * init;
    208         bool sized;
    209210
    210211        /// Data extracted from a type decl
    211212        struct Data {
    212                 TypeDecl::Kind kind;
     213                Kind kind;
    213214                bool isComplete;
    214215
    215                 Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {}
    216                 Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}
     216                Data() : kind( NUMBER_OF_KINDS ), isComplete( false ) {}
     217                Data( const TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}
    217218                Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {}
    218                 Data( const Data& d1, const Data& d2 )
    219                 : kind( d1.kind ), isComplete ( d1.isComplete || d2.isComplete ) {}
    220 
    221                 bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; }
    222                 bool operator!=(const Data & other) const { return !(*this == other);}
     219                Data( const Data & d1, const Data & d2 )
     220                        : kind( d1.kind ), isComplete( d1.isComplete || d2.isComplete ) {}
     221
     222                bool operator==( const Data & other ) const { return kind == other.kind && isComplete == other.isComplete; }
     223                bool operator!=( const Data & other ) const { return !(*this == other);}
    223224        };
    224225
    225         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    226         TypeDecl( const TypeDecl &other );
     226        TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init = nullptr );
     227        TypeDecl( const TypeDecl & other );
    227228        virtual ~TypeDecl();
    228229
     
    239240        virtual const char * genTypeString() const;
    240241
    241         virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
    242         virtual void accept( Visitor & v ) override { v.visit( this ); }
    243         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    244         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    245         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    246 
    247         Kind kind;
     242        virtual TypeDecl * clone() const override { return new TypeDecl( *this ); }
     243        virtual void accept( Visitor & v ) override { v.visit( this ); }
     244        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     245        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     246        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
    248247};
    249248
     
    251250        typedef NamedTypeDecl Parent;
    252251  public:
    253         TypedefDecl( const std::string &name, CodeLocation location, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall )
     252        TypedefDecl( const std::string & name, CodeLocation location, Type::StorageClasses scs, Type * type, LinkageSpec::Spec spec = LinkageSpec::Cforall )
    254253                : Parent( name, scs, type ) { set_linkage( spec ); this->location = location; }
    255254
    256         TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    257 
    258         virtual const char * typeString() const override;
    259 
    260         virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
    261         virtual void accept( Visitor & v ) override { v.visit( this ); }
    262         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    263         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     255        TypedefDecl( const TypedefDecl & other ) : Parent( other ) {}
     256
     257        virtual const char * typeString() const override;
     258
     259        virtual TypedefDecl * clone() const override { return new TypedefDecl( *this ); }
     260        virtual void accept( Visitor & v ) override { v.visit( this ); }
     261        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     262        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    264263  private:
    265264};
     
    277276        AggregateDecl * parent = nullptr;
    278277
    279         AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    280         AggregateDecl( const AggregateDecl &other );
     278        AggregateDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
     279        AggregateDecl( const AggregateDecl & other );
    281280        virtual ~AggregateDecl();
    282281
     
    290289        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    291290
    292         virtual void print( std::ostream &os, Indenter indent = {} ) const override final;
    293         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     291        virtual void print( std::ostream & os, Indenter indent = {} ) const override final;
     292        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    294293  protected:
    295294        virtual const char * typeString() const = 0;
     
    299298        typedef AggregateDecl Parent;
    300299  public:
    301         StructDecl( const std::string &name, Aggregate kind = Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
    302         StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {}
     300        StructDecl( const std::string & name, Aggregate kind = Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
     301        StructDecl( const StructDecl & other ) : Parent( other ), kind( other.kind ) {}
    303302
    304303        bool is_coroutine() { return kind == Coroutine; }
     
    306305        bool is_thread() { return kind == Thread; }
    307306
    308         virtual StructDecl *clone() const override { return new StructDecl( *this ); }
    309         virtual void accept( Visitor & v ) override { v.visit( this ); }
    310         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    311         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     307        virtual StructDecl * clone() const override { return new StructDecl( *this ); }
     308        virtual void accept( Visitor & v ) override { v.visit( this ); }
     309        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     310        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    312311        Aggregate kind;
    313312  private:
     
    318317        typedef AggregateDecl Parent;
    319318  public:
    320         UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
    321         UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    322 
    323         virtual UnionDecl *clone() const override { return new UnionDecl( *this ); }
    324         virtual void accept( Visitor & v ) override { v.visit( this ); }
    325         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    326         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     319        UnionDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
     320        UnionDecl( const UnionDecl & other ) : Parent( other ) {}
     321
     322        virtual UnionDecl * clone() const override { return new UnionDecl( *this ); }
     323        virtual void accept( Visitor & v ) override { v.visit( this ); }
     324        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     325        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    327326  private:
    328327        virtual const char * typeString() const override;
     
    332331        typedef AggregateDecl Parent;
    333332  public:
    334         EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
    335         EnumDecl( const EnumDecl &other ) : Parent( other ) {}
     333        EnumDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
     334        EnumDecl( const EnumDecl & other ) : Parent( other ) {}
    336335
    337336        bool valueOf( Declaration * enumerator, long long int & value );
    338337
    339         virtual EnumDecl *clone() const override { return new EnumDecl( *this ); }
    340         virtual void accept( Visitor & v ) override { v.visit( this ); }
    341         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    342         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     338        virtual EnumDecl * clone() const override { return new EnumDecl( *this ); }
     339        virtual void accept( Visitor & v ) override { v.visit( this ); }
     340        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     341        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    343342  private:
    344343        std::unordered_map< std::string, long long int > enumValues;
     
    349348        typedef AggregateDecl Parent;
    350349  public:
    351         TraitDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) {
     350        TraitDecl( const std::string & name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) {
    352351                assertf( attributes.empty(), "attribute unsupported for traits" );
    353352        }
    354         TraitDecl( const TraitDecl &other ) : Parent( other ) {}
    355 
    356         virtual TraitDecl *clone() const override { return new TraitDecl( *this ); }
    357         virtual void accept( Visitor & v ) override { v.visit( this ); }
    358         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    359         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     353        TraitDecl( const TraitDecl & other ) : Parent( other ) {}
     354
     355        virtual TraitDecl * clone() const override { return new TraitDecl( *this ); }
     356        virtual void accept( Visitor & v ) override { v.visit( this ); }
     357        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     358        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    360359  private:
    361360        virtual const char * typeString() const override;
     
    381380class AsmDecl : public Declaration {
    382381  public:
    383         AsmStmt *stmt;
    384 
    385         AsmDecl( AsmStmt *stmt );
    386         AsmDecl( const AsmDecl &other );
     382        AsmStmt * stmt;
     383
     384        AsmDecl( AsmStmt * stmt );
     385        AsmDecl( const AsmDecl & other );
    387386        virtual ~AsmDecl();
    388387
    389         AsmStmt *get_stmt() { return stmt; }
    390         void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
    391 
    392         virtual AsmDecl *clone() const override { return new AsmDecl( *this ); }
    393         virtual void accept( Visitor & v ) override { v.visit( this ); }
    394         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    395         virtual AsmDecl *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    396         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    397         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     388        AsmStmt * get_stmt() { return stmt; }
     389        void set_stmt( AsmStmt * newValue ) { stmt = newValue; }
     390
     391        virtual AsmDecl * clone() const override { return new AsmDecl( *this ); }
     392        virtual void accept( Visitor & v ) override { v.visit( this ); }
     393        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     394        virtual AsmDecl * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     395        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     396        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    398397};
    399398
     
    410409        virtual void accept( Visitor & v ) override { v.visit( this ); }
    411410        virtual void accept( Visitor & v ) const override { v.visit( this ); }
    412         virtual StaticAssertDecl * acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    413         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    414         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     411        virtual StaticAssertDecl * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     412        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     413        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    415414};
    416415
  • src/SynTree/DeclarationWithType.cc

    rab5c0008 r07de76b  
    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:34:35 2017
    13 // Update Count     : 25
     12// Last Modified On : Fri Dec 13 23:45:16 2019
     13// Update Count     : 26
    1414//
    1515
     
    2020#include "Common/utility.h"      // for cloneAll, deleteAll, maybeClone
    2121#include "Declaration.h"         // for DeclarationWithType, Declaration
    22 #include "Parser/LinkageSpec.h"  // for Spec
    23 #include "SynTree/Expression.h"  // for ConstantExpr
     22#include "LinkageSpec.h"         // for Spec
     23#include "Expression.h"          // for ConstantExpr
    2424#include "Type.h"                // for Type, Type::FuncSpecifiers, Type::St...
    2525
  • src/SynTree/FunctionDecl.cc

    rab5c0008 r07de76b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec  7 17:40:09 2019
    13 // Update Count     : 75
     12// Last Modified On : Fri Dec 13 23:10:34 2019
     13// Update Count     : 76
    1414//
    1515
     
    2424#include "Declaration.h"         // for FunctionDecl, FunctionDecl::Parent
    2525#include "Expression.h"
    26 #include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
     26#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
    2727#include "Statement.h"           // for CompoundStmt
    2828#include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
  • src/SynTree/NamedTypeDecl.cc

    rab5c0008 r07de76b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 08:26:17 2019
    13 // Update Count     : 15
     12// Last Modified On : Fri Dec 13 23:44:24 2019
     13// Update Count     : 16
    1414//
    1515
     
    2020#include "Common/utility.h"      // for printAll, cloneAll, deleteAll, maybe...
    2121#include "Declaration.h"         // for NamedTypeDecl, DeclarationWithType
    22 #include "Parser/LinkageSpec.h"  // for Spec, Cforall, linkageName
     22#include "LinkageSpec.h"         // for Spec, Cforall, linkageName
    2323#include "Type.h"                // for Type, Type::StorageClasses
    2424
  • src/SynTree/ObjectDecl.cc

    rab5c0008 r07de76b  
    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:34:27 2017
    13 // Update Count     : 59
     12// Last Modified On : Fri Dec 13 23:44:50 2019
     13// Update Count     : 60
    1414//
    1515
     
    2323#include "Expression.h"          // for Expression
    2424#include "Initializer.h"         // for Initializer
    25 #include "Parser/LinkageSpec.h"  // for Spec, linkageName, Cforall
     25#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
    2626#include "Type.h"                // for Type, Type::StorageClasses, Type::Fu...
    2727
  • src/SynTree/TupleType.cc

    rab5c0008 r07de76b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  1 17:10:58 2017
    13 // Update Count     : 3
     12// Last Modified On : Fri Dec 13 23:44:38 2019
     13// Update Count     : 4
    1414//
    1515
     
    2020#include "Declaration.h"         // for Declaration, ObjectDecl
    2121#include "Initializer.h"         // for ListInit
    22 #include "Parser/LinkageSpec.h"  // for Cforall
     22#include "LinkageSpec.h"         // for Cforall
    2323#include "Type.h"                // for TupleType, Type, Type::Qualifiers
    2424
  • src/SynTree/TypeDecl.cc

    rab5c0008 r07de76b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 17:56:30 2019
    13 // Update Count     : 10
     12// Last Modified On : Fri Dec 13 15:26:14 2019
     13// Update Count     : 21
    1414//
    1515
     
    1818
    1919#include "Common/utility.h"  // for maybeClone
    20 #include "Parser/ParseNode.h"
    2120#include "Declaration.h"     // for TypeDecl, TypeDecl::Data, TypeDecl::Kind...
    2221#include "Type.h"            // for Type, Type::StorageClasses
    2322
    24 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) {
     23TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), kind( kind ), sized( kind == Ttype || sized ), init( init ) {
    2524}
    2625
    27 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) {
     26TypeDecl::TypeDecl( const TypeDecl & other ) : Parent( other ), kind( other.kind ), sized( other.sized ), init( maybeClone( other.init ) ) {
    2827}
    2928
    3029TypeDecl::~TypeDecl() {
    31   delete init;
     30        delete init;
    3231}
    3332
    3433const char * TypeDecl::typeString() const {
    35         static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" };
    36         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );
    37         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     34        static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" };
     35        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
     36        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    3837        return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
    3938}
    4039
    4140const char * TypeDecl::genTypeString() const {
    42         static const char * kindNames[] = { "dtype", "ftype", "ttype" };
    43         assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    44         assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     41        static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };
     42        static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );
     43        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
    4544        return kindNames[ kind ];
    4645}
    4746
    4847void TypeDecl::print( std::ostream &os, Indenter indent ) const {
    49   NamedTypeDecl::print( os, indent );
    50   if ( init ) {
    51     os << std::endl << indent << "with type initializer: ";
    52     init->print( os, indent + 1 );
    53   }
     48        NamedTypeDecl::print( os, indent );
     49        if ( init ) {
     50                os << std::endl << indent << "with type initializer: ";
     51                init->print( os, indent + 1 );
     52        } // if
    5453}
    5554
    56 
    5755std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
    58   return os << data.kind << ", " << data.isComplete;
     56        return os << data.kind << ", " << data.isComplete;
    5957}
    6058
  • src/SynTree/module.mk

    rab5c0008 r07de76b  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Mon Jun  1 17:54:09 2015
    14 ## Update Count     : 1
     13## Last Modified On : Sat Dec 14 07:26:43 2019
     14## Update Count     : 2
    1515###############################################################################
    1616
    1717SRC_SYNTREE = \
    18       SynTree/Type.cc \
    19       SynTree/VoidType.cc \
     18      SynTree/AddressExpr.cc \
     19      SynTree/AggregateDecl.cc \
     20      SynTree/ApplicationExpr.cc \
     21      SynTree/ArrayType.cc \
     22      SynTree/AttrType.cc \
     23      SynTree/Attribute.cc \
    2024      SynTree/BasicType.cc \
    21       SynTree/PointerType.cc \
    22       SynTree/ArrayType.cc \
    23       SynTree/ReferenceType.cc \
    24       SynTree/FunctionType.cc \
    25       SynTree/ReferenceToType.cc \
    26       SynTree/TupleType.cc \
    27       SynTree/TypeofType.cc \
    28       SynTree/AttrType.cc \
    29       SynTree/VarArgsType.cc \
    30       SynTree/ZeroOneType.cc \
     25      SynTree/CommaExpr.cc \
     26      SynTree/CompoundStmt.cc \
    3127      SynTree/Constant.cc \
    32       SynTree/Expression.cc \
    33       SynTree/TupleExpr.cc \
    34       SynTree/CommaExpr.cc \
    35       SynTree/TypeExpr.cc \
    36       SynTree/ApplicationExpr.cc \
    37       SynTree/AddressExpr.cc \
    38       SynTree/Statement.cc \
    39       SynTree/CompoundStmt.cc \
     28      SynTree/DeclReplacer.cc \
    4029      SynTree/DeclStmt.cc \
    4130      SynTree/Declaration.cc \
    4231      SynTree/DeclarationWithType.cc \
     32      SynTree/Expression.cc \
     33      SynTree/FunctionDecl.cc \
     34      SynTree/FunctionType.cc \
     35      SynTree/Initializer.cc \
     36      SynTree/LinkageSpec.cc \
     37      SynTree/NamedTypeDecl.cc \
    4338      SynTree/ObjectDecl.cc \
    44       SynTree/FunctionDecl.cc \
    45       SynTree/AggregateDecl.cc \
    46       SynTree/NamedTypeDecl.cc \
     39      SynTree/PointerType.cc \
     40      SynTree/ReferenceToType.cc \
     41      SynTree/ReferenceType.cc \
     42      SynTree/Statement.cc \
     43      SynTree/TupleExpr.cc \
     44      SynTree/TupleType.cc \
     45      SynTree/Type.cc \
    4746      SynTree/TypeDecl.cc \
    48       SynTree/Initializer.cc \
     47      SynTree/TypeExpr.cc \
    4948      SynTree/TypeSubstitution.cc \
    50       SynTree/Attribute.cc \
    51       SynTree/DeclReplacer.cc
     49      SynTree/TypeofType.cc \
     50      SynTree/VarArgsType.cc \
     51      SynTree/VoidType.cc \
     52      SynTree/ZeroOneType.cc
    5253
    5354SRC += $(SRC_SYNTREE)
Note: See TracChangeset for help on using the changeset viewer.