ExprTools

class haxe.macro.ExprToolsAvailable in flash8, flash, neko, js, php, cpp, cs, javaThis class provides some utility methods to work with expressions. It is best used through 'using haxe.macro.ExprTools' syntax and then provides additional methods on haxe.macro.Expr instances.
While mainly intended to be used in macros, it works in non-macro code as well.
static function iter( e : Expr, f : Expr -> Void ) : VoidCalls function f on each sub-expression of e.
If e has no sub-expressions, this operation has no effect.
Otherwise f is called once per sub-expression of e, with the sub-expression as argument. These calls are done in order of the sub-expression declarations.
This method does not call itself recursively. It should instead be used in a recursive function which handles the expression nodes of interest.
Usage example:
 function findStrings(e:Expr) { 
    switch(e.expr) { 
        case EConst(CString(s)): // handle s 
        case _: ExprTools.iter(e, findStrings); 
    }
}
static function map( e : Expr, f : Expr -> Expr ) : Expr static function toFieldExpr( sl : Array<String> ) : Expr static function toString( e : Expr ) : StringConverts expression e to a human-readable String representation.
The result is guaranteed to be valid haxe code, but there may be differences from the original lexical syntax.
version #18526, modified 2013-05-08 10:51:47 by api
0 comment