diff options
author | Martin Odersky <odersky@gmail.com> | 2011-07-30 21:04:43 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-07-30 21:04:43 +0000 |
commit | c0db3f2d065e22796a2c917c6c3b0f14f3982cf0 (patch) | |
tree | a21a5982ec9d0a6311843b2e1397192a3a64aecd /src/compiler/scala/reflect/internal | |
parent | d0c5e4be5554f4862da0690ac0315a4433fcb5d5 (diff) | |
download | scala-c0db3f2d065e22796a2c917c6c3b0f14f3982cf0.tar.gz scala-c0db3f2d065e22796a2c917c6c3b0f14f3982cf0.tar.bz2 scala-c0db3f2d065e22796a2c917c6c3b0f14f3982cf0.zip |
LiftCode works again, now integrated with new r...
LiftCode works again, now integrated with new reflection library.
Other changes: def Literal(x: Any) has been deprecated, and all its uses removed.
Modifiers has lost positions as fourth case class argument; is now a field, mirroring Tree.pos (this removes junk in patterns and makes reification simpler). Review by extempore.
Diffstat (limited to 'src/compiler/scala/reflect/internal')
5 files changed, 31 insertions, 23 deletions
diff --git a/src/compiler/scala/reflect/internal/TreeGen.scala b/src/compiler/scala/reflect/internal/TreeGen.scala index 15c339aefd..61c4edf75e 100644 --- a/src/compiler/scala/reflect/internal/TreeGen.scala +++ b/src/compiler/scala/reflect/internal/TreeGen.scala @@ -243,15 +243,15 @@ abstract class TreeGen { */ def mkZero(tp: Type): Tree = { val tree = tp.typeSymbol match { - case UnitClass => Literal(()) - case BooleanClass => Literal(false) - case FloatClass => Literal(0.0f) - case DoubleClass => Literal(0.0d) - case ByteClass => Literal(0.toByte) - case ShortClass => Literal(0.toShort) - case IntClass => Literal(0) - case LongClass => Literal(0L) - case CharClass => Literal(0.toChar) + case UnitClass => Literal(Constant()) + case BooleanClass => Literal(Constant(false)) + case FloatClass => Literal(Constant(0.0f)) + case DoubleClass => Literal(Constant(0.0d)) + case ByteClass => Literal(Constant(0.toByte)) + case ShortClass => Literal(Constant(0.toShort)) + case IntClass => Literal(Constant(0)) + case LongClass => Literal(Constant(0L)) + case CharClass => Literal(Constant(0.toChar)) case _ => Literal(Constant(null)) } tree setType tp @@ -259,7 +259,7 @@ abstract class TreeGen { /** Builds a tuple */ def mkTuple(elems: List[Tree]): Tree = - if (elems.isEmpty) Literal(()) + if (elems.isEmpty) Literal(Constant()) else Apply( Select(mkAttributedRef(TupleClass(elems.length).caseModule), nme.apply), elems) diff --git a/src/compiler/scala/reflect/internal/TreePrinters.scala b/src/compiler/scala/reflect/internal/TreePrinters.scala index aef9219ed4..e5b9fafa00 100644 --- a/src/compiler/scala/reflect/internal/TreePrinters.scala +++ b/src/compiler/scala/reflect/internal/TreePrinters.scala @@ -435,7 +435,8 @@ trait TreePrinters { self: SymbolTable => } } - def xprintRaw(treePrinter: TreePrinter, tree: Tree) = print("<unknown tree of class "+tree.getClass+">") + def xprintRaw(treePrinter: TreePrinter, tree: Tree) = + treePrinter.print(tree.productPrefix+tree.productIterator.mkString("(", ", ", ")")) def newTreePrinter(writer: PrintWriter): TreePrinter = new TreePrinter(writer) def newTreePrinter(stream: OutputStream): TreePrinter = newTreePrinter(new PrintWriter(stream)) diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala index ef80b5d479..5ba1a1221e 100644 --- a/src/compiler/scala/reflect/internal/Trees.scala +++ b/src/compiler/scala/reflect/internal/Trees.scala @@ -22,8 +22,13 @@ trait Trees extends api.Trees { self: SymbolTable => */ case class Modifiers(flags: Long, privateWithin: Name, - annotations: List[Tree], - positions: Map[Long, Position]) extends AbsModifiers with HasFlags { + annotations: List[Tree]) extends AbsModifiers with HasFlags { + + var positions: Map[Long, Position] = Map() + + def setPositions(poss: Map[Long, Position]): this.type = { + positions = poss; this + } /* Abstract types from HasFlags. */ type FlagsType = Long @@ -40,42 +45,43 @@ trait Trees extends api.Trees { self: SymbolTable => def & (flag: Long): Modifiers = { val flags1 = flags & flag if (flags1 == flags) this - else Modifiers(flags1, privateWithin, annotations, positions) + else Modifiers(flags1, privateWithin, annotations) setPositions positions } def &~ (flag: Long): Modifiers = { val flags1 = flags & (~flag) if (flags1 == flags) this - else Modifiers(flags1, privateWithin, annotations, positions) + else Modifiers(flags1, privateWithin, annotations) setPositions positions } def | (flag: Long): Modifiers = { val flags1 = flags | flag if (flags1 == flags) this - else Modifiers(flags1, privateWithin, annotations, positions) + else Modifiers(flags1, privateWithin, annotations) setPositions positions } def withAnnotations(annots: List[Tree]) = if (annots.isEmpty) this - else copy(annotations = annotations ::: annots) + else copy(annotations = annotations ::: annots) setPositions positions + def withPosition(flag: Long, position: Position) = - copy(positions = positions + (flag -> position)) + copy() setPositions positions + (flag -> position) override def hasModifier(mod: Modifier.Value) = hasFlag(flagOfModifier(mod)) override def allModifiers: Set[Modifier.Value] = Modifier.values filter hasModifier override def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers = - Modifiers(flags, privateWithin, f(annotations), positions) + Modifiers(flags, privateWithin, f(annotations)) setPositions positions override def toString = "Modifiers(%s, %s, %s)".format(hasFlagsToString(-1L), annotations mkString ", ", positions) } - def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List(), Map.empty) + def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List()) def Modifiers(flags: Long): Modifiers = Modifiers(flags, tpnme.EMPTY) def Modifiers(mods: Set[Modifier.Value], privateWithin: Name, annotations: List[Tree]): Modifiers = { val flagSet = mods map flagOfModifier - Modifiers((0L /: flagSet)(_ | _), privateWithin, annotations, Map.empty) + Modifiers((0L /: flagSet)(_ | _), privateWithin, annotations) } lazy val NoMods = Modifiers(0) diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 545b86f6ab..81962f89d8 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -826,7 +826,8 @@ trait Types extends api.Types { self: SymbolTable => /** The string representation of this type, with singletypes explained. */ def toLongString = { val str = toString - if (str endsWith ".type") str + " (with underlying type " + widen + ")" + if (str == "type") widen.toString + else if (str endsWith ".type") str + " (with underlying type " + widen + ")" else str } diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala index 6d0b22ac05..dfae6c50be 100644 --- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala @@ -766,7 +766,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { val pflags = (pflagsHi.toLong << 32) + pflagsLo val flags = pickledToRawFlags(pflags) val privateWithin = readNameRef() - Modifiers(flags, privateWithin, Nil, Map.empty) + Modifiers(flags, privateWithin, Nil) } /* Read a reference to a pickled item */ |