Skip to content

Commit

Permalink
fixed real static errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Jun 17, 2024
1 parent 5630fb6 commit bc857c8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
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
32 changes: 16 additions & 16 deletions src/lang/flybytes/tests/ArithmeticTests.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -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 = val(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 @@ -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,
= all (t <- exactArithmeticTypes
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 num val(float(), Mirror r) = r.toValue(#real);
private num val(double(), Mirror r) = r.toValue(#real);
private default num val(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 bc857c8

Please sign in to comment.