How about something like this:
case class Action(f: Function, ts: List[TypeName]) {
def render(ruleName: String): Expr[Unit] = {
val argNames = (1 to ts.size).map(i => newTermName(s"value$i"))
val args = argNames.map(name => Ident(name))
val valDefs = (ts zip argNames).map {
case (tn, argName) =>
q"val $argName = p.valueStack.pop().asInstanceOf[$tn]"
}
c.Expr[Unit]( q"""
val p = ${c.prefix}
..$valDefs
p.valueStack.push($f(..$args))
""")
}
}
This compiles (in Scala 2.10.2 with Macro Paradise plugin), but I didn't test whether it works.