Changes in src/SynTree/Declaration.h [65cdc1e:6b0b624]
- File:
-
- 1 edited
-
src/SynTree/Declaration.h (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r65cdc1e r6b0b624 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 9 14:45:00201713 // Update Count : 12 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:52:59 2017 13 // Update Count : 124 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 33 29 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 34 30 Declaration( const Declaration &other ); … … 57 53 static void dumpIds( std::ostream &os ); 58 54 static Declaration *declFromId( UniqueId id ); 59 60 private: 55 private: 56 std::string name; 61 57 Type::StorageClasses storageClasses; 58 LinkageSpec::Spec linkage; 62 59 UniqueId uniqueId; 60 bool extension = false; 63 61 }; 64 62 65 63 class DeclarationWithType : public Declaration { 66 64 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: 67 92 // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 68 93 std::string mangleName; … … 72 97 ConstantExpr *asmName; 73 98 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 99 Type::FuncSpecifiers fs; 104 100 }; … … 107 103 typedef DeclarationWithType Parent; 108 104 public: 109 Type *type;110 Initializer *init;111 Expression *bitfieldWidth;112 113 105 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 114 106 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 130 122 virtual void print( std::ostream &os, int indent = 0 ) const; 131 123 virtual void printShort( std::ostream &os, int indent = 0 ) const; 124 private: 125 Type *type; 126 Initializer *init; 127 Expression *bitfieldWidth; 132 128 }; 133 129 … … 135 131 typedef DeclarationWithType Parent; 136 132 public: 137 FunctionType *type;138 CompoundStmt *statements;139 140 133 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 141 134 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); … … 156 149 virtual void print( std::ostream &os, int indent = 0 ) const; 157 150 virtual void printShort( std::ostream &os, int indent = 0 ) const; 151 private: 152 FunctionType *type; 153 CompoundStmt *statements; 158 154 }; 159 155 … … 161 157 typedef Declaration Parent; 162 158 public: 163 Type *base;164 std::list< TypeDecl* > parameters;165 std::list< DeclarationWithType* > assertions;166 167 159 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 168 160 NamedTypeDecl( const NamedTypeDecl &other ); … … 179 171 virtual void print( std::ostream &os, int indent = 0 ) const; 180 172 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; 181 178 }; 182 179 … … 185 182 public: 186 183 enum Kind { Any, Dtype, Ftype, Ttype }; 187 188 Type * init;189 bool sized;190 191 184 /// Data extracted from a type decl 192 185 struct Data { … … 223 216 private: 224 217 Kind kind; 218 Type * init; 219 bool sized; 225 220 }; 226 221 … … 228 223 typedef NamedTypeDecl Parent; 229 224 public: 230 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type , LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec );}225 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {} 231 226 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 232 227 … … 242 237 typedef Declaration Parent; 243 238 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: 244 258 std::list<Declaration*> members; 245 259 std::list<TypeDecl*> parameters; 246 260 bool body; 247 261 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 262 }; 267 263 … … 337 333 class AsmDecl : public Declaration { 338 334 public: 339 AsmStmt *stmt;340 341 335 AsmDecl( AsmStmt *stmt ); 342 336 AsmDecl( const AsmDecl &other ); … … 351 345 virtual void print( std::ostream &os, int indent = 0 ) const; 352 346 virtual void printShort( std::ostream &os, int indent = 0 ) const; 347 private: 348 AsmStmt *stmt; 353 349 }; 354 350
Note:
See TracChangeset
for help on using the changeset viewer.