Trait

org.emmalanguage.ast

JavaAST

Related Doc: package ast

Permalink

trait JavaAST extends AST

Implements various utility functions that mitigate and/or workaround deficiencies in Scala's macros APIs, e.g. non- idempotent type checking, lack of hygiene, capture-avoiding substitution, fully-qualified names, fresh name generation, identifying closures, etc.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JavaAST
  2. AST
  3. Variables
  4. Values
  5. Types
  6. Trees
  7. Transversers
  8. Terms
  9. Symbols
  10. Patterns
  11. Parameters
  12. Methods
  13. Loops
  14. Bindings
  15. CommonAST
  16. AnyRef
  17. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type =?>[-A, +B] = PartialFunction[A, B]

    Permalink

    Syntax sugar for partial functions.

    Syntax sugar for partial functions.

    Definition Classes
    CommonAST
  2. trait API extends BindingAPI with LoopAPI with MethodAPI with ParameterAPI with PatternAPI with SymbolAPI with TermAPI with TransverserAPI with TreeAPI with TypeAPI with ValueAPI with VariableAPI

    Permalink

    Virtual AST API.

    Virtual AST API.

    Definition Classes
    AST
  3. case class Attr[A, I, S](tree: scala.reflect.api.Universe.Tree, acc: A, inh: I, syn: S) extends Product with Serializable

    Permalink

    An attributed tree.

    An attributed tree.

    tree

    The tree being attributed.

    acc

    Accumulated attributes.

    inh

    Inherited attributes.

    syn

    Synthesized attributes.

    Definition Classes
    Transversers
  4. trait BindingAPI extends AnyRef

    Permalink

    Bindings (values, variables and parameters).

    Bindings (values, variables and parameters).

    Examples
    // 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) }
    Definition Classes
    Bindings
  5. trait LoopAPI extends AnyRef

    Permalink

    Loops (while and do-while).

    Loops (while and do-while).

    Definition Classes
    Loops
  6. trait ManagedAttr[A <: HList, I <: HList, S <: HList] extends (scala.reflect.api.Universe.Tree) ⇒ AST.Attr[A, I, S]

    Permalink

    Utility for managing attribute grammars.

    Utility for managing attribute grammars.

    Definition Classes
    Transversers
  7. trait Meta extends AnyRef

    Permalink

    Meta information (attachments).

    Meta information (attachments).

    Definition Classes
    CommonAST
  8. trait MethodAPI extends AnyRef

    Permalink

    Methods (defs).

    Methods (defs).

    Examples
    // 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)
    Definition Classes
    Methods
  9. trait Node extends AnyRef

    Permalink

    Common parent for all virtual AST nodes.

    Common parent for all virtual AST nodes.

    Definition Classes
    CommonAST
  10. trait ParameterAPI extends AnyRef

    Permalink

    (method / lambda) Parameters.

    (method / lambda) Parameters.

    Examples
    def method(c: Char) = c
    (d: Double) => d
    abstract class A(e: Exception) { e.printStackTrace() }
    class C(f: Float) { println(f) }
    Definition Classes
    Parameters
  11. trait PatternAPI extends AnyRef

    Permalink

    Patterns (for pattern matching).

    Patterns (for pattern matching).

    Definition Classes
    Patterns
  12. case class Strategy[A <: HList, I <: HList, S <: HList](grammar: AST.AttrGrammar[A, I, S], factory: AST.Factory) extends Product with Serializable

    Permalink

    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.

    Definition Classes
    Transversers
  13. trait SymbolAPI extends AnyRef

    Permalink
    Definition Classes
    Symbols
  14. trait TermAPI extends AnyRef

    Permalink
    Definition Classes
    Terms
  15. abstract class Transform[A <: HList, I <: HList, S <: HList] extends scala.reflect.api.Universe.Transformer with AST.ManagedAttr[A, I, S]

    Permalink

    An abstract transformation (default is top-down break).

    An abstract transformation (default is top-down break).

    Definition Classes
    Transversers
  16. trait TransverserAPI extends AnyRef

    Permalink

    Fluent tree traversal / transformation APIs.

    Fluent tree traversal / transformation APIs.

    Definition Classes
    Transversers
  17. abstract class Traversal[A <: HList, I <: HList, S <: HList] extends scala.reflect.api.Universe.Traverser with AST.ManagedAttr[A, I, S]

    Permalink

    An abstract traversal (default is top-down break).

    An abstract traversal (default is top-down break).

    Definition Classes
    Transversers
  18. trait TreeAPI extends AnyRef

    Permalink
    Definition Classes
    Trees
  19. sealed trait TreeTransform extends AnyRef

    Permalink
    Definition Classes
    CommonAST
  20. trait TypeAPI extends AnyRef

    Permalink
    Definition Classes
    Types
  21. trait ValueAPI extends AnyRef

    Permalink

    Values (vals).

    Values (vals).

    Examples
    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)
    Definition Classes
    Values
  22. trait VariableAPI extends AnyRef

    Permalink

    Variables (vars).

    Variables (vars).

    Examples
    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"
    Definition Classes
    Variables
  23. type Xfrm = TreeTransform

    Permalink
    Definition Classes
    CommonAST
  24. trait XfrmAlg[B] extends AnyRef

    Permalink
    Definition Classes
    CommonAST
  25. trait XfrmEval extends AnyRef

    Permalink
    Definition Classes
    CommonAST
  26. implicit class XfrmOps extends (scala.reflect.api.Universe.Tree) ⇒ scala.reflect.api.Universe.Tree

    Permalink
    Definition Classes
    CommonAST

Abstract Value Members

  1. abstract val tb: ToolBox[u.type]

    Permalink

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. object Attr extends Serializable

    Permalink
    Definition Classes
    Transversers
  5. lazy val Flags: Set[scala.reflect.runtime.JavaUniverse.FlagSet]

    Permalink

    All explicit flags.

    All explicit flags.

    Definition Classes
    CommonAST
  6. lazy val FlagsNoSynthetic: Set[scala.reflect.runtime.JavaUniverse.FlagSet]

    Permalink
    Definition Classes
    CommonAST
  7. object Max

    Permalink

    Constant limits.

    Constant limits.

    Definition Classes
    CommonAST
  8. object NaiveEval extends XfrmEval

    Permalink

    Just evaluate the tree transform.

    Just evaluate the tree transform.

    Definition Classes
    CommonAST
  9. object TimerEval extends XfrmEval

    Permalink

    Evaluate and time each node.

    Evaluate and time each node.

    Definition Classes
    CommonAST
  10. object TreeTransform

    Permalink
    Definition Classes
    CommonAST
  11. object UniverseImplicits

    Permalink

    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.method

    as 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.

    Attributes
    protected[org.emmalanguage]
    Definition Classes
    CommonAST
  12. final val Xfrm: TreeTransform.type

    Permalink
    Definition Classes
    CommonAST
  13. def abort(msg: String, pos: scala.reflect.runtime.JavaUniverse.Position = NoPosition): Nothing

    Permalink

    Raises an error and terminates compilation.

    Raises an error and terminates compilation.

    Definition Classes
    JavaASTCommonAST
  14. object api extends API

    Permalink

    Virtual non-overlapping semantic AST based on Scala trees.

    Virtual non-overlapping semantic AST based on Scala trees.

    Definition Classes
    AST
  15. object are

    Permalink
    Definition Classes
    CommonAST
  16. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  17. def asSource(title: String)(tree: scala.reflect.runtime.JavaUniverse.Tree): String

    Permalink

    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.

    title

    Useful to distinguish different printouts from each other.

    tree

    The tree to print as source code.

    returns

    The printable source code.

    Definition Classes
    AST
  18. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def compile(tree: scala.reflect.runtime.JavaUniverse.Tree): () ⇒ Any

    Permalink
  20. lazy val enclosingOwner: scala.reflect.runtime.JavaUniverse.Symbol

    Permalink

    Returns the enclosing named entity (class, method, value, etc).

    Returns the enclosing named entity (class, method, value, etc).

    Definition Classes
    JavaASTCommonAST
  21. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  23. def eval[T](code: scala.reflect.runtime.JavaUniverse.Tree): T

    Permalink

    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).

    Definition Classes
    JavaASTCommonAST
  24. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  25. lazy val fixSymbolTypes: Xfrm

    Permalink

    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.

    Definition Classes
    AST
  26. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  27. object has

    Permalink
    Definition Classes
    CommonAST
  28. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  29. object have

    Permalink
    Definition Classes
    CommonAST
  30. def inferImplicit(tpe: scala.reflect.runtime.JavaUniverse.Type): Option[scala.reflect.runtime.JavaUniverse.Tree]

    Permalink

    Infers an implicit value from the enclosing context (if possible).

    Infers an implicit value from the enclosing context (if possible).

    Definition Classes
    JavaASTCommonAST
  31. object is

    Permalink
    Definition Classes
    CommonAST
  32. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  33. def meta(tree: scala.reflect.runtime.JavaUniverse.Tree): Meta { def all: scala.reflect.macros.Attachments{type Pos = JavaAST.this.u.Position} }

    Permalink

    Returns the meta information associated with tree.

    Returns the meta information associated with tree.

    Definition Classes
    JavaASTCommonAST
  34. def meta(sym: scala.reflect.runtime.JavaUniverse.Symbol): Meta { def all: scala.reflect.macros.Attachments{type Pos = JavaAST.this.u.Position} }

    Permalink

    Returns the meta information associated with sym.

    Returns the meta information associated with sym.

    Definition Classes
    JavaASTCommonAST
  35. def nameClashes(tree: scala.reflect.runtime.JavaUniverse.Tree): Seq[scala.reflect.runtime.JavaUniverse.TermSymbol]

    Permalink

    Returns a sequence of symbols in tree that have clashing names.

    Returns a sequence of symbols in tree that have clashing names.

    Definition Classes
    AST
  36. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  37. val noop: Xfrm

    Permalink
    Definition Classes
    CommonAST
  38. lazy val normalizeStatements: Xfrm

    Permalink

    Normalizes all statements in term position by wrapping them in a block.

    Normalizes all statements in term position by wrapping them in a block.

    Definition Classes
    AST
  39. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  40. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  41. def parse(code: String): scala.reflect.runtime.JavaUniverse.Tree

    Permalink

    Parses a snippet of source code and returns the AST.

    Parses a snippet of source code and returns the AST.

    Definition Classes
    JavaASTCommonAST
  42. lazy val qualifyStatics: Xfrm

    Permalink

    Fully qualifies references to static symbols.

    Fully qualifies references to static symbols.

    Definition Classes
    AST
  43. lazy val removeShadowedThis: Xfrm

    Permalink

    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)
      }
    }
    Definition Classes
    AST
  44. lazy val resolveNameClashes: Xfrm

    Permalink

    Ensures that all definitions within tree have unique names.

    Ensures that all definitions within tree have unique names.

    Definition Classes
    AST
  45. lazy val restoreTypeTrees: Xfrm

    Permalink

    Restores u.TypeTrees with their original field set.

    Restores u.TypeTrees with their original field set.

    Definition Classes
    AST
  46. lazy val shadowedOwners: Set[scala.reflect.runtime.JavaUniverse.Symbol]

    Permalink

    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.

    Definition Classes
    AST
  47. lazy val stubTypeTrees: Xfrm

    Permalink

    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.

    Definition Classes
    AST
  48. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  49. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  50. def typeCheck(tree: scala.reflect.runtime.JavaUniverse.Tree, typeMode: Boolean = false): scala.reflect.runtime.JavaUniverse.Tree

    Permalink

    Type-checks a tree (use typeMode=true for type-trees).

    Type-checks a tree (use typeMode=true for type-trees).

    Definition Classes
    JavaASTCommonAST
  51. val u: JavaUniverse

    Permalink
    Definition Classes
    JavaASTCommonAST
  52. lazy val unQualifyStatics: Xfrm

    Permalink

    Removes the qualifiers from references to static symbols.

    Removes the qualifiers from references to static symbols.

    Definition Classes
    AST
  53. def unTypeCheck(tree: scala.reflect.runtime.JavaUniverse.Tree): scala.reflect.runtime.JavaUniverse.Tree

    Permalink

    Removes all type and symbol attributes from a tree.

    Removes all type and symbol attributes from a tree.

    Definition Classes
    CommonAST
  54. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. def warning(msg: String, pos: scala.reflect.runtime.JavaUniverse.Position = NoPosition): Unit

    Permalink

    Raises a compiler warning.

    Raises a compiler warning.

    Definition Classes
    JavaASTCommonAST

Inherited from AST

Inherited from Variables

Inherited from Values

Inherited from Types

Inherited from Trees

Inherited from Transversers

Inherited from Terms

Inherited from Symbols

Inherited from Patterns

Inherited from Parameters

Inherited from Methods

Inherited from Loops

Inherited from Bindings

Inherited from CommonAST

Inherited from AnyRef

Inherited from Any

Ungrouped