- Timestamp:
- May 21, 2019, 4:08:45 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 514a791
- Parents:
- d148778 (diff), ca8704f (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. - Location:
- src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rd148778 ra83044fb 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri May 17 16:01:00 201913 // Update Count : 412 // Last Modified On : Tue May 21 15:30:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 108 108 109 109 private: 110 void declPostamble( Declaration * decl, const ast::Decl * node ) { 111 decl->location = node->location; 112 // name comes from constructor 113 // linkage comes from constructor 114 decl->extension = node->extension; 115 decl->uniqueId = node->uniqueId; 116 // storageClasses comes from constructor 117 this->node = decl; 118 } 119 120 const ast::DeclWithType * declWithTypePostamble ( 121 DeclarationWithType * decl, const ast::DeclWithType * node ) { 122 declPostamble( decl, node ); 123 decl->mangleName = node->mangleName; 124 decl->scopeLevel = node->scopeLevel; 125 decl->asmName = get<Expression>().accept1( node->asmName ); 126 // attributes comes from constructor 127 decl->isDeleted = node->isDeleted; 128 // fs comes from constructor 129 return nullptr; 130 } 131 110 132 const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final { 111 (void)node; 112 return nullptr; 133 auto decl = new ObjectDecl( 134 node->name, 135 Type::StorageClasses( node->storage.val ), 136 LinkageSpec::Spec( node->linkage.val ), 137 get<Expression>().accept1( node->bitfieldWidth ), 138 get<Type>().accept1( node->type ), 139 get<Initializer>().accept1( node->init ), 140 get<Attribute>().acceptL( node->attributes ), 141 Type::FuncSpecifiers( node->funcSpec.val ) 142 ); 143 return declWithTypePostamble( decl, node ); 113 144 } 114 145 115 146 const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final { 116 (void)node; 147 auto decl = new FunctionDecl( 148 node->name, 149 Type::StorageClasses( node->storage.val ), 150 LinkageSpec::Spec( node->linkage.val ), 151 get<FunctionType>().accept1( node->type ), 152 get<CompoundStmt>().accept1( node->stmts ), 153 get<Attribute>().acceptL( node->attributes ), 154 Type::FuncSpecifiers( node->funcSpec.val ) 155 ); 156 decl->withExprs = get<Expression>().acceptL( node->withExprs ); 157 return declWithTypePostamble( decl, node ); 158 } 159 160 // NamedTypeDecl 161 const ast::Decl * namedTypePostamble( NamedTypeDecl * decl, const ast::NamedTypeDecl * node ) { 162 declPostamble( decl, node ); 163 // base comes from constructor 164 decl->parameters = get<TypeDecl>().acceptL( node->params ); 165 decl->assertions = get<DeclarationWithType>().acceptL( node->assertions ); 166 return nullptr; 167 } 168 169 const ast::Decl * visit( const ast::TypeDecl * node ) override final { 170 TypeDecl::Kind kind; 171 switch (node->kind) { 172 case ast::TypeVar::Dtype: 173 kind = TypeDecl::Dtype; 174 break; 175 case ast::TypeVar::Ftype: 176 kind = TypeDecl::Ftype; 177 break; 178 case ast::TypeVar::Ttype: 179 kind = TypeDecl::Ttype; 180 break; 181 default: 182 assertf(false, "Invalid ast::TypeVar::Kind: %d\n", node->kind); 183 }; 184 auto decl = new TypeDecl( 185 node->name, 186 Type::StorageClasses( node->storage.val ), 187 get<Type>().accept1( node->base ), 188 kind, 189 node->sized, 190 get<Type>().accept1( node->init ) 191 ); 192 return namedTypePostamble( decl, node ); 193 } 194 195 const ast::Decl * visit( const ast::TypedefDecl * node ) override final { 196 auto decl = new TypedefDecl( 197 node->name, 198 node->location, 199 Type::StorageClasses( node->storage.val ), 200 get<Type>().accept1( node->base ), 201 LinkageSpec::Spec( node->linkage.val ) 202 ); 203 return namedTypePostamble( decl, node ); 204 } 205 206 const ast::Decl * aggregatePostamble( AggregateDecl * decl, const ast::AggregateDecl * node ) { 207 decl->members = get<Declaration>().acceptL( node->members ); 208 decl->parameters = get<TypeDecl>().acceptL( node->params ); 209 decl->body = node->body; 210 // attributes come from constructor 211 // TODO: Need caching for: decl->parent = node->parent; 117 212 return nullptr; 118 213 } 119 214 120 215 const ast::Decl * visit( const ast::StructDecl * node ) override final { 121 (void)node; 122 return nullptr; 216 auto decl = new StructDecl( 217 node->name, 218 node->kind, 219 get<Attribute>().acceptL( node->attributes ), 220 LinkageSpec::Spec( node->linkage.val ) 221 ); 222 return aggregatePostamble( decl, node ); 123 223 } 124 224 125 225 const ast::Decl * visit( const ast::UnionDecl * node ) override final { 126 (void)node; 127 return nullptr; 226 auto decl = new UnionDecl( 227 node->name, 228 get<Attribute>().acceptL( node->attributes ), 229 LinkageSpec::Spec( node->linkage.val ) 230 ); 231 return aggregatePostamble( decl, node ); 128 232 } 129 233 130 234 const ast::Decl * visit( const ast::EnumDecl * node ) override final { 131 (void)node; 132 return nullptr; 235 auto decl = new EnumDecl( 236 node->name, 237 get<Attribute>().acceptL( node->attributes ), 238 LinkageSpec::Spec( node->linkage.val ) 239 ); 240 return aggregatePostamble( decl, node ); 133 241 } 134 242 135 243 const ast::Decl * visit( const ast::TraitDecl * node ) override final { 136 (void)node; 137 return nullptr; 138 } 139 140 const ast::Decl * visit( const ast::TypeDecl * node ) override final { 141 (void)node; 142 return nullptr; 143 } 144 145 const ast::Decl * visit( const ast::TypedefDecl * node ) override final { 146 (void)node; 147 return nullptr; 244 auto decl = new TraitDecl( 245 node->name, 246 {}, 247 LinkageSpec::Spec( node->linkage.val ) 248 ); 249 return aggregatePostamble( decl, node ); 148 250 } 149 251 150 252 const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final { 151 (void)node; 253 auto decl = new AsmDecl( get<AsmStmt>().accept1( node->stmt ) ); 254 declPostamble( decl, node ); 152 255 return nullptr; 153 256 } 154 257 155 258 const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) override final { 156 (void)node; 157 return nullptr; 158 } 159 160 const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final { 161 auto stmt = new CompoundStmt( get<Statement>().acceptL( node->kids ) ); 259 auto decl = new StaticAssertDecl( 260 get<Expression>().accept1( node->cond ), 261 get<ConstantExpr>().accept1( node->msg ) 262 ); 263 declPostamble( decl, node ); 264 return nullptr; 265 } 266 267 const ast::Stmt * stmtPostamble( Statement * stmt, const ast::Stmt * node ) { 162 268 stmt->location = node->location; 163 269 stmt->labels = makeLabelL( stmt, node->labels ); … … 166 272 } 167 273 274 const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final { 275 auto stmt = new CompoundStmt( get<Statement>().acceptL( node->kids ) ); 276 stmtPostamble( stmt, node ); 277 return nullptr; 278 } 279 168 280 const ast::Stmt * visit( const ast::ExprStmt * node ) override final { 169 281 auto stmt = new ExprStmt( get<Expression>().accept1( node->expr ) ); 170 stmt->location = node->location; 171 stmt->labels = makeLabelL( stmt, node->labels ); 172 this->node = stmt; 173 return nullptr; 282 return stmtPostamble( stmt, node ); 174 283 } 175 284 … … 183 292 makeLabelL( nullptr, node->gotoLabels ) // What are these labelling? 184 293 ); 185 stmt->location = node->location; 186 stmt->labels = makeLabelL( stmt, node->labels ); 187 this->node = stmt; 188 return nullptr; 294 return stmtPostamble( stmt, node ); 189 295 } 190 296 191 297 const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final { 192 298 auto stmt = new DirectiveStmt( node->directive ); 193 stmt->location = node->location; 194 stmt->labels = makeLabelL( stmt, node->labels ); 195 this->node = stmt; 196 return nullptr; 299 return stmtPostamble( stmt, node ); 197 300 } 198 301 … … 204 307 get<Statement>().acceptL( node->inits ) 205 308 ); 206 stmt->location = node->location; 207 stmt->labels = makeLabelL( stmt, node->labels ); 208 this->node = stmt; 209 return nullptr; 309 return stmtPostamble( stmt, node ); 210 310 } 211 311 … … 215 315 get<Statement>().acceptL( node->stmts ) 216 316 ); 217 stmt->location = node->location; 218 stmt->labels = makeLabelL( stmt, node->labels ); 219 this->node = stmt; 220 return nullptr; 317 return stmtPostamble( stmt, node ); 221 318 } 222 319 … … 227 324 node->isDefault() 228 325 ); 229 stmt->location = node->location; 230 stmt->labels = makeLabelL( stmt, node->labels ); 231 this->node = stmt; 232 return nullptr; 326 return stmtPostamble( stmt, node ); 233 327 } 234 328 … … 241 335 node->isDoWhile 242 336 ); 243 stmt->location = node->location; 244 stmt->labels = makeLabelL( stmt, node->labels ); 245 this->node = stmt; 246 return nullptr; 337 return stmtPostamble( stmt, node ); 247 338 } 248 339 … … 254 345 get<Statement>().accept1( node->body ) 255 346 ); 256 stmt->location = node->location; 257 stmt->labels = makeLabelL( stmt, node->labels ); 258 this->node = stmt; 259 return nullptr; 347 return stmtPostamble( stmt, node ); 260 348 } 261 349 … … 286 374 stmt->target = makeLabel( stmt, node->target ); 287 375 } 288 stmt->location = node->location; 289 stmt->labels = makeLabelL( stmt, node->labels ); 290 this->node = stmt; 291 return nullptr; 376 return stmtPostamble( stmt, node ); 292 377 } 293 378 294 379 const ast::Stmt * visit( const ast::ReturnStmt * node ) override final { 295 380 auto stmt = new ReturnStmt( get<Expression>().accept1( node->expr ) ); 296 stmt->location = node->location; 297 stmt->labels = makeLabelL( stmt, node->labels ); 298 this->node = stmt; 299 return nullptr; 381 return stmtPostamble( stmt, node ); 300 382 } 301 383 … … 317 399 get<Expression>().accept1( node->target ) 318 400 ); 319 stmt->location = node->location; 320 stmt->labels = makeLabelL( stmt, node->labels ); 321 this->node = stmt; 322 return nullptr; 401 return stmtPostamble( stmt, node ); 323 402 } 324 403 … … 330 409 get<FinallyStmt>().accept1( node->finally ) 331 410 ); 332 stmt->location = node->location; 333 stmt->labels = makeLabelL( stmt, node->labels ); 334 this->node = stmt; 335 return nullptr; 411 return stmtPostamble( stmt, node ); 336 412 } 337 413 … … 354 430 get<Statement>().accept1( node->body ) 355 431 ); 356 stmt->location = node->location; 357 stmt->labels = makeLabelL( stmt, node->labels ); 358 this->node = stmt; 359 return nullptr; 432 return stmtPostamble( stmt, node ); 360 433 } 361 434 362 435 const ast::Stmt * visit( const ast::FinallyStmt * node ) override final { 363 436 auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) ); 364 stmt->location = node->location; 365 stmt->labels = makeLabelL( stmt, node->labels ); 366 this->node = stmt; 367 return nullptr; 437 return stmtPostamble( stmt, node ); 368 438 } 369 439 … … 373 443 for ( auto clause : node->clauses ) { 374 444 stmt->clauses.push_back({{ 375 get<Expression>().accept1( clause.target.func tion),376 get<Expression>().acceptL( clause.target.arg uments ),445 get<Expression>().accept1( clause.target.func ), 446 get<Expression>().acceptL( clause.target.args ), 377 447 }, 378 448 get<Statement>().accept1( clause.stmt ), … … 389 459 get<Expression>().accept1( node->orElse.cond ), 390 460 }; 391 stmt->location = node->location; 392 stmt->labels = makeLabelL( stmt, node->labels ); 393 this->node = stmt; 394 return nullptr; 461 return stmtPostamble( stmt, node ); 395 462 } 396 463 … … 400 467 get<Statement>().accept1( node->stmt ) 401 468 ); 402 stmt->location = node->location; 403 stmt->labels = makeLabelL( stmt, node->labels ); 404 this->node = stmt; 405 return nullptr; 469 return stmtPostamble( stmt, node ); 406 470 } 407 471 408 472 const ast::NullStmt * visit( const ast::NullStmt * node ) override final { 409 473 auto stmt = new NullStmt(); 410 stmt->location = node->location; 411 stmt->labels = makeLabelL( stmt, node->labels ); 412 this->node = stmt; 474 stmtPostamble( stmt, node ); 413 475 return nullptr; 414 476 } … … 416 478 const ast::Stmt * visit( const ast::DeclStmt * node ) override final { 417 479 auto stmt = new DeclStmt( get<Declaration>().accept1( node->decl ) ); 418 stmt->location = node->location; 419 stmt->labels = makeLabelL( stmt, node->labels ); 420 this->node = stmt; 421 return nullptr; 480 return stmtPostamble( stmt, node ); 422 481 } 423 482 … … 427 486 } 428 487 488 TypeSubstitution * convertTypeSubstitution(const ast::TypeSubstitution * src) { 489 490 TypeSubstitution *rslt = new TypeSubstitution(); 491 492 for (decltype(src->begin()) src_i = src->begin(); src_i != src->end(); src_i++) { 493 rslt->add( src_i->first, 494 get<Type>().accept1(src_i->second) ); 495 } 496 497 for (decltype(src->beginVar()) src_i = src->beginVar(); src_i != src->endVar(); src_i++) { 498 rslt->addVar( src_i->first, 499 get<Expression>().accept1(src_i->second) ); 500 } 501 502 return rslt; 503 } 504 505 void convertInferUnion(std::map<UniqueId,ParamEntry> &tgtInferParams, 506 std::vector<UniqueId> &tgtResnSlots, 507 const ast::Expr::InferUnion &srcInferred ) { 508 509 assert( tgtInferParams.empty() ); 510 assert( tgtResnSlots.empty() ); 511 512 if ( srcInferred.mode == ast::Expr::InferUnion::Params ) { 513 const ast::InferredParams &srcParams = srcInferred.inferParamsConst(); 514 for (auto srcParam : srcParams) { 515 tgtInferParams[srcParam.first] = ParamEntry( 516 srcParam.second.decl, 517 get<Type>().accept1(srcParam.second.actualType), 518 get<Type>().accept1(srcParam.second.formalType), 519 get<Expression>().accept1(srcParam.second.expr) 520 ); 521 } 522 } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots ) { 523 const ast::ResnSlots &srcSlots = srcInferred.resnSlotsConst(); 524 for (auto srcSlot : srcSlots) { 525 tgtResnSlots.push_back(srcSlot); 526 } 527 } 528 } 529 530 Expression * visitBaseExpr(const ast::Expr * src, Expression * tgt) { 531 532 tgt->location = src->location; 533 534 tgt->result = get<Type>().accept1(src->result); 535 tgt->env = convertTypeSubstitution(src->env); 536 537 tgt->extension = src->extension; 538 convertInferUnion(tgt->inferParams, tgt->resnSlots, src->inferred); 539 540 return tgt; 541 } 542 429 543 const ast::Expr * visit( const ast::ApplicationExpr * node ) override final { 430 (void)node; 544 auto expr = visitBaseExpr( node, 545 new ApplicationExpr( 546 get<Expression>().accept1(node->func), 547 get<Expression>().acceptL(node->args) 548 ) 549 ); 550 this->node = expr; 431 551 return nullptr; 432 552 } 433 553 434 554 const ast::Expr * visit( const ast::UntypedExpr * node ) override final { 435 (void)node; 555 auto expr = visitBaseExpr( node, 556 new UntypedExpr( 557 get<Expression>().accept1(node->func), 558 get<Expression>().acceptL(node->args) 559 ) 560 ); 561 this->node = expr; 436 562 return nullptr; 437 563 } 438 564 439 565 const ast::Expr * visit( const ast::NameExpr * node ) override final { 440 (void)node; 566 auto expr = visitBaseExpr( node, 567 new NameExpr( 568 node->name 569 ) 570 ); 571 this->node = expr; 441 572 return nullptr; 442 573 } … … 1236 1367 getAccept1<ast::Expr>(old_i->second) ); 1237 1368 } 1238 } 1239 1240 void convertInferUnion(ast::Expr::InferUnion &nwInferred, InferredParams oldInferParams, const std::vector<UniqueId> &oldResnSlots) { 1241 1242 (void) nwInferred; 1243 (void) oldInferParams; 1244 (void) oldResnSlots; 1245 1246 // TODO 1369 1370 return rslt; 1371 } 1372 1373 void convertInferUnion(ast::Expr::InferUnion &newInferred, 1374 const std::map<UniqueId,ParamEntry> &oldInferParams, 1375 const std::vector<UniqueId> &oldResnSlots) { 1376 1377 assert( oldInferParams.empty() || oldResnSlots.empty() ); 1378 assert( newInferred.mode == ast::Expr::InferUnion::Empty ); 1379 1380 if ( !oldInferParams.empty() ) { 1381 ast::InferredParams &tgt = newInferred.inferParams(); 1382 for (auto old : oldInferParams) { 1383 tgt[old.first] = ast::ParamEntry( 1384 old.second.decl, 1385 getAccept1<ast::Type>(old.second.actualType), 1386 getAccept1<ast::Type>(old.second.formalType), 1387 getAccept1<ast::Expr>(old.second.expr) 1388 ); 1389 } 1390 } else if ( !oldResnSlots.empty() ) { 1391 ast::ResnSlots &tgt = newInferred.resnSlots(); 1392 for (auto old : oldResnSlots) { 1393 tgt.push_back(old); 1394 } 1395 } 1247 1396 } 1248 1397 … … 1258 1407 } 1259 1408 1260 virtual void visit( ApplicationExpr * ) override final { 1261 // TODO 1262 } 1263 1264 virtual void visit( UntypedExpr * ) override final { 1265 // TODO 1409 virtual void visit( ApplicationExpr * old ) override final { 1410 this->node = visitBaseExpr( old, 1411 new ast::ApplicationExpr( 1412 old->location, 1413 GET_ACCEPT_1(function, Expr), 1414 GET_ACCEPT_V(args, Expr) 1415 ) 1416 ); 1417 } 1418 1419 virtual void visit( UntypedExpr * old ) override final { 1420 this->node = visitBaseExpr( old, 1421 new ast::UntypedExpr( 1422 old->location, 1423 GET_ACCEPT_1(function, Expr), 1424 GET_ACCEPT_V(args, Expr) 1425 ) 1426 ); 1266 1427 } 1267 1428 … … 1275 1436 } 1276 1437 1277 virtual void visit( CastExpr * ) override final { 1278 // TODO ... (rest) 1438 virtual void visit( CastExpr * old ) override final { 1439 this->node = visitBaseExpr( old, 1440 new ast::CastExpr( 1441 old->location, 1442 nullptr, // cast's "to" type is expr's result type; converted in visitBaseExpr 1443 old->isGenerated ? ast::GeneratedCast : ast::ExplicitCast 1444 ) 1445 ); 1279 1446 } 1280 1447 -
src/AST/Decl.cpp
rd148778 ra83044fb 81 81 auto result = eval( init->value ); 82 82 if ( ! result.second ) { 83 SemanticError( init->location, toString( "Non-constexpr in initialization of "83 SemanticError( init->location, ::toString( "Non-constexpr in initialization of " 84 84 "enumerator: ", field ) ); 85 85 } … … 87 87 } 88 88 if ( enumValues.count( field->name ) != 0 ) { 89 SemanticError( location, toString( "Enum ", name, " has multiple members with the " "name ", field->name ) );89 SemanticError( location, ::toString( "Enum ", name, " has multiple members with the " "name ", field->name ) ); 90 90 } 91 91 enumValues[ field->name ] = crntVal; -
src/AST/Decl.hpp
rd148778 ra83044fb 329 329 class StaticAssertDecl : public Decl { 330 330 public: 331 ptr<Expr> cond ition;331 ptr<Expr> cond; 332 332 ptr<ConstantExpr> msg; // string literal 333 333 334 334 StaticAssertDecl( const CodeLocation & loc, const Expr * condition, const ConstantExpr * msg ) 335 : Decl( loc, "", {}, {} ), cond ition( condition ), msg( msg ) {}335 : Decl( loc, "", {}, {} ), cond( condition ), msg( msg ) {} 336 336 337 337 const StaticAssertDecl * accept( Visitor &v ) const override { return v.visit( this ); } -
src/AST/Expr.cpp
rd148778 ra83044fb 22 22 #include "Stmt.hpp" 23 23 #include "Type.hpp" 24 #include "Common/utility.h" 24 25 #include "Common/SemanticError.h" 25 26 #include "GenPoly/Lvalue.h" // for referencesPermissable -
src/AST/Expr.hpp
rd148778 ra83044fb 106 106 case Params: assert(!"Cannot return to resnSlots from Params"); 107 107 } 108 return *((ResnSlots*)nullptr); 109 } 110 111 const ResnSlots& resnSlotsConst() const { 112 if (mode == Slots) { 113 return data.resnSlots; 114 } 115 assert(!"Mode was not already resnSlots"); 116 return *((ResnSlots*)nullptr); 108 117 } 109 118 … … 114 123 case Params: return data.inferParams; 115 124 } 125 return *((InferredParams*)nullptr); 126 } 127 128 const InferredParams& inferParamsConst() const { 129 if (mode == Params) { 130 return data.inferParams; 131 } 132 assert(!"Mode was not already Params"); 133 return *((InferredParams*)nullptr); 116 134 } 117 135 }; … … 503 521 }; 504 522 505 /// The application of a function to a set of parameters, along with a set of copy constructor 523 /// The application of a function to a set of parameters, along with a set of copy constructor 506 524 /// calls, one for each argument 507 525 class ImplicitCopyCtorExpr final : public Expr { … … 603 621 }; 604 622 605 /// A multiple- or mass-assignment operation, or a tuple ctor/dtor expression. 606 /// multiple-assignment: both sides of the assignment have tuple type, 623 /// A multiple- or mass-assignment operation, or a tuple ctor/dtor expression. 624 /// multiple-assignment: both sides of the assignment have tuple type, 607 625 /// e.g. `[a, b, c] = [d, e, f];` 608 626 /// mass-assignment: left-hand side has tuple type and right-hand side does not: … … 612 630 ptr<StmtExpr> stmtExpr; 613 631 614 TupleAssignExpr( 615 const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 632 TupleAssignExpr( 633 const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 616 634 std::vector<ptr<ObjectDecl>> && tempDecls ); 617 635 618 636 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 619 637 private: -
src/AST/Fwd.hpp
rd148778 ra83044fb 131 131 class TypeSubstitution; 132 132 133 std::string toString( const Node * );134 135 template < typename ... Params >136 std::string toString( const Params & ... params );137 138 133 typedef unsigned int UniqueId; 139 134 -
src/AST/Node.cpp
rd148778 ra83044fb 16 16 #include "Node.hpp" 17 17 #include "Fwd.hpp" 18 19 #include <iostream> 18 20 19 21 #include "Attribute.hpp" … … 42 44 assign( r ); 43 45 return r; 46 } 47 48 std::ostream & ast::operator<< ( std::ostream & out, const ast::Node * node ) { 49 (void)node; 50 #warning unimplemented 51 assertf(false, "Unimplemented"); 52 return out; 44 53 } 45 54 -
src/AST/Pass.impl.hpp
rd148778 ra83044fb 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Pass.impl.hpp --7 // ast::Pass.impl.hpp -- 8 8 // 9 9 // Author : Thierry Delisle … … 121 121 template< typename pass_t > 122 122 template< typename node_t > 123 auto Pass< pass_t >::call_accept( const node_t * node )123 auto ast::Pass< pass_t >::call_accept( const node_t * node ) 124 124 -> typename std::enable_if< 125 125 !std::is_base_of<ast::Expr, node_t>::value && … … 139 139 140 140 template< typename pass_t > 141 const ast::Expr * Pass< pass_t >::call_accept( const ast::Expr * expr ) {141 const ast::Expr * ast::Pass< pass_t >::call_accept( const ast::Expr * expr ) { 142 142 __pedantic_pass_assert( __visit_children() ); 143 143 __pedantic_pass_assert( expr ); … … 152 152 153 153 template< typename pass_t > 154 const ast::Stmt * Pass< pass_t >::call_accept( const ast::Stmt * stmt ) {154 const ast::Stmt * ast::Pass< pass_t >::call_accept( const ast::Stmt * stmt ) { 155 155 __pedantic_pass_assert( __visit_children() ); 156 156 __pedantic_pass_assert( stmt ); … … 204 204 template< typename pass_t > 205 205 template< template <class...> class container_t > 206 container_t< ptr<Stmt> > Pass< pass_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {206 container_t< ptr<Stmt> > ast::Pass< pass_t >::call_accept( const container_t< ptr<Stmt> > & statements ) { 207 207 __pedantic_pass_assert( __visit_children() ); 208 208 if( statements.empty() ) return {}; … … 270 270 template< typename pass_t > 271 271 template< template <class...> class container_t, typename node_t > 272 container_t< ast::ptr<node_t> > Pass< pass_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {272 container_t< ast::ptr<node_t> > ast::Pass< pass_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) { 273 273 __pedantic_pass_assert( __visit_children() ); 274 274 if( container.empty() ) return {}; … … 301 301 template< typename pass_t > 302 302 template<typename node_t, typename parent_t, typename child_t> 303 void Pass< pass_t >::maybe_accept(303 void ast::Pass< pass_t >::maybe_accept( 304 304 const node_t * & parent, 305 305 child_t parent_t::*child … … 571 571 __pass::indexer::addType( pass, 0, node ); 572 572 573 maybe_accept( node, &TypedefDecl::assertions );573 VISIT( maybe_accept( node, &TypedefDecl::assertions ); ) 574 574 575 575 VISIT_END( Decl, node ); … … 596 596 597 597 VISIT( 598 maybe_accept( node, &StaticAssertDecl::cond ition);599 maybe_accept( node, &StaticAssertDecl::msg 598 maybe_accept( node, &StaticAssertDecl::cond ); 599 maybe_accept( node, &StaticAssertDecl::msg ); 600 600 ) 601 601 … … 626 626 // ExprStmt 627 627 template< typename pass_t > 628 const ast::Stmt * ast::Pass< pass_t >::visit( const ExprStmt * node ) {628 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ExprStmt * node ) { 629 629 VISIT_START( node ); 630 630 … … 666 666 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::IfStmt * node ) { 667 667 VISIT_START( node ); 668 668 669 VISIT({ 669 670 // if statements introduce a level of scope (for the initialization) … … 674 675 maybe_accept( node, &IfStmt::elsePart ); 675 676 }) 677 676 678 VISIT_END( Stmt, node ); 677 679 } … … 680 682 // WhileStmt 681 683 template< typename pass_t > 682 const ast::Stmt * ast::Pass< pass_t >::visit( const WhileStmt * node ) {684 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WhileStmt * node ) { 683 685 VISIT_START( node ); 684 686 … … 832 834 // maybeAccept_impl( clause.condition, *this ); 833 835 // } 836 837 VISIT({ 838 std::vector<WaitForStmt::Clause> new_clauses; 839 new_clauses.reserve( node->clauses.size() ); 840 bool mutated = false; 841 for( const auto & clause : node->clauses ) { 842 843 Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr; 844 if(func != clause.target.func) mutated = true; 845 846 std::vector<ptr<Expr>> new_args; 847 new_args.reserve(clause.target.args.size()); 848 for( const auto & arg : clause.target.args ) { 849 auto a = arg->accept(*this); 850 new_args.push_back( a ); 851 if( a != arg ) mutated = true; 852 } 853 854 Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr; 855 if(stmt != clause.stmt) mutated = true; 856 857 Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr; 858 if(cond != clause.cond) mutated = true; 859 860 new_clauses.push_back( WaitForStmt::Clause{ {func, std::move(new_args) }, stmt, cond } ); 861 } 862 863 if(mutated) { 864 auto n = mutate(node); 865 n->clauses = std::move( new_clauses ); 866 node = n; 867 } 868 }) 834 869 835 870 #define maybe_accept(field) \ … … 910 945 } 911 946 912 913 914 915 947 //-------------------------------------------------------------------------- 948 // ApplicationExpr 949 template< typename pass_t > 950 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ApplicationExpr * node ) { 951 VISIT_START( node ); 952 953 VISIT( 954 { 955 guard_indexer guard { *this }; 956 maybe_accept( node, &ApplicationExpr::result ); 957 } 958 maybe_accept( node, &ApplicationExpr::func ); 959 maybe_accept( node, &ApplicationExpr::args ); 960 ) 961 962 VISIT_END( Expr, node ); 963 } 964 965 //-------------------------------------------------------------------------- 966 // UntypedExpr 967 template< typename pass_t > 968 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedExpr * node ) { 969 VISIT_START( node ); 970 971 VISIT( 972 { 973 guard_indexer guard { *this }; 974 maybe_accept( node, &UntypedExpr::result ); 975 } 976 977 maybe_accept( node, &UntypedExpr::args ); 978 ) 979 980 VISIT_END( Expr, node ); 981 } 982 983 //-------------------------------------------------------------------------- 984 // NameExpr 985 template< typename pass_t > 986 const ast::Expr * ast::Pass< pass_t >::visit( const ast::NameExpr * node ) { 987 VISIT_START( node ); 988 989 VISIT({ 990 guard_indexer guard { *this }; 991 maybe_accept( node, &NameExpr::result ); 992 }) 993 994 VISIT_END( Expr, node ); 995 } 996 997 //-------------------------------------------------------------------------- 998 // CastExpr 999 template< typename pass_t > 1000 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CastExpr * node ) { 1001 VISIT_START( node ); 1002 1003 VISIT({ 1004 guard_indexer guard { *this }; 1005 maybe_accept( node, &CastExpr::result ); 1006 } 1007 maybe_accept( node, &CastExpr::arg ); 1008 ) 1009 1010 VISIT_END( Expr, node ); 1011 } 1012 1013 //-------------------------------------------------------------------------- 1014 // KeywordCastExpr 1015 template< typename pass_t > 1016 const ast::Expr * ast::Pass< pass_t >::visit( const ast::KeywordCastExpr * node ) { 1017 VISIT_START( node ); 1018 1019 VISIT({ 1020 guard_indexer guard { *this }; 1021 maybe_accept( node, &KeywordCastExpr::result ); 1022 } 1023 maybe_accept( node, &KeywordCastExpr::arg ); 1024 ) 1025 1026 VISIT_END( Expr, node ); 1027 } 1028 1029 //-------------------------------------------------------------------------- 1030 // VirtualCastExpr 1031 template< typename pass_t > 1032 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VirtualCastExpr * node ) { 1033 VISIT_START( node ); 1034 1035 VISIT({ 1036 guard_indexer guard { *this }; 1037 maybe_accept( node, &VirtualCastExpr::result ); 1038 } 1039 maybe_accept( node, &VirtualCastExpr::arg ); 1040 ) 1041 1042 VISIT_END( Expr, node ); 1043 } 1044 1045 //-------------------------------------------------------------------------- 1046 // AddressExpr 1047 template< typename pass_t > 1048 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AddressExpr * node ) { 1049 VISIT_START( node ); 1050 1051 VISIT({ 1052 guard_indexer guard { *this }; 1053 maybe_accept( node, &AddressExpr::result ); 1054 } 1055 maybe_accept( node, &AddressExpr::arg ); 1056 ) 1057 1058 VISIT_END( Expr, node ); 1059 } 1060 1061 //-------------------------------------------------------------------------- 1062 // LabelAddressExpr 1063 template< typename pass_t > 1064 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LabelAddressExpr * node ) { 1065 VISIT_START( node ); 1066 1067 VISIT({ 1068 guard_indexer guard { *this }; 1069 maybe_accept( node, &LabelAddressExpr::result ); 1070 }) 1071 1072 VISIT_END( Expr, node ); 1073 } 1074 1075 //-------------------------------------------------------------------------- 1076 // UntypedMemberExpr 1077 template< typename pass_t > 1078 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedMemberExpr * node ) { 1079 VISIT_START( node ); 1080 1081 VISIT({ 1082 guard_indexer guard { *this }; 1083 maybe_accept( node, &UntypedMemberExpr::result ); 1084 } 1085 maybe_accept( node, &UntypedMemberExpr::aggregate ); 1086 maybe_accept( node, &UntypedMemberExpr::member ); 1087 ) 1088 1089 VISIT_END( Expr, node ); 1090 } 1091 1092 //-------------------------------------------------------------------------- 1093 // MemberExpr 1094 template< typename pass_t > 1095 const ast::Expr * ast::Pass< pass_t >::visit( const ast::MemberExpr * node ) { 1096 VISIT_START( node ); 1097 1098 VISIT({ 1099 guard_indexer guard { *this }; 1100 maybe_accept( node, &MemberExpr::result ); 1101 } 1102 maybe_accept( node, &MemberExpr::aggregate ); 1103 ) 1104 1105 VISIT_END( Expr, node ); 1106 } 1107 1108 //-------------------------------------------------------------------------- 1109 // VariableExpr 1110 template< typename pass_t > 1111 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VariableExpr * node ) { 1112 VISIT_START( node ); 1113 1114 VISIT({ 1115 guard_indexer guard { *this }; 1116 maybe_accept( node, &VariableExpr::result ); 1117 }) 1118 1119 VISIT_END( Expr, node ); 1120 } 1121 1122 //-------------------------------------------------------------------------- 1123 // ConstantExpr 1124 template< typename pass_t > 1125 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstantExpr * node ) { 1126 VISIT_START( node ); 1127 1128 VISIT({ 1129 guard_indexer guard { *this }; 1130 maybe_accept( node, &ConstantExpr::result ); 1131 }) 1132 1133 VISIT_END( Expr, node ); 1134 } 1135 1136 //-------------------------------------------------------------------------- 1137 // SizeofExpr 1138 template< typename pass_t > 1139 const ast::Expr * ast::Pass< pass_t >::visit( const ast::SizeofExpr * node ) { 1140 VISIT_START( node ); 1141 1142 VISIT({ 1143 guard_indexer guard { *this }; 1144 maybe_accept( node, &SizeofExpr::result ); 1145 } 1146 if ( node->type ) { 1147 maybe_accept( node, &SizeofExpr::type ); 1148 } else { 1149 maybe_accept( node, &SizeofExpr::expr ); 1150 } 1151 ) 1152 1153 VISIT_END( Expr, node ); 1154 } 1155 1156 //-------------------------------------------------------------------------- 1157 // AlignofExpr 1158 template< typename pass_t > 1159 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AlignofExpr * node ) { 1160 VISIT_START( node ); 1161 1162 VISIT({ 1163 guard_indexer guard { *this }; 1164 maybe_accept( node, &AlignofExpr::result ); 1165 } 1166 if ( node->type ) { 1167 maybe_accept( node, &AlignofExpr::type ); 1168 } else { 1169 maybe_accept( node, &AlignofExpr::expr ); 1170 } 1171 ) 1172 1173 VISIT_END( Expr, node ); 1174 } 1175 1176 //-------------------------------------------------------------------------- 1177 // UntypedOffsetofExpr 1178 template< typename pass_t > 1179 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedOffsetofExpr * node ) { 1180 VISIT_START( node ); 1181 1182 VISIT({ 1183 guard_indexer guard { *this }; 1184 maybe_accept( node, &UntypedOffsetofExpr::result ); 1185 } 1186 maybe_accept( node, &UntypedOffsetofExpr::type ); 1187 ) 1188 1189 VISIT_END( Expr, node ); 1190 } 1191 1192 //-------------------------------------------------------------------------- 1193 // OffsetofExpr 1194 template< typename pass_t > 1195 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetofExpr * node ) { 1196 VISIT_START( node ); 1197 1198 VISIT({ 1199 guard_indexer guard { *this }; 1200 maybe_accept( node, &OffsetofExpr::result ); 1201 } 1202 maybe_accept( node, &OffsetofExpr::type ); 1203 ) 1204 1205 VISIT_END( Expr, node ); 1206 } 1207 1208 //-------------------------------------------------------------------------- 1209 // OffsetPackExpr 1210 template< typename pass_t > 1211 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetPackExpr * node ) { 1212 VISIT_START( node ); 1213 1214 VISIT({ 1215 guard_indexer guard { *this }; 1216 maybe_accept( node, &OffsetPackExpr::result ); 1217 } 1218 maybe_accept( node, &OffsetPackExpr::type ); 1219 ) 1220 1221 VISIT_END( Expr, node ); 1222 } 1223 1224 //-------------------------------------------------------------------------- 1225 // LogicalExpr 1226 template< typename pass_t > 1227 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LogicalExpr * node ) { 1228 VISIT_START( node ); 1229 1230 VISIT({ 1231 guard_indexer guard { *this }; 1232 maybe_accept( node, &LogicalExpr::result ); 1233 } 1234 maybe_accept( node, &LogicalExpr::arg1 ); 1235 maybe_accept( node, &LogicalExpr::arg2 ); 1236 ) 1237 1238 VISIT_END( Expr, node ); 1239 } 1240 1241 //-------------------------------------------------------------------------- 1242 // ConditionalExpr 1243 template< typename pass_t > 1244 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConditionalExpr * node ) { 1245 VISIT_START( node ); 1246 1247 VISIT({ 1248 guard_indexer guard { *this }; 1249 maybe_accept( node, &ConditionalExpr::result ); 1250 } 1251 maybe_accept( node, &ConditionalExpr::arg1 ); 1252 maybe_accept( node, &ConditionalExpr::arg2 ); 1253 maybe_accept( node, &ConditionalExpr::arg3 ); 1254 ) 1255 1256 VISIT_END( Expr, node ); 1257 } 1258 1259 //-------------------------------------------------------------------------- 1260 // CommaExpr 1261 template< typename pass_t > 1262 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CommaExpr * node ) { 1263 VISIT_START( node ); 1264 1265 VISIT({ 1266 guard_indexer guard { *this }; 1267 maybe_accept( node, &CommaExpr::result ); 1268 } 1269 maybe_accept( node, &CommaExpr::arg1 ); 1270 maybe_accept( node, &CommaExpr::arg2 ); 1271 ) 1272 1273 VISIT_END( Expr, node ); 1274 } 1275 1276 //-------------------------------------------------------------------------- 1277 // TypeExpr 1278 template< typename pass_t > 1279 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TypeExpr * node ) { 1280 VISIT_START( node ); 1281 1282 VISIT({ 1283 guard_indexer guard { *this }; 1284 maybe_accept( node, &TypeExpr::result ); 1285 } 1286 maybe_accept( node, &TypeExpr::type ); 1287 ) 1288 1289 VISIT_END( Expr, node ); 1290 } 1291 1292 //-------------------------------------------------------------------------- 1293 // AsmExpr 1294 template< typename pass_t > 1295 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AsmExpr * node ) { 1296 VISIT_START( node ); 1297 1298 VISIT({ 1299 guard_indexer guard { *this }; 1300 maybe_accept( node, &AsmExpr::result ); 1301 } 1302 maybe_accept( node, &AsmExpr::inout ); 1303 maybe_accept( node, &AsmExpr::constraint ); 1304 maybe_accept( node, &AsmExpr::operand ); 1305 ) 1306 1307 VISIT_END( Expr, node ); 1308 } 1309 1310 //-------------------------------------------------------------------------- 1311 // ImplicitCopyCtorExpr 1312 template< typename pass_t > 1313 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ImplicitCopyCtorExpr * node ) { 1314 VISIT_START( node ); 1315 1316 VISIT({ 1317 guard_indexer guard { *this }; 1318 maybe_accept( node, &ImplicitCopyCtorExpr::result ); 1319 } 1320 maybe_accept( node, &ImplicitCopyCtorExpr::callExpr ); 1321 maybe_accept( node, &ImplicitCopyCtorExpr::tempDecls ); 1322 maybe_accept( node, &ImplicitCopyCtorExpr::returnDecls ); 1323 maybe_accept( node, &ImplicitCopyCtorExpr::dtors ); 1324 ) 1325 1326 VISIT_END( Expr, node ); 1327 } 1328 1329 //-------------------------------------------------------------------------- 1330 // ConstructorExpr 1331 template< typename pass_t > 1332 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstructorExpr * node ) { 1333 VISIT_START( node ); 1334 1335 VISIT({ 1336 guard_indexer guard { *this }; 1337 maybe_accept( node, &ConstructorExpr::result ); 1338 } 1339 maybe_accept( node, &ConstructorExpr::callExpr ); 1340 ) 1341 1342 VISIT_END( Expr, node ); 1343 } 1344 1345 //-------------------------------------------------------------------------- 1346 // CompoundLiteralExpr 1347 template< typename pass_t > 1348 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CompoundLiteralExpr * node ) { 1349 VISIT_START( node ); 1350 1351 VISIT({ 1352 guard_indexer guard { *this }; 1353 maybe_accept( node, &CompoundLiteralExpr::result ); 1354 } 1355 maybe_accept( node, &CompoundLiteralExpr::init ); 1356 ) 1357 1358 VISIT_END( Expr, node ); 1359 } 1360 1361 //-------------------------------------------------------------------------- 1362 // RangeExpr 1363 template< typename pass_t > 1364 const ast::Expr * ast::Pass< pass_t >::visit( const ast::RangeExpr * node ) { 1365 VISIT_START( node ); 1366 1367 VISIT({ 1368 guard_indexer guard { *this }; 1369 maybe_accept( node, &RangeExpr::result ); 1370 } 1371 maybe_accept( node, &RangeExpr::low ); 1372 maybe_accept( node, &RangeExpr::high ); 1373 ) 1374 1375 VISIT_END( Expr, node ); 1376 } 1377 1378 //-------------------------------------------------------------------------- 1379 // UntypedTupleExpr 1380 template< typename pass_t > 1381 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedTupleExpr * node ) { 1382 VISIT_START( node ); 1383 1384 VISIT({ 1385 guard_indexer guard { *this }; 1386 maybe_accept( node, &UntypedTupleExpr::result ); 1387 } 1388 maybe_accept( node, &UntypedTupleExpr::exprs ); 1389 ) 1390 1391 VISIT_END( Expr, node ); 1392 } 1393 1394 //-------------------------------------------------------------------------- 1395 // TupleExpr 1396 template< typename pass_t > 1397 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleExpr * node ) { 1398 VISIT_START( node ); 1399 1400 VISIT({ 1401 guard_indexer guard { *this }; 1402 maybe_accept( node, &TupleExpr::result ); 1403 } 1404 maybe_accept( node, &TupleExpr::exprs ); 1405 ) 1406 1407 VISIT_END( Expr, node ); 1408 } 1409 1410 //-------------------------------------------------------------------------- 1411 // TupleIndexExpr 1412 template< typename pass_t > 1413 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleIndexExpr * node ) { 1414 VISIT_START( node ); 1415 1416 VISIT({ 1417 guard_indexer guard { *this }; 1418 maybe_accept( node, &TupleIndexExpr::result ); 1419 } 1420 maybe_accept( node, &TupleIndexExpr::tuple ); 1421 ) 1422 1423 VISIT_END( Expr, node ); 1424 } 1425 1426 //-------------------------------------------------------------------------- 1427 // TupleAssignExpr 1428 template< typename pass_t > 1429 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleAssignExpr * node ) { 1430 VISIT_START( node ); 1431 1432 VISIT({ 1433 guard_indexer guard { *this }; 1434 maybe_accept( node, &TupleAssignExpr::result ); 1435 } 1436 maybe_accept( node, &TupleAssignExpr::stmtExpr ); 1437 ) 1438 1439 VISIT_END( Expr, node ); 1440 } 1441 1442 //-------------------------------------------------------------------------- 1443 // StmtExpr 1444 template< typename pass_t > 1445 const ast::Expr * ast::Pass< pass_t >::visit( const ast::StmtExpr * node ) { 1446 VISIT_START( node ); 1447 1448 VISIT(// don't want statements from outer CompoundStmts to be added to this StmtExpr 1449 // get the stmts that will need to be spliced in 1450 auto stmts_before = __pass::stmtsToAddBefore( pass, 0); 1451 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0); 1452 1453 // These may be modified by subnode but most be restored once we exit this statemnet. 1454 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::env( pass, 0) ); 1455 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 1456 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); 1457 1458 { 1459 guard_indexer guard { *this }; 1460 maybe_accept( node, &StmtExpr::result ); 1461 } 1462 maybe_accept( node, &StmtExpr::stmts ); 1463 maybe_accept( node, &StmtExpr::returnDecls ); 1464 maybe_accept( node, &StmtExpr::dtors ); 1465 ) 1466 1467 VISIT_END( Expr, node ); 1468 } 1469 1470 //-------------------------------------------------------------------------- 1471 // UniqueExpr 1472 template< typename pass_t > 1473 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UniqueExpr * node ) { 1474 VISIT_START( node ); 1475 1476 VISIT({ 1477 guard_indexer guard { *this }; 1478 maybe_accept( node, &UniqueExpr::result ); 1479 } 1480 maybe_accept( node, &UniqueExpr::expr ); 1481 ) 1482 1483 VISIT_END( Expr, node ); 1484 } 1485 1486 //-------------------------------------------------------------------------- 1487 // UntypedInitExpr 1488 template< typename pass_t > 1489 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedInitExpr * node ) { 1490 VISIT_START( node ); 1491 1492 VISIT({ 1493 guard_indexer guard { *this }; 1494 maybe_accept( node, &UntypedInitExpr::result ); 1495 } 1496 maybe_accept( node, &UntypedInitExpr::expr ); 1497 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. 1498 ) 1499 1500 VISIT_END( Expr, node ); 1501 } 1502 1503 //-------------------------------------------------------------------------- 1504 // InitExpr 1505 template< typename pass_t > 1506 const ast::Expr * ast::Pass< pass_t >::visit( const ast::InitExpr * node ) { 1507 VISIT_START( node ); 1508 1509 VISIT({ 1510 guard_indexer guard { *this }; 1511 maybe_accept( node, &InitExpr::result ); 1512 } 1513 maybe_accept( node, &InitExpr::expr ); 1514 maybe_accept( node, &InitExpr::designation ); 1515 ) 1516 1517 VISIT_END( Expr, node ); 1518 } 1519 1520 //-------------------------------------------------------------------------- 1521 // DeletedExpr 1522 template< typename pass_t > 1523 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DeletedExpr * node ) { 1524 VISIT_START( node ); 1525 1526 VISIT({ 1527 guard_indexer guard { *this }; 1528 maybe_accept( node, &DeletedExpr::result ); 1529 } 1530 maybe_accept( node, &DeletedExpr::expr ); 1531 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. 1532 ) 1533 1534 VISIT_END( Expr, node ); 1535 } 1536 1537 //-------------------------------------------------------------------------- 1538 // DefaultArgExpr 1539 template< typename pass_t > 1540 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DefaultArgExpr * node ) { 1541 VISIT_START( node ); 1542 1543 VISIT({ 1544 guard_indexer guard { *this }; 1545 maybe_accept( node, &DefaultArgExpr::result ); 1546 } 1547 maybe_accept( node, &DefaultArgExpr::expr ); 1548 ) 1549 1550 VISIT_END( Expr, node ); 1551 } 1552 1553 //-------------------------------------------------------------------------- 1554 // GenericExpr 1555 template< typename pass_t > 1556 const ast::Expr * ast::Pass< pass_t >::visit( const ast::GenericExpr * node ) { 1557 VISIT_START( node ); 1558 1559 VISIT({ 1560 guard_indexer guard { *this }; 1561 maybe_accept( node, &GenericExpr::result ); 1562 } 1563 maybe_accept( node, &GenericExpr::control ); 1564 1565 std::vector<GenericExpr::Association> new_kids; 1566 new_kids.reserve(node->associations.size()); 1567 bool mutated = false; 1568 for( const auto & assoc : node->associations ) { 1569 Type * type = nullptr; 1570 if( assoc.type ) { 1571 guard_indexer guard { *this }; 1572 type = assoc.type->accept( *this ); 1573 if( type != assoc.type ) mutated = true; 1574 } 1575 Expr * expr = nullptr; 1576 if( assoc.expr ) { 1577 expr = assoc.expr->accept( *this ); 1578 if( expr != assoc.expr ) mutated = true; 1579 } 1580 new_kids.emplace_back( type, expr ); 1581 } 1582 1583 if(mutated) { 1584 auto n = mutate(node); 1585 n->associations = std::move( new_kids ); 1586 node = n; 1587 } 1588 ) 1589 1590 VISIT_END( Expr, node ); 1591 } 1592 1593 //-------------------------------------------------------------------------- 1594 // VoidType 1595 template< typename pass_t > 1596 const ast::Type * ast::Pass< pass_t >::visit( const ast::VoidType * node ) { 1597 VISIT_START( node ); 1598 1599 VISIT_END( Type, node ); 1600 } 1601 1602 //-------------------------------------------------------------------------- 1603 // BasicType 1604 template< typename pass_t > 1605 const ast::Type * ast::Pass< pass_t >::visit( const ast::BasicType * node ) { 1606 VISIT_START( node ); 1607 1608 VISIT_END( Type, node ); 1609 } 1610 1611 //-------------------------------------------------------------------------- 1612 // PointerType 1613 template< typename pass_t > 1614 const ast::Type * ast::Pass< pass_t >::visit( const ast::PointerType * node ) { 1615 VISIT_START( node ); 1616 1617 VISIT( 1618 // xxx - should PointerType visit/mutate dimension? 1619 maybe_accept( node, &PointerType::base ); 1620 ) 1621 1622 VISIT_END( Type, node ); 1623 } 1624 1625 //-------------------------------------------------------------------------- 1626 // ArrayType 1627 template< typename pass_t > 1628 const ast::Type * ast::Pass< pass_t >::visit( const ast::ArrayType * node ) { 1629 VISIT_START( node ); 1630 1631 VISIT( 1632 maybe_accept( node, &ArrayType::dimension ); 1633 maybe_accept( node, &ArrayType::base ); 1634 ) 1635 1636 VISIT_END( Type, node ); 1637 } 1638 1639 //-------------------------------------------------------------------------- 1640 // ReferenceType 1641 template< typename pass_t > 1642 const ast::Type * ast::Pass< pass_t >::visit( const ast::ReferenceType * node ) { 1643 VISIT_START( node ); 1644 1645 VISIT( 1646 maybe_accept( node, &ReferenceType::base ); 1647 ) 1648 1649 VISIT_END( Type, node ); 1650 } 1651 1652 //-------------------------------------------------------------------------- 1653 // QualifiedType 1654 template< typename pass_t > 1655 const ast::Type * ast::Pass< pass_t >::visit( const ast::QualifiedType * node ) { 1656 VISIT_START( node ); 1657 1658 VISIT( 1659 maybe_accept( node, &QualifiedType::parent ); 1660 maybe_accept( node, &QualifiedType::child ); 1661 ) 1662 1663 VISIT_END( Type, node ); 1664 } 1665 1666 //-------------------------------------------------------------------------- 1667 // FunctionType 1668 template< typename pass_t > 1669 const ast::Type * ast::Pass< pass_t >::visit( const ast::FunctionType * node ) { 1670 VISIT_START( node ); 1671 1672 VISIT( 1673 maybe_accept( node, &FunctionType::forall ); 1674 maybe_accept( node, &FunctionType::returns ); 1675 maybe_accept( node, &FunctionType::params ); 1676 ) 1677 1678 VISIT_END( Type, node ); 1679 } 1680 1681 //-------------------------------------------------------------------------- 1682 // StructInstType 1683 template< typename pass_t > 1684 const ast::Type * ast::Pass< pass_t >::visit( const ast::StructInstType * node ) { 1685 VISIT_START( node ); 1686 1687 __pass::indexer::addStruct( node->name, 0, pass ); 1688 1689 VISIT({ 1690 guard_indexer guard { *this }; 1691 maybe_accept( node, &StructInstType::forall ); 1692 maybe_accept( node, &StructInstType::params ); 1693 }) 1694 1695 VISIT_END( Type, node ); 1696 } 1697 1698 //-------------------------------------------------------------------------- 1699 // UnionInstType 1700 template< typename pass_t > 1701 const ast::Type * ast::Pass< pass_t >::visit( const ast::UnionInstType * node ) { 1702 VISIT_START( node ); 1703 1704 __pass::indexer::addStruct( node->name, 0, pass ); 1705 1706 { 1707 guard_indexer guard { *this }; 1708 maybe_accept( node, &UnionInstType::forall ); 1709 maybe_accept( node, &UnionInstType::params ); 1710 } 1711 1712 VISIT_END( Type, node ); 1713 } 1714 1715 //-------------------------------------------------------------------------- 1716 // EnumInstType 1717 template< typename pass_t > 1718 const ast::Type * ast::Pass< pass_t >::visit( const ast::EnumInstType * node ) { 1719 VISIT_START( node ); 1720 1721 VISIT( 1722 maybe_accept( node, &EnumInstType::forall ); 1723 maybe_accept( node, &EnumInstType::params ); 1724 ) 1725 1726 VISIT_END( Type, node ); 1727 } 1728 1729 //-------------------------------------------------------------------------- 1730 // TraitInstType 1731 template< typename pass_t > 1732 const ast::Type * ast::Pass< pass_t >::visit( const ast::TraitInstType * node ) { 1733 VISIT_START( node ); 1734 1735 VISIT( 1736 maybe_accept( node, &TraitInstType::forall ); 1737 maybe_accept( node, &TraitInstType::params ); 1738 ) 1739 1740 VISIT_END( Type, node ); 1741 } 1742 1743 //-------------------------------------------------------------------------- 1744 // TypeInstType 1745 template< typename pass_t > 1746 const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeInstType * node ) { 1747 VISIT_START( node ); 1748 1749 VISIT( 1750 maybe_accept( node, &TypeInstType::forall ); 1751 maybe_accept( node, &TypeInstType::params ); 1752 ) 1753 1754 VISIT_END( Type, node ); 1755 } 1756 1757 //-------------------------------------------------------------------------- 1758 // TupleType 1759 template< typename pass_t > 1760 const ast::Type * ast::Pass< pass_t >::visit( const ast::TupleType * node ) { 1761 VISIT_START( node ); 1762 1763 VISIT( 1764 maybe_accept( node, &TupleType::types ); 1765 maybe_accept( node, &TupleType::members ); 1766 ) 1767 1768 VISIT_END( Type, node ); 1769 } 1770 1771 //-------------------------------------------------------------------------- 1772 // TypeofType 1773 template< typename pass_t > 1774 const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeofType * node ) { 1775 VISIT_START( node ); 1776 1777 VISIT( 1778 maybe_accept( node, &TypeofType::expr ); 1779 ) 1780 1781 VISIT_END( Type, node ); 1782 } 1783 1784 //-------------------------------------------------------------------------- 1785 // VarArgsType 1786 template< typename pass_t > 1787 const ast::Type * ast::Pass< pass_t >::visit( const ast::VarArgsType * node ) { 1788 VISIT_START( node ); 1789 1790 VISIT_END( Type, node ); 1791 } 1792 1793 //-------------------------------------------------------------------------- 1794 // ZeroType 1795 template< typename pass_t > 1796 const ast::Type * ast::Pass< pass_t >::visit( const ast::ZeroType * node ) { 1797 VISIT_START( node ); 1798 1799 VISIT_END( Type, node ); 1800 } 1801 1802 //-------------------------------------------------------------------------- 1803 // OneType 1804 template< typename pass_t > 1805 const ast::Type * ast::Pass< pass_t >::visit( const ast::OneType * node ) { 1806 VISIT_START( node ); 1807 1808 VISIT_END( Type, node ); 1809 } 1810 1811 //-------------------------------------------------------------------------- 1812 // GlobalScopeType 1813 template< typename pass_t > 1814 const ast::Type * ast::Pass< pass_t >::visit( const ast::GlobalScopeType * node ) { 1815 VISIT_START( node ); 1816 1817 VISIT_END( Type, node ); 1818 } 1819 1820 1821 //-------------------------------------------------------------------------- 1822 // Designation 1823 template< typename pass_t > 1824 const ast::Designation * ast::Pass< pass_t >::visit( const ast::Designation * node ) { 1825 VISIT_START( node ); 1826 1827 VISIT( maybe_accept( node, &Designation::designators ); ) 1828 1829 VISIT_END( Designation, node ); 1830 } 916 1831 917 1832 //-------------------------------------------------------------------------- … … 970 1885 } 971 1886 972 // --------------------------------------------------------------------------973 // TypeSubstitution974 template< typename pass_t >975 const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) {976 VISIT_START( node );977 978 VISIT(979 {980 bool mutated = false;981 std::unordered_map< std::string, ast::ptr< ast::Type > > new_map;982 for ( const auto & p : node->typeEnv ) {983 guard_indexer guard { *this };984 auto new_node = p.second->accept( *this );985 if (new_node != p.second) mutated = false;986 new_map.insert({ p.first, new_node });987 }988 if (mutated) {989 auto new_node = mutate( node );990 new_node->typeEnv.swap( new_map );991 node = new_node;992 }993 }994 995 {996 bool mutated = false;997 std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map;998 for ( const auto & p : node->varEnv ) {999 guard_indexer guard { *this };1000 auto new_node = p.second->accept( *this );1001 if (new_node != p.second) mutated = false;1002 new_map.insert({ p.first, new_node });1003 }1004 if (mutated) {1005 auto new_node = mutate( node );1006 new_node->varEnv.swap( new_map );1007 node = new_node;1008 }1009 }1010 )1011 1012 VISIT_END( TypeSubstitution, node );1013 }1887 // //-------------------------------------------------------------------------- 1888 // // TypeSubstitution 1889 // template< typename pass_t > 1890 // const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) { 1891 // VISIT_START( node ); 1892 1893 // VISIT( 1894 // { 1895 // bool mutated = false; 1896 // std::unordered_map< std::string, ast::ptr< ast::Type > > new_map; 1897 // for ( const auto & p : node->typeEnv ) { 1898 // guard_indexer guard { *this }; 1899 // auto new_node = p.second->accept( *this ); 1900 // if (new_node != p.second) mutated = false; 1901 // new_map.insert({ p.first, new_node }); 1902 // } 1903 // if (mutated) { 1904 // auto new_node = mutate( node ); 1905 // new_node->typeEnv.swap( new_map ); 1906 // node = new_node; 1907 // } 1908 // } 1909 1910 // { 1911 // bool mutated = false; 1912 // std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map; 1913 // for ( const auto & p : node->varEnv ) { 1914 // guard_indexer guard { *this }; 1915 // auto new_node = p.second->accept( *this ); 1916 // if (new_node != p.second) mutated = false; 1917 // new_map.insert({ p.first, new_node }); 1918 // } 1919 // if (mutated) { 1920 // auto new_node = mutate( node ); 1921 // new_node->varEnv.swap( new_map ); 1922 // node = new_node; 1923 // } 1924 // } 1925 // ) 1926 1927 // VISIT_END( TypeSubstitution, node ); 1928 // } 1014 1929 1015 1930 #undef VISIT_START -
src/AST/Stmt.hpp
rd148778 ra83044fb 330 330 public: 331 331 struct Target { 332 ptr<Expr> func tion;333 std::vector<ptr<Expr>> arg uments;332 ptr<Expr> func; 333 std::vector<ptr<Expr>> args; 334 334 }; 335 335 -
src/AST/module.mk
rd148778 ra83044fb 1 ######################### -*- Mode: Makefile-Gmake -*- 2 ######################## 1 ######################### -*- Mode: Makefile-Gmake -*- ######################## 3 2 ## 4 3 ## Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo … … 17 16 18 17 SRC_AST = \ 19 AST/Convert.cpp \ 20 AST/Node.cpp \ 21 AST/TypeSubstitution.cpp 18 AST/Attribute.cpp \ 19 AST/Convert.cpp \ 20 AST/Decl.cpp \ 21 AST/DeclReplacer.cpp \ 22 AST/Expr.cpp \ 23 AST/Init.cpp \ 24 AST/LinkageSpec.cpp \ 25 AST/Node.cpp \ 26 AST/Stmt.cpp \ 27 AST/Type.cpp \ 28 AST/TypeSubstitution.cpp 22 29 23 30 … … 25 32 SRC += $(SRC_AST) 26 33 SRCDEMANGLE += $(SRC_AST) 27 -
src/Common/Eval.cc
rd148778 ra83044fb 90 90 } 91 91 92 std::pair<long long int, bool> eval(const ast::Expr * expr) { 93 #warning not implemented 94 return { 0, false }; 95 } 96 92 97 // Local Variables: // 93 98 // tab-width: 4 // -
src/Makefile.am
rd148778 ra83044fb 37 37 endif 38 38 39 include AST/module.mk 39 40 include CodeGen/module.mk 40 41 include CodeTools/module.mk -
src/Makefile.in
rd148778 ra83044fb 16 16 17 17 ######################## -*- Mode: Makefile-Automake -*- ###################### 18 ############################################################################### 19 20 ######################### -*- Mode: Makefile-Gmake -*- ######################## 18 21 ############################################################################### 19 22 … … 162 165 libdemangle_a_LIBADD = 163 166 am__dirstamp = $(am__leading_dot)dirstamp 164 am__objects_1 = CodeGen/CodeGenerator.$(OBJEXT) \ 167 am__objects_1 = AST/Attribute.$(OBJEXT) AST/Convert.$(OBJEXT) \ 168 AST/Decl.$(OBJEXT) AST/DeclReplacer.$(OBJEXT) \ 169 AST/Expr.$(OBJEXT) AST/Init.$(OBJEXT) \ 170 AST/LinkageSpec.$(OBJEXT) AST/Node.$(OBJEXT) \ 171 AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \ 172 AST/TypeSubstitution.$(OBJEXT) 173 am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \ 165 174 CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \ 166 175 CodeGen/OperatorTable.$(OBJEXT) 167 am__objects_ 2= Common/Assert.$(OBJEXT) Common/Eval.$(OBJEXT) \176 am__objects_3 = Common/Assert.$(OBJEXT) Common/Eval.$(OBJEXT) \ 168 177 Common/PassVisitor.$(OBJEXT) Common/SemanticError.$(OBJEXT) \ 169 178 Common/Stats/Counter.$(OBJEXT) Common/Stats/Heap.$(OBJEXT) \ 170 179 Common/Stats/Stats.$(OBJEXT) Common/Stats/Time.$(OBJEXT) \ 171 180 Common/UniqueName.$(OBJEXT) 172 am__objects_ 3= ControlStruct/ForExprMutator.$(OBJEXT) \181 am__objects_4 = ControlStruct/ForExprMutator.$(OBJEXT) \ 173 182 ControlStruct/LabelFixer.$(OBJEXT) \ 174 183 ControlStruct/LabelGenerator.$(OBJEXT) \ 175 184 ControlStruct/MLEMutator.$(OBJEXT) \ 176 185 ControlStruct/Mutate.$(OBJEXT) 177 am__objects_ 4= ResolvExpr/AdjustExprType.$(OBJEXT) \186 am__objects_5 = ResolvExpr/AdjustExprType.$(OBJEXT) \ 178 187 ResolvExpr/Alternative.$(OBJEXT) \ 179 188 ResolvExpr/AlternativeFinder.$(OBJEXT) \ … … 193 202 ResolvExpr/TypeEnvironment.$(OBJEXT) \ 194 203 ResolvExpr/Unify.$(OBJEXT) 195 am__objects_ 5= SymTab/Autogen.$(OBJEXT) SymTab/FixFunction.$(OBJEXT) \204 am__objects_6 = SymTab/Autogen.$(OBJEXT) SymTab/FixFunction.$(OBJEXT) \ 196 205 SymTab/Indexer.$(OBJEXT) SymTab/Mangler.$(OBJEXT) \ 197 206 SymTab/ManglerCommon.$(OBJEXT) SymTab/Validate.$(OBJEXT) 198 am__objects_ 6= SynTree/Type.$(OBJEXT) SynTree/VoidType.$(OBJEXT) \207 am__objects_7 = SynTree/Type.$(OBJEXT) SynTree/VoidType.$(OBJEXT) \ 199 208 SynTree/BasicType.$(OBJEXT) SynTree/PointerType.$(OBJEXT) \ 200 209 SynTree/ArrayType.$(OBJEXT) SynTree/ReferenceType.$(OBJEXT) \ … … 216 225 SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \ 217 226 SynTree/DeclReplacer.$(OBJEXT) 218 am__objects_ 7= CompilationState.$(OBJEXT) $(am__objects_1) \219 Concurrency/Keywords.$(OBJEXT) $(am__objects_2) \220 $(am__objects_3) GenPoly/GenPoly.$(OBJEXT) \227 am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \ 228 $(am__objects_2) Concurrency/Keywords.$(OBJEXT) \ 229 $(am__objects_3) $(am__objects_4) GenPoly/GenPoly.$(OBJEXT) \ 221 230 GenPoly/Lvalue.$(OBJEXT) InitTweak/GenInit.$(OBJEXT) \ 222 231 InitTweak/InitTweak.$(OBJEXT) Parser/LinkageSpec.$(OBJEXT) \ 223 $(am__objects_ 4) $(am__objects_5) SymTab/Demangle.$(OBJEXT) \224 $(am__objects_ 6) Tuples/TupleAssignment.$(OBJEXT) \232 $(am__objects_5) $(am__objects_6) SymTab/Demangle.$(OBJEXT) \ 233 $(am__objects_7) Tuples/TupleAssignment.$(OBJEXT) \ 225 234 Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \ 226 235 Validate/HandleAttributes.$(OBJEXT) 227 am_libdemangle_a_OBJECTS = $(am__objects_ 7)236 am_libdemangle_a_OBJECTS = $(am__objects_8) 228 237 libdemangle_a_OBJECTS = $(am_libdemangle_a_OBJECTS) 229 238 am__installdirs = "$(DESTDIR)$(cfa_cpplibdir)" 230 239 PROGRAMS = $(cfa_cpplib_PROGRAMS) 231 am__objects_ 8= main.$(OBJEXT) MakeLibCfa.$(OBJEXT) \232 CompilationState.$(OBJEXT) $(am__objects_1) \240 am__objects_9 = main.$(OBJEXT) MakeLibCfa.$(OBJEXT) \ 241 CompilationState.$(OBJEXT) $(am__objects_1) $(am__objects_2) \ 233 242 CodeGen/Generate.$(OBJEXT) CodeGen/FixNames.$(OBJEXT) \ 234 243 CodeTools/DeclStats.$(OBJEXT) \ 235 244 CodeTools/ResolvProtoDump.$(OBJEXT) \ 236 245 CodeTools/TrackLoc.$(OBJEXT) Concurrency/Keywords.$(OBJEXT) \ 237 Concurrency/Waitfor.$(OBJEXT) $(am__objects_ 2) \238 Common/DebugMalloc.$(OBJEXT) $(am__objects_ 3) \246 Concurrency/Waitfor.$(OBJEXT) $(am__objects_3) \ 247 Common/DebugMalloc.$(OBJEXT) $(am__objects_4) \ 239 248 ControlStruct/ExceptTranslate.$(OBJEXT) GenPoly/Box.$(OBJEXT) \ 240 249 GenPoly/GenPoly.$(OBJEXT) GenPoly/ScrubTyVars.$(OBJEXT) \ … … 250 259 Parser/InitializerNode.$(OBJEXT) Parser/TypeData.$(OBJEXT) \ 251 260 Parser/LinkageSpec.$(OBJEXT) Parser/parserutility.$(OBJEXT) \ 252 $(am__objects_ 4) ResolvExpr/AlternativePrinter.$(OBJEXT) \253 $(am__objects_ 5) $(am__objects_6) \261 $(am__objects_5) ResolvExpr/AlternativePrinter.$(OBJEXT) \ 262 $(am__objects_6) $(am__objects_7) \ 254 263 Tuples/TupleAssignment.$(OBJEXT) \ 255 264 Tuples/TupleExpansion.$(OBJEXT) Tuples/Explode.$(OBJEXT) \ 256 265 Validate/HandleAttributes.$(OBJEXT) \ 257 266 Virtual/ExpandCasts.$(OBJEXT) 258 am____driver_cfa_cpp_OBJECTS = $(am__objects_ 8)267 am____driver_cfa_cpp_OBJECTS = $(am__objects_9) 259 268 ___driver_cfa_cpp_OBJECTS = $(am____driver_cfa_cpp_OBJECTS) 260 269 am__DEPENDENCIES_1 = … … 366 375 ETAGS = etags 367 376 CTAGS = ctags 368 am__DIST_COMMON = $(srcdir)/ CodeGen/module.mk \377 am__DIST_COMMON = $(srcdir)/AST/module.mk $(srcdir)/CodeGen/module.mk \ 369 378 $(srcdir)/CodeTools/module.mk $(srcdir)/Common/module.mk \ 370 379 $(srcdir)/Concurrency/module.mk \ … … 526 535 AUTOMAKE_OPTIONS = foreign subdir-objects 527 536 ACLOCAL_AMFLAGS = -I automake 528 SRC = main.cc MakeLibCfa.cc CompilationState.cc $(SRC_ CODEGEN) \529 CodeGen/Generate.cc CodeGen/FixNames.cc CodeTools/DeclStats.cc \530 CodeTools/ ResolvProtoDump.cc CodeTools/TrackLoc.cc \531 Co ncurrency/Keywords.cc Concurrency/Waitfor.cc $(SRC_COMMON)\532 Co mmon/DebugMalloc.cc $(SRC_CONTROLSTRUCT)\533 ControlStruct/ExceptTranslate.cc GenPoly/Box.cc \534 GenPoly/ GenPoly.cc GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc \535 GenPoly/ Specialize.cc GenPoly/FindFunction.cc \536 GenPoly/ InstantiateGeneric.cc InitTweak/GenInit.cc \537 InitTweak/ FixInit.cc InitTweak/FixGlobalInit.cc \538 InitTweak/ InitTweak.cc Parser/parser.yy Parser/lex.ll\539 Parser/ TypedefTable.cc Parser/ParseNode.cc \540 Parser/ DeclarationNode.cc Parser/ExpressionNode.cc \541 Parser/ StatementNode.cc Parser/InitializerNode.cc \542 Parser/ TypeData.cc Parser/LinkageSpec.cc \543 Parser/ parserutility.cc $(SRC_RESOLVEXPR)\544 ResolvExpr/AlternativePrinter.cc $(SRC_SYMTAB) $(SRC_SYNTREE)\545 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \546 Tuples/ Explode.cc Validate/HandleAttributes.cc \547 V irtual/ExpandCasts.cc548 SRCDEMANGLE = CompilationState.cc $(SRC_ CODEGEN) \537 SRC = main.cc MakeLibCfa.cc CompilationState.cc $(SRC_AST) \ 538 $(SRC_CODEGEN) CodeGen/Generate.cc CodeGen/FixNames.cc \ 539 CodeTools/DeclStats.cc CodeTools/ResolvProtoDump.cc \ 540 CodeTools/TrackLoc.cc Concurrency/Keywords.cc \ 541 Concurrency/Waitfor.cc $(SRC_COMMON) Common/DebugMalloc.cc \ 542 $(SRC_CONTROLSTRUCT) ControlStruct/ExceptTranslate.cc \ 543 GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/ScrubTyVars.cc \ 544 GenPoly/Lvalue.cc GenPoly/Specialize.cc \ 545 GenPoly/FindFunction.cc GenPoly/InstantiateGeneric.cc \ 546 InitTweak/GenInit.cc InitTweak/FixInit.cc \ 547 InitTweak/FixGlobalInit.cc InitTweak/InitTweak.cc \ 548 Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \ 549 Parser/ParseNode.cc Parser/DeclarationNode.cc \ 550 Parser/ExpressionNode.cc Parser/StatementNode.cc \ 551 Parser/InitializerNode.cc Parser/TypeData.cc \ 552 Parser/LinkageSpec.cc Parser/parserutility.cc \ 553 $(SRC_RESOLVEXPR) ResolvExpr/AlternativePrinter.cc \ 554 $(SRC_SYMTAB) $(SRC_SYNTREE) Tuples/TupleAssignment.cc \ 555 Tuples/TupleExpansion.cc Tuples/Explode.cc \ 556 Validate/HandleAttributes.cc Virtual/ExpandCasts.cc 557 SRCDEMANGLE = CompilationState.cc $(SRC_AST) $(SRC_CODEGEN) \ 549 558 Concurrency/Keywords.cc $(SRC_COMMON) $(SRC_CONTROLSTRUCT) \ 550 559 GenPoly/GenPoly.cc GenPoly/Lvalue.cc InitTweak/GenInit.cc \ … … 559 568 @WITH_LIBTCMALLOC_TRUE@LIBTCMALLOC = -ltcmalloc 560 569 @WITH_LIBTCMALLOC_TRUE@TCMALLOCFLAG = -DTCMALLOC 570 SRC_AST = \ 571 AST/Attribute.cpp \ 572 AST/Convert.cpp \ 573 AST/Decl.cpp \ 574 AST/DeclReplacer.cpp \ 575 AST/Expr.cpp \ 576 AST/Init.cpp \ 577 AST/LinkageSpec.cpp \ 578 AST/Node.cpp \ 579 AST/Stmt.cpp \ 580 AST/Type.cpp \ 581 AST/TypeSubstitution.cpp 582 561 583 SRC_CODEGEN = \ 562 584 CodeGen/CodeGenerator.cc \ … … 667 689 668 690 .SUFFIXES: 669 .SUFFIXES: .cc . ll .lo .o .obj .yy670 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/ CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps)691 .SUFFIXES: .cc .cpp .ll .lo .o .obj .yy 692 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/AST/module.mk $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__configure_deps) 671 693 @for dep in $?; do \ 672 694 case '$(am__configure_deps)' in \ … … 688 710 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 689 711 esac; 690 $(srcdir)/ CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__empty):712 $(srcdir)/AST/module.mk $(srcdir)/CodeGen/module.mk $(srcdir)/CodeTools/module.mk $(srcdir)/Concurrency/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(srcdir)/Validate/module.mk $(srcdir)/Virtual/module.mk $(am__empty): 691 713 692 714 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) … … 701 723 clean-noinstLIBRARIES: 702 724 -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) 725 AST/$(am__dirstamp): 726 @$(MKDIR_P) AST 727 @: > AST/$(am__dirstamp) 728 AST/$(DEPDIR)/$(am__dirstamp): 729 @$(MKDIR_P) AST/$(DEPDIR) 730 @: > AST/$(DEPDIR)/$(am__dirstamp) 731 AST/Attribute.$(OBJEXT): AST/$(am__dirstamp) \ 732 AST/$(DEPDIR)/$(am__dirstamp) 733 AST/Convert.$(OBJEXT): AST/$(am__dirstamp) \ 734 AST/$(DEPDIR)/$(am__dirstamp) 735 AST/Decl.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 736 AST/DeclReplacer.$(OBJEXT): AST/$(am__dirstamp) \ 737 AST/$(DEPDIR)/$(am__dirstamp) 738 AST/Expr.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 739 AST/Init.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 740 AST/LinkageSpec.$(OBJEXT): AST/$(am__dirstamp) \ 741 AST/$(DEPDIR)/$(am__dirstamp) 742 AST/Node.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 743 AST/Stmt.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 744 AST/Type.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 745 AST/TypeSubstitution.$(OBJEXT): AST/$(am__dirstamp) \ 746 AST/$(DEPDIR)/$(am__dirstamp) 703 747 CodeGen/$(am__dirstamp): 704 748 @$(MKDIR_P) CodeGen … … 1097 1141 mostlyclean-compile: 1098 1142 -rm -f *.$(OBJEXT) 1143 -rm -f AST/*.$(OBJEXT) 1099 1144 -rm -f CodeGen/*.$(OBJEXT) 1100 1145 -rm -f CodeTools/*.$(OBJEXT) … … 1119 1164 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MakeLibCfa.Po@am__quote@ 1120 1165 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ 1166 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Attribute.Po@am__quote@ 1167 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Convert.Po@am__quote@ 1168 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Decl.Po@am__quote@ 1169 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/DeclReplacer.Po@am__quote@ 1170 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Expr.Po@am__quote@ 1171 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Init.Po@am__quote@ 1172 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@ 1173 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Node.Po@am__quote@ 1174 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Stmt.Po@am__quote@ 1175 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Type.Po@am__quote@ 1176 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/TypeSubstitution.Po@am__quote@ 1121 1177 @AMDEP_TRUE@@am__include@ @am__quote@CodeGen/$(DEPDIR)/CodeGenerator.Po@am__quote@ 1122 1178 @AMDEP_TRUE@@am__include@ @am__quote@CodeGen/$(DEPDIR)/FixMain.Po@am__quote@ … … 1261 1317 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< 1262 1318 1319 .cpp.o: 1320 @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ 1321 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ 1322 @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po 1323 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 1324 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1325 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< 1326 1327 .cpp.obj: 1328 @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ 1329 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ 1330 @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po 1331 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 1332 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1333 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 1334 1335 .cpp.lo: 1336 @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ 1337 @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ 1338 @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo 1339 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ 1340 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1341 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< 1342 1263 1343 .ll.cc: 1264 1344 $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) … … 1393 1473 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 1394 1474 -rm -f ../driver/$(am__dirstamp) 1475 -rm -f AST/$(DEPDIR)/$(am__dirstamp) 1476 -rm -f AST/$(am__dirstamp) 1395 1477 -rm -f CodeGen/$(DEPDIR)/$(am__dirstamp) 1396 1478 -rm -f CodeGen/$(am__dirstamp) … … 1438 1520 1439 1521 distclean: distclean-am 1440 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Common/Stats/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR)1522 -rm -rf ./$(DEPDIR) AST/$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Common/Stats/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR) 1441 1523 -rm -f Makefile 1442 1524 distclean-am: clean-am distclean-compile distclean-generic \ … … 1484 1566 1485 1567 maintainer-clean: maintainer-clean-am 1486 -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Common/Stats/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR)1568 -rm -rf ./$(DEPDIR) AST/$(DEPDIR) CodeGen/$(DEPDIR) CodeTools/$(DEPDIR) Common/$(DEPDIR) Common/Stats/$(DEPDIR) Concurrency/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR) Validate/$(DEPDIR) Virtual/$(DEPDIR) 1487 1569 -rm -f Makefile 1488 1570 maintainer-clean-am: distclean-am maintainer-clean-generic -
src/Tuples/TupleExpansion.cc
rd148778 ra83044fb 353 353 } 354 354 355 const ast::TypeInstType * isTtype( const ast::Type * type ) { 356 #warning unimplemented 357 return nullptr; 358 } 359 355 360 namespace { 356 361 /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure -
src/include/cassert
rd148778 ra83044fb 19 19 20 20 #include_next <cassert> 21 22 #include <string> 23 24 template < typename ... Params > 25 std::string toString( const Params & ... params ); 21 26 22 27 #ifdef NDEBUG -
src/main.cc
rd148778 ra83044fb 40 40 #include "Common/Stats.h" 41 41 #include "Common/PassVisitor.h" 42 // #include "AST/Pass.hpp"43 42 #include "Common/SemanticError.h" // for SemanticError 44 43 #include "Common/UnimplementedError.h" // for UnimplementedError
Note: See TracChangeset
for help on using the changeset viewer.