summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Global.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-06 07:41:38 +0000
committerPaul Phillips <paulp@improving.org>2011-02-06 07:41:38 +0000
commita4bbb15aa23198e1b482e2ef6ab18cf5c7f4b2be (patch)
treefc6f901ad16e5ec3b4fc79a90a9bc8a0009a697d /src/compiler/scala/tools/nsc/Global.scala
parent1f189a0d91deb00ad86ef213780a4374c7332e50 (diff)
downloadscala-a4bbb15aa23198e1b482e2ef6ab18cf5c7f4b2be.tar.gz
scala-a4bbb15aa23198e1b482e2ef6ab18cf5c7f4b2be.tar.bz2
scala-a4bbb15aa23198e1b482e2ef6ab18cf5c7f4b2be.zip
Added new option -Yshow-syms.
symbols. Specifically, it extracts all the symbols attached to AST nodes, and then prints them hierarchically along with indicators for new symbols and other interesting factoids like disappearing symbols. A small demonstration. Output shown is obviously only a fraction of what is produced. // a.scala class A { Nil foreach println } % scalac -Yshow-syms -uniqid a.scala [[symbol layout at end of selectivecps]] class A#17 constructor A#8019 value <local A>#8020 value $anonfun#10961 <synthetic> value x#10971 <synthetic> [[symbol layout at end of uncurry]] class A#17 constructor A#8019 value <local A>#8020 * anonymous class $anonfun#10993 final <synthetic> * constructor $anonfun#11001 * method apply#10994 final value x#10971 <synthetic> * value <local $anonfun>#10999 No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index b132b47417..56426cfcfd 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -16,7 +16,7 @@ import reporters.{ Reporter, ConsoleReporter }
import util.{ Exceptional, ClassPath, SourceFile, Statistics, BatchSourceFile, ScriptSourceFile, ShowPickled, returning }
import reflect.generic.{ PickleBuffer, PickleFormat }
-import symtab.{ Flags, SymbolTable, SymbolLoaders }
+import symtab.{ Flags, SymbolTable, SymbolLoaders, SymbolTrackers }
import symtab.classfile.Pickler
import dependencies.DependencyAnalysis
import plugins.Plugins
@@ -249,6 +249,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def profileMem = settings.YprofileMem.value
def richExes = settings.YrichExes.value
def showTrees = settings.Xshowtrees.value
+ def showSymbols = settings.Yshowsyms.value
def target = settings.target.value
def typerDebug = settings.Ytyperdebug.value
def unchecked = settings.unchecked.value
@@ -854,6 +855,21 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
// If -Yprofile isn't given this will never be triggered.
lazy val profiler = Class.forName(opt.profileClass).newInstance().asInstanceOf[Profiling]
+ // Similarly, this will only be created under -Yshow-syms.
+ object trackerFactory extends SymbolTrackers {
+ val global: Global.this.type = Global.this
+ lazy val trackers = currentRun.units.toList map (x => SymbolTracker(x))
+ def snapshot() = {
+ inform("\n[[symbol layout at end of " + phase + "]]")
+ atPhase(phase.next) {
+ trackers foreach { t =>
+ t.snapshot()
+ inform(t.show())
+ }
+ }
+ }
+ }
+
/** Compile list of source files */
def compileSources(_sources: List[SourceFile]) {
val depSources = dependencyAnalysis.calculateFiles(_sources.distinct) // bug #1268, scalac confused by duplicated filenames
@@ -898,6 +914,10 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
if (opt.showTrees) nodePrinters.printAll()
else printAllUnits()
}
+ // print the symbols presently attached to AST nodes
+ if (opt.showSymbols)
+ trackerFactory.snapshot()
+
// print members
if (opt.showPhase)
showMembers()