Changes in src/AST/Convert.cpp [4559b34:b230091]
- File:
-
- 1 edited
-
src/AST/Convert.cpp (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r4559b34 rb230091 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 13:19:22202213 // Update Count : 4 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Mar 16 15:01:00 2022 13 // Update Count : 42 14 14 // 15 15 … … 49 49 //================================================================================================ 50 50 namespace ast { 51 52 // This is to preserve the FindSpecialDecls hack. It does not (and perhaps should not) 53 // allow us to use the same stratagy in the new ast. 54 // xxx - since convert back pass works, this concern seems to be unnecessary. 55 56 // these need to be accessed in new FixInit now 57 ast::ptr<ast::Type> sizeType = nullptr; 58 const ast::FunctionDecl * dereferenceOperator = nullptr; 59 const ast::StructDecl * dtorStruct = nullptr; 60 const ast::FunctionDecl * dtorStructDestroy = nullptr; 51 // These are the shared local information used by ConverterNewToOld and 52 // ConverterOldToNew to update the global information in the two versions. 53 54 static ast::ptr<ast::Type> sizeType = nullptr; 55 static const ast::FunctionDecl * dereferenceOperator = nullptr; 56 static const ast::StructDecl * dtorStruct = nullptr; 57 static const ast::FunctionDecl * dtorStructDestroy = nullptr; 61 58 62 59 } … … 276 273 decl->parent = get<AggregateDecl>().accept1( node->parent ); 277 274 declPostamble( decl, node ); 278 return nullptr; // ??275 return nullptr; 279 276 } 280 277 … … 310 307 node->name, 311 308 get<Attribute>().acceptL( node->attributes ), 312 LinkageSpec::Spec( node->linkage.val ), 313 get<Type>().accept1(node->base) 314 ); 315 return aggregatePostamble( decl, node ); // Node info, including members, processed in aggregatePostamble 309 LinkageSpec::Spec( node->linkage.val ) 310 ); 311 return aggregatePostamble( decl, node ); 316 312 } 317 313 … … 355 351 this->node = stmt; 356 352 return nullptr; 353 } 354 355 void clausePostamble( Statement * stmt, const ast::StmtClause * node ) { 356 stmt->location = node->location; 357 this->node = stmt; 357 358 } 358 359 … … 405 406 auto stmt = new SwitchStmt( 406 407 get<Expression>().accept1( node->cond ), 407 get<Statement>().acceptL( node-> stmts )408 get<Statement>().acceptL( node->cases ) 408 409 ); 409 410 return stmtPostamble( stmt, node ); 410 411 } 411 412 412 const ast:: Stmt * visit( const ast::CaseStmt* node ) override final {413 const ast::CaseClause * visit( const ast::CaseClause * node ) override final { 413 414 if ( inCache( node ) ) return nullptr; 414 415 auto stmt = new CaseStmt( … … 417 418 node->isDefault() 418 419 ); 419 return stmtPostamble( stmt, node ); 420 clausePostamble( stmt, node ); 421 return nullptr; 420 422 } 421 423 … … 513 515 } 514 516 515 const ast:: Stmt * visit( const ast::CatchStmt* node ) override final {517 const ast::CatchClause * visit( const ast::CatchClause * node ) override final { 516 518 if ( inCache( node ) ) return nullptr; 517 519 CatchStmt::Kind kind; … … 524 526 break; 525 527 default: 526 assertf(false, "Invalid ast:: CatchStmt::Kind: %d\n", node->kind);528 assertf(false, "Invalid ast::ExceptionKind: %d\n", node->kind); 527 529 } 528 530 auto stmt = new CatchStmt( … … 532 534 get<Statement>().accept1( node->body ) 533 535 ); 534 return stmtPostamble( stmt, node );535 } 536 537 const ast:: Stmt * visit( const ast::FinallyStmt* node ) override final {536 return clausePostamble( stmt, node ), nullptr; 537 } 538 539 const ast::FinallyClause * visit( const ast::FinallyClause * node ) override final { 538 540 if ( inCache( node ) ) return nullptr; 539 541 auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) ); 540 return stmtPostamble( stmt, node );542 return clausePostamble( stmt, node ), nullptr; 541 543 } 542 544 … … 1468 1470 return strict_dynamic_cast< ast::Decl * >( node ); 1469 1471 } 1470 1472 1471 1473 ConverterOldToNew() = default; 1472 1474 ConverterOldToNew(const ConverterOldToNew &) = delete; … … 1496 1498 getAccept1< ast::type, decltype( old->child ) >( old->child ) 1497 1499 1498 1499 1500 template<typename NewT, typename OldC> 1500 1501 std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) { … … 1511 1512 # define GET_ACCEPT_V(child, type) \ 1512 1513 getAcceptV< ast::type, decltype( old->child ) >( old->child ) 1513 1514 # define GET_ACCEPT_E(child, type) \1515 getAccept1< ast::type, decltype( old->base ) >( old->base )1516 1514 1517 1515 template<typename NewT, typename OldC> … … 1715 1713 } 1716 1714 1717 // Convert SynTree::EnumDecl to AST::EnumDecl1718 1715 virtual void visit( const EnumDecl * old ) override final { 1719 1716 if ( inCache( old ) ) return; … … 1722 1719 old->name, 1723 1720 GET_ACCEPT_V(attributes, Attribute), 1724 { old->linkage.val }, 1725 GET_ACCEPT_1(base, Type), 1726 old->enumValues 1721 { old->linkage.val } 1727 1722 ); 1728 1723 cache.emplace( old, decl ); … … 1734 1729 decl->uniqueId = old->uniqueId; 1735 1730 decl->storage = { old->storageClasses.val }; 1731 1736 1732 this->node = decl; 1737 1733 } … … 1894 1890 old->location, 1895 1891 GET_ACCEPT_1(condition, Expr), 1896 GET_ACCEPT_V(statements, Stmt),1892 GET_ACCEPT_V(statements, CaseClause), 1897 1893 GET_LABELS_V(old->labels) 1898 1894 ); … … 1902 1898 virtual void visit( const CaseStmt * old ) override final { 1903 1899 if ( inCache( old ) ) return; 1904 this->node = new ast::Case Stmt(1900 this->node = new ast::CaseClause( 1905 1901 old->location, 1906 1902 GET_ACCEPT_1(condition, Expr), 1907 GET_ACCEPT_V(stmts, Stmt), 1908 GET_LABELS_V(old->labels) 1909 ); 1903 GET_ACCEPT_V(stmts, Stmt) 1904 ); 1905 auto labels = GET_LABELS_V(old->labels); 1906 assertf(labels.empty(), "Labels found on CaseStmt."); 1910 1907 cache.emplace( old, this->node ); 1911 1908 } … … 2015 2012 old->location, 2016 2013 GET_ACCEPT_1(block, CompoundStmt), 2017 GET_ACCEPT_V(handlers, Catch Stmt),2018 GET_ACCEPT_1(finallyBlock, Finally Stmt),2014 GET_ACCEPT_V(handlers, CatchClause), 2015 GET_ACCEPT_1(finallyBlock, FinallyClause), 2019 2016 GET_LABELS_V(old->labels) 2020 2017 ); … … 2036 2033 } 2037 2034 2038 this->node = new ast::Catch Stmt(2035 this->node = new ast::CatchClause( 2039 2036 old->location, 2040 2037 kind, 2041 2038 GET_ACCEPT_1(decl, Decl), 2042 2039 GET_ACCEPT_1(cond, Expr), 2043 GET_ACCEPT_1(body, Stmt), 2044 GET_LABELS_V(old->labels) 2045 ); 2040 GET_ACCEPT_1(body, Stmt) 2041 ); 2042 auto labels = GET_LABELS_V(old->labels); 2043 assertf(labels.empty(), "Labels found on CatchStmt."); 2046 2044 cache.emplace( old, this->node ); 2047 2045 } … … 2049 2047 virtual void visit( const FinallyStmt * old ) override final { 2050 2048 if ( inCache( old ) ) return; 2051 this->node = new ast::FinallyStmt( 2052 old->location, 2053 GET_ACCEPT_1(block, CompoundStmt), 2054 GET_LABELS_V(old->labels) 2055 ); 2049 this->node = new ast::FinallyClause( 2050 old->location, 2051 GET_ACCEPT_1(block, CompoundStmt) 2052 ); 2053 auto labels = GET_LABELS_V(old->labels); 2054 assertf(labels.empty(), "Labels found on FinallyStmt."); 2056 2055 cache.emplace( old, this->node ); 2057 2056 } … … 2718 2717 2719 2718 for (auto & param : foralls) { 2720 ty->forall.emplace_back(new ast::TypeInstType(param ->name, param));2719 ty->forall.emplace_back(new ast::TypeInstType(param)); 2721 2720 for (auto asst : param->assertions) { 2722 2721 ty->assertions.emplace_back(new ast::VariableExpr({}, asst)); … … 2768 2767 } 2769 2768 2770 virtual void visit( const EnumInstType * old ) override final { // Here is visiting the EnumInst Decl not the usage.2771 ast::EnumInstType * ty; 2769 virtual void visit( const EnumInstType * old ) override final { 2770 ast::EnumInstType * ty; 2772 2771 if ( old->baseEnum ) { 2773 ty = new ast::EnumInstType{ // Probably here: missing the specification of the base2772 ty = new ast::EnumInstType{ 2774 2773 GET_ACCEPT_1( baseEnum, EnumDecl ), 2775 2774 cv( old ),
Note:
See TracChangeset
for help on using the changeset viewer.