Skip to content

Commit

Permalink
Typechecked and compilable version of typechecker and compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed May 12, 2024
1 parent 869c5a9 commit 0698c1b
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
Expand Down
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
4 changes: 3 additions & 1 deletion .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations
2 changes: 1 addition & 1 deletion .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
4 changes: 2 additions & 2 deletions src/org/rascalmpl/core/library/CompileTestSources.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import util::Benchmark;
import lang::rascalcore::compile::util::Names;

PathConfig manualTestConfig= pathConfig(bin=|project://rascal-core/target/test-classes|,
generatedSources = |project://rascal-core/target/generated-test-sources|,
resources = |project://rascal-core/target/generated-test-resources|
generatedSources = |project://rascal-core/target/generated-test-sources2|,
resources = |project://rascal-core/target/generated-test-resources2|
);

void main() = compileTestSources(manualTestConfig);
Expand Down
10 changes: 5 additions & 5 deletions src/org/rascalmpl/core/library/lang/rascalcore/check/AType.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ AType alub(p:aparameter(n1, b1,closed=true), aparameter(n2, b2, closed=true)) =
: lb == b1 ? p : lb when lb := alub(b1, b2);

AType alub(p1:aparameter(n1, b1,closed=false), p2:aparameter(n2, b2,closed=true)) = n1 == n2 && lb == b1 ? p1 : lb when lb := alub(b1, p2);
AType alub(p1:aparameter(n1, b1, closed=true), aparameter(n2, b2, closed=false)) = n1 == n2 && lb == b2 ? p2 : lb when lb := alub(p1, b2);
AType alub(p1:aparameter(n1, b1, closed=true), p2:aparameter(n2, b2, closed=false)) = n1 == n2 && lb == b2 ? p2 : lb when lb := alub(p1, b2);

AType alub(p:aparameter(n, b, closed=false), AType r) = lb == b ? p : lb when !(r is aparameter), lb := alub(b, r);
AType alub(AType l, p:aparameter(n, b,closed=false)) = lb == b ? p : lb when !(l is aparameter), lb := alub(l, b);
Expand All @@ -619,10 +619,10 @@ AType alub(\iter-star(AType l), \iter-star(AType r)) = aadt("Tree", [], dataSynt
AType alub(\iter-star(AType l), \iter(AType r)) = aadt("Tree", [], dataSyntax());

AType alub(\iter-seps(_, _), \iter-seps(_,_)) = aadt("Tree", [], dataSyntax());
AType alub(\iter-seps(_,_), \iter-star-seps(AType r)) = aadt("Tree", [], dataSyntax());
AType alub(\iter-seps(_,_), \iter-star-seps(AType r,_)) = aadt("Tree", [], dataSyntax());

AType alub(\iter-star-seps(AType l), \iter-star-seps(AType r)) = aadt("Tree", [], dataSyntax());
AType alub(\iter-star-seps(AType l), \iter-seps(AType r)) = aadt("Tree", [], dataSyntax());
AType alub(\iter-star-seps(AType l, _), \iter-star-seps(AType r, _)) = aadt("Tree", [], dataSyntax());
AType alub(\iter-star-seps(AType l, _), \iter-seps(AType r, _)) = aadt("Tree", [], dataSyntax());

AType alub(l:aadt("Tree", _, _), AType r) = l
when r is \achar-class || r is seq || r is opt || r is alt || r is iter || r is \iter-star || r is \iter-seps || r is \iter-star-seps;
Expand Down Expand Up @@ -738,7 +738,7 @@ AType aglb(aparameter(n1, b1,closed=true), aparameter(n2, b2,closed=true)) = n1
: avoid();

AType aglb(p1:aparameter(n1, b1,closed=false), p2:aparameter(n2, b2,closed=true)) = n1 == n2 && b1 == gl ? p1 : gl when gl := aglb(b1, p2);
AType aglb(p1:aparameter(n1, b1,closed=true), aparameter(n2, b2,closed=false)) = n1 == n2 && b2 == gl ? p2 : gl when gl := aglb(p1, b2);
AType aglb(p1:aparameter(n1, b1,closed=true), p2:aparameter(n2, b2,closed=false)) = n1 == n2 && b2 == gl ? p2 : gl when gl := aglb(p1, b2);

AType aglb(p:aparameter(n, b,closed=false), AType r) = b == gl ? p : gl when !(r is aparameter), gl := aglb(b, r);
AType aglb(AType l, p:aparameter(n, b,closed=false)) = b == gl ? p : gl when !(l is aparameter), gl := aglb(l, b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ extend lang::rascalcore::check::Import;

extend lang::rascalcore::check::RascalConfig;

import lang::rascalcore::compile::CompileTimeError;
import analysis::typepal::Exception;

import IO;
import List;
import Map;
Expand Down Expand Up @@ -260,7 +263,7 @@ ModuleStatus rascalTModelForLocs(
ordered = reverse(sorted);
singletons = toList(topModuleNames - toSet(ordered));
ordered += singletons;
for(singleton <- singletons){
for(str singleton <- singletons){
module2component[singleton] = {singleton};
}
}
Expand Down Expand Up @@ -368,7 +371,7 @@ ModuleStatus rascalTModelForLocs(
}
} catch rascalSourceMissing(str txt):{
for(str mname <- topModuleNames){
ms.messages[mname] = [error("<msg>", ms.moduleLocs[mname] ? |unknown:///|)];
ms.messages[mname] = [error("<txt>", ms.moduleLocs[mname] ? |unknown:///|)];
}
} catch Message msg: {
for(str mname <- topModuleNames){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,15 +969,11 @@ void collect(current: (QualifiedName) `<QualifiedName name>`, Collector c){
c.useQualified([qualifier, base], name, {variableId(), moduleVariableId(), functionId(), constructorId()}, dataOrSyntaxRoles + {moduleId()} );
} else {
if(!isWildCard(base)){
//if(inPatternScope(c)){
if(!isEmpty(c.getStack(currentAdt))){
c.use(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), keywordFormalId(), fieldId(), keywordFieldId(), functionId(), constructorId()});
} else {
c.useLub(name, {variableId(), moduleVariableId(), formalId(), nestedFormalId(), patternVariableId(), keywordFormalId(), fieldId(), keywordFieldId(), functionId(), constructorId()});
}
//} else {
// c.useLub(name, {variableId(), formalId(), nestedFormalId(), patternVariableId(), keywordFormalId(), fieldId(), keywordFieldId(), functionId(), constructorId()});
//}
} else {
c.fact(current, avalue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import analysis::graphs::Graph;
import util::Reflective;
import lang::rascalcore::compile::util::Names; // TODO: refactor, this is an undesired dependency on compile

bool traceTPL = true;
bool traceTPL = false;
bool traceCaches = false;

tuple[bool,loc] getTPLReadLoc(str qualifiedModuleName, PathConfig pcfg){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import lang::rascalcore::compile::Compile;

value main() {
pcfg = getRascalCorePathConfig();
input ="lang::rascalcore::check::Checker";
testConfig = pathConfig(
bin=|project://rascal-core/target|,
generatedSources=|project://rascal-core/target/generated-test-sources2|,
Expand All @@ -16,6 +17,6 @@ value main() {
|project://typepal/src|],
libs = [|lib:///| ]
);
msgs = compile("lang::rascalcore::compile::Examples::Tst0", getRascalCorePathConfig(), getRascalCompilerConfig());
msgs = compile(input, getRascalCoreCompilerConfig());
return msgs;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module lang::rascalcore::compile::Examples::Tst6

import lang::rascalcore::compile::Examples::Tst5;

value main() = inc(43);
value main() = 1;

0 comments on commit 0698c1b

Please sign in to comment.