Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved to the latest rascal and rascal-plugin release #27

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
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.1</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.7</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
2 changes: 1 addition & 1 deletion src/lang/flybytes/Syntax.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ Method staticMethod(Type ret, str name, list[Formal] args, list[Stat] block)
@synopsis{Short-hand for generating a constructor.}
@pitfalls{Don't forgot to generate a super call.}
Method constructor(Modifier access, list[Formal] formals, list[Stat] block)
= method(constructorDesc([ var.\type | var <- formals]), formals, block, modifiers={access});
= method(constructorDesc([ var.\type | Formal var <- formals]), formals, block, modifiers={access});

@synopsis{"new" short-hand with parameters}
Exp new(Type class, list[Type] argTypes, list[Exp] args)
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
Loading