Changeset 7030dab for src/ResolvExpr
- Timestamp:
- Apr 6, 2020, 4:46:28 PM (5 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:
- e3bc51c
- Parents:
- 71d6bd8 (diff), 057298e (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/ResolvExpr
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AdjustExprType.cc
r71d6bd8 r7030dab 10 10 // Created On : Sat May 16 23:41:42 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:34:53 201613 // Update Count : 412 // Last Modified On : Wed Dec 11 21:43:56 2019 13 // Update Count : 6 14 14 // 15 15 … … 134 134 // replace known function-type-variables with pointer-to-function 135 135 if ( const ast::EqvClass * eqvClass = tenv.lookup( inst->name ) ) { 136 if ( eqvClass->data.kind == ast::Type Var::Ftype ) {136 if ( eqvClass->data.kind == ast::TypeDecl::Ftype ) { 137 137 return new ast::PointerType{ inst }; 138 138 } 139 139 } else if ( const ast::NamedTypeDecl * ntDecl = symtab.lookupType( inst->name ) ) { 140 140 if ( auto tyDecl = dynamic_cast< const ast::TypeDecl * >( ntDecl ) ) { 141 if ( tyDecl->kind == ast::Type Var::Ftype ) {141 if ( tyDecl->kind == ast::TypeDecl::Ftype ) { 142 142 return new ast::PointerType{ inst }; 143 143 } -
src/ResolvExpr/AlternativeFinder.cc
r71d6bd8 r7030dab 69 69 void postvisit( CastExpr * castExpr ); 70 70 void postvisit( VirtualCastExpr * castExpr ); 71 void postvisit( KeywordCastExpr * castExpr ); 71 72 void postvisit( UntypedMemberExpr * memberExpr ); 72 73 void postvisit( MemberExpr * memberExpr ); … … 1255 1256 } 1256 1257 1258 void AlternativeFinder::Finder::postvisit( KeywordCastExpr * castExpr ) { 1259 assertf( castExpr->get_result(), "Cast target should have been set in Validate." ); 1260 auto ref = dynamic_cast<ReferenceType*>(castExpr->get_result()); 1261 assert(ref); 1262 auto inst = dynamic_cast<StructInstType*>(ref->base); 1263 assert(inst); 1264 auto target = inst->baseStruct; 1265 1266 AlternativeFinder finder( indexer, env ); 1267 1268 auto pick_alternatives = [target, this](AltList & found, bool expect_ref) { 1269 for(auto & alt : found) { 1270 Type * expr = alt.expr->get_result(); 1271 if(expect_ref) { 1272 auto res = dynamic_cast<ReferenceType*>(expr); 1273 if(!res) { continue; } 1274 expr = res->base; 1275 } 1276 1277 if(auto insttype = dynamic_cast<TypeInstType*>(expr)) { 1278 auto td = alt.env.lookup(insttype->name); 1279 if(!td) { continue; } 1280 expr = td->type; 1281 } 1282 1283 if(auto base = dynamic_cast<StructInstType*>(expr)) { 1284 if(base->baseStruct == target) { 1285 alternatives.push_back( 1286 std::move(alt) 1287 ); 1288 } 1289 } 1290 } 1291 }; 1292 1293 try { 1294 // Attempt 1 : turn (thread&)X into ($thread&)X.__thrd 1295 // Clone is purely for memory management 1296 std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) }; 1297 1298 // don't prune here, since it's guaranteed all alternatives will have the same type 1299 finder.findWithoutPrune( tech1.get() ); 1300 pick_alternatives(finder.alternatives, false); 1301 1302 return; 1303 } catch(SemanticErrorException & ) {} 1304 1305 // Fallback : turn (thread&)X into ($thread&)get_thread(X) 1306 std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) }; 1307 // don't prune here, since it's guaranteed all alternatives will have the same type 1308 finder.findWithoutPrune( fallback.get() ); 1309 1310 pick_alternatives(finder.alternatives, true); 1311 1312 // Whatever happens here, we have no more fallbacks 1313 } 1314 1257 1315 namespace { 1258 1316 /// Gets name from untyped member expression (member must be NameExpr) -
src/ResolvExpr/PtrsCastable.cc
r71d6bd8 r7030dab 10 10 // Created On : Sun May 17 11:48:00 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:36:18 201613 // Update Count : 812 // Last Modified On : Wed Dec 11 21:48:33 2019 13 // Update Count : 9 14 14 // 15 15 … … 176 176 if ( const ast::NamedTypeDecl * named = symtab.lookupType( inst->name ) ) { 177 177 if ( auto tyDecl = dynamic_cast< const ast::TypeDecl * >( named ) ) { 178 if ( tyDecl->kind == ast::Type Var::Ftype ) {178 if ( tyDecl->kind == ast::TypeDecl::Ftype ) { 179 179 return -1; 180 180 } 181 181 } 182 182 } else if ( const ast::EqvClass * eqvClass = env.lookup( inst->name ) ) { 183 if ( eqvClass->data.kind == ast::Type Var::Ftype ) {183 if ( eqvClass->data.kind == ast::TypeDecl::Ftype ) { 184 184 return -1; 185 185 } -
src/ResolvExpr/Resolver.cc
r71d6bd8 r7030dab 9 9 // Author : Aaron B. Moss 10 10 // Created On : Sun May 17 12:17:01 2015 11 // Last Modified By : A aron B. Moss12 // Last Modified On : Wed May 29 11:00:00 201913 // Update Count : 24 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 27 11:58:00 2020 13 // Update Count : 242 14 14 // 15 15 … … 84 84 void previsit( ThrowStmt * throwStmt ); 85 85 void previsit( CatchStmt * catchStmt ); 86 void postvisit( CatchStmt * catchStmt ); 86 87 void previsit( WaitForStmt * stmt ); 87 88 … … 559 560 // TODO: Replace *exception type with &exception type. 560 561 if ( throwStmt->get_expr() ) { 561 const StructDecl * exception_decl = indexer.lookupStruct( "__cfa abi_ehm__base_exception_t" );562 const StructDecl * exception_decl = indexer.lookupStruct( "__cfaehm_base_exception_t" ); 562 563 assert( exception_decl ); 563 564 Type * exceptType = new PointerType( noQualifiers, new StructInstType( noQualifiers, const_cast<StructDecl *>(exception_decl) ) ); … … 567 568 568 569 void Resolver_old::previsit( CatchStmt * catchStmt ) { 570 // Until we are very sure this invarent (ifs that move between passes have thenPart) 571 // holds, check it. This allows a check for when to decode the mangling. 572 if ( IfStmt * ifStmt = dynamic_cast<IfStmt *>( catchStmt->body ) ) { 573 assert( ifStmt->thenPart ); 574 } 575 // Encode the catchStmt so the condition can see the declaration. 569 576 if ( catchStmt->cond ) { 570 findSingleExpression( catchStmt->cond, new BasicType( noQualifiers, BasicType::Bool ), indexer ); 577 IfStmt * ifStmt = new IfStmt( catchStmt->cond, nullptr, catchStmt->body ); 578 catchStmt->cond = nullptr; 579 catchStmt->body = ifStmt; 580 } 581 } 582 583 void Resolver_old::postvisit( CatchStmt * catchStmt ) { 584 // Decode the catchStmt so everything is stored properly. 585 IfStmt * ifStmt = dynamic_cast<IfStmt *>( catchStmt->body ); 586 if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) { 587 assert( ifStmt->condition ); 588 assert( ifStmt->elsePart ); 589 catchStmt->cond = ifStmt->condition; 590 catchStmt->body = ifStmt->elsePart; 591 ifStmt->condition = nullptr; 592 ifStmt->elsePart = nullptr; 593 delete ifStmt; 571 594 } 572 595 } … … 1454 1477 if ( throwStmt->expr ) { 1455 1478 const ast::StructDecl * exceptionDecl = 1456 symtab.lookupStruct( "__cfa abi_ehm__base_exception_t" );1479 symtab.lookupStruct( "__cfaehm_base_exception_t" ); 1457 1480 assert( exceptionDecl ); 1458 1481 ast::ptr< ast::Type > exceptType = … … 1466 1489 1467 1490 const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) { 1491 // TODO: This will need a fix for the decl/cond scoping problem. 1468 1492 if ( catchStmt->cond ) { 1469 1493 ast::ptr< ast::Type > boolType = new ast::BasicType{ ast::BasicType::Bool }; -
src/ResolvExpr/Unify.cc
r71d6bd8 r7030dab 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:27:10 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Sep 4 10:00:00201913 // Update Count : 4 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:43:05 2019 13 // Update Count : 46 14 14 // 15 15 … … 34 34 #include "Common/PassVisitor.h" // for PassVisitor 35 35 #include "FindOpenVars.h" // for findOpenVars 36 #include " Parser/LinkageSpec.h"// for C36 #include "SynTree/LinkageSpec.h" // for C 37 37 #include "SynTree/Constant.h" // for Constant 38 38 #include "SynTree/Declaration.h" // for TypeDecl, TypeDecl::Data, Declarati... … … 771 771 if ( const ast::EqvClass * clz = tenv.lookup( typeInst->name ) ) { 772 772 // expand ttype parameter into its actual type 773 if ( clz->data.kind == ast::Type Var::Ttype && clz->bound ) {773 if ( clz->data.kind == ast::TypeDecl::Ttype && clz->bound ) { 774 774 return clz->bound; 775 775 }
Note: See TracChangeset
for help on using the changeset viewer.