- File:
-
- 1 edited
-
src/ResolvExpr/CandidateFinder.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rc75b30a r61e362f 891 891 } else if ( auto unionInst = aggrExpr->result.as< ast::UnionInstType >() ) { 892 892 addAggMembers( unionInst, aggrExpr, *cand, Cost::unsafe, "" ); 893 } else if ( auto enumInst = aggrExpr->result.as< ast::EnumInstType >() ) {894 // The Attribute Arrays are not yet generated, need to proxy them895 // as attribute function call896 const CodeLocation & location = cand->expr->location;897 if ( enumInst->base && enumInst->base->base ) {898 auto valueName = new ast::NameExpr(location, "valueE");899 auto untypedValueCall = new ast::UntypedExpr(900 location, valueName, { aggrExpr } );901 auto result = ResolvExpr::findVoidExpression( untypedValueCall, context );902 assert( result.get() );903 CandidateRef newCand = std::make_shared<Candidate>(904 *cand, result, Cost::safe );905 candidates.emplace_back( std::move( newCand ) );906 }907 893 } 908 894 } … … 975 961 976 962 if (argType.as<ast::PointerType>()) funcFinder.otypeKeys.insert(Mangle::Encoding::pointer); 963 // else if (const ast::EnumInstType * enumInst = argType.as<ast::EnumInstType>()) { 964 // const ast::EnumDecl * enumDecl = enumInst->base; // Here 965 // if ( const ast::Type* enumType = enumDecl->base ) { 966 // // instance of enum (T) is a instance of type (T) 967 // funcFinder.otypeKeys.insert(Mangle::mangle(enumType, Mangle::NoGenericParams | Mangle::Type)); 968 // } else { 969 // // instance of an untyped enum is techically int 970 // funcFinder.otypeKeys.insert(Mangle::mangle(enumDecl, Mangle::NoGenericParams | Mangle::Type)); 971 // } 972 // } 977 973 else funcFinder.otypeKeys.insert(Mangle::mangle(argType, Mangle::NoGenericParams | Mangle::Type)); 978 974 } … … 1403 1399 // not sufficient to just pass `variableExpr` here, type might have changed since 1404 1400 // creation 1405 if ( auto obj = dynamic_cast<const ast::ObjectDecl *>( variableExpr->var.get() )) { 1406 if ( auto enumInstType = dynamic_cast<const ast::EnumInstType *>( obj->type.get() ) ) { 1407 if ( enumInstType->base && enumInstType->base->base ) { 1408 const CodeLocation & location = variableExpr->location; 1409 auto ids = symtab.lookupId( "valueE" ); 1410 for ( ast::SymbolTable::IdData & id : ids ) { 1411 if ( auto func = id.id.as<ast::FunctionDecl>() ) { 1412 if ( func->params.size() == 1 ) { 1413 ast::ptr<ast::DeclWithType> valueEParam = func->params.front(); 1414 auto valueEParamType = valueEParam->get_type(); 1415 ast::OpenVarSet funcOpen; 1416 ast::AssertionSet funcNeed, funcHave; 1417 ast::TypeEnvironment funcEnv{ tenv }; 1418 ast::ptr<ast::Type> common; 1419 if ( unifyInexact( valueEParamType, enumInstType, funcEnv, funcNeed, funcHave, funcOpen, WidenMode{ true, true }, common ) ) { 1420 auto appl = new ast::ApplicationExpr( location, 1421 ast::VariableExpr::functionPointer( location, func), { variableExpr } ); 1422 // addCandidate( appl, copy( tenv ), ); 1423 Candidate cand {appl, copy( tenv )}; 1424 addCandidate( cand, appl, Cost::safe ); 1425 } 1426 } 1427 } 1428 } 1429 } 1430 1431 } 1432 } 1433 addCandidate( variableExpr, tenv ); 1434 1401 addCandidate( 1402 new ast::VariableExpr{ variableExpr->location, variableExpr->var }, tenv ); 1435 1403 } 1436 1404
Note:
See TracChangeset
for help on using the changeset viewer.