Changeset cd7ef0b for src/SynTree/Declaration.h
- Timestamp:
- Aug 10, 2017, 3:39:11 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 38d70ab
- Parents:
- 275f4b4 (diff), e1780a2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r275f4b4 rcd7ef0b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:52:59201713 // Update Count : 12 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:45:00 2017 13 // Update Count : 126 14 14 // 15 15 … … 27 27 class Declaration : public BaseSyntaxNode { 28 28 public: 29 std::string name; 30 LinkageSpec::Spec linkage; 31 bool extension = false; 32 29 33 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 30 34 Declaration( const Declaration &other ); … … 53 57 static void dumpIds( std::ostream &os ); 54 58 static Declaration *declFromId( UniqueId id ); 55 private: 56 std::string name; 59 60 private: 57 61 Type::StorageClasses storageClasses; 58 LinkageSpec::Spec linkage;59 62 UniqueId uniqueId; 60 bool extension = false;61 63 }; 62 64 63 65 class DeclarationWithType : public Declaration { 64 66 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:92 67 // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 93 68 std::string mangleName; … … 97 72 ConstantExpr *asmName; 98 73 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: 99 103 Type::FuncSpecifiers fs; 100 104 }; … … 103 107 typedef DeclarationWithType Parent; 104 108 public: 109 Type *type; 110 Initializer *init; 111 Expression *bitfieldWidth; 112 105 113 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 106 114 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 122 130 virtual void print( std::ostream &os, int indent = 0 ) const; 123 131 virtual void printShort( std::ostream &os, int indent = 0 ) const; 124 private:125 Type *type;126 Initializer *init;127 Expression *bitfieldWidth;128 132 }; 129 133 … … 131 135 typedef DeclarationWithType Parent; 132 136 public: 137 FunctionType *type; 138 CompoundStmt *statements; 139 133 140 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 134 141 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 149 156 virtual void print( std::ostream &os, int indent = 0 ) const; 150 157 virtual void printShort( std::ostream &os, int indent = 0 ) const; 151 private:152 FunctionType *type;153 CompoundStmt *statements;154 158 }; 155 159 … … 157 161 typedef Declaration Parent; 158 162 public: 163 Type *base; 164 std::list< TypeDecl* > parameters; 165 std::list< DeclarationWithType* > assertions; 166 159 167 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 160 168 NamedTypeDecl( const NamedTypeDecl &other ); … … 171 179 virtual void print( std::ostream &os, int indent = 0 ) const; 172 180 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;178 181 }; 179 182 … … 182 185 public: 183 186 enum Kind { Any, Dtype, Ftype, Ttype }; 187 188 Type * init; 189 bool sized; 190 184 191 /// Data extracted from a type decl 185 192 struct Data { … … 216 223 private: 217 224 Kind kind; 218 Type * init;219 bool sized;220 225 }; 221 226 … … 223 228 typedef NamedTypeDecl Parent; 224 229 public: 225 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}230 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); } 226 231 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 227 232 … … 237 242 typedef Declaration Parent; 238 243 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:258 244 std::list<Declaration*> members; 259 245 std::list<TypeDecl*> parameters; 260 246 bool body; 261 247 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; 262 266 }; 263 267 … … 333 337 class AsmDecl : public Declaration { 334 338 public: 339 AsmStmt *stmt; 340 335 341 AsmDecl( AsmStmt *stmt ); 336 342 AsmDecl( const AsmDecl &other ); … … 345 351 virtual void print( std::ostream &os, int indent = 0 ) const; 346 352 virtual void printShort( std::ostream &os, int indent = 0 ) const; 347 private:348 AsmStmt *stmt;349 353 }; 350 354
Note:
See TracChangeset
for help on using the changeset viewer.