diff options
Diffstat (limited to 'sources')
-rwxr-xr-x | sources/scala/tools/nsc/Global.scala | 23 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Symbols.scala | 4 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/symtab/classfile/PickleFormat.scala | 2 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/typechecker/Typers.scala | 7 |
4 files changed, 19 insertions, 17 deletions
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala index 3c5f45806a..0648bd3c4e 100755 --- a/sources/scala/tools/nsc/Global.scala +++ b/sources/scala/tools/nsc/Global.scala @@ -20,6 +20,7 @@ import matching.TransMatcher; import transform._; import backend.icode.{ICodes, GenICode, Checkers}; import backend.ScalaPrimitives; +import backend.jvm.BytecodeGenerators; class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable with Trees @@ -235,6 +236,10 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable val global: Global.this.type = Global.this; } + object genJVM extends BytecodeGenerators { + val global: Global.this.type = Global.this; + } + object icodeChecker extends checkers.ICodeChecker(); object typer extends analyzer.Typer(analyzer.NoContext.make(EmptyTree, Global.this.definitions.RootClass, new Scope())) { @@ -263,16 +268,13 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable flatten, constructors, mixin, - if (settings.Xshowicode.value) genicode - else sampleTransform); - -// Runs ---------------------------------------------------------------- + genicode, + genJVM, + sampleTransform); private var curRun: Run = NoRun; override def currentRun: Run = curRun; - type AttrInfo = Pair[Type, List[Any]]; - class Run extends CompilerRun { curRun = this; override val firstPhase = syntaxAnalyzer.newPhase(NoPhase); @@ -306,9 +308,6 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable override val erasurePhase = phaseNamed("erasure"); override val flattenPhase = phaseNamed("flatten"); - /** A map from symbols to their attributes */ - val attributes = new HashMap[Symbol, List[AttrInfo]]; - private var unitbuf = new ListBuffer[CompilationUnit]; private var fileset = new HashSet[AbstractFile]; @@ -343,7 +342,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable globalPhase = globalPhase.next; if (settings.check contains globalPhase.name) { phase = globalPhase; - if (globalPhase.name == "terminal" && settings.Xshowicode.value) icodeChecker.checkICodes; + if (globalPhase.name == "terminal") icodeChecker.checkICodes; else checker.checkTrees; } if (settings.statistics.value) statistics.print(phase); @@ -351,7 +350,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable if (settings.Xshowcls.value != "") showDef(newTermName(settings.Xshowcls.value), false); if (settings.Xshowobj.value != "") showDef(newTermName(settings.Xshowobj.value), true); - if (settings.Xshowicode.value) printICode(); + if (settings.Xshowicode.value) writeICode(); if (reporter.errors() == 0) { for (val Pair(sym, pickled) <- symData.elements.toList) { @@ -447,7 +446,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable } } - private def printICode(): Unit = { + private def writeICode(): Unit = { val printer = new icodePrinter.TextPrinter(new PrintWriter(System.out, true)); icodes.classes.foreach(printer.printClass); } diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala index 0aa534e568..626ed445f3 100755 --- a/sources/scala/tools/nsc/symtab/Symbols.scala +++ b/sources/scala/tools/nsc/symtab/Symbols.scala @@ -18,6 +18,8 @@ abstract class Symbols: SymbolTable { var typeSymbolCount = 0; var classSymbolCount = 0; + type AttrInfo = Pair[Type, List[Constant]]; + val emptySymbolArray = new Array[Symbol](0); /** The class for all symbols */ @@ -34,6 +36,8 @@ abstract class Symbols: SymbolTable { def pos = rawpos; def setPos(pos: int): this.type = { this.rawpos = pos; this } + var attributes: List[AttrInfo] = List(); + // Creators ------------------------------------------------------------------- final def newValue(pos: int, name: Name) = diff --git a/sources/scala/tools/nsc/symtab/classfile/PickleFormat.scala b/sources/scala/tools/nsc/symtab/classfile/PickleFormat.scala index 42aa2e933c..76b75356e1 100755 --- a/sources/scala/tools/nsc/symtab/classfile/PickleFormat.scala +++ b/sources/scala/tools/nsc/symtab/classfile/PickleFormat.scala @@ -44,6 +44,7 @@ object PickleFormat { * | 33 LITERALstring len_Nat name_Ref * | 34 LITERALnull len_Nat * | 35 LITERALzero len_Nat + * | 36 ATTRIBUTE sym_Ref type_Ref {constant_Ref} * SymbolInfo = name_Ref owner_Ref flags_Nat info_Ref * NameInfo = <character sequence of length len_Nat in Utf8 format> * NumInfo = <len_Nat-byte signed number in big endian format> @@ -86,6 +87,7 @@ object PickleFormat { final val LITERALstring = 33; final val LITERALnull = 34; final val LITERALzero = 35; + final val ATTRIBUTE = 40; final val firstSymTag = NONEsym; final val lastSymTag = VALsym; diff --git a/sources/scala/tools/nsc/typechecker/Typers.scala b/sources/scala/tools/nsc/typechecker/Typers.scala index a1f1c02171..0ecbab0c53 100755 --- a/sources/scala/tools/nsc/typechecker/Typers.scala +++ b/sources/scala/tools/nsc/typechecker/Typers.scala @@ -190,6 +190,7 @@ abstract class Typers: Analyzer { value case arg => error(arg.pos, "attribute argument needs to be a constant; found: " + arg); + null }) } @@ -1078,11 +1079,7 @@ abstract class Typers: Analyzer { case Attributed(attr, defn) => val attr1 = typed(attr, AttributeClass.tpe); val defn1 = typed(defn, mode, pt); - val existing = currentRun.attributes.get(defn1.symbol) match { - case None => List() - case Some(attrs) => attrs - } - currentRun.attributes(defn1.symbol) = attrInfo(attr1) :: existing; + defn1.symbol.attributes = defn1.symbol.attributes ::: List(attrInfo(attr1)); defn1 case DocDef(comment, defn) => |