Changeset 65cdc1e
- Timestamp:
- Aug 9, 2017, 3:21:58 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:
- 0ec9229
- Parents:
- cbce272
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
rcbce272 r65cdc1e 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Jul 27 21:42:38201713 // Update Count : 56 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 2 11:12:00 2017 13 // Update Count : 568 14 14 // 15 15 … … 40 40 // type. 41 41 42 Type::Qualifiers noQualifiers;// no qualifiers on constants42 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 43 43 44 44 static inline bool checkU( char c ) { return c == 'u' || c == 'U'; } -
src/SynTree/Declaration.cc
rcbce272 r65cdc1e 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 : Thu Mar 16 07:49:18201713 // Update Count : 2 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:38:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 28 28 29 29 Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) 30 : name( name ), storageClasses( scs ), linkage( linkage), uniqueId( 0 ) {30 : name( name ), linkage( linkage ), storageClasses( scs ), uniqueId( 0 ) { 31 31 } 32 32 33 33 Declaration::Declaration( const Declaration &other ) 34 : BaseSyntaxNode( other ), name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage), uniqueId( other.uniqueId ) {34 : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), storageClasses( other.storageClasses ), uniqueId( other.uniqueId ) { 35 35 } 36 36 -
src/SynTree/Declaration.h
rcbce272 r65cdc1e 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Aug 8 13:25:00 201713 // Update Count : 12 512 // 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 … … 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 -
src/SynTree/Expression.h
rcbce272 r65cdc1e 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jul 24 16:27:00 201713 // Update Count : 4 312 // Last Modified On : Fri Aug 8 11:54:00 2017 13 // Update Count : 44 14 14 // 15 15 … … 29 29 class Expression : public BaseSyntaxNode{ 30 30 public: 31 Type * result; 32 TypeSubstitution * env; 33 Expression * argName; // if expression is used as an argument, it can be "designated" by this name 34 bool extension = false; 35 31 36 Expression( Expression * _aname = nullptr ); 32 37 Expression( const Expression & other ); … … 49 54 virtual Expression * acceptMutator( Mutator & m ) = 0; 50 55 virtual void print( std::ostream & os, int indent = 0 ) const; 51 protected:52 Type * result;53 TypeSubstitution * env;54 Expression * argName; // if expression is used as an argument, it can be "designated" by this name55 bool extension = false;56 56 }; 57 57 … … 79 79 class ApplicationExpr : public Expression { 80 80 public: 81 Expression * function; 82 81 83 ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); 82 84 ApplicationExpr( const ApplicationExpr & other ); … … 92 94 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 93 95 virtual void print( std::ostream & os, int indent = 0 ) const; 96 94 97 private: 95 Expression * function;96 98 std::list<Expression *> args; 97 99 InferredParams inferParams; … … 103 105 class UntypedExpr : public Expression { 104 106 public: 107 Expression * function; 108 std::list<Expression*> args; 109 105 110 UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr ); 106 111 UntypedExpr( const UntypedExpr & other ); … … 123 128 virtual void print( std::ostream & os, int indent = 0 ) const; 124 129 virtual void printArgs(std::ostream & os, int indent = 0) const; 125 private:126 Expression * function;127 std::list<Expression*> args;128 130 }; 129 131 … … 131 133 class NameExpr : public Expression { 132 134 public: 135 std::string name; 136 133 137 NameExpr( std::string name, Expression *_aname = nullptr ); 134 138 NameExpr( const NameExpr & other ); … … 142 146 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 143 147 virtual void print( std::ostream & os, int indent = 0 ) const; 144 private:145 std::string name;146 148 }; 147 149 … … 152 154 class AddressExpr : public Expression { 153 155 public: 156 Expression * arg; 157 154 158 AddressExpr( Expression * arg, Expression *_aname = nullptr ); 155 159 AddressExpr( const AddressExpr & other ); … … 163 167 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 164 168 virtual void print( std::ostream & os, int indent = 0 ) const; 165 private:166 Expression * arg;167 169 }; 168 170 … … 170 172 class LabelAddressExpr : public Expression { 171 173 public: 174 Expression * arg; 175 172 176 LabelAddressExpr( Expression * arg ); 173 177 LabelAddressExpr( const LabelAddressExpr & other ); … … 181 185 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 182 186 virtual void print( std::ostream & os, int indent = 0 ) const; 183 private:184 Expression * arg;185 187 }; 186 188 … … 188 190 class CastExpr : public Expression { 189 191 public: 192 Expression * arg; 193 190 194 CastExpr( Expression * arg, Expression *_aname = nullptr ); 191 195 CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr ); … … 200 204 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 201 205 virtual void print( std::ostream & os, int indent = 0 ) const; 202 private:203 Expression * arg;204 206 }; 205 207 … … 207 209 class VirtualCastExpr : public Expression { 208 210 public: 211 Expression * arg; 212 209 213 VirtualCastExpr( Expression * arg, Type * toType ); 210 214 VirtualCastExpr( const VirtualCastExpr & other ); … … 218 222 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 219 223 virtual void print( std::ostream & os, int indent = 0 ) const; 220 private:221 Expression * arg;222 224 }; 223 225 … … 225 227 class UntypedMemberExpr : public Expression { 226 228 public: 229 Expression * member; 230 Expression * aggregate; 231 227 232 UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr ); 228 233 UntypedMemberExpr( const UntypedMemberExpr & other ); … … 238 243 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 239 244 virtual void print( std::ostream & os, int indent = 0 ) const; 240 private:241 Expression * member;242 Expression * aggregate;243 245 }; 244 246 … … 247 249 class MemberExpr : public Expression { 248 250 public: 251 DeclarationWithType * member; 252 Expression * aggregate; 253 249 254 MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr ); 250 255 MemberExpr( const MemberExpr & other ); … … 260 265 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 261 266 virtual void print( std::ostream & os, int indent = 0 ) const; 262 private:263 DeclarationWithType * member;264 Expression * aggregate;265 267 }; 266 268 … … 269 271 class VariableExpr : public Expression { 270 272 public: 273 DeclarationWithType * var; 274 271 275 VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr ); 272 276 VariableExpr( const VariableExpr & other ); … … 280 284 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 281 285 virtual void print( std::ostream & os, int indent = 0 ) const; 282 private:283 DeclarationWithType * var;284 286 }; 285 287 … … 287 289 class ConstantExpr : public Expression { 288 290 public: 291 Constant constant; 292 289 293 ConstantExpr( Constant constant, Expression *_aname = nullptr ); 290 294 ConstantExpr( const ConstantExpr & other ); … … 298 302 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 299 303 virtual void print( std::ostream & os, int indent = 0 ) const; 300 private:301 Constant constant;302 304 }; 303 305 … … 305 307 class SizeofExpr : public Expression { 306 308 public: 309 Expression * expr; 310 Type * type; 311 bool isType; 312 307 313 SizeofExpr( Expression * expr, Expression *_aname = nullptr ); 308 314 SizeofExpr( const SizeofExpr & other ); … … 321 327 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 322 328 virtual void print( std::ostream & os, int indent = 0 ) const; 323 private: 329 }; 330 331 /// AlignofExpr represents an alignof expression 332 class AlignofExpr : public Expression { 333 public: 324 334 Expression * expr; 325 335 Type * type; 326 336 bool isType; 327 }; 328 329 /// AlignofExpr represents an alignof expression 330 class AlignofExpr : public Expression { 331 public: 337 332 338 AlignofExpr( Expression * expr, Expression *_aname = nullptr ); 333 339 AlignofExpr( const AlignofExpr & other ); … … 346 352 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 347 353 virtual void print( std::ostream & os, int indent = 0 ) const; 348 private:349 Expression * expr;350 Type * type;351 bool isType;352 354 }; 353 355 … … 355 357 class UntypedOffsetofExpr : public Expression { 356 358 public: 359 Type * type; 360 std::string member; 361 357 362 UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr ); 358 363 UntypedOffsetofExpr( const UntypedOffsetofExpr & other ); … … 368 373 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 369 374 virtual void print( std::ostream & os, int indent = 0 ) const; 370 private:371 Type * type;372 std::string member;373 375 }; 374 376 … … 376 378 class OffsetofExpr : public Expression { 377 379 public: 380 Type * type; 381 DeclarationWithType * member; 382 378 383 OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr ); 379 384 OffsetofExpr( const OffsetofExpr & other ); … … 389 394 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 390 395 virtual void print( std::ostream & os, int indent = 0 ) const; 391 private:392 Type * type;393 DeclarationWithType * member;394 396 }; 395 397 … … 397 399 class OffsetPackExpr : public Expression { 398 400 public: 401 StructInstType * type; 402 399 403 OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 ); 400 404 OffsetPackExpr( const OffsetPackExpr & other ); … … 407 411 virtual void accept( Visitor & v ) { v.visit( this ); } 408 412 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 409 410 virtual void print( std::ostream & os, int indent = 0 ) const; 411 412 private: 413 StructInstType * type; 413 virtual void print( std::ostream & os, int indent = 0 ) const; 414 414 }; 415 415 … … 417 417 class AttrExpr : public Expression { 418 418 public: 419 Expression * attr; 420 Expression * expr; 421 Type * type; 422 bool isType; 423 419 424 AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr ); 420 425 AttrExpr( const AttrExpr & other ); … … 435 440 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 436 441 virtual void print( std::ostream & os, int indent = 0 ) const; 437 private:438 Expression * attr;439 Expression * expr;440 Type * type;441 bool isType;442 442 }; 443 443 … … 445 445 class LogicalExpr : public Expression { 446 446 public: 447 Expression * arg1; 448 Expression * arg2; 449 447 450 LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr ); 448 451 LogicalExpr( const LogicalExpr & other ); … … 459 462 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 460 463 virtual void print( std::ostream & os, int indent = 0 ) const; 464 461 465 private: 466 bool isAnd; 467 }; 468 469 /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) 470 class ConditionalExpr : public Expression { 471 public: 462 472 Expression * arg1; 463 473 Expression * arg2; 464 bool isAnd; 465 }; 466 467 /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) 468 class ConditionalExpr : public Expression { 469 public: 474 Expression * arg3; 475 470 476 ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr ); 471 477 ConditionalExpr( const ConditionalExpr & other ); … … 483 489 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 484 490 virtual void print( std::ostream & os, int indent = 0 ) const; 485 private: 491 }; 492 493 /// CommaExpr represents the sequence operator ( a, b ) 494 class CommaExpr : public Expression { 495 public: 486 496 Expression * arg1; 487 497 Expression * arg2; 488 Expression * arg3; 489 }; 490 491 /// CommaExpr represents the sequence operator ( a, b ) 492 class CommaExpr : public Expression { 493 public: 498 494 499 CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr ); 495 500 CommaExpr( const CommaExpr & other ); … … 505 510 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 506 511 virtual void print( std::ostream & os, int indent = 0 ) const; 507 private:508 Expression * arg1;509 Expression * arg2;510 512 }; 511 513 … … 513 515 class TypeExpr : public Expression { 514 516 public: 517 Type * type; 518 515 519 TypeExpr( Type * type ); 516 520 TypeExpr( const TypeExpr & other ); … … 524 528 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 525 529 virtual void print( std::ostream & os, int indent = 0 ) const; 526 private:527 Type * type;528 530 }; 529 531 … … 531 533 class AsmExpr : public Expression { 532 534 public: 535 Expression * inout; 536 ConstantExpr * constraint; 537 Expression * operand; 538 533 539 AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 534 540 AsmExpr( const AsmExpr & other ); … … 548 554 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 549 555 virtual void print( std::ostream & os, int indent = 0 ) const; 550 private: 556 551 557 // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints 552 Expression * inout;553 ConstantExpr * constraint;554 Expression * operand;555 558 }; 556 559 … … 559 562 class ImplicitCopyCtorExpr : public Expression { 560 563 public: 561 ImplicitCopyCtorExpr( ApplicationExpr * callExpr );562 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );563 virtual ~ImplicitCopyCtorExpr();564 565 ApplicationExpr * get_callExpr() const { return callExpr; }566 void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }567 568 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }569 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }570 std::list< Expression * > & get_dtors() { return dtors; }571 572 virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }573 virtual void accept( Visitor & v ) { v.visit( this ); }574 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }575 virtual void print( std::ostream & os, int indent = 0 ) const;576 private:577 564 ApplicationExpr * callExpr; 578 565 std::list< ObjectDecl * > tempDecls; 579 566 std::list< ObjectDecl * > returnDecls; 580 567 std::list< Expression * > dtors; 568 569 ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); 570 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); 571 virtual ~ImplicitCopyCtorExpr(); 572 573 ApplicationExpr * get_callExpr() const { return callExpr; } 574 void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; } 575 576 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 577 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 578 std::list< Expression * > & get_dtors() { return dtors; } 579 580 virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); } 581 virtual void accept( Visitor & v ) { v.visit( this ); } 582 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 583 virtual void print( std::ostream & os, int indent = 0 ) const; 581 584 }; 582 585 … … 584 587 class ConstructorExpr : public Expression { 585 588 public: 589 Expression * callExpr; 590 586 591 ConstructorExpr( Expression * callExpr ); 587 592 ConstructorExpr( const ConstructorExpr & other ); … … 595 600 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 596 601 virtual void print( std::ostream & os, int indent = 0 ) const; 597 private:598 Expression * callExpr;599 602 }; 600 603 … … 602 605 class CompoundLiteralExpr : public Expression { 603 606 public: 607 Initializer * initializer; 608 604 609 CompoundLiteralExpr( Type * type, Initializer * initializer ); 605 610 CompoundLiteralExpr( const CompoundLiteralExpr & other ); … … 613 618 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 614 619 virtual void print( std::ostream & os, int indent = 0 ) const; 615 private:616 Initializer * initializer;617 620 }; 618 621 … … 620 623 class RangeExpr : public Expression { 621 624 public: 625 Expression * low, * high; 626 622 627 RangeExpr( Expression * low, Expression * high ); 623 628 RangeExpr( const RangeExpr & other ); … … 632 637 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 633 638 virtual void print( std::ostream & os, int indent = 0 ) const; 634 private:635 Expression * low, * high;636 639 }; 637 640 … … 639 642 class UntypedTupleExpr : public Expression { 640 643 public: 644 std::list<Expression*> exprs; 645 641 646 UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 642 647 UntypedTupleExpr( const UntypedTupleExpr & other ); … … 649 654 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 650 655 virtual void print( std::ostream & os, int indent = 0 ) const; 651 private:652 std::list<Expression*> exprs;653 656 }; 654 657 … … 656 659 class TupleExpr : public Expression { 657 660 public: 661 std::list<Expression*> exprs; 662 658 663 TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 659 664 TupleExpr( const TupleExpr & other ); … … 666 671 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 667 672 virtual void print( std::ostream & os, int indent = 0 ) const; 668 private:669 std::list<Expression*> exprs;670 673 }; 671 674 … … 673 676 class TupleIndexExpr : public Expression { 674 677 public: 678 Expression * tuple; 679 unsigned int index; 680 675 681 TupleIndexExpr( Expression * tuple, unsigned int index ); 676 682 TupleIndexExpr( const TupleIndexExpr & other ); … … 686 692 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 687 693 virtual void print( std::ostream & os, int indent = 0 ) const; 688 private:689 Expression * tuple;690 unsigned int index;691 694 }; 692 695 … … 694 697 class TupleAssignExpr : public Expression { 695 698 public: 699 StmtExpr * stmtExpr = nullptr; 700 696 701 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); 697 702 TupleAssignExpr( const TupleAssignExpr & other ); … … 705 710 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 706 711 virtual void print( std::ostream & os, int indent = 0 ) const; 707 private:708 StmtExpr * stmtExpr = nullptr;709 712 }; 710 713 … … 712 715 class StmtExpr : public Expression { 713 716 public: 717 CompoundStmt * statements; 718 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression 719 std::list< Expression * > dtors; // destructor(s) for return variable(s) 720 714 721 StmtExpr( CompoundStmt * statements ); 715 722 StmtExpr( const StmtExpr & other ); … … 726 733 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 727 734 virtual void print( std::ostream & os, int indent = 0 ) const; 728 private:729 CompoundStmt * statements;730 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression731 std::list< Expression * > dtors; // destructor(s) for return variable(s)732 735 }; 733 736 734 737 class UniqueExpr : public Expression { 735 738 public: 739 Expression * expr; 740 ObjectDecl * object; 741 VariableExpr * var; 742 736 743 UniqueExpr( Expression * expr, long long idVal = -1 ); 737 744 UniqueExpr( const UniqueExpr & other ); … … 753 760 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 754 761 virtual void print( std::ostream & os, int indent = 0 ) const; 762 755 763 private: 756 Expression * expr;757 ObjectDecl * object;758 VariableExpr * var;759 764 int id; 760 765 static long long count; … … 773 778 class UntypedInitExpr : public Expression { 774 779 public: 780 Expression * expr; 781 std::list<InitAlternative> initAlts; 782 775 783 UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ); 776 784 UntypedInitExpr( const UntypedInitExpr & other ); … … 786 794 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 787 795 virtual void print( std::ostream & os, int indent = 0 ) const; 788 private:789 Expression * expr;790 std::list<InitAlternative> initAlts;791 796 }; 792 797 793 798 class InitExpr : public Expression { 794 799 public: 800 Expression * expr; 801 Designation * designation; 802 795 803 InitExpr( Expression * expr, Designation * designation ); 796 804 InitExpr( const InitExpr & other ); … … 807 815 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 808 816 virtual void print( std::ostream & os, int indent = 0 ) const; 809 private:810 Expression * expr;811 Designation * designation;812 817 }; 813 818 -
src/SynTree/Initializer.h
rcbce272 r65cdc1e 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:02201713 // Update Count : 2 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 10:19:00 2017 13 // Update Count : 22 14 14 // 15 15 … … 27 27 class Designation : public BaseSyntaxNode { 28 28 public: 29 std::list< Expression * > designators; 30 29 31 Designation( const std::list< Expression * > & designators ); 30 32 Designation( const Designation & other ); … … 37 39 virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); } 38 40 virtual void print( std::ostream &os, int indent = 0 ) const; 39 private:40 std::list< Expression * > designators;41 41 }; 42 42 … … 63 63 class SingleInit : public Initializer { 64 64 public: 65 //Constant *value; 66 Expression *value; // has to be a compile-time constant 67 65 68 SingleInit( Expression *value, bool maybeConstructed = false ); 66 69 SingleInit( const SingleInit &other ); … … 74 77 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 75 78 virtual void print( std::ostream &os, int indent = 0 ) const; 76 private:77 //Constant *value;78 Expression *value; // has to be a compile-time constant79 79 }; 80 80 … … 83 83 class ListInit : public Initializer { 84 84 public: 85 std::list<Initializer *> initializers; // order *is* important 86 std::list<Designation *> designations; // order/length is consistent with initializers 87 85 88 ListInit( const std::list<Initializer*> &initializers, 86 89 const std::list<Designation *> &designators = {}, bool maybeConstructed = false ); … … 102 105 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 103 106 virtual void print( std::ostream &os, int indent = 0 ) const; 104 private:105 std::list<Initializer *> initializers; // order *is* important106 std::list<Designation *> designations; // order/length is consistent with initializers107 107 }; 108 108 … … 113 113 class ConstructorInit : public Initializer { 114 114 public: 115 Statement * ctor; 116 Statement * dtor; 117 115 118 ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ); 116 119 ConstructorInit( const ConstructorInit &other ); … … 130 133 131 134 private: 132 Statement * ctor;133 Statement * dtor;134 135 // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback 135 136 // if an appropriate constructor definition is not found by the resolver -
src/SynTree/Statement.h
rcbce272 r65cdc1e 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:54:32201713 // Update Count : 6 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 3 14:08:00 2017 13 // Update Count : 69 14 14 // 15 15 … … 26 26 class Statement : public BaseSyntaxNode { 27 27 public: 28 std::list<Label> labels; 29 28 30 Statement( std::list<Label> labels ); 29 31 virtual ~Statement(); … … 36 38 virtual Statement *acceptMutator( Mutator &m ) = 0; 37 39 virtual void print( std::ostream &os, int indent = 0 ) const; 38 protected:39 std::list<Label> labels;40 40 }; 41 41 42 42 class CompoundStmt : public Statement { 43 43 public: 44 std::list<Statement*> kids; 45 44 46 CompoundStmt( std::list<Label> labels ); 45 47 CompoundStmt( const CompoundStmt &other ); … … 54 56 virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 55 57 virtual void print( std::ostream &os, int indent = 0 ) const; 56 private:57 std::list<Statement*> kids;58 58 }; 59 59 … … 67 67 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 68 68 virtual void print( std::ostream &os, int indent = 0 ) const; 69 70 private:71 69 }; 72 70 73 71 class ExprStmt : public Statement { 74 72 public: 73 Expression *expr; 74 75 75 ExprStmt( std::list<Label> labels, Expression *expr ); 76 76 ExprStmt( const ExprStmt &other ); … … 84 84 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 85 85 virtual void print( std::ostream &os, int indent = 0 ) const; 86 private:87 Expression *expr;88 86 }; 89 87 90 88 class AsmStmt : public Statement { 91 89 public: 90 bool voltile; 91 ConstantExpr *instruction; 92 std::list<Expression *> output, input; 93 std::list<ConstantExpr *> clobber; 94 std::list<Label> gotolabels; 95 92 96 AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 93 97 AsmStmt( const AsmStmt &other ); … … 111 115 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 112 116 virtual void print( std::ostream &os, int indent = 0 ) const; 113 private:114 bool voltile;115 ConstantExpr *instruction;116 std::list<Expression *> output, input;117 std::list<ConstantExpr *> clobber;118 std::list<Label> gotolabels;119 117 }; 120 118 121 119 class IfStmt : public Statement { 122 120 public: 121 Expression *condition; 122 Statement *thenPart; 123 Statement *elsePart; 124 123 125 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 124 126 IfStmt( const IfStmt &other ); … … 136 138 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 137 139 virtual void print( std::ostream &os, int indent = 0 ) const; 138 private:139 Expression *condition;140 Statement *thenPart;141 Statement *elsePart;142 140 }; 143 141 144 142 class SwitchStmt : public Statement { 145 143 public: 144 Expression * condition; 145 146 146 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 147 147 SwitchStmt( const SwitchStmt &other ); … … 159 159 virtual void print( std::ostream &os, int indent = 0 ) const; 160 160 private: 161 std::list<Statement *> statements; 162 }; 163 164 class CaseStmt : public Statement { 165 public: 161 166 Expression * condition; 162 std::list<Statement *> statements; 163 }; 164 165 class CaseStmt : public Statement { 166 public: 167 std::list<Statement *> stmts; 168 167 169 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 168 170 CaseStmt( const CaseStmt &other ); … … 186 188 virtual void print( std::ostream &os, int indent = 0 ) const; 187 189 private: 188 Expression * condition;189 std::list<Statement *> stmts;190 190 bool _isDefault; 191 191 }; … … 193 193 class WhileStmt : public Statement { 194 194 public: 195 Expression *condition; 196 Statement *body; 197 bool isDoWhile; 198 195 199 WhileStmt( std::list<Label> labels, Expression *condition, 196 200 Statement *body, bool isDoWhile = false ); … … 209 213 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 210 214 virtual void print( std::ostream &os, int indent = 0 ) const; 211 private: 215 }; 216 217 class ForStmt : public Statement { 218 public: 219 std::list<Statement *> initialization; 212 220 Expression *condition; 221 Expression *increment; 213 222 Statement *body; 214 bool isDoWhile; 215 }; 216 217 class ForStmt : public Statement { 218 public: 223 219 224 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 220 225 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); … … 235 240 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 236 241 virtual void print( std::ostream &os, int indent = 0 ) const; 237 private:238 std::list<Statement *> initialization;239 Expression *condition;240 Expression *increment;241 Statement *body;242 242 }; 243 243 … … 245 245 public: 246 246 enum Type { Goto = 0, Break, Continue }; 247 248 // originalTarget kept for error messages. 249 const Label originalTarget; 250 Label target; 251 Expression *computedTarget; 252 Type type; 247 253 248 254 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); … … 265 271 private: 266 272 static const char *brType[]; 267 Label originalTarget; // can give better error messages if we remember the label name that the user entered268 Label target;269 Expression *computedTarget;270 Type type;271 273 }; 272 274 273 275 class ReturnStmt : public Statement { 274 276 public: 277 Expression *expr; 278 275 279 ReturnStmt( std::list<Label> labels, Expression *expr ); 276 280 ReturnStmt( const ReturnStmt &other ); … … 284 288 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 285 289 virtual void print( std::ostream &os, int indent = 0 ) const; 286 private:287 Expression *expr;288 290 }; 289 291 … … 291 293 public: 292 294 enum Kind { Terminate, Resume }; 295 296 const Kind kind; 297 Expression * expr; 298 Expression * target; 293 299 294 300 ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target = nullptr ); … … 306 312 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 307 313 virtual void print( std::ostream &os, int indent = 0 ) const; 308 private:309 Kind kind;310 Expression * expr;311 Expression * target;312 314 }; 313 315 314 316 class TryStmt : public Statement { 315 317 public: 318 CompoundStmt *block; 319 std::list<CatchStmt *> handlers; 320 FinallyStmt *finallyBlock; 321 316 322 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 317 323 TryStmt( const TryStmt &other ); … … 329 335 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 330 336 virtual void print( std::ostream &os, int indent = 0 ) const; 331 332 private:333 CompoundStmt *block;334 std::list<CatchStmt *> handlers;335 FinallyStmt *finallyBlock;336 337 }; 337 338 … … 339 340 public: 340 341 enum Kind { Terminate, Resume }; 342 343 const Kind kind; 344 Declaration *decl; 345 Expression *cond; 346 Statement *body; 341 347 342 348 CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, … … 357 363 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 358 364 virtual void print( std::ostream &os, int indent = 0 ) const; 359 360 private:361 Kind kind;362 Declaration *decl;363 Expression *cond;364 Statement *body;365 365 }; 366 366 367 367 class FinallyStmt : public Statement { 368 368 public: 369 CompoundStmt *block; 370 369 371 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 370 372 FinallyStmt( const FinallyStmt &other ); … … 378 380 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 379 381 virtual void print( std::ostream &os, int indent = 0 ) const; 380 private:381 CompoundStmt *block;382 382 }; 383 383 … … 386 386 class DeclStmt : public Statement { 387 387 public: 388 Declaration *decl; 389 388 390 DeclStmt( std::list<Label> labels, Declaration *decl ); 389 391 DeclStmt( const DeclStmt &other ); … … 397 399 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 398 400 virtual void print( std::ostream &os, int indent = 0 ) const; 399 private:400 Declaration *decl;401 401 }; 402 402 … … 407 407 class ImplicitCtorDtorStmt : public Statement { 408 408 public: 409 // Non-owned pointer to the constructor/destructor statement 410 Statement * callStmt; 411 409 412 ImplicitCtorDtorStmt( Statement * callStmt ); 410 413 ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other ); … … 418 421 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 419 422 virtual void print( std::ostream &os, int indent = 0 ) const; 420 421 private:422 // Non-owned pointer to the constructor/destructor statement423 Statement * callStmt;424 423 }; 425 424 -
src/SynTree/Type.cc
rcbce272 r65cdc1e 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 : Fri Mar 17 08:42:47201713 // Update Count : 2 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 2 11:11:00 2017 13 // Update Count : 29 14 14 // 15 15 … … 88 88 } 89 89 90 // Empty Variable declarations: 91 const Type::FuncSpecifiers noFuncSpecifiers; 92 const Type::StorageClasses noStorageClasses; 93 const Type::Qualifiers noQualifiers; 94 90 95 std::ostream & operator<<( std::ostream & out, const Type * type ) { 91 96 if ( type ) { -
src/SynTree/Type.h
rcbce272 r65cdc1e 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:53:29201713 // Update Count : 15 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:25:00 2017 13 // Update Count : 152 14 14 // 15 15 … … 127 127 }; // Qualifiers 128 128 129 typedef std::list<TypeDecl *> ForallList; 130 131 Qualifiers tq; 132 ForallList forall; 133 std::list< Attribute * > attributes; 134 129 135 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 130 136 Type( const Type & other ); … … 145 151 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } 146 152 147 typedef std::list<TypeDecl *> ForallList;148 153 ForallList& get_forall() { return forall; } 149 154 … … 165 170 virtual Type *acceptMutator( Mutator & m ) = 0; 166 171 virtual void print( std::ostream & os, int indent = 0 ) const; 167 private: 168 Qualifiers tq; 169 ForallList forall; 170 std::list< Attribute * > attributes; 171 }; 172 173 extern Type::Qualifiers noQualifiers; // no qualifiers on constants 172 }; 173 174 extern const Type::FuncSpecifiers noFuncSpecifiers; 175 extern const Type::StorageClasses noStorageClasses; 176 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 174 177 175 178 class VoidType : public Type { … … 211 214 LongDoubleImaginary, 212 215 NUMBER_OF_BASIC_TYPES 213 } ;216 } kind; 214 217 215 218 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind … … 226 229 227 230 bool isInteger() const; 228 private:229 Kind kind;230 231 }; 231 232 232 233 class PointerType : public Type { 233 234 public: 235 Type *base; 236 237 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) 238 Expression *dimension; 239 bool isVarLen; 240 bool isStatic; 241 234 242 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 235 243 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 252 260 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 253 261 virtual void print( std::ostream & os, int indent = 0 ) const; 254 private: 262 }; 263 264 class ArrayType : public Type { 265 public: 255 266 Type *base; 256 257 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )258 267 Expression *dimension; 259 268 bool isVarLen; 260 269 bool isStatic; 261 }; 262 263 class ArrayType : public Type { 264 public: 270 265 271 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 266 272 ArrayType( const ArrayType& ); … … 282 288 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 283 289 virtual void print( std::ostream & os, int indent = 0 ) const; 284 private:285 Type *base;286 Expression *dimension;287 bool isVarLen;288 bool isStatic;289 290 }; 290 291 291 292 class FunctionType : public Type { 292 293 public: 294 std::list<DeclarationWithType*> returnVals; 295 std::list<DeclarationWithType*> parameters; 296 297 // Does the function accept a variable number of arguments following the arguments specified in the parameters list. 298 // This could be because of 299 // - an ellipsis in a prototype declaration 300 // - an unprototyped declaration 301 bool isVarArgs; 302 293 303 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 294 304 FunctionType( const FunctionType& ); … … 305 315 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 306 316 virtual void print( std::ostream & os, int indent = 0 ) const; 307 private:308 std::list<DeclarationWithType*> returnVals;309 std::list<DeclarationWithType*> parameters;310 311 // Does the function accept a variable number of arguments following the arguments specified in the parameters list.312 // This could be because of313 // - an ellipsis in a prototype declaration314 // - an unprototyped declaration315 bool isVarArgs;316 317 }; 317 318 318 319 class ReferenceToType : public Type { 319 320 public: 321 std::list< Expression* > parameters; 322 std::string name; 323 bool hoistType; 324 320 325 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 321 326 ReferenceToType( const ReferenceToType & other ); … … 336 341 protected: 337 342 virtual std::string typeString() const = 0; 338 std::list< Expression* > parameters;339 std::string name;340 private:341 bool hoistType;342 343 }; 343 344 … … 345 346 typedef ReferenceToType Parent; 346 347 public: 348 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, 349 // where the structure used in this type is actually defined 350 StructDecl *baseStruct; 351 347 352 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 348 353 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 368 373 private: 369 374 virtual std::string typeString() const; 370 371 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,372 // where the structure used in this type is actually defined373 StructDecl *baseStruct;374 375 }; 375 376 … … 377 378 typedef ReferenceToType Parent; 378 379 public: 380 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 381 // where the union used in this type is actually defined 382 UnionDecl *baseUnion; 383 379 384 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 380 385 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 400 405 private: 401 406 virtual std::string typeString() const; 402 407 }; 408 409 class EnumInstType : public ReferenceToType { 410 typedef ReferenceToType Parent; 411 public: 403 412 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 404 413 // where the union used in this type is actually defined 405 UnionDecl *baseUnion; 406 }; 407 408 class EnumInstType : public ReferenceToType { 409 typedef ReferenceToType Parent; 410 public: 414 EnumDecl *baseEnum = nullptr; 415 411 416 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 412 417 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 423 428 private: 424 429 virtual std::string typeString() const; 425 426 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,427 // where the union used in this type is actually defined428 EnumDecl *baseEnum = nullptr;429 430 }; 430 431 … … 432 433 typedef ReferenceToType Parent; 433 434 public: 435 // this member is filled in by the validate pass, which instantiates the members of the correponding 436 // aggregate with the actual type parameters specified for this use of the context 437 std::list< Declaration* > members; 438 434 439 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 435 440 TraitInstType( const TraitInstType & other ); … … 445 450 private: 446 451 virtual std::string typeString() const; 447 448 // this member is filled in by the validate pass, which instantiates the members of the correponding449 // aggregate with the actual type parameters specified for this use of the context450 std::list< Declaration* > members;451 452 }; 452 453 … … 454 455 typedef ReferenceToType Parent; 455 456 public: 457 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, 458 // where the type used here is actually defined 459 TypeDecl *baseType; 460 bool isFtype; 461 456 462 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 457 463 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 472 478 private: 473 479 virtual std::string typeString() const; 474 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,475 // where the type used here is actually defined476 TypeDecl *baseType;477 bool isFtype;478 480 }; 479 481 480 482 class TupleType : public Type { 481 483 public: 484 std::list<Type *> types; 485 std::list<Declaration *> members; 486 482 487 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 483 488 TupleType( const TupleType& ); … … 508 513 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 509 514 virtual void print( std::ostream & os, int indent = 0 ) const; 510 private:511 std::list<Type *> types;512 std::list<Declaration *> members;513 515 }; 514 516 515 517 class TypeofType : public Type { 516 518 public: 519 Expression *expr; 520 517 521 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 518 522 TypeofType( const TypeofType& ); … … 528 532 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 529 533 virtual void print( std::ostream & os, int indent = 0 ) const; 530 private: 534 }; 535 536 class AttrType : public Type { 537 public: 538 std::string name; 531 539 Expression *expr; 532 }; 533 534 class AttrType : public Type { 535 public: 540 Type *type; 541 bool isType; 542 536 543 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 537 544 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 554 561 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 555 562 virtual void print( std::ostream & os, int indent = 0 ) const; 556 private:557 std::string name;558 Expression *expr;559 Type *type;560 bool isType;561 563 }; 562 564 -
src/SynTree/TypeDecl.cc
rcbce272 r65cdc1e 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 : Thu Mar 16 07:49:58201713 // Update Count : 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:35:00 2017 13 // Update Count : 6 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), kind( kind ), init( init ), sized( kind == Any || kind == Ttype) {20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) { 21 21 } 22 22 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) {23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) { 24 24 } 25 25
Note: See TracChangeset
for help on using the changeset viewer.