Skip to content

Commit

Permalink
Merge pull request #27 from usethesource/chore/update-latest-rascal-r…
Browse files Browse the repository at this point in the history
…elease

Moved to the latest rascal and rascal-plugin release
  • Loading branch information
jurgenvinju authored Oct 17, 2024
2 parents 9bc4f10 + a8f8ee6 commit c4c71be
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<plugin>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal-maven-plugin</artifactId>
<version>0.26.3-BOOT1</version>
<version>0.28.5</version>
<configuration>
<errorsAsWarnings>true</errorsAsWarnings>
<errorsAsWarnings>false</errorsAsWarnings>
<bin>${project.build.outputDirectory}</bin>
<srcs>
<src>${project.basedir}/src</src>
Expand Down Expand Up @@ -160,7 +160,7 @@
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal</artifactId>
<version>0.34.0</version>
<version>0.40.11</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
Expand Down
6 changes: 3 additions & 3 deletions src/lang/flybytes/Decompiler.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Method decompile(Method m:static([asm(list[Instruction] instrs)]), bool cleanup=
return cleanup? m[block=done] : m[block=[asm(withStat)]];
}

Method decompile(Method m) = m when \abstract in m.modifiers;
default Method decompile(Method m, bool cleanup=true) = m when \abstract in m.modifiers;

// LINES:
data Instruction(int LINE = -1);
Expand Down Expand Up @@ -612,8 +612,8 @@ BinOp binOp("ALOAD") = aload;

alias UnOp = Exp (Exp);

UnOp invertedCond("NULL") = nonnull;
UnOp invertedCond("NONNULL") = null;
UnOp invertedUnaryCond("NULL") = nonnull;
UnOp invertedUnaryCond("NONNULL") = null;

Exp nonnull(Exp e) = ne(e, null());
Exp null(Exp e) = eq(e, null());
Expand Down
4 changes: 2 additions & 2 deletions src/lang/flybytes/demo/protol/Compiler.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ Stat compile((Command) `print <Expr e>;`) = stdout(compile(e));
Exp compile(e:(Expr) `this`) = load("this", src=e@\loc);

Exp compile((Expr) `<Expr rec>.<Id name>(<{Expr ","}* args>)`)
= invokeDynamic(bootstrap(Prototype, "bootstrap", []), methodDesc(Prototype, "<name>", [Prototype]/*receiver*/ + [Prototype | _ <- args] ), [compile(rec), *compile(args) ])[src=name@\loc];
= invokeDynamic(bootstrap(Prototype, "bootstrap", []), methodDesc(Prototype, "<name>", [Prototype]/*receiver*/ + [Prototype | _ <- args] ), [compile(rec), *compileList(args) ])[src=name@\loc];

list[Exp] compile({Expr ","}* args) = [compile(a)[src=a@\loc] | a <- args];
list[Exp] compileList({Expr ","}* args) = [compile(a)[src=a@\loc] | a <- args];

Exp compile(x:(Expr) `[<{Expr ","}* elems>]`)
= new(Arr, [array(Prototype)], [newInitArray(array(Prototype), [compile(e) | e <- elems])])[src=x@\loc];
Expand Down
2 changes: 1 addition & 1 deletion src/lang/flybytes/internal/ASTgen.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ str type2FactoryCall(Symbol t){
case \str() : return "IString";
case \datetime() : return "IDateTime";
case \tuple(_) : return "ITuple";
case \func(_, _): return "ICallableValue";
case \func(_, _, _): return "ICallableValue";
case \alias(_,_,a) : return typeToJavaType(a);
default : return "IValue";
}
Expand Down
36 changes: 18 additions & 18 deletions src/lang/flybytes/tests/ArithmeticTests.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Class unOpClass(Type t, UnOp op) {

bool testBinOp(Class c, Type t, num lhs, num rhs, num answer) {
m = loadClass(c);
reply = val(t, m.invokeStatic(methodDesc(t, "op", [t, t]), [prim(t, lhs), prim(t,rhs)]));
reply = intVal(t, m.invokeStatic(methodDesc(t, "op", [t, t]), [prim(t, lhs), prim(t,rhs)]));

if (answer != reply) {
println("op(<lhs>,<rhs>) == <round(t, answer)> != <round(t,reply)>");
Expand All @@ -50,7 +50,7 @@ bool testBinOp(Class c, Type t, num lhs, num rhs, num answer) {

bool testUnOp(Class c, Type t, num arg, num answer) {
m = loadClass(c);
reply = val(t, m.invokeStatic(methodDesc(t, "op", [t]), [prim(t, arg)]));
reply = intVal(t, m.invokeStatic(methodDesc(t, "op", [t]), [prim(t, arg)]));

if (answer != reply) {
println("op(<arg>) == <round(t, answer)> != <round(t,reply)>");
Expand All @@ -62,10 +62,10 @@ bool testUnOp(Class c, Type t, num arg, num answer) {

bool testBinOpRange(Class c, Type t, num lhs, num rhs, real answer) {
m = loadClass(c);
real reply = val(t, m.invokeStatic(methodDesc(t, "op", [t, t]), [prim(t, lhs), prim(t,rhs)]));
reply = realVal(t, m.invokeStatic(methodDesc(t, "op", [t, t]), [prim(t, lhs), prim(t,rhs)]));

if (abs(answer - reply) > 0.1) {
println("op(<lhs>,<rhs>) == <answer> != <reply> (diff: <abs(answer - reply)>)");
if (real r := reply, abs(answer - r) > 0.1) {
println("op(<lhs>,<rhs>) == <answer> != <reply> (diff: <abs(answer - r)>)");
return false;
}

Expand All @@ -74,7 +74,7 @@ bool testBinOpRange(Class c, Type t, num lhs, num rhs, real answer) {

bool testUnOpRange(Class c, Type t, num arg, real answer) {
m = loadClass(c);
real reply = val(t, m.invokeStatic(methodDesc(t, "op", [t]), [prim(t, arg)]));
real reply = realVal(t, m.invokeStatic(methodDesc(t, "op", [t]), [prim(t, arg)]));

if (abs(answer - reply) > 0.1) {
return false;
Expand All @@ -87,12 +87,12 @@ list[Type] exactArithmeticTypes = [integer(), short(), byte(), long()];

test bool testNeg1(int i)
= all(t <- exactArithmeticTypes,
I := i % maxValue(t), testUnOp(unOpClass(t, neg), t, I, -1 * I));
I := i % maxIntValue(t), testUnOp(unOpClass(t, neg), t, I, -1 * I));

test bool testAdd2(int i, int j)
= all (t <- exactArithmeticTypes,
I := (i % maxValue(t)) / 2,
J := (j % maxValue(t)) / 2,
I := (i % maxIntValue(t)) / 2,
J := (j % maxIntValue(t)) / 2,
testBinOp(binOpClass(t, add), t, I, J, I + J));

test bool testMul2(int i, int j)
Expand All @@ -103,20 +103,20 @@ test bool testMul2(int i, int j)

test bool testSub2(int i, int j)
= all (t <- exactArithmeticTypes,
I := (i % maxValue(t)) / 2,
J := ((j % maxValue(t)) / 2),
I := (i % maxIntValue(t)) / 2,
J := ((j % maxIntValue(t)) / 2),
testBinOp(binOpClass(t, sub), t, I, J, I - J));

test bool testDivInt(int i, int j)
= all (t <- exactArithmeticTypes,
I := (i % maxValue(t)),
J := abs(((j % maxValue(t)) / 2)) + 1, // never 0,
I := (i % maxIntValue(t)),
J := abs(((j % maxIntValue(t)) / 2)) + 1, // never 0,
testBinOp(binOpClass(t, div), t, I, J, I / J));

test bool testRem(int i, int j)
= all (t <- exactArithmeticTypes,
I := (i % maxValue(t)),
J := abs(((j % maxValue(t)) / 2)) + 1, // never 0,
I := (i % maxIntValue(t)),
J := abs(((j % maxIntValue(t)) / 2)) + 1, // never 0,
testBinOp(binOpClass(t, rem), t, I, J, I % J));
list[Type] floatingPointTypes = [float(), double()];
Expand Down Expand Up @@ -159,7 +159,7 @@ private real round(float(), real f) = precision(f, 0);
private real round(double(), real f) = precision(f, 0);
private default int round(Type _, int f) = f;
private real val(float(), Mirror r) = r.toValue(#real);
private real val(double(), Mirror r) = r.toValue(#real);
private default int val(Type _, Mirror r) = r.toValue(#int);
private real realVal(float(), Mirror r) = r.toValue(#real);
private real realVal(double(), Mirror r) = r.toValue(#real);
private int intVal(Type _, Mirror r) = r.toValue(#int);
24 changes: 12 additions & 12 deletions src/lang/flybytes/tests/BranchingTests.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -88,46 +88,46 @@ list[str] condTypes = ["ifThenTest", "ifThenElseTest"];

test bool testEqTrue(int i)
= all (t <- intTypes,
I := prim(t, abs(i) % maxValue(t)), cl <- condTypes,
I := prim(t, abs(i) % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, eq), t, cl, I, I, true));

test bool testEqFalse(int i)
= all (t <- intTypes,
I := abs(i) % maxValue(t), cl <- condTypes,
I := abs(i) % maxIntValue(t), cl <- condTypes,
testIf(ifCmpClass(t, eq), t, cl, prim(t, I), prim(t, I - 1), false));

test bool testNEqTrue(int i)
= all (t <- intTypes,
I := abs(i) % maxValue(t), cl <- condTypes,
I := abs(i) % maxIntValue(t), cl <- condTypes,
testIf(ifCmpClass(t, ne), t, cl, prim(t, I), prim(t, I - 1), true));

test bool testNEqFalse(int i)
= all (t <- intTypes,
I := prim(t, abs(i) % maxValue(t)), cl <- condTypes,
I := prim(t, abs(i) % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, ne), t, cl, I, I, false));

test bool testLt(int i, int j)
= all (t <- intTypes,
I := (i % maxValue(t)),
J := (j % maxValue(t)), cl <- condTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, lt), t, cl, prim(t, I), prim(t, J), I < J));

test bool testGt(int i, int j)
= all (t <- intTypes,
I := (i % maxValue(t)),
J := (j % maxValue(t)), cl <- condTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, gt), t, cl, prim(t, I), prim(t, J), I > J));

test bool testGe(int i, int j)
= all (t <- intTypes,
I := (i % maxValue(t)),
J := (j % maxValue(t)), cl <- condTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, ge), t, cl, prim(t, I), prim(t, J), I >= J));

test bool testLe(int i, int j)
= all (t <- intTypes,
I := (i % maxValue(t)),
J := (j % maxValue(t)), cl <- condTypes,
I := (i % maxIntValue(t)),
J := (j % maxIntValue(t)), cl <- condTypes,
testIf(ifCmpClass(t, le), t, cl, prim(t, I), prim(t, J), I <= J));


2 changes: 1 addition & 1 deletion src/lang/flybytes/tests/VariableTests.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool testVarClass(Class c) {
list[Type] intTypes = [integer(), long(), short(), character(), byte()];

test bool intVariables(int i)
= all(t <- intTypes, I := i % maxValue(t), testVarClass(primVarTestClass(t, I)));
= all(t <- intTypes, I := i % maxIntValue(t), testVarClass(primVarTestClass(t, I)));

list[Type] floatTypes = [float(), double()];

Expand Down

0 comments on commit c4c71be

Please sign in to comment.