如何在haxe中检测来电者?

时间:2013-12-07 17:05:57

标签: haxe

我正在设置属性,我需要知道谁在设置属性值? haxe 3有可能吗?

另外,我可以知道谁在函数内部调用函数吗?

1 个答案:

答案 0 :(得分:6)

结帐PosInfos。你这样使用它:

public static function add(a:Int, b:Int, ?pos:PosInfos) {
    trace( 'Called from ${pos.className}');
    trace( 'Called from ${pos.methodName}');
    trace( 'Called from ${pos.fileName}');
    trace( 'Called from ${pos.lineNumber}');
    return a+b;
}

add( 1, 1 ); // "pos" will automatically be filled in by compiler