Skip to content

Commit

Permalink
Major renaming getModuleLocation => getRascalModuleLocation, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Dec 16, 2024
1 parent b3b4e6a commit 24641e1
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/org/rascalmpl/core/library/MeasureParsing.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main(){
write_time = 0;
for(int _ <- [1..10]){
for(qualifiedModuleName <- ["Boolean", "Type", "ParseTree", "List"]){
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
ploc = |file:///tmp/<qualifiedModuleName>.parsetree|;
//println("*** parsing <qualifiedModuleName> from <mloc>");
start_time = cpuTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void addCommonKeywordFields(Solver s){
fieldName = "<kwf.name>";
fieldType = s.getType(kwf);
fieldType.alabel = fieldName;
moduleName = getModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig);
moduleName = getRascalModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig);
commonKeywordFields += <adtType, kwField(fieldType, fieldName, moduleName, kwf.expression)>;
//commonKeywordFieldNames += <adtType, fieldName, fieldType>;
// TODO: reconsider this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ set[map[str, list[Message]]] allRascalTests(PathConfig pcfg= pathConfig(
//
// <_, msgs> = checkModules([qualifiedModuleName], rascalTypePalConfig(), pcfg);
// iprintln(msgs);
// mTplLoc = getDerivedWriteLoc(qualifiedModuleName, "tpl", pcfg);
// mTplLoc = getRascalModuleDerivedWriteLoc(qualifiedModuleName, "tpl", pcfg);
// mOrgModel = readBinaryValueFile(#TModel, mTplLoc);
//
// differences = ();
Expand Down Expand Up @@ -434,7 +434,7 @@ void allFiles(PathConfig pcfg = pathConfig(
nskipped = 0;
ncount = 0;
for(p <- modulePaths){
qualifiedModuleName = getModuleName(p, pcfg);
qualifiedModuleName = getRascalModuleName(p, pcfg);
ncount += 1;
if(blacklisted(qualifiedModuleName)){
println("\>\>\> <ncount>: SKIPPING <qualifiedModuleName>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extend lang::rascalcore::check::RascalConfig;
extend lang::rascalcore::check::CheckerCommon;

import lang::rascalcore::compile::CompileTimeError;
import lang::rascalcore::check::ModuleLocations;
extend lang::rascalcore::check::TestConfigs;

import analysis::typepal::Exception;
Expand Down Expand Up @@ -135,7 +136,7 @@ ModuleStatus rascalTModelForLocs(
append "LocationDoesNotExist: <mloc>";
} else {
try {
append getModuleName(mloc, pcfg);
append getRascalModuleName(mloc, pcfg);
} catch e: {
append "NoModuleNameFound: <mloc>";
msgs += error("No module name found for <mloc>", mloc);
Expand Down Expand Up @@ -406,7 +407,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
ms.messages[nm] = {};
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
try {
mloc = getModuleLocation(nm, pcfg);
mloc = getRascalModuleLocation(nm, pcfg);
} catch e: {
err = error("Cannot get location for <nm>: <e>", mloc);
ms.messages[nm] = { err };
Expand Down Expand Up @@ -487,7 +488,7 @@ ModuleStatus rascalTModelForNames(list[str] moduleNames,
mlocs = [];
for(moduleName <- moduleNames){
try {
mlocs += [ getModuleLocation(moduleName, pcfg) ];
mlocs += [ getRascalModuleLocation(moduleName, pcfg) ];
} catch value e: {
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
err = error("Cannot get location for <moduleName>: <e>", mloc);
Expand All @@ -514,7 +515,7 @@ bool otherModulesWithOutdatedTpls(list[loc] candidates, PathConfig pcfg){
for(srcdir <- pcfg.srcs){
for(loc mloc <- find(srcdir, "rsc")){
try {
mname = getModuleName(mloc, pcfg);
mname = getRascalModuleName(mloc, pcfg);
<found, tpl> = getTPLReadLoc(mname, pcfg);
if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extend lang::rascalcore::check::SyntaxGetters;
extend analysis::typepal::FailMessage;

extend lang::rascalcore::check::BasicRascalConfig;
extend lang::rascalcore::check::ModuleLocations;

import analysis::typepal::Collector;

Expand Down Expand Up @@ -119,7 +120,7 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM
return res;
} catch NoSuchKey(_): {
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
res = lastModified(mloc);
//println("getLastModified <mloc> via lastModified: <res>");
return res;
Expand All @@ -131,7 +132,7 @@ datetime getLastModified(str qualifiedModuleName, map[str, datetime] moduleLastM

bool tplOutdated(str qualifiedModuleName, PathConfig pcfg){
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
<found, tpl> = getTPLReadLoc(qualifiedModuleName, pcfg);
lmMloc = lastModified(mloc);
lmTpl = lastModified(tpl);
Expand Down Expand Up @@ -163,7 +164,7 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, Mo
ms.parseTreeLIFO = [qualifiedModuleName, *ms.parseTreeLIFO];
mloc = |unknown:///<qualifiedModuleName>|;
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
// 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()};
Expand Down Expand Up @@ -329,7 +330,7 @@ tuple[bool, TModel, ModuleStatus] getTModelForModule(str qualifiedModuleName, Mo
tm.usesPhysicalLocs = false; // temporary
tm = convertTModel2PhysicalLocs(tm);
ms.tmodels[qualifiedModuleName] = tm;
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
if(isModuleLocationInLibs(qualifiedModuleName, mloc, pcfg)){
ms.status[qualifiedModuleName] ? {} += {rsc_not_found()};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void checkModuleName(loc mloc, QualifiedName qualifiedModuleName, Collector c){
if([PathConfig pcfg] := pcfgVal){
mname = prettyPrintName(qualifiedModuleName);
try {
mloc1 = getModuleLocation(mname, pcfg);
mloc1 = getRascalModuleLocation(mname, pcfg);
if(mloc.scheme != mloc1.scheme || mloc.authority != mloc1.authority || mloc.path != mloc1.path){
c.report(error(qualifiedModuleName, "Module name `%v` is incompatible with its file location %v", mname, mloc));
}
Expand Down
20 changes: 10 additions & 10 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import util::Reflective;
import util::Benchmark;
import lang::rascalcore::compile::util::Names; // TODO: refactor, this is an undesired dependency on compile

private str getModuleName(loc mloc, map[loc,str] moduleStrs, PathConfig pcfg){
private str getRascalModuleName(loc mloc, map[loc,str] moduleStrs, PathConfig pcfg){
if(moduleStrs[mloc]? ){
return moduleStrs[mloc];
}
return getModuleName(mloc, pcfg);
return getRascalModuleName(mloc, pcfg);
}

// Complete a ModuleStatus by adding a contains relation that adds transitive edges for extend
Expand All @@ -52,9 +52,9 @@ ModuleStatus completeModuleStatus(ModuleStatus ms){
|| <mloc1, extendPath(), mloc2> in paths && <mloc2, importPath(), mloc1> in paths };

for(mloc <- cyclicMixed){
mname = getModuleName(mloc, moduleStrs, pcfg);
set[str] cycle = { getModuleName(mloc2, moduleStrs, pcfg) | <mloc1, mloc2> <- pathsPlus, mloc1 == mloc, mloc2 in cyclicMixed } +
{ getModuleName(mloc1, moduleStrs, pcfg) | <mloc1, mloc2> <- pathsPlus, mloc2 == mloc , mloc1 in cyclicMixed };
mname = getRascalModuleName(mloc, moduleStrs, pcfg);
set[str] cycle = { getRascalModuleName(mloc2, moduleStrs, pcfg) | <mloc1, mloc2> <- pathsPlus, mloc1 == mloc, mloc2 in cyclicMixed } +
{ getRascalModuleName(mloc1, moduleStrs, pcfg) | <mloc1, mloc2> <- pathsPlus, mloc2 == mloc , mloc1 in cyclicMixed };
if(size(cycle) > 1){
ms.messages[mname] = (ms.messages[mname] ? {}) + error("Mixed import/extend cycle not allowed: {<intercalate(", ", toList(cycle))>}", mloc);
}
Expand All @@ -67,8 +67,8 @@ ModuleStatus completeModuleStatus(ModuleStatus ms){
strPaths = {};
for(<loc from, PathRole r, loc to> <- paths){
try {
mfrom = getModuleName(from, moduleStrs, pcfg);
mto = getModuleName(to, moduleStrs, pcfg);
mfrom = getRascalModuleName(from, moduleStrs, pcfg);
mto = getRascalModuleName(to, moduleStrs, pcfg);
strPaths += <mfrom, r, mto >;
} catch _: ;/* ignore non-existing module */
}
Expand Down Expand Up @@ -140,7 +140,7 @@ ModuleStatus getImportAndExtendGraph(str qualifiedModuleName, ModuleStatus ms){
try {
mloc = |unknown:///|(0,0,<0,0>,<0,0>);
try {
mloc = getModuleLocation(qualifiedModuleName, pcfg);
mloc = getRascalModuleLocation(qualifiedModuleName, pcfg);
} catch e: {
err = error("Cannot get location for <qualifiedModuleName>: <e>", mloc);
ms.messages[qualifiedModuleName] = { err };
Expand Down Expand Up @@ -278,7 +278,7 @@ tuple[ModuleStatus, rel[str, PathRole, str]] getModulePathsAsStr(Module m, Modul
imports_and_extends += <moduleName, imod is \default ? importPath() : extendPath(), iname>;
ms.status[iname] = ms.status[iname] ? {};
try {
mloc = getModuleLocation(iname, ms.pathConfig);
mloc = getRascalModuleLocation(iname, ms.pathConfig);
} catch str msg: {
err = error("Cannot get location for <iname>: <msg>", imod@\loc);
ms.messages[moduleName] ? {} += { err };
Expand All @@ -299,7 +299,7 @@ loc getModuleScope(str qualifiedModuleName, map[str, loc] moduleScopes, PathConf
return moduleScopes[qualifiedModuleName];
}
for(l <- range(moduleScopes)){
if(getModuleName(l, pcfg) == qualifiedModuleName){
if(getRascalModuleName(l, pcfg) == qualifiedModuleName){
return l;
}
}
Expand Down
Loading

0 comments on commit 24641e1

Please sign in to comment.