summaryrefslogtreecommitdiff
path: root/sources/scalac/transformer/LambdaLift.java
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-03-06 19:14:59 +0000
committerMartin Odersky <odersky@gmail.com>2003-03-06 19:14:59 +0000
commita16dd265fddd7da26564109f4026fb1d12c1071a (patch)
tree702ba02d30d68d21d51ac5c83f31b448cd654ce1 /sources/scalac/transformer/LambdaLift.java
parentbcc3899778ce607df11b471a641493037a8c962f (diff)
downloadscala-a16dd265fddd7da26564109f4026fb1d12c1071a.tar.gz
scala-a16dd265fddd7da26564109f4026fb1d12c1071a.tar.bz2
scala-a16dd265fddd7da26564109f4026fb1d12c1071a.zip
*** empty log message ***
Diffstat (limited to 'sources/scalac/transformer/LambdaLift.java')
-rw-r--r--sources/scalac/transformer/LambdaLift.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java
index 608db61eae..48f1edf66a 100644
--- a/sources/scalac/transformer/LambdaLift.java
+++ b/sources/scalac/transformer/LambdaLift.java
@@ -380,6 +380,11 @@ public class LambdaLift extends OwnerTransformer
}
return copy.ValDef(tree, mods, name1, tpe1, rhs1);
+ case Tuple(Tree[] args):
+ Tree tree1 = mkList(tree.pos, tree.type, transform(args));
+ //new scalac.ast.printer.TextTreePrinter().print("TUPLE: ").print(tree).print("\n ==> \n").print(tree1).println().end();//DEBUG
+ return tree1;
+
case Apply(Tree fn, Tree[] args):
Symbol fsym = TreeInfo.methSymbol(fn);
Tree fn1 = transform(fn);
@@ -535,4 +540,36 @@ public class LambdaLift extends OwnerTransformer
return args;
}
}
+
+ Tree mkList(int pos, Type tpe, Tree[] args) {
+ return mkList(pos, tpe.typeArgs()[0], args, 0);
+ }
+
+ Tree mkList(int pos, Type elemtpe, Tree[] args, int start) {
+ if (start == args.length) return mkNil(pos, elemtpe);
+ else return mkCons(pos, elemtpe, args[start],
+ mkList(pos, elemtpe, args, start + 1));
+ }
+
+ Tree mkNil(int pos, Type elemtpe) {
+ return gen.New(
+ gen.Apply(
+ gen.TypeApply(
+ gen.mkRef(
+ pos,
+ global.definitions.getClass(Names.scala_Nil).constructor()),
+ new Tree[]{gen.mkType(pos, elemtpe)}),
+ new Tree[]{}));
+ }
+
+ Tree mkCons(int pos, Type elemtpe, Tree hd, Tree tl) {
+ return gen.New(
+ gen.Apply(
+ gen.TypeApply(
+ gen.mkRef(
+ pos,
+ global.definitions.getClass(Names.scala_COLONCOLON).constructor()),
+ new Tree[]{gen.mkType(pos, elemtpe)}),
+ new Tree[]{hd, tl}));
+ }
}