Ignore:
Timestamp:
Jan 7, 2015, 6:04:42 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
0b8cd722
Parents:
d9a0e76
Message:

fixed restrict, fixed parameter copy, introduced name table for types, changed variable after to string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/Declaration.h

    rd9a0e76 r17cd4eb  
    1 /*
    2  * This file is part of the Cforall project
    3  *
    4  * $Id: Declaration.h,v 1.22 2005/08/29 20:59:25 rcbilson Exp $
    5  *
    6  */
    7 
    81#ifndef DECLARATION_H
    92#define DECLARATION_H
     
    158
    169
    17 class Declaration
    18 {
    19 public:
    20     enum StorageClass
    21     { 
     10class Declaration {
     11  public:
     12    enum StorageClass { 
    2213        NoStorageClass,
    2314        Auto,
     
    2718        Fortran
    2819    }; 
    29    
     20
    3021    Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage );
    3122    Declaration( const Declaration &other );
     
    3930    void set_linkage( LinkageSpec::Type newValue ) { linkage = newValue; }
    4031    UniqueId get_uniqueId() const { return uniqueId; }
    41    
     32
    4233    void fixUniqueId( void );
    4334    virtual Declaration *clone() const = 0;
     
    4637    virtual void print( std::ostream &os, int indent = 0 ) const = 0;
    4738    virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
    48    
     39
    4940    static const char* storageClassName[]; 
    50    
     41
    5142    static void dumpIds( std::ostream &os );
    5243    static Declaration *declFromId( UniqueId id );
    53    
    54 private:
     44  private:
    5545    std::string name;
    5646    StorageClass storageClass;
     
    5949};
    6050
    61 class DeclarationWithType : public Declaration
    62 {
    63 public:
     51class DeclarationWithType : public Declaration {
     52  public:
    6453    DeclarationWithType( const std::string &name, StorageClass sc, LinkageSpec::Type linkage );
    6554    DeclarationWithType( const DeclarationWithType &other );
     
    6857    std::string get_mangleName() const { return mangleName; }
    6958    void set_mangleName( std::string newValue ) { mangleName = newValue; }
    70    
     59
    7160    virtual DeclarationWithType *clone() const = 0;
    7261    virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
    73    
     62
    7463    virtual Type *get_type() const = 0;
    7564    virtual void set_type(Type *) = 0;
    76    
    77 private:
    78     // this represents the type with all types and typedefs expanded
    79     // it is generated by SymTab::Validate::Pass2
     65  private:
     66    // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    8067    std::string mangleName;
    8168};
    8269
    83 class ObjectDecl : public DeclarationWithType
    84 {
     70class ObjectDecl : public DeclarationWithType {
    8571    typedef DeclarationWithType Parent;
    86 
    87 public:
     72  public:
    8873    ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init );
    8974    ObjectDecl( const ObjectDecl &other );
     
    9782    Expression *get_bitfieldWidth() const { return bitfieldWidth; }
    9883    void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; }
    99    
     84
    10085    virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); }
    10186    virtual void accept( Visitor &v ) { v.visit( this ); }
     
    10388    virtual void print( std::ostream &os, int indent = 0 ) const;
    10489    virtual void printShort( std::ostream &os, int indent = 0 ) const;
    105    
    106 private:
     90  private:
    10791    Type *type;
    10892    Initializer *init;
     
    11094};
    11195
    112 class FunctionDecl : public DeclarationWithType
    113 {
     96class FunctionDecl : public DeclarationWithType {
    11497    typedef DeclarationWithType Parent;
    115 
    116 public:
     98  public:
    11799    FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline );
    118100    FunctionDecl( const FunctionDecl &other );
     
    130112    std::list< std::string >& get_oldIdents() { return oldIdents; }
    131113    std::list< Declaration* >& get_oldDecls() { return oldDecls; }
    132    
     114
    133115    virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
    134116    virtual void accept( Visitor &v ) { v.visit( this ); }
     
    136118    virtual void print( std::ostream &os, int indent = 0 ) const;
    137119    virtual void printShort( std::ostream &os, int indent = 0 ) const;
    138    
    139 private:
     120  private:
    140121    FunctionType *type;
    141122    CompoundStmt *statements;
     
    145126};
    146127
    147 class NamedTypeDecl : public Declaration
    148 {
     128class NamedTypeDecl : public Declaration {
    149129    typedef Declaration Parent;
    150 
    151 public:
     130  public:
    152131    NamedTypeDecl( const std::string &name, StorageClass sc, Type *type );
    153132    NamedTypeDecl( const TypeDecl &other );
     
    162141    virtual void print( std::ostream &os, int indent = 0 ) const;
    163142    virtual void printShort( std::ostream &os, int indent = 0 ) const;
    164    
    165 protected:
     143  protected:
    166144    virtual std::string typeString() const = 0;
    167    
    168 private:
     145  private:
    169146    Type *base;
    170147    std::list< TypeDecl* > parameters;
     
    172149};
    173150
    174 class TypeDecl : public NamedTypeDecl
    175 {
     151class TypeDecl : public NamedTypeDecl {
    176152    typedef NamedTypeDecl Parent;
    177 
    178 public:
     153  public:
    179154    enum Kind { Any, Dtype, Ftype };
    180155
    181156    TypeDecl( const std::string &name, StorageClass sc, Type *type, Kind kind );
    182157    TypeDecl( const TypeDecl &other );
    183    
     158
    184159    Kind get_kind() const { return kind; }
    185160
     
    187162    virtual void accept( Visitor &v ) { v.visit( this ); }
    188163    virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    189 
    190 private:
     164  private:
    191165    virtual std::string typeString() const;
    192166    Kind kind;
    193167};
    194    
    195 class TypedefDecl : public NamedTypeDecl
    196 {
     168
     169class TypedefDecl : public NamedTypeDecl {
    197170    typedef NamedTypeDecl Parent;
    198 
    199 public:
     171  public:
    200172    TypedefDecl( const std::string &name, StorageClass sc, Type *type ) : Parent( name, sc, type ) {}
    201173    TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    202    
     174
    203175    virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }
    204176    virtual void accept( Visitor &v ) { v.visit( this ); }
    205177    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    206 
    207 private:
    208     virtual std::string typeString() const;
    209 };
    210    
    211 class AggregateDecl : public Declaration
    212 {
     178  private:
     179    virtual std::string typeString() const;
     180};
     181
     182class AggregateDecl : public Declaration {
    213183    typedef Declaration Parent;
    214 
    215 public:
     184  public:
    216185    AggregateDecl( const std::string &name );
    217186    AggregateDecl( const AggregateDecl &other );
     
    220189    std::list<Declaration*>& get_members() { return members; }
    221190    std::list<TypeDecl*>& get_parameters() { return parameters; }
    222    
    223     virtual void print( std::ostream &os, int indent = 0 ) const;
    224     virtual void printShort( std::ostream &os, int indent = 0 ) const;
    225 
    226 protected:
     191
     192    virtual void print( std::ostream &os, int indent = 0 ) const;
     193    virtual void printShort( std::ostream &os, int indent = 0 ) const;
     194  protected:
    227195    virtual std::string typeString() const = 0;
    228    
    229 private:
     196
     197  private:
    230198    std::list<Declaration*> members;
    231199    std::list<TypeDecl*> parameters;
    232200};
    233201
    234 class StructDecl : public AggregateDecl
    235 {
    236     typedef AggregateDecl Parent;
    237 
    238 public:
     202class StructDecl : public AggregateDecl {
     203    typedef AggregateDecl Parent;
     204  public:
    239205    StructDecl( const std::string &name ) : Parent( name ) {}
    240206    StructDecl( const StructDecl &other ) : Parent( other ) {}
    241    
     207
    242208    virtual StructDecl *clone() const { return new StructDecl( *this ); }
    243209    virtual void accept( Visitor &v ) { v.visit( this ); }
    244210    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    245211
    246 private:
    247     virtual std::string typeString() const;
    248 };
    249    
    250 class UnionDecl : public AggregateDecl
    251 {
    252     typedef AggregateDecl Parent;
    253 
    254 public:
     212  private:
     213    virtual std::string typeString() const;
     214};
     215
     216class UnionDecl : public AggregateDecl {
     217    typedef AggregateDecl Parent;
     218  public:
    255219    UnionDecl( const std::string &name ) : Parent( name ) {}
    256220    UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    257    
     221
    258222    virtual UnionDecl *clone() const { return new UnionDecl( *this ); }
    259223    virtual void accept( Visitor &v ) { v.visit( this ); }
    260224    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    261 
    262 private:
    263     virtual std::string typeString() const;
    264 };
    265    
    266 class EnumDecl : public AggregateDecl
    267 {
    268     typedef AggregateDecl Parent;
    269 
    270 public:
     225  private:
     226    virtual std::string typeString() const;
     227};
     228
     229class EnumDecl : public AggregateDecl {
     230    typedef AggregateDecl Parent;
     231  public:
    271232    EnumDecl( const std::string &name ) : Parent( name ) {}
    272233    EnumDecl( const EnumDecl &other ) : Parent( other ) {}
    273    
     234
    274235    virtual EnumDecl *clone() const { return new EnumDecl( *this ); }
    275236    virtual void accept( Visitor &v ) { v.visit( this ); }
    276237    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    277 
    278 private:
    279     virtual std::string typeString() const;
    280 };
    281    
    282 class ContextDecl : public AggregateDecl
    283 {
    284     typedef AggregateDecl Parent;
    285 
    286 public:
     238  private:
     239    virtual std::string typeString() const;
     240};
     241
     242class ContextDecl : public AggregateDecl {
     243    typedef AggregateDecl Parent;
     244  public:
    287245    ContextDecl( const std::string &name ) : Parent( name ) {}
    288246    ContextDecl( const ContextDecl &other ) : Parent( other ) {}
    289    
     247
    290248    virtual ContextDecl *clone() const { return new ContextDecl( *this ); }
    291249    virtual void accept( Visitor &v ) { v.visit( this ); }
    292250    virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    293 
    294 private:
    295     virtual std::string typeString() const;
    296 };
    297    
    298 
    299 
    300 #endif /* #ifndef DECLARATION_H */
     251  private:
     252    virtual std::string typeString() const;
     253};
     254
     255#endif // DECLARATION_H
Note: See TracChangeset for help on using the changeset viewer.