summaryrefslogtreecommitdiff
path: root/sources/scalac/transformer
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
parentbcc3899778ce607df11b471a641493037a8c962f (diff)
downloadscala-a16dd265fddd7da26564109f4026fb1d12c1071a.tar.gz
scala-a16dd265fddd7da26564109f4026fb1d12c1071a.tar.bz2
scala-a16dd265fddd7da26564109f4026fb1d12c1071a.zip
*** empty log message ***
Diffstat (limited to 'sources/scalac/transformer')
-rw-r--r--sources/scalac/transformer/LambdaLift.java37
-rw-r--r--sources/scalac/transformer/UnCurry.java4
2 files changed, 39 insertions, 2 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}));
+ }
}
diff --git a/sources/scalac/transformer/UnCurry.java b/sources/scalac/transformer/UnCurry.java
index 9647b43852..427c7a0efd 100644
--- a/sources/scalac/transformer/UnCurry.java
+++ b/sources/scalac/transformer/UnCurry.java
@@ -146,10 +146,10 @@ public class UnCurry extends OwnerTransformer
private Tree[] transformArgs(int pos, Tree[] args, Type methtype) {
switch (methtype) {
case MethodType(Symbol[] params, _):
+ Tree[] args0 = args;//debug
if (params.length == 1 && (params[0].flags & REPEATED) != 0) {
assert (args.length != 1 || !(args[0] instanceof Tree.Tuple));
- args = new Tree[]{
- make.Tuple(pos, args).setType(params[0].type())};
+ args = new Tree[]{make.Tuple(pos, args).setType(params[0].type())};
}
Tree[] args1 = args;
for (int i = 0; i < args.length; i++) {