diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-14 10:59:53 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-14 10:59:53 -0800 |
commit | 964fc6ee55dec031b5d697114db84a365425baf8 (patch) | |
tree | df3921df29e61a57b45373d3a8b3006d94280a60 /src/compiler | |
parent | 8c5583c1a229fc18fdef818649d4db793c0989a5 (diff) | |
download | scala-964fc6ee55dec031b5d697114db84a365425baf8.tar.gz scala-964fc6ee55dec031b5d697114db84a365425baf8.tar.bz2 scala-964fc6ee55dec031b5d697114db84a365425baf8.zip |
Toward the elimination of setInternalFlags.
Modifications in LiftCode to avoid upsetting the happy world
upon which I am converging where flags change in an almost
predictable fashion.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/reflect/internal/Symbols.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/LiftCode.scala | 37 |
2 files changed, 22 insertions, 21 deletions
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index e34189657e..a73ab32960 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -49,9 +49,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => val originalOwner = perRunCaches.newMap[Symbol, Symbol]() abstract class AbsSymbolImpl extends AbsSymbol { this: Symbol => - def newNestedSymbol(pos: Position, name: Name) = name match { - case n: TermName => newTermSymbol(n, pos) - case n: TypeName => newTypeSymbol(n, pos) + def newNestedSymbol(name: Name, pos: Position, flags: Long) = name match { + case n: TermName => newTermSymbol(n, pos, flags) + case n: TypeName => newTypeSymbol(n, pos, flags) } def typeSig: Type = info def typeSigIn(site: Type): Type = site.memberInfo(this) diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala index bc7d1754d4..c5475fa0f2 100644 --- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala +++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala @@ -71,6 +71,8 @@ abstract class LiftCode extends Transform with TypingTransformers { case mod => mod.toString } + // I fervently hope this is a test case or something, not anything being + // depended upon. Of more fragile code I cannot conceive. for (line <- (tree.toString.split(Properties.lineSeparator) drop 2 dropRight 1)) { var s = line.trim s = s.replace("$mr.", "") @@ -81,24 +83,23 @@ abstract class LiftCode extends Transform with TypingTransformers { s = s.replace("immutable.this.Nil", "List()") s = s.replace("modifiersFromInternalFlags", "Modifiers") s = s.replace("Modifiers(0L, newTypeName(\"\"), List())", "Modifiers()") - s = """Modifiers\((\d+)L, newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => { - val buf = new StringBuffer() + s = """Modifiers\((\d+)[lL], newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => { + val buf = new StringBuilder val flags = m.group(1).toLong - var s_flags = Flags.modifiersOfFlags(flags) map copypasteModifier - buf.append("Set(" + s_flags.mkString(", ") + ")") + val s_flags = Flags.modifiersOfFlags(flags) map copypasteModifier mkString ", " + if (s_flags != "") + buf.append("Set(" + s_flags + ")") - var privateWithin = m.group(2) - buf.append(", " + "newTypeName(\"" + privateWithin + "\")") + val privateWithin = "" + m.group(2) + if (privateWithin != "") + buf.append(", newTypeName(\"" + privateWithin + "\")") - var annotations = m.group(3) - buf.append(", " + "List(" + annotations + ")") + val annotations = m.group(3) + if (annotations.nonEmpty) + buf.append(", List(" + annotations + ")") - var s = buf.toString - if (s.endsWith(", List()")) s = s.substring(0, s.length - ", List()".length) - if (s.endsWith(", newTypeName(\"\")")) s = s.substring(0, s.length - ", newTypeName(\"\")".length) - if (s.endsWith("Set()")) s = s.substring(0, s.length - "Set()".length) - "Modifiers(" + s + ")" + "Modifiers(" + buf.toString + ")" }) s = """setInternalFlags\((\d+)L\)""".r.replaceAllIn(s, m => { val flags = m.group(1).toLong @@ -310,13 +311,13 @@ abstract class LiftCode extends Transform with TypingTransformers { */ private def reifySymbolDef(sym: Symbol): Tree = { if (reifyDebug) println("reify sym def " + sym) - var rsym: Tree = + + ValDef(NoMods, localName(sym), TypeTree(), Apply( Select(reify(sym.owner), "newNestedSymbol"), - List(reify(sym.pos), reify(sym.name))) - if (sym.flags != 0L) - rsym = Apply(Select(rsym, "setInternalFlags"), List(Literal(Constant(sym.flags)))) - ValDef(NoMods, localName(sym), TypeTree(), rsym) + List(reify(sym.name), reify(sym.pos), Literal(Constant(sym.flags))) + ) + ) } /** |