I have deconstructed Function, got it vparams, and now I am able to call:
case class Action(f: Function, ts: List[TypeName]) {
def render(ruleName: String): Expr[Unit] = c.Expr[Unit](q"""
val p = ${c.prefix}
val value1 = p.valueStack.pop().asInstanceOf[${ts(0)}]
val value2 = p.valueStack.pop().asInstanceOf[${ts(1)}]
p.valueStack.push($f(value1, value2))
""")
}
f is of arbitrary number of parameters that is known at compile time.
How to pass ts.count parameters from p.valueStack to a function f?
How about something like this:
This compiles (in Scala 2.10.2 with Macro Paradise plugin), but I didn't test whether it works.