summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/CleanUp.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2009-03-30 08:45:39 +0000
committerIulian Dragos <jaguarul@gmail.com>2009-03-30 08:45:39 +0000
commit532147c333a8dab79fc77c20162a4d752c6f6780 (patch)
treed18c5275381e34655b0dad967f6304ba63c4416e /src/compiler/scala/tools/nsc/transform/CleanUp.scala
parent1c72ffaee5e0faeeb6d046216e5e76c86a6a41ff (diff)
downloadscala-532147c333a8dab79fc77c20162a4d752c6f6780.tar.gz
scala-532147c333a8dab79fc77c20162a4d752c6f6780.tar.bz2
scala-532147c333a8dab79fc77c20162a4d752c6f6780.zip
Code to support invoke-dynamic for structural t...
Code to support invoke-dynamic for structural types. Not yet complete, built around the JSR 292 spec of December 2008.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/CleanUp.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index db88df5dc5..23496807d8 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -592,6 +592,25 @@ abstract class CleanUp extends Transform {
)
}
+ def getClass(q: Tree): Tree =
+ Apply(Select(q, nme.getClass_), List())
+
+ if (settings.refinementMethodDispatch.value == "invoke-dynamic") {
+/* val guardCallSite: Tree = {
+ val cachedClass = addStaticVariableToClass("cachedClass", definitions.ClassClass.tpe, EmptyTree)
+ val tmpVar = currentOwner.newVariable(ad.pos, unit.fresh.newName(ad.pos, "x")).setInfo(definitions.AnyRefClass.tpe)
+ atPos(ad.pos)(Block(List(
+ ValDef(tmpVar, transform(qual))),
+ If(Apply(Select(gen.mkAttributedRef(cachedClass), nme.EQ), List(getClass(Ident(tmpVar)))),
+ Block(List(Assign(gen.mkAttributedRef(cachedClass), getClass(Ident(tmpVar)))),
+ copy.ApplyDynamic(ad, Ident(tmpVar), transformTrees(params))),
+ EmptyTree)))
+ }
+ //println(guardCallSite)
+*/
+ localTyper.typed(copy.ApplyDynamic(ad, transform(qual), transformTrees(params)))
+ } else {
+
/* ### BODY OF THE TRANSFORMATION -> remember we're in case ad@ApplyDynamic(qual, params) ### */
/* This creates the tree that does the reflective call (see general comment
@@ -659,7 +678,7 @@ abstract class CleanUp extends Transform {
/* We return the dynamic call tree, after making sure no other
* clean-up transformation are to be applied on it. */
transform(t)
-
+ }
/* ### END OF DYNAMIC APPLY TRANSFORM ### */
/* Some cleanup transformations add members to templates (classes, traits, etc).