|
Scala example source code file (Internals.scala)
The Internals.scala Scala example source codepackage scala.reflect.macros package contexts trait Internals extends scala.tools.nsc.transform.TypingTransformers { self: Context => import global._ lazy val internal: ContextInternalApi = new global.SymbolTableInternal with ContextInternalApi { val enclosingOwner = callsiteTyper.context.owner class HofTransformer(hof: (Tree, TransformApi) => Tree) extends Transformer { val api = new TransformApi { def recur(tree: Tree): Tree = hof(tree, this) def default(tree: Tree): Tree = superTransform(tree) } def superTransform(tree: Tree) = super.transform(tree) override def transform(tree: Tree): Tree = hof(tree, api) } def transform(tree: Tree)(transformer: (Tree, TransformApi) => Tree): Tree = new HofTransformer(transformer).transform(tree) class HofTypingTransformer(hof: (Tree, TypingTransformApi) => Tree) extends TypingTransformer(callsiteTyper.context.unit) { self => currentOwner = callsiteTyper.context.owner curTree = EmptyTree localTyper = global.analyzer.newTyper(callsiteTyper.context.make(unit = callsiteTyper.context.unit)) val api = new TypingTransformApi { def recur(tree: Tree): Tree = hof(tree, this) def default(tree: Tree): Tree = superTransform(tree) def atOwner[T](owner: Symbol)(op: => T): T = self.atOwner(owner)(op) def atOwner[T](tree: Tree, owner: Symbol)(op: => T): T = self.atOwner(tree, owner)(op) def currentOwner: Symbol = self.currentOwner def typecheck(tree: Tree): Tree = localTyper.typed(tree) } def superTransform(tree: Tree) = super.transform(tree) override def transform(tree: Tree): Tree = hof(tree, api) } def typingTransform(tree: Tree)(transformer: (Tree, TypingTransformApi) => Tree): Tree = new HofTypingTransformer(transformer).transform(tree) def typingTransform(tree: Tree, owner: Symbol)(transformer: (Tree, TypingTransformApi) => Tree): Tree = { val trans = new HofTypingTransformer(transformer) trans.atOwner(owner)(trans.transform(tree)) } } } Other Scala source code examplesHere is a short list of links related to this Scala Internals.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.