Using -Xprint
flag in scalac
we get output of different compiler phases, for example given the following Foo.scala
object Foo {
val x = 42
}
then scalac -Xprint:jvm Foo.scala
outputs
package <empty> {
object Foo extends Object {
<static> private[this] val x: Int = _;
<stable> <accessor> def x(): Int = Foo.this.x;
def <init>(): Foo.type = {
Foo.super.<init>();
Foo.this.x = 42;
()
}
}
}
How to compile the phase itself, that is, say we have source file jvmphase.scala
like so
package <empty> { ...
containing the phase source code instead of the original vanilla Scala source code, then how to achieve something similar to scalac jvmphase.scala
?