Changeset 9236060 for src/SynTree/Declaration.h
- Timestamp:
- Aug 14, 2017, 2:03:39 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:
- 74b007ba
- Parents:
- fd344aa (diff), 54cd58b0 (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
rfd344aa r9236060 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jun 27 15:31:00 2017 13 // Update Count : 122 14 // 15 16 #ifndef DECLARATION_H 17 #define DECLARATION_H 12 // Last Modified On : Wed Aug 9 14:45:00 2017 13 // Update Count : 126 14 // 15 16 #pragma once 18 17 19 18 #include <string> … … 28 27 class Declaration : public BaseSyntaxNode { 29 28 public: 29 std::string name; 30 LinkageSpec::Spec linkage; 31 bool extension = false; 32 30 33 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 31 34 Declaration( const Declaration &other ); … … 54 57 static void dumpIds( std::ostream &os ); 55 58 static Declaration *declFromId( UniqueId id ); 56 private: 57 std::string name; 59 60 private: 58 61 Type::StorageClasses storageClasses; 59 LinkageSpec::Spec linkage;60 62 UniqueId uniqueId; 61 bool extension = false;62 63 }; 63 64 64 65 class DeclarationWithType : public Declaration { 65 66 public: 66 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );67 DeclarationWithType( const DeclarationWithType &other );68 virtual ~DeclarationWithType();69 70 std::string get_mangleName() const { return mangleName; }71 DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }72 73 std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }74 75 int get_scopeLevel() const { return scopeLevel; }76 DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }77 78 ConstantExpr *get_asmName() const { return asmName; }79 DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }80 81 std::list< Attribute * >& get_attributes() { return attributes; }82 const std::list< Attribute * >& get_attributes() const { return attributes; }83 84 Type::FuncSpecifiers get_funcSpec() const { return fs; }85 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }86 87 virtual DeclarationWithType *clone() const = 0;88 virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;89 90 virtual Type *get_type() const = 0;91 virtual void set_type(Type *) = 0;92 private:93 67 // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 94 68 std::string mangleName; … … 98 72 ConstantExpr *asmName; 99 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: 100 103 Type::FuncSpecifiers fs; 101 104 }; … … 104 107 typedef DeclarationWithType Parent; 105 108 public: 109 Type *type; 110 Initializer *init; 111 Expression *bitfieldWidth; 112 106 113 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 107 114 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 123 130 virtual void print( std::ostream &os, int indent = 0 ) const; 124 131 virtual void printShort( std::ostream &os, int indent = 0 ) const; 125 private:126 Type *type;127 Initializer *init;128 Expression *bitfieldWidth;129 132 }; 130 133 … … 132 135 typedef DeclarationWithType Parent; 133 136 public: 137 FunctionType *type; 138 CompoundStmt *statements; 139 134 140 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 135 141 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 150 156 virtual void print( std::ostream &os, int indent = 0 ) const; 151 157 virtual void printShort( std::ostream &os, int indent = 0 ) const; 152 private:153 FunctionType *type;154 CompoundStmt *statements;155 158 }; 156 159 … … 158 161 typedef Declaration Parent; 159 162 public: 163 Type *base; 164 std::list< TypeDecl* > parameters; 165 std::list< DeclarationWithType* > assertions; 166 160 167 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 161 168 NamedTypeDecl( const NamedTypeDecl &other ); … … 172 179 virtual void print( std::ostream &os, int indent = 0 ) const; 173 180 virtual void printShort( std::ostream &os, int indent = 0 ) const; 174 protected:175 private:176 Type *base;177 std::list< TypeDecl* > parameters;178 std::list< DeclarationWithType* > assertions;179 181 }; 180 182 … … 183 185 public: 184 186 enum Kind { Any, Dtype, Ftype, Ttype }; 187 188 Type * init; 189 bool sized; 190 185 191 /// Data extracted from a type decl 186 192 struct Data { … … 217 223 private: 218 224 Kind kind; 219 Type * init;220 bool sized;221 225 }; 222 226 … … 224 228 typedef NamedTypeDecl Parent; 225 229 public: 226 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 ); } 227 231 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 228 232 … … 238 242 typedef Declaration Parent; 239 243 public: 240 AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );241 AggregateDecl( const AggregateDecl &other );242 virtual ~AggregateDecl();243 244 std::list<Declaration*>& get_members() { return members; }245 std::list<TypeDecl*>& get_parameters() { return parameters; }246 247 std::list< Attribute * >& get_attributes() { return attributes; }248 const std::list< Attribute * >& get_attributes() const { return attributes; }249 250 bool has_body() const { return body; }251 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }252 253 virtual void print( std::ostream &os, int indent = 0 ) const;254 virtual void printShort( std::ostream &os, int indent = 0 ) const;255 protected:256 virtual std::string typeString() const = 0;257 258 private:259 244 std::list<Declaration*> members; 260 245 std::list<TypeDecl*> parameters; 261 246 bool body; 262 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; 263 266 }; 264 267 … … 266 269 typedef AggregateDecl Parent; 267 270 public: 268 StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {} 271 StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ), tagged( false ), parent_name( "" ) {} 272 StructDecl( const std::string &name, const std::string *parent, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( DeclarationNode::Struct ), tagged( true ), parent_name( parent ? *parent : "" ) {} 269 273 StructDecl( const StructDecl &other ) : Parent( other ) {} 270 274 … … 273 277 bool is_thread() { return kind == DeclarationNode::Thread; } 274 278 279 // Tagged/Tree Structure Excetion 280 bool get_tagged() { return tagged; } 281 void set_tagged( bool newValue ) { tagged = newValue; } 282 bool has_parent() { return parent_name != ""; } 283 std::string get_parentName() { return parent_name; } 284 275 285 virtual StructDecl *clone() const { return new StructDecl( *this ); } 276 286 virtual void accept( Visitor &v ) { v.visit( this ); } … … 279 289 DeclarationNode::Aggregate kind; 280 290 virtual std::string typeString() const; 291 292 bool tagged; 293 std::string parent_name; 281 294 }; 282 295 … … 324 337 class AsmDecl : public Declaration { 325 338 public: 339 AsmStmt *stmt; 340 326 341 AsmDecl( AsmStmt *stmt ); 327 342 AsmDecl( const AsmDecl &other ); … … 336 351 virtual void print( std::ostream &os, int indent = 0 ) const; 337 352 virtual void printShort( std::ostream &os, int indent = 0 ) const; 338 private:339 AsmStmt *stmt;340 353 }; 341 354 342 355 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 343 356 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 344 345 #endif // DECLARATION_H346 357 347 358 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.