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) }
Alpha equivalence.
Alpha equivalence.
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)
Alpha difference at subtrees lhs and rhs due to msg.
Alpha difference at subtrees lhs and rhs due to msg.
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"
Reflection of the Emma API.
Reflection of the Emma API.
Core language.
Core language.
All explicit flags.
All explicit flags.
The fold-fusion optimization.
The fold-fusion optimization.
The fold-fusion optimization.
The fold-fusion optimization.
Constant limits.
Constant limits.
Static (compile-time) optimizations.
Static (compile-time) optimizations.
Source language.
Source language.
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.
Common validation helpers.
Raises an error and terminates compilation.
Are lhs and rhs alpha equivalent (i.e.
Are lhs and rhs alpha equivalent (i.e. equal upto renaming)?
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.
Shows tree in a Swing AST browser.
Shows tree in a Swing AST browser.
Resolves a sequence of config paths to be used with loadConfig.
Resolves a sequence of config paths to be used with loadConfig. The result
- path :+ baseConfig if tlPath is some tree represenging a string literal path, or
- baseConfig otherwise.
Aborts execution with an error if tlPath is not a string literal.
Returns the enclosing named entity (class, method, value, etc).
Evaluates a snippet of code and returns a value of type T.
Unconditional failure.
Unconditional failure.
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.
The identity transformation with pre- and post-processing.
Implicit types to be removed
Implicit types to be removed
Infers an implicit value from the enclosing context (if possible).
Loads a sequence of resources (in decreasing priority).
Loads a sequence of resources (in decreasing priority).
Returns the meta information associated with tree.
Returns the meta information associated with sym.
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.
Parses a snippet of source code and returns the AST.
Unconditional success.
Unconditional success.
Combines a sequence of transformations into a pipeline with pre- and post-processing.
Standard pipeline suffix.
Standard pipeline prefix.
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.
Type-checks a tree (use typeMode=true for type-trees).
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.
Raises a compiler warning.
Macros needed for the test cases.
These are defined here and not in the
testfolder, because they need to be compiled in an earlier compilation run.