【问题标题】:Haxe generating super call with argumentsHaxe 生成带有参数的超级调用
【发布时间】:2016-07-17 22:45:27
【问题描述】:

上下文是类型构建宏。我的目标是生成

super(arg1, arg2, arg3)

我有什么:

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 }]

我已经尝试过macro super($a{ancestorArgs}),但这很愚蠢,因为$a 期望Array&lt;Expr&gt;

我没有任何想法。

【问题讨论】:

    标签: macros haxe


    【解决方案1】:

    试试:

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

    【讨论】:

      猜你喜欢
      • 2021-06-02
      • 2020-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多