Skip to content
Snippets Groups Projects
Commit 58343a96 authored by Nicolas Voirol's avatar Nicolas Voirol
Browse files

Partial fix for extern evaluation in CodeGen

parent 63376f70
No related branches found
No related tags found
No related merge requests found
...@@ -682,6 +682,11 @@ trait CodeGeneration { ...@@ -682,6 +682,11 @@ trait CodeGeneration {
load(monitorID, ch) load(monitorID, ch)
ch << Ldc(id) ch << Ldc(id)
if (tfd.fd.tparams.nonEmpty) {
loadTypes(tfd.tps, ch)
} else {
ch << Ldc(0) << NewArray.primitive("T_INT")
}
ch << Ldc(as.size) ch << Ldc(as.size)
ch << NewArray(ObjectClass) ch << NewArray(ObjectClass)
......
...@@ -369,28 +369,11 @@ class EvaluatorSuite extends LeonTestSuiteWithProgram with ExpressionsDSL { ...@@ -369,28 +369,11 @@ class EvaluatorSuite extends LeonTestSuiteWithProgram with ExpressionsDSL {
} }
test("Lambda functions") { implicit fix => test("Lambda functions") { implicit fix =>
def checkLambda(e: Evaluator, in: Expr, out: PartialFunction[Expr, Boolean]) {
val res = eval(e, in).success
if (!out.isDefinedAt(res) || !out(res))
throw new AssertionError(s"Evaluation of '$in' with evaluator '${e.name}' produced invalid '$res'.")
}
val ONE = bi(1)
val TWO = bi(2)
for(e <- allEvaluators) { for(e <- allEvaluators) {
checkLambda(e, fcall("Lambda.foo1")(), { eval(e, Application(fcall("Lambda.foo1")(), Seq(bi(1)))) === bi(1)
case Lambda(Seq(vd), Variable(id)) if vd.id == id => true eval(e, Application(fcall("Lambda.foo2")(), Seq(bi(1)))) === bi(2)
}) eval(e, Application(fcall("Lambda.foo3")(), Seq(bi(1), bi(2)))) === bi(6)
checkLambda(e, fcall("Lambda.foo2")(), { eval(e, Application(fcall("Lambda.foo4")(bi(2)), Seq(bi(1)))) === bi(3)
case Lambda(Seq(vd), Plus(ONE, Variable(id))) if vd.id == id => true
})
checkLambda(e, fcall("Lambda.foo3")(), {
case Lambda(Seq(vx, vy), Plus(Plus(Variable(x), ONE), Plus(Variable(y), TWO))) if vx.id == x && vy.id == y => true
})
checkLambda(e, fcall("Lambda.foo4")(TWO), {
case Lambda(Seq(vd), Plus(Variable(id), TWO)) if vd.id == id => true
})
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment