Skip to content

Commit

Permalink
Fixing issues with library modules
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 30, 2024
1 parent 4412c4d commit fe61727
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ ModuleStatus rascalTModelForLocs(

for (mloc <- mlocs) {
m = getModuleName(mloc, pcfg);
if(isModuleLocationInLibs(mloc, pcfg)){
ms.status[m] ? {} += rsc_not_found();
if(isModuleLocationInLibs(m, mloc, pcfg)){
ms.status[m] ? {} += {rsc_not_found()};
}
topModuleNames += {m};
ms.moduleLocs[m] = mloc;
Expand Down Expand Up @@ -186,6 +186,9 @@ ModuleStatus rascalTModelForLocs(
while(mi < nmodules) {
component = module2component[ordered[mi]];
if(component == {"IO"}){
println("IO");
}
jobStep(jobName, intercalate(" + ", [*component]), work=size(component));
recheck = !all(m <- component, ms.status[m]?, (tpl_uptodate() in ms.status[m] || checked() in ms.status[m]));
Expand Down Expand Up @@ -382,7 +385,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
ms.status[nm] = {};
ms.messages[nm] = [];
mloc = getModuleLocation(nm, pcfg);
if(mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg)){
if(mloc.extension != "rsc" || isModuleLocationInLibs(nm, mloc, pcfg)){
continue;
}
<success, pt, ms> = getModuleParseTree(nm, ms);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ data ModuleStatus =

ModuleStatus newModuleStatus(RascalCompilerConfig ccfg) = moduleStatus({}, {}, (), [], (), [], (), (), (), (), ccfg.typepalPathConfig, ccfg);

bool isModuleLocationInLibs(loc l, PathConfig pcfg)
= !isEmpty(pcfg.libs) && any(lib <- pcfg.libs, l.scheme == lib.scheme && l.path == lib.path);
bool isModuleLocationInLibs(str mname, loc l, PathConfig pcfg){
res = l.extension == "tpl" || !isEmpty(pcfg.libs) && any(lib <- pcfg.libs, l.scheme == lib.scheme && l.path == lib.path);
//println("isModuleLocationInLibs: <mname>, <l> ==\> <res>");
return res;
}

bool traceTPL = false;
bool traceParseTreeCache = false;
Expand Down Expand Up @@ -148,7 +151,7 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, Mo
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
// Make sure we found a real source module (as opposed to a tpl module in a library
if(mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg)) {
if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) {
ms.status[qualifiedModuleName] += {rsc_not_found()};
throw "No src or library module";
}
Expand Down Expand Up @@ -286,8 +289,12 @@ tuple[bool, TModel, ModuleStatus] getTModelForModule(str qualifiedModuleName, Mo
try {
tpl = readBinaryValueFile(#TModel, tplLoc);
if(tpl.rascalTplVersion? && isValidRascalTplVersion(tpl.rascalTplVersion)){
tpl.convertedToPhysical = false; // temporary
tpl = convertTModel2PhysicalLocs(tpl);

mloc = getModuleLocation(qualifiedModuleName, pcfg);
if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)){
ms.status[qualifiedModuleName] ? {} += rsc_not_found();
}
ms.tmodels[qualifiedModuleName] = tpl;
ms.status[qualifiedModuleName] ? {} += {tpl_uptodate(), tpl_saved()};
if(qualifiedModuleName notin hardwired){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
if(!allImportsAndExtendsValid){ // Check that the source code of qualifiedModuleName is available
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
if(mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg)) throw "No src or library module 1"; //There is only a tpl file available
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);
if(!compatible){
Expand Down Expand Up @@ -259,7 +259,7 @@ 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(mloc, ms.pathConfig)) throw "No src or library module 2";
//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) ];
ms.status[iname] += { rsc_not_found() };
Expand Down Expand Up @@ -332,6 +332,9 @@ rel[str,datetime,PathRole] makeBom(str qualifiedModuleName, set[str] imports, se
+ { <qualifiedModuleName, getLastModified(qualifiedModuleName, moduleLastModified, pcfg), importPath() > };
}
void updateBOM(str qualifiedModuleName, set[str] imports, set[str] extends, ModuleStatus ms){
if(isModuleLocationInLibs(qualifiedModuleName, ms.moduleLocs[qualifiedModuleName], ms.pathConfig)){
return;
}
<found, tm, ms> = getTModelForModule(qualifiedModuleName, ms);
if(found){
newBom = makeBom(qualifiedModuleName, imports, extends, ms);
Expand Down Expand Up @@ -451,6 +454,7 @@ ModuleStatus doSaveModule(set[str] component, map[str,set[str]] m_imports, map[s
case loc l : if(!isEmpty(l.fragment)) insert l[fragment=""];
};

m1.convertedToPhysical = false;
ms.status[qualifiedModuleName] -= {tpl_saved()};
ms = addTModel(qualifiedModuleName, m1, ms);
//println("doSaveModule"); iprintln(m1.logical2physical);
Expand Down

0 comments on commit fe61727

Please sign in to comment.