Skip to content

Commit 625fcda

Browse files
authored
Merge pull request #2732 from usethesource/fix/changeMultipleTimes
Fix/change multiple times
2 parents 65925cd + 776f3fc commit 625fcda

File tree

8 files changed

+167
-121
lines changed

8 files changed

+167
-121
lines changed

src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ ModuleStatus rascalTModelForLocs(
183183
mloc = mlocs[i];
184184
mname = mnames[i];
185185
if(isModuleLocationInLibs(mloc, pcfg)){
186-
ms.status[mloc] ? {} += {rsc_not_found()};
186+
ms = addProperty(mloc, ms, tpl_from_library());
187187
}
188188

189189
ms.moduleLocs[mid] = mloc;
@@ -241,18 +241,15 @@ ModuleStatus rascalTModelForLocs(
241241

242242
jobStep(jobName, intercalate(" + ", [*componentNames]), work=size(componentNames));
243243

244-
recheck = !all(m <- component, m in ms.status, (tpl_uptodate() in ms.status[m] || checked() in ms.status[m]));
244+
recheck = !all(m <- component, hasAnyProperty(m, ms, tpl_uptodate(), checked()));
245245
for(m <- component){
246246

247-
if(m notin ms.status){
248-
ms.status[m] = {};
249-
}
250247
mi += 1;
251248
if(!recheck){
252-
if(tpl_uptodate() notin ms.status[m]){
249+
if(hasNotProperty(m, ms, tpl_uptodate())){
253250
<found, tm, ms> = getTModelForModule(m, ms);
254251
if(found){
255-
ms.status[m] += {tpl_uptodate(), checked()};
252+
ms = addProperty(m, ms, tpl_uptodate(), checked());
256253
}
257254
}
258255
}
@@ -262,8 +259,7 @@ ModuleStatus rascalTModelForLocs(
262259
any_tpl_outdated = any(m <- component, tplOutdated(m, pcfg));
263260
if(any_tpl_outdated){
264261
for(m <- component){
265-
ms.status[m] -= {tpl_uptodate(), checked()};
266-
ms.status[m] += {rsc_changed()};
262+
ms = deleteProperty(m, ms, tpl_uptodate(), checked());
267263
}
268264
} else {
269265
for(m <- component){
@@ -275,26 +271,27 @@ ModuleStatus rascalTModelForLocs(
275271

276272
<m_compatible, ms> = importsAndExtendsAreBinaryCompatible(tm, imports_extends_m, ms);
277273
if(m_compatible){
278-
ms.status[m] += {tpl_uptodate(), checked(), bom_update_needed()};
274+
ms = addProperty(m, ms, tpl_uptodate(), checked(), bom_update_needed());
279275
}
280276
}
281277
} catch rascalTplVersionError(_,_,_,_): {
282-
ms.status[m] += { tpl_version_error() };
278+
ms = addProperty(m, ms, tpl_version_error());
283279
// m_compatible remains false
284280
};
285281

286282
compatible_with_all_imports = compatible_with_all_imports && m_compatible;
287283
}
288284
}
289285

290-
any_rsc_changed = any(m <- component, rsc_changed() in ms.status[m]);
291-
any_from_lib = any(m <- component, rsc_not_found() in ms.status[m]);
286+
any_rsc_changed = any(m <- component, hasProperty(m, ms, rsc_changed()));
287+
all_rsc_found = all(m <- component, hasNotProperty(m, ms, rsc_not_found()));
288+
any_from_lib = any(m <- component, hasProperty(m, ms, tpl_from_library()));
292289
all_tmodels_uptodate = true;
293290
for(m <- component){
294-
if(tpl_uptodate() notin ms.status[m] && checked() notin ms.status[m])
291+
if(hasNotProperty(m, ms, tpl_uptodate(), checked()))
295292
all_tmodels_uptodate = false;
296293
}
297-
recheckCond = !any_from_lib && (!compatible_with_all_imports || any_rsc_changed || !all_tmodels_uptodate);
294+
recheckCond = !any_from_lib && all_rsc_found && (!compatible_with_all_imports || any_rsc_changed || !all_tmodels_uptodate);
298295

299296
if(recheckCond){
300297
// if(ms.compilerConfig.verbose){
@@ -306,16 +303,16 @@ ModuleStatus rascalTModelForLocs(
306303
map[str,TModel] tmodels_for_component = ();
307304
map[MODID,set[MODID]] m_imports = ();
308305
map[MODID,set[MODID]] m_extends = ();
309-
for(m <- component, rsc_not_found() notin ms.status[m], MStatus::ignored() notin ms.status[m]){
310-
imports = { imp | <m1, importPath(), imp> <- ms.paths, m1 == m, MStatus::ignored() notin ms.status[imp]};
306+
for(m <- component, hasNotProperty(m, ms, rsc_not_found(), ModuleProperty::ignored())){
307+
imports = { imp | <m1, importPath(), imp> <- ms.paths, m1 == m, hasNotProperty(imp, ms, ModuleProperty::ignored())};
311308
m_imports[m] = imports;
312-
extends = { ext | <m1, extendPath(), ext > <- ms.paths, m1 == m, MStatus::ignored() notin ms.status[ext] };
309+
extends = { ext | <m1, extendPath(), ext > <- ms.paths, m1 == m, hasNotProperty(ext, ms, ModuleProperty::ignored()) };
313310
m_extends[m] = extends;
314311
invertedExtends = ms.paths<2,0>;
315312
if(compilerConfig.warnUnused){
316313
// Look for unused imports or extends
317314
//usedModules = {path2module[l.path] | loc l <- range(tm.useDef), tm.definitions[l].idRole == moduleId(), path2module[l.path]?};
318-
usedModules = {l | loc l <- range(tm.useDef), tm.definitions[l].idRole == moduleId()};
315+
usedModules = {l | loc l <- range(tm.useDef), l in tm.definitions, tm.definitions[l].idRole == moduleId()};
319316
usedModules += {*invertedExtends[um] | um <- usedModules}; // use of an extended module via import
320317
list[Message] imsgs = [];
321318
<success, pt, ms> = getModuleParseTree(m, ms);
@@ -327,10 +324,7 @@ ModuleStatus rascalTModelForLocs(
327324
for(imod <- pt.header.imports, imod has \module){
328325
iname = unescape("<imod.\module.name>");
329326
inameId = moduleName2moduleId(iname);
330-
if(!ms.status[inameId]?){
331-
ms.status[inameId] = {};
332-
}
333-
if({tpl_version_error(), rsc_not_found()} <= ms.status[inameId]){
327+
if(hasProperty(inameId, ms, tpl_version_error(), rsc_not_found())){
334328
imsgs += error("Rascal TPL version error for `<iname>`, no source found", imod@\loc);
335329
}
336330
if(inameId notin usedModules){
@@ -343,8 +337,8 @@ ModuleStatus rascalTModelForLocs(
343337
if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){
344338
continue check_imports;
345339
}
346-
if((inameId in component || checked() in ms.status[inameId]) && rsc_not_found() notin ms.status[inameId]){
347-
if(imod is \default){
340+
if((inameId in component || hasProperty(inameId, ms, checked())) && hasNotProperty(inameId, ms, rsc_not_found())){
341+
if(imod is \default){
348342
imsgs += warning("Unused import of `<iname>`", imod@\loc);
349343
} //else { //TODO: maybe add option to turn off info messages?
350344
//imsgs += info("Extended module `<iname>` is unused in the current module", imod@\loc);
@@ -360,34 +354,29 @@ ModuleStatus rascalTModelForLocs(
360354
}
361355
ms.messages[m] ? {} += toSet(tm.messages);
362356

363-
ms.status[m] += {tpl_uptodate(), checked()};
357+
ms = addProperty(m, ms, tpl_uptodate(), checked());
364358
if(errorsPresent(ms.messages[m])){
365-
ms.status[m] += {check_error()};
359+
ms = addProperty(m, ms, check_error());
366360
}
367361
}
368362
// prepare the TModels of the modules in this component for compilation
369363

370364
<transient_tms, ms> = prepareForCompilation(component, m_imports, m_extends, ms, tm);
371365

372366
// generate code for the modules in this component
373-
374-
for(MODID m <- component, MStatus::ignored() notin ms.status[m]){
367+
for(MODID m <- component, hasNotProperty(m, ms, ModuleProperty::ignored())){
375368
<success, pt, ms> = getModuleParseTree(m, ms);
376369
if(success){
377370
lmsgs = codgen(m, pt, transient_tms, ms, compilerConfig);
378371
ms.messages[m] += toSet(lmsgs);
379-
ms.status[m] += errorsPresent(lmsgs) ? {code_generation_error()} : {code_generated()};
372+
ms = addProperty(m, ms, errorsPresent(lmsgs) ? code_generation_error() : code_generated());
380373
}
381374
}
382375
ms = doSaveModule(component, m_imports, m_extends, ms, transient_tms, compilerConfig);
383376
for(m <- component){
384-
ms.status[m] -= {rsc_changed()};
385-
ms.status[m] += {tpl_uptodate()};
377+
ms = deleteProperty(m, ms, rsc_changed());
378+
ms = addProperty(m, ms, tpl_uptodate());
386379
}
387-
} else {
388-
;// for(m <- component){
389-
// ms.status[m] += bom_update_needed();
390-
// }
391380
}
392381
}
393382
} catch ParseError(loc src): {
@@ -433,7 +422,7 @@ tuple[set[MODID], ModuleStatus] loadImportsAndExtends(set[MODID] moduleIds, Modu
433422
pcfg = ms.pathConfig;
434423
for(<from, pathRole, imp> <- ms.paths, from in moduleIds){
435424
if(imp notin added, imp notin moduleIds){
436-
if(tpl_uptodate() in ms.status[imp]){
425+
if(hasProperty(imp, ms, tpl_uptodate())){
437426
added += imp;
438427
<found, tm, ms> = getTModelForModule(imp, ms);
439428
try {
@@ -458,15 +447,16 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleSt
458447
map[MODID, Module] idTrees = ();
459448
for(MODID mid <- moduleIds){
460449
mname = moduleId2moduleName(mid);
461-
//ms.status[mid] = {};
462-
//ms.messages[mid] = {};
463450
ms = removeTModel(mid, ms);
464451
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
465452
try {
466453
mloc = getRascalModuleLocation(mid, ms);
454+
if(endsWith(mloc.path, "tpl")){
455+
ms = addProperty(mid, ms, tpl_from_library());
456+
}
467457
} catch Message err: {
468458
ms.messages[mid] = { err };
469-
ms.status[mid] += { rsc_not_found() };
459+
ms = addProperty(mid, ms, rsc_not_found());
470460
tm = tmodel(modelName=mname, messages=[ err ]);
471461
ms = addTModel(mid, tm, ms);
472462
return <tm, ms>;
@@ -480,7 +470,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleSt
480470

481471
if(hasIgnoreCompilerTag(tagsMap)) {
482472
ms.messages[mid] ? {} += { Message::info("Ignoring module <mid>", pt.header.name@\loc) };
483-
ms.status[mid] += MStatus::ignored();
473+
ms = addProperty(mid, ms, ModuleProperty::ignored());
484474
}
485475
idTrees[mid] = pt;
486476
}
@@ -522,8 +512,8 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleSt
522512
return <tm, ms>;
523513
} else {
524514
oneOfComponent = getOneFrom(moduleIds);
525-
ms.status[oneOfComponent]? {} += { tpl_saved() }; // TODO check this, when is this executed?
526-
<found, tm, ms> = getTModelForModule(oneOfComponent, ms);
515+
ms = addProperty(oneOfComponent, ms, tpl_saved());
516+
<found, tm, ms> = getTModelForModule(oneOfComponent, ms);
527517
return <tm, ms>;
528518
}
529519
}
@@ -565,7 +555,7 @@ tuple[bool, ModuleStatus] libraryDependenciesAreCompatible(list[MODID] candidate
565555
try {
566556
<found, tm, ms> = getTModelForModule(candidate, ms);
567557
if(found){ // TODO: needed?
568-
imports_and_extends = ms.paths<0,2>[candidate];
558+
imports_and_extends = tm.paths<0,2>[candidate]; // ms.paths<0,2>[candidate];
569559
<compatible, ms> = importsAndExtendsAreBinaryCompatible(tm, imports_and_extends, ms);
570560
if(!compatible){
571561
return <false, ms>;

0 commit comments

Comments
 (0)