简体   繁体   English

Haxe用参数生成超级调用

[英]Haxe generating super call with arguments

The context is type-building macro. 上下文是类型构建宏。 My goal is to generate 我的目标是产生

super(arg1, arg2, arg3)

What I have: 我有的:

Array<FunctionArg> => [{ meta => null, name => foo, type => TPath({ name => StdTypes, pack => [], params => [], sub => Int }), opt => null, value => null },{ meta => null, name => bar, type => TPath({ name => StdTypes, pack => [], params => [], sub => Int }), opt => null, value => null }]

I've tried macro super($a{ancestorArgs}) but that's just silly, as $a expects Array<Expr> . 我已经尝试了macro super($a{ancestorArgs})但是这很愚蠢,因为$a期望Array<Expr>

I have no ideas left. 我没有想法了。

Try: 尝试:

var args = [ for ( arg in funcArgs ) macro $i { arg.name } ];
func.expr = macro 
{
    super( $a{ args } );
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM