Skip to content
Snippets Groups Projects
Commit 9f530f53 authored by Etienne Kneuss's avatar Etienne Kneuss Committed by Philippe Suter
Browse files

Renamings

parent 27600072
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,11 @@ class CompilationUnit(val program: Program, val classes: Map[Definition, ClassFi
_nextExprId
}
private[codegen] def groundExprToJava(e: Expr): Any = {
compileExpression(e, Seq()).evalToJava(Seq())
private[codegen] def valueToJVM(e: Expr): Any = {
compileExpression(e, Seq()).evalToJVM(Seq())
}
private[codegen] def javaToGroundExpr(e: AnyRef): Expr = e match {
private[codegen] def jvmToValue(e: AnyRef): Expr = e match {
case i: Integer =>
IntLiteral(i.toInt)
......@@ -49,14 +49,14 @@ class CompilationUnit(val program: Program, val classes: Map[Definition, ClassFi
jvmClassToDef.get(e.getClass.getName) match {
case Some(cc: CaseClassDef) =>
CaseClass(cc, fields.map(javaToGroundExpr))
CaseClass(cc, fields.map(jvmToValue))
case _ =>
throw CompilationException("Unsupported return value : " + e)
}
case tpl: runtime.Tuple =>
val elems = for (i <- 0 until tpl.getArity) yield {
javaToGroundExpr(tpl.get(i))
jvmToValue(tpl.get(i))
}
Tuple(elems)
......
......@@ -14,7 +14,7 @@ import cafebabe.Flags._
class CompiledExpression(unit: CompilationUnit, cf: ClassFile, argsDecl: Seq[Identifier]) {
def evalToJava(args: Seq[Expr]): AnyRef = {
def evalToJVM(args: Seq[Expr]): AnyRef = {
val cl = unit.loader.loadClass(cf.className)
val meth = cl.getMethods()(0)
......@@ -23,12 +23,12 @@ class CompiledExpression(unit: CompilationUnit, cf: ClassFile, argsDecl: Seq[Ide
if (args.isEmpty) {
meth.invoke(null)
} else {
meth.invoke(null, args.map(unit.groundExprToJava).toArray)
meth.invoke(null, args.map(unit.valueToJVM).toArray)
}
}
def eval(args: Seq[Expr]): Expr = {
unit.javaToGroundExpr(evalToJava(args))
unit.jvmToValue(evalToJVM(args))
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment