- Timestamp:
- Jul 19, 2019, 2:16:01 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 4eb43fa
- Parents:
- 1f1c102 (diff), 8ac3b0e (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/AST
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r1f1c102 rf53acdf8 518 518 } 519 519 520 const ast:: Stmt* visit( const ast::WithStmt * node ) override final {520 const ast::Decl * visit( const ast::WithStmt * node ) override final { 521 521 if ( inCache( node ) ) return nullptr; 522 522 auto stmt = new WithStmt( … … 524 524 get<Statement>().accept1( node->stmt ) 525 525 ); 526 return stmtPostamble( stmt, node ); 526 declPostamble( stmt, node ); 527 return nullptr; 527 528 } 528 529 … … 1039 1040 get<Expression>().accept1(node->expr), 1040 1041 inCache(node->deleteStmt) ? 1041 this->node:1042 get< BaseSyntaxNode>().accept1(node->deleteStmt)1042 strict_dynamic_cast<Declaration*>(this->node) : 1043 get<Declaration>().accept1(node->deleteStmt) 1043 1044 ) 1044 1045 ); … … 1355 1356 ast::Node * node = nullptr; 1356 1357 /// cache of nodes that might be referenced by readonly<> for de-duplication 1357 std::unordered_map< BaseSyntaxNode *, ast::Node * > cache = {};1358 std::unordered_map< const BaseSyntaxNode *, ast::Node * > cache = {}; 1358 1359 1359 1360 // Local Utilities: … … 1422 1423 to<std::vector>::from( make_labels( std::move( labels ) ) ) 1423 1424 1424 static ast::CV::Qualifiers cv( Type * ty ) { return { ty->get_qualifiers().val }; }1425 static ast::CV::Qualifiers cv( const Type * ty ) { return { ty->tq.val }; } 1425 1426 1426 1427 /// returns true and sets `node` if in cache 1427 bool inCache( BaseSyntaxNode * old ) {1428 bool inCache( const BaseSyntaxNode * old ) { 1428 1429 auto it = cache.find( old ); 1429 1430 if ( it == cache.end() ) return false; … … 1434 1435 // Now all the visit functions: 1435 1436 1436 virtual void visit( ObjectDecl * old ) override final {1437 virtual void visit( const ObjectDecl * old ) override final { 1437 1438 auto&& type = GET_ACCEPT_1(type, Type); 1438 1439 auto&& init = GET_ACCEPT_1(init, Init); … … 1465 1466 } 1466 1467 1467 virtual void visit( FunctionDecl * old ) override final {1468 virtual void visit( const FunctionDecl * old ) override final { 1468 1469 if ( inCache( old ) ) return; 1469 1470 auto decl = new ast::FunctionDecl{ … … 1498 1499 } 1499 1500 1500 virtual void visit( StructDecl * old ) override final {1501 virtual void visit( const StructDecl * old ) override final { 1501 1502 if ( inCache( old ) ) return; 1502 1503 auto decl = new ast::StructDecl( … … 1523 1524 } 1524 1525 1525 virtual void visit( UnionDecl * old ) override final {1526 virtual void visit( const UnionDecl * old ) override final { 1526 1527 if ( inCache( old ) ) return; 1527 1528 auto decl = new ast::UnionDecl( … … 1543 1544 } 1544 1545 1545 virtual void visit( EnumDecl * old ) override final {1546 virtual void visit( const EnumDecl * old ) override final { 1546 1547 if ( inCache( old ) ) return; 1547 1548 auto decl = new ast::EnumDecl( … … 1563 1564 } 1564 1565 1565 virtual void visit( TraitDecl * old ) override final {1566 virtual void visit( const TraitDecl * old ) override final { 1566 1567 if ( inCache( old ) ) return; 1567 1568 auto decl = new ast::TraitDecl( … … 1583 1584 } 1584 1585 1585 virtual void visit( TypeDecl * old ) override final {1586 virtual void visit( const TypeDecl * old ) override final { 1586 1587 if ( inCache( old ) ) return; 1587 1588 auto decl = new ast::TypeDecl{ … … 1603 1604 } 1604 1605 1605 virtual void visit( TypedefDecl * old ) override final {1606 virtual void visit( const TypedefDecl * old ) override final { 1606 1607 auto decl = new ast::TypedefDecl( 1607 1608 old->location, … … 1620 1621 } 1621 1622 1622 virtual void visit( AsmDecl * old ) override final {1623 virtual void visit( const AsmDecl * old ) override final { 1623 1624 auto decl = new ast::AsmDecl{ 1624 1625 old->location, … … 1632 1633 } 1633 1634 1634 virtual void visit( StaticAssertDecl * old ) override final {1635 virtual void visit( const StaticAssertDecl * old ) override final { 1635 1636 auto decl = new ast::StaticAssertDecl{ 1636 1637 old->location, … … 1645 1646 } 1646 1647 1647 virtual void visit( CompoundStmt * old ) override final {1648 virtual void visit( const CompoundStmt * old ) override final { 1648 1649 if ( inCache( old ) ) return; 1649 1650 auto stmt = new ast::CompoundStmt( … … 1657 1658 } 1658 1659 1659 virtual void visit( ExprStmt * old ) override final {1660 virtual void visit( const ExprStmt * old ) override final { 1660 1661 if ( inCache( old ) ) return; 1661 1662 this->node = new ast::ExprStmt( … … 1667 1668 } 1668 1669 1669 virtual void visit( AsmStmt * old ) override final {1670 virtual void visit( const AsmStmt * old ) override final { 1670 1671 if ( inCache( old ) ) return; 1671 1672 this->node = new ast::AsmStmt( … … 1682 1683 } 1683 1684 1684 virtual void visit( DirectiveStmt * old ) override final {1685 virtual void visit( const DirectiveStmt * old ) override final { 1685 1686 if ( inCache( old ) ) return; 1686 1687 this->node = new ast::DirectiveStmt( … … 1692 1693 } 1693 1694 1694 virtual void visit( IfStmt * old ) override final {1695 virtual void visit( const IfStmt * old ) override final { 1695 1696 if ( inCache( old ) ) return; 1696 1697 this->node = new ast::IfStmt( … … 1705 1706 } 1706 1707 1707 virtual void visit( SwitchStmt * old ) override final {1708 virtual void visit( const SwitchStmt * old ) override final { 1708 1709 if ( inCache( old ) ) return; 1709 1710 this->node = new ast::SwitchStmt( … … 1716 1717 } 1717 1718 1718 virtual void visit( CaseStmt * old ) override final {1719 virtual void visit( const CaseStmt * old ) override final { 1719 1720 if ( inCache( old ) ) return; 1720 1721 this->node = new ast::CaseStmt( … … 1727 1728 } 1728 1729 1729 virtual void visit( WhileStmt * old ) override final {1730 virtual void visit( const WhileStmt * old ) override final { 1730 1731 if ( inCache( old ) ) return; 1731 1732 this->node = new ast::WhileStmt( … … 1740 1741 } 1741 1742 1742 virtual void visit( ForStmt * old ) override final {1743 virtual void visit( const ForStmt * old ) override final { 1743 1744 if ( inCache( old ) ) return; 1744 1745 this->node = new ast::ForStmt( … … 1753 1754 } 1754 1755 1755 virtual void visit( BranchStmt * old ) override final {1756 virtual void visit( const BranchStmt * old ) override final { 1756 1757 if ( inCache( old ) ) return; 1757 1758 if (old->computedTarget) { … … 1790 1791 } 1791 1792 1792 virtual void visit( ReturnStmt * old ) override final {1793 virtual void visit( const ReturnStmt * old ) override final { 1793 1794 if ( inCache( old ) ) return; 1794 1795 this->node = new ast::ReturnStmt( … … 1800 1801 } 1801 1802 1802 virtual void visit( ThrowStmt * old ) override final {1803 virtual void visit( const ThrowStmt * old ) override final { 1803 1804 if ( inCache( old ) ) return; 1804 1805 ast::ExceptionKind kind; … … 1824 1825 } 1825 1826 1826 virtual void visit( TryStmt * old ) override final {1827 virtual void visit( const TryStmt * old ) override final { 1827 1828 if ( inCache( old ) ) return; 1828 1829 this->node = new ast::TryStmt( … … 1836 1837 } 1837 1838 1838 virtual void visit( CatchStmt * old ) override final {1839 virtual void visit( const CatchStmt * old ) override final { 1839 1840 if ( inCache( old ) ) return; 1840 1841 ast::ExceptionKind kind; … … 1861 1862 } 1862 1863 1863 virtual void visit( FinallyStmt * old ) override final {1864 virtual void visit( const FinallyStmt * old ) override final { 1864 1865 if ( inCache( old ) ) return; 1865 1866 this->node = new ast::FinallyStmt( … … 1871 1872 } 1872 1873 1873 virtual void visit( WaitForStmt * old ) override final {1874 virtual void visit( const WaitForStmt * old ) override final { 1874 1875 if ( inCache( old ) ) return; 1875 1876 ast::WaitForStmt * stmt = new ast::WaitForStmt( … … 1903 1904 } 1904 1905 1905 virtual void visit( WithStmt * old ) override final {1906 virtual void visit( const WithStmt * old ) override final { 1906 1907 if ( inCache( old ) ) return; 1907 1908 this->node = new ast::WithStmt( 1908 1909 old->location, 1909 1910 GET_ACCEPT_V(exprs, Expr), 1910 GET_ACCEPT_1(stmt, Stmt), 1911 GET_LABELS_V(old->labels) 1911 GET_ACCEPT_1(stmt, Stmt) 1912 1912 ); 1913 1913 cache.emplace( old, this->node ); 1914 1914 } 1915 1915 1916 virtual void visit( NullStmt * old ) override final {1916 virtual void visit( const NullStmt * old ) override final { 1917 1917 if ( inCache( old ) ) return; 1918 1918 this->node = new ast::NullStmt( … … 1923 1923 } 1924 1924 1925 virtual void visit( DeclStmt * old ) override final {1925 virtual void visit( const DeclStmt * old ) override final { 1926 1926 if ( inCache( old ) ) return; 1927 1927 this->node = new ast::DeclStmt( … … 1933 1933 } 1934 1934 1935 virtual void visit( ImplicitCtorDtorStmt * old ) override final {1935 virtual void visit( const ImplicitCtorDtorStmt * old ) override final { 1936 1936 if ( inCache( old ) ) return; 1937 1937 auto stmt = new ast::ImplicitCtorDtorStmt( … … 1990 1990 } 1991 1991 1992 ast::Expr * visitBaseExpr_SkipResultType( Expression * old, ast::Expr * nw) {1992 ast::Expr * visitBaseExpr_SkipResultType( const Expression * old, ast::Expr * nw) { 1993 1993 1994 1994 nw->env = convertTypeSubstitution(old->env); … … 2000 2000 } 2001 2001 2002 ast::Expr * visitBaseExpr( Expression * old, ast::Expr * nw) {2002 ast::Expr * visitBaseExpr( const Expression * old, ast::Expr * nw) { 2003 2003 2004 2004 nw->result = GET_ACCEPT_1(result, Type); … … 2006 2006 } 2007 2007 2008 virtual void visit( ApplicationExpr * old ) override final {2008 virtual void visit( const ApplicationExpr * old ) override final { 2009 2009 this->node = visitBaseExpr( old, 2010 2010 new ast::ApplicationExpr( … … 2016 2016 } 2017 2017 2018 virtual void visit( UntypedExpr * old ) override final {2018 virtual void visit( const UntypedExpr * old ) override final { 2019 2019 this->node = visitBaseExpr( old, 2020 2020 new ast::UntypedExpr( … … 2026 2026 } 2027 2027 2028 virtual void visit( NameExpr * old ) override final {2028 virtual void visit( const NameExpr * old ) override final { 2029 2029 this->node = visitBaseExpr( old, 2030 2030 new ast::NameExpr( … … 2035 2035 } 2036 2036 2037 virtual void visit( CastExpr * old ) override final {2037 virtual void visit( const CastExpr * old ) override final { 2038 2038 this->node = visitBaseExpr( old, 2039 2039 new ast::CastExpr( … … 2045 2045 } 2046 2046 2047 virtual void visit( KeywordCastExpr * old) override final {2047 virtual void visit( const KeywordCastExpr * old) override final { 2048 2048 ast::KeywordCastExpr::Target castTarget = ast::KeywordCastExpr::NUMBER_OF_TARGETS; 2049 2049 switch (old->target) { … … 2070 2070 } 2071 2071 2072 virtual void visit( VirtualCastExpr * old ) override final {2072 virtual void visit( const VirtualCastExpr * old ) override final { 2073 2073 this->node = visitBaseExpr_SkipResultType( old, 2074 2074 new ast::VirtualCastExpr( … … 2080 2080 } 2081 2081 2082 virtual void visit( AddressExpr * old ) override final {2082 virtual void visit( const AddressExpr * old ) override final { 2083 2083 this->node = visitBaseExpr( old, 2084 2084 new ast::AddressExpr( … … 2089 2089 } 2090 2090 2091 virtual void visit( LabelAddressExpr * old ) override final {2091 virtual void visit( const LabelAddressExpr * old ) override final { 2092 2092 this->node = visitBaseExpr( old, 2093 2093 new ast::LabelAddressExpr( … … 2098 2098 } 2099 2099 2100 virtual void visit( UntypedMemberExpr * old ) override final {2100 virtual void visit( const UntypedMemberExpr * old ) override final { 2101 2101 this->node = visitBaseExpr( old, 2102 2102 new ast::UntypedMemberExpr( … … 2108 2108 } 2109 2109 2110 virtual void visit( MemberExpr * old ) override final {2110 virtual void visit( const MemberExpr * old ) override final { 2111 2111 this->node = visitBaseExpr( old, 2112 2112 new ast::MemberExpr( … … 2118 2118 } 2119 2119 2120 virtual void visit( VariableExpr * old ) override final {2120 virtual void visit( const VariableExpr * old ) override final { 2121 2121 auto expr = new ast::VariableExpr( 2122 2122 old->location … … 2129 2129 } 2130 2130 2131 virtual void visit( ConstantExpr * old ) override final {2131 virtual void visit( const ConstantExpr * old ) override final { 2132 2132 ast::ConstantExpr *rslt = new ast::ConstantExpr( 2133 2133 old->location, 2134 2134 GET_ACCEPT_1(result, Type), 2135 old->constant. get_value(),2135 old->constant.rep, 2136 2136 old->constant.ival 2137 2137 ); 2138 rslt->underlyer = getAccept1< ast::Type, Type* >( old->constant. get_type());2138 rslt->underlyer = getAccept1< ast::Type, Type* >( old->constant.type ); 2139 2139 this->node = visitBaseExpr( old, rslt ); 2140 2140 } 2141 2141 2142 virtual void visit( SizeofExpr * old ) override final {2142 virtual void visit( const SizeofExpr * old ) override final { 2143 2143 assert (old->expr || old->type); 2144 2144 assert (! (old->expr && old->type)); … … 2161 2161 } 2162 2162 2163 virtual void visit( AlignofExpr * old ) override final {2163 virtual void visit( const AlignofExpr * old ) override final { 2164 2164 assert (old->expr || old->type); 2165 2165 assert (! (old->expr && old->type)); … … 2182 2182 } 2183 2183 2184 virtual void visit( UntypedOffsetofExpr * old ) override final {2184 virtual void visit( const UntypedOffsetofExpr * old ) override final { 2185 2185 this->node = visitBaseExpr( old, 2186 2186 new ast::UntypedOffsetofExpr( … … 2192 2192 } 2193 2193 2194 virtual void visit( OffsetofExpr * old ) override final {2194 virtual void visit( const OffsetofExpr * old ) override final { 2195 2195 this->node = visitBaseExpr( old, 2196 2196 new ast::OffsetofExpr( … … 2202 2202 } 2203 2203 2204 virtual void visit( OffsetPackExpr * old ) override final {2204 virtual void visit( const OffsetPackExpr * old ) override final { 2205 2205 this->node = visitBaseExpr( old, 2206 2206 new ast::OffsetPackExpr( … … 2211 2211 } 2212 2212 2213 virtual void visit( LogicalExpr * old ) override final {2213 virtual void visit( const LogicalExpr * old ) override final { 2214 2214 this->node = visitBaseExpr( old, 2215 2215 new ast::LogicalExpr( … … 2224 2224 } 2225 2225 2226 virtual void visit( ConditionalExpr * old ) override final {2226 virtual void visit( const ConditionalExpr * old ) override final { 2227 2227 this->node = visitBaseExpr( old, 2228 2228 new ast::ConditionalExpr( … … 2235 2235 } 2236 2236 2237 virtual void visit( CommaExpr * old ) override final {2237 virtual void visit( const CommaExpr * old ) override final { 2238 2238 this->node = visitBaseExpr( old, 2239 2239 new ast::CommaExpr( … … 2245 2245 } 2246 2246 2247 virtual void visit( TypeExpr * old ) override final {2247 virtual void visit( const TypeExpr * old ) override final { 2248 2248 this->node = visitBaseExpr( old, 2249 2249 new ast::TypeExpr( … … 2254 2254 } 2255 2255 2256 virtual void visit( AsmExpr * old ) override final {2256 virtual void visit( const AsmExpr * old ) override final { 2257 2257 this->node = visitBaseExpr( old, 2258 2258 new ast::AsmExpr( … … 2265 2265 } 2266 2266 2267 virtual void visit( ImplicitCopyCtorExpr * old ) override final {2267 virtual void visit( const ImplicitCopyCtorExpr * old ) override final { 2268 2268 auto rslt = new ast::ImplicitCopyCtorExpr( 2269 2269 old->location, … … 2274 2274 } 2275 2275 2276 virtual void visit( ConstructorExpr * old ) override final {2276 virtual void visit( const ConstructorExpr * old ) override final { 2277 2277 this->node = visitBaseExpr( old, 2278 2278 new ast::ConstructorExpr( … … 2283 2283 } 2284 2284 2285 virtual void visit( CompoundLiteralExpr * old ) override final {2285 virtual void visit( const CompoundLiteralExpr * old ) override final { 2286 2286 this->node = visitBaseExpr_SkipResultType( old, 2287 2287 new ast::CompoundLiteralExpr( … … 2293 2293 } 2294 2294 2295 virtual void visit( RangeExpr * old ) override final {2295 virtual void visit( const RangeExpr * old ) override final { 2296 2296 this->node = visitBaseExpr( old, 2297 2297 new ast::RangeExpr( … … 2303 2303 } 2304 2304 2305 virtual void visit( UntypedTupleExpr * old ) override final {2305 virtual void visit( const UntypedTupleExpr * old ) override final { 2306 2306 this->node = visitBaseExpr( old, 2307 2307 new ast::UntypedTupleExpr( … … 2312 2312 } 2313 2313 2314 virtual void visit( TupleExpr * old ) override final {2314 virtual void visit( const TupleExpr * old ) override final { 2315 2315 this->node = visitBaseExpr( old, 2316 2316 new ast::TupleExpr( … … 2321 2321 } 2322 2322 2323 virtual void visit( TupleIndexExpr * old ) override final {2323 virtual void visit( const TupleIndexExpr * old ) override final { 2324 2324 this->node = visitBaseExpr( old, 2325 2325 new ast::TupleIndexExpr( … … 2331 2331 } 2332 2332 2333 virtual void visit( TupleAssignExpr * old ) override final {2333 virtual void visit( const TupleAssignExpr * old ) override final { 2334 2334 this->node = visitBaseExpr_SkipResultType( old, 2335 2335 new ast::TupleAssignExpr( … … 2341 2341 } 2342 2342 2343 virtual void visit( StmtExpr * old ) override final {2343 virtual void visit( const StmtExpr * old ) override final { 2344 2344 auto rslt = new ast::StmtExpr( 2345 2345 old->location, … … 2352 2352 } 2353 2353 2354 virtual void visit( UniqueExpr * old ) override final {2354 virtual void visit( const UniqueExpr * old ) override final { 2355 2355 auto rslt = new ast::UniqueExpr( 2356 2356 old->location, … … 2364 2364 } 2365 2365 2366 virtual void visit( UntypedInitExpr * old ) override final {2366 virtual void visit( const UntypedInitExpr * old ) override final { 2367 2367 std::deque<ast::InitAlternative> initAlts; 2368 2368 for (auto ia : old->initAlts) { … … 2381 2381 } 2382 2382 2383 virtual void visit( InitExpr * old ) override final {2383 virtual void visit( const InitExpr * old ) override final { 2384 2384 this->node = visitBaseExpr( old, 2385 2385 new ast::InitExpr( … … 2391 2391 } 2392 2392 2393 virtual void visit( DeletedExpr * old ) override final {2393 virtual void visit( const DeletedExpr * old ) override final { 2394 2394 this->node = visitBaseExpr( old, 2395 2395 new ast::DeletedExpr( … … 2397 2397 GET_ACCEPT_1(expr, Expr), 2398 2398 inCache(old->deleteStmt) ? 2399 this->node:2400 GET_ACCEPT_1(deleteStmt, Node)2401 ) 2402 ); 2403 } 2404 2405 virtual void visit( DefaultArgExpr * old ) override final {2399 strict_dynamic_cast<ast::Decl*>(this->node) : 2400 GET_ACCEPT_1(deleteStmt, Decl) 2401 ) 2402 ); 2403 } 2404 2405 virtual void visit( const DefaultArgExpr * old ) override final { 2406 2406 this->node = visitBaseExpr( old, 2407 2407 new ast::DefaultArgExpr( … … 2412 2412 } 2413 2413 2414 virtual void visit( GenericExpr * old ) override final {2414 virtual void visit( const GenericExpr * old ) override final { 2415 2415 std::vector<ast::GenericExpr::Association> associations; 2416 2416 for (auto association : old->associations) { … … 2429 2429 } 2430 2430 2431 void visitType( Type * old, ast::Type * type ) {2431 void visitType( const Type * old, ast::Type * type ) { 2432 2432 // Some types do this in their constructor so add a check. 2433 2433 if ( !old->attributes.empty() && type->attributes.empty() ) { … … 2437 2437 } 2438 2438 2439 virtual void visit( VoidType * old ) override final {2439 virtual void visit( const VoidType * old ) override final { 2440 2440 visitType( old, new ast::VoidType{ cv( old ) } ); 2441 2441 } 2442 2442 2443 virtual void visit( BasicType * old ) override final {2443 virtual void visit( const BasicType * old ) override final { 2444 2444 auto type = new ast::BasicType{ (ast::BasicType::Kind)(unsigned)old->kind, cv( old ) }; 2445 2445 // I believe this should always be a BasicType. … … 2450 2450 } 2451 2451 2452 virtual void visit( PointerType * old ) override final {2452 virtual void visit( const PointerType * old ) override final { 2453 2453 visitType( old, new ast::PointerType{ 2454 2454 GET_ACCEPT_1( base, Type ), … … 2460 2460 } 2461 2461 2462 virtual void visit( ArrayType * old ) override final {2462 virtual void visit( const ArrayType * old ) override final { 2463 2463 visitType( old, new ast::ArrayType{ 2464 2464 GET_ACCEPT_1( base, Type ), … … 2470 2470 } 2471 2471 2472 virtual void visit( ReferenceType * old ) override final {2472 virtual void visit( const ReferenceType * old ) override final { 2473 2473 visitType( old, new ast::ReferenceType{ 2474 2474 GET_ACCEPT_1( base, Type ), … … 2477 2477 } 2478 2478 2479 virtual void visit( QualifiedType * old ) override final {2479 virtual void visit( const QualifiedType * old ) override final { 2480 2480 visitType( old, new ast::QualifiedType{ 2481 2481 GET_ACCEPT_1( parent, Type ), … … 2485 2485 } 2486 2486 2487 virtual void visit( FunctionType * old ) override final {2487 virtual void visit( const FunctionType * old ) override final { 2488 2488 auto ty = new ast::FunctionType { 2489 2489 (ast::ArgumentFlag)old->isVarArgs, … … 2496 2496 } 2497 2497 2498 void postvisit( ReferenceToType * old, ast::ReferenceToType * ty ) {2498 void postvisit( const ReferenceToType * old, ast::ReferenceToType * ty ) { 2499 2499 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2500 2500 ty->params = GET_ACCEPT_V( parameters, Expr ); … … 2503 2503 } 2504 2504 2505 virtual void visit( StructInstType * old ) override final {2505 virtual void visit( const StructInstType * old ) override final { 2506 2506 ast::StructInstType * ty; 2507 2507 if ( old->baseStruct ) { … … 2521 2521 } 2522 2522 2523 virtual void visit( UnionInstType * old ) override final {2523 virtual void visit( const UnionInstType * old ) override final { 2524 2524 ast::UnionInstType * ty; 2525 2525 if ( old->baseUnion ) { … … 2539 2539 } 2540 2540 2541 virtual void visit( EnumInstType * old ) override final {2541 virtual void visit( const EnumInstType * old ) override final { 2542 2542 ast::EnumInstType * ty; 2543 2543 if ( old->baseEnum ) { … … 2557 2557 } 2558 2558 2559 virtual void visit( TraitInstType * old ) override final {2559 virtual void visit( const TraitInstType * old ) override final { 2560 2560 ast::TraitInstType * ty; 2561 2561 if ( old->baseTrait ) { … … 2575 2575 } 2576 2576 2577 virtual void visit( TypeInstType * old ) override final {2577 virtual void visit( const TypeInstType * old ) override final { 2578 2578 ast::TypeInstType * ty; 2579 2579 if ( old->baseType ) { … … 2595 2595 } 2596 2596 2597 virtual void visit( TupleType * old ) override final {2597 virtual void visit( const TupleType * old ) override final { 2598 2598 visitType( old, new ast::TupleType{ 2599 2599 GET_ACCEPT_V( types, Type ), … … 2603 2603 } 2604 2604 2605 virtual void visit( TypeofType * old ) override final {2605 virtual void visit( const TypeofType * old ) override final { 2606 2606 visitType( old, new ast::TypeofType{ 2607 2607 GET_ACCEPT_1( expr, Expr ), … … 2611 2611 } 2612 2612 2613 virtual void visit( AttrType * ) override final {2613 virtual void visit( const AttrType * ) override final { 2614 2614 assertf( false, "AttrType deprecated in new AST." ); 2615 2615 } 2616 2616 2617 virtual void visit( VarArgsType * old ) override final {2617 virtual void visit( const VarArgsType * old ) override final { 2618 2618 visitType( old, new ast::VarArgsType{ cv( old ) } ); 2619 2619 } 2620 2620 2621 virtual void visit( ZeroType * old ) override final {2621 virtual void visit( const ZeroType * old ) override final { 2622 2622 visitType( old, new ast::ZeroType{ cv( old ) } ); 2623 2623 } 2624 2624 2625 virtual void visit( OneType * old ) override final {2625 virtual void visit( const OneType * old ) override final { 2626 2626 visitType( old, new ast::OneType{ cv( old ) } ); 2627 2627 } 2628 2628 2629 virtual void visit( GlobalScopeType * old ) override final {2629 virtual void visit( const GlobalScopeType * old ) override final { 2630 2630 visitType( old, new ast::GlobalScopeType{} ); 2631 2631 } 2632 2632 2633 virtual void visit( Designation * old ) override final {2633 virtual void visit( const Designation * old ) override final { 2634 2634 this->node = new ast::Designation( 2635 2635 old->location, … … 2638 2638 } 2639 2639 2640 virtual void visit( SingleInit * old ) override final {2640 virtual void visit( const SingleInit * old ) override final { 2641 2641 this->node = new ast::SingleInit( 2642 2642 old->location, … … 2646 2646 } 2647 2647 2648 virtual void visit( ListInit * old ) override final {2648 virtual void visit( const ListInit * old ) override final { 2649 2649 this->node = new ast::ListInit( 2650 2650 old->location, … … 2655 2655 } 2656 2656 2657 virtual void visit( ConstructorInit * old ) override final {2657 virtual void visit( const ConstructorInit * old ) override final { 2658 2658 this->node = new ast::ConstructorInit( 2659 2659 old->location, … … 2664 2664 } 2665 2665 2666 virtual void visit( Constant * ) override final {2666 virtual void visit( const Constant * ) override final { 2667 2667 // Handled in visit( ConstantEpxr * ). 2668 2668 // In the new tree, Constant fields are inlined into containing ConstantExpression. … … 2670 2670 } 2671 2671 2672 virtual void visit( Attribute * old ) override final {2672 virtual void visit( const Attribute * old ) override final { 2673 2673 this->node = new ast::Attribute( 2674 2674 old->name, … … 2677 2677 } 2678 2678 2679 virtual void visit( AttrExpr * ) override final {2679 virtual void visit( const AttrExpr * ) override final { 2680 2680 assertf( false, "AttrExpr deprecated in new AST." ); 2681 2681 } -
src/AST/Decl.hpp
r1f1c102 rf53acdf8 102 102 ptr<Expr> bitfieldWidth; 103 103 104 ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, 105 const Init * init = nullptr, Storage::Classes storage = {}, 106 Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr, 104 ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, 105 const Init * init = nullptr, Storage::Classes storage = {}, 106 Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr, 107 107 std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} ) 108 108 : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ), … … 323 323 }; 324 324 325 /// With statement `with (...) ...` 326 class WithStmt final : public Decl { 327 public: 328 std::vector<ptr<Expr>> exprs; 329 ptr<Stmt> stmt; 330 331 WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt ) 332 : Decl(loc, "", Storage::Auto, Linkage::Cforall), exprs(std::move(exprs)), stmt(stmt) {} 333 334 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } 335 private: 336 WithStmt * clone() const override { return new WithStmt{ *this }; } 337 MUTATE_FRIEND 338 }; 339 325 340 class AsmDecl : public Decl { 326 341 public: -
src/AST/Expr.hpp
r1f1c102 rf53acdf8 47 47 48 48 ParamEntry() : decl( 0 ), declptr( nullptr ), actualType( nullptr ), formalType( nullptr ), expr( nullptr ) {} 49 ParamEntry( 50 UniqueId id, const Decl * declptr, const Type * actual, const Type * formal, 49 ParamEntry( 50 UniqueId id, const Decl * declptr, const Type * actual, const Type * formal, 51 51 const Expr * e ) 52 52 : decl( id ), declptr( declptr ), actualType( actual ), formalType( formal ), expr( e ) {} … … 112 112 case Empty: new(&data.resnSlots) ResnSlots{}; mode = Slots; // fallthrough 113 113 case Slots: return data.resnSlots; 114 case Params: assert (!"Cannot return to resnSlots from Params");114 case Params: assertf(false, "Cannot return to resnSlots from Params"); abort(); 115 115 } 116 return *((ResnSlots*)nullptr);116 assertf(false, "unreachable"); 117 117 } 118 118 … … 121 121 return data.resnSlots; 122 122 } 123 assert (!"Mode was not already resnSlots");124 return *((ResnSlots*)nullptr);123 assertf(false, "Mode was not already resnSlots"); 124 abort(); 125 125 } 126 126 … … 131 131 case Params: return data.inferParams; 132 132 } 133 assert(!"unreachable"); 134 return *((InferredParams*)nullptr); 133 assertf(false, "unreachable"); 135 134 } 136 135 … … 139 138 return data.inferParams; 140 139 } 141 assert (!"Mode was not already Params");142 return *((InferredParams*)nullptr);140 assertf(false, "Mode was not already Params"); 141 abort(); 143 142 } 144 143 145 144 void set_inferParams( InferredParams && ps ) { 146 145 switch(mode) { 147 case Slots: 146 case Slots: 148 147 data.resnSlots.~ResnSlots(); 149 148 // fallthrough 150 case Empty: 149 case Empty: 151 150 new(&data.inferParams) InferredParams{ std::move( ps ) }; 152 151 mode = Params; … … 172 171 data.inferParams[p.first] = std::move(p.second); 173 172 } 174 } else assert (!"invalid mode");173 } else assertf(false, "invalid mode"); 175 174 } 176 175 }; … … 384 383 385 384 ConstantExpr( 386 const CodeLocation & loc, const Type * ty, const std::string & r, 385 const CodeLocation & loc, const Type * ty, const std::string & r, 387 386 std::optional<unsigned long long> i ) 388 387 : Expr( loc, ty ), rep( r ), ival( i ) {} … … 770 769 public: 771 770 ptr<Expr> expr; 772 readonly< Node> deleteStmt;773 774 DeletedExpr( const CodeLocation & loc, const Expr * e, const Node* del )771 readonly<Decl> deleteStmt; 772 773 DeletedExpr( const CodeLocation & loc, const Expr * e, const Decl * del ) 775 774 : Expr( loc, e->result ), expr( e ), deleteStmt( del ) { assert( expr->result ); } 776 775 -
src/AST/Pass.hpp
r1f1c102 rf53acdf8 115 115 const ast::Stmt * visit( const ast::FinallyStmt * ) override final; 116 116 const ast::Stmt * visit( const ast::WaitForStmt * ) override final; 117 const ast:: Stmt* visit( const ast::WithStmt * ) override final;117 const ast::Decl * visit( const ast::WithStmt * ) override final; 118 118 const ast::NullStmt * visit( const ast::NullStmt * ) override final; 119 119 const ast::Stmt * visit( const ast::DeclStmt * ) override final; -
src/AST/Pass.impl.hpp
r1f1c102 rf53acdf8 909 909 // WithStmt 910 910 template< typename pass_t > 911 const ast:: Stmt* ast::Pass< pass_t >::visit( const ast::WithStmt * node ) {911 const ast::Decl * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) { 912 912 VISIT_START( node ); 913 913 -
src/AST/Print.cpp
r1f1c102 rf53acdf8 37 37 } 38 38 39 class Printer : public Visitor {39 class Printer final : public Visitor { 40 40 public: 41 41 ostream & os; … … 272 272 273 273 public: 274 virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) {274 virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final { 275 275 if ( ! node->name.empty() ) os << node->name << ": "; 276 276 … … 314 314 } 315 315 316 virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) {316 virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final { 317 317 if ( !node->name.empty() ) os << node->name << ": "; 318 318 … … 342 342 } 343 343 344 virtual const ast::Decl * visit( const ast::StructDecl * node ) {344 virtual const ast::Decl * visit( const ast::StructDecl * node ) override final { 345 345 print(node); 346 346 return node; 347 347 } 348 348 349 virtual const ast::Decl * visit( const ast::UnionDecl * node ) {349 virtual const ast::Decl * visit( const ast::UnionDecl * node ) override final { 350 350 print(node); 351 351 return node; 352 352 } 353 353 354 virtual const ast::Decl * visit( const ast::EnumDecl * node ) {354 virtual const ast::Decl * visit( const ast::EnumDecl * node ) override final { 355 355 print(node); 356 356 return node; 357 357 } 358 358 359 virtual const ast::Decl * visit( const ast::TraitDecl * node ) {359 virtual const ast::Decl * visit( const ast::TraitDecl * node ) override final { 360 360 print(node); 361 361 return node; 362 362 } 363 363 364 virtual const ast::Decl * visit( const ast::TypeDecl * node ) {364 virtual const ast::Decl * visit( const ast::TypeDecl * node ) override final { 365 365 preprint( node ); 366 366 if ( ! short_mode && node->init ) { … … 374 374 } 375 375 376 virtual const ast::Decl * visit( const ast::TypedefDecl * node ) {377 preprint( node ); 378 return node; 379 } 380 381 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) {376 virtual const ast::Decl * visit( const ast::TypedefDecl * node ) override final { 377 preprint( node ); 378 return node; 379 } 380 381 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) override final { 382 382 safe_print( node->stmt ); 383 383 return node; 384 384 } 385 385 386 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) {386 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) override final { 387 387 os << "Static Assert with condition: "; 388 388 ++indent; … … 396 396 } 397 397 398 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) {398 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final { 399 399 os << "Compound Statement:" << endl; 400 400 ++indent; … … 404 404 } 405 405 406 virtual const ast::Stmt * visit( const ast::ExprStmt * node ) {406 virtual const ast::Stmt * visit( const ast::ExprStmt * node ) override final { 407 407 ++indent; 408 408 os << "Expression Statement:" << endl << indent; … … 412 412 } 413 413 414 virtual const ast::Stmt * visit( const ast::AsmStmt * node ) {414 virtual const ast::Stmt * visit( const ast::AsmStmt * node ) override final { 415 415 os << "Assembler Statement:" << endl; 416 416 ++indent; … … 433 433 } 434 434 435 virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) {435 virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final { 436 436 os << "GCC Directive: " << node->directive << endl; 437 437 return node; 438 438 } 439 439 440 virtual const ast::Stmt * visit( const ast::IfStmt * node ) {440 virtual const ast::Stmt * visit( const ast::IfStmt * node ) override final { 441 441 os << "If on condition:" << endl; 442 442 ++indent; … … 473 473 } 474 474 475 virtual const ast::Stmt * visit( const ast::WhileStmt * node ) {475 virtual const ast::Stmt * visit( const ast::WhileStmt * node ) override final { 476 476 if ( node->isDoWhile ) { os << "Do-"; } 477 477 os << "While on condition:" << endl; … … 490 490 } 491 491 492 virtual const ast::Stmt * visit( const ast::ForStmt * node ) {492 virtual const ast::Stmt * visit( const ast::ForStmt * node ) override final { 493 493 os << "For Statement" << endl; 494 494 … … 532 532 } 533 533 534 virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) {534 virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) override final { 535 535 os << "Switch on condition: "; 536 536 safe_print( node->cond ); … … 546 546 } 547 547 548 virtual const ast::Stmt * visit( const ast::CaseStmt * node ) {548 virtual const ast::Stmt * visit( const ast::CaseStmt * node ) override final { 549 549 if ( node->isDefault() ) { 550 550 os << indent << "Default "; … … 565 565 } 566 566 567 virtual const ast::Stmt * visit( const ast::BranchStmt * node ) {567 virtual const ast::Stmt * visit( const ast::BranchStmt * node ) override final { 568 568 os << "Branch (" << node->kindName() << ")" << endl; 569 569 ++indent; … … 586 586 } 587 587 588 virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) {588 virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) override final { 589 589 os << "Return Statement, returning"; 590 590 if ( node->expr ) { … … 601 601 } 602 602 603 virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) {603 virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) override final { 604 604 if ( node->target ) os << "Non-Local "; 605 605 … … 621 621 } 622 622 623 virtual const ast::Stmt * visit( const ast::TryStmt * node ) {623 virtual const ast::Stmt * visit( const ast::TryStmt * node ) override final { 624 624 ++indent; 625 625 os << "Try Statement" << endl << indent-1 … … 642 642 } 643 643 644 virtual const ast::Stmt * visit( const ast::CatchStmt * node ) {644 virtual const ast::Stmt * visit( const ast::CatchStmt * node ) override final { 645 645 os << "Catch "; 646 646 switch ( node->kind ) { … … 667 667 } 668 668 669 virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) {669 virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) override final { 670 670 os << "Finally Statement" << endl; 671 671 os << indent << "... with block:" << endl; … … 678 678 } 679 679 680 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) {680 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { 681 681 os << "Waitfor Statement" << endl; 682 682 indent += 2; … … 732 732 } 733 733 734 virtual const ast:: Stmt * visit( const ast::WithStmt * node ){734 virtual const ast::Decl * visit( const ast::WithStmt * node ) override final { 735 735 os << "With statement" << endl; 736 736 os << indent << "... with expressions:" << endl; … … 744 744 } 745 745 746 virtual const ast::NullStmt * visit( const ast::NullStmt * node ) {746 virtual const ast::NullStmt * visit( const ast::NullStmt * node ) override final { 747 747 os << "Null Statement" << endl; 748 748 print( node->labels ); … … 751 751 } 752 752 753 virtual const ast::Stmt * visit( const ast::DeclStmt * node ) {753 virtual const ast::Stmt * visit( const ast::DeclStmt * node ) override final { 754 754 os << "Declaration of "; 755 755 safe_print( node->decl ); … … 758 758 } 759 759 760 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) {760 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final { 761 761 os << "Implicit Ctor Dtor Statement" << endl; 762 762 os << indent << "... with Ctor/Dtor: "; … … 769 769 } 770 770 771 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) {771 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) override final { 772 772 ++indent; 773 773 os << "Application of" << endl << indent; … … 784 784 } 785 785 786 virtual const ast::Expr * visit( const ast::UntypedExpr * node ) {786 virtual const ast::Expr * visit( const ast::UntypedExpr * node ) override final { 787 787 ++indent; 788 788 os << "Applying untyped:" << endl; … … 797 797 } 798 798 799 virtual const ast::Expr * visit( const ast::NameExpr * node ) {799 virtual const ast::Expr * visit( const ast::NameExpr * node ) override final { 800 800 os << "Name: " << node->name; 801 801 postprint( node ); … … 804 804 } 805 805 806 virtual const ast::Expr * visit( const ast::AddressExpr * node ) {806 virtual const ast::Expr * visit( const ast::AddressExpr * node ) override final { 807 807 os << "Address of:" << endl; 808 808 ++indent; … … 815 815 } 816 816 817 virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) {817 virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) override final { 818 818 os << "Address of label:" << node->arg; 819 819 … … 821 821 } 822 822 823 virtual const ast::Expr * visit( const ast::CastExpr * node ) {823 virtual const ast::Expr * visit( const ast::CastExpr * node ) override final { 824 824 ++indent; 825 825 os << (node->isGenerated ? "Generated" : "Explicit") << " cast of:" << endl << indent; … … 841 841 } 842 842 843 virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) {843 virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) override final { 844 844 ++indent; 845 845 os << "Keyword Cast of:" << endl << indent; … … 852 852 } 853 853 854 virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) {854 virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) override final { 855 855 ++indent; 856 856 os << "Virtual Cast of:" << endl << indent; … … 869 869 } 870 870 871 virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) {871 virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) override final { 872 872 ++indent; 873 873 os << "Untyped Member Expression, with field: " << endl << indent; … … 881 881 } 882 882 883 virtual const ast::Expr * visit( const ast::MemberExpr * node ) {883 virtual const ast::Expr * visit( const ast::MemberExpr * node ) override final { 884 884 ++indent; 885 885 os << "Member Expression, with field:" << endl << indent; … … 893 893 } 894 894 895 virtual const ast::Expr * visit( const ast::VariableExpr * node ) {895 virtual const ast::Expr * visit( const ast::VariableExpr * node ) override final { 896 896 os << "Variable Expression: "; 897 897 short_print( node->var ); … … 901 901 } 902 902 903 virtual const ast::Expr * visit( const ast::ConstantExpr * node ) {903 virtual const ast::Expr * visit( const ast::ConstantExpr * node ) override final { 904 904 os << "Constant Expression (" << node->rep; 905 905 if ( node->result ) { … … 913 913 } 914 914 915 virtual const ast::Expr * visit( const ast::SizeofExpr * node ) {915 virtual const ast::Expr * visit( const ast::SizeofExpr * node ) override final { 916 916 os << "Sizeof Expression on: "; 917 917 ++indent; … … 924 924 } 925 925 926 virtual const ast::Expr * visit( const ast::AlignofExpr * node ) {926 virtual const ast::Expr * visit( const ast::AlignofExpr * node ) override final { 927 927 os << "Alignof Expression on: "; 928 928 ++indent; … … 935 935 } 936 936 937 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) {937 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) override final { 938 938 os << "Untyped Offsetof Expression on member " << node->member << " of "; 939 939 ++indent; … … 945 945 } 946 946 947 virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) {947 virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) override final { 948 948 os << "Offsetof Expression on member " << node->member->name << " of "; 949 949 ++indent; … … 955 955 } 956 956 957 virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) {957 virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) override final { 958 958 os << "Offset Pack Expression on: "; 959 959 ++indent; … … 965 965 } 966 966 967 virtual const ast::Expr * visit( const ast::LogicalExpr * node ) {967 virtual const ast::Expr * visit( const ast::LogicalExpr * node ) override final { 968 968 os << "Short-circuited operation (" << (node->isAnd ? "and" : "or") << ") on: "; 969 969 safe_print( node->arg1 ); … … 975 975 } 976 976 977 virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) {977 virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) override final { 978 978 ++indent; 979 979 os << "Conditional expression on:" << endl << indent; … … 989 989 } 990 990 991 virtual const ast::Expr * visit( const ast::CommaExpr * node ) {991 virtual const ast::Expr * visit( const ast::CommaExpr * node ) override final { 992 992 ++indent; 993 993 os << "Comma Expression:" << endl << indent; … … 1001 1001 } 1002 1002 1003 virtual const ast::Expr * visit( const ast::TypeExpr * node ) {1003 virtual const ast::Expr * visit( const ast::TypeExpr * node ) override final { 1004 1004 safe_print( node->type ); 1005 1005 postprint( node ); … … 1008 1008 } 1009 1009 1010 virtual const ast::Expr * visit( const ast::AsmExpr * node ) {1010 virtual const ast::Expr * visit( const ast::AsmExpr * node ) override final { 1011 1011 os << "Asm Expression:" << endl; 1012 1012 ++indent; … … 1019 1019 } 1020 1020 1021 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) {1021 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) override final { 1022 1022 ++indent; 1023 1023 os << "Implicit Copy Constructor Expression:" << endl << indent; … … 1029 1029 } 1030 1030 1031 virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) {1031 virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) override final { 1032 1032 os << "Constructor Expression:" << endl << indent+1; 1033 1033 indent += 2; … … 1039 1039 } 1040 1040 1041 virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) {1041 virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) override final { 1042 1042 ++indent; 1043 1043 os << "Compound Literal Expression: " << endl << indent; … … 1051 1051 } 1052 1052 1053 virtual const ast::Expr * visit( const ast::RangeExpr * node ) {1053 virtual const ast::Expr * visit( const ast::RangeExpr * node ) override final { 1054 1054 os << "Range Expression: "; 1055 1055 safe_print( node->low ); … … 1061 1061 } 1062 1062 1063 virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) {1063 virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) override final { 1064 1064 os << "Untyped Tuple:" << endl; 1065 1065 ++indent; … … 1071 1071 } 1072 1072 1073 virtual const ast::Expr * visit( const ast::TupleExpr * node ) {1073 virtual const ast::Expr * visit( const ast::TupleExpr * node ) override final { 1074 1074 os << "Tuple:" << endl; 1075 1075 ++indent; … … 1081 1081 } 1082 1082 1083 virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) {1083 virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) override final { 1084 1084 os << "Tuple Index Expression, with tuple:" << endl; 1085 1085 ++indent; … … 1093 1093 } 1094 1094 1095 virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) {1095 virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) override final { 1096 1096 os << "Tuple Assignment Expression, with stmt expr:" << endl; 1097 1097 ++indent; … … 1104 1104 } 1105 1105 1106 virtual const ast::Expr * visit( const ast::StmtExpr * node ) {1106 virtual const ast::Expr * visit( const ast::StmtExpr * node ) override final { 1107 1107 ++indent; 1108 1108 os << "Statement Expression:" << endl << indent; … … 1122 1122 } 1123 1123 1124 virtual const ast::Expr * visit( const ast::UniqueExpr * node ) {1124 virtual const ast::Expr * visit( const ast::UniqueExpr * node ) override final { 1125 1125 ++indent; 1126 1126 os << "Unique Expression with id: " << node->id << endl << indent; … … 1136 1136 } 1137 1137 1138 virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) {1138 virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) override final { 1139 1139 ++indent; 1140 1140 os << "Untyped Init Expression" << endl << indent; … … 1152 1152 } 1153 1153 1154 virtual const ast::Expr * visit( const ast::InitExpr * node ) {1154 virtual const ast::Expr * visit( const ast::InitExpr * node ) override final { 1155 1155 ++indent; 1156 1156 os << "Init Expression" << endl << indent; … … 1163 1163 } 1164 1164 1165 virtual const ast::Expr * visit( const ast::DeletedExpr * node ) {1165 virtual const ast::Expr * visit( const ast::DeletedExpr * node ) override final { 1166 1166 ++indent; 1167 1167 os << "Deleted Expression" << endl << indent; … … 1174 1174 } 1175 1175 1176 virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) {1176 virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) override final { 1177 1177 ++indent; 1178 1178 os << "Default Argument Expression" << endl << indent; … … 1183 1183 } 1184 1184 1185 virtual const ast::Expr * visit( const ast::GenericExpr * node ) {1185 virtual const ast::Expr * visit( const ast::GenericExpr * node ) override final { 1186 1186 ++indent; 1187 1187 os << "C11 _Generic Expression" << endl << indent; … … 1206 1206 } 1207 1207 1208 virtual const ast::Type * visit( const ast::VoidType * node ) {1208 virtual const ast::Type * visit( const ast::VoidType * node ) override final { 1209 1209 preprint( node ); 1210 1210 os << "void"; … … 1212 1212 } 1213 1213 1214 virtual const ast::Type * visit( const ast::BasicType * node ) {1214 virtual const ast::Type * visit( const ast::BasicType * node ) override final { 1215 1215 preprint( node ); 1216 1216 os << ast::BasicType::typeNames[ node->kind ]; … … 1218 1218 } 1219 1219 1220 virtual const ast::Type * visit( const ast::PointerType * node ) {1220 virtual const ast::Type * visit( const ast::PointerType * node ) override final { 1221 1221 preprint( node ); 1222 1222 if ( ! node->isArray() ) { … … 1241 1241 } 1242 1242 1243 virtual const ast::Type * visit( const ast::ArrayType * node ) {1243 virtual const ast::Type * visit( const ast::ArrayType * node ) override final { 1244 1244 preprint( node ); 1245 1245 if ( node->isStatic ) { … … 1265 1265 } 1266 1266 1267 virtual const ast::Type * visit( const ast::ReferenceType * node ) {1267 virtual const ast::Type * visit( const ast::ReferenceType * node ) override final { 1268 1268 preprint( node ); 1269 1269 os << "reference to "; … … 1273 1273 } 1274 1274 1275 virtual const ast::Type * visit( const ast::QualifiedType * node ) {1275 virtual const ast::Type * visit( const ast::QualifiedType * node ) override final { 1276 1276 preprint( node ); 1277 1277 ++indent; … … 1286 1286 } 1287 1287 1288 virtual const ast::Type * visit( const ast::FunctionType * node ) {1288 virtual const ast::Type * visit( const ast::FunctionType * node ) override final { 1289 1289 preprint( node ); 1290 1290 … … 1315 1315 } 1316 1316 1317 virtual const ast::Type * visit( const ast::StructInstType * node ) {1317 virtual const ast::Type * visit( const ast::StructInstType * node ) override final { 1318 1318 preprint( node ); 1319 1319 os << "instance of struct " << node->name; … … 1326 1326 } 1327 1327 1328 virtual const ast::Type * visit( const ast::UnionInstType * node ) {1328 virtual const ast::Type * visit( const ast::UnionInstType * node ) override final { 1329 1329 preprint( node ); 1330 1330 os << "instance of union " << node->name; … … 1337 1337 } 1338 1338 1339 virtual const ast::Type * visit( const ast::EnumInstType * node ) {1339 virtual const ast::Type * visit( const ast::EnumInstType * node ) override final { 1340 1340 preprint( node ); 1341 1341 os << "instance of enum " << node->name; … … 1348 1348 } 1349 1349 1350 virtual const ast::Type * visit( const ast::TraitInstType * node ) {1350 virtual const ast::Type * visit( const ast::TraitInstType * node ) override final { 1351 1351 preprint( node ); 1352 1352 os << "instance of trait " << node->name; … … 1356 1356 } 1357 1357 1358 virtual const ast::Type * visit( const ast::TypeInstType * node ) {1358 virtual const ast::Type * visit( const ast::TypeInstType * node ) override final { 1359 1359 preprint( node ); 1360 1360 os << "instance of type " << node->name … … 1365 1365 } 1366 1366 1367 virtual const ast::Type * visit( const ast::TupleType * node ) {1367 virtual const ast::Type * visit( const ast::TupleType * node ) override final { 1368 1368 preprint( node ); 1369 1369 os << "tuple of types" << endl; … … 1375 1375 } 1376 1376 1377 virtual const ast::Type * visit( const ast::TypeofType * node ) {1377 virtual const ast::Type * visit( const ast::TypeofType * node ) override final { 1378 1378 preprint( node ); 1379 1379 if ( node->kind == ast::TypeofType::Basetypeof ) { os << "base-"; } … … 1384 1384 } 1385 1385 1386 virtual const ast::Type * visit( const ast::VarArgsType * node ) {1386 virtual const ast::Type * visit( const ast::VarArgsType * node ) override final { 1387 1387 preprint( node ); 1388 1388 os << "builtin var args pack"; … … 1390 1390 } 1391 1391 1392 virtual const ast::Type * visit( const ast::ZeroType * node ) {1392 virtual const ast::Type * visit( const ast::ZeroType * node ) override final { 1393 1393 preprint( node ); 1394 1394 os << "zero_t"; … … 1396 1396 } 1397 1397 1398 virtual const ast::Type * visit( const ast::OneType * node ) {1398 virtual const ast::Type * visit( const ast::OneType * node ) override final { 1399 1399 preprint( node ); 1400 1400 os << "one_t"; … … 1402 1402 } 1403 1403 1404 virtual const ast::Type * visit( const ast::GlobalScopeType * node ) {1404 virtual const ast::Type * visit( const ast::GlobalScopeType * node ) override final { 1405 1405 preprint( node ); 1406 1406 os << "Global Scope Type"; … … 1408 1408 } 1409 1409 1410 virtual const ast::Designation * visit( const ast::Designation * node ) {1410 virtual const ast::Designation * visit( const ast::Designation * node ) override final { 1411 1411 if ( node->designators.empty() ) return node; 1412 1412 os << "... designated by: " << endl; … … 1421 1421 } 1422 1422 1423 virtual const ast::Init * visit( const ast::SingleInit * node ) {1423 virtual const ast::Init * visit( const ast::SingleInit * node ) override final { 1424 1424 os << "Simple Initializer: "; 1425 1425 safe_print( node->value ); … … 1427 1427 } 1428 1428 1429 virtual const ast::Init * visit( const ast::ListInit * node ) {1429 virtual const ast::Init * visit( const ast::ListInit * node ) override final { 1430 1430 os << "Compound initializer: " << endl; 1431 1431 ++indent; … … 1445 1445 } 1446 1446 1447 virtual const ast::Init * visit( const ast::ConstructorInit * node ) {1447 virtual const ast::Init * visit( const ast::ConstructorInit * node ) override final { 1448 1448 os << "Constructor initializer: " << endl; 1449 1449 if ( node->ctor ) { … … 1470 1470 } 1471 1471 1472 virtual const ast::Attribute * visit( const ast::Attribute * node ) {1472 virtual const ast::Attribute * visit( const ast::Attribute * node ) override final { 1473 1473 if ( node->empty() ) return node; 1474 1474 os << "Attribute with name: " << node->name; … … 1481 1481 } 1482 1482 1483 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) {1483 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) override final { 1484 1484 os << indent << "Types:" << endl; 1485 1485 for ( const auto& i : *node ) { -
src/AST/Stmt.hpp
r1f1c102 rf53acdf8 380 380 }; 381 381 382 /// With statement `with (...) ...`383 class WithStmt final : public Stmt {384 public:385 std::vector<ptr<Expr>> exprs;386 ptr<Stmt> stmt;387 388 WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt,389 std::vector<Label> && labels = {} )390 : Stmt(loc, std::move(labels)), exprs(std::move(exprs)), stmt(stmt) {}391 392 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }393 private:394 WithStmt * clone() const override { return new WithStmt{ *this }; }395 MUTATE_FRIEND396 };397 398 382 /// Any declaration in a (compound) statement. 399 383 class DeclStmt final : public Stmt { -
src/AST/SymbolTable.cpp
r1f1c102 rf53acdf8 73 73 74 74 SymbolTable::SymbolTable() 75 : idTable(), typeTable(), structTable(), enumTable(), unionTable(), traitTable(), 75 : idTable(), typeTable(), structTable(), enumTable(), unionTable(), traitTable(), 76 76 prevScope(), scope( 0 ), repScope( 0 ) { ++*stats().count; } 77 77 … … 171 171 } 172 172 173 void SymbolTable::addDeletedId( const DeclWithType * decl, const Node* deleter ) {173 void SymbolTable::addDeletedId( const DeclWithType * decl, const Decl * deleter ) { 174 174 // default handling of conflicts is to raise an error 175 175 addId( decl, OnConflict::error(), nullptr, deleter ); … … 189 189 } 190 190 } 191 // does not need to be added to the table if both existing and added have a base that are 191 // does not need to be added to the table if both existing and added have a base that are 192 192 // the same 193 193 return true; … … 209 209 const std::string &id = decl->name; 210 210 211 if ( ! typeTable ) { 211 if ( ! typeTable ) { 212 212 typeTable = TypeTable::new_ptr(); 213 213 } else { 214 214 ++*stats().map_lookups; 215 215 auto existing = typeTable->find( id ); 216 if ( existing != typeTable->end() 217 && existing->second.scope == scope 216 if ( existing != typeTable->end() 217 && existing->second.scope == scope 218 218 && addedTypeConflicts( existing->second.decl, decl ) ) return; 219 219 } 220 220 221 221 lazyInitScope(); 222 222 ++*stats().map_mutations; … … 237 237 ++*stats().map_lookups; 238 238 auto existing = structTable->find( id ); 239 if ( existing != structTable->end() 240 && existing->second.scope == scope 239 if ( existing != structTable->end() 240 && existing->second.scope == scope 241 241 && addedDeclConflicts( existing->second.decl, decl ) ) return; 242 242 } … … 256 256 ++*stats().map_lookups; 257 257 auto existing = enumTable->find( id ); 258 if ( existing != enumTable->end() 259 && existing->second.scope == scope 258 if ( existing != enumTable->end() 259 && existing->second.scope == scope 260 260 && addedDeclConflicts( existing->second.decl, decl ) ) return; 261 261 } 262 262 263 263 lazyInitScope(); 264 264 ++*stats().map_mutations; … … 279 279 ++*stats().map_lookups; 280 280 auto existing = unionTable->find( id ); 281 if ( existing != unionTable->end() 282 && existing->second.scope == scope 281 if ( existing != unionTable->end() 282 && existing->second.scope == scope 283 283 && addedDeclConflicts( existing->second.decl, decl ) ) return; 284 284 } … … 298 298 ++*stats().map_lookups; 299 299 auto existing = traitTable->find( id ); 300 if ( existing != traitTable->end() 301 && existing->second.scope == scope 300 if ( existing != traitTable->end() 301 && existing->second.scope == scope 302 302 && addedDeclConflicts( existing->second.decl, decl ) ) return; 303 303 } … … 309 309 310 310 311 void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Node* withStmt ) {311 void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt ) { 312 312 for ( const Expr * expr : withExprs ) { 313 313 if ( ! expr->result ) continue; 314 314 const Type * resTy = expr->result->stripReferences(); 315 315 auto aggrType = dynamic_cast< const ReferenceToType * >( resTy ); 316 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 316 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 317 317 toString( expr->result ).c_str() ); 318 318 const AggregateDecl * aggr = aggrType->aggr(); 319 assertf( aggr, "WithStmt has null aggregate from type: %s", 319 assertf( aggr, "WithStmt has null aggregate from type: %s", 320 320 toString( expr->result ).c_str() ); 321 321 322 322 addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) ); 323 323 } … … 373 373 } 374 374 375 /// gets the declaration for the function acting on a type specified by otype key, 375 /// gets the declaration for the function acting on a type specified by otype key, 376 376 /// nullptr if none such 377 const FunctionDecl * getFunctionForOtype( 377 const FunctionDecl * getFunctionForOtype( 378 378 const DeclWithType * decl, const std::string & otypeKey ) { 379 379 auto func = dynamic_cast< const FunctionDecl * >( decl ); … … 383 383 } 384 384 385 bool SymbolTable::removeSpecialOverrides( 385 bool SymbolTable::removeSpecialOverrides( 386 386 SymbolTable::IdData & data, SymbolTable::MangleTable::Ptr & mangleTable ) { 387 // if a type contains user defined ctor/dtor/assign, then special rules trigger, which 388 // determine the set of ctor/dtor/assign that can be used by the requester. In particular, 389 // if the user defines a default ctor, then the generated default ctor is unavailable, 390 // likewise for copy ctor and dtor. If the user defines any ctor/dtor, then no generated 391 // field ctors are available. If the user defines any ctor then the generated default ctor 392 // is unavailable (intrinsic default ctor must be overridden exactly). If the user defines 393 // anything that looks like a copy constructor, then the generated copy constructor is 387 // if a type contains user defined ctor/dtor/assign, then special rules trigger, which 388 // determine the set of ctor/dtor/assign that can be used by the requester. In particular, 389 // if the user defines a default ctor, then the generated default ctor is unavailable, 390 // likewise for copy ctor and dtor. If the user defines any ctor/dtor, then no generated 391 // field ctors are available. If the user defines any ctor then the generated default ctor 392 // is unavailable (intrinsic default ctor must be overridden exactly). If the user defines 393 // anything that looks like a copy constructor, then the generated copy constructor is 394 394 // unavailable, and likewise for the assignment operator. 395 395 … … 450 450 // if this is the first user-defined function, delete non-user-defined overloads 451 451 std::vector< MangleTable::value_type > deleted; 452 452 453 453 for ( const auto& entry : *mangleTable ) { 454 454 // skip decls that aren't functions or are for the wrong type … … 489 489 if ( dataIsCopyFunc ) { 490 490 // remove current function if exists a user-defined copy function 491 // since the signatures for copy functions don't need to match exactly, using 491 // since the signatures for copy functions don't need to match exactly, using 492 492 // a delete statement is the wrong approach 493 493 if ( InitTweak::isCopyFunction( decl ) ) return false; … … 499 499 } 500 500 } 501 501 502 502 // nothing (more) to fix, return true 503 503 return true; … … 525 525 526 526 bool SymbolTable::addedIdConflicts( 527 const SymbolTable::IdData & existing, const DeclWithType * added, 528 SymbolTable::OnConflict handleConflicts, const Node* deleter ) {529 // if we're giving the same name mangling to things of different types then there is something 527 const SymbolTable::IdData & existing, const DeclWithType * added, 528 SymbolTable::OnConflict handleConflicts, const Decl * deleter ) { 529 // if we're giving the same name mangling to things of different types then there is something 530 530 // wrong 531 531 assert( (isObject( added ) && isObject( existing.id ) ) 532 532 || ( isFunction( added ) && isFunction( existing.id ) ) ); 533 533 534 534 if ( existing.id->linkage.is_overrideable ) { 535 535 // new definition shadows the autogenerated one, even at the same scope 536 536 return false; 537 } else if ( existing.id->linkage.is_mangled 538 || ResolvExpr::typesCompatible( 537 } else if ( existing.id->linkage.is_mangled 538 || ResolvExpr::typesCompatible( 539 539 added->get_type(), existing.id->get_type(), SymbolTable{} ) ) { 540 540 541 541 // it is a conflict if one declaration is deleted and the other is not 542 542 if ( deleter && ! existing.deleter ) { … … 555 555 if ( isDefinition( added ) && isDefinition( existing.id ) ) { 556 556 if ( handleConflicts.mode == OnConflict::Error ) { 557 SemanticError( added, 558 isFunction( added ) ? 559 "duplicate function definition for " : 557 SemanticError( added, 558 isFunction( added ) ? 559 "duplicate function definition for " : 560 560 "duplicate object definition for " ); 561 561 } … … 572 572 } 573 573 574 void SymbolTable::addId( 575 const DeclWithType * decl, SymbolTable::OnConflict handleConflicts, const Expr * baseExpr, 576 const Node* deleter ) {574 void SymbolTable::addId( 575 const DeclWithType * decl, SymbolTable::OnConflict handleConflicts, const Expr * baseExpr, 576 const Decl * deleter ) { 577 577 ++*stats().add_calls; 578 578 const std::string &name = decl->name; … … 581 581 std::string mangleName; 582 582 if ( decl->linkage.is_overrideable ) { 583 // mangle the name without including the appropriate suffix, so overridable routines 583 // mangle the name without including the appropriate suffix, so overridable routines 584 584 // are placed into the same "bucket" as their user defined versions. 585 585 mangleName = Mangle::mangle( decl, Mangle::Mode{ Mangle::NoOverrideable } ); … … 588 588 } 589 589 590 // this ensures that no two declarations with the same unmangled name at the same scope 590 // this ensures that no two declarations with the same unmangled name at the same scope 591 591 // both have C linkage 592 592 if ( decl->linkage.is_mangled ) { … … 596 596 } 597 597 } else { 598 // NOTE: only correct if name mangling is completely isomorphic to C 598 // NOTE: only correct if name mangling is completely isomorphic to C 599 599 // type-compatibility, which it may not be. 600 600 if ( hasIncompatibleCDecl( name, mangleName ) ) { … … 628 628 idTable = idTable->set( 629 629 name, 630 mangleTable->set( 631 mangleName, 630 mangleTable->set( 631 mangleName, 632 632 IdData{ existing->second, handleConflicts.deleter } ) ); 633 633 } … … 647 647 } 648 648 649 void SymbolTable::addMembers( 649 void SymbolTable::addMembers( 650 650 const AggregateDecl * aggr, const Expr * expr, SymbolTable::OnConflict handleConflicts ) { 651 651 for ( const Decl * decl : aggr->members ) { … … 655 655 const Type * t = dwt->get_type()->stripReferences(); 656 656 if ( auto rty = dynamic_cast<const ReferenceToType *>( t ) ) { 657 if ( ! dynamic_cast<const StructInstType *>(rty) 657 if ( ! dynamic_cast<const StructInstType *>(rty) 658 658 && ! dynamic_cast<const UnionInstType *>(rty) ) continue; 659 659 ResolvExpr::Cost cost = ResolvExpr::Cost::zero; 660 660 const Expr * base = ResolvExpr::referenceToRvalueConversion( expr, cost ); 661 addMembers( 661 addMembers( 662 662 rty->aggr(), new MemberExpr{ base->location, dwt, base }, handleConflicts ); 663 663 } … … 680 680 if ( ! decl.second.id->linkage.is_mangled && decl.first == mangleName ) return true; 681 681 } 682 682 683 683 return false; 684 684 } -
src/AST/SymbolTable.hpp
r1f1c102 rf53acdf8 37 37 readonly<DeclWithType> id = nullptr; ///< Identifier of declaration 38 38 readonly<Expr> baseExpr = nullptr; ///< Implied containing aggregate (from WithExpr) 39 readonly< Node> deleter = nullptr; ///< Node deleting this declaration (if non-null)39 readonly<Decl> deleter = nullptr; ///< Node deleting this declaration (if non-null) 40 40 unsigned long scope = 0; ///< Scope of identifier 41 41 42 42 IdData() = default; 43 IdData( const DeclWithType * i, const Expr * base, const Node * del, unsigned long s )43 IdData( const DeclWithType * i, const Expr * base, const Decl * del, unsigned long s ) 44 44 : id( i ), baseExpr( base ), deleter( del ), scope( s ) {} 45 45 46 46 /// Modify an existing node with a new deleter 47 IdData( const IdData & o, const Node* del )47 IdData( const IdData & o, const Decl * del ) 48 48 : id( o.id ), baseExpr( o.baseExpr ), deleter( del ), scope( o.scope ) {} 49 49 … … 58 58 struct scoped { 59 59 readonly<D> decl; ///< wrapped declaration 60 unsigned long scope; ///< scope of this declaration 60 unsigned long scope; ///< scope of this declaration 61 61 62 62 scoped(const D * d, unsigned long s) : decl(d), scope(s) {} … … 88 88 ~SymbolTable(); 89 89 90 // when using an indexer manually (e.g., within a mutator traversal), it is necessary to 90 // when using an indexer manually (e.g., within a mutator traversal), it is necessary to 91 91 // tell the indexer explicitly when scopes begin and end 92 92 void enterScope(); … … 118 118 void addId( const DeclWithType * decl, const Expr * baseExpr = nullptr ); 119 119 /// Adds a deleted identifier declaration to the symbol table 120 void addDeletedId( const DeclWithType * decl, const Node* deleter );120 void addDeletedId( const DeclWithType * decl, const Decl * deleter ); 121 121 122 122 /// Adds a type to the symbol table … … 136 136 137 137 /// adds all of the IDs from WithStmt exprs 138 void addWith( const std::vector< ptr<Expr> > & withExprs, const Node* withStmt );138 void addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt ); 139 139 140 140 /// convenience function for adding a list of Ids to the indexer … … 154 154 const SymbolTable * atScope( unsigned long i ) const; 155 155 156 /// Removes matching autogenerated constructors and destructors so that they will not be 156 /// Removes matching autogenerated constructors and destructors so that they will not be 157 157 /// selected. If returns false, passed decl should not be added. 158 158 bool removeSpecialOverrides( IdData & decl, MangleTable::Ptr & mangleTable ); … … 164 164 Delete ///< Delete the earlier version with the delete statement 165 165 } mode; 166 const Node* deleter; ///< Statement that deletes this expression166 const Decl * deleter; ///< Statement that deletes this expression 167 167 168 168 private: 169 169 OnConflict() : mode(Error), deleter(nullptr) {} 170 OnConflict( const Node* d ) : mode(Delete), deleter(d) {}170 OnConflict( const Decl * d ) : mode(Delete), deleter(d) {} 171 171 public: 172 172 OnConflict( const OnConflict& ) = default; 173 173 174 174 static OnConflict error() { return {}; } 175 static OnConflict deleteWith( const Node* d ) { return { d }; }175 static OnConflict deleteWith( const Decl * d ) { return { d }; } 176 176 }; 177 177 178 178 /// true if the existing identifier conflicts with the added identifier 179 179 bool addedIdConflicts( 180 const IdData & existing, const DeclWithType * added, OnConflict handleConflicts, 181 const Node* deleter );180 const IdData & existing, const DeclWithType * added, OnConflict handleConflicts, 181 const Decl * deleter ); 182 182 183 183 /// common code for addId, addDeletedId, etc. 184 void addId( 185 const DeclWithType * decl, OnConflict handleConflicts, const Expr * baseExpr = nullptr, 186 const Node* deleter = nullptr );184 void addId( 185 const DeclWithType * decl, OnConflict handleConflicts, const Expr * baseExpr = nullptr, 186 const Decl * deleter = nullptr ); 187 187 188 188 /// adds all of the members of the Aggregate (addWith helper) -
src/AST/Type.hpp
r1f1c102 rf53acdf8 35 35 36 36 template< typename T > class Pass; 37 class ForallSubstitutor; 37 38 struct ForallSubstitutor; 38 39 39 40 class Type : public Node { … … 167 168 static const char *typeNames[]; 168 169 169 BasicType( Kind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 170 BasicType( Kind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 170 171 : Type(q, std::move(as)), kind(k) {} 171 172 … … 274 275 public: 275 276 using ForallList = std::vector<ptr<TypeDecl>>; 276 277 277 278 ForallList forall; 278 279 … … 338 339 bool hoistType = false; 339 340 340 ReferenceToType( 341 ReferenceToType( 341 342 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 342 343 : ParameterizedType(q, std::move(as)), params(), name(n) {} … … 359 360 readonly<StructDecl> base; 360 361 361 StructInstType( 362 StructInstType( 362 363 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 363 364 : ReferenceToType( n, q, std::move(as) ), base() {} 364 365 365 StructInstType( 366 StructInstType( 366 367 const StructDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 367 368 … … 381 382 readonly<UnionDecl> base; 382 383 383 UnionInstType( 384 UnionInstType( 384 385 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 385 386 : ReferenceToType( n, q, std::move(as) ), base() {} 386 387 387 UnionInstType( 388 UnionInstType( 388 389 const UnionDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 389 390 … … 403 404 readonly<EnumDecl> base; 404 405 405 EnumInstType( 406 EnumInstType( 406 407 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 407 408 : ReferenceToType( n, q, std::move(as) ), base() {} 408 409 409 EnumInstType( 410 EnumInstType( 410 411 const EnumDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 411 412 … … 425 426 readonly<TraitDecl> base; 426 427 427 TraitInstType( 428 TraitInstType( 428 429 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 429 430 : ReferenceToType( n, q, std::move(as) ), base() {} 430 431 TraitInstType( 431 432 TraitInstType( 432 433 const TraitDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 433 434 … … 449 450 TypeVar::Kind kind; 450 451 451 TypeInstType( 452 TypeInstType( 452 453 const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 453 454 std::vector<ptr<Attribute>> && as = {} ) 454 455 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 455 456 TypeInstType( 456 457 TypeInstType( 457 458 const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 458 459 std::vector<ptr<Attribute>> && as = {} ) -
src/AST/Visitor.hpp
r1f1c102 rf53acdf8 48 48 virtual const ast::Stmt * visit( const ast::FinallyStmt * ) = 0; 49 49 virtual const ast::Stmt * visit( const ast::WaitForStmt * ) = 0; 50 virtual const ast:: Stmt* visit( const ast::WithStmt * ) = 0;50 virtual const ast::Decl * visit( const ast::WithStmt * ) = 0; 51 51 virtual const ast::NullStmt * visit( const ast::NullStmt * ) = 0; 52 52 virtual const ast::Stmt * visit( const ast::DeclStmt * ) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.