diff options
author | Martin Odersky <odersky@gmail.com> | 2003-03-05 12:48:28 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-03-05 12:48:28 +0000 |
commit | 4a44cf6531eeb2a80036c1370d1e9bd72dd22616 (patch) | |
tree | bcdea28d0ea695260dde8a111b8e0dd3e40d97c4 /sources | |
parent | c5ffb069fa3fa7bd1f95bfc62784297c49c17925 (diff) | |
download | scala-4a44cf6531eeb2a80036c1370d1e9bd72dd22616.tar.gz scala-4a44cf6531eeb2a80036c1370d1e9bd72dd22616.tar.bz2 scala-4a44cf6531eeb2a80036c1370d1e9bd72dd22616.zip |
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/ast/parser/Parser.java | 8 | ||||
-rw-r--r-- | sources/scalac/ast/printer/TextTreePrinter.java | 7 | ||||
-rw-r--r-- | sources/scalac/transformer/LambdaLift.java | 2 | ||||
-rw-r--r-- | sources/scalac/transformer/UnCurry.java | 13 |
4 files changed, 23 insertions, 7 deletions
diff --git a/sources/scalac/ast/parser/Parser.java b/sources/scalac/ast/parser/Parser.java index fa2769f8d9..6f2ddb5d0f 100644 --- a/sources/scalac/ast/parser/Parser.java +++ b/sources/scalac/ast/parser/Parser.java @@ -32,9 +32,13 @@ public class Parser implements Tokens { */ TreeFactory make; + final Transformer duplicator; + public Parser(Unit unit) { s = new Scanner(unit); make = unit.global.make; + this.duplicator = new Transformer( + unit.global, null, make, new StrictTreeFactory(make)); } /** this is the general parse method @@ -212,7 +216,7 @@ public class Parser implements Tokens { System.arraycopy(enums, 2, newenums, 1, newenums.length - 1); newenums[0] = make.PatDef( enums[0].pos, mods, pat, - makeFor1(enums[1].pos, Names.filter, pat, rhs, enums[1])); + makeFor1(enums[1].pos, Names.filter, duplicator.transform(pat), rhs, enums[1])); return makeFor(pos, newenums, mapName, flatmapName, body); } default: @@ -942,7 +946,7 @@ public class Parser implements Tokens { rhs.pos, new Tree.CaseDef[]{ (CaseDef)make.CaseDef( - rhs.pos, pat, Tree.Empty, + rhs.pos, duplicator.transform(pat), Tree.Empty, make.Select(rhs.pos, scalaDot(rhs.pos, Names.Boolean), Names.True)), (CaseDef)make.CaseDef( diff --git a/sources/scalac/ast/printer/TextTreePrinter.java b/sources/scalac/ast/printer/TextTreePrinter.java index 26dadcc679..b41642af07 100644 --- a/sources/scalac/ast/printer/TextTreePrinter.java +++ b/sources/scalac/ast/printer/TextTreePrinter.java @@ -30,8 +30,8 @@ public class TextTreePrinter implements TreePrinter { protected int indent = 0; protected final int INDENT_STEP = 2; - protected final String INDENT_STRING = - " "; + protected String INDENT_STRING = + " "; protected final int MAX_INDENT = INDENT_STRING.length(); public TextTreePrinter(OutputStream stream) { @@ -81,6 +81,9 @@ public class TextTreePrinter implements TreePrinter { protected void printNewLine() { out.println(); + while (indent > INDENT_STRING.length()) { + INDENT_STRING = INDENT_STRING + INDENT_STRING; + } if (indent > 0) out.write(INDENT_STRING, 0, indent); } diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java index 51d49ef8e8..608db61eae 100644 --- a/sources/scalac/transformer/LambdaLift.java +++ b/sources/scalac/transformer/LambdaLift.java @@ -147,7 +147,7 @@ public class LambdaLift extends OwnerTransformer * the owner of sym. */ private boolean markFree(Symbol sym, Symbol owner) { - if (global.debug) global.log("mark " + sym + " free in " + owner);//debug + if (global.debug) global.log("mark " + sym + " of " + sym.owner() + " free in " + owner);//debug if (owner.kind == NONE) { assert propagatePhase : sym + " in " + sym.owner(); return false; diff --git a/sources/scalac/transformer/UnCurry.java b/sources/scalac/transformer/UnCurry.java index 461fa150df..a37ce8732a 100644 --- a/sources/scalac/transformer/UnCurry.java +++ b/sources/scalac/transformer/UnCurry.java @@ -105,6 +105,7 @@ public class UnCurry extends OwnerTransformer // argument to parameterless function e => ( => e) Type ftype = fn.type; Tree fn1 = transform(fn); + System.out.println("transforming args of " + fn.symbol());//debug Tree[] args1 = transformArgs(tree.pos, args, ftype); switch (fn1) { case Apply(Tree fn2, Tree[] args2): @@ -147,13 +148,21 @@ public class UnCurry extends OwnerTransformer switch (methtype) { case MethodType(Symbol[] params, _): 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())}; } + Tree[] args1 = args; for (int i = 0; i < args.length; i++) { - args[i] = transformArg(args[i], params[i]); + Tree arg = args[i]; + Tree arg1 = transform(arg, params[i]); + if (arg1 != arg && args1 == args) { + args1 = new Tree[args.length]; + System.arraycopy(args, 0, args1, 0, i); + } + args1[i] = arg1; } - return args; + return args1; case PolyType(_, Type restp): return transformArgs(pos, args, restp); default: |