diff --git a/pom.xml b/pom.xml
index dc9a0fb7b76..44e1527d192 100644
--- a/pom.xml
+++ b/pom.xml
@@ -458,7 +458,7 @@
org.rascalmpl
typepal
- 0.15.3
+ 0.16.0-RC2
compile
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc
index 9d75d2d38cf..46578396ce4 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ADTandGrammar.rsc
@@ -165,19 +165,20 @@ list[&T <: node ] unsetRec(list[&T <: node] args) = [unsetRec(a) | a <- args];
bool isManualLayout(AProduction p) = (p has attributes && atag("manual"()) in p.attributes);
-tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports, set[str] extends, map[str,TModel] transient_tms, ModuleStatus ms){
+tuple[TModel, ModuleStatus] addGrammar(MODID moduleId, set[MODID] imports, set[MODID] extends, map[MODID,TModel] transient_tms, ModuleStatus ms){
try {
rel[AType,AProduction] definedProductions = {};
allStarts = {};
- for(m <- {qualifiedModuleName, *imports, *extends}){
+ qualifiedModuleName = moduleId2moduleName(moduleId);
+ for(m <- {moduleId, *imports, *extends}){
TModel tm1;
if(transient_tms[m]?){
tm1 = transient_tms[m];
} else {
= getTModelForModule(m, ms);
if(!found) {
- msg = error("Cannot add grammar, tmodel for not found", ms.moduleLocs[qualifiedModuleName] ? |unknown:///|);
- ms.messages[qualifiedModuleName] ? {} += { msg };
+ msg = error("Cannot add grammar, tmodel for not found", ms.moduleLocs[moduleId] ? |unknown:///|);
+ ms.messages[moduleId] ? {} += { msg };
tm1 = tmodel(modelName=qualifiedModuleName, messages=[msg]);
return ;
}
@@ -223,7 +224,7 @@ tuple[TModel, ModuleStatus] addGrammar(str qualifiedModuleName, set[str] imports
// Check keyword rules
- tm = checkKeywords(allProductions, transient_tms[qualifiedModuleName]);
+ tm = checkKeywords(allProductions, transient_tms[moduleId]);
// Check layout
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc
index 6616a2f29ab..4243ece11cc 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/ATypeUtils.rsc
@@ -24,17 +24,6 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
-@license{
- Copyright (c) 2009-2015 CWI
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-}
-@contributor{Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI}
-@contributor{Mark Hills - Mark.Hills@cwi.nl (CWI)}
-@contributor{Paul Klint - Paul.Klint@cwi.nl (CWI)}
-@contributor{Anastasia Izmaylova - Anastasia.Izmaylova@cwi.nl (CWI)}
@bootstrapParser
module lang::rascalcore::check::ATypeUtils
@@ -366,7 +355,7 @@ AType symbol2atype1(Symbol::\cons(Symbol \adt, str name, list[Symbol] parameters
AType symbol2atype1(Symbol::sort(str name)) = aadt(name, [], contextFreeSyntax());
AType symbol2atype1(Symbol::lex(str name)) = aadt(name, [], lexicalSyntax());
AType symbol2atype1(Symbol::keywords(str name)) = aadt(name, [], keywordSyntax());
-AType symbol2atype1(Symbol::layouts(str name)) = AType::layouts(name);
+AType symbol2atype1(Symbol::layouts(str name)) = aadt(name, [], layoutSyntax());
AType symbol2atype1(Symbol::\parameterized-sort(str name, list[Symbol] parameters)) =
aadt(name, symbol2atype(parameters), contextFreeSyntax());
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc
index c520de35695..0b63696da40 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Checker.rsc
@@ -113,7 +113,7 @@ bool errorsPresent(list[Message] msgs) = !isEmpty([ e | e:error(_,_) <- msgs ]);
// Dummy compile function (used when running only the checker)
-list[Message] dummy_compile1(str _qualifiedModuleName, lang::rascal::\syntax::Rascal::Module _M, map[str,TModel] _transient_tms, ModuleStatus _ms, RascalCompilerConfig _compilerConfig)
+list[Message] dummy_compile1(MODID _moduleId, lang::rascal::\syntax::Rascal::Module _M, map[MODID,TModel] _transient_tms, ModuleStatus _ms, RascalCompilerConfig _compilerConfig)
= [];
// rascalTModelForLocs is the basic work horse
@@ -123,7 +123,7 @@ list[Message] dummy_compile1(str _qualifiedModuleName, lang::rascal::\syntax::Ra
ModuleStatus rascalTModelForLocs(
list[loc] mlocs,
RascalCompilerConfig compilerConfig,
- list[Message](str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen
+ list[Message](MODID moduleId, lang::rascal::\syntax::Rascal::Module M, map[MODID,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen
){
pcfg = compilerConfig.typepalPathConfig;
@@ -135,11 +135,18 @@ ModuleStatus rascalTModelForLocs(
set[Message] msgs = validatePathConfigForChecker(pcfg, mlocs[0]);
- mnames =
+ list[str] mnames = [];
+ mids =
for(mloc <- mlocs){
+ if(isLogicalLoc(mloc)){
+ mnames += moduleId2moduleName(mloc);
+ append mloc;
+ } else
if(exists(mloc)){
try {
- append getRascalModuleName(mloc, pcfg);
+ mname = getRascalModuleName(mloc, pcfg);
+ mnames += mname;
+ append moduleName2moduleId(mname);
} catch e: {
msgs += error("No module name found for ", mloc);
}
@@ -149,8 +156,8 @@ ModuleStatus rascalTModelForLocs(
};
if(size(mlocs) != size(mnames)){ // not all mlocs could be mapped to a module
- for(mn <- mnames){
- ms.messages[mn] = msgs;
+ for(mid <- mids){
+ ms.messages[mid] = msgs;
}
if(errorsPresent(msgs)){
pcfg.messages += toList(msgs);
@@ -160,11 +167,11 @@ ModuleStatus rascalTModelForLocs(
return ms;
}
- = libraryDependenciesAreCompatible(mlocs, ms);
+ = libraryDependenciesAreCompatible(mids, ms);
if(compatibleLibs && uptodateTPls(mlocs, mnames, pcfg)){
- for (i <- index(mlocs)) {
- = getTModelForModule(mnames[i], ms, convert=true);
+ for (i <- index(mids)) {
+ = getTModelForModule(mids[i], ms);
if(!found){
throw "TModel for not found (no changes)";
}
@@ -173,49 +180,50 @@ ModuleStatus rascalTModelForLocs(
}
for (int i <- index(mlocs)) {
+ mid = mids[i];
mloc = mlocs[i];
mname = mnames[i];
- if(isModuleLocationInLibs(mname, mloc, pcfg)){
- ms.status[mname] ? {} += {rsc_not_found()};
+ if(isModuleLocationInLibs(mloc, pcfg)){
+ ms.status[mloc] ? {} += {rsc_not_found()};
}
- ms.moduleLocs[mname] = mloc;
- msgs += (ms.messages[mname] ? {});
+ ms.moduleLocs[mid] = mloc;
+ msgs += (ms.messages[mid] ? {});
}
str jobName = "";
- ms.changedModules = topModuleNames = toSet(mnames);
+ ms.changedModules = topModuleIds = toSet(mids);
+ topModuleNames = mnames;
try {
- ms = getImportAndExtendGraph(topModuleNames, ms);
+ ms = getImportAndExtendGraph(topModuleIds, ms);
// if(/error(_,_) := ms.messages){
-
// return clearTModelCache(ms);
// }
- imports_and_extends = ms.strPaths<0,2>;
+ imports_and_extends = ms.paths<0,2>;
= stronglyConnectedComponentsAndTopSort(imports_and_extends);
- map[str, set[str]] module2component = (m : c | c <- components, m <- c);
+ map[MODID, set[MODID]] module2component = (m : c | c <- components, m <- c);
- list[str] ordered = [];
+ list[MODID] ordered = [];
if(isEmpty(sorted)){
- ordered = toList(topModuleNames);
- for(str topModuleName <- topModuleNames){
- module2component[topModuleName] = {topModuleName};
+ ordered = toList(topModuleIds);
+ for(MODID topModuleId <- topModuleIds){
+ module2component[topModuleId] = {topModuleId};
}
} else {
ordered = reverse(sorted);
- singletons = toList(topModuleNames - toSet(ordered));
+ singletons = toList(topModuleIds - toSet(ordered));
ordered += singletons;
- for(str singleton <- singletons){
+ for(MODID singleton <- singletons){
module2component[singleton] = {singleton};
}
}
- map[str, loc] moduleScopes = ();
- map[str,str] path2module = (ms.moduleLocs[mname].path : mname | mname <- ms.moduleLocs);
+ // map[loc, loc] moduleScopes = ();
+ //map[str,loc] path2module = (ms.moduleLocs[mname].path : mname | mname <- ms.moduleLocs);
mi = 0;
nmodules = size(ordered);
@@ -226,7 +234,8 @@ ModuleStatus rascalTModelForLocs(
component = module2component[ordered[mi]];
sizeComponent = size(component);
- jobStep(jobName, intercalate(" + ", [*component]), work=size(component));
+ componentNames = [moduleId2moduleName(c) | c <- component];
+ jobStep(jobName, intercalate(" + ", [*componentNames]), work=size(componentNames));
recheck = !all(m <- component, m in ms.status, (tpl_uptodate() in ms.status[m] || checked() in ms.status[m]));
for(m <- component){
@@ -237,7 +246,7 @@ ModuleStatus rascalTModelForLocs(
mi += 1;
if(!recheck){
if(tpl_uptodate() notin ms.status[m]){
- = getTModelForModule(m, ms, convert=sizeComponent>1);
+ = getTModelForModule(m, ms);
if(found){
ms.status[m] += {tpl_uptodate(), checked()};
}
@@ -255,7 +264,7 @@ ModuleStatus rascalTModelForLocs(
} else {
for(m <- component){
m_compatible = false;
- = getTModelForModule(m, ms, convert=sizeComponent>1);
+ = getTModelForModule(m, ms);
if(found && !tplOutdated(m, pcfg)){
imports_extends_m = imports_and_extends[m];
@@ -283,43 +292,45 @@ ModuleStatus rascalTModelForLocs(
// }
= rascalTModelComponent(component, ms);
- moduleScopes += getModuleScopes(tm);
+ // moduleScopes += getModuleScopes(tm);
map[str,TModel] tmodels_for_component = ();
- map[str,set[str]] m_imports = ();
- map[str,set[str]] m_extends = ();
+ map[MODID,set[MODID]] m_imports = ();
+ map[MODID,set[MODID]] m_extends = ();
for(m <- component, rsc_not_found() notin ms.status[m], MStatus::ignored() notin ms.status[m]){
- imports = { imp | <- ms.strPaths, m1 == m, MStatus::ignored() notin ms.status[imp]};
+ imports = { imp | <- ms.paths, m1 == m, MStatus::ignored() notin ms.status[imp]};
m_imports[m] = imports;
- extends = { ext | <- ms.strPaths, m1 == m, MStatus::ignored() notin ms.status[ext] };
+ extends = { ext | <- ms.paths, m1 == m, MStatus::ignored() notin ms.status[ext] };
m_extends[m] = extends;
- invertedExtends = ms.strPaths<2,0>;
+ invertedExtends = ms.paths<2,0>;
if(compilerConfig.warnUnused){
// Look for unused imports or extends
- usedModules = {path2module[l.path] | loc l <- range(tm.useDef), tm.definitions[l].idRole == moduleId(), path2module[l.path]?};
+ //usedModules = {path2module[l.path] | loc l <- range(tm.useDef), tm.definitions[l].idRole == moduleId(), path2module[l.path]?};
+ usedModules = {l | loc l <- range(tm.useDef), tm.definitions[l].idRole == moduleId()};
usedModules += {*invertedExtends[um] | um <- usedModules}; // use of an extended module via import
list[Message] imsgs = [];
= getModuleParseTree(m, ms);
if(success){
if(compilerConfig.infoModuleChecked){
- imsgs += [info("Checked ", pt.header.name@\loc)];
+ imsgs += [info("Checked ", pt.header.name@\loc)];
}
check_imports:
for(imod <- pt.header.imports, imod has \module){
iname = unescape("");
- if(!ms.status[iname]?){
- ms.status[iname] = {};
+ inameId = moduleName2moduleId(iname);
+ if(!ms.status[inameId]?){
+ ms.status[inameId] = {};
}
- if(iname notin usedModules){
+ if(inameId notin usedModules){
if(iname == "ParseTree" && implicitlyUsesParseTree(ms.moduleLocs[m].path, tm)){
continue check_imports;
}
- if(ms.moduleLocs[iname]? && ms.moduleLocs[m]? && implicitlyUsesLayoutOrLexical(ms.moduleLocs[m].path, ms.moduleLocs[iname].path, tm)){
+ if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && implicitlyUsesLayoutOrLexical(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){
continue check_imports;
}
- if(ms.moduleLocs[iname]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[iname].path, tm)){
+ if(ms.moduleLocs[inameId]? && ms.moduleLocs[m]? && usesOrExtendsADT(ms.moduleLocs[m].path, ms.moduleLocs[inameId].path, tm)){
continue check_imports;
}
- if((iname in component || checked() in ms.status[iname]) && rsc_not_found() notin ms.status[iname]){
+ if((inameId in component || checked() in ms.status[inameId]) && rsc_not_found() notin ms.status[inameId]){
if(imod is \default){
imsgs += warning("Unused import of ``", imod@\loc);
} //else { //TODO: maybe add option to turn off info messages?
@@ -343,11 +354,11 @@ ModuleStatus rascalTModelForLocs(
}
// prepare the TModels of the modules in this component for compilation
- = prepareForCompilation(component, m_imports, m_extends, ms, moduleScopes, tm);
+ = prepareForCompilation(component, m_imports, m_extends, ms, tm);
// generate code for the modules in this component
- for(str m <- component, MStatus::ignored() notin ms.status[m]){
+ for(MODID m <- component, MStatus::ignored() notin ms.status[m]){
= getModuleParseTree(m, ms);
if(success){
lmsgs = codgen(m, pt, transient_tms, ms, compilerConfig);
@@ -355,28 +366,28 @@ ModuleStatus rascalTModelForLocs(
ms.status[m] += errorsPresent(lmsgs) ? {code_generation_error()} : {code_generated()};
}
}
- ms = doSaveModule(component, m_imports, m_extends, ms, moduleScopes, transient_tms, compilerConfig);
+ ms = doSaveModule(component, m_imports, m_extends, ms, transient_tms, compilerConfig);
for(m <- component){
ms.status[m] -= {rsc_changed()};
ms.status[m] += {tpl_uptodate()};
}
} else {
- for(m <- component){
- ms.status[m] += bom_update_needed();
- }
+ ;// for(m <- component){
+ // ms.status[m] += bom_update_needed();
+ // }
}
}
} catch ParseError(loc src): {
- for(str mname <- topModuleNames){
- ms.messages[mname] = { error("Parse error", src) };
+ for(MODID mid <- topModuleIds){
+ ms.messages[mid] = { error("Parse error", src) };
}
} catch rascalTplVersionError(str txt):{
- for(str mname <- topModuleNames){
- ms.messages[mname] = { error("", ms.moduleLocs[mname] ? |unknown:///|) };
+ for(MODID mid <- topModuleIds){
+ ms.messages[mid] = { error("", ms.moduleLocs[mid] ? |unknown:///|) };
}
} catch Message msg: {
- for(str mname <- topModuleNames){
- ms.messages[mname] = { error("During type checking: ", msg.at) };
+ for(MODID mid <- topModuleIds){
+ ms.messages[mid] = { error("During type checking: ", msg.at) };
}
}
@@ -401,13 +412,13 @@ bool usesOrExtendsADT(str modulePath, str importPath, TModel tm){
return res;
}
-tuple[set[str], ModuleStatus] loadImportsAndExtends(set[str] moduleNames, ModuleStatus ms, Collector c, set[str] added){
+tuple[set[MODID], ModuleStatus] loadImportsAndExtends(set[MODID] moduleIds, ModuleStatus ms, Collector c, set[MODID] added){
pcfg = ms.pathConfig;
- for( <- ms.strPaths, from in moduleNames){
- if(imp notin added, imp notin moduleNames){
+ for( <- ms.paths, from in moduleIds){
+ if(imp notin added, imp notin moduleIds){
if(tpl_uptodate() in ms.status[imp]){
added += imp;
- = getTModelForModule(imp, ms, convert=true);
+ = getTModelForModule(imp, ms);
try {
if(pathRole == importPath()){
tm.defines = {d | d <- tm.defines, d.idRole == moduleVariableId() ==> d.defInfo.vis == publicVis() };
@@ -422,54 +433,55 @@ tuple[set[str], ModuleStatus] loadImportsAndExtends(set[str] moduleNames, Module
return ;
}
-tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleStatus ms){
-
+tuple[TModel, ModuleStatus] rascalTModelComponent(set[MODID] moduleIds, ModuleStatus ms){
pcfg = ms.pathConfig;
compilerConfig = ms.compilerConfig;
- modelName = intercalate(" + ", toList(moduleNames));
- map[str, Module] namedTrees = ();
- for(str nm <- moduleNames){
- ms.status[nm] = {};
- //ms.messages[nm] = {};
- ms = removeTModel(nm, ms);
+ modelNames = [moduleId2moduleName(moduleId) | moduleId <- moduleIds];
+ modelName = intercalate(" + ", modelNames);
+ map[MODID, Module] idTrees = ();
+ for(MODID mid <- moduleIds){
+ mname = moduleId2moduleName(mid);
+ //ms.status[mid] = {};
+ //ms.messages[mid] = {};
+ ms = removeTModel(mid, ms);
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
try {
- mloc = getRascalModuleLocation(nm, ms);
+ mloc = getRascalModuleLocation(mid, ms);
} catch Message err: {
- ms.messages[nm] = { err };
- ms.status[nm] += { rsc_not_found() };
- tm = tmodel(modelName=nm, messages=[ err ]);
- ms = addTModel(nm, tm, ms);
+ ms.messages[mid] = { err };
+ ms.status[mid] += { rsc_not_found() };
+ tm = tmodel(modelName=mname, messages=[ err ]);
+ ms = addTModel(mid, tm, ms);
return ;
}
- if(mloc.extension != "rsc" || isModuleLocationInLibs(nm, mloc, pcfg)){
+ if(!isLogicalLoc(mloc) && (mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg))){
continue;
}
- = getModuleParseTree(nm, ms);
+ = getModuleParseTree(mid, ms);
if(success){
tagsMap = getTags(pt.header.tags);
if(ignoreCompiler(tagsMap)) {
- ms.messages[nm] ? {} += { Message::info("Ignoring module ", pt@\loc) };
- ms.status[nm] += MStatus::ignored();
+ ms.messages[mid] ? {} += { Message::info("Ignoring module ", pt@\loc) };
+ ms.status[mid] += MStatus::ignored();
}
- namedTrees[nm] = pt;
+ idTrees[mid] = pt;
}
//else {
- // ms.messages[nm] += error("Cannot get parse tree for module ``", ms.moduleLocs[nm]);
+ // ms.messages[mid] += error("Cannot get parse tree for module ``", ms.moduleLocs[mid]);
//}
}
- if(!isEmpty(namedTrees)){
+ if(!isEmpty(idTrees)){
if(compilerConfig.verbose) { println("Checking ... "); }
start_check = cpuTime();
resetClosureCounter();
+ namedTrees = (moduleId2moduleName(mid) : idTrees[mid] | mid <- idTrees);
c = newCollector(modelName, namedTrees, compilerConfig);
c.push(key_pathconfig, pcfg);
rascalPreCollectInitialization(namedTrees, c);
-
- = loadImportsAndExtends(moduleNames, ms, c, {});
+ = loadImportsAndExtends(domain(idTrees), ms, c, {});
for(str nm <- namedTrees){
collect(namedTrees[nm], c);
}
@@ -481,9 +493,9 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
s = newSolver(namedTrees, tm);
tm = s.run();
}
- tm.usesPhysicalLocs = true;
- for(mname <- moduleNames){
- ms.messages[mname] ? {} += toSet(tm.messages);
+
+ for(mid <- moduleIds){
+ ms.messages[mid] ? {} += toSet(tm.messages);
}
//iprintln(tm.messages);
@@ -492,19 +504,18 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
if(compilerConfig.verbose) { println("Checked .... in ms"); }
return ;
} else {
- ms.status[modelName]? {} += { tpl_saved() };
- = getTModelForModule(modelName, ms, convert=false);
+ oneOfComponent = getOneFrom(moduleIds);
+ ms.status[oneOfComponent]? {} += { tpl_saved() }; // TODO check this, when is this executed?
+ = getTModelForModule(oneOfComponent, ms);
return ;
}
}
-
-
// ---- rascalTModelForName a checker version that works on module names
ModuleStatus rascalTModelForNames(list[str] moduleNames,
RascalCompilerConfig compilerConfig,
- list[Message] (str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, map[str,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen){
+ list[Message] (MODID moduleId, lang::rascal::\syntax::Rascal::Module M, map[MODID,TModel] transient_tms, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen){
pcfg = compilerConfig.typepalPathConfig;
mlocs = [];
@@ -513,7 +524,7 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
mlocs += [ getRascalModuleLocation(moduleName, pcfg) ];
} catch Message err: {
ms = newModuleStatus(compilerConfig);
- ms.messages[moduleName] = { err };
+ ms.messages[moduleName2moduleId(moduleName)] = { err };
return ms;
}
}
@@ -531,18 +542,17 @@ bool uptodateTPls(list[loc] candidates, list[str] mnames, PathConfig pcfg){
return true;
}
-tuple[bool, ModuleStatus] libraryDependenciesAreCompatible(list[loc] candidates, ModuleStatus ms){
+tuple[bool, ModuleStatus] libraryDependenciesAreCompatible(list[MODID] candidates, ModuleStatus ms){
pcfg = ms.pathConfig;
for(candidate <- candidates){
- mname = getRascalModuleName(candidate, pcfg);
- = getTModelForModule(mname, ms, convert=false);
- //if(found){
- imports_and_extends = ms.strPaths<0,2>[mname];
+ = getTModelForModule(candidate, ms);
+ if(found){ // TODO: needed?
+ imports_and_extends = ms.paths<0,2>[candidate];
= importsAndExtendsAreBinaryCompatible(tm, imports_and_extends, ms);
if(!compatible){
return ;
}
- //}
+ }
}
return ;
}
@@ -564,9 +574,9 @@ list[ModuleMessages] check(list[loc] moduleLocs, RascalCompilerConfig compilerCo
}
list[ModuleMessages] reportModuleMessages(ModuleStatus ms){
- moduleNames = domain(ms.moduleLocs);
- messagesNoModule = {*ms.messages[mname] | mname <- ms.messages, (mname notin moduleNames || mname notin ms.moduleLocs)} + toSet(ms.pathConfig.messages);
- msgs = [ program(ms.moduleLocs[mname], (ms.messages[mname] ? {}) + messagesNoModule) | mname <- moduleNames ];
+ moduleIds = domain(ms.moduleLocs);
+ messagesNoModule = {*ms.messages[mid] | MODID mid <- ms.messages, (mid notin moduleIds || mid notin ms.moduleLocs)} + toSet(ms.pathConfig.messages);
+ msgs = [ program(ms.moduleLocs[mid], (ms.messages[mid] ? {}) + messagesNoModule) | MODID mid <- moduleIds ];
if(isEmpty(msgs) && !isEmpty(messagesNoModule)){
msgs = [ program(|unknown:///|, messagesNoModule) ];
}
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc
index 0dc88807197..9b8fc280183 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CheckerCommon.rsc
@@ -40,6 +40,7 @@ extend analysis::typepal::FailMessage;
extend lang::rascalcore::check::BasicRascalConfig;
extend lang::rascalcore::check::ModuleLocations;
extend lang::rascalcore::CompilerPathConfig;
+extend lang::rascalcore::check::LogicalLocations;
extend analysis::typepal::Collector;
@@ -67,6 +68,8 @@ void checkSupportedByParserGenerator(Tree t, Collector c){
});
}
+
+
data MStatus =
rsc_not_found()
| tpl_not_found()
@@ -86,26 +89,38 @@ data MStatus =
data ModuleStatus =
moduleStatus(
- rel[str, PathRole, str] strPaths,
- rel[loc, PathRole, loc] paths,
- map[str, Module] parseTrees,
- list[str] parseTreeLIFO,
- map[str, TModel] tmodels,
- list[str] tmodelLIFO,
- set[str] changedModules,
- map[str,loc] moduleLocs,
- map[str,datetime] moduleLastModified,
- map[str, set[Message]] messages,
- map[str, set[MStatus]] status,
+ rel[MODID, PathRole, MODID] paths,
+ map[MODID, Module] parseTrees,
+ list[MODID] parseTreeLIFO,
+ map[MODID, TModel] tmodels,
+ list[MODID] tmodelLIFO,
+ set[MODID] changedModules,
+ map[MODID,loc] moduleLocs,
+ map[MODID,datetime] moduleLastModified,
+ map[MODID, set[Message]] messages,
+ map[MODID, set[MStatus]] status,
PathConfig pathConfig,
RascalCompilerConfig compilerConfig
);
-ModuleStatus newModuleStatus(RascalCompilerConfig ccfg) = moduleStatus({}, {}, (), [], (), [], {}, (), (), (), (), ccfg.typepalPathConfig, ccfg);
-
-bool isModuleLocationInLibs(str mname, loc l, PathConfig pcfg){
+// void checkMS(ModuleStatus ms){
+// for( <- ms.paths) assert isModuleId(f) && isModuleId(t);
+// for(mid <- domain(ms.parseTrees)) assert isModuleId(mid);
+// for(mid <- ms.parseTreeLIFO) assert isModuleId(mid);
+// for(mid <- domain(ms.tmodels)) assert isModuleId(mid);
+// for(mid <- ms.tmodelLIFO) assert isModuleId(mid);
+// for(mid <- ms.changedModules) assert isModuleId(mid);
+// for(mid <- domain(ms.moduleLocs)) assert isModuleId(mid);
+// for(mid <- domain(ms.moduleLastModified)) assert isModuleId(mid);
+// for(mid <- domain(ms.messages)) assert isModuleId(mid);
+// for(mid <- domain(ms.status)) assert isModuleId(mid);
+// }
+
+ModuleStatus newModuleStatus(RascalCompilerConfig ccfg) = moduleStatus({}, (), [], (), [], {}, (), (), (), (), ccfg.typepalPathConfig, ccfg);
+
+bool isModuleLocationInLibs(loc l, PathConfig pcfg){
+ assert !isModuleId(l);
res = l.extension == "tpl" || !isEmpty(pcfg.libs) && any(lib <- pcfg.libs, l.scheme == lib.scheme && l.path == lib.path);
- //println("isModuleLocationInLibs: , ==\> ");
return res;
}
@@ -113,17 +128,20 @@ bool traceTPL = false;
bool traceParseTreeCache = false;
bool traceTModelCache = false;
-tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg){
- parts = split("::", qualifiedModuleName);
+tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg)
+ = getTPLReadLoc(moduleName2moduleId(qualifiedModuleName), pcfg);
+
+tuple[bool,loc] getTPLReadLoc(MODID moduleId, PathConfig pcfg){
+ assert isModuleId(moduleId) : "getTPLReadLoc: ";
+ parts = split("/", moduleId.path);
parts = parts[0 .. size(parts)-1] + "$";
- res = intercalate("/", parts);
fileName = intercalate("/", parts) + ".tpl";
- dirName = makeDirName(qualifiedModuleName);
+ dirName = makeDirName(parts);
for(loc dir <- [pcfg.generatedResources, pcfg.bin] + pcfg.libs){ // In a bin or lib directory?
- fileLoc = dir + "" + fileName;
+ fileLoc = dir + "" + fileName;
if(exists(fileLoc)){
- if(traceTPL) println("getTPLReadLoc: =\> ");
+ if(traceTPL) println("getTPLReadLoc: =\> ");
return ;
} else {
;// if(traceTPL)
@@ -133,7 +151,9 @@ tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg){
return ;
}
-tuple[bool,loc] getTPLWriteLoc(str qualifiedModuleName, PathConfig pcfg){
+tuple[bool,loc] getTPLWriteLoc(MODID moduleId, PathConfig pcfg){
+ assert isModuleId(moduleId) : "getTPLWriteLoc: ";
+ qualifiedModuleName = moduleId2moduleName(moduleId);
fileName = ".tpl";
tplLoc = getGeneratedResourcesDir(qualifiedModuleName, pcfg) + fileName;
return ;
@@ -141,13 +161,14 @@ tuple[bool,loc] getTPLWriteLoc(str qualifiedModuleName, PathConfig pcfg){
datetime startOfEpoch = $2000-01-01T00:00:00.000+00:00$;
-datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastModified, PathConfig pcfg){
- qualifiedModuleName = unescape(qualifiedModuleName);
- try {
- return moduleLastModified[qualifiedModuleName];
- } catch NoSuchKey(_): {
+datetime getLastModified(MODID moduleId, ModuleStatus ms){
+ assert isModuleId(moduleId) : "getLastModified: ";
+ qualifiedModuleName = moduleId2moduleName(moduleId);
+ if(moduleId in ms.moduleLastModified){
+ return ms.moduleLastModified[moduleId];
+ } else {
try {
- mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
+ mloc = getRascalModuleLocation(moduleId, ms);
return lastModified(mloc);
} catch value _: {
return startOfEpoch;
@@ -156,11 +177,10 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM
}
// Check if a module is modified compared to a given timestamp in BOM
-tuple[bool,ModuleStatus] isModuleModified(str qualifiedModuleName, datetime timestamp, PathRole pathRole, ModuleStatus ms){
- qualifiedModuleName = unescape(qualifiedModuleName);
+tuple[bool,ModuleStatus] isModuleModified(MODID moduleId, datetime timestamp, PathRole pathRole, ModuleStatus ms){
pcfg = ms.pathConfig;
try {
- mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
+ mloc = getRascalModuleLocation(moduleId, ms);
bool modifiedChanged = lastModified(mloc) != timestamp;
if(pathRole == importPath()){
return ;
@@ -169,10 +189,10 @@ tuple[bool,ModuleStatus] isModuleModified(str qualifiedModuleName, datetime time
// TODO: in the case of deep extend chains this might become inefficient since we are
// yoyo-ing up and down through the extend chains.
// Potential solution: maintain set of changed modules in ModuleStatus
- = getTModelForModule(qualifiedModuleName, ms, convert=false);
+ = getTModelForModule(moduleId, ms);
if(found && tm.store[key_bom]? && rel[str,datetime,PathRole] bom := tm.store[key_bom]){
for( <- bom){
- = isModuleModified(m, timestampInBom, pathRole, ms);
+ = isModuleModified(moduleName2moduleId(m), timestampInBom, pathRole, ms);
if(mchanged){
return ;
}
@@ -186,8 +206,9 @@ tuple[bool,ModuleStatus] isModuleModified(str qualifiedModuleName, datetime time
}
}
-bool tplOutdated(str qualifiedModuleName, PathConfig pcfg){
+bool tplOutdated(MODID moduleId, PathConfig pcfg){
try {
+ qualifiedModuleName = moduleId2moduleName(moduleId);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
= getTPLReadLoc(qualifiedModuleName, pcfg);
lmMloc = lastModified(mloc);
@@ -195,83 +216,82 @@ bool tplOutdated(str qualifiedModuleName, PathConfig pcfg){
res = !found || lmMloc > lmTpl;
//println("tplOutdated : ; mloc: \> tpl: : lmTpl>, (, )");
return res;
- } catch e: {
+ } catch _: {
return false;
}
}
int parseTreeCacheSize = 20;
-tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, ModuleStatus ms){
+tuple[bool, Module, ModuleStatus] getModuleParseTree(MODID moduleId, ModuleStatus ms){
+ assert isModuleId(moduleId) : "getModuleParseTree: ";
pcfg = ms.pathConfig;
- if(ms.parseTrees[qualifiedModuleName]?){
- if(traceParseTreeCache) println("*** using cached parse tree for ");
- return ;
+ qualifiedModuleName = moduleId2moduleName(moduleId);
+ if(ms.parseTrees[moduleId]?){
+ if(traceParseTreeCache) println("*** using cached parse tree for ");
+ return ;
} else {
- if(!ms.status[qualifiedModuleName]?){
- ms.status[qualifiedModuleName] = {};
+ if(!ms.status[moduleId]?){
+ ms.status[moduleId] = {};
}
- if(parse_error() notin ms.status[qualifiedModuleName]){
+ if(parse_error() notin ms.status[moduleId]){
if(size(ms.parseTreeLIFO) >= parseTreeCacheSize){
ms.parseTrees = delete(ms.parseTrees, ms.parseTreeLIFO[-1]);
if(traceParseTreeCache) println("*** deleting parse tree ");
ms.parseTreeLIFO = ms.parseTreeLIFO[..-1];
}
- ms.parseTreeLIFO = [qualifiedModuleName, *ms.parseTreeLIFO];
- mloc = |unknown:///|;
+ ms.parseTreeLIFO = [moduleId, *ms.parseTreeLIFO];
+ mloc = moduleId;
try {
- mloc = getRascalModuleLocation(qualifiedModuleName, ms);
+ mloc = getRascalModuleLocation(moduleId, ms);
// Make sure we found a real source module (as opposed to a tpl module in a library
- if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) {
- ms.status[qualifiedModuleName] += {rsc_not_found()};
+ if(isModuleLocationInLibs(mloc, pcfg)) {
+ ms.status[moduleId] += {rsc_not_found()};
throw "No src or library module";
}
- } catch _: {
- ms.messages[qualifiedModuleName] ? {} += {error("Module not found", mloc)};
+ } catch e: {
+ println(e);
+ ms.messages[moduleId] ? {} += {error("Module not found", mloc)};
mpt = [Module] "module ";
- //ms.parseTrees[qualifiedModuleName] = mpt;
- ms.moduleLocs[qualifiedModuleName] = mloc;
+ ms.moduleLocs[moduleId] = mloc;
return ;
}
- if(traceParseTreeCache) println("*** parsing from ");
+ if(traceParseTreeCache) println("*** parsing from ");
try {
pt = parseModuleWithSpaces(mloc.top).top;
- ms.parseTrees[qualifiedModuleName] = pt;
+ ms.parseTrees[moduleId] = pt;
newLoc = getLoc(pt);
- if(qualifiedModuleName in ms.moduleLocs){
- ms = updatePaths(ms.moduleLocs[qualifiedModuleName], newLoc, ms);
- }
- ms.moduleLocs[qualifiedModuleName] = newLoc;
- ms.status[qualifiedModuleName] ? {} += {parsed()};
+ ms.moduleLocs[moduleId] = newLoc;
+ ms.status[moduleId] ? {} += {parsed()};
return ;
- } catch _: {//ParseError(loc src): {
- ms.messages[qualifiedModuleName] ? {} = {error("Parse error in ", mloc)};
- ms.moduleLocs[qualifiedModuleName] = mloc;
- ms.status[qualifiedModuleName] += parse_error();
+ } catch ParseError(loc src): {
+ ms.messages[moduleId] ? {} = {error("Parse error in ", src)};
+ ms.moduleLocs[moduleId] = mloc;
+ ms.status[moduleId] += parse_error();
return ", ms>;
}
}
mpt = [Module] "module ";
- ms.parseTrees[qualifiedModuleName] = mpt;
+ ms.parseTrees[moduleId] = mpt;
return ;
}
}
-loc getRascalModuleLocation(str qualifiedModuleName, ModuleStatus ms){
- return qualifiedModuleName in ms.moduleLocs
- ? ms.moduleLocs[qualifiedModuleName]
- : getRascalModuleLocation(qualifiedModuleName, ms.pathConfig);
+loc getRascalModuleLocation(MODID moduleId, ModuleStatus ms){
+ if(moduleId in ms.moduleLocs){
+ loc l = ms.moduleLocs[moduleId];
+ if(!isLogicalLoc(l)) return l;
+ }
+ return getRascalModuleLocation(moduleId2moduleName(moduleId), ms.pathConfig);
}
/*
* We implement a caching mechanism for TModels with the following properties:
* - tmodelCacheSize tmodels are cached.
- * - TModels on file (.tpl) physical locations have been replaced by logical locations where possible.
- * - When a TModel is read in, physical locations are NOT YET converted by logical logical locations
- * and only do that when absolutely needed
- * - The policy is to keep TModels in the cache in this unconverted logical form as long as possible.
+ * - In TModels on file (.tpl) physical locations have been replaced by logical locations where possible.
+ * - The policy is to always keep TModels in the cache in this logical form.
* - During its presence in the cache, the BOM of a TModel may get updated.
- * - When a TModel has to be removed from the cache, it is converted back to the logical form (if needed) and written back to file.
+ * - When a TModel has to be removed from the cache, it is written back to file (if needed).
*/
int tmodelCacheSize = 30; // should be > 0
@@ -279,62 +299,65 @@ int tmodelCacheSize = 30; // should be > 0
ModuleStatus clearTModelCache(ModuleStatus ms){
todo = { mname | mname <- ms.status, bom_update_needed() in ms.status[mname]};
for(candidate <- ms.tmodelLIFO){
- ms = removeOldestTModelFromCache(ms, updateBOMneeded=true);
+ ms = removeOldestTModelFromCache(ms/*, updateBOMneeded=true*/);
todo -= candidate;
}
for(candidate <- todo){
- ms = removeTModel(candidate, ms, updateBOMneeded=true);
+ ms = removeTModel(candidate, ms/*, updateBOMneeded=true*/);
ms.status[candidate] -= bom_update_needed();
}
return ms;
}
-rel[str,datetime,PathRole] makeBom(str qualifiedModuleName, ModuleStatus ms){
- map[str,datetime] moduleLastModified = ms.moduleLastModified;
+rel[str,datetime,PathRole] makeBom(MODID moduleId, ModuleStatus ms){
pcfg = ms.pathConfig;
- imports = ms.strPaths[qualifiedModuleName,importPath()];
- extends = ms.strPaths[qualifiedModuleName, extendPath()];
- return { < m, getLastModified(m, moduleLastModified, pcfg), importPath() > | m <- imports }
- + { < m, getLastModified(m, moduleLastModified, pcfg), extendPath() > | m <- extends }
- + { };
+ qualifiedModuleName = moduleId2moduleName(moduleId);
+ imports = ms.paths[moduleId,importPath()];
+ extends = ms.paths[moduleId, extendPath()];
+ return { < mname, getLastModified(m, ms), importPath() > | m <- imports, mname := moduleId2moduleName(m) }
+ + { < mname, getLastModified(m, ms), extendPath() > | m <- extends, mname := moduleId2moduleName(m) }
+ + { };
}
-ModuleStatus updateBOM(str qualifiedModuleName, ModuleStatus ms){
- if(rsc_not_found() in ms.status[qualifiedModuleName]){
+ModuleStatus updateBOM(MODID moduleId, ModuleStatus ms){
+ if(rsc_not_found() in ms.status[moduleId]){
return ms;
}
- = getTModelForModule(qualifiedModuleName, ms, convert=false);
+ = getTModelForModule(moduleId, ms);
if(found){
- newBom = makeBom(qualifiedModuleName,
- ms);
+ newBom = makeBom(moduleId, ms);
if(newBom != tm.store[key_bom]){
tm.store[key_bom] = newBom;
- ms.status[qualifiedModuleName] -= tpl_saved();
- ms = addTModel(qualifiedModuleName, tm, ms);
+ ms.status[moduleId] -= {tpl_saved(), bom_update_needed()};
+ ms = addTModel(moduleId, tm, ms);
- if(ms.compilerConfig.logWrittenFiles) println("Updated BOM: ");
+ if(ms.compilerConfig.logWrittenFiles) println("Updated BOM: ");
}
} else{
- println("Could not update BOM of ");
+ println("Could not update BOM of ");
}
return ms;
}
-ModuleStatus removeTModel(str candidate, ModuleStatus ms, bool updateBOMneeded = false){
- if(candidate in ms.tmodels && ms.status[candidate]? && tpl_saved() notin ms.status[candidate] && rsc_not_found() notin ms.status[candidate]){
+ModuleStatus removeTModel(MODID candidate, ModuleStatus ms, bool updateBOMneeded = false){
+ assert isModuleId(candidate) : "removeTModel: ";
+ if( updateBOMneeded
+ || ( candidate in ms.tmodels
+ && candidate in ms.status
+ && tpl_saved() notin ms.status[candidate]
+ && rsc_not_found() notin ms.status[candidate])
+ ){
pcfg = ms.pathConfig;
if(updateBOMneeded){
ms = updateBOM(candidate, ms);
- } else {
- ms.status[candidate] += bom_update_needed();
- }
+ }
+ ms.status[candidate] -= bom_update_needed();
= getTPLWriteLoc(candidate, pcfg);
tm = ms.tmodels[candidate];
- tm.messages = toList(toSet(tm.messages) + ms.messages[candidate]);
- tm = convertTModel2LogicalLocs(tm, ms.tmodels);
+ tm.messages = toList(toSet(tm.messages) + ms.messages[candidate]); // TODO needed ?
ms.status[candidate] += tpl_saved();
- if(ms.compilerConfig.verbose) println("Saving tmodel for before removing from cache");
+ if(ms.compilerConfig.verbose) println("Saving tmodel for before removing from cache");
try {
writeBinaryValueFile(tplLoc, tm);
if(traceTPL) println("Written ");
@@ -357,13 +380,13 @@ ModuleStatus removeOldestTModelFromCache(ModuleStatus ms, bool updateBOMneeded =
return ms;
}
-ModuleStatus addTModel (str qualifiedModuleName, TModel tm, ModuleStatus ms){
- if(traceTModelCache) println("addTModel: ");
+ModuleStatus addTModel (MODID moduleId, TModel tm, ModuleStatus ms){
+ if(traceTModelCache) println("addTModel: ");
if(tmodelCacheSize > 0){
- ms.tmodels[qualifiedModuleName] = tm;
- if(qualifiedModuleName notin ms.tmodelLIFO){
- ms.tmodelLIFO = [qualifiedModuleName, *ms.tmodelLIFO];
- while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != qualifiedModuleName){
+ ms.tmodels[moduleId] = tm;
+ if(moduleId notin ms.tmodelLIFO){
+ ms.tmodelLIFO = [moduleId, *ms.tmodelLIFO];
+ while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != moduleId){
ms = removeOldestTModelFromCache(ms);
}
}
@@ -373,112 +396,61 @@ ModuleStatus addTModel (str qualifiedModuleName, TModel tm, ModuleStatus ms){
private type[TModel] ReifiedTModel = #TModel; // precomputed for efficiency
-tuple[bool, TModel, ModuleStatus] getTModelForModule(str qualifiedModuleName, ModuleStatus ms, bool convert = true){
- if(traceTModelCache) println("getTModelForModule: ");
+tuple[bool, TModel, ModuleStatus] getTModelForModule(str moduleName, ModuleStatus ms)
+ = getTModelForModule(moduleName2moduleId(moduleName), ms);
+
+tuple[bool, TModel, ModuleStatus] getTModelForModule(MODID moduleId, ModuleStatus ms){
+ assert isModuleId(moduleId) : "getTModelForModule: ";
+ if(traceTModelCache) println("getTModelForModule: ");
pcfg = ms.pathConfig;
- if(qualifiedModuleName in ms.tmodels){
- tm = ms.tmodels[qualifiedModuleName];
- if(convert && !tm.usesPhysicalLocs){
- tm = convertTModel2PhysicalLocs(tm);
- ms.moduleLocs += tm.moduleLocs;
- ms.tmodels[qualifiedModuleName] = tm;
- }
+ if(moduleId in ms.tmodels){
+ tm = ms.tmodels[moduleId];
return ;
}
- while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != qualifiedModuleName){
+ while(size(ms.tmodels) >= tmodelCacheSize && size(ms.tmodelLIFO) > 0 && ms.tmodelLIFO[-1] != moduleId){
ms = removeOldestTModelFromCache(ms);
}
- = getTPLReadLoc(qualifiedModuleName, pcfg);
+ = getTPLReadLoc(moduleId, pcfg);
if(found){
if(traceTPL) println("*** reading tmodel ");
try {
tm = readBinaryValueFile(ReifiedTModel, tplLoc);
if(tm.rascalTplVersion? && isValidRascalTplVersion(tm.rascalTplVersion)){
- tm.usesPhysicalLocs = false; // temporary
- if(convert){
- tm = convertTModel2PhysicalLocs(tm);
+ ms.tmodels[moduleId] = tm;
+ mloc = getRascalModuleLocation(moduleId, ms);
+ if(isModuleLocationInLibs(mloc, pcfg)){
+ ms.status[moduleId] ? {} += {rsc_not_found()};
}
- ms.tmodels[qualifiedModuleName] = tm;
- mloc = getRascalModuleLocation(qualifiedModuleName, ms);
- if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)){
- ms.status[qualifiedModuleName] ? {} += {rsc_not_found()};
- }
- ms.status[qualifiedModuleName] ? {} += {tpl_uptodate(), tpl_saved()};
- ms.messages[qualifiedModuleName] = toSet(tm.messages);
- ms.tmodelLIFO = [qualifiedModuleName, *ms.tmodelLIFO];
+ ms.status[moduleId] ? {} += {tpl_uptodate(), tpl_saved()};
+ ms.messages[moduleId] = toSet(tm.messages);
+ ms.tmodelLIFO = [moduleId, *ms.tmodelLIFO];
return ;
}
} catch e: {
- return : ", tplLoc)]), ms>;
+ qualifiedModuleName = moduleId2moduleName(moduleId);
+ return : ", tplLoc)]), ms>;
}
msg = " has outdated or missing Rascal TPL version (required: )";
println("INFO: )");
throw rascalTplVersionError(msg);
}
+ qualifiedModuleName = moduleId2moduleName(moduleId);
return ", tplLoc)]), ms>;
}
-rel[str from, PathRole r, str to] getStrPaths(rel[loc from, PathRole r, loc to] paths, PathConfig pcfg){
- strPaths = {};
- for( <- paths){
- try {
- mfrom = getRascalModuleName(from, pcfg);
- mto = getRascalModuleName(to, pcfg);
- strPaths += ;
- } catch _: ;/* ignore non-existing module */
- }
- return strPaths;
-}
-
-rel[loc from, PathRole r, loc to] getPaths(rel[str from, PathRole r, str to] strPaths, ModuleStatus ms){
+rel[loc from, PathRole r, loc to] getPaths(rel[MODID from, PathRole r, MODID to] paths, ModuleStatus ms){
paths = {};
- for( <- strPaths){
+ for( <- paths){
try {
mfrom = getRascalModuleLocation(from, ms);
mto = getRascalModuleLocation(to, ms);
paths += ;
- } catch e: ;/* ignore non-existing module */
+ } catch _: ;/* ignore non-existing module */
}
return paths;
}
-// Update locations in paths when new module locations is known
-ModuleStatus updatePaths(loc oldModuleLoc, loc newModuleLoc, ModuleStatus ms){
- if(oldModuleLoc == newModuleLoc) return ms;
- ms.paths = visit(ms.paths){ case oldModuleLoc => newModuleLoc };
- return ms;
-}
-
-ModuleStatus consolidatePaths(ModuleStatus ms){
- set[loc] locs = {lc| /loc lc := ms.paths};
- map[loc,loc] lprops = ();
- rel[loc,PathRole,loc] paths = ms.paths;
- for(loc l <- locs){
- if(l.top in lprops && loc r := lprops[l.top] && r != l){
- if(l.length? && !r.length?){
- paths = visit(paths) { case r: { insert l; }};
- } else if(!l.length? && r.length?){
- paths = visit(paths) { case l: { insert r; }};
- } else {
- mname = getRascalModuleName(l, ms.pathConfig);
- causes = [info("Module location for : ", x) | x <- [l, r]];
- ms.messages[mname] ? {} += { error("Conflicting module locations found for ", l, causes=causes) };
- }
- }
- lprops[l.top] = l;
- }
- ms.paths = paths;
-
- // strPaths = getStrPaths(ms.paths, ms.pathConfig);
- // if(strPaths != ms.strPaths){
- // println("ms.strPaths:"); iprintln(ms.strPaths);
- // println("ms.paths:"); iprintln(ms.paths);
- // throw "ms.strPaths and ms.paths are incompatible";
- // }
- return ms;
-}
-
int closureCounter = 0;
int nextClosure(){
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc
index 2a458f25d69..7403133a2cb 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/CollectExpression.rsc
@@ -750,10 +750,27 @@ void reportMissingNonTerminalCases(Expression current, rel[loc def, IdRole idRol
// }
private tuple[rel[loc, IdRole, AType], list[bool]] filterOverloads(rel[loc, IdRole, AType] overloads, int arity){
+ // println("filterOverloads: , ");
rel[loc, IdRole, AType] filteredOverloads = {};
list[AType] prevFormals = [];
list[bool] identicalFormals = [true | int _ <- [0 .. arity]];
+ // Filter constructors first to avoid issues with vararg functions
+ for(ovl:<_, _, tp> <- overloads){
+ if(acons(aadt(_, list[AType] _,_), list[AType] fields, list[Keyword] _) := tp){
+ if(size(fields) == arity){
+ filteredOverloads += ovl;
+ if(isEmpty(prevFormals)){
+ prevFormals = fields; //<1>;
+ } else {
+ for(int i <- index(fields)) {
+ identicalFormals[i] = identicalFormals[i] && (comparable(prevFormals[i], fields[i]/*.fieldType*/));
+ }
+ }
+ }
+ }
+ }
+
for(ovl:<_, _, tp> <- overloads){
if(ft:afunc(AType _, list[AType] formals, list[Keyword] _) := tp){
if(ft.varArgs ? (arity >= size(formals) - 1) : (arity == size(formals))) {
@@ -769,18 +786,7 @@ private tuple[rel[loc, IdRole, AType], list[bool]] filterOverloads(rel[loc, IdRo
}
}
}
- else if(acons(aadt(_, list[AType] _,_), list[AType] fields, list[Keyword] _) := tp){
- if(size(fields) == arity){
- filteredOverloads += ovl;
- if(isEmpty(prevFormals)){
- prevFormals = fields; //<1>;
- } else {
- for(int i <- index(fields)) {
- identicalFormals[i] = identicalFormals[i] && (comparable(prevFormals[i], fields[i]/*.fieldType*/));
- }
- }
- }
- }
+
}
return ;
}
diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc
index 2e7d0ac7ea8..ae78e61512b 100644
--- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc
+++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc
@@ -55,41 +55,40 @@ import lang::rascalcore::compile::util::Names; // TODO: refactor, this is an und
ModuleStatus reportSelfImport(rel[loc, PathRole, loc] paths, ModuleStatus ms){
for( <- paths){
- mname = getRascalModuleName(from, ms.pathConfig);
- ms.messages[mname] ? {} += {error("Self import not allowed", from)};
- ms.status[mname] ? {} += {check_error()};
+ // mname = getRascalModuleName(from, ms.pathConfig);
+ ms.messages[from] ? {} += {error("Self import not allowed", from)};
+ ms.status[from] ? {} += {check_error()};
}
return ms;
}
-ModuleStatus reportCycles(rel[loc, PathRole, loc]paths, rel[loc,loc] extendPlus, ModuleStatus ms){
+ModuleStatus reportCycles(rel[MODID, PathRole, MODID]paths, rel[MODID,MODID] extendPlus, ModuleStatus ms){
extendCycle = { m | <- extendPlus };
if(size(extendCycle) > 0){
- for(mloc <- extendCycle){
- mname = getRascalModuleName(mloc, ms.pathConfig);
- causes = [ info("Part of extend cycle ", eloc) | eloc <- extendCycle ];
- ms.messages[mname] ? {} += {error("Extend cycle not allowed", mloc, causes=causes)};
- ms.status[mname] ? {} += {check_error()};
+ for(mid <- extendCycle){
+ mname = getRascalModuleName(mid, ms.pathConfig);
+ causes = [ info("Part of extend cycle ", emid) | emid <- extendCycle ];
+ ms.messages[mid] ? {} += {error("Extend cycle not allowed", mid, causes=causes)};
+ ms.status[mid] ? {} += {check_error()};
}
}
pathsPlus = { | <- paths}+;
- cyclicMixed = { mloc1, mloc2
- | <- pathsPlus, mloc1 != mloc2,
- ( in paths && in paths
- || in paths && in paths
+ cyclicMixed = { mid1, mid2
+ | <- pathsPlus, mid1 != mid2,
+ ( in paths && in paths
+ || in paths && in paths
)
};
- for(mloc <- cyclicMixed){
- set[loc] cycle = { mloc2 | <- pathsPlus, mloc1 == mloc, mloc2 in cyclicMixed } +
- { mloc1 | <- pathsPlus, mloc2 == mloc , mloc1 in cyclicMixed };
+ for(mid <- cyclicMixed){
+ set[loc] cycle = { mid2 | <- pathsPlus, mid1 == mid, mid2 in cyclicMixed } +
+ { mid1 | <- pathsPlus, mid2 == mid , mid1 in cyclicMixed };
if(size(cycle) > 0){
- mname = getRascalModuleName(mloc, ms.pathConfig);
causes = [ info("Part of mixed import/extend cycle ", eloc) | eloc <- cycle ];
- ms.messages[mname] ? {} += { error("Mixed import/extend cycle not allowed", mloc, causes=causes) };
- ms.status[mname] ? {} += {check_error()};
+ ms.messages[mid] ? {} += { error("Mixed import/extend cycle not allowed", mid, causes=causes) };
+ ms.status[mid] ? {} += {check_error()};
}
}
return ms;
@@ -100,119 +99,118 @@ ModuleStatus reportCycles(rel[loc, PathRole, loc]paths, rel[loc,loc] extendPlus,
//- by checking circular dependencies
// TODO: reuse enhancePathRelation from RascalConfig here
ModuleStatus completeModuleStatus(ModuleStatus ms){
- ms = consolidatePaths(ms);
- paths = ms.paths + getPaths(ms.strPaths, ms);
+ paths = ms.paths;
ms = reportSelfImport(paths, ms);
- imports = { | <- paths};
- extendPlus = { | <- paths}+;
- paths += { | <- extendPlus };
+ imports = { | <- paths};
+ extendPlus = { | <- paths}+;
+ paths += { | <- extendPlus };
ms = reportCycles(paths, extendPlus, ms);
paths += { *{ | a <- extendPlus[b], c != a}
- | < loc c, loc b> <- imports
+ | < MODID c, MODID b> <- imports
};
- ms.paths = paths; // sync ms.paths with paths
- ms.strPaths = getStrPaths(ms.paths, ms.pathConfig); // sync ms.strPaths with ms.paths
-
+ ms.paths = paths;
return ms;
}
-ModuleStatus getImportAndExtendGraph(set[str] qualifiedModuleNames, RascalCompilerConfig ccfg){
- return completeModuleStatus((newModuleStatus(ccfg) | getImportAndExtendGraph(qualifiedModuleName, it) | qualifiedModuleName <- qualifiedModuleNames));
+ModuleStatus getImportAndExtendGraph(set[MODID] moduleIds, RascalCompilerConfig ccfg){
+ return completeModuleStatus((newModuleStatus(ccfg) | getImportAndExtendGraph(moduleId, it) | moduleId <- moduleIds));
}
-ModuleStatus getImportAndExtendGraph(set[str] qualifiedModuleNames, ModuleStatus ms){
- return completeModuleStatus((ms | getImportAndExtendGraph(qualifiedModuleName, it) | qualifiedModuleName <- qualifiedModuleNames));
+ModuleStatus getImportAndExtendGraph(set[MODID] moduleIds, ModuleStatus ms){
+ return completeModuleStatus((ms | getImportAndExtendGraph(moduleId, it) | moduleId <- moduleIds));
}
-ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, RascalCompilerConfig ccfg){
- return completeModuleStatus(getImportAndExtendGraph(qualifiedModuleName, newModuleStatus(ccfg)));
+ModuleStatus getImportAndExtendGraph(MODID moduleId, RascalCompilerConfig ccfg){
+ return completeModuleStatus(getImportAndExtendGraph(moduleId, newModuleStatus(ccfg)));
}
-ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
-//println("getImportAndExtendGraph: ");
+ModuleStatus getImportAndExtendGraph(MODID moduleId, ModuleStatus ms){
+ assert isModuleId(moduleId): "getImportAndExtendGraph: ";
pcfg = ms.pathConfig;
- qualifiedModuleName = unescape(qualifiedModuleName);
+ qualifiedModuleName = moduleId2moduleName(moduleId);
- if(!ms.status[qualifiedModuleName]?){
- ms.status[qualifiedModuleName] = {};
+ if(!ms.status[moduleId]?){
+ ms.status[moduleId] = {};
}
- if(module_dependencies_extracted() in ms.status[qualifiedModuleName]){
+ if(module_dependencies_extracted() in ms.status[moduleId]){
return ms;
}
- ms.status[qualifiedModuleName] += module_dependencies_extracted();
+ ms.status[moduleId] += module_dependencies_extracted();
- = getTModelForModule(qualifiedModuleName, ms, convert=true);
+ = getTModelForModule(moduleId, ms);
if(found){
allImportsAndExtendsValid = true;
- rel[str, PathRole] localImportsAndExtends = {};
+ rel[loc, PathRole] localImportsAndExtends = {};
- if(!ms.moduleLastModified[qualifiedModuleName]?){
- ms.moduleLastModified[qualifiedModuleName] = getLastModified(qualifiedModuleName, ms.moduleLastModified, pcfg);
+ if(!ms.moduleLastModified[moduleId]?){
+ ms.moduleLastModified[moduleId] = getLastModified(moduleId, ms);
}
if(tm.store[key_bom]? && rel[str,datetime,PathRole] bom := tm.store[key_bom]){
for( <- bom){
- if(!ms.status[m]?){
- ms.status[m] = {};
+ mid = moduleName2moduleId(m);
+ if(!ms.status[mid]?){
+ ms.status[mid] = {};
}
- if(m != qualifiedModuleName){
- localImportsAndExtends += ;
+ if(mid != moduleId){
+ localImportsAndExtends += ;
}
- dependencyChanged = (m != qualifiedModuleName) && !isEmpty(ms.changedModules & range(ms.strPaths[m]));
+ dependencyChanged = (mid != moduleId) && !isEmpty(ms.changedModules & range(ms.paths[mid]));
//if(dependencyChanged) println("processing BOM of and consider , dependencyChanged: ");
- = isModuleModified(m, timestampInBom, pathRole, ms);
+ = isModuleModified(mid, timestampInBom, pathRole, ms);
if(dependencyChanged || mchanged){
allImportsAndExtendsValid = false;
- ms.status[m] += rsc_changed();
- ms.status[m] -= {tpl_uptodate(), checked()};
- ms.status[qualifiedModuleName] -= tpl_saved();
- ms.messages[qualifiedModuleName] = {};
+ ms.status[mid] += rsc_changed();
+ ms.status[mid] -= {tpl_uptodate(), checked()};
+ ms.status[moduleId] -= tpl_saved();
+ ms.messages[moduleId] = {};
if(ms.compilerConfig.verbose){
- println("--- using (most recent) version of ,
+ println("--- using (most recent) version of ,
' older version was used in previous check of ");
}
}
}
} else {
- throw "No bill-of-materials found for ";
+ throw "No bill-of-materials found for ";
}
if(!allImportsAndExtendsValid){ // Check that the source code of qualifiedModuleName is available
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
try {
try {
- mloc = getRascalModuleLocation(qualifiedModuleName, ms);
+ mloc = getRascalModuleLocation(moduleId, ms);
} catch Message err: {
- ms.messages[qualifiedModuleName] = { err };
- tm = tmodel(modelName=qualifiedModuleName, messages=[ err ]);
- ms = addTModel(qualifiedModuleName, tm, ms);
- ms.status[qualifiedModuleName] += { rsc_not_found() };
+ ms.messages[moduleId] = { err };
+ tm = tmodel(modelName=moduleId2moduleName(moduleId), messages=[ err ]);
+ ms = addTModel(moduleId, tm, ms);
+ ms.status[moduleId] += { rsc_not_found() };
return ms;
}
- if(mloc.extension != "rsc" || isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)) throw "No src or library module 1"; //There is only a tpl file available
+ if(!isLogicalLoc(mloc) && (mloc.extension != "rsc" || isModuleLocationInLibs(mloc, pcfg))) throw "No src or library module 1"; //There is only a tpl file available
} catch value _:{
= isCompatibleBinaryLibrary(tm, ms);
+ incompatibleNames = [ getModuleNameFromAnyLogical(imod) | MODID imod <- incompatible ];
if(!isEmpty(incompatible)){
- causes = [ info("Module is incompatible with ", getRascalModuleLocation(iname, ms)) | iname <- incompatible ];
- txt = "Review of dependencies, reconfiguration or recompilation needed: binary module `` depends (indirectly) on incompatible module(s) ";
+ causes = [ info("Module is incompatible with ", incomp) | incomp <- incompatible ];
+ txt = "Review of dependencies, reconfiguration or recompilation needed: binary module `` depends (indirectly) on incompatible module(s) ";
msg = error(txt, mloc, causes=causes);
tm.messages += [msg];
- ms.messages[qualifiedModuleName] ? {} += { msg };
+ ms.messages[moduleId] ? {} += { msg };
txt2 = "Review of dependencies, reconfiguration or recompilation needed: imported/extended binary module `` depends (indirectly) on incompatible module(s)";
- usingModules = {user | <- ms.strPaths<0,2>*};
+ usingModules = {user | <- ms.paths<0,2>*};
for(user <- usingModules){
mloc = getRascalModuleLocation(user, ms);
- if(!isModuleLocationInLibs(user, mloc, pcfg)){
+ if(!isModuleLocationInLibs(mloc, pcfg)){
msg2 = error(txt2, mloc, causes=causes);
ms.messages[user] ? {} += { msg2 };
}
@@ -226,12 +224,12 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
}
}
if(allImportsAndExtendsValid){
- ms.status[qualifiedModuleName] += {tpl_uptodate(), checked()}; //TODO: maybe check existence of generated java files
- ms.moduleLocs += tm.moduleLocs;
+ ms.status[moduleId] += {tpl_uptodate(), checked(), tpl_saved()}; //TODO: maybe check existence of generated java files
+ ms.moduleLocs += (moduleName2moduleId(mname) : tm.moduleLocs[mname] | mname <- tm.moduleLocs); // TODO: or not?
ms.paths += tm.paths;
- ms.strPaths += { | <- localImportsAndExtends };
- ms.status[qualifiedModuleName] += module_dependencies_extracted();
- ms.messages[qualifiedModuleName] ? {} += toSet(tm.messages);
+ // ms.strPaths += { | <- localImportsAndExtends };
+ ms.status[moduleId] += module_dependencies_extracted();
+ ms.messages[moduleId] ? {} += toSet(tm.messages);
for( <- localImportsAndExtends, isEmpty({module_dependencies_extracted()} & ms.status[imp]) ){
ms.status[imp] -= tpl_saved();
ms = getImportAndExtendGraph(imp, ms);
@@ -240,20 +238,19 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
}
}
- if(rsc_not_found() in ms.status[qualifiedModuleName]){
+ if(rsc_not_found() in ms.status[moduleId]){
return ms;
}
- = getModuleParseTree(qualifiedModuleName, ms);
+ = getModuleParseTree(moduleId, ms);
if(success){
- = getModulePathsAsStr(pt, ms);
+ = getModulePaths(pt, ms);
for(<_, kind, imp> <- imports_and_extends, rsc_not_found() notin ms.status[imp]){
- ms.strPaths += {};
ms = getImportAndExtendGraph(imp, ms);
}
} else {
- ms.status[qualifiedModuleName] += rsc_not_found();
+ ms.status[moduleId] += rsc_not_found();
}
return ms;
@@ -266,23 +263,23 @@ ModuleStatus getInlineImportAndExtendGraph(Tree pt, RascalCompilerConfig ccfg){
header = m.header;
body = m.body;
qualifiedModuleName = prettyPrintName(header.name);
- ms.moduleLocs[qualifiedModuleName] = getLoc(m);
- = getModulePathsAsStr(m, ms);
+ ms.moduleLocs[moduleName2moduleId(qualifiedModuleName)] = getLoc(m);
+ = getModulePaths(m, ms);
}
}
return completeModuleStatus(ms);
}
// Is binary library module compatible with its dependencies (originating from imports and extends)?
-tuple[list[str], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatus ms){
+tuple[list[MODID], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatus ms){
libName = lib.modelName;
set[loc] libLogical = domain(lib.logical2physical);
- set[loc] libDefines = { l | l <- libLogical, getModuleFromLogical(l) == libName };
+ set[loc] libDefines = { l | l <- libLogical, getModuleNameFromAnyLogical(l) == libName };
set[loc] libDependsOn = libLogical - libDefines;
- set[str] libDependsOnModules = { getModuleFromLogical(l) | l <- libDependsOn };
+ set[str] libDependsOnModules = { getModuleNameFromAnyLogical(l) | l <- libDependsOn };
set[loc] dependentsProvide = {};
for(m <- libDependsOnModules){
- = getTModelForModule(m, ms, convert=false);
+ = getTModelForModule(m, ms);
if(found){
dependentsProvide += domain(tm.logical2physical);
}
@@ -294,40 +291,40 @@ tuple[list[str], ModuleStatus] isCompatibleBinaryLibrary(TModel lib, ModuleStatu
//println("isCompatibleBinaryLibrary : satisfied");
return <[], ms>;
} else {
- println("BOM of :"); iprintln(lib.store[key_bom]);
- println("libDependsOn:
- 'dependentsProvide:
- 'unstatisfied:
- ");
- println("isCompatibleBinaryLibrary, unsatisfied ()");
+ // println("BOM of :"); iprintln(lib.store[key_bom]);
+ // println("libDependsOn:
+ // 'dependentsProvide:
+ // 'unstatisfied:
+ // ");
+ // println("isCompatibleBinaryLibrary, unsatisfied ()");
- incompatibleModules = { getModuleFromLogical(u) | u <- unsatisfied };
- return ;
+ //incompatibleModuleNames = { moduleId2moduleName(u) | u <- unsatisfied };
+ return ;
}
}
// Example: |rascal+function:///util/Math/round$d80e373d64c01979| ==> util::Math
// Example: |rascal+module:///lang/rascal/syntax/Rascal| -> lang::rascal::syntax::Rascal
-str getModuleFromLogical(loc l){
+str getModuleNameFromAnyLogical(loc l){
i = findLast(l.path[1..], "/");
res = (l.scheme == "rascal+module" || i < 0) ? l.path[1..] : l.path[1..i+1];
res = replaceAll(res, "/", "::");
- //println("getModuleFromLogical: -\> ");
+ //println("getModuleNameFromAnyLogical: -\> ");
return res;
}
-tuple[bool, ModuleStatus] importsAndExtendsAreBinaryCompatible(TModel tm, set[str] importsAndExtends, ModuleStatus ms){
+tuple[bool, ModuleStatus] importsAndExtendsAreBinaryCompatible(TModel tm, set[MODID] importsAndExtends, ModuleStatus ms){
moduleName = tm.modelName;
physical2logical = invertUnique(tm.logical2physical);
modRequires = { lg | l <- range(tm.useDef),
physical2logical[l]?, lg := physical2logical[l],
- moduleName !:= getModuleFromLogical(lg) };
+ moduleName !:= getModuleNameFromAnyLogical(lg) };
provided = {};
if(!isEmpty(modRequires)){
for(m <- importsAndExtends){
-