Syntax sugar for partial functions.
Syntax sugar for partial functions.
Virtual AST API.
Virtual AST API.
An attributed tree.
An attributed tree.
The tree being attributed.
Accumulated attributes.
Inherited attributes.
Synthesized attributes.
Backend-specific APIs.
Backend-specific APIs. This trait should be implemented by each backend.
Bindings (values, variables and parameters).
Bindings (values, variables and parameters).
// values val a = 42 // variables var b = true // parameters def method(c: Char) = c (d: Double) => d abstract class A(e: Exception) { e.printStackTrace() } class C(f: Float) { println(f) }
Loops (while and do-while).
Loops (while and do-while).
Utility for managing attribute grammars.
Utility for managing attribute grammars.
Meta information (attachments).
Meta information (attachments).
Methods (defs).
Methods (defs).
// definitions def pi = 3.14 def greet() = println("Hello, World!") def nil[A] = List.empty[A] def pNil[A]() = println(nil[A]) def succ(i: Int) = i + 1 def one[A](a: A) = a :: Nil def add(x: Int, y: Int) = x + y def pair[A, B](a: A, b: B) = (a, b) def addCurry(x: Int)(y: Int) = x + y def pairCurry[A, B](a: A)(b: B) = (a, b) def zero[N: Numeric] = implicitly[Numeric[N]].zero def times2[N](n: N)(implicit N: Numeric[N]) = N.times(n, N.fromInt(2)) // calls pi greet() nil[String] pNil[String]() succ(42) one[Char]('1') add(2, 3) pair[String, Double]("pi = ", 3.14) addCurry(2)(3) pairCurry[String, Double]("pi = ")(3.14) zero[Double] times2[Long](5)
Common parent for all virtual AST nodes.
Common parent for all virtual AST nodes.
(method / lambda) Parameters.
(method / lambda) Parameters.
def method(c: Char) = c (d: Double) => d abstract class A(e: Exception) { e.printStackTrace() } class C(f: Float) { println(f) }
Patterns (for pattern matching).
Patterns (for pattern matching).
A traversal / transformation strategy.
A traversal / transformation strategy. 4 fundamental strategies are available:
1. Top-down continue left-to-right 2. Top-down break left-to-right 3. Bottom-up continue left-to-right 4. Bottom-up break left-to-right
Right-to-left variants are not supported.
An abstract transformation (default is top-down break).
An abstract transformation (default is top-down break).
Fluent tree traversal / transformation APIs.
Fluent tree traversal / transformation APIs.
An abstract traversal (default is top-down break).
An abstract traversal (default is top-down break).
Values (vals).
Values (vals).
val x = 42 println(x) object Math { val pi = 3.14 } println(Math.pi) ("Hello", '!')._1 println(math.e) import scala.math.e println(e)
Variables (vars).
Variables (vars).
var x = 42 x = x * 2 object Greet { var hi = "Hello" } println(Greet.hi + ", World!") // This is a `Def.Call` of the method `hi_=`, not a `Var.Mut`: Greet.hi = "Hola"
Raises an error and terminates compilation.
Raises an error and terminates compilation.
Returns the enclosing named entity (class, method, value, etc).
Returns the enclosing named entity (class, method, value, etc).
Evaluates a snippet of code and returns a value of type T.
Evaluates a snippet of code and returns a value of type T.
Note: this can be called on type--checked trees (as opposed to the eval method in ToolBox).
Infers an implicit value from the enclosing context (if possible).
Infers an implicit value from the enclosing context (if possible).
Returns the meta information associated with tree.
Returns the meta information associated with tree.
Returns the meta information associated with sym.
Returns the meta information associated with sym.
Parses a snippet of source code and returns the AST.
Parses a snippet of source code and returns the AST.
Combines a sequence of transformations into a pipeline with pre- and post-processing.
Standard pipeline suffix.
Standard pipeline suffix. Brings a tree into a form acceptable for scalac after being transformed.
Standard pipeline prefix.
Standard pipeline prefix. Brings a tree into a form convenient for transformation.
Type-checks a tree (use typeMode=true for type-trees).
Type-checks a tree (use typeMode=true for type-trees).
Raises a compiler warning.
Raises a compiler warning.
Reflection of the Emma API.
Reflection of the Emma API.
All explicit flags.
All explicit flags.
Constant limits.
Constant limits.
Factors out the implicit objects that need to be imported from the Scala universe.
Factors out the implicit objects that need to be imported from the Scala universe.
Please use
import UniverseImplicits._
u.Type
u.methodas opposed to
import universe._ // or import u._ Type method
in order to make the parts of the Emma compiler which depend on the Scala metaprogramming API explicit.
Common validation helpers.
Virtual non-overlapping semantic AST based on Scala trees.
Virtual non-overlapping semantic AST based on Scala trees.
Prints tree for debugging.
Prints tree for debugging.
Makes a best effort to shorten the resulting source code for better readability, especially removing particular package qualifiers. Does not return parseable source code.
Useful to distinguish different printouts from each other.
The tree to print as source code.
The printable source code.
Populates the missing types of lambda symbols in a tree.
Populates the missing types of lambda symbols in a tree. WARN: Mutates the symbol table in place.
The identity transformation with pre- and post-processing.
Returns a sequence of symbols in tree that have clashing names.
Returns a sequence of symbols in tree that have clashing names.
Normalizes all statements in term position by wrapping them in a block.
Normalizes all statements in term position by wrapping them in a block.
Fully qualifies references to static symbols.
Fully qualifies references to static symbols.
Rewrites A.this.x as x if A is shadowed another symbol in the owner chain.
Rewrites A.this.x as x if A is shadowed another symbol in the owner chain.
Can be used before showCode to avoid printing invalid trees such as
class A { val x = 42; class A { scala.Predef.println(A.this.x) } }
Ensures that all definitions within tree have unique names.
Ensures that all definitions within tree have unique names.
Restores u.TypeTrees with their original field set.
Restores u.TypeTrees with their original field set.
Computes a set of owners whose name is shadowed in the current scope.
Computes a set of owners whose name is shadowed in the current scope.
Replaces u.TypeTrees that have their original field set with stubs that only have their
tpe field set to the corresponding type.
Replaces u.TypeTrees that have their original field set with stubs that only have their
tpe field set to the corresponding type. Type-trees of val/vars are left empty for the
compiler to infer.
Removes the qualifiers from references to static symbols.
Removes the qualifiers from references to static symbols.
Removes all type and symbol attributes from a tree.
Removes all type and symbol attributes from a tree.
Common IR tools.