Changeset 17cd4eb for translator/SynTree/Declaration.h
- Timestamp:
- Jan 7, 2015, 6:04:42 PM (10 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/Declaration.h
rd9a0e76 r17cd4eb 1 /*2 * This file is part of the Cforall project3 *4 * $Id: Declaration.h,v 1.22 2005/08/29 20:59:25 rcbilson Exp $5 *6 */7 8 1 #ifndef DECLARATION_H 9 2 #define DECLARATION_H … … 15 8 16 9 17 class Declaration 18 { 19 public: 20 enum StorageClass 21 { 10 class Declaration { 11 public: 12 enum StorageClass { 22 13 NoStorageClass, 23 14 Auto, … … 27 18 Fortran 28 19 }; 29 20 30 21 Declaration( const std::string &name, StorageClass sc, LinkageSpec::Type linkage ); 31 22 Declaration( const Declaration &other ); … … 39 30 void set_linkage( LinkageSpec::Type newValue ) { linkage = newValue; } 40 31 UniqueId get_uniqueId() const { return uniqueId; } 41 32 42 33 void fixUniqueId( void ); 43 34 virtual Declaration *clone() const = 0; … … 46 37 virtual void print( std::ostream &os, int indent = 0 ) const = 0; 47 38 virtual void printShort( std::ostream &os, int indent = 0 ) const = 0; 48 39 49 40 static const char* storageClassName[]; 50 41 51 42 static void dumpIds( std::ostream &os ); 52 43 static Declaration *declFromId( UniqueId id ); 53 54 private: 44 private: 55 45 std::string name; 56 46 StorageClass storageClass; … … 59 49 }; 60 50 61 class DeclarationWithType : public Declaration 62 { 63 public: 51 class DeclarationWithType : public Declaration { 52 public: 64 53 DeclarationWithType( const std::string &name, StorageClass sc, LinkageSpec::Type linkage ); 65 54 DeclarationWithType( const DeclarationWithType &other ); … … 68 57 std::string get_mangleName() const { return mangleName; } 69 58 void set_mangleName( std::string newValue ) { mangleName = newValue; } 70 59 71 60 virtual DeclarationWithType *clone() const = 0; 72 61 virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0; 73 62 74 63 virtual Type *get_type() const = 0; 75 64 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 80 67 std::string mangleName; 81 68 }; 82 69 83 class ObjectDecl : public DeclarationWithType 84 { 70 class ObjectDecl : public DeclarationWithType { 85 71 typedef DeclarationWithType Parent; 86 87 public: 72 public: 88 73 ObjectDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init ); 89 74 ObjectDecl( const ObjectDecl &other ); … … 97 82 Expression *get_bitfieldWidth() const { return bitfieldWidth; } 98 83 void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; } 99 84 100 85 virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); } 101 86 virtual void accept( Visitor &v ) { v.visit( this ); } … … 103 88 virtual void print( std::ostream &os, int indent = 0 ) const; 104 89 virtual void printShort( std::ostream &os, int indent = 0 ) const; 105 106 private: 90 private: 107 91 Type *type; 108 92 Initializer *init; … … 110 94 }; 111 95 112 class FunctionDecl : public DeclarationWithType 113 { 96 class FunctionDecl : public DeclarationWithType { 114 97 typedef DeclarationWithType Parent; 115 116 public: 98 public: 117 99 FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline ); 118 100 FunctionDecl( const FunctionDecl &other ); … … 130 112 std::list< std::string >& get_oldIdents() { return oldIdents; } 131 113 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 132 114 133 115 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } 134 116 virtual void accept( Visitor &v ) { v.visit( this ); } … … 136 118 virtual void print( std::ostream &os, int indent = 0 ) const; 137 119 virtual void printShort( std::ostream &os, int indent = 0 ) const; 138 139 private: 120 private: 140 121 FunctionType *type; 141 122 CompoundStmt *statements; … … 145 126 }; 146 127 147 class NamedTypeDecl : public Declaration 148 { 128 class NamedTypeDecl : public Declaration { 149 129 typedef Declaration Parent; 150 151 public: 130 public: 152 131 NamedTypeDecl( const std::string &name, StorageClass sc, Type *type ); 153 132 NamedTypeDecl( const TypeDecl &other ); … … 162 141 virtual void print( std::ostream &os, int indent = 0 ) const; 163 142 virtual void printShort( std::ostream &os, int indent = 0 ) const; 164 165 protected: 143 protected: 166 144 virtual std::string typeString() const = 0; 167 168 private: 145 private: 169 146 Type *base; 170 147 std::list< TypeDecl* > parameters; … … 172 149 }; 173 150 174 class TypeDecl : public NamedTypeDecl 175 { 151 class TypeDecl : public NamedTypeDecl { 176 152 typedef NamedTypeDecl Parent; 177 178 public: 153 public: 179 154 enum Kind { Any, Dtype, Ftype }; 180 155 181 156 TypeDecl( const std::string &name, StorageClass sc, Type *type, Kind kind ); 182 157 TypeDecl( const TypeDecl &other ); 183 158 184 159 Kind get_kind() const { return kind; } 185 160 … … 187 162 virtual void accept( Visitor &v ) { v.visit( this ); } 188 163 virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); } 189 190 private: 164 private: 191 165 virtual std::string typeString() const; 192 166 Kind kind; 193 167 }; 194 195 class TypedefDecl : public NamedTypeDecl 196 { 168 169 class TypedefDecl : public NamedTypeDecl { 197 170 typedef NamedTypeDecl Parent; 198 199 public: 171 public: 200 172 TypedefDecl( const std::string &name, StorageClass sc, Type *type ) : Parent( name, sc, type ) {} 201 173 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 202 174 203 175 virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); } 204 176 virtual void accept( Visitor &v ) { v.visit( this ); } 205 177 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 182 class AggregateDecl : public Declaration { 213 183 typedef Declaration Parent; 214 215 public: 184 public: 216 185 AggregateDecl( const std::string &name ); 217 186 AggregateDecl( const AggregateDecl &other ); … … 220 189 std::list<Declaration*>& get_members() { return members; } 221 190 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: 227 195 virtual std::string typeString() const = 0; 228 229 private:196 197 private: 230 198 std::list<Declaration*> members; 231 199 std::list<TypeDecl*> parameters; 232 200 }; 233 201 234 class StructDecl : public AggregateDecl 235 { 236 typedef AggregateDecl Parent; 237 238 public: 202 class StructDecl : public AggregateDecl { 203 typedef AggregateDecl Parent; 204 public: 239 205 StructDecl( const std::string &name ) : Parent( name ) {} 240 206 StructDecl( const StructDecl &other ) : Parent( other ) {} 241 207 242 208 virtual StructDecl *clone() const { return new StructDecl( *this ); } 243 209 virtual void accept( Visitor &v ) { v.visit( this ); } 244 210 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); } 245 211 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 216 class UnionDecl : public AggregateDecl { 217 typedef AggregateDecl Parent; 218 public: 255 219 UnionDecl( const std::string &name ) : Parent( name ) {} 256 220 UnionDecl( const UnionDecl &other ) : Parent( other ) {} 257 221 258 222 virtual UnionDecl *clone() const { return new UnionDecl( *this ); } 259 223 virtual void accept( Visitor &v ) { v.visit( this ); } 260 224 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 229 class EnumDecl : public AggregateDecl { 230 typedef AggregateDecl Parent; 231 public: 271 232 EnumDecl( const std::string &name ) : Parent( name ) {} 272 233 EnumDecl( const EnumDecl &other ) : Parent( other ) {} 273 234 274 235 virtual EnumDecl *clone() const { return new EnumDecl( *this ); } 275 236 virtual void accept( Visitor &v ) { v.visit( this ); } 276 237 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 242 class ContextDecl : public AggregateDecl { 243 typedef AggregateDecl Parent; 244 public: 287 245 ContextDecl( const std::string &name ) : Parent( name ) {} 288 246 ContextDecl( const ContextDecl &other ) : Parent( other ) {} 289 247 290 248 virtual ContextDecl *clone() const { return new ContextDecl( *this ); } 291 249 virtual void accept( Visitor &v ) { v.visit( this ); } 292 250 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.