From d94e8ba2a962ea04c6631315d41ccaf512036487 Mon Sep 17 00:00:00 2001 From: paulklint Date: Wed, 13 Mar 2024 12:48:10 +0100 Subject: [PATCH] Fixed issues with missing messages - messages are sorted by line number - new compiler option: logPathConfig --- .settings/org.eclipse.core.resources.prefs | 2 -- .../core/library/CheckTestSources.rsc | 8 +++++--- .../core/library/CompileTestSources.rsc | 6 ++++-- .../core/library/GenerateTestSources.rsc | 7 +++++-- .../rascalcore/check/BasicRascalConfig.rsc | 3 ++- .../library/lang/rascalcore/check/Checker.rsc | 10 ++++++++-- .../library/lang/rascalcore/check/Import.rsc | 3 ++- .../lang/rascalcore/check/RascalConfig.rsc | 6 ++++-- .../lang/rascalcore/compile/Compile.rsc | 6 ++---- .../lang/rascalcore/compile/Examples/Tst5.rsc | 18 ++++++++++++------ 10 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 4e8aa177..7ec1b20e 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,7 +1,5 @@ eclipse.preferences.version=1 encoding//src/org/rascalmpl/core/library=UTF-8 -encoding//target/generated-test-resources=UTF-8 -encoding//target/generated-test-sources=UTF-8 encoding/=UTF-8 encoding/src=UTF-8 encoding/test=UTF-8 diff --git a/src/org/rascalmpl/core/library/CheckTestSources.rsc b/src/org/rascalmpl/core/library/CheckTestSources.rsc index 6fceae35..55fb71e7 100644 --- a/src/org/rascalmpl/core/library/CheckTestSources.rsc +++ b/src/org/rascalmpl/core/library/CheckTestSources.rsc @@ -29,7 +29,7 @@ void checkTestSources(PathConfig pcfg) { println("PathConfig for type checking test sources:\n"); iprintln(testConfig); - testCompilerConfig = rascalCompilerConfig(testConfig); + testCompilerConfig = rascalCompilerConfig(testConfig)[logPathConfig=false]; total = 0; println(readFile(|lib://rascal/META-INF/MANIFEST.MF|)); @@ -119,8 +119,10 @@ tuple[str, int] safeCompile(str \module, RascalCompilerConfig compilerConfig) { ModuleStatus result = rascalTModelForNames([\module], compilerConfig, dummy_compile1); - iprintln(result.tmodels[\module].messages); - return <"", cpuTime()-start_time>; + if(!isEmpty(result.tmodels[\module].messages)){ + iprintln(result.tmodels[\module].messages); + } + return <"", cpuTime()-start_time>; } catch value exception: { println("Something unexpected went wrong during test source generation for <\module>: diff --git a/src/org/rascalmpl/core/library/CompileTestSources.rsc b/src/org/rascalmpl/core/library/CompileTestSources.rsc index 706cd1f4..70e26818 100644 --- a/src/org/rascalmpl/core/library/CompileTestSources.rsc +++ b/src/org/rascalmpl/core/library/CompileTestSources.rsc @@ -13,7 +13,6 @@ import Map; import util::Reflective; import lang::rascalcore::compile::Compile; import util::FileSystem; -import util::Monitor; import util::Benchmark; import lang::rascalcore::compile::util::Names; @@ -161,7 +160,10 @@ void compileTestSources(PathConfig pcfg) { tuple[str, int] safeCompile(str \module, RascalCompilerConfig compilerConfig) { start_time = cpuTime(); try { - compile(\module, compilerConfig); + msgs = compile(\module, compilerConfig); + if(!isEmpty(msgs)){ + iprintln(msgs); + } return <"",cpuTime()-start_time>; } catch value exception: { diff --git a/src/org/rascalmpl/core/library/GenerateTestSources.rsc b/src/org/rascalmpl/core/library/GenerateTestSources.rsc index 38113a36..05d4d87e 100644 --- a/src/org/rascalmpl/core/library/GenerateTestSources.rsc +++ b/src/org/rascalmpl/core/library/GenerateTestSources.rsc @@ -27,7 +27,7 @@ void generateTestSources(PathConfig pcfg) { libs = [ ] ); - testCompilerConfig = getRascalCoreCompilerConfig(testConfig); + testCompilerConfig = getRascalCoreCompilerConfig(testConfig)[logPathConfig=false]; map[str,int] durations = (); @@ -156,7 +156,10 @@ void generateTestSources(PathConfig pcfg) { str safeCompile(str \module, RascalCompilerConfig compilerConfig, void (int duration) measure) { try { measure(cpuTimeOf(() { - compile(\module, compilerConfig); + msgs = compile(\module, compilerConfig); + if(!isEmpty(msgs)){ + iprintln(msgs); + } })); return ""; } diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/BasicRascalConfig.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/BasicRascalConfig.rsc index db8a08d6..011d50b7 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/BasicRascalConfig.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/BasicRascalConfig.rsc @@ -123,9 +123,10 @@ data TypePalConfig( loc reloc = |noreloc:///|, // Unused // Debugging options - bool verbose = true, // for each compiled module, print PathConfig, module name and compilation time + bool verbose = true, // for each compiled module, module name and compilation time bool logImports = false, // log all imported files bool logWrittenFiles = false, // log all files written by compiler + bool logPathConfig = true, // log PathConfig that is used bool optimizeVisit = true, // Options for compiler developer bool enableAsserts = true, 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 1bcd3b63..1e61faa6 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc @@ -212,7 +212,7 @@ ModuleStatus rascalTModelForLocs( list[Message](str qualifiedModuleName, lang::rascal::\syntax::Rascal::Module M, ModuleStatus ms, RascalCompilerConfig compilerConfig) codgen ){ pcfg = compilerConfig.typepalPathConfig; - if(compilerConfig.verbose) { iprintln(pcfg); } + if(compilerConfig.logPathConfig) { iprintln(pcfg); } msgs = validatePathConfigForCompiler(pcfg, mlocs[0]); if(!isEmpty(msgs)){ @@ -354,7 +354,7 @@ ModuleStatus rascalTModelForLocs( = getModuleParseTree(m, ms); if(success){ msgs = codgen(m, pt, ms, compilerConfig); - ms.messages[m] = msgs; + ms.messages[m] += msgs; ms.status[m] += {code_generated()}; } //else { @@ -427,6 +427,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt jobStep("RascalCompiler", "Checking "); // TODO: monitor if(compilerConfig.verbose) { println("Checking ... "); } + start_check = cpuTime(); c = newCollector(modelName, namedTrees, compilerConfig); c.push(key_pathconfig, pcfg); @@ -448,6 +449,11 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt s = newSolver(namedTrees, tm); tm = s.run(); + check_time = (cpuTime() - start_check)/1000000; + + jobStep("RascalCompiler", "Checked in ms");// TODO: monitor + if(compilerConfig.verbose) { println("Checked .... in ms"); } + return ; } 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 5153ac02..51f17494 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/Import.rsc @@ -501,7 +501,8 @@ ModuleStatus doSaveModule(set[str] component, map[str,set[str]] m_imports, map[s m1.specializedFacts = (key : tm.specializedFacts[key] | key <- tm.specializedFacts, isContainedInComponentScopes(key), any(fms <- filteredModuleScopes, isContainedIn(key, fms))); m1.facts += m1.specializedFacts; - m1.messages = [msg | msg <- tm.messages, msg.at.file == mscope.file]; + m1.messages = sort(toList({msg | msg <- tm.messages, msg.at.file == mscope.file}), bool(Message a, Message b){ return a.at.begin.line < b.at.begin.line; }); + ms.messages[qualifiedModuleName] = m1.messages; filteredModuleScopePaths = {ml.path |loc ml <- filteredModuleScopes}; 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 2d0edf0b..6d96de62 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/RascalConfig.rsc @@ -431,9 +431,10 @@ RascalCompilerConfig rascalCompilerConfig(PathConfig pcfg, bool warnDeprecated = false, // Debugging - bool verbose = true, // for each compiled module, print PathConfig, module name and compilation time + bool verbose = true, // for each compiled module, log module name and compilation time bool logImports = false, - bool logWrittenFiles = false, // print location of written files: .constants, .tpl, *.java + bool logWrittenFiles = false, // log location of written files: .constants, .tpl, *.java + bool logPathConfig = true, // log PathConfig that is used loc reloc = |noreloc:///|, // Currently unused @@ -453,6 +454,7 @@ RascalCompilerConfig rascalCompilerConfig(PathConfig pcfg, verbose = verbose, logImports = logImports, logWrittenFiles = logWrittenFiles, + logPathConfig = logPathConfig, reloc = reloc, optimizeVisit = optimizeVisit, 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 df63fab7..718e9021 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Compile.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Compile.rsc @@ -1,9 +1,7 @@ @bootstrapParser module lang::rascalcore::compile::Compile -import Exception; import Message; -import Map; import String; import util::Reflective; import util::Benchmark; @@ -124,8 +122,8 @@ list[Message] compile(str qualifiedModuleName, RascalCompilerConfig compilerConf comp_time = (cpuTime() - start_comp)/1000000; - jobStep("RascalCompiler", "Compiled in ms");// TODO: monitor - if(compilerConfig.verbose) { println("Compiled ... in ms"); } + jobStep("RascalCompiler", "Compiled in ms [total]");// TODO: monitor + if(compilerConfig.verbose) { println("Compiled ... in ms [total]"); } jobEnd("RascalCompiler");// TODO: monitor return ms.messages[qualifiedModuleName] ? []; diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst5.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst5.rsc index e2d15de0..c4c05e09 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst5.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst5.rsc @@ -1,13 +1,19 @@ module lang::rascalcore::compile::Examples::Tst5 - -import List; - -value main(){ - myList = [<1,2>,<2,2>]; - return sort(myList, bool (, ) { return i < j; }); +//public rel[str s, int n] filterRelWorking(rel[str s, int n] inRel, set[str] relFilter) { +// return { < s, n > | < s, n > <- inRel, s in relFilter }; +//} +public rel[str s, int n] filterRelBroken(rel[str s, int n] inRel, set[str] relFilter) { + return { t | t:< s, n > <- inRel }; } +//import List; +// +//value main(){ +// myList = [<1,2>,<2,2>]; +// return sort(myList, bool (, ) { return i < j; }); +//} + //value main(){ // if([1, int x] !:= [1]) return x; // return -1;