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