From ffb65f00615ba524298b39e676debf45af4a13cb Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 24 Oct 2011 16:34:55 +0000 Subject: First end-to-end implementation of a runtime re... First end-to-end implementation of a runtime reflexive compiler that generates and loads bytecodes. Review by szeiger. --- test/files/run/code.scala | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 test/files/run/code.scala (limited to 'test/files/run/code.scala') diff --git a/test/files/run/code.scala b/test/files/run/code.scala new file mode 100644 index 0000000000..e26f97b2a4 --- /dev/null +++ b/test/files/run/code.scala @@ -0,0 +1,60 @@ +import scala.tools.partest.utils.CodeTest + +case class Element(name: String) + +object Test extends App { + case class InnerElement(name: String) + def foo[T](ys: List[T]) = { + val fun: reflect.Code[Int => Int] = x => x + ys.length + fun + } + CodeTest(foo(List(2)), args) + CodeTest({() => val e = Element("someName"); e}, args) +// CodeTest({() => val e = InnerElement("someName"); e}, args) // (does not work yet) + def titi() = { + var truc = 0 + CodeTest(() => { + truc = 6 + }, args) + } + def tata(): Unit = { + var truc = 0 + CodeTest(() => { + truc = truc + 6 + }, args) + } + titi() + tata() + new baz.A(args) + + def show() { + def foo[T](ys: List[T]) = { + val fun: reflect.Code[Int => Int] = x => x + ys.length + CodeTest(fun, args) + } + foo(List(1, 2, 3)) + } + + show() + + def evaltest(x: Int) = { + CodeTest.static(() => x + 1, args) + CodeTest(() => x + 1, args) + } + + println("1+1 = "+evaltest(1)) +} + + +package baz { + + case class BazElement(name: String) { } + + class A(args: Array[String]) { + CodeTest(() => new baz.BazElement("someName"), args) + } + +} + + + -- cgit v1.2.3