Skip to content
Merged
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
32 changes: 20 additions & 12 deletions src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ ModuleStatus rascalTModelForLocs(
// }

<tm, ms> = rascalTModelComponent(component, ms);

// Convert `tm.facts` and `tm.defines` to a more efficient
// representation for later use
map[loc, AType] facts = tm.facts;
rel[str, AType] factsByPath = {<l.path, facts[l]> | loc l <- facts};
Defines defines = tm.defines;
rel[str, Define] definesByPath = {<d.defined.path, d> | Define d <- defines};

// moduleScopes += getModuleScopes(tm);
map[str,TModel] tmodels_for_component = ();
map[MODID,set[MODID]] m_imports = ();
Expand Down Expand Up @@ -328,13 +336,13 @@ ModuleStatus rascalTModelForLocs(
imsgs += error("Rascal TPL version error for `<iname>`, no source found", imod.src);
}
if(inameId notin usedModules){
if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, tm)){
if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, factsByPath)){
continue check_imports;
}
if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && implicitlyUsesLayoutOrLexical(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){
if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && implicitlyUsesLayoutOrLexical(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, factsByPath)){
continue check_imports;
}
if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){
if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, factsByPath, definesByPath)){
continue check_imports;
}
if((inameId in component || hasProperty(inameId, ms, checked())) && hasNotProperty(inameId, ms, rsc_not_found())){
Expand Down Expand Up @@ -401,20 +409,20 @@ ModuleStatus rascalTModelForLocs(
return clearTModelCache(ms);
}

bool implicitlyUsesParseTree(str modulePath, TModel tm){
return any(loc l <- tm.facts, l.path == modulePath, areified(_) <- tm.facts[l]);
bool implicitlyUsesParseTree(str modulePath, rel[str, AType] factsByPath){
return any(areified(_) <- factsByPath[modulePath]);
}

bool implicitlyUsesLayoutOrLexical(str modulePath, str importPath, TModel tm){
return any(loc l <- tm.facts, l.path == importPath, aadt(_,_,sr) := tm.facts[l], sr in {layoutSyntax(), lexicalSyntax()})
&& any(loc l <- tm.facts, l.path == modulePath, aadt(_,_,contextFreeSyntax()) := tm.facts[l]);
bool implicitlyUsesLayoutOrLexical(str modulePath, str importPath, rel[str, AType] factsByPath){
return any(aadt(_,_,sr) <- factsByPath[importPath], sr in {layoutSyntax(), lexicalSyntax()})
&& any(aadt(_,_,contextFreeSyntax()) <- factsByPath[modulePath]);
}

bool usesOrExtendsADT(str modulePath, str importPath, TModel tm){
usedADTs = { unset(tm.facts[l], "alabel") | loc l <- tm.facts, l.path == modulePath, aadt(_,_,_) := tm.facts[l] };
definedADTs = { unset(the_adt, "alabel") | Define d <- tm.defines, d.defined.path == modulePath, defType(the_adt:aadt(_,_,_)) := d.defInfo };
bool usesOrExtendsADT(str modulePath, str importPath, rel[str, AType] factsByPath, rel[str, Define] definesByPath){
usedADTs = { unset(the_adt, "alabel") | the_adt:aadt(_,_,_) <- factsByPath[modulePath] };
definedADTs = { unset(the_adt, "alabel") | Define d <- definesByPath[modulePath], defType(the_adt:aadt(_,_,_)) := d.defInfo };
usedOrDefinedADTs = usedADTs + definedADTs;
res = any(loc l <- tm.facts, l.path == importPath, the_adt:aadt(_,_,_) := tm.facts[l], unset(the_adt, "alabel") in usedOrDefinedADTs);
res = any(the_adt:aadt(_,_,_) <- factsByPath[importPath], unset(the_adt, "alabel") in usedOrDefinedADTs);
return res;
}

Expand Down
Loading