Changes in src/SynTree/Declaration.h [65cdc1e:fa4805f]
- File:
-
- 1 edited
-
src/SynTree/Declaration.h (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r65cdc1e rfa4805f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:45:00 2017 13 // Update Count : 126 14 // 15 16 #pragma once 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 17 18 18 19 #include <string> … … 27 28 class Declaration : public BaseSyntaxNode { 28 29 public: 29 std::string name;30 LinkageSpec::Spec linkage;31 bool extension = false;32 33 30 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 34 31 Declaration( const Declaration &other ); … … 57 54 static void dumpIds( std::ostream &os ); 58 55 static Declaration *declFromId( UniqueId id ); 59 60 private: 56 private: 57 std::string name; 61 58 Type::StorageClasses storageClasses; 59 LinkageSpec::Spec linkage; 62 60 UniqueId uniqueId; 61 bool extension = false; 63 62 }; 64 63 65 64 class DeclarationWithType : public Declaration { 66 65 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: 67 93 // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 68 94 std::string mangleName; … … 72 98 ConstantExpr *asmName; 73 99 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:103 100 Type::FuncSpecifiers fs; 104 101 }; … … 107 104 typedef DeclarationWithType Parent; 108 105 public: 109 Type *type;110 Initializer *init;111 Expression *bitfieldWidth;112 113 106 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 114 107 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 130 123 virtual void print( std::ostream &os, int indent = 0 ) const; 131 124 virtual void printShort( std::ostream &os, int indent = 0 ) const; 125 private: 126 Type *type; 127 Initializer *init; 128 Expression *bitfieldWidth; 132 129 }; 133 130 … … 135 132 typedef DeclarationWithType Parent; 136 133 public: 137 FunctionType *type;138 CompoundStmt *statements;139 140 134 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 141 135 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 156 150 virtual void print( std::ostream &os, int indent = 0 ) const; 157 151 virtual void printShort( std::ostream &os, int indent = 0 ) const; 152 private: 153 FunctionType *type; 154 CompoundStmt *statements; 158 155 }; 159 156 … … 161 158 typedef Declaration Parent; 162 159 public: 163 Type *base;164 std::list< TypeDecl* > parameters;165 std::list< DeclarationWithType* > assertions;166 167 160 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 168 161 NamedTypeDecl( const NamedTypeDecl &other ); … … 179 172 virtual void print( std::ostream &os, int indent = 0 ) const; 180 173 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; 181 179 }; 182 180 … … 185 183 public: 186 184 enum Kind { Any, Dtype, Ftype, Ttype }; 187 188 Type * init;189 bool sized;190 191 185 /// Data extracted from a type decl 192 186 struct Data { … … 223 217 private: 224 218 Kind kind; 219 Type * init; 220 bool sized; 225 221 }; 226 222 … … 228 224 typedef NamedTypeDecl Parent; 229 225 public: 230 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type , LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec );}226 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {} 231 227 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 232 228 … … 242 238 typedef Declaration Parent; 243 239 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: 244 259 std::list<Declaration*> members; 245 260 std::list<TypeDecl*> parameters; 246 261 bool body; 247 262 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;266 263 }; 267 264 … … 269 266 typedef AggregateDecl Parent; 270 267 public: 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 : "" ) {} 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 ) {} 273 269 StructDecl( const StructDecl &other ) : Parent( other ) {} 274 270 … … 277 273 bool is_thread() { return kind == DeclarationNode::Thread; } 278 274 279 // Tagged/Tree Structure Excetion280 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 285 275 virtual StructDecl *clone() const { return new StructDecl( *this ); } 286 276 virtual void accept( Visitor &v ) { v.visit( this ); } … … 289 279 DeclarationNode::Aggregate kind; 290 280 virtual std::string typeString() const; 291 292 bool tagged;293 std::string parent_name;294 281 }; 295 282 … … 337 324 class AsmDecl : public Declaration { 338 325 public: 339 AsmStmt *stmt;340 341 326 AsmDecl( AsmStmt *stmt ); 342 327 AsmDecl( const AsmDecl &other ); … … 351 336 virtual void print( std::ostream &os, int indent = 0 ) const; 352 337 virtual void printShort( std::ostream &os, int indent = 0 ) const; 338 private: 339 AsmStmt *stmt; 353 340 }; 354 341 355 342 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 356 343 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 344 345 #endif // DECLARATION_H 357 346 358 347 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.