Skip to content

Commit

Permalink
Some further streamlining
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Mar 10, 2024
1 parent 99553dd commit 53b0ffa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
14 changes: 7 additions & 7 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ModuleStatus rascalTModelForLocs(
ms = getImportAndExtendGraph(topModuleNames, pcfg);

if(forceCompilationTopModule){
for(nm <- topModuleNames){
for(str nm <- topModuleNames){
ms.status[nm] = {};
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ ModuleStatus rascalTModelForLocs(
}
tm.messages += msgs;
} else {
tm.messages += error("Cannot get parse tree for module `<m>`", ms.moduleLocs[m]);
tm.messages += [ error("Cannot get parse tree for module `<m>`", ms.moduleLocs[m]) ];
}
}
if(ms.messages[m]?){
Expand All @@ -333,18 +333,18 @@ ModuleStatus rascalTModelForLocs(
ms.messages[m] = msgs;
ms.status[m] += {code_generated()};
} else {
ms.messages[m] += error("Cannot get parse tree for module `<m>`", ms.moduleLocs[m]);
ms.messages[m] += [ error("Cannot get parse tree for module `<m>`", ms.moduleLocs[m]) ];
}
}
ms = doSaveModule(component, m_imports, m_extends, ms, moduleScopes, compilerConfig);
}
}
} catch ParseError(loc src): {
for(mname <- topModuleNames){
for(str mname <- topModuleNames){
ms.messages[mname] = [ error("Parse error", src) ];
}
} catch Message msg: {
for(mname <- topModuleNames){
for(str mname <- topModuleNames){
ms.messages[mname] = [error("During type checking: <msg>", msg.at)];
}
}
Expand Down Expand Up @@ -389,7 +389,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
pcfg = ms.pathConfig;
modelName = intercalate(" + ", toList(moduleNames));
map[str, Module] namedTrees = ();
for(nm <- moduleNames){
for(str nm <- moduleNames){
<success, pt, ms> = getModuleParseTree(nm, ms);
if(success){
namedTrees[nm] = pt;
Expand All @@ -407,7 +407,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
rascalPreCollectInitialization(namedTrees, c);

added = {};
for(nm <- moduleNames){
for(str nm <- moduleNames){
<a, ms> = loadImportsAndExtends(nm, ms, c, added);
added += a;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import lang::rascalcore::check::Checker;
import analysis::typepal::TypePal;
import analysis::typepal::TestFramework;

import IO;

start syntax Modules
= Module+ modules;

Expand All @@ -19,11 +21,14 @@ TModel rascalTModelForTestModules(Tree pt, bool debug=false){
config = config[logImports = true];
}
if(start[Modules] mds := pt){
return rascalTModelComponent( {unescape("<md.header.name>") | md <- mds.top.modules }, ms, config)[1];
} else if(Modules mds := pt){
return rascalTModelComponent( {unescape("<md.header.name>") | md <- mds.modules }, ms, config)[1];
<tm, ms> = rascalTModelComponent( { unescape("<md.header.name>") | md <- mds.top.modules }, ms, config);
return tm;
} else
if(Modules mds := pt){
<tm, ms> = rascalTModelComponent( { unescape("<md.header.name>") | md <- mds.modules }, ms, config);
return tm;
} else
throw "Cannot handle Modules";
throw "Cannot handle Module";
}

void testModules(str names...) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ tuple[bool, Module, ModuleStatus] getModuleParseTree(str qualifiedModuleName, Mo
if(traceCaches) println("*** using cached parse tree for <qualifiedModuleName>");
return <true, ms.parseTrees[qualifiedModuleName], ms>;
} else {
if(!ms.status[qualifiedModuleName]?){
ms.status[qualifiedModuleName] = {};
}
if(parse_error() notin ms.status[qualifiedModuleName]){
if(size(ms.parseTreeLIFO) >= parseTreeCacheSize){
ms.parseTrees = delete(ms.parseTrees, ms.parseTreeLIFO[-1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ bool errorsPresent(TModel tmodel) = !isEmpty([ e | e:error(_,_) <- tmodel.messag
bool errorsPresent(list[Message] msgs) = !isEmpty([ e | e:error(_,_) <- msgs ]);

data ModuleStatus;

list[Message] compile1(str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, ModuleStatus ms, CompilerConfig compilerConfig){
pcfg = ms.pathConfig;
<found, tm, ms> = getTModelForModule(qualifiedModuleName, ms);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
module lang::rascalcore::compile::Examples::Tst5


import lang::rascalcore::check::tests::StaticTestingUtils;

value main() {
makeModule("RT", "import List;
'int f(list[int] L) {
' return size(L);
'}
'");
return checkOK("f([1,2,3]);", importedModules=["RT"]);
void main() {
map[str key, int key] x;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,11 @@ default JCode transMuSetField(AType resultType, AType baseType, MuExp baseExp, s
JCode trans(muPrim(str name, AType result, list[AType] details, list[MuExp] exps, loc src), JGenie jg){
//details = [ overloadedAType(rel[loc, IdRole, AType] overloads) := d ? lubList(toList(overloads<2>)) : d | d <- details];
actuals = transPrimArgs(name, result, details, exps, jg);
return transPrim(name, result, details, actuals, jg);
try {
return transPrim(name, result, details, actuals, jg);
} catch e: {
throw "muPrim fails for <src>: <e>";
}
}
JCode trans(muCallJava(str name, str class, AType funType, list[MuExp] largs, str enclosingFun), JGenie jg){
Expand Down

0 comments on commit 53b0ffa

Please sign in to comment.