- Timestamp:
- Apr 19, 2022, 3:00:04 PM (4 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 5b84a321
- Parents:
- ba897d21 (diff), bb7c77d (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:
-
- 19 edited
-
Convert.cpp (modified) (25 diffs)
-
Decl.cpp (modified) (2 diffs)
-
Decl.hpp (modified) (2 diffs)
-
Expr.hpp (modified) (1 diff)
-
Fwd.hpp (modified) (3 diffs)
-
GenericSubstitution.cpp (modified) (1 diff)
-
Node.cpp (modified) (5 diffs)
-
Node.hpp (modified) (6 diffs)
-
Pass.hpp (modified) (2 diffs)
-
Pass.impl.hpp (modified) (13 diffs)
-
Pass.proto.hpp (modified) (3 diffs)
-
Print.cpp (modified) (7 diffs)
-
Stmt.hpp (modified) (6 diffs)
-
TranslationUnit.hpp (modified) (2 diffs)
-
Type.cpp (modified) (1 diff)
-
Type.hpp (modified) (1 diff)
-
TypeSubstitution.hpp (modified) (4 diffs)
-
Util.cpp (modified) (2 diffs)
-
Visitor.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rba897d21 r2e9b59b 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 ); 314 return aggregatePostamble( decl, node ); 309 LinkageSpec::Spec( node->linkage.val ), 310 get<Type>().accept1(node->base) 311 ); 312 return aggregatePostamble( decl, node ); // Node info, including members, processed in aggregatePostamble 315 313 } 316 314 … … 354 352 this->node = stmt; 355 353 return nullptr; 354 } 355 356 void clausePostamble( Statement * stmt, const ast::StmtClause * node ) { 357 stmt->location = node->location; 358 this->node = stmt; 356 359 } 357 360 … … 404 407 auto stmt = new SwitchStmt( 405 408 get<Expression>().accept1( node->cond ), 406 get<Statement>().acceptL( node-> stmts )409 get<Statement>().acceptL( node->cases ) 407 410 ); 408 411 return stmtPostamble( stmt, node ); 409 412 } 410 413 411 const ast:: Stmt * visit( const ast::CaseStmt* node ) override final {414 const ast::CaseClause * visit( const ast::CaseClause * node ) override final { 412 415 if ( inCache( node ) ) return nullptr; 413 416 auto stmt = new CaseStmt( … … 416 419 node->isDefault() 417 420 ); 418 return stmtPostamble( stmt, node ); 421 clausePostamble( stmt, node ); 422 return nullptr; 419 423 } 420 424 … … 512 516 } 513 517 514 const ast:: Stmt * visit( const ast::CatchStmt* node ) override final {518 const ast::CatchClause * visit( const ast::CatchClause * node ) override final { 515 519 if ( inCache( node ) ) return nullptr; 516 520 CatchStmt::Kind kind; … … 523 527 break; 524 528 default: 525 assertf(false, "Invalid ast:: CatchStmt::Kind: %d\n", node->kind);529 assertf(false, "Invalid ast::ExceptionKind: %d\n", node->kind); 526 530 } 527 531 auto stmt = new CatchStmt( … … 531 535 get<Statement>().accept1( node->body ) 532 536 ); 533 return stmtPostamble( stmt, node );534 } 535 536 const ast:: Stmt * visit( const ast::FinallyStmt* node ) override final {537 return clausePostamble( stmt, node ), nullptr; 538 } 539 540 const ast::FinallyClause * visit( const ast::FinallyClause * node ) override final { 537 541 if ( inCache( node ) ) return nullptr; 538 542 auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) ); 539 return stmtPostamble( stmt, node );543 return clausePostamble( stmt, node ), nullptr; 540 544 } 541 545 … … 947 951 } 948 952 953 const ast::Expr * visit( const ast::DimensionExpr * node ) override final { 954 auto expr = visitBaseExpr( node, new DimensionExpr( node->name ) ); 955 this->node = expr; 956 return nullptr; 957 } 958 949 959 const ast::Expr * visit( const ast::AsmExpr * node ) override final { 950 960 auto expr = visitBaseExpr( node, … … 1467 1477 return strict_dynamic_cast< ast::Decl * >( node ); 1468 1478 } 1469 1479 1470 1480 ConverterOldToNew() = default; 1471 1481 ConverterOldToNew(const ConverterOldToNew &) = delete; … … 1495 1505 getAccept1< ast::type, decltype( old->child ) >( old->child ) 1496 1506 1507 1497 1508 template<typename NewT, typename OldC> 1498 1509 std::vector< ast::ptr<NewT> > getAcceptV( const OldC& old ) { … … 1509 1520 # define GET_ACCEPT_V(child, type) \ 1510 1521 getAcceptV< ast::type, decltype( old->child ) >( old->child ) 1522 1523 # define GET_ACCEPT_E(child, type) \ 1524 getAccept1< ast::type, decltype( old->base ) >( old->base ) 1511 1525 1512 1526 template<typename NewT, typename OldC> … … 1710 1724 } 1711 1725 1726 // Convert SynTree::EnumDecl to AST::EnumDecl 1712 1727 virtual void visit( const EnumDecl * old ) override final { 1713 1728 if ( inCache( old ) ) return; … … 1716 1731 old->name, 1717 1732 GET_ACCEPT_V(attributes, Attribute), 1718 { old->linkage.val } 1733 { old->linkage.val }, 1734 GET_ACCEPT_1(base, Type), 1735 old->enumValues 1719 1736 ); 1720 1737 cache.emplace( old, decl ); … … 1726 1743 decl->uniqueId = old->uniqueId; 1727 1744 decl->storage = { old->storageClasses.val }; 1728 1729 1745 this->node = decl; 1730 1746 } … … 1887 1903 old->location, 1888 1904 GET_ACCEPT_1(condition, Expr), 1889 GET_ACCEPT_V(statements, Stmt),1905 GET_ACCEPT_V(statements, CaseClause), 1890 1906 GET_LABELS_V(old->labels) 1891 1907 ); … … 1895 1911 virtual void visit( const CaseStmt * old ) override final { 1896 1912 if ( inCache( old ) ) return; 1897 this->node = new ast::Case Stmt(1913 this->node = new ast::CaseClause( 1898 1914 old->location, 1899 1915 GET_ACCEPT_1(condition, Expr), 1900 GET_ACCEPT_V(stmts, Stmt), 1901 GET_LABELS_V(old->labels) 1902 ); 1916 GET_ACCEPT_V(stmts, Stmt) 1917 ); 1918 auto labels = GET_LABELS_V(old->labels); 1919 assertf(labels.empty(), "Labels found on CaseStmt."); 1903 1920 cache.emplace( old, this->node ); 1904 1921 } … … 2008 2025 old->location, 2009 2026 GET_ACCEPT_1(block, CompoundStmt), 2010 GET_ACCEPT_V(handlers, Catch Stmt),2011 GET_ACCEPT_1(finallyBlock, Finally Stmt),2027 GET_ACCEPT_V(handlers, CatchClause), 2028 GET_ACCEPT_1(finallyBlock, FinallyClause), 2012 2029 GET_LABELS_V(old->labels) 2013 2030 ); … … 2029 2046 } 2030 2047 2031 this->node = new ast::Catch Stmt(2048 this->node = new ast::CatchClause( 2032 2049 old->location, 2033 2050 kind, 2034 2051 GET_ACCEPT_1(decl, Decl), 2035 2052 GET_ACCEPT_1(cond, Expr), 2036 GET_ACCEPT_1(body, Stmt), 2037 GET_LABELS_V(old->labels) 2038 ); 2053 GET_ACCEPT_1(body, Stmt) 2054 ); 2055 auto labels = GET_LABELS_V(old->labels); 2056 assertf(labels.empty(), "Labels found on CatchStmt."); 2039 2057 cache.emplace( old, this->node ); 2040 2058 } … … 2042 2060 virtual void visit( const FinallyStmt * old ) override final { 2043 2061 if ( inCache( old ) ) return; 2044 this->node = new ast::FinallyStmt( 2045 old->location, 2046 GET_ACCEPT_1(block, CompoundStmt), 2047 GET_LABELS_V(old->labels) 2048 ); 2062 this->node = new ast::FinallyClause( 2063 old->location, 2064 GET_ACCEPT_1(block, CompoundStmt) 2065 ); 2066 auto labels = GET_LABELS_V(old->labels); 2067 assertf(labels.empty(), "Labels found on FinallyStmt."); 2049 2068 cache.emplace( old, this->node ); 2050 2069 } … … 2450 2469 2451 2470 virtual void visit( const DimensionExpr * old ) override final { 2452 // DimensionExpr gets desugared away in Validate. 2453 // As long as new-AST passes don't use it, this cheap-cheerful error 2454 // detection helps ensure that these occurrences have been compiled 2455 // away, as expected. To move the DimensionExpr boundary downstream 2456 // or move the new-AST translation boundary upstream, implement 2457 // DimensionExpr in the new AST and implement a conversion. 2458 (void) old; 2459 assert(false && "DimensionExpr should not be present at new-AST boundary"); 2471 this->node = visitBaseExpr( old, 2472 new ast::DimensionExpr( old->location, old->name ) 2473 ); 2460 2474 } 2461 2475 … … 2711 2725 2712 2726 for (auto & param : foralls) { 2713 ty->forall.emplace_back(new ast::TypeInstType(param ->name, param));2727 ty->forall.emplace_back(new ast::TypeInstType(param)); 2714 2728 for (auto asst : param->assertions) { 2715 2729 ty->assertions.emplace_back(new ast::VariableExpr({}, asst)); … … 2761 2775 } 2762 2776 2763 virtual void visit( const EnumInstType * old ) override final { 2764 ast::EnumInstType * ty; 2777 virtual void visit( const EnumInstType * old ) override final { // Here is visiting the EnumInst Decl not the usage. 2778 ast::EnumInstType * ty; 2765 2779 if ( old->baseEnum ) { 2766 ty = new ast::EnumInstType{ 2780 ty = new ast::EnumInstType{ // Probably here: missing the specification of the base 2767 2781 GET_ACCEPT_1( baseEnum, EnumDecl ), 2768 2782 cv( old ), -
src/AST/Decl.cpp
rba897d21 r2e9b59b 68 68 } 69 69 for (auto & tp : this->type_params) { 70 ftype->forall.emplace_back(new TypeInstType(tp ->name, tp));70 ftype->forall.emplace_back(new TypeInstType(tp)); 71 71 for (auto & ap: tp->assertions) { 72 72 ftype->assertions.emplace_back(new VariableExpr(loc, ap)); … … 136 136 137 137 auto it = enumValues.find( enumerator->name ); 138 138 139 if ( it != enumValues.end() ) { 139 value = it->second; 140 141 // Handle typed enum by casting the value in (C++) compiler 142 // if ( base ) { // A typed enum 143 // if ( const BasicType * bt = dynamic_cast<const BasicType *>(base) ) { 144 // switch( bt->kind ) { 145 // case BasicType::Kind::Bool: value = (bool) it->second; break; 146 // case BasicType::Kind::Char: value = (char) it->second; break; 147 // case BasicType::Kind::SignedChar: value = (signed char) it->second; break; 148 // case BasicType::Kind::UnsignedChar: value = (unsigned char) it->second; break; 149 // case BasicType::Kind::ShortSignedInt: value = (short signed int) it->second; break; 150 // case BasicType::Kind::SignedInt: value = (signed int) it->second; break; 151 // case BasicType::Kind::UnsignedInt: value = (unsigned int) it->second; break; 152 // case BasicType::Kind::LongSignedInt: value = (long signed int) it->second; break; 153 // case BasicType::Kind::LongUnsignedInt: value = (long unsigned int) it->second; break; 154 // case BasicType::Kind::LongLongSignedInt: value = (long long signed int) it->second; break; 155 // case BasicType::Kind::LongLongUnsignedInt: value = (long long unsigned int) it->second; break; 156 // // TODO: value should be able to handle long long unsigned int 157 158 // default: 159 // value = it->second; 160 // } 161 // } 162 // } else { 163 value = it->second; 164 //} 165 140 166 return true; 141 167 } -
src/AST/Decl.hpp
rba897d21 r2e9b59b 302 302 class EnumDecl final : public AggregateDecl { 303 303 public: 304 ptr<Type> base; 305 304 306 EnumDecl( const CodeLocation& loc, const std::string& name, 305 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall ) 306 : AggregateDecl( loc, name, std::move(attrs), linkage ), enumValues() {} 307 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, Type * base = nullptr, 308 std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() ) 309 : AggregateDecl( loc, name, std::move(attrs), linkage ), base(base), enumValues(enumValues) {} 307 310 308 311 /// gets the integer value for this enumerator, returning true iff value found 312 // Maybe it is not used in producing the enum value 309 313 bool valueOf( const Decl * enumerator, long long& value ) const; 310 314 … … 312 316 313 317 const char * typeString() const override { return aggrString( Enum ); } 318 319 bool isTyped() {return base && base.get();} 314 320 315 321 private: -
src/AST/Expr.hpp
rba897d21 r2e9b59b 604 604 }; 605 605 606 class DimensionExpr final : public Expr { 607 public: 608 std::string name; 609 610 DimensionExpr( const CodeLocation & loc, std::string name ) 611 : Expr( loc ), name( name ) {} 612 613 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 614 private: 615 DimensionExpr * clone() const override { return new DimensionExpr{ *this }; } 616 MUTATE_FRIEND 617 }; 618 606 619 /// A GCC "asm constraint operand" used in an asm statement, e.g. `[output] "=f" (result)`. 607 620 /// https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints -
src/AST/Fwd.hpp
rba897d21 r2e9b59b 47 47 class ForStmt; 48 48 class SwitchStmt; 49 class Case Stmt;49 class CaseClause; 50 50 class BranchStmt; 51 51 class ReturnStmt; 52 52 class ThrowStmt; 53 53 class TryStmt; 54 class Catch Stmt;55 class Finally Stmt;54 class CatchClause; 55 class FinallyClause; 56 56 class SuspendStmt; 57 57 class WaitForStmt; … … 84 84 class CommaExpr; 85 85 class TypeExpr; 86 class DimensionExpr; 86 87 class AsmExpr; 87 88 class ImplicitCopyCtorExpr; … … 141 142 142 143 class TranslationUnit; 143 // TODO: Get from the TranslationUnit: 144 extern ptr<Type> sizeType; 145 extern const FunctionDecl * dereferenceOperator; 146 extern const StructDecl * dtorStruct; 147 extern const FunctionDecl * dtorStructDestroy; 144 class TranslationGlobal; 148 145 149 146 } -
src/AST/GenericSubstitution.cpp
rba897d21 r2e9b59b 45 45 visit_children = false; 46 46 const AggregateDecl * aggr = ty->aggr(); 47 sub = TypeSubstitution { aggr->params.begin(), aggr->params.end(), ty->params.begin() };47 sub = TypeSubstitution( aggr->params, ty->params ); 48 48 } 49 49 -
src/AST/Node.cpp
rba897d21 r2e9b59b 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 16 14:16:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Feb 1 09:09:39202213 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 25 10:30:00 2022 13 // Update Count : 4 14 14 // 15 15 … … 19 19 #include <csignal> // MEMORY DEBUG -- for raise 20 20 #include <iostream> 21 #include <utility> 21 22 22 23 #include "Attribute.hpp" … … 76 77 void ast::ptr_base<node_t, ref_t>::_check() const { 77 78 // if(node) assert(node->was_ever_strong == false || node->strong_count > 0); 79 } 80 81 template< typename node_t, enum ast::Node::ref_type ref_t > 82 void ast::ptr_base<node_t, ref_t>::swap( ptr_base & other ) noexcept { 83 std::swap( this->node, other.node ); 84 _trap( this->node ); 85 _trap( other.node ); 78 86 } 79 87 … … 152 160 template class ast::ptr_base< ast::SwitchStmt, ast::Node::ref_type::weak >; 153 161 template class ast::ptr_base< ast::SwitchStmt, ast::Node::ref_type::strong >; 154 template class ast::ptr_base< ast::Case Stmt, ast::Node::ref_type::weak >;155 template class ast::ptr_base< ast::Case Stmt, ast::Node::ref_type::strong >;162 template class ast::ptr_base< ast::CaseClause, ast::Node::ref_type::weak >; 163 template class ast::ptr_base< ast::CaseClause, ast::Node::ref_type::strong >; 156 164 template class ast::ptr_base< ast::BranchStmt, ast::Node::ref_type::weak >; 157 165 template class ast::ptr_base< ast::BranchStmt, ast::Node::ref_type::strong >; … … 162 170 template class ast::ptr_base< ast::TryStmt, ast::Node::ref_type::weak >; 163 171 template class ast::ptr_base< ast::TryStmt, ast::Node::ref_type::strong >; 164 template class ast::ptr_base< ast::Catch Stmt, ast::Node::ref_type::weak >;165 template class ast::ptr_base< ast::Catch Stmt, ast::Node::ref_type::strong >;166 template class ast::ptr_base< ast::Finally Stmt, ast::Node::ref_type::weak >;167 template class ast::ptr_base< ast::Finally Stmt, ast::Node::ref_type::strong >;172 template class ast::ptr_base< ast::CatchClause, ast::Node::ref_type::weak >; 173 template class ast::ptr_base< ast::CatchClause, ast::Node::ref_type::strong >; 174 template class ast::ptr_base< ast::FinallyClause, ast::Node::ref_type::weak >; 175 template class ast::ptr_base< ast::FinallyClause, ast::Node::ref_type::strong >; 168 176 template class ast::ptr_base< ast::WaitForStmt, ast::Node::ref_type::weak >; 169 177 template class ast::ptr_base< ast::WaitForStmt, ast::Node::ref_type::strong >; -
src/AST/Node.hpp
rba897d21 r2e9b59b 10 10 // Created On : Wed May 8 10:27:04 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jun 5 9:47:00 202013 // Update Count : 612 // Last Modified On : Fri Mar 25 10:33:00 2022 13 // Update Count : 7 14 14 // 15 15 … … 103 103 104 104 /// Mutate a node field (only clones if not equal to existing value) 105 template<typename node_t, typename parent_t, typename field_t, typename assn_t>106 const node_t * mutate_field( const node_t * node, field_t parent_t::* field, assn_t && val ) {105 template<typename node_t, typename super_t, typename field_t, typename assn_t> 106 const node_t * mutate_field( const node_t * node, field_t super_t::* field, assn_t && val ) { 107 107 // skip mutate if equivalent 108 108 if ( node->*field == val ) return node; … … 115 115 116 116 /// Mutate a single index of a node field (only clones if not equal to existing value) 117 template<typename node_t, typename parent_t, typename coll_t, typename ind_t, typename field_t>117 template<typename node_t, typename super_t, typename coll_t, typename ind_t, typename field_t> 118 118 const node_t * mutate_field_index( 119 const node_t * node, coll_t parent_t::* field, ind_t i, field_t && val119 const node_t * node, coll_t super_t::* field, ind_t i, field_t && val 120 120 ) { 121 121 // skip mutate if equivalent … … 129 129 130 130 /// Mutate an entire indexed collection by cloning to accepted value 131 template<typename node_t, typename parent_t, typename coll_t>132 const node_t * mutate_each( const node_t * node, coll_t parent_t::* field, Visitor & v ) {131 template<typename node_t, typename super_t, typename coll_t> 132 const node_t * mutate_each( const node_t * node, coll_t super_t::* field, Visitor & v ) { 133 133 for ( unsigned i = 0; i < (node->*field).size(); ++i ) { 134 134 node = mutate_field_index( node, field, i, (node->*field)[i]->accept( v ) ); … … 230 230 } 231 231 232 /// Swaps the nodes contained within two pointers. 233 void swap( ptr_base & other ) noexcept; 234 232 235 const node_t * get() const { _check(); return node; } 233 236 const node_t * operator->() const { _check(); return node; } … … 292 295 template< typename node_t > 293 296 using readonly = ptr_base< node_t, Node::ref_type::weak >; 297 298 /// Non-member swap that an participate in overload resolution. 299 template< typename node_t, enum Node::ref_type ref_t > 300 void swap( ptr_base< node_t, ref_t > & l, ptr_base< node_t, ref_t > & r ) { 301 l.swap( r ); 302 } 303 294 304 } 295 305 -
src/AST/Pass.hpp
rba897d21 r2e9b59b 149 149 const ast::Stmt * visit( const ast::ForStmt * ) override final; 150 150 const ast::Stmt * visit( const ast::SwitchStmt * ) override final; 151 const ast:: Stmt * visit( const ast::CaseStmt* ) override final;151 const ast::CaseClause * visit( const ast::CaseClause * ) override final; 152 152 const ast::Stmt * visit( const ast::BranchStmt * ) override final; 153 153 const ast::Stmt * visit( const ast::ReturnStmt * ) override final; 154 154 const ast::Stmt * visit( const ast::ThrowStmt * ) override final; 155 155 const ast::Stmt * visit( const ast::TryStmt * ) override final; 156 const ast:: Stmt * visit( const ast::CatchStmt* ) override final;157 const ast:: Stmt * visit( const ast::FinallyStmt* ) override final;156 const ast::CatchClause * visit( const ast::CatchClause * ) override final; 157 const ast::FinallyClause * visit( const ast::FinallyClause * ) override final; 158 158 const ast::Stmt * visit( const ast::SuspendStmt * ) override final; 159 159 const ast::Stmt * visit( const ast::WaitForStmt * ) override final; … … 184 184 const ast::Expr * visit( const ast::CommaExpr * ) override final; 185 185 const ast::Expr * visit( const ast::TypeExpr * ) override final; 186 const ast::Expr * visit( const ast::DimensionExpr * ) override final; 186 187 const ast::Expr * visit( const ast::AsmExpr * ) override final; 187 188 const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * ) override final; -
src/AST/Pass.impl.hpp
rba897d21 r2e9b59b 354 354 // Take all the elements that are different in 'values' 355 355 // and swap them into 'container' 356 if( values[i] != nullptr ) s td::swap(container[i], values[i]);356 if( values[i] != nullptr ) swap(container[i], values[i]); 357 357 } 358 358 … … 399 399 400 400 template< typename core_t > 401 template<typename node_t, typename parent_t, typename child_t>401 template<typename node_t, typename super_t, typename field_t> 402 402 void ast::Pass< core_t >::maybe_accept( 403 403 const node_t * & parent, 404 child_t parent_t::*child404 field_t super_t::*field 405 405 ) { 406 static_assert( std::is_base_of< parent_t, node_t>::value, "Error deducing member object" );407 408 if(__pass::skip(parent->* child)) return;409 const auto & old_val = __pass::get(parent->* child, 0);406 static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" ); 407 408 if(__pass::skip(parent->*field)) return; 409 const auto & old_val = __pass::get(parent->*field, 0); 410 410 411 411 static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR"); … … 417 417 if( new_val.differs ) { 418 418 auto new_parent = __pass::mutate<core_t>(parent); 419 new_val.apply(new_parent, child);419 new_val.apply(new_parent, field); 420 420 parent = new_parent; 421 421 } … … 423 423 424 424 template< typename core_t > 425 template<typename node_t, typename parent_t, typename child_t>425 template<typename node_t, typename super_t, typename field_t> 426 426 void ast::Pass< core_t >::maybe_accept_as_compound( 427 427 const node_t * & parent, 428 child_t parent_t::*child428 field_t super_t::*child 429 429 ) { 430 static_assert( std::is_base_of< parent_t, node_t>::value, "Error deducing member object" );430 static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" ); 431 431 432 432 if(__pass::skip(parent->*child)) return; … … 575 575 __pass::symtab::addId( core, 0, func ); 576 576 if ( __visit_children() ) { 577 // parameter declarations 577 maybe_accept( node, &FunctionDecl::type_params ); 578 maybe_accept( node, &FunctionDecl::assertions ); 578 579 maybe_accept( node, &FunctionDecl::params ); 579 580 maybe_accept( node, &FunctionDecl::returns ); 580 // type params and assertions 581 maybe_accept( node, &FunctionDecl::type_params ); 582 maybe_accept( node, &FunctionDecl::assertions ); 581 maybe_accept( node, &FunctionDecl::type ); 583 582 // First remember that we are now within a function. 584 583 ValueGuard< bool > oldInFunction( inFunction ); … … 893 892 if ( __visit_children() ) { 894 893 maybe_accept( node, &SwitchStmt::cond ); 895 maybe_accept( node, &SwitchStmt:: stmts );894 maybe_accept( node, &SwitchStmt::cases ); 896 895 } 897 896 … … 900 899 901 900 //-------------------------------------------------------------------------- 902 // Case Stmt903 template< typename core_t > 904 const ast:: Stmt * ast::Pass< core_t >::visit( const ast::CaseStmt* node ) {905 VISIT_START( node ); 906 907 if ( __visit_children() ) { 908 maybe_accept( node, &Case Stmt::cond );909 maybe_accept( node, &Case Stmt::stmts );910 } 911 912 VISIT_END( Stmt, node );901 // CaseClause 902 template< typename core_t > 903 const ast::CaseClause * ast::Pass< core_t >::visit( const ast::CaseClause * node ) { 904 VISIT_START( node ); 905 906 if ( __visit_children() ) { 907 maybe_accept( node, &CaseClause::cond ); 908 maybe_accept( node, &CaseClause::stmts ); 909 } 910 911 VISIT_END( CaseClause, node ); 913 912 } 914 913 … … 964 963 965 964 //-------------------------------------------------------------------------- 966 // Catch Stmt967 template< typename core_t > 968 const ast:: Stmt * ast::Pass< core_t >::visit( const ast::CatchStmt* node ) {965 // CatchClause 966 template< typename core_t > 967 const ast::CatchClause * ast::Pass< core_t >::visit( const ast::CatchClause * node ) { 969 968 VISIT_START( node ); 970 969 … … 972 971 // catch statements introduce a level of scope (for the caught exception) 973 972 guard_symtab guard { *this }; 974 maybe_accept( node, &Catch Stmt::decl );975 maybe_accept( node, &Catch Stmt::cond );976 maybe_accept_as_compound( node, &Catch Stmt::body );977 } 978 979 VISIT_END( Stmt, node );980 } 981 982 //-------------------------------------------------------------------------- 983 // Finally Stmt984 template< typename core_t > 985 const ast:: Stmt * ast::Pass< core_t >::visit( const ast::FinallyStmt* node ) {986 VISIT_START( node ); 987 988 if ( __visit_children() ) { 989 maybe_accept( node, &Finally Stmt::body );990 } 991 992 VISIT_END( Stmt, node );973 maybe_accept( node, &CatchClause::decl ); 974 maybe_accept( node, &CatchClause::cond ); 975 maybe_accept_as_compound( node, &CatchClause::body ); 976 } 977 978 VISIT_END( CatchClause, node ); 979 } 980 981 //-------------------------------------------------------------------------- 982 // FinallyClause 983 template< typename core_t > 984 const ast::FinallyClause * ast::Pass< core_t >::visit( const ast::FinallyClause * node ) { 985 VISIT_START( node ); 986 987 if ( __visit_children() ) { 988 maybe_accept( node, &FinallyClause::body ); 989 } 990 991 VISIT_END( FinallyClause, node ); 993 992 } 994 993 … … 1054 1053 auto n = __pass::mutate<core_t>(node); 1055 1054 for(size_t i = 0; i < new_clauses.size(); i++) { 1056 if(new_clauses.at(i).target.func != nullptr) s td::swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func);1055 if(new_clauses.at(i).target.func != nullptr) swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func); 1057 1056 1058 1057 for(size_t j = 0; j < new_clauses.at(i).target.args.size(); j++) { 1059 if(new_clauses.at(i).target.args.at(j) != nullptr) s td::swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j));1058 if(new_clauses.at(i).target.args.at(j) != nullptr) swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j)); 1060 1059 } 1061 1060 1062 if(new_clauses.at(i).stmt != nullptr) s td::swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt);1063 if(new_clauses.at(i).cond != nullptr) s td::swap(n->clauses.at(i).cond, new_clauses.at(i).cond);1061 if(new_clauses.at(i).stmt != nullptr) swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt); 1062 if(new_clauses.at(i).cond != nullptr) swap(n->clauses.at(i).cond, new_clauses.at(i).cond); 1064 1063 } 1065 1064 node = n; … … 1516 1515 } 1517 1516 maybe_accept( node, &TypeExpr::type ); 1517 } 1518 1519 VISIT_END( Expr, node ); 1520 } 1521 1522 //-------------------------------------------------------------------------- 1523 // DimensionExpr 1524 template< typename core_t > 1525 const ast::Expr * ast::Pass< core_t >::visit( const ast::DimensionExpr * node ) { 1526 VISIT_START( node ); 1527 1528 if ( __visit_children() ) { 1529 guard_symtab guard { *this }; 1530 maybe_accept( node, &DimensionExpr::result ); 1518 1531 } 1519 1532 … … 1859 1872 1860 1873 if ( __visit_children() ) { 1861 // xxx - should PointerType visit/mutate dimension?1874 maybe_accept( node, &PointerType::dimension ); 1862 1875 maybe_accept( node, &PointerType::base ); 1863 1876 } … … 2151 2164 2152 2165 if ( __visit_children() ) { 2153 { 2154 bool mutated = false; 2155 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map; 2156 for ( const auto & p : node->typeEnv ) { 2157 guard_symtab guard { *this }; 2158 auto new_node = p.second->accept( *this ); 2159 if (new_node != p.second) mutated = true; 2160 new_map.insert({ p.first, new_node }); 2161 } 2162 if (mutated) { 2163 auto new_node = __pass::mutate<core_t>( node ); 2164 new_node->typeEnv.swap( new_map ); 2165 node = new_node; 2166 } 2166 bool mutated = false; 2167 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map; 2168 for ( const auto & p : node->typeEnv ) { 2169 guard_symtab guard { *this }; 2170 auto new_node = p.second->accept( *this ); 2171 if (new_node != p.second) mutated = true; 2172 new_map.insert({ p.first, new_node }); 2173 } 2174 if (mutated) { 2175 auto new_node = __pass::mutate<core_t>( node ); 2176 new_node->typeEnv.swap( new_map ); 2177 node = new_node; 2167 2178 } 2168 2179 } -
src/AST/Pass.proto.hpp
rba897d21 r2e9b59b 26 26 27 27 struct PureVisitor; 28 29 template<typename node_t> 30 node_t * deepCopy( const node_t * localRoot ); 28 31 29 32 namespace __pass { … … 396 399 static inline auto addStructFwd( core_t & core, int, const ast::StructDecl * decl ) -> decltype( core.symtab.addStruct( decl ), void() ) { 397 400 ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name ); 398 fwd->params = decl->params; 401 for ( const auto & param : decl->params ) { 402 fwd->params.push_back( deepCopy( param.get() ) ); 403 } 399 404 core.symtab.addStruct( fwd ); 400 405 } … … 405 410 template<typename core_t> 406 411 static inline auto addUnionFwd( core_t & core, int, const ast::UnionDecl * decl ) -> decltype( core.symtab.addUnion( decl ), void() ) { 407 UnionDecl * fwd = new UnionDecl( decl->location, decl->name ); 408 fwd->params = decl->params; 412 ast::UnionDecl * fwd = new ast::UnionDecl( decl->location, decl->name ); 413 for ( const auto & param : decl->params ) { 414 fwd->params.push_back( deepCopy( param.get() ) ); 415 } 409 416 core.symtab.addUnion( fwd ); 410 417 } -
src/AST/Print.cpp
rba897d21 r2e9b59b 210 210 } 211 211 212 auto ptrToEnum = dynamic_cast<const ast::EnumDecl *>(node); 213 if ( ! short_mode && ptrToEnum && ptrToEnum->base ) { 214 os << endl << indent << ".. with (enum) base" << endl; 215 ++indent; 216 ptrToEnum->base->accept( *this ); 217 --indent; 218 } 219 212 220 os << endl; 213 221 } … … 589 597 590 598 ++indent; 591 for ( const ast:: Stmt * stmt : node->stmts ) {599 for ( const ast::CaseClause * stmt : node->cases ) { 592 600 stmt->accept( *this ); 593 601 } … … 597 605 } 598 606 599 virtual const ast:: Stmt * visit( const ast::CaseStmt* node ) override final {607 virtual const ast::CaseClause * visit( const ast::CaseClause * node ) override final { 600 608 if ( node->isDefault() ) { 601 609 os << indent << "Default "; … … 679 687 680 688 os << indent-1 << "... and handlers:" << endl; 681 for ( const ast::Catch Stmt* stmt : node->handlers ) {689 for ( const ast::CatchClause * stmt : node->handlers ) { 682 690 os << indent; 683 691 stmt->accept( *this ); … … 693 701 } 694 702 695 virtual const ast:: Stmt * visit( const ast::CatchStmt* node ) override final {703 virtual const ast::CatchClause * visit( const ast::CatchClause * node ) override final { 696 704 os << "Catch "; 697 705 switch ( node->kind ) { … … 718 726 } 719 727 720 virtual const ast:: Stmt * visit( const ast::FinallyStmt* node ) override final {728 virtual const ast::FinallyClause * visit( const ast::FinallyClause * node ) override final { 721 729 os << "Finally Statement" << endl; 722 730 os << indent << "... with block:" << endl; … … 1088 1096 virtual const ast::Expr * visit( const ast::TypeExpr * node ) override final { 1089 1097 safe_print( node->type ); 1098 postprint( node ); 1099 1100 return node; 1101 } 1102 1103 virtual const ast::Expr * visit( const ast::DimensionExpr * node ) override final { 1104 os << "Type-Sys Value: " << node->name; 1090 1105 postprint( node ); 1091 1106 -
src/AST/Stmt.hpp
rba897d21 r2e9b59b 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 20:06:41202213 // Update Count : 3 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Mar 28 9:50:00 2022 13 // Update Count : 35 14 14 // 15 15 … … 47 47 private: 48 48 Stmt * clone() const override = 0; 49 MUTATE_FRIEND 50 }; 51 52 // Base statement component node (only serves to group them). 53 class StmtClause : public ParseNode { 54 public: 55 // This is for non-statements that still belong with the statements, 56 // but are not statements, usually some sort of clause. Often these can 57 // (and should) be folded into the approprate parent node, but if they 58 // cannot be, they are sub-types of this type, for organization. 59 60 StmtClause( const CodeLocation & loc ) 61 : ParseNode(loc) {} 62 63 private: 64 StmtClause * clone() const override = 0; 49 65 MUTATE_FRIEND 50 66 }; … … 158 174 public: 159 175 ptr<Expr> cond; 176 std::vector<ptr<CaseClause>> cases; 177 178 SwitchStmt( const CodeLocation & loc, const Expr * cond, 179 const std::vector<ptr<CaseClause>> && cases, 180 const std::vector<Label> && labels = {} ) 181 : Stmt(loc, std::move(labels)), cond(cond), cases(std::move(cases)) {} 182 183 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 184 private: 185 SwitchStmt * clone() const override { return new SwitchStmt{ *this }; } 186 MUTATE_FRIEND 187 }; 188 189 // Case label: case ...: or default: 190 class CaseClause final : public StmtClause { 191 public: 192 // Null for the default label. 193 ptr<Expr> cond; 160 194 std::vector<ptr<Stmt>> stmts; 161 195 162 SwitchStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts, 163 const std::vector<Label> && labels = {} ) 164 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 165 166 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 167 private: 168 SwitchStmt * clone() const override { return new SwitchStmt{ *this }; } 169 MUTATE_FRIEND 170 }; 171 172 // Case label: case ...: or default: 173 class CaseStmt final : public Stmt { 174 public: 175 // Null for the default label. 176 ptr<Expr> cond; 177 std::vector<ptr<Stmt>> stmts; 178 179 CaseStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts, 180 const std::vector<Label> && labels = {} ) 181 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 196 CaseClause( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts ) 197 : StmtClause(loc), cond(cond), stmts(std::move(stmts)) {} 182 198 183 199 bool isDefault() const { return !cond; } 184 200 185 const Stmt* accept( Visitor & v ) const override { return v.visit( this ); }186 private: 187 Case Stmt * clone() const override { return new CaseStmt{ *this }; }201 const CaseClause * accept( Visitor & v ) const override { return v.visit( this ); } 202 private: 203 CaseClause * clone() const override { return new CaseClause{ *this }; } 188 204 MUTATE_FRIEND 189 205 }; … … 298 314 public: 299 315 ptr<CompoundStmt> body; 300 std::vector<ptr<Catch Stmt>> handlers;301 ptr<Finally Stmt> finally;316 std::vector<ptr<CatchClause>> handlers; 317 ptr<FinallyClause> finally; 302 318 303 319 TryStmt( const CodeLocation & loc, const CompoundStmt * body, 304 const std::vector<ptr<Catch Stmt>> && handlers, const FinallyStmt* finally,320 const std::vector<ptr<CatchClause>> && handlers, const FinallyClause * finally, 305 321 const std::vector<Label> && labels = {} ) 306 322 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} … … 313 329 314 330 // Catch clause of try statement 315 class Catch Stmt final : public Stmt{331 class CatchClause final : public StmtClause { 316 332 public: 317 333 ptr<Decl> decl; … … 320 336 ExceptionKind kind; 321 337 322 Catch Stmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,323 const Stmt * body , const std::vector<Label> && labels = {})324 : Stmt (loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {}325 326 const Stmt* accept( Visitor & v ) const override { return v.visit( this ); }327 private: 328 Catch Stmt * clone() const override { return new CatchStmt{ *this }; }338 CatchClause( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 339 const Stmt * body ) 340 : StmtClause(loc), decl(decl), cond(cond), body(body), kind(kind) {} 341 342 const CatchClause * accept( Visitor & v ) const override { return v.visit( this ); } 343 private: 344 CatchClause * clone() const override { return new CatchClause{ *this }; } 329 345 MUTATE_FRIEND 330 346 }; 331 347 332 348 // Finally clause of try statement 333 class Finally Stmt final : public Stmt{349 class FinallyClause final : public StmtClause { 334 350 public: 335 351 ptr<CompoundStmt> body; 336 352 337 FinallyStmt( const CodeLocation & loc, const CompoundStmt * body, 338 std::vector<Label> && labels = {} ) 339 : Stmt(loc, std::move(labels)), body(body) {} 340 341 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 342 private: 343 FinallyStmt * clone() const override { return new FinallyStmt{ *this }; } 353 FinallyClause( const CodeLocation & loc, const CompoundStmt * body ) 354 : StmtClause(loc), body(body) {} 355 356 const FinallyClause * accept( Visitor & v ) const override { return v.visit( this ); } 357 private: 358 FinallyClause * clone() const override { return new FinallyClause{ *this }; } 344 359 MUTATE_FRIEND 345 360 }; -
src/AST/TranslationUnit.hpp
rba897d21 r2e9b59b 10 10 // Created On : Tue Jun 11 15:30:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jun 11 15:42:00 201913 // Update Count : 012 // Last Modified On : Tue Mar 11 11:19:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 23 23 namespace ast { 24 24 25 class TranslationGlobal { 26 public: 27 std::map< UniqueId, Decl * > idMap; 28 29 ptr<Type> sizeType; 30 const FunctionDecl * dereference; 31 const StructDecl * dtorStruct; 32 const FunctionDecl * dtorDestroy; 33 }; 34 25 35 class TranslationUnit { 26 36 public: 27 37 std::list< ptr< Decl > > decls; 28 29 struct Global { 30 std::map< UniqueId, Decl * > idMap; 31 32 ptr<Type> sizeType; 33 const FunctionDecl * dereference; 34 const StructDecl * dtorStruct; 35 const FunctionDecl * dtorDestroy; 36 } global; 38 TranslationGlobal global; 37 39 }; 38 40 -
src/AST/Type.cpp
rba897d21 r2e9b59b 147 147 // --- TypeInstType 148 148 149 TypeInstType::TypeInstType( const TypeDecl * b, 150 CV::Qualifiers q, std::vector<ptr<Attribute>> && as ) 151 : BaseInstType( b->name, q, move(as) ), base( b ), kind( b->kind ) {} 152 149 153 void TypeInstType::set_base( const TypeDecl * b ) { 150 154 base = b; -
src/AST/Type.hpp
rba897d21 r2e9b59b 421 421 std::vector<ptr<Attribute>> && as = {} ) 422 422 : BaseInstType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 423 424 TypeInstType( const TypeDecl * b, 425 CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 426 423 427 TypeInstType( const std::string& n, TypeDecl::Kind k, CV::Qualifiers q = {}, 424 428 std::vector<ptr<Attribute>> && as = {} ) -
src/AST/TypeSubstitution.hpp
rba897d21 r2e9b59b 37 37 public: 38 38 TypeSubstitution(); 39 template< typename FormalContainer, typename ActualContainer > 40 TypeSubstitution( FormalContainer formals, ActualContainer actuals ); 39 41 template< typename FormalIterator, typename ActualIterator > 40 42 TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ); … … 76 78 bool empty() const; 77 79 80 template< typename FormalContainer, typename ActualContainer > 81 void addAll( FormalContainer formals, ActualContainer actuals ); 78 82 template< typename FormalIterator, typename ActualIterator > 79 void add ( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin );83 void addAll( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ); 80 84 81 85 /// create a new TypeSubstitution using bindings from env containing all of the type variables in expr … … 112 116 }; 113 117 118 template< typename FormalContainer, typename ActualContainer > 119 TypeSubstitution::TypeSubstitution( FormalContainer formals, ActualContainer actuals ) { 120 assert( formals.size() == actuals.size() ); 121 addAll( formals.begin(), formals.end(), actuals.begin() ); 122 } 123 124 template< typename FormalIterator, typename ActualIterator > 125 TypeSubstitution::TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ) { 126 addAll( formalBegin, formalEnd, actualBegin ); 127 } 128 129 template< typename FormalContainer, typename ActualContainer > 130 void TypeSubstitution::addAll( FormalContainer formals, ActualContainer actuals ) { 131 assert( formals.size() == actuals.size() ); 132 addAll( formals.begin(), formals.end(), actuals.begin() ); 133 } 134 114 135 // this is the only place where type parameters outside a function formal may be substituted. 115 136 template< typename FormalIterator, typename ActualIterator > 116 void TypeSubstitution::add ( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ) {137 void TypeSubstitution::addAll( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ) { 117 138 // FormalIterator points to a TypeDecl 118 139 // ActualIterator points to a Type … … 129 150 } // if 130 151 } else { 131 152 // Is this an error? 132 153 } // if 133 154 } // for 134 155 } 135 136 137 138 template< typename FormalIterator, typename ActualIterator >139 TypeSubstitution::TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ) {140 add( formalBegin, formalEnd, actualBegin );141 }142 143 156 144 157 } // namespace ast -
src/AST/Util.cpp
rba897d21 r2e9b59b 10 10 // Created On : Wed Jan 19 9:46:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Feb 18 9:42:00 202213 // Update Count : 012 // Last Modified On : Fri Mar 11 18:07:00 2022 13 // Update Count : 1 14 14 // 15 15 16 16 #include "Util.hpp" 17 17 18 #include "Decl.hpp"19 18 #include "Node.hpp" 19 #include "ParseNode.hpp" 20 20 #include "Pass.hpp" 21 21 #include "TranslationUnit.hpp" 22 #include "Common/ScopedMap.h"23 22 24 23 #include <vector> … … 46 45 }; 47 46 47 /// Check that every note that can has a set CodeLocation. 48 struct SetCodeLocationsCore { 49 void previsit( const ParseNode * node ) { 50 assert( node->location.isSet() ); 51 } 52 }; 53 48 54 struct InvariantCore { 49 55 // To save on the number of visits: this is a kind of composed core. 50 56 // None of the passes should make changes so ordering doesn't matter. 51 57 NoStrongCyclesCore no_strong_cycles; 58 SetCodeLocationsCore set_code_locations; 52 59 53 60 void previsit( const Node * node ) { 54 61 no_strong_cycles.previsit( node ); 62 } 63 64 void previsit( const ParseNode * node ) { 65 no_strong_cycles.previsit( node ); 66 set_code_locations.previsit( node ); 55 67 } 56 68 -
src/AST/Visitor.hpp
rba897d21 r2e9b59b 41 41 virtual const ast::Stmt * visit( const ast::ForStmt * ) = 0; 42 42 virtual const ast::Stmt * visit( const ast::SwitchStmt * ) = 0; 43 virtual const ast:: Stmt * visit( const ast::CaseStmt* ) = 0;43 virtual const ast::CaseClause * visit( const ast::CaseClause * ) = 0; 44 44 virtual const ast::Stmt * visit( const ast::BranchStmt * ) = 0; 45 45 virtual const ast::Stmt * visit( const ast::ReturnStmt * ) = 0; 46 46 virtual const ast::Stmt * visit( const ast::ThrowStmt * ) = 0; 47 47 virtual const ast::Stmt * visit( const ast::TryStmt * ) = 0; 48 virtual const ast:: Stmt * visit( const ast::CatchStmt* ) = 0;49 virtual const ast:: Stmt * visit( const ast::FinallyStmt* ) = 0;48 virtual const ast::CatchClause * visit( const ast::CatchClause * ) = 0; 49 virtual const ast::FinallyClause * visit( const ast::FinallyClause * ) = 0; 50 50 virtual const ast::Stmt * visit( const ast::SuspendStmt * ) = 0; 51 51 virtual const ast::Stmt * visit( const ast::WaitForStmt * ) = 0; … … 76 76 virtual const ast::Expr * visit( const ast::CommaExpr * ) = 0; 77 77 virtual const ast::Expr * visit( const ast::TypeExpr * ) = 0; 78 virtual const ast::Expr * visit( const ast::DimensionExpr * ) = 0; 78 79 virtual const ast::Expr * visit( const ast::AsmExpr * ) = 0; 79 80 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * ) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.