- Timestamp:
- May 22, 2019, 1:35:55 PM (6 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:
- 37eef7a
- Parents:
- 15934a6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r15934a6 r4073b16 265 265 stmt->location = node->location; 266 266 stmt->labels = makeLabelL( stmt, node->labels ); 267 cache.emplace( node, stmt ); 267 268 this->node = stmt; 268 269 return nullptr; … … 270 271 271 272 const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final { 273 if ( inCache( node ) ) return nullptr; 272 274 auto stmt = new CompoundStmt( get<Statement>().acceptL( node->kids ) ); 273 275 stmtPostamble( stmt, node ); … … 276 278 277 279 const ast::Stmt * visit( const ast::ExprStmt * node ) override final { 280 if ( inCache( node ) ) return nullptr; 278 281 auto stmt = new ExprStmt( get<Expression>().accept1( node->expr ) ); 279 282 return stmtPostamble( stmt, node ); … … 281 284 282 285 const ast::Stmt * visit( const ast::AsmStmt * node ) override final { 286 if ( inCache( node ) ) return nullptr; 283 287 auto stmt = new AsmStmt( 284 288 node->isVolatile, … … 293 297 294 298 const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final { 299 if ( inCache( node ) ) return nullptr; 295 300 auto stmt = new DirectiveStmt( node->directive ); 296 301 return stmtPostamble( stmt, node ); … … 298 303 299 304 const ast::Stmt * visit( const ast::IfStmt * node ) override final { 305 if ( inCache( node ) ) return nullptr; 300 306 auto stmt = new IfStmt( 301 307 get<Expression>().accept1( node->cond ), … … 308 314 309 315 const ast::Stmt * visit( const ast::SwitchStmt * node ) override final { 316 if ( inCache( node ) ) return nullptr; 310 317 auto stmt = new SwitchStmt( 311 318 get<Expression>().accept1( node->cond ), … … 316 323 317 324 const ast::Stmt * visit( const ast::CaseStmt * node ) override final { 325 if ( inCache( node ) ) return nullptr; 318 326 auto stmt = new CaseStmt( 319 327 get<Expression>().accept1( node->cond ), … … 325 333 326 334 const ast::Stmt * visit( const ast::WhileStmt * node ) override final { 335 if ( inCache( node ) ) return nullptr; 327 336 auto inits = get<Statement>().acceptL( node->inits ); 328 337 auto stmt = new WhileStmt( … … 336 345 337 346 const ast::Stmt * visit( const ast::ForStmt * node ) override final { 347 if ( inCache( node ) ) return nullptr; 338 348 auto stmt = new ForStmt( 339 349 get<Statement>().acceptL( node->inits ), … … 346 356 347 357 const ast::Stmt * visit( const ast::BranchStmt * node ) override final { 358 if ( inCache( node ) ) return nullptr; 348 359 BranchStmt * stmt; 349 360 if (node->computedTarget) { … … 375 386 376 387 const ast::Stmt * visit( const ast::ReturnStmt * node ) override final { 388 if ( inCache( node ) ) return nullptr; 377 389 auto stmt = new ReturnStmt( get<Expression>().accept1( node->expr ) ); 378 390 return stmtPostamble( stmt, node ); … … 380 392 381 393 const ast::Stmt * visit( const ast::ThrowStmt * node ) override final { 394 if ( inCache( node ) ) return nullptr; 382 395 ThrowStmt::Kind kind; 383 396 switch (node->kind) { … … 400 413 401 414 const ast::Stmt * visit( const ast::TryStmt * node ) override final { 415 if ( inCache( node ) ) return nullptr; 402 416 auto handlers = get<CatchStmt>().acceptL( node->handlers ); 403 417 auto stmt = new TryStmt( … … 410 424 411 425 const ast::Stmt * visit( const ast::CatchStmt * node ) override final { 426 if ( inCache( node ) ) return nullptr; 412 427 CatchStmt::Kind kind; 413 428 switch (node->kind) { … … 431 446 432 447 const ast::Stmt * visit( const ast::FinallyStmt * node ) override final { 448 if ( inCache( node ) ) return nullptr; 433 449 auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) ); 434 450 return stmtPostamble( stmt, node ); … … 436 452 437 453 const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { 454 if ( inCache( node ) ) return nullptr; 438 455 auto stmt = new WaitForStmt; 439 456 stmt->clauses.reserve( node->clauses.size() ); … … 460 477 461 478 const ast::Stmt * visit( const ast::WithStmt * node ) override final { 479 if ( inCache( node ) ) return nullptr; 462 480 auto stmt = new WithStmt( 463 481 get<Expression>().acceptL( node->exprs ), … … 468 486 469 487 const ast::NullStmt * visit( const ast::NullStmt * node ) override final { 488 if ( inCache( node ) ) return nullptr; 470 489 auto stmt = new NullStmt(); 471 490 stmtPostamble( stmt, node ); … … 474 493 475 494 const ast::Stmt * visit( const ast::DeclStmt * node ) override final { 495 if ( inCache( node ) ) return nullptr; 476 496 auto stmt = new DeclStmt( get<Declaration>().accept1( node->decl ) ); 477 497 return stmtPostamble( stmt, node ); … … 479 499 480 500 const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final { 481 (void)node; 482 return nullptr; 501 if ( inCache( node ) ) return nullptr; 502 auto stmt = new ImplicitCtorDtorStmt{ 503 get<Statement>().accept1( node->callStmt ) 504 }; 505 return stmtPostamble( stmt, node ); 483 506 } 484 507 … … 1564 1587 1565 1588 virtual void visit( CompoundStmt * old ) override final { 1589 if ( inCache( old ) ) return; 1566 1590 auto stmt = new ast::CompoundStmt( 1567 1591 old->location, … … 1571 1595 1572 1596 this->node = stmt; 1597 cache.emplace( old, this->node ); 1573 1598 } 1574 1599 1575 1600 virtual void visit( ExprStmt * old ) override final { 1601 if ( inCache( old ) ) return; 1576 1602 this->node = new ast::ExprStmt( 1577 1603 old->location, … … 1579 1605 GET_LABELS_V(old->labels) 1580 1606 ); 1607 cache.emplace( old, this->node ); 1581 1608 } 1582 1609 1583 1610 virtual void visit( AsmStmt * old ) override final { 1611 if ( inCache( old ) ) return; 1584 1612 this->node = new ast::AsmStmt( 1585 1613 old->location, … … 1592 1620 GET_LABELS_V(old->labels) 1593 1621 ); 1622 cache.emplace( old, this->node ); 1594 1623 } 1595 1624 1596 1625 virtual void visit( DirectiveStmt * old ) override final { 1626 if ( inCache( old ) ) return; 1597 1627 this->node = new ast::DirectiveStmt( 1598 1628 old->location, … … 1600 1630 GET_LABELS_V(old->labels) 1601 1631 ); 1632 cache.emplace( old, this->node ); 1602 1633 } 1603 1634 1604 1635 virtual void visit( IfStmt * old ) override final { 1636 if ( inCache( old ) ) return; 1605 1637 this->node = new ast::IfStmt( 1606 1638 old->location, … … 1611 1643 GET_LABELS_V(old->labels) 1612 1644 ); 1645 cache.emplace( old, this->node ); 1613 1646 } 1614 1647 1615 1648 virtual void visit( SwitchStmt * old ) override final { 1649 if ( inCache( old ) ) return; 1616 1650 this->node = new ast::SwitchStmt( 1617 1651 old->location, … … 1620 1654 GET_LABELS_V(old->labels) 1621 1655 ); 1656 cache.emplace( old, this->node ); 1622 1657 } 1623 1658 1624 1659 virtual void visit( CaseStmt * old ) override final { 1660 if ( inCache( old ) ) return; 1625 1661 this->node = new ast::CaseStmt( 1626 1662 old->location, … … 1629 1665 GET_LABELS_V(old->labels) 1630 1666 ); 1667 cache.emplace( old, this->node ); 1631 1668 } 1632 1669 1633 1670 virtual void visit( WhileStmt * old ) override final { 1671 if ( inCache( old ) ) return; 1634 1672 this->node = new ast::WhileStmt( 1635 1673 old->location, … … 1640 1678 GET_LABELS_V(old->labels) 1641 1679 ); 1680 cache.emplace( old, this->node ); 1642 1681 } 1643 1682 1644 1683 virtual void visit( ForStmt * old ) override final { 1684 if ( inCache( old ) ) return; 1645 1685 this->node = new ast::ForStmt( 1646 1686 old->location, … … 1651 1691 GET_LABELS_V(old->labels) 1652 1692 ); 1693 cache.emplace( old, this->node ); 1653 1694 } 1654 1695 1655 1696 virtual void visit( BranchStmt * old ) override final { 1697 if ( inCache( old ) ) return; 1656 1698 if (old->computedTarget) { 1657 1699 this->node = new ast::BranchStmt( … … 1687 1729 this->node = stmt; 1688 1730 } 1731 cache.emplace( old, this->node ); 1689 1732 } 1690 1733 1691 1734 virtual void visit( ReturnStmt * old ) override final { 1735 if ( inCache( old ) ) return; 1692 1736 this->node = new ast::ReturnStmt( 1693 1737 old->location, … … 1695 1739 GET_LABELS_V(old->labels) 1696 1740 ); 1741 cache.emplace( old, this->node ); 1697 1742 } 1698 1743 1699 1744 virtual void visit( ThrowStmt * old ) override final { 1745 if ( inCache( old ) ) return; 1700 1746 ast::ThrowStmt::Kind kind; 1701 1747 switch (old->kind) { … … 1717 1763 GET_LABELS_V(old->labels) 1718 1764 ); 1765 cache.emplace( old, this->node ); 1719 1766 } 1720 1767 1721 1768 virtual void visit( TryStmt * old ) override final { 1769 if ( inCache( old ) ) return; 1722 1770 this->node = new ast::TryStmt( 1723 1771 old->location, … … 1727 1775 GET_LABELS_V(old->labels) 1728 1776 ); 1777 cache.emplace( old, this->node ); 1729 1778 } 1730 1779 1731 1780 virtual void visit( CatchStmt * old ) override final { 1781 if ( inCache( old ) ) return; 1732 1782 ast::CatchStmt::Kind kind; 1733 1783 switch (old->kind) { … … 1750 1800 GET_LABELS_V(old->labels) 1751 1801 ); 1802 cache.emplace( old, this->node ); 1752 1803 } 1753 1804 1754 1805 virtual void visit( FinallyStmt * old ) override final { 1806 if ( inCache( old ) ) return; 1755 1807 this->node = new ast::FinallyStmt( 1756 1808 old->location, … … 1758 1810 GET_LABELS_V(old->labels) 1759 1811 ); 1812 cache.emplace( old, this->node ); 1760 1813 } 1761 1814 1762 1815 virtual void visit( WaitForStmt * old ) override final { 1816 if ( inCache( old ) ) return; 1763 1817 ast::WaitForStmt * stmt = new ast::WaitForStmt( 1764 1818 old->location, … … 1788 1842 1789 1843 this->node = stmt; 1844 cache.emplace( old, this->node ); 1790 1845 } 1791 1846 1792 1847 virtual void visit( WithStmt * old ) override final { 1848 if ( inCache( old ) ) return; 1793 1849 this->node = new ast::WithStmt( 1794 1850 old->location, … … 1797 1853 GET_LABELS_V(old->labels) 1798 1854 ); 1855 cache.emplace( old, this->node ); 1799 1856 } 1800 1857 1801 1858 virtual void visit( NullStmt * old ) override final { 1859 if ( inCache( old ) ) return; 1802 1860 this->node = new ast::NullStmt( 1803 1861 old->location, 1804 1862 GET_LABELS_V(old->labels) 1805 1863 ); 1864 cache.emplace( old, this->node ); 1806 1865 } 1807 1866 1808 1867 virtual void visit( DeclStmt * old ) override final { 1868 if ( inCache( old ) ) return; 1809 1869 this->node = new ast::DeclStmt( 1810 1870 old->location, … … 1812 1872 GET_LABELS_V(old->labels) 1813 1873 ); 1874 cache.emplace( old, this->node ); 1814 1875 } 1815 1876 1816 1877 virtual void visit( ImplicitCtorDtorStmt * old ) override final { 1878 if ( inCache( old ) ) return; 1817 1879 this->node = new ast::ImplicitCtorDtorStmt( 1818 1880 old->location, … … 1820 1882 GET_LABELS_V(old->labels) 1821 1883 ); 1884 cache.emplace( old, this->node ); 1822 1885 } 1823 1886
Note: See TracChangeset
for help on using the changeset viewer.