diff --git a/src/org/rascalmpl/core/library/MeasureParsing.rsc b/src/org/rascalmpl/core/library/MeasureParsing.rsc index 7365f9c9..20f9a0f8 100644 --- a/src/org/rascalmpl/core/library/MeasureParsing.rsc +++ b/src/org/rascalmpl/core/library/MeasureParsing.rsc @@ -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/.parsetree|; //println("*** parsing from "); start_time = cpuTime(); diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/ADTandGrammar.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/ADTandGrammar.rsc index 4c37c939..a9b8ff80 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/ADTandGrammar.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/ADTandGrammar.rsc @@ -72,7 +72,7 @@ void addCommonKeywordFields(Solver s){ fieldName = ""; fieldType = s.getType(kwf); fieldType.alabel = fieldName; - moduleName = getModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig); + moduleName = getRascalModuleName(kwf.expression@\loc, s.getConfig().typepalPathConfig); commonKeywordFields += ; //commonKeywordFieldNames += ; // TODO: reconsider this diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/AllRascalTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/AllRascalTests.rsc index 4f6f1c00..cca0838a 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/AllRascalTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/AllRascalTests.rsc @@ -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 = (); @@ -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("\>\>\> : SKIPPING "); diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc index a925b239..82f92499 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc @@ -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; @@ -135,7 +136,7 @@ ModuleStatus rascalTModelForLocs( append "LocationDoesNotExist: "; } else { try { - append getModuleName(mloc, pcfg); + append getRascalModuleName(mloc, pcfg); } catch e: { append "NoModuleNameFound: "; msgs += error("No module name found for ", mloc); @@ -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 : ", mloc); ms.messages[nm] = { err }; @@ -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 : ", mloc); @@ -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); = getTPLReadLoc(mname, pcfg); if(found && (mloc notin candidates) && (lastModified(mloc) > lastModified(tpl))){ return true; diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CheckerCommon.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CheckerCommon.rsc index b2b680f8..975bc893 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CheckerCommon.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CheckerCommon.rsc @@ -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; @@ -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 via lastModified: "); return res; @@ -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); = getTPLReadLoc(qualifiedModuleName, pcfg); lmMloc = lastModified(mloc); lmTpl = lastModified(tpl); @@ -163,7 +164,7 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, Mo ms.parseTreeLIFO = [qualifiedModuleName, *ms.parseTreeLIFO]; mloc = |unknown:///|; 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()}; @@ -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()}; } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc index 075d757a..b486b13d 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectDeclaration.rsc @@ -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)); } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc index f9def466..8c39b7e3 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc @@ -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 @@ -52,9 +52,9 @@ ModuleStatus completeModuleStatus(ModuleStatus ms){ || in paths && in paths }; for(mloc <- cyclicMixed){ - mname = getModuleName(mloc, moduleStrs, pcfg); - set[str] cycle = { getModuleName(mloc2, moduleStrs, pcfg) | <- pathsPlus, mloc1 == mloc, mloc2 in cyclicMixed } + - { getModuleName(mloc1, moduleStrs, pcfg) | <- pathsPlus, mloc2 == mloc , mloc1 in cyclicMixed }; + mname = getRascalModuleName(mloc, moduleStrs, pcfg); + set[str] cycle = { getRascalModuleName(mloc2, moduleStrs, pcfg) | <- pathsPlus, mloc1 == mloc, mloc2 in cyclicMixed } + + { getRascalModuleName(mloc1, moduleStrs, pcfg) | <- pathsPlus, mloc2 == mloc , mloc1 in cyclicMixed }; if(size(cycle) > 1){ ms.messages[mname] = (ms.messages[mname] ? {}) + error("Mixed import/extend cycle not allowed: {}", mloc); } @@ -67,8 +67,8 @@ ModuleStatus completeModuleStatus(ModuleStatus ms){ strPaths = {}; for( <- paths){ try { - mfrom = getModuleName(from, moduleStrs, pcfg); - mto = getModuleName(to, moduleStrs, pcfg); + mfrom = getRascalModuleName(from, moduleStrs, pcfg); + mto = getRascalModuleName(to, moduleStrs, pcfg); strPaths += ; } catch _: ;/* ignore non-existing module */ } @@ -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 : ", mloc); ms.messages[qualifiedModuleName] = { err }; @@ -278,7 +278,7 @@ tuple[ModuleStatus, rel[str, PathRole, str]] getModulePathsAsStr(Module m, Modul imports_and_extends += ; 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 : ", imod@\loc); ms.messages[moduleName] ? {} += { err }; @@ -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; } } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/ModuleLocations.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/ModuleLocations.rsc new file mode 100644 index 00000000..7effa43e --- /dev/null +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/ModuleLocations.rsc @@ -0,0 +1,241 @@ +@bootstrapParser +module lang::rascalcore::check::ModuleLocations + +import IO; +import String; +import util::Reflective; +import util::FileSystem; + +str makeFileName(str qualifiedModuleName, str extension = "rsc") { + str qnameSlashes = replaceAll(qualifiedModuleName, "::", "/"); + int n = findLast(qnameSlashes, "/"); + str prefix = extension == "rsc" ? "" : "$"; + str package = extension == "rsc" ? "" : "rascal/"; + qnameSlashes = n < 0 ? "" + qnameSlashes : qnameSlashes[0..n] + "/" + qnameSlashes[n+1..]; + return "">"; +} + +loc getSearchPathLoc(str filePath, PathConfig pcfg){ + for(loc dir <- pcfg.srcs + pcfg.libs){ + fileLoc = dir + filePath; + if(exists(fileLoc)){ + //println("getRascalModuleLocation =\> "); + return fileLoc; + } + } + throw "Module with path not found"; +} + +@synopsis{Get the location of a named module, search for `src` in srcs and `tpl` in libs} +loc getRascalModuleLocation(str qualifiedModuleName, PathConfig pcfg){ + fileName = makeFileName(qualifiedModuleName, extension="rsc"); + for(loc dir <- pcfg.srcs){ + fileLoc = dir + fileName; + if(exists(fileLoc)){ + return fileLoc; + } + } + fileName = makeFileName(qualifiedModuleName, extension="tpl"); + for(loc dir <- pcfg.libs){ + fileLoc = dir + fileName; + + if(exists(fileLoc)){ + return fileLoc; + } + } + throw "Module `` not found;\n"; +} + +tuple[str,str] splitFileExtension(str path){ + int n = findLast(path, "."); + if(n < 0) return ; + return ; +} + +@synopsis{Determine length of common suffix of list of strings} +int commonSuffix(list[str] dir, list[str] m) + = commonPrefix(reverse(dir), reverse(m)); + +@synopsis{Determine length of common prefix of list of strings} +int commonPrefix(list[str] rdir, list[str] rm){ + for(int i <- index(rm)){ + if(i >= size(rdir)){ + return i; + } else if(rdir[i] != rm[i]){ + return i; + } else { + continue; + } + } + return size(rm); +} + +@synopsis{Find the module name corresponding to a given module location via its (src or tpl) location} +str getRascalModuleName(loc moduleLoc, PathConfig pcfg){ + modulePath = moduleLoc.path; + + rscFile = endsWith(modulePath, "rsc"); + tplFile = endsWith(modulePath, "tpl"); + + if(!( rscFile || tplFile )){ + throw "Not a Rascal .src or .tpl file: "; + } + + // Find matching .rsc file in source directories + if(rscFile){ + for(loc dir <- pcfg.srcs){ + if(moduleLoc.authority == dir.authority && startsWith(modulePath, dir.path)) { + moduleName = replaceFirst(modulePath, dir.path, ""); + = splitFileExtension(moduleName); + if(moduleName[0] == "/"){ + moduleName = moduleName[1..]; + } + moduleName = replaceAll(moduleName, "/", "::"); + return moduleName; + } + } + } + + // Find longest matching .tpl file in library directories + + = splitFileExtension(modulePath); + while(modulePathNoExt[0] == "/"){ + modulePathNoExt = modulePathNoExt[1..]; + } + + modulePathAsList = split("/", modulePathNoExt); + if(tplFile){ + lastName = modulePathAsList[-1]; + if(lastName[0] == "$"){ + modulePathAsList = [*modulePathAsList[..-1],lastName[1..]]; + } + } + if(modulePathAsList[0] == "rascal"){ + modulePathAsList = modulePathAsList[1..]; + } + modulePathReversed = reverse(modulePathAsList); + + int longestSuffix = 0; + for(loc dir <- pcfg.libs){ + dir = dir + "rascal"; + dpath = dir.path; + + while(dpath[0] == "/"){ + dpath = dpath[1..]; + } + + for(loc file <- find(dir, "tpl")){ + candidate = replaceFirst(file.path, dpath, ""); + = splitFileExtension(candidate); + while(candidate[0] == "/"){ + candidate = candidate[1..]; + } + + candidateAsList = split("/", candidate); + lastName = candidateAsList[-1]; + if(lastName[0] == "$"){ + candidateAsList = [*candidateAsList[..-1],lastName[1..]]; + } + // println("cand: , modpath: "); + n = commonPrefix(reverse(candidateAsList), modulePathReversed); + + if(n > longestSuffix){ + longestSuffix = n; + } + } + } + + if(longestSuffix > 0){ + lastName = modulePathAsList[-1]; + if(lastName[0] == "$"){ + modulePathAsList = [*modulePathAsList[..-1],lastName[1..]]; + } + return intercalate("::", modulePathAsList[size(modulePathAsList) - longestSuffix .. ]); + } + throw "No module name found for ;\nsrcs=;\nlibs="; +} + +@synopsis{Derive a location from a given module name for reading} +@description{ +Given a module name, a file name extension, and a PathConfig, +a path name is constructed from the module name + extension. + +If a file F with this path exists in one of the directories in the PathConfig, +then the pair is returned. Otherwise is returned. + +For a source extension (typically "rsc" or "mu" but this can be configured) srcs is searched, otherwise binPath + libs. +} +@examples{ +```rascal-shell +import util::Reflective; +getRascalModuleDerivedReadLoc("List", "rsc", pathConfig()); +getRascalModuleDerivedReadLoc("experiments::Compiler::Compile", "rvm", pathConfig()); +getRascalModuleDerivedReadLoc("experiments::Compiler::muRascal2RVM::Library", "mu", pathConfig()); +``` +} +@benefits{ +This function is useful for type checking and compilation tasks, when derived information related to source modules has to be read +from locations in different, configurable, directories. +} + +tuple[bool, loc] getRascalModuleDerivedReadLoc(str qualifiedModuleName, str extension, PathConfig pcfg, set[str] srcExtensions = {"rsc", "mu"}, str rootDir = ""){ + fileName = makeFileName(qualifiedModuleName, extension=extension); + //println("getRascalModuleDerivedReadLoc: "); + + if(extension in srcExtensions){ + for(loc dir <- pcfg.srcs){ // In a source directory? + fileLoc = dir + rootDir + fileName; + if(exists(fileLoc)){ + //println("getRascalModuleDerivedReadLoc: , =\> ; + } + } + } else { + for(loc dir <- pcfg.bin + pcfg.libs){ // In a bin or lib directory? + + fileLoc = dir + rootDir + fileName; + if(exists(fileLoc)){ + //println("getRascalModuleDerivedReadLoc: , =\> "); + return ; + } + } + } + //println("getRascalModuleDerivedReadLoc: , =\> |error:///|"); + return ; +} + +@synopsis{Derive a location from a given module name for writing} +@description{ +Given a module name, a file name extension, and a PathConfig, +a path name is constructed from the module name + extension. + +For source modules, a writable location cannot be derived. +For other modules, a location for this path in bin will be returned. +} +@examples{ +```rascal-shell +import util::Reflective; +getRascalModuleDerivedWriteLoc("List", "rvm", pathConfig()); +getRascalModuleDerivedWriteLoc("experiments::Compiler::Compile", "rvm", pathConfig()); +``` + +```rascal-shell,error +getRascalModuleDerivedWriteLoc("experiments::Compiler::muRascal2RVM::Library", "rsc", pathConfig()); +``` +} +@benefits{ +This function is useful for type checking and compilation tasks, when derived information related to source modules has to be written +to locations in separate, configurable, directories. +} +loc getRascalModuleDerivedWriteLoc(str qualifiedModuleName, str extension, PathConfig pcfg, set[str] srcExtensions = {"rsc", "mu"}, str rootDir = ""){ + if(extension in srcExtensions){ + throw "Cannot derive writable location for module with extension "; + } + fileNameSrc = makeFileName(qualifiedModuleName); + fileNameBin = makeFileName(qualifiedModuleName, extension=extension); + + bin = pcfg.bin; + fileLocBin = bin + rootDir + fileNameBin; + //println("getRascalModuleDerivedWriteLoc: , =\> "); + return fileLocBin; +} \ No newline at end of file diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/RascalConfig.rsc index bbc1f23d..89fe5b5b 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/RascalConfig.rsc @@ -451,7 +451,7 @@ bool isLogicalLoc(loc l) loc rascalCreateLogicalLoc(Define def, str _modelName, PathConfig pcfg){ if(def.idRole in keepInTModelRoles){ if(isLogicalLoc(def.defined)) return def.defined; - moduleName = getModuleName(def.defined, pcfg); + moduleName = getRascalModuleName(def.defined, pcfg); moduleNameSlashed = replaceAll(moduleName, "::", "/"); suffix = def.defInfo.md5? ? "$" : ""; if(def.idRole == moduleId()){ @@ -464,12 +464,12 @@ loc rascalCreateLogicalLoc(Define def, str _modelName, PathConfig pcfg){ } @memo{expireAfter(minutes=5),maximumSize(1000)} -rel[str shortName, str longName] getModuleNames(PathConfig pcfg){ +rel[str shortName, str longName] getRascalModuleNames(PathConfig pcfg){ longNames = {}; for(srcdir <- pcfg.srcs){ for(loc mloc <- find(srcdir, "rsc")){ try { - longName = getModuleName(mloc, pcfg); + longName = getRascalModuleName(mloc, pcfg); longNames += ; } catch _: ; } @@ -477,7 +477,7 @@ rel[str shortName, str longName] getModuleNames(PathConfig pcfg){ for(libdir <- pcfg.libs){ for(loc mloc <- find(libdir, "tpl")){ try { - longName = getModuleName(mloc, pcfg); + longName = getRascalModuleName(mloc, pcfg); longNames += ; } catch _: ; } @@ -491,7 +491,7 @@ list[str] rascalSimilarNames(Use u, TModel tm){ idRoles = u.idRoles; pcfg = tm.config.typepalPathConfig; if(moduleId() in idRoles){ - longNames = getModuleNames(pcfg); + longNames = getRascalModuleNames(pcfg); similar = similarWords(w, domain(longNames), tm.config.cutoffForNameSimilarity)[0..10]; return sort({*longNames[s] | s <- similar }, bool (str a, str b) { return size(a) < size(b); }); } else { diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/ChangeScenarioTests.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/ChangeScenarioTests.rsc index 2c746eed..6cbeeb55 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/ChangeScenarioTests.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/ChangeScenarioTests.rsc @@ -18,7 +18,7 @@ bool validateBOMs(PathConfig pcfg){ nOudatedTPLs = 0; for(srcdir <- pcfg.srcs){ for(loc mloc <- find(srcdir, "rsc")){ - m = getModuleName(mloc, pcfg); + m = getRascalModuleName(mloc, pcfg); lastModRSC[m] = lastModified(mloc); = getTPLReadLoc(m, pcfg); if(found){ @@ -35,7 +35,7 @@ bool validateBOMs(PathConfig pcfg){ valid = nOudatedTPLs == 0; for(srcdir <- pcfg.srcs){ for(loc mloc <- find(srcdir, "rsc")){ - m = getModuleName(mloc, pcfg); + m = getRascalModuleName(mloc, pcfg); = getTPLReadLoc(m, pcfg); if(found){ @@ -419,7 +419,7 @@ test bool breakingChange1(){ bool touchAndCheck(loc Top, list[str] moduleNames, PathConfig pcfg){ println("TOUCH "); for(mname <- moduleNames){ - touch(getModuleLocation(mname, pcfg)); + touch(getRascalModuleLocation(mname, pcfg)); } return expectReChecks(Top, moduleNames, pathConfig=pcfg); } @@ -427,7 +427,7 @@ bool touchAndCheck(loc Top, list[str] moduleNames, PathConfig pcfg){ test bool onlyTouchedModulesAreReChecked1(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); - Top = getModuleLocation("analysis::grammars::Ambiguity", pcfg); + Top = getRascalModuleLocation("analysis::grammars::Ambiguity", pcfg); assert checkModuleOK(Top, pathConfig = pcfg); assert validateBOMs(pcfg); @@ -441,7 +441,7 @@ test bool onlyTouchedModulesAreReChecked1(){ test bool onlyTouchedModulesAreReChecked2(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); - Top = getModuleLocation("lang::rascalcore::check::Checker", pcfg); + Top = getRascalModuleLocation("lang::rascalcore::check::Checker", pcfg); assert checkModuleOK(Top, pathConfig = pcfg); assert validateBOMs(pcfg); @@ -458,7 +458,7 @@ str MARKER = "//TEMPORARILY ADDED FOR TESTING"; void changeModules(list[str] moduleNames, PathConfig pcfg, str injectedError=""){ for(moduleName <- moduleNames){ - mloc = getModuleLocation(moduleName, pcfg); + mloc = getRascalModuleLocation(moduleName, pcfg); lines = readFileLines(mloc); lines += MARKER; lines += injectedError; @@ -468,7 +468,7 @@ void changeModules(list[str] moduleNames, PathConfig pcfg, str injectedError="") void restoreModules(list[str] moduleNames, PathConfig pcfg){ for(moduleName <- moduleNames){ - mloc = getModuleLocation(moduleName, pcfg); + mloc = getRascalModuleLocation(moduleName, pcfg); lines = readFileLines(mloc); for(int i <- index(lines)){ if(lines[i] == MARKER){ @@ -488,7 +488,7 @@ bool changeAndCheck(loc Top, list[str] moduleNames, PathConfig pcfg, str injecte value main(){ pcfg = getAllSrcPathConfig(); TopName = "Boolean"; - Top = getModuleLocation(TopName, pcfg); + Top = getRascalModuleLocation(TopName, pcfg); //assert changeAndCheck(Top, [TopName, "Exception"], pcfg, injectedError="int X = false;"); changeModules([TopName], pcfg, injectedError="int X = false;"); assert unexpectedDeclarationInModule(Top); @@ -500,7 +500,7 @@ test bool onlyChangedModulesAreReChecked1(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); TopName = "analysis::grammars::Ambiguity"; - Top = getModuleLocation(TopName, pcfg); + Top = getRascalModuleLocation(TopName, pcfg); assert checkModuleOK(Top, pathConfig = pcfg); assert validateBOMs(pcfg); @@ -529,7 +529,7 @@ test bool onlyChangedModulesAreReChecked1(){ test bool onlyChangedModulesAreReChecked2(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); - Top = getModuleLocation("lang::rascalcore::check::Checker", pcfg); + Top = getRascalModuleLocation("lang::rascalcore::check::Checker", pcfg); assert checkModuleOK(Top, pathConfig = pcfg); assert validateBOMs(pcfg); @@ -564,7 +564,7 @@ void touchOne(){ pcfg = getRascalPathConfig(); remove(pcfg.resources, recursive=true); TopName = "ParseTree"; - Top = getModuleLocation("ParseTree", pcfg); + Top = getRascalModuleLocation("ParseTree", pcfg); cases = [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }> // <", touched", void(){ touchAndCheck(Top, [TopName], pcfg); }> @@ -576,7 +576,7 @@ void miniBenchmarkRechecking(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); TopName = "ParseTree"; - Top = getModuleLocation("ParseTree", pcfg); + Top = getRascalModuleLocation("ParseTree", pcfg); cases = [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, @@ -593,7 +593,7 @@ void mediumBenchmarkRechecking(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); TopName = "analysis::grammars::Ambiguity"; - Top = getModuleLocation(TopName, pcfg); + Top = getRascalModuleLocation(TopName, pcfg); cases = [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, @@ -612,7 +612,7 @@ void largeBenchmarkRechecking(){ pcfg = getAllSrcPathConfig(); remove(pcfg.resources, recursive=true); TopName = "lang::rascalcore::check::Checker"; - Top = getModuleLocation(TopName, pcfg); + Top = getRascalModuleLocation(TopName, pcfg); cases = [<", first", void(){ checkModuleOK(Top, pathConfig = pcfg); }>, diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Compile.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Compile.rsc index b5f53e99..401d51ca 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Compile.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Compile.rsc @@ -107,7 +107,7 @@ list[Message] compile(loc moduleLoc, RascalCompilerConfig compilerConfig) { } moduleName = "**unknown**"; try { - moduleName = getModuleName(moduleLoc, pcfg); + moduleName = getRascalModuleName(moduleLoc, pcfg); } catch str e: { return [ error("Cannot find name for location, reason: ", moduleLoc) ]; } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc index 1ec86b60..dcdec4bd 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst0.rsc @@ -1,9 +1,9 @@ module lang::rascalcore::compile::Examples::Tst0 -import util::Reflective; +import Reflect; int XX1 = 14 ; int XXX = 13; -int main() = XX1; \ No newline at end of file +int main() = XX; \ No newline at end of file diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/ModuleInfo.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/ModuleInfo.rsc index 037c48d2..93212f5b 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/ModuleInfo.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/ModuleInfo.rsc @@ -30,9 +30,9 @@ public void setModuleName(str name){ module_name = name; } -public str getModuleName() = module_name; +public str getRascalModuleName() = module_name; -public str getModuleNameUnderscores() = replaceAll(module_name, "::", "_"); +public str getRascalModuleNameUnderscores() = replaceAll(module_name, "::", "_"); public void setModuleTags(map[str,str] mtags){ module_tags = mtags; diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc index 4fc27ab6..9b2dc510 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalDeclaration.rsc @@ -48,14 +48,14 @@ public void translateToplevel((Toplevel) ``) { // -- variable declaration ------------------------------------------ void translateDecl(d: (Declaration) ` <{Variable ","}+ variables> ;`) { - str module_name = asUnqualifiedName(getModuleName()); + str module_name = asUnqualifiedName(getRascalModuleName()); enterFunctionScope("_init"); for(var <- variables){ unescapedVarName = unescapeName(""); addVariableToModule(muModuleVar(getType(tp), unescapedVarName)); if(var is initialized) { init_code = translate(var.initial); - asg = muAssign( muVar(unescapedVarName, getModuleNameUnderscores(), -1, filterOverloads(getType(tp), {variableId()}), variableId()), init_code); + asg = muAssign( muVar(unescapedVarName, getRascalModuleNameUnderscores(), -1, filterOverloads(getType(tp), {variableId()}), variableId()), init_code); addVariableInitializationToModule(asg); } } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc index 82a3b4fc..e77d2df1 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Rascal2muRascal/RascalModule.rsc @@ -52,7 +52,7 @@ tuple[TModel, MuModule] r2mu(lang::rascal::\syntax::Rascal::Module M, TModel tmo if(ignoreTest(mtags)){ e = info("Ignore tag suppressed compilation", M@\loc); tmodel.messages += [e]; - return ; + return ; } //if(verbose) println("r2mu: entering ... , enableAsserts: "); @@ -95,14 +95,14 @@ tuple[TModel, MuModule] r2mu(lang::rascal::\syntax::Rascal::Module M, TModel tmo if (compilerConfig.verbose) { println("Parse error in concrete syntax ; returning error module"); } msg = error("Parse error in concrete syntax fragment", l); tmodel.messages += [msg]; - return ; + return ; } catch CompileTimeError(Message m): { tmodel.messages += [m]; - return ; + return ; } //catch value e: { - // return ", M@\loc)}, M@\loc)>; + // return ", M@\loc)}, M@\loc)>; //} finally { resetModuleInfo(compilerConfig);