Skip to content

Commit

Permalink
Made uses of getModuleName more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Dec 1, 2024
1 parent 6f281fc commit 66f40e1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
64 changes: 39 additions & 25 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,48 @@ ModuleStatus rascalTModelForLocs(
msgs = validatePathConfigForChecker(pcfg, mlocs[0]);

ModuleStatus ms = newModuleStatus(compilerConfig);
topModuleNames = {};

mnames =
for(mloc <- mlocs){
if(!exists(mloc)){
msgs += error("<mloc> does not exist", mloc);
append "LocationDoesNotExist: <mloc>";
} else {
try {
append getModuleName(mloc, pcfg);
} catch e: {
append "NoModuleNameFound: <mloc>";
msgs += error("No module name found for <mloc>", mloc);
}
}
};

if(!otherModulesWithOutdatedTpls(mlocs, pcfg)){
if(uptodateTPls(mlocs, pcfg)){
for (mloc <- mlocs) {
m = getModuleName(mloc, pcfg);
<found, tm, ms> = getTModelForModule(m, ms);
if(uptodateTPls(mlocs, mnames, pcfg)){
for (i <- index(mlocs)) {
<found, tm, ms> = getTModelForModule(mnames[i], ms);
if(!found){
throw "TModel for <m> not found (no changes)";
throw "TModel for <mnames[i]> not found (no changes)";
}
}
return ms;
}
}

for (mloc <- mlocs) {
try {
m = getModuleName(mloc, pcfg);
if(isModuleLocationInLibs(m, mloc, pcfg)){
ms.status[m] ? {} += {rsc_not_found()};
}
topModuleNames += {m};
ms.moduleLocs[m] = mloc;
msgs += toList(ms.messages[m] ? {});
} catch e:{
msgs += error(e, mloc);
for (int i <- index(mlocs)) {
mloc = mlocs[i];
mname = mnames[i];
if(isModuleLocationInLibs(mname, mloc, pcfg)){
ms.status[mname] ? {} += {rsc_not_found()};
}

ms.moduleLocs[mname] = mloc;
msgs += toList(ms.messages[mname] ? {});
}

str jobName = "";

topModuleNames = toSet(mnames);
try {
ms = getImportAndExtendGraph(topModuleNames, ms);

Expand All @@ -168,7 +179,6 @@ ModuleStatus rascalTModelForLocs(

imports_and_extends = ms.strPaths<0,2>;
<components, sorted> = stronglyConnectedComponentsAndTopSort(imports_and_extends);
//println("strong: <components>, Ambiguity: <ms.status["analysis::grammars::Ambiguity"] ? {}>");
map[str, set[str]] module2component = (m : c | c <- components, m <- c);

list[str] ordered = [];
Expand Down Expand Up @@ -489,10 +499,10 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
return rascalTModelForLocs(mlocs, compilerConfig, codgen);
}
bool uptodateTPls(list[loc] candidates, PathConfig pcfg){
for(mloc <- candidates){
mname = getModuleName(mloc, pcfg);
<found, tpl> = getTPLReadLoc(mname, pcfg);
bool uptodateTPls(list[loc] candidates, list[str] mnames, PathConfig pcfg){
for(int i <- index(candidates)){
mloc = candidates[i];
<found, tpl> = getTPLReadLoc(mnames[i], pcfg);
if(!found || lastModified(mloc) > lastModified(tpl)){
return false;
}
Expand All @@ -503,9 +513,13 @@ bool uptodateTPls(list[loc] candidates, PathConfig pcfg){
bool otherModulesWithOutdatedTpls(list[loc] candidates, PathConfig pcfg){
for(srcdir <- pcfg.srcs){
for(loc mloc <- find(srcdir, "rsc")){
mname = getModuleName(mloc, pcfg);
<found, tpl> = getTPLReadLoc(mname, pcfg);
if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){
try {
mname = getModuleName(mloc, pcfg);
<found, tpl> = getTPLReadLoc(mname, pcfg);
if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){
return true;
}
} catch e:{
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ ModuleStatus updateBOM(str qualifiedModuleName, ModuleStatus ms){
}

ModuleStatus removeTModel(str candidate, ModuleStatus ms, bool updateBOMneeded = false){
// if(candidate == "analysis::grammar::Ambiguity"){
// println("removeTModel: <candidate>, <ms.status[candidate]>");
// }
messages = [];
if(ms.status[candidate]? && tpl_saved() notin ms.status[candidate] && rsc_not_found() notin ms.status[candidate]){
pcfg = ms.pathConfig;
if(updateBOMneeded){
Expand All @@ -272,27 +268,17 @@ ModuleStatus removeTModel(str candidate, ModuleStatus ms, bool updateBOMneeded =
<found, tplLoc> = getTPLWriteLoc(candidate, pcfg);
tm = ms.tmodels[candidate];
tm = convertTModel2LogicalLocs(tm, ms.tmodels);
messages = tm.messages;
ms.status[candidate] += tpl_saved();
if(ms.compilerConfig.verbose) println("Save <candidate> before removing from cache <ms.status[candidate]>");
try {
writeBinaryValueFile(tplLoc, tm);
// if(candidate == "analysis::grammar::Ambiguity"){
// println("removeTModel <candidate>: <getLastModified(candidate, ms.pathConfig)>, tpl: <lastModified(tplLoc)>");
// }
if(traceTPL) println("Written <tplLoc>");
} catch value e: {
throw "Cannot write TPL file <tplLoc>, reason: <e>";
mloc = ms.moduleLocs[candidate] ? |unknown:///|;
ms.messages[candidate] += { error("Cannot write TPL file <tplLoc>, reason: <e>", mloc) };
}
}
// if(!isEmpty(messages)){
// ms.messages[candidate] = messages;
// println("<candidate>:"); iprintln(messages);
// }
ms.tmodels = delete(ms.tmodels, candidate);
//if(candidate == "analysis::grammar::Ambiguity"){
// println("removeTModel, end: <candidate>, <ms.status[candidate]>");
//}
return ms;
}

Expand Down

0 comments on commit 66f40e1

Please sign in to comment.