Changes in src/AST/Convert.cpp [3e5dd913:07de76b]
- File:
-
- 1 edited
-
src/AST/Convert.cpp (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r3e5dd913 r07de76b 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Nov 12 10:07:00 202013 // Update Count : 3 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 21:39:32 2019 13 // Update Count : 33 14 14 // 15 15 … … 20 20 21 21 #include "AST/Attribute.hpp" 22 #include "AST/Copy.hpp"23 22 #include "AST/Decl.hpp" 24 23 #include "AST/Expr.hpp" 25 24 #include "AST/Init.hpp" 26 25 #include "AST/Stmt.hpp" 27 #include "AST/TranslationUnit.hpp"28 26 #include "AST/TypeSubstitution.hpp" 29 27 … … 48 46 49 47 //================================================================================================ 50 namespace ast{48 namespace { 51 49 52 50 // This is to preserve the FindSpecialDecls hack. It does not (and perhaps should not) 53 51 // 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; 52 ast::Type * sizeType = nullptr; 53 ast::FunctionDecl * dereferenceOperator = nullptr; 54 ast::StructDecl * dtorStruct = nullptr; 55 ast::FunctionDecl * dtorStructDestroy = nullptr; 61 56 62 57 } … … 67 62 using Cache = std::unordered_map< const ast::Node *, BaseSyntaxNode * >; 68 63 Cache cache; 69 70 // Statements can no longer be shared.71 // however, since StmtExprResult is now implemented, need to still maintain72 // readonly references.73 Cache readonlyCache;74 64 75 65 template<typename T> … … 163 153 } 164 154 165 const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final { 155 const ast::DeclWithType * visit( const ast::ObjectDecl * node ) override final { 156 auto&& bfwd = get<Expression>().accept1( node->bitfieldWidth ); 157 auto&& type = get<Type>().accept1( node->type ); 158 auto&& init = get<Initializer>().accept1( node->init ); 159 auto&& attr = get<Attribute>().acceptL( node->attributes ); 166 160 if ( inCache( node ) ) { 167 161 return nullptr; 168 162 } 169 auto bfwd = get<Expression>().accept1( node->bitfieldWidth );170 auto type = get<Type>().accept1( node->type );171 auto attr = get<Attribute>().acceptL( node->attributes );172 173 163 auto decl = new ObjectDecl( 174 164 node->name, … … 176 166 LinkageSpec::Spec( node->linkage.val ), 177 167 bfwd, 178 type ->clone(),179 nullptr, // prevent infinite loop168 type, 169 init, 180 170 attr, 181 171 Type::FuncSpecifiers( node->funcSpec.val ) 182 172 ); 183 184 // handles the case where node->init references itself 185 // xxx - does it really happen? 186 declWithTypePostamble(decl, node); 187 auto init = get<Initializer>().accept1( node->init ); 188 decl->init = init; 189 190 this->node = decl; 191 return nullptr; 173 return declWithTypePostamble( decl, node ); 192 174 } 193 175 194 176 const ast::DeclWithType * visit( const ast::FunctionDecl * node ) override final { 195 177 if ( inCache( node ) ) return nullptr; 196 197 // function decl contains real variables that the type must use.198 // the structural change means function type in and out of decl199 // must be handled **differently** on convert back to old.200 auto ftype = new FunctionType(201 cv(node->type),202 (bool)node->type->isVarArgs203 );204 ftype->returnVals = get<DeclarationWithType>().acceptL(node->returns);205 ftype->parameters = get<DeclarationWithType>().acceptL(node->params);206 207 ftype->forall = get<TypeDecl>().acceptL( node->type_params );208 if (!node->assertions.empty()) {209 assert(!ftype->forall.empty());210 // find somewhere to place assertions back, for convenience it is the last slot211 ftype->forall.back()->assertions = get<DeclarationWithType>().acceptL(node->assertions);212 }213 214 visitType(node->type, ftype);215 216 178 auto decl = new FunctionDecl( 217 179 node->name, 218 180 Type::StorageClasses( node->storage.val ), 219 181 LinkageSpec::Spec( node->linkage.val ), 220 ftype, 221 //get<FunctionType>().accept1( node->type ), 182 get<FunctionType>().accept1( node->type ), 222 183 {}, 223 184 get<Attribute>().acceptL( node->attributes ), … … 227 188 decl->statements = get<CompoundStmt>().accept1( node->stmts ); 228 189 decl->withExprs = get<Expression>().acceptL( node->withExprs ); 229 if ( ast::dereferenceOperator == node ) {190 if ( dereferenceOperator == node ) { 230 191 Validate::dereferenceOperator = decl; 231 192 } 232 if ( ast::dtorStructDestroy == node ) {193 if ( dtorStructDestroy == node ) { 233 194 Validate::dtorStructDestroy = decl; 234 195 } … … 238 199 const ast::Decl * namedTypePostamble( NamedTypeDecl * decl, const ast::NamedTypeDecl * node ) { 239 200 // base comes from constructor 201 decl->parameters = get<TypeDecl>().acceptL( node->params ); 240 202 decl->assertions = get<DeclarationWithType>().acceptL( node->assertions ); 241 203 declPostamble( decl, node ); … … 288 250 ); 289 251 290 if ( ast::dtorStruct == node ) {252 if ( dtorStruct == node ) { 291 253 Validate::dtorStruct = decl; 292 254 } … … 341 303 342 304 const ast::Stmt * stmtPostamble( Statement * stmt, const ast::Stmt * node ) { 343 // force statements in old tree to be unique. 344 // cache.emplace( node, stmt ); 345 readonlyCache.emplace( node, stmt ); 305 cache.emplace( node, stmt ); 346 306 stmt->location = node->location; 347 307 stmt->labels = makeLabelL( stmt, node->labels ); … … 360 320 if ( inCache( node ) ) return nullptr; 361 321 auto stmt = new ExprStmt( nullptr ); 322 cache.emplace( node, stmt ); 362 323 stmt->expr = get<Expression>().accept1( node->expr ); 363 324 return stmtPostamble( stmt, node ); … … 532 493 } 533 494 534 const ast::Stmt * visit(const ast::SuspendStmt * node ) override final {535 if ( inCache( node ) ) return nullptr;536 auto stmt = new SuspendStmt();537 stmt->then = get<CompoundStmt>().accept1( node->then );538 switch(node->type) {539 case ast::SuspendStmt::None : stmt->type = SuspendStmt::None ; break;540 case ast::SuspendStmt::Coroutine: stmt->type = SuspendStmt::Coroutine; break;541 case ast::SuspendStmt::Generator: stmt->type = SuspendStmt::Generator; break;542 }543 return stmtPostamble( stmt, node );544 }545 546 495 const ast::Stmt * visit( const ast::WaitForStmt * node ) override final { 547 496 if ( inCache( node ) ) return nullptr; … … 607 556 608 557 for (decltype(src->begin()) src_i = src->begin(); src_i != src->end(); src_i++) { 609 rslt->add( src_i->first .typeString(),558 rslt->add( src_i->first, 610 559 get<Type>().accept1(src_i->second) ); 560 } 561 562 for (decltype(src->beginVar()) src_i = src->beginVar(); src_i != src->endVar(); src_i++) { 563 rslt->addVar( src_i->first, 564 get<Expression>().accept1(src_i->second) ); 611 565 } 612 566 … … 621 575 assert( tgtResnSlots.empty() ); 622 576 623 if ( srcInferred. data.inferParams ) {577 if ( srcInferred.mode == ast::Expr::InferUnion::Params ) { 624 578 const ast::InferredParams &srcParams = srcInferred.inferParams(); 625 579 for (auto & srcParam : srcParams) { … … 627 581 srcParam.second.decl, 628 582 get<Declaration>().accept1(srcParam.second.declptr), 629 get<Type>().accept1(srcParam.second.actualType) ->clone(),630 get<Type>().accept1(srcParam.second.formalType) ->clone(),631 get<Expression>().accept1(srcParam.second.expr) ->clone()583 get<Type>().accept1(srcParam.second.actualType), 584 get<Type>().accept1(srcParam.second.formalType), 585 get<Expression>().accept1(srcParam.second.expr) 632 586 )); 633 587 assert(res.second); 634 588 } 635 } 636 if ( srcInferred.data.resnSlots ) { 589 } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots ) { 637 590 const ast::ResnSlots &srcSlots = srcInferred.resnSlots(); 638 591 for (auto srcSlot : srcSlots) { … … 655 608 656 609 tgt->result = get<Type>().accept1(src->result); 657 // Unconditionally use a clone of the result type.658 // We know this will leak some objects: much of the immediate conversion result.659 // In some cases, using the conversion result directly gives unintended object sharing.660 // A parameter (ObjectDecl, a child of a FunctionType) is shared by the weak-ref cache.661 // But tgt->result must be fully owned privately by tgt.662 // Applying these conservative copies here means663 // - weak references point at the declaration's copy, not these expr.result copies (good)664 // - we copy more objects than really needed (bad, tolerated)665 if (tgt->result) {666 tgt->result = tgt->result->clone();667 }668 610 return visitBaseExpr_skipResultType(src, tgt); 669 611 } … … 738 680 new KeywordCastExpr( 739 681 get<Expression>().accept1(node->arg), 740 castTarget, 741 {node->concrete_target.field, node->concrete_target.getter} 682 castTarget 742 683 ) 743 684 ); … … 1026 967 1027 968 const ast::Expr * visit( const ast::StmtExpr * node ) override final { 1028 auto stmts = node->stmts;1029 // disable sharing between multiple StmtExprs explicitly.1030 // this should no longer be true.1031 1032 969 auto rslt = new StmtExpr( 1033 get<CompoundStmt>().accept1( stmts)970 get<CompoundStmt>().accept1(node->stmts) 1034 971 ); 1035 972 1036 973 rslt->returnDecls = get<ObjectDecl>().acceptL(node->returnDecls); 1037 974 rslt->dtors = get<Expression>().acceptL(node->dtors); 1038 if (node->resultExpr) {1039 // this MUST be found by children visit1040 rslt->resultExpr = strict_dynamic_cast<ExprStmt *>(readonlyCache.at(node->resultExpr));1041 }1042 975 1043 976 auto expr = visitBaseExpr( node, rslt ); … … 1056 989 1057 990 auto expr = visitBaseExpr( node, rslt ); 1058 this->node = expr ->clone();991 this->node = expr; 1059 992 return nullptr; 1060 993 } … … 1146 1079 auto type = new BasicType{ cv( node ), (BasicType::Kind)(unsigned)node->kind }; 1147 1080 // I believe this should always be a BasicType. 1148 if ( ast::sizeType == node ) {1081 if ( sizeType == node ) { 1149 1082 Validate::SizeType = type; 1150 1083 } … … 1188 1121 1189 1122 const ast::Type * visit( const ast::FunctionType * node ) override final { 1190 static std::string dummy_paramvar_prefix = "__param_";1191 static std::string dummy_returnvar_prefix = "__retval_";1192 1193 1123 auto ty = new FunctionType { 1194 1124 cv( node ), 1195 1125 (bool)node->isVarArgs 1196 1126 }; 1197 auto returns = get<Type>().acceptL(node->returns); 1198 auto params = get<Type>().acceptL(node->params); 1199 1200 int ret_index = 0; 1201 for (auto t: returns) { 1202 // xxx - LinkageSpec shouldn't matter but needs to be something 1203 ObjectDecl * dummy = new ObjectDecl(dummy_returnvar_prefix + std::to_string(ret_index++), {}, LinkageSpec::C, nullptr, t, nullptr); 1204 ty->returnVals.push_back(dummy); 1205 } 1206 int param_index = 0; 1207 for (auto t: params) { 1208 ObjectDecl * dummy = new ObjectDecl(dummy_paramvar_prefix + std::to_string(param_index++), {}, LinkageSpec::C, nullptr, t, nullptr); 1209 ty->parameters.push_back(dummy); 1210 } 1211 1212 // ty->returnVals = get<DeclarationWithType>().acceptL( node->returns ); 1213 // ty->parameters = get<DeclarationWithType>().acceptL( node->params ); 1214 1215 auto types = get<TypeInstType>().acceptL( node->forall ); 1216 for (auto t : types) { 1217 auto newT = new TypeDecl(*t->baseType); 1218 newT->name = t->name; // converted by typeString() 1219 for (auto asst : newT->assertions) delete asst; 1220 newT->assertions.clear(); 1221 ty->forall.push_back(newT); 1222 } 1223 auto assts = get<VariableExpr>().acceptL( node->assertions ); 1224 if (!assts.empty()) { 1225 assert(!types.empty()); 1226 for (auto asst : assts) { 1227 auto newDecl = new ObjectDecl(*strict_dynamic_cast<ObjectDecl*>(asst->var)); 1228 delete newDecl->type; 1229 newDecl->type = asst->result->clone(); 1230 newDecl->storageClasses.is_extern = true; // hack 1231 ty->forall.back()->assertions.push_back(newDecl); 1232 } 1233 } 1234 1127 ty->returnVals = get<DeclarationWithType>().acceptL( node->returns ); 1128 ty->parameters = get<DeclarationWithType>().acceptL( node->params ); 1129 ty->forall = get<TypeDecl>().acceptL( node->forall ); 1235 1130 return visitType( node, ty ); 1236 1131 } 1237 1132 1238 const ast::Type * postvisit( const ast::BaseInstType * old, ReferenceToType * ty ) { 1133 const ast::Type * postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) { 1134 ty->forall = get<TypeDecl>().acceptL( old->forall ); 1239 1135 ty->parameters = get<Expression>().acceptL( old->params ); 1240 1136 ty->hoistType = old->hoistType; … … 1319 1215 ty = new TypeInstType{ 1320 1216 cv( node ), 1321 node-> typeString(),1217 node->name, 1322 1218 get<TypeDecl>().accept1( node->base ), 1323 1219 get<Attribute>().acceptL( node->attributes ) … … 1326 1222 ty = new TypeInstType{ 1327 1223 cv( node ), 1328 node-> typeString(),1224 node->name, 1329 1225 node->kind == ast::TypeDecl::Ftype, 1330 1226 get<Attribute>().acceptL( node->attributes ) … … 1423 1319 }; 1424 1320 1425 std::list< Declaration * > convert( const ast::TranslationUnit&& translationUnit ) {1321 std::list< Declaration * > convert( const std::list< ast::ptr< ast::Decl > > && translationUnit ) { 1426 1322 ConverterNewToOld c; 1427 1323 std::list< Declaration * > decls; 1428 for(auto d : translationUnit .decls) {1324 for(auto d : translationUnit) { 1429 1325 decls.emplace_back( c.decl( d ) ); 1430 1326 } … … 1447 1343 ast::Node * node = nullptr; 1448 1344 /// cache of nodes that might be referenced by readonly<> for de-duplication 1449 /// in case that some nodes are dropped by conversion (due to possible structural change) 1450 /// use smart pointers in cache value to prevent accidental invalidation. 1451 /// at conversion stage, all created nodes are guaranteed to be unique, therefore 1452 /// const_casting out of smart pointers is permitted. 1453 std::unordered_map< const BaseSyntaxNode *, ast::readonly<ast::Node> > cache = {}; 1345 std::unordered_map< const BaseSyntaxNode *, ast::Node * > cache = {}; 1454 1346 1455 1347 // Local Utilities: … … 1524 1416 auto it = cache.find( old ); 1525 1417 if ( it == cache.end() ) return false; 1526 node = const_cast<ast::Node *>(it->second.get());1418 node = it->second; 1527 1419 return true; 1528 1420 } … … 1563 1455 virtual void visit( const FunctionDecl * old ) override final { 1564 1456 if ( inCache( old ) ) return; 1565 auto paramVars = GET_ACCEPT_V(type->parameters, DeclWithType);1566 auto returnVars = GET_ACCEPT_V(type->returnVals, DeclWithType);1567 auto forall = GET_ACCEPT_V(type->forall, TypeDecl);1568 1569 // function type is now derived from parameter decls instead of storing them1570 1571 /*1572 auto ftype = new ast::FunctionType((ast::ArgumentFlag)old->type->isVarArgs, cv(old->type));1573 ftype->params.reserve(paramVars.size());1574 ftype->returns.reserve(returnVars.size());1575 1576 for (auto & v: paramVars) {1577 ftype->params.emplace_back(v->get_type());1578 }1579 for (auto & v: returnVars) {1580 ftype->returns.emplace_back(v->get_type());1581 }1582 ftype->forall = std::move(forall);1583 */1584 1585 // can function type have attributes? seems not to be the case.1586 // visitType(old->type, ftype);1587 1588 // collect assertions and put directly in FunctionDecl1589 std::vector<ast::ptr<ast::DeclWithType>> assertions;1590 for (auto & param: forall) {1591 for (auto & asst: param->assertions) {1592 assertf(asst->unique(), "newly converted decl must be unique");1593 assertions.emplace_back(asst);1594 }1595 auto mut = param.get_and_mutate();1596 assertf(mut == param, "newly converted decl must be unique");1597 mut->assertions.clear();1598 }1599 1600 1457 auto decl = new ast::FunctionDecl{ 1601 1458 old->location, 1602 1459 old->name, 1603 // GET_ACCEPT_1(type, FunctionType), 1604 std::move(forall), 1605 std::move(paramVars), 1606 std::move(returnVars), 1460 GET_ACCEPT_1(type, FunctionType), 1607 1461 {}, 1608 1462 { old->storageClasses.val }, 1609 1463 { old->linkage.val }, 1610 1464 GET_ACCEPT_V(attributes, Attribute), 1611 { old->get_funcSpec().val }, 1612 old->type->isVarArgs 1465 { old->get_funcSpec().val } 1613 1466 }; 1614 1615 // decl->type = ftype;1616 1467 cache.emplace( old, decl ); 1617 1618 decl->assertions = std::move(assertions);1619 1468 decl->withExprs = GET_ACCEPT_V(withExprs, Expr); 1620 1469 decl->stmts = GET_ACCEPT_1(statements, CompoundStmt); … … 1629 1478 1630 1479 if ( Validate::dereferenceOperator == old ) { 1631 ast::dereferenceOperator = decl;1480 dereferenceOperator = decl; 1632 1481 } 1633 1482 1634 1483 if ( Validate::dtorStructDestroy == old ) { 1635 ast::dtorStructDestroy = decl;1484 dtorStructDestroy = decl; 1636 1485 } 1637 1486 } … … 1658 1507 1659 1508 if ( Validate::dtorStruct == old ) { 1660 ast::dtorStruct = decl;1509 dtorStruct = decl; 1661 1510 } 1662 1511 } … … 1735 1584 cache.emplace( old, decl ); 1736 1585 decl->assertions = GET_ACCEPT_V(assertions, DeclWithType); 1586 decl->params = GET_ACCEPT_V(parameters, TypeDecl); 1737 1587 decl->extension = old->extension; 1738 1588 decl->uniqueId = old->uniqueId; … … 1750 1600 ); 1751 1601 decl->assertions = GET_ACCEPT_V(assertions, DeclWithType); 1602 decl->params = GET_ACCEPT_V(parameters, TypeDecl); 1752 1603 decl->extension = old->extension; 1753 1604 decl->uniqueId = old->uniqueId; … … 2008 1859 } 2009 1860 2010 virtual void visit( const SuspendStmt * old ) override final {2011 if ( inCache( old ) ) return;2012 ast::SuspendStmt::Type type;2013 switch (old->type) {2014 case SuspendStmt::Coroutine: type = ast::SuspendStmt::Coroutine; break;2015 case SuspendStmt::Generator: type = ast::SuspendStmt::Generator; break;2016 case SuspendStmt::None : type = ast::SuspendStmt::None ; break;2017 default: abort();2018 }2019 this->node = new ast::SuspendStmt(2020 old->location,2021 GET_ACCEPT_1(then , CompoundStmt),2022 type,2023 GET_LABELS_V(old->labels)2024 );2025 cache.emplace( old, this->node );2026 }2027 2028 1861 virtual void visit( const WaitForStmt * old ) override final { 2029 1862 if ( inCache( old ) ) return; … … 2099 1932 } 2100 1933 2101 // TypeSubstitution shouldn't exist yet in old.2102 1934 ast::TypeSubstitution * convertTypeSubstitution(const TypeSubstitution * old) { 2103 1935 2104 1936 if (!old) return nullptr; 2105 if (old->empty()) return nullptr; 2106 assert(false); 2107 2108 /* 1937 2109 1938 ast::TypeSubstitution *rslt = new ast::TypeSubstitution(); 2110 1939 … … 2114 1943 } 2115 1944 1945 for (decltype(old->beginVar()) old_i = old->beginVar(); old_i != old->endVar(); old_i++) { 1946 rslt->addVar( old_i->first, 1947 getAccept1<ast::Expr>(old_i->second) ); 1948 } 1949 2116 1950 return rslt; 2117 */2118 1951 } 2119 1952 … … 2123 1956 2124 1957 assert( oldInferParams.empty() || oldResnSlots.empty() ); 2125 //assert( newInferred.mode == ast::Expr::InferUnion::Empty );1958 assert( newInferred.mode == ast::Expr::InferUnion::Empty ); 2126 1959 2127 1960 if ( !oldInferParams.empty() ) { … … 2206 2039 old->location, 2207 2040 GET_ACCEPT_1(arg, Expr), 2208 castTarget, 2209 {old->concrete_target.field, old->concrete_target.getter} 2041 castTarget 2210 2042 ) 2211 2043 ); … … 2255 2087 old->location, 2256 2088 GET_ACCEPT_1(member, DeclWithType), 2257 GET_ACCEPT_1(aggregate, Expr), 2258 ast::MemberExpr::NoOpConstructionChosen 2089 GET_ACCEPT_1(aggregate, Expr) 2259 2090 ) 2260 2091 ); … … 2588 2419 // I believe this should always be a BasicType. 2589 2420 if ( Validate::SizeType == old ) { 2590 ast::sizeType = type;2421 sizeType = type; 2591 2422 } 2592 2423 visitType( old, type ); … … 2633 2464 cv( old ) 2634 2465 }; 2635 auto returnVars = GET_ACCEPT_V(returnVals, DeclWithType); 2636 auto paramVars = GET_ACCEPT_V(parameters, DeclWithType); 2637 // ty->returns = GET_ACCEPT_V( returnVals, DeclWithType ); 2638 // ty->params = GET_ACCEPT_V( parameters, DeclWithType ); 2639 for (auto & v: returnVars) { 2640 ty->returns.emplace_back(v->get_type()); 2641 } 2642 for (auto & v: paramVars) { 2643 ty->params.emplace_back(v->get_type()); 2644 } 2645 // xxx - when will this be non-null? 2646 // will have to create dangling (no-owner) decls to be pointed to 2647 auto foralls = GET_ACCEPT_V( forall, TypeDecl ); 2648 2649 for (auto & param : foralls) { 2650 ty->forall.emplace_back(new ast::TypeInstType(param->name, param)); 2651 for (auto asst : param->assertions) { 2652 ty->assertions.emplace_back(new ast::VariableExpr({}, asst)); 2653 } 2654 } 2466 ty->returns = GET_ACCEPT_V( returnVals, DeclWithType ); 2467 ty->params = GET_ACCEPT_V( parameters, DeclWithType ); 2468 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2655 2469 visitType( old, ty ); 2656 2470 } 2657 2471 2658 void postvisit( const ReferenceToType * old, ast::BaseInstType * ty ) { 2472 void postvisit( const ReferenceToType * old, ast::ReferenceToType * ty ) { 2473 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2659 2474 ty->params = GET_ACCEPT_V( parameters, Expr ); 2660 2475 ty->hoistType = old->hoistType; … … 2801 2616 old->location, 2802 2617 GET_ACCEPT_1(value, Expr), 2803 (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast:: NoConstruct2618 (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast::DoConstruct 2804 2619 ); 2805 2620 } … … 2810 2625 GET_ACCEPT_V(initializers, Init), 2811 2626 GET_ACCEPT_V(designations, Designation), 2812 (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast:: NoConstruct2627 (old->get_maybeConstructed()) ? ast::MaybeConstruct : ast::DoConstruct 2813 2628 ); 2814 2629 } … … 2841 2656 #undef GET_ACCEPT_1 2842 2657 2843 ast::TranslationUnitconvert( const std::list< Declaration * > && translationUnit ) {2658 std::list< ast::ptr< ast::Decl > > convert( const std::list< Declaration * > && translationUnit ) { 2844 2659 ConverterOldToNew c; 2845 ast::TranslationUnit unit; 2846 if (Validate::SizeType) { 2847 // this should be a BasicType. 2848 auto old = strict_dynamic_cast<BasicType *>(Validate::SizeType); 2849 ast::sizeType = new ast::BasicType{ (ast::BasicType::Kind)(unsigned)old->kind }; 2850 } 2851 2660 std::list< ast::ptr< ast::Decl > > decls; 2852 2661 for(auto d : translationUnit) { 2853 2662 d->accept( c ); 2854 unit.decls.emplace_back( c.decl() );2663 decls.emplace_back( c.decl() ); 2855 2664 } 2856 2665 deleteAll(translationUnit); 2857 2858 // Load the local static varables into the global store. 2859 unit.global.sizeType = ast::sizeType; 2860 unit.global.dereference = ast::dereferenceOperator; 2861 unit.global.dtorStruct = ast::dtorStruct; 2862 unit.global.dtorDestroy = ast::dtorStructDestroy; 2863 2864 return unit; 2666 return decls; 2865 2667 }
Note:
See TracChangeset
for help on using the changeset viewer.