以下代码获取调用函数(如 C _ _ FUNC _ _):
def __func__(c: Context) = {
import c.universe._
c.enclosingMethod match {
case DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
c.universe.reify(println(
"\n mods "+c.literal(mods.toString).splice
+"\n name "+c.literal(name.toString).splice
+"\n tparams "+c.literal(tparams.toString).splice
+"\n vparamss "+c.literal(vparamss.toString).splice
+"\n tpt "+c.literal(tpt.toString).splice
+"\n rhs "+c.literal(rhs.toString).splice
))
case _ => c.abort(c.enclosingPosition, "NoEnclosingMethod")
}
}
但是如何获得更多的深度,即获取调用宏的函数的函数的名称?
提前感谢您的帮助。