Skip to content

Commit

Permalink
Made compilerConfig more widely available; some clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 9, 2024
1 parent 58ef5a6 commit 69056c1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ModuleStatus rascalTModelForLocs(

msgs = validatePathConfigForChecker(pcfg, mlocs[0]);

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

for (mloc <- mlocs) {
Expand All @@ -139,7 +139,7 @@ ModuleStatus rascalTModelForLocs(
}

try {
ms = getImportAndExtendGraph(topModuleNames, pcfg);
ms = getImportAndExtendGraph(topModuleNames, compilerConfig);

if(/error(_,_) := ms.messages){
return ms;
Expand Down Expand Up @@ -409,7 +409,7 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
mlocs += [ getModuleLocation(moduleName, pcfg) ];
} catch value e: {
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
ms = newModuleStatus(pcfg);
ms = newModuleStatus(compilerConfig);
ms.messages[moduleName] = [ error("<e>", mloc) ];
return ms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ data ModuleStatus =
map[str,datetime] moduleLastModified,
map[str, list[Message]] messages,
map[str, set[MStatus]] status,
PathConfig pathConfig
PathConfig pathConfig,
RascalCompilerConfig compilerConfig
);

ModuleStatus newModuleStatus(PathConfig pcfg) = moduleStatus({}, {}, (), [], (), [], (), (), (), (), pcfg);
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);
Expand Down
20 changes: 10 additions & 10 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ ModuleStatus complete(ModuleStatus ms){
return ms;
}

ModuleStatus getImportAndExtendGraph(set[str] qualifiedModuleNames, PathConfig pcfg){
return complete((newModuleStatus(pcfg) | getImportAndExtendGraph(qualifiedModuleName, it) | qualifiedModuleName <- qualifiedModuleNames));
ModuleStatus getImportAndExtendGraph(set[str] qualifiedModuleNames, RascalCompilerConfig ccfg){
return complete((newModuleStatus(ccfg) | getImportAndExtendGraph(qualifiedModuleName, it) | qualifiedModuleName <- qualifiedModuleNames));
}

ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, PathConfig pcfg){
return complete(getImportAndExtendGraph(qualifiedModuleName, newModuleStatus(pcfg)));
ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, RascalCompilerConfig ccfg){
return complete(getImportAndExtendGraph(qualifiedModuleName, newModuleStatus(ccfg)));
}

ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
Expand Down Expand Up @@ -117,7 +117,7 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
lm = getLastModified(m, ms.moduleLastModified, pcfg);
if(lm == startOfEpoch || lm > timestampInBom) {
allImportsAndExtendsValid = false;
if(tpl_uptodate() notin ms.status[m] && lm != timestampInBom){
if(tpl_uptodate() notin ms.status[m] && lm != timestampInBom && ms.compilerConfig.verbose){
println("--- using <lm> (most recent) version of <m>,
' older <timestampInBom> version was used in previous check of <qualifiedModuleName>");
}
Expand All @@ -139,7 +139,9 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
throw rascalBinaryNeedsRecompilation(qualifiedModuleName);
} else {
allImportsAndExtendsValid = true;
println("--- reusing tmodel of <qualifiedModuleName> (source not accessible)");
if(ms.compilerConfig.verbose){
println("--- reusing tmodel of <qualifiedModuleName> (source not accessible)");
}
}
}
}
Expand Down Expand Up @@ -178,8 +180,8 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
return ms;
}

ModuleStatus getInlineImportAndExtendGraph(Tree pt, PathConfig pcfg){
ms = newModuleStatus(pcfg);
ModuleStatus getInlineImportAndExtendGraph(Tree pt, RascalCompilerConfig ccfg){
ms = newModuleStatus(ccfg);
visit(pt){
case m: (Module) `<Header header> <Body _>`: {
qualifiedModuleName = prettyPrintName(header.name);
Expand Down Expand Up @@ -387,8 +389,6 @@ ModuleStatus doSaveModule(set[str] component, map[str,set[str]] m_imports, map[s
)
){
append tup;
} else {
;//println("skip: <tup>");
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ tuple[PathConfig, RascalCompilerConfig] testConfigs(loc projectPath) {
);

RascalCompilerConfig ccfg = rascalCompilerConfig(pcfg)
[forceCompilationTopModule = true]
[verbose = true];
//[forceCompilationTopModule = true]
[verbose = false];

return <pcfg, ccfg>;
}
Expand All @@ -30,7 +30,7 @@ void checkModule(loc projectPath, str moduleName, str moduleBody, RascalCompiler
iprintln(msgs);
}

void sameNameImportResolutionBug(loc projectPath = |memory:///TestModule|, bool skipFirst = false) {
void sameNameImportResolutionBug(loc projectPath = |file:///Users/paulklint/TestModule|, bool skipFirst = false) {
remove(projectPath);
<pcfg, ccfg> = testConfigs(projectPath);

Expand Down

0 comments on commit 69056c1

Please sign in to comment.