Skip to content

Commit

Permalink
Further improvements to isAlreadyDefined
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 7, 2024
1 parent 20a4046 commit 701d667
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/analysis/typepal/Collector.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -333,42 +333,18 @@ Collector newCollector(str modelName, map[str,Tree] namedTrees, TypePalConfig co
return appl(prod(sort("$PREDEFINED-<id>"), [], {}),
[])[@\loc=defining[query="predefined=<id>"][fragment="<nPredefinedTree>"]];
}

bool isContainedInScopes(loc l, loc r){
outer = r;
do {
if(isContainedIn(l, outer)){
return true;
}
if(scopes[outer]?) {
outer2 = scopes[outer];
if(isContainedIn(outer2, currentLubScope)){
outer = outer2;
} else {
return false;
}
} else {
return false;
}
} while (true);
return false;
}

bool collector_isAlreadyDefined(str id, Tree useOrDef){

lubdefs = { def | def <- definesPerLubScope[currentLubScope], def.id == id } +
{ def | def <- lubDefinesPerLubScope[currentLubScope], def.id == id };
useOrDefLoc = getLoc(useOrDef);

if(!isEmpty(lubdefs) && any(def <- lubdefs, isContainedInScopes(useOrDefLoc, def.scope))){
if(!isEmpty(lubdefs) && any(def <- lubdefs, isContainedIn(useOrDefLoc, def.scope))){
return true;
}

// for(def <- defines, def.id == id, config.isInferrable(def.idRole), isContainedInScopes(useOrDefLoc, def.scope)){
// return true;
// }

for(def <- defines, def.id == id, isContainedInScopes(useOrDefLoc, def.scope)){
for(def <- defines, def.id == id, isContainedIn(useOrDefLoc, def.scope)){
return true;
}
return false;
Expand Down

0 comments on commit 701d667

Please sign in to comment.