Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/analysis/typepal/Collector.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,18 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
}
}

AType(Solver) makeGetTypeInType(Tree container, Tree selector, set[IdRole] idRolesSel, loc scope){
AType(Solver) makeGetTypeInType(loc containerLoc, Tree selector, set[IdRole] idRolesSel, loc scope){
return AType(Solver s) {
return s.getTypeInType(s.getType(container), selector, idRolesSel, scope);
return s.getTypeInType(s.getType(containerLoc), selector, idRolesSel, scope);
};
}

void collector_useViaType(Tree container, Tree selector, set[IdRole] idRolesSel){
if(building){
name = normalizeName("<selector>");
sloc = getLoc(selector);
calculators += calc("useViaType `<name>` in <getLoc(container)>", sloc, [getLoc(container)], makeGetTypeInType(container, selector, idRolesSel, currentScope));
selectorLoc = getLogicalLoc(selector);
containerLoc = getLogicalLoc(container);
calculators += calc("useViaType `<name>` in <containerLoc>", selectorLoc, [containerLoc], makeGetTypeInType(containerLoc, selector, idRolesSel, toLogicalLocs(currentScope)));
} else {
throw TypePalUsage("Cannot call `useViaType` on Collector after `run`");
}
Expand Down
17 changes: 10 additions & 7 deletions src/analysis/typepal/Solver.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ Solver newSolver(map[str,Tree] namedTrees, TModel tm){

AType solver_getTypeInType(AType containerType, Tree selector, set[IdRole] idRolesSel, loc scope){
selectorLoc = getLogicalLoc(getLoc(selector));
scope = getLogicalLoc(scope);
selectorOrgName = "<selector>";
selectorName = normalizeName(selectorOrgName);

Expand All @@ -684,13 +683,15 @@ Solver newSolver(map[str,Tree] namedTrees, TModel tm){
}
if(isEmpty(valid_overloads)){
solver_report(error(selector, "Cannot access field on overloaded type %t", containerType));
} else if({<loc key, IdRole _, AType tp>} := valid_overloads){
addUse({key}, selectorUse);
} else if({<loc key, IdRole idr, AType tp>} := valid_overloads){
if(idr in idRolesSel) addUse({key}, selectorUse);
addFact(selectorLoc, tp);
return tp;
} else {
for(<loc key, IdRole idr, AType _> <- valid_overloads){
if(idr in idRolesSel) addUse({key}, selectorUse);
}
tp2 = overloadedAType(valid_overloads);
addUse(valid_overloads<0>, selectorUse);
addFact(selectorLoc, tp2);

return tp2;
Expand Down Expand Up @@ -731,13 +732,15 @@ Solver newSolver(map[str,Tree] namedTrees, TModel tm){
else
solver_report(error(selector, "No definition for type %t is available here", containerType));
}
} else if({<loc key, IdRole _, AType tp>} := valid_overloads){
addUse({key}, selectorUse);
} else if({<loc key, IdRole idr, AType tp>} := valid_overloads){
if(idr in idRolesSel) addUse({key}, selectorUse);
addFact(selectorLoc, tp);
return tp;
} else {
for(<loc key, IdRole idr, AType tp> <- valid_overloads){
if(idr in idRolesSel) addUse({key}, selectorUse);
}
tp2 = overloadedAType(valid_overloads);
addUse(valid_overloads<0>, selectorUse);
addFact(selectorLoc, tp2);
return tp2;
}
Expand Down