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

Commit 9f3fb0c

Browse files
committed
Merge branch 'master' into renamings-for-move-to-rascal
2 parents 65051dd + 0c909db commit 9f3fb0c

File tree

19 files changed

+459
-136
lines changed

19 files changed

+459
-136
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
<dependency>
244244
<groupId>org.rascalmpl</groupId>
245245
<artifactId>rascal</artifactId>
246-
<version>0.40.17</version>
246+
<version>0.40.18-SNAPSHOT</version>
247247
</dependency>
248248
</dependencies>
249249
</project>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import util::Benchmark;
55
import lang::rascal::\syntax::Rascal;
66
import IO;
77
import ValueIO;
8+
import lang::rascalcore::check::ModuleLocations;
89

910
data PathConfig(
1011
loc resources = |unknown:///|,
@@ -32,7 +33,7 @@ void main(){
3233
write_time = 0;
3334
for(int _ <- [1..10]){
3435
for(qualifiedModuleName <- ["Boolean", "Type", "ParseTree", "List"]){
35-
mloc = getModuleLocation(qualifiedModuleName, pcfg);
36+
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
3637
ploc = |file:///tmp/<qualifiedModuleName>.parsetree|;
3738
//println("*** parsing <qualifiedModuleName> from <mloc>");
3839
start_time = cpuTime();

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void addCommonKeywordFields(Solver s){
7272
fieldName = "<kwf.name>";
7373
fieldType = s.getType(kwf);
7474
fieldType.alabel = fieldName;
75-
moduleName = getModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig);
75+
moduleName = getRascalModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig);
7676
commonKeywordFields += <adtType, kwField(fieldType, fieldName, moduleName, kwf.expression)>;
7777
//commonKeywordFieldNames += <adtType, fieldName, fieldType>;
7878
// TODO: reconsider this
@@ -148,7 +148,10 @@ tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports
148148
} else {
149149
<found, tm1, ms> = getTModelForModule(m, ms);
150150
if(!found) {
151-
throw "addGrammar: tmodel for <m> not found";
151+
msg = error("Cannot add grammar, tmodel for <m> not found", ms.moduleLocs[qualifiedModuleName] ? |unknown:///|);
152+
ms.messages[qualifiedModuleName] ? {} += { msg };
153+
tm1 = tmodel(modelName=qualifiedModuleName, messages=[msg]);
154+
return <tm1, ms>;
152155
}
153156
}
154157
facts = tm1.facts;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ str prettyAType(areal()) = "real";
5050
str prettyAType(arat()) = "rat";
5151
str prettyAType(astr()) = "str";
5252
str prettyAType(anum()) = "num";
53-
str prettyAType(anode(list[AType fieldType] fields)) = isEmpty(fields) ? "node" : "node(<intercalate(", ", ["<prettyAType(ft)> <ft.alabel> = ..." | ft <- fields])>)";
53+
str prettyAType(anode(list[AType] fields)) = isEmpty(fields) ? "node" : "node(<intercalate(", ", ["<prettyAType(ft)> <ft.alabel> = ..." | ft <- fields])>)";
5454
str prettyAType(avoid()) = "void";
5555
str prettyAType(avalue()) = "value";
5656
str prettyAType(aloc()) = "loc";
@@ -74,7 +74,7 @@ str prettyAType(aadt(str s, [], SyntaxRole _)) = s;
7474
str prettyAType(aadt(str s, ps, SyntaxRole _)) = "<s>[<prettyAType(ps)>]" when size(ps) > 0;
7575
7676
str prettyAType(t: acons(AType adt, /*str consName,*/
77-
list[AType fieldType] fields,
77+
list[AType] fields,
7878
list[Keyword] kwFields))
7979
= "<prettyAType(adt)>::<t.alabel>(<intercalate(", ", ["<prettyAType(ft)><ft.alabel? ? " <ft.alabel>" : "">" | ft <- fields])><isEmpty(kwFields) ? "" : ", "><intercalate(",", ["<prettyAType(kw.fieldType)> <kw.fieldName>=..." | Keyword kw <- kwFields])>)";
8080
@@ -140,7 +140,7 @@ Symbol atype2symbol1(areal()) = Symbol::\real();
140140
Symbol atype2symbol1(arat()) = \rat();
141141
Symbol atype2symbol1(astr()) = \str();
142142
Symbol atype2symbol1(anum()) = Symbol::\num();
143-
Symbol atype2symbol1(anode( list[AType fieldType] fields)) = Symbol::\node();
143+
Symbol atype2symbol1(anode( list[AType] fields)) = Symbol::\node();
144144
Symbol atype2symbol1(avoid()) = Symbol::\void();
145145
Symbol atype2symbol1(avalue()) = Symbol::\value();
146146
Symbol atype2symbol1(aloc()) = Symbol::\loc();
@@ -171,7 +171,7 @@ Symbol atype2symbol1(aadt(str s, ps, contextFreeSyntax())) = \parameterized-sort
171171
Symbol atype2symbol1(aadt(str s, ps, lexicalSyntax())) = \parameterized-lex(s, [atype2symbol(p) | p <- ps]) when size(ps) > 0;
172172
173173
Symbol atype2symbol1(t: acons(AType adt,
174-
list[AType fieldType] fields,
174+
list[AType] fields,
175175
list[Keyword] kwFields))
176176
= Symbol::cons(atype2symbol(adt), t.alabel, [atype2symbol(f) | f <- fields]); // we loose kw fields here
177177
@@ -258,7 +258,7 @@ set[Production] aprods2prods(set[AType] alts) = {aprod2prod(p) | p <- alts/*, ac
258258
Production aprod2prod(aprod(AProduction prod)) = aprod2prod(prod);
259259
260260
default Production aprod2prod(AType t) {
261-
throw "internal error: do not know how to translate a <t> to a production rule?!";
261+
throw rascalCheckerInternalError("Do not know how to translate a <t> to a production rule");
262262
}
263263
264264
Production aprod2prod(p:AProduction::prod(AType lhs, list[AType] atypes, attributes=set[AAttr] as))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ set[map[str, list[Message]]] allRascalTests(PathConfig pcfg= pathConfig(
350350
//
351351
// <_, msgs> = checkModules([qualifiedModuleName], rascalTypePalConfig(), pcfg);
352352
// iprintln(msgs);
353-
// mTplLoc = getDerivedWriteLoc(qualifiedModuleName, "tpl", pcfg);
353+
// mTplLoc = getRascalModuleDerivedWriteLoc(qualifiedModuleName, "tpl", pcfg);
354354
// mOrgModel = readBinaryValueFile(#TModel, mTplLoc);
355355
//
356356
// differences = ();
@@ -434,7 +434,7 @@ void allFiles(PathConfig pcfg = pathConfig(
434434
nskipped = 0;
435435
ncount = 0;
436436
for(p <- modulePaths){
437-
qualifiedModuleName = getModuleName(p, pcfg);
437+
qualifiedModuleName = getRascalModuleName(p, pcfg);
438438
ncount += 1;
439439
if(blacklisted(qualifiedModuleName)){
440440
println("\>\>\> <ncount>: SKIPPING <qualifiedModuleName>");

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

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extend lang::rascalcore::check::RascalConfig;
3939
extend lang::rascalcore::check::CheckerCommon;
4040

4141
import lang::rascalcore::compile::CompileTimeError;
42+
import lang::rascalcore::check::ModuleLocations;
4243
extend lang::rascalcore::check::TestConfigs;
4344

4445
import analysis::typepal::Exception;
@@ -127,37 +128,48 @@ ModuleStatus rascalTModelForLocs(
127128
msgs = validatePathConfigForChecker(pcfg, mlocs[0]);
128129
129130
ModuleStatus ms = newModuleStatus(compilerConfig);
130-
topModuleNames = {};
131+
132+
mnames =
133+
for(mloc <- mlocs){
134+
if(!exists(mloc)){
135+
msgs += error("<mloc> does not exist", mloc);
136+
append "LocationDoesNotExist: <mloc>";
137+
} else {
138+
try {
139+
append getRascalModuleName(mloc, pcfg);
140+
} catch e: {
141+
append "NoModuleNameFound: <mloc>";
142+
msgs += error("No module name found for <mloc>", mloc);
143+
}
144+
}
145+
};
131146
132147
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);
148+
if(uptodateTPls(mlocs, mnames, pcfg)){
149+
for (i <- index(mlocs)) {
150+
<found, tm, ms> = getTModelForModule(mnames[i], ms);
137151
if(!found){
138-
throw "TModel for <m> not found (no changes)";
152+
throw "TModel for <mnames[i]> not found (no changes)";
139153
}
140154
}
141155
return ms;
142156
}
143157
}
144158
145-
for (mloc <- mlocs) {
146-
try {
147-
m = getModuleName(mloc, pcfg);
148-
if(isModuleLocationInLibs(m, mloc, pcfg)){
149-
ms.status[m] ? {} += {rsc_not_found()};
150-
}
151-
topModuleNames += {m};
152-
ms.moduleLocs[m] = mloc;
153-
msgs += toList(ms.messages[m] ? {});
154-
} catch e:{
155-
msgs += error(e, mloc);
159+
for (int i <- index(mlocs)) {
160+
mloc = mlocs[i];
161+
mname = mnames[i];
162+
if(isModuleLocationInLibs(mname, mloc, pcfg)){
163+
ms.status[mname] ? {} += {rsc_not_found()};
156164
}
165+
166+
ms.moduleLocs[mname] = mloc;
167+
msgs += toList(ms.messages[mname] ? {});
157168
}
158169
159170
str jobName = "";
160171
172+
topModuleNames = toSet(mnames);
161173
try {
162174
ms = getImportAndExtendGraph(topModuleNames, ms);
163175
@@ -168,7 +180,6 @@ ModuleStatus rascalTModelForLocs(
168180
169181
imports_and_extends = ms.strPaths<0,2>;
170182
<components, sorted> = stronglyConnectedComponentsAndTopSort(imports_and_extends);
171-
//println("strong: <components>, Ambiguity: <ms.status["analysis::grammars::Ambiguity"] ? {}>");
172183
map[str, set[str]] module2component = (m : c | c <- components, m <- c);
173184
174185
list[str] ordered = [];
@@ -396,7 +407,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
396407
ms.messages[nm] = {};
397408
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
398409
try {
399-
mloc = getModuleLocation(nm, pcfg);
410+
mloc = getRascalModuleLocation(nm, pcfg);
400411
} catch e: {
401412
err = error("Cannot get location for <nm>: <e>", mloc);
402413
ms.messages[nm] = { err };
@@ -477,7 +488,7 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
477488
mlocs = [];
478489
for(moduleName <- moduleNames){
479490
try {
480-
mlocs += [ getModuleLocation(moduleName, pcfg) ];
491+
mlocs += [ getRascalModuleLocation(moduleName, pcfg) ];
481492
} catch value e: {
482493
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
483494
err = error("Cannot get location for <moduleName>: <e>", mloc);
@@ -489,10 +500,10 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
489500
return rascalTModelForLocs(mlocs, compilerConfig, codgen);
490501
}
491502
492-
bool uptodateTPls(list[loc] candidates, PathConfig pcfg){
493-
for(mloc <- candidates){
494-
mname = getModuleName(mloc, pcfg);
495-
<found, tpl> = getTPLReadLoc(mname, pcfg);
503+
bool uptodateTPls(list[loc] candidates, list[str] mnames, PathConfig pcfg){
504+
for(int i <- index(candidates)){
505+
mloc = candidates[i];
506+
<found, tpl> = getTPLReadLoc(mnames[i], pcfg);
496507
if(!found || lastModified(mloc) > lastModified(tpl)){
497508
return false;
498509
}
@@ -503,9 +514,13 @@ bool uptodateTPls(list[loc] candidates, PathConfig pcfg){
503514
bool otherModulesWithOutdatedTpls(list[loc] candidates, PathConfig pcfg){
504515
for(srcdir <- pcfg.srcs){
505516
for(loc mloc <- find(srcdir, "rsc")){
506-
mname = getModuleName(mloc, pcfg);
507-
<found, tpl> = getTPLReadLoc(mname, pcfg);
508-
if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){
517+
try {
518+
mname = getRascalModuleName(mloc, pcfg);
519+
<found, tpl> = getTPLReadLoc(mname, pcfg);
520+
if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){
521+
return true;
522+
}
523+
} catch e:{
509524
return true;
510525
}
511526
}
@@ -522,7 +537,11 @@ list[ModuleMessages] check(list[loc] moduleLocs, RascalCompilerConfig compilerCo
522537
pcfg1 = compilerConfig.typepalPathConfig; pcfg1.classloaders = []; pcfg1.javaCompilerPath = [];
523538
compilerConfig.typepalPathConfig = pcfg1;
524539
ms = rascalTModelForLocs(moduleLocs, compilerConfig, dummy_compile1);
525-
return [ program(ms.moduleLocs[mname] ? |unknown:///|, ms.messages[mname]) | mname <- ms.messages ];
540+
messagesNoModule = {};
541+
for(mname <- ms.messages, !ms.moduleLocs[mname]?){
542+
messagesNoModule += ms.messages[mname];
543+
}
544+
return [ program(ms.moduleLocs[mname], ms.messages[mname] + messagesNoModule) | mname <- ms.messages, ms.moduleLocs[mname] ? ];
526545
}
527546
528547
list[ModuleMessages] checkAll(loc root, RascalCompilerConfig compilerConfig){

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extend lang::rascalcore::check::SyntaxGetters;
1212
extend analysis::typepal::FailMessage;
1313

1414
extend lang::rascalcore::check::BasicRascalConfig;
15+
extend lang::rascalcore::check::ModuleLocations;
1516

1617
import analysis::typepal::Collector;
1718

@@ -119,7 +120,7 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM
119120
return res;
120121
} catch NoSuchKey(_): {
121122
try {
122-
mloc = getModuleLocation(qualifiedModuleName, pcfg);
123+
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
123124
res = lastModified(mloc);
124125
//println("getLastModified <mloc> via lastModified: <res>");
125126
return res;
@@ -131,7 +132,7 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM
131132
132133
bool tplOutdated(str qualifiedModuleName, PathConfig pcfg){
133134
try {
134-
mloc = getModuleLocation(qualifiedModuleName, pcfg);
135+
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
135136
<found, tpl> = getTPLReadLoc(qualifiedModuleName, pcfg);
136137
lmMloc = lastModified(mloc);
137138
lmTpl = lastModified(tpl);
@@ -163,7 +164,7 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, Mo
163164
ms.parseTreeLIFO = [qualifiedModuleName, *ms.parseTreeLIFO];
164165
mloc = |unknown:///<qualifiedModuleName>|;
165166
try {
166-
mloc = getModuleLocation(qualifiedModuleName, pcfg);
167+
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
167168
// Make sure we found a real source module (as opposed to a tpl module in a library
168169
if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) {
169170
ms.status[qualifiedModuleName] += {rsc_not_found()};
@@ -216,9 +217,6 @@ ModuleStatus clearTModelCache(ModuleStatus ms){
216217
todo -= candidate;
217218
}
218219
for(candidate <- todo){
219-
// if(candidate == "analysis::grammar::Ambiguity"){
220-
// println("clearTModelCache");
221-
// }
222220
ms = removeTModel(candidate, ms, updateBOMneeded=true);
223221
ms.status[candidate] -= bom_update_needed();
224222
}
@@ -258,10 +256,6 @@ ModuleStatus updateBOM(str qualifiedModuleName, ModuleStatus ms){
258256
}
259257
260258
ModuleStatus removeTModel(str candidate, ModuleStatus ms, bool updateBOMneeded = false){
261-
// if(candidate == "analysis::grammar::Ambiguity"){
262-
// println("removeTModel: <candidate>, <ms.status[candidate]>");
263-
// }
264-
messages = [];
265259
if(ms.status[candidate]? && tpl_saved() notin ms.status[candidate] && rsc_not_found() notin ms.status[candidate]){
266260
pcfg = ms.pathConfig;
267261
if(updateBOMneeded){
@@ -272,27 +266,17 @@ ModuleStatus removeTModel(str candidate, ModuleStatus ms, bool updateBOMneeded =
272266
<found, tplLoc> = getTPLWriteLoc(candidate, pcfg);
273267
tm = ms.tmodels[candidate];
274268
tm = convertTModel2LogicalLocs(tm, ms.tmodels);
275-
messages = tm.messages;
276269
ms.status[candidate] += tpl_saved();
277270
if(ms.compilerConfig.verbose) println("Save <candidate> before removing from cache <ms.status[candidate]>");
278271
try {
279272
writeBinaryValueFile(tplLoc, tm);
280-
// if(candidate == "analysis::grammar::Ambiguity"){
281-
// println("removeTModel <candidate>: <getLastModified(candidate, ms.pathConfig)>, tpl: <lastModified(tplLoc)>");
282-
// }
283273
if(traceTPL) println("Written <tplLoc>");
284274
} catch value e: {
285-
throw "Cannot write TPL file <tplLoc>, reason: <e>";
275+
mloc = ms.moduleLocs[candidate] ? |unknown:///|;
276+
ms.messages[candidate] += { error("Cannot write TPL file <tplLoc>, reason: <e>", mloc) };
286277
}
287278
}
288-
// if(!isEmpty(messages)){
289-
// ms.messages[candidate] = messages;
290-
// println("<candidate>:"); iprintln(messages);
291-
// }
292279
ms.tmodels = delete(ms.tmodels, candidate);
293-
//if(candidate == "analysis::grammar::Ambiguity"){
294-
// println("removeTModel, end: <candidate>, <ms.status[candidate]>");
295-
//}
296280
return ms;
297281
}
298282
@@ -346,7 +330,7 @@ tuple[bool, TModel, ModuleStatus] getTModelForModule(str qualifiedModuleName, Mo
346330
tm.usesPhysicalLocs = false; // temporary
347331
tm = convertTModel2PhysicalLocs(tm);
348332
ms.tmodels[qualifiedModuleName] = tm;
349-
mloc = getModuleLocation(qualifiedModuleName, pcfg);
333+
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
350334
if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)){
351335
ms.status[qualifiedModuleName] ? {} += {rsc_not_found()};
352336
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void checkModuleName(loc mloc, QualifiedName qualifiedModuleName, Collector c){
7676
if([PathConfig pcfg] := pcfgVal){
7777
mname = prettyPrintName(qualifiedModuleName);
7878
try {
79-
mloc1 = getModuleLocation(mname, pcfg);
79+
mloc1 = getRascalModuleLocation(mname, pcfg);
8080
if(mloc.scheme != mloc1.scheme || mloc.authority != mloc1.authority || mloc.path != mloc1.path){
8181
c.report(error(qualifiedModuleName, "Module name `%v` is incompatible with its file location %v", mname, mloc));
8282
}

0 commit comments

Comments
 (0)