This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Print compiler phases using ScalaSettings

2 replies
Stefan Kuhn
Joined: 2009-10-01,
User offline. Last seen 42 years 45 weeks ago.

I wonder why the following code doesn't print the compiler phases:
http://paste.pocoo.org/show/517509/

def printPhases() {
val settings = new Settings()
settings.showPhases.value = true //doesn't make a difference

settings.embeddedDefaults(Thread.currentThread().getContextClassLoader)
settings.outputDirs.setSingleOutput(new
VirtualDirectory("(memory)", None))

val compiler = new Global(settings, new ConsoleReporter(settings))
new compiler.Run() compileSources
(new BatchSourceFile("", "object Foo extends Application {
println(42 / 1) }") ::Nil)
}

What am I doing wrong?

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Print compiler phases using ScalaSettings

The output from commands which are designed to print something and
exit are not handled by Global, but by infrastructure which precedes
Global used by the runners. Look at CompilerCommand.scala, which
would eventually reveal to you that you can get there by a more direct
route:

scala> println(new Global(new Settings()) phaseDescriptions)
phase name id description
---------- -- -----------
parser 1 parse source into ASTs, perform simple desugaring
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
superaccessors 5 add super accessors in traits and nested classes
pickler 6 serialize symbol tables
refchecks 7 reference/override checking, translate
nested objects
selectiveanf 8
liftcode 9 reify trees
selectivecps 10
uncurry 11 uncurry, translate function values to
anonymous classes
tailcalls 12 replace tail calls by jumps
specialize 13 @specialized-driven class and method specialization
explicitouter 14 this refs to outer pointers, translate patterns
erasure 15 erase types, add interfaces for traits
lazyvals 16 allocate bitmaps, translate lazy vals
into lazified defs
lambdalift 17 move nested functions to top level
constructors 18 move field definitions into constructors
flatten 19 eliminate inner classes
mixin 20 mixin composition
cleanup 21 platform-specific cleanups, generate
reflective calls
icode 22 generate portable intermediate code
inliner 23 optimization: do inlining
inlineExceptionHandlers 24 optimization: inline exception handlers
closelim 25 optimization: eliminate uncalled closures
dce 26 optimization: eliminate dead code
jvm 27 generate JVM bytecode
terminal 28 The last phase in the compiler chain

Stefan Kuhn
Joined: 2009-10-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Print compiler phases using ScalaSettings

Thanks, I missed that. It's good to know that Global doesn't handle
(help, Xhelp, Yhelp, showPlugins, showPhases)

On 07.12.11 18:44, Paul Phillips wrote:
> The output from commands which are designed to print something and
> exit are not handled by Global, but by infrastructure which precedes
> Global used by the runners. Look at CompilerCommand.scala

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland