Skip to content

Commit

Permalink
Fixed issues with missing messages
Browse files Browse the repository at this point in the history
- messages are sorted by line number
- new compiler option: logPathConfig
  • Loading branch information
PaulKlint committed Mar 13, 2024
1 parent 0bc0aab commit d94e8ba
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -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/<project>=UTF-8
encoding/src=UTF-8
encoding/test=UTF-8
8 changes: 5 additions & 3 deletions src/org/rascalmpl/core/library/CheckTestSources.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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|));
Expand Down Expand Up @@ -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>:
Expand Down
6 changes: 4 additions & 2 deletions src/org/rascalmpl/core/library/CompileTestSources.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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: {
Expand Down
7 changes: 5 additions & 2 deletions src/org/rascalmpl/core/library/GenerateTestSources.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void generateTestSources(PathConfig pcfg) {
libs = [ ]
);

testCompilerConfig = getRascalCoreCompilerConfig(testConfig);
testCompilerConfig = getRascalCoreCompilerConfig(testConfig)[logPathConfig=false];

map[str,int] durations = ();

Expand Down Expand Up @@ -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 "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/Checker.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down Expand Up @@ -354,7 +354,7 @@ ModuleStatus rascalTModelForLocs(
<success, pt, ms> = 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 {
Expand Down Expand Up @@ -427,6 +427,7 @@ tuple[TModel, ModuleStatus] rascalTModelComponent(set[str] moduleNames, ModuleSt
jobStep("RascalCompiler", "Checking <modelName>"); // TODO: monitor
if(compilerConfig.verbose) { println("Checking ... <modelName>"); }

start_check = cpuTime();
c = newCollector(modelName, namedTrees, compilerConfig);
c.push(key_pathconfig, pcfg);

Expand All @@ -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 <modelName> in <check_time> ms");// TODO: monitor
if(compilerConfig.verbose) { println("Checked .... <modelName> in <check_time> ms"); }
return <tm, ms>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -453,6 +454,7 @@ RascalCompilerConfig rascalCompilerConfig(PathConfig pcfg,
verbose = verbose,
logImports = logImports,
logWrittenFiles = logWrittenFiles,
logPathConfig = logPathConfig,

reloc = reloc,
optimizeVisit = optimizeVisit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
@bootstrapParser
module lang::rascalcore::compile::Compile

import Exception;
import Message;
import Map;
import String;
import util::Reflective;
import util::Benchmark;
Expand Down Expand Up @@ -124,8 +122,8 @@ list[Message] compile(str qualifiedModuleName, RascalCompilerConfig compilerConf

comp_time = (cpuTime() - start_comp)/1000000;
jobStep("RascalCompiler", "Compiled <qualifiedModuleName> in <comp_time> ms");// TODO: monitor
if(compilerConfig.verbose) { println("Compiled ... <qualifiedModuleName> in <comp_time> ms"); }
jobStep("RascalCompiler", "Compiled <qualifiedModuleName> in <comp_time> ms [total]");// TODO: monitor
if(compilerConfig.verbose) { println("Compiled ... <qualifiedModuleName> in <comp_time> ms [total]"); }
jobEnd("RascalCompiler");// TODO: monitor
return ms.messages[qualifiedModuleName] ? [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
module lang::rascalcore::compile::Examples::Tst5


import List;

value main(){
myList = [<1,2>,<2,2>];
return sort(myList, bool (<int i, _>, <int j, _>) { 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 (<int i, _>, <int j, _>) { return i < j; });
//}

//value main(){
// if([1, int x] !:= [1]) return x;
// return -1;
Expand Down

0 comments on commit d94e8ba

Please sign in to comment.