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

Commit 087a363

Browse files
committed
Merge branch 'shallow-incremental-checking'
2 parents f3f5cce + 884d5b0 commit 087a363

File tree

15 files changed

+373
-143
lines changed

15 files changed

+373
-143
lines changed

src/org/rascalmpl/core/library/CheckTestSources.rsc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void checkTestSources(list[str] cmdLineArgs) {
2323
println("PathConfig for type checking test sources:\n");
2424
iprintln(testConfig);
2525

26-
testCompilerConfig = rascalCompilerConfig(testConfig)[logPathConfig=false][forceCompilationTopModule=false];
26+
testCompilerConfig = rascalCompilerConfig(testConfig)[logPathConfig=false];
2727
total = 0;
2828

2929
println(readFile(|lib://rascal/META-INF/MANIFEST.MF|));
@@ -128,6 +128,9 @@ tuple[str, int] safeCheck(str \module, RascalCompilerConfig compilerConfig) {
128128
//iprintln(result.tmodels[\module].facts);
129129
<found, tm, result> = getTModelForModule(\module, result);
130130
if(found && !isEmpty(tm.messages)){
131+
if(/error(_,_) := tm.messages){
132+
println("*** ERRORS ***");
133+
}
131134
iprintln(tm.messages);
132135
}
133136
return <"", cpuTime()-start_time>;

src/org/rascalmpl/core/library/CompileTestSources.rsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void compileTestSources(PathConfig pcfg) {
3434
println("PathConfig for compiling test sources:\n");
3535
iprintln(testConfig);
3636

37-
testCompilerConfig = getRascalCoreCompilerConfig(testConfig)[logPathConfig=false][forceCompilationTopModule=false];
37+
testCompilerConfig = getRascalCoreCompilerConfig(testConfig)[logPathConfig=false];
3838
total = 0;
3939

4040
println(readFile(|lib://rascal/META-INF/MANIFEST.MF|));

src/org/rascalmpl/core/library/GenerateTestSources.rsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void generateTestSources(list[str] cmdLineArgs) {
3636
libs = [ ]
3737
);
3838

39-
testCompilerConfig = getRascalCoreCompilerConfig(testConfig)[logPathConfig=false][forceCompilationTopModule=false];
39+
testCompilerConfig = getRascalCoreCompilerConfig(testConfig)[logPathConfig=false];
4040

4141
map[str,int] durations = ();
4242

src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ extend lang::rascalcore::grammar::definition::Characters;
1010

1111
import Node;
1212
import Set;
13-
//import IO;
1413

1514
// ---- asubtype --------------------------------------------------------------
1615

src/org/rascalmpl/core/library/lang/rascalcore/check/ATypeBase.rsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ data AType (str alabel = "")
6363
| avalue()
6464
;
6565

66-
@memo{expireAfter(minutes=5).maximumSize(1000)}
66+
@memo{expireAfter(minutes=5),maximumSize(1000)}
6767
AType overloadedAType(rel[loc, IdRole, AType] overloads){
6868
if(all(<loc _, IdRole _, AType t> <- overloads, aadt(_, _, _) := t)){
6969
str adtName = "";

src/org/rascalmpl/core/library/lang/rascalcore/check/BasicRascalConfig.rsc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,5 @@ data TypePalConfig(
147147
bool logPathConfig = false, // log PathConfig that is used
148148
149149
bool optimizeVisit = true, // Options for compiler developer
150-
bool enableAsserts = true,
151-
bool forceCompilationTopModule = false
150+
bool enableAsserts = true
152151
);

src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc

Lines changed: 73 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -121,43 +121,50 @@ ModuleStatus rascalTModelForLocs(
121121
list[Message](str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen
122122
){
123123
pcfg = compilerConfig.typepalPathConfig;
124+
124125
if(compilerConfig.logPathConfig) { iprintln(pcfg); }
125126
126127
msgs = validatePathConfigForChecker(pcfg, mlocs[0]);
127128
128129
ModuleStatus ms = newModuleStatus(compilerConfig);
129130
topModuleNames = {};
130131
132+
if(!otherModulesWithOutdatedTpls(mlocs, pcfg)){
133+
if(uptodateTPls(mlocs, pcfg)){
134+
for (mloc <- mlocs) {
135+
m = getModuleName(mloc, pcfg);
136+
<found, tm, ms> = getTModelForModule(m, ms);
137+
if(!found){
138+
throw "TModel for <m> not found (no changes)";
139+
}
140+
}
141+
return ms;
142+
}
143+
}
144+
131145
for (mloc <- mlocs) {
132146
m = getModuleName(mloc, pcfg);
133147
if(isModuleLocationInLibs(m, mloc, pcfg)){
134148
ms.status[m] ? {} += {rsc_not_found()};
135149
}
136150
topModuleNames += {m};
137151
ms.moduleLocs[m] = mloc;
138-
msgs += ms.messages[m] ? [];
152+
msgs += toList(ms.messages[m] ? {});
139153
}
140154
141155
str jobName = "";
142156
143157
try {
144-
ms = getImportAndExtendGraph(topModuleNames, compilerConfig);
158+
ms = getImportAndExtendGraph(topModuleNames, ms);
145159
146-
if(/error(_,_) := ms.messages){
147-
148-
return clearTModelCache(ms);
149-
}
150-
151-
if(compilerConfig.forceCompilationTopModule){
152-
for(str nm <- topModuleNames){
153-
ms.status[nm] = {};
154-
}
155-
}
160+
// if(/error(_,_) := ms.messages){
156161
162+
// return clearTModelCache(ms);
163+
// }
157164
158165
imports_and_extends = ms.strPaths<0,2>;
159166
<components, sorted> = stronglyConnectedComponentsAndTopSort(imports_and_extends);
160-
167+
//println("strong: <components>, Ambiguity: <ms.status["analysis::grammars::Ambiguity"] ? {}>");
161168
map[str, set[str]] module2component = (m : c | c <- components, m <- c);
162169
163170
list[str] ordered = [];
@@ -185,7 +192,9 @@ ModuleStatus rascalTModelForLocs(
185192
jobStart(jobName, totalWork=nmodules);
186193
187194
while(mi < nmodules) {
195+
188196
component = module2component[ordered[mi]];
197+
//println("while: <component>, Ambiguity: <ms.status["analysis::grammars::Ambiguity"] ? {}>");
189198
jobStep(jobName, intercalate(" + ", [*component]), work=size(component));
190199
191200
recheck = !all(m <- component, ms.status[m]?, (tpl_uptodate() in ms.status[m] || checked() in ms.status[m]));
@@ -205,11 +214,12 @@ ModuleStatus rascalTModelForLocs(
205214
for(m <- component){
206215
m_compatible = false;
207216
<found, tm, ms> = getTModelForModule(m, ms);
208-
if(found){
217+
if(found && !tplOutdated(m, pcfg)){
209218
imports_extends_m = imports_and_extends[m];
219+
210220
<m_compatible, ms> = importsAndExtendsAreBinaryCompatible(tm, imports_extends_m, ms);
211221
if(m_compatible){
212-
ms.status[m] += {tpl_uptodate(), checked()};
222+
ms.status[m] += {tpl_uptodate(), checked(), bom_update_needed()};
213223
}
214224
}
215225
compatible_with_all_imports = compatible_with_all_imports && m_compatible;
@@ -244,11 +254,11 @@ ModuleStatus rascalTModelForLocs(
244254
// Look for unused imports or exports
245255
usedModules = {path2module[l.path] | loc l <- range(tm.useDef), tm.definitions[l].idRole != moduleId(), path2module[l.path]?};
246256
usedModules += {*invertedExtends[um] | um <- usedModules}; // use of an extended module via import
247-
msgs = [];
257+
list[Message] imsgs = [];
248258
<success, pt, ms> = getModuleParseTree(m, ms);
249259
if(success){
250260
if(compilerConfig.infoModuleChecked){
251-
msgs += [info("Checked <m>", pt.header.name@\loc)];
261+
imsgs += [info("Checked <m>", pt.header.name@\loc)];
252262
}
253263
check_imports:
254264
for(imod <- pt.header.imports, imod has \module){
@@ -268,20 +278,20 @@ ModuleStatus rascalTModelForLocs(
268278
}
269279
if(checked() in ms.status[iname] && rsc_not_found() notin ms.status[iname]){
270280
if(imod is \default){
271-
msgs += warning("Unused import of `<iname>`", imod@\loc);
281+
imsgs += warning("Unused import of `<iname>`", imod@\loc);
272282
} //else { //TODO: maybe add option to turn off info messages?
273-
//msgs += info("Extended module `<iname>` is unused in the current module", imod@\loc);
283+
//imsgs += info("Extended module `<iname>` is unused in the current module", imod@\loc);
274284
//}
275285
}
276286
}
277287
}
278-
tm.messages += msgs;
288+
tm.messages += imsgs;
279289
}
280290
}
281291
if(ms.messages[m]?){
282-
tm.messages += ms.messages[m];
292+
tm.messages += toList(ms.messages[m]);
283293
}
284-
ms.messages[m] ? [] += tm.messages;
294+
ms.messages[m] ? {} += toSet(tm.messages);
285295
286296
ms.status[m] += {tpl_uptodate(), checked()};
287297
if(!isEmpty([ e | e:error(_,_) <- ms.messages[m] ])){
@@ -298,7 +308,7 @@ ModuleStatus rascalTModelForLocs(
298308
<success, pt, ms> = getModuleParseTree(m, ms);
299309
if(success){
300310
msgs = codgen(m, pt, transient_tms, ms, compilerConfig);
301-
ms.messages[m] += msgs;
311+
ms.messages[m] += toSet(msgs);
302312
ms.status[m] += {code_generated()};
303313
}
304314
}
@@ -308,31 +318,26 @@ ModuleStatus rascalTModelForLocs(
308318
ms.status[m] += {tpl_uptodate()};
309319
}
310320
} else {
311-
for(m <- component){
312-
// imports = { imp | <m1, importPath(), imp> <- ms.strPaths, m1 == m };
313-
// extends = { ext | <m1, extendPath(), ext > <- ms.strPaths, m1 == m };
314-
315-
imports = ms.strPaths[m,importPath()];
316-
extends = ms.strPaths[m,extendPath()];
317-
updateBOM(m, imports, extends, ms);
321+
for(m <- component){
322+
ms.status[m] += bom_update_needed();
318323
}
319324
}
320325
}
321326
} catch ParseError(loc src): {
322327
for(str mname <- topModuleNames){
323-
ms.messages[mname] = [ error("Parse error", src) ];
328+
ms.messages[mname] = { error("Parse error", src) };
324329
}
325330
} catch rascalTplVersionError(str txt):{
326331
for(str mname <- topModuleNames){
327-
ms.messages[mname] = [error("<txt>", ms.moduleLocs[mname] ? |unknown:///|)];
332+
ms.messages[mname] = { error("<txt>", ms.moduleLocs[mname] ? |unknown:///|) };
328333
}
329334
} catch Message msg: {
330335
for(str mname <- topModuleNames){
331-
ms.messages[mname] = [error("During type checking: <msg>", msg.at)];
336+
ms.messages[mname] = { error("During type checking: <msg>", msg.at) };
332337
}
333338
} catch rascalBinaryNeedsRecompilation(str txt): {
334339
for(str mname <- topModuleNames){
335-
ms.messages[mname] = [error("Binary module `<txt>` needs recompilation", |unknown:///|)];
340+
ms.messages[mname] = { error("Binary module `<txt>` needs recompilation", |unknown:///|) };
336341
}
337342
}
338343
@@ -368,7 +373,7 @@ tuple[set[str], ModuleStatus] loadImportsAndExtends(str moduleName, ModuleStatus
368373
try {
369374
c.addTModel(tm);
370375
} catch wrongTplVersion(str reason): {
371-
ms.messages[imp] ? [] += [ Message::error(reason, ms.moduleLocs[imp]) ];
376+
ms.messages[imp] ? {} += { Message::error(reason, ms.moduleLocs[imp]) };
372377
}
373378
}
374379
}
@@ -383,8 +388,8 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
383388
modelName = intercalate(" + ", toList(moduleNames));
384389
map[str, Module] namedTrees = ();
385390
for(str nm <- moduleNames){
386-
ms.status[nm] = {};
387-
ms.messages[nm] = [];
391+
//ms.status[nm] = {};
392+
ms.messages[nm] = {};
388393
mloc = getModuleLocation(nm, pcfg);
389394
if(mloc.extension != "rsc" || isModuleLocationInLibs(nm, mloc, pcfg)){
390395
continue;
@@ -394,7 +399,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
394399
tagsMap = getTags(pt.header.tags);
395400
396401
if(ignoreCompiler(tagsMap)) {
397-
ms.messages[nm] ? [] += [ Message::info("Ignoring module <nm>", pt@\loc) ];
402+
ms.messages[nm] ? {} += { Message::info("Ignoring module <nm>", pt@\loc) };
398403
ms.status[nm] += MStatus::ignored();
399404
} else {
400405
namedTrees[nm] = pt;
@@ -432,6 +437,9 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
432437
tm = s.run();
433438
}
434439
tm.usesPhysicalLocs = true;
440+
// for(mname <- moduleNames){
441+
// ms.messages[mname] = tm.messages;
442+
// }
435443
//iprintln(tm.messages);
436444
437445
check_time = (cpuTime() - start_check)/1000000;
@@ -451,7 +459,6 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
451459
RascalCompilerConfig compilerConfig,
452460
list[Message] (str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen){
453461
454-
455462
pcfg = compilerConfig.typepalPathConfig;
456463
mlocs = [];
457464
for(moduleName <- moduleNames){
@@ -460,24 +467,47 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
460467
} catch value e: {
461468
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
462469
ms = newModuleStatus(compilerConfig);
463-
ms.messages[moduleName] = [ error("<e>", mloc) ];
470+
ms.messages[moduleName] = { error("<e>", mloc) };
464471
return ms;
465472
}
466473
}
467474
return rascalTModelForLocs(mlocs, compilerConfig, codgen);
468475
}
469476
477+
bool uptodateTPls(list[loc] candidates, PathConfig pcfg){
478+
for(mloc <- candidates){
479+
mname = getModuleName(mloc, pcfg);
480+
<found, tpl> = getTPLReadLoc(mname, pcfg);
481+
if(!found || lastModified(mloc) > lastModified(tpl)){
482+
return false;
483+
}
484+
}
485+
return true;
486+
}
487+
488+
bool otherModulesWithOutdatedTpls(list[loc] candidates, PathConfig pcfg){
489+
for(srcdir <- pcfg.srcs){
490+
for(loc mloc <- find(srcdir, "rsc")){
491+
mname = getModuleName(mloc, pcfg);
492+
<found, tpl> = getTPLReadLoc(mname, pcfg);
493+
if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){
494+
return true;
495+
}
496+
}
497+
}
498+
return false;
499+
}
500+
470501
// ---- checker functions for IDE
471502
472503
// name of the production has to mirror the Kernel compile result
473504
data ModuleMessages = program(loc src, set[Message] messages);
474505
475-
476506
list[ModuleMessages] check(list[loc] moduleLocs, RascalCompilerConfig compilerConfig){
477507
pcfg1 = compilerConfig.typepalPathConfig; pcfg1.classloaders = []; pcfg1.javaCompilerPath = [];
478508
compilerConfig.typepalPathConfig = pcfg1;
479509
ms = rascalTModelForLocs(moduleLocs, compilerConfig, dummy_compile1);
480-
return [ program(ms.moduleLocs[mname] ? |unknown:///|, toSet(ms.messages[mname])) | mname <- ms.messages ];
510+
return [ program(ms.moduleLocs[mname] ? |unknown:///|, ms.messages[mname]) | mname <- ms.messages ];
481511
}
482512
483513
list[ModuleMessages] checkAll(loc root, RascalCompilerConfig compilerConfig){
@@ -488,10 +518,7 @@ list[ModuleMessages] checkAll(loc root, RascalCompilerConfig compilerConfig){
488518
489519
map[str, list[Message]] checkModules(list[str] moduleNames, RascalCompilerConfig compilerConfig) {
490520
ModuleStatus ms = rascalTModelForNames(moduleNames, compilerConfig, dummy_compile1);
491-
tmodels = ms.tmodels;
492-
tmMsgs = (mname : tmodels[mname].messages | mname <- tmodels, !isEmpty(tmodels[mname].messages));
493-
return //(mname : tmodels[mname].messages | mname <- tmodels, !isEmpty(tmodels[mname].messages))
494-
(mname : ms.messages[mname] + (tmMsgs[mname] ? []) | mname <- ms.messages, !isEmpty(ms.messages[mname]));
521+
return (mname : toList(msgs) | mname <- ms.messages, msgs := ms.messages[mname], !isEmpty(msgs));
495522
}
496523
497524
// -- calculate rename changes

0 commit comments

Comments
 (0)