Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit

Permalink
Make use of getModuleLocation and getModuleName more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Nov 30, 2024
1 parent 3db7d2c commit 6f281fc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
15 changes: 13 additions & 2 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,17 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
for(str nm <- moduleNames){
//ms.status[nm] = {};
ms.messages[nm] = {};
mloc = getModuleLocation(nm, pcfg);
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
try {
mloc = getModuleLocation(nm, pcfg);
} catch e: {
err = error("Cannot get location for <nm>: <e>", mloc);
ms.messages[nm] = { err };
ms.status[nm] += { rsc_not_found() };
tm = tmodel(modelName=nm, messages=[ err ]);
ms = addTModel(nm, tm, ms);
return <tm, ms>;
}
if(mloc.extension != "rsc" || isModuleLocationInLibs(nm, mloc, pcfg)){
continue;
}
Expand Down Expand Up @@ -470,8 +480,9 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
mlocs += [ getModuleLocation(moduleName, pcfg) ];
} catch value e: {
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
err = error("Cannot get location for <moduleName>: <e>", mloc);
ms = newModuleStatus(compilerConfig);
ms.messages[moduleName] = { error("<e>", mloc) };
ms.messages[moduleName] = { err };
return ms;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM
}

bool tplOutdated(str qualifiedModuleName, PathConfig pcfg){
mloc = getModuleLocation(qualifiedModuleName, pcfg);
<found, tpl> = getTPLReadLoc(qualifiedModuleName, pcfg);
lmMloc = lastModified(mloc);
lmTpl = lastModified(tpl);
res = !found || lmMloc > lmTpl;
//println("tplOutdated <qualifiedModuleName>: <res>; mloc: <lmMloc> \> tpl: <lmTpl>: <lmMloc > lmTpl>, (<mloc>, <tpl>)");
return res;
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
<found, tpl> = getTPLReadLoc(qualifiedModuleName, pcfg);
lmMloc = lastModified(mloc);
lmTpl = lastModified(tpl);
res = !found || lmMloc > lmTpl;
//println("tplOutdated <qualifiedModuleName>: <res>; mloc: <lmMloc> \> tpl: <lmTpl>: <lmMloc > lmTpl>, (<mloc>, <tpl>)");
return res;
} catch e: {
return false;
}
}

int parseTreeCacheSize = 20;
Expand Down Expand Up @@ -166,7 +170,7 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, Mo
throw "No src or library module";
}
} catch _: {
//ms.messages[qualifiedModuleName] ? [] = [error("Module <qualifiedModuleName> not found", mloc)];
ms.messages[qualifiedModuleName] ? {} += {error("Module <qualifiedModuleName> not found", mloc)};
mpt = [Module] "module <qualifiedModuleName>";
//ms.parseTrees[qualifiedModuleName] = mpt;
ms.moduleLocs[qualifiedModuleName] = mloc;
Expand Down
18 changes: 14 additions & 4 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import util::Reflective;
import util::Benchmark;
import lang::rascalcore::compile::util::Names; // TODO: refactor, this is an undesired dependency on compile

str getModuleName(loc mloc, map[loc,str] moduleStrs, PathConfig pcfg){
private str getModuleName(loc mloc, map[loc,str] moduleStrs, PathConfig pcfg){
if(moduleStrs[mloc]? ){
return moduleStrs[mloc];
}
Expand Down Expand Up @@ -138,7 +138,17 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
}
if(!allImportsAndExtendsValid){ // Check that the source code of qualifiedModuleName is available
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
} catch e: {
err = error("Cannot get location for <qualifiedModuleName>: <e>", mloc);
ms.messages[qualifiedModuleName] = { err };
tm = tmodel(modelName=qualifiedModuleName, messages=[ err ]);
ms = addTModel(qualifiedModuleName, tm, ms);
ms.status[qualifiedModuleName] += { rsc_not_found() };
return ms;
}
if(mloc.extension != "rsc" || isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) throw "No src or library module 1"; //There is only a tpl file available
} catch value _:{
<compatible, ms> = isCompatibleBinaryLibrary(tm, domain(localImportsAndExtends), ms);
Expand Down Expand Up @@ -269,9 +279,9 @@ tuple[ModuleStatus, rel[str, PathRole, str]] getModulePathsAsStr(Module m, Modul
ms.status[iname] = ms.status[iname] ? {};
try {
mloc = getModuleLocation(iname, ms.pathConfig);
//if(mloc.extension != "rsc" || isModuleLocationInLibs(iname, mloc, ms.pathConfig)) throw "No src or library module 2";
} catch str msg: {
ms.messages[moduleName] ? {} += { error(msg, imod@\loc) };
err = error("Cannot get location for <iname>: <msg>", imod@\loc);
ms.messages[moduleName] ? {} += { err };
ms.status[iname] += { rsc_not_found() };
}
}
Expand Down

0 comments on commit 6f281fc

Please sign in to comment.