You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ochafik edited this page May 1, 2012
·
2 revisions
import scala.reflect._
trait Bindings {
val from: api.Universe
val to: api.Universe
val nameBindings: Map[from.Name, to.Tree]
val typeBindings: Map[from.Type, to.Type]
def apply(replacement: from.Tree): to.Tree = {
new to.Importer {
val from = Bindings.this.from
override def importTree(t: from.Tree) = t match {
case Ident(n) if n != null =>
nameBindings.get(n).getOrElse(super.importTree(t))
case _ =>
super.importTree(t)
}
override def importType(t: from.Type) =
Option(t).map(_.deconst.dealias.widen.normalize).map(typeBindings.get(_).getOrElse(super.importType(t))).orNull
}.importTree(replacement)
}
}
case class Matcher[T](from: api.Universe, to: api.Universe)(
patterns: from.Tree => T
) {
def bindings(tree: from.Tree): List[(T, Bindings)] = {
error("TODO")
}
}