|
@@ -73,25 +73,22 @@ extern class Syntax {
|
|
|
|
|
|
|
|
|
@:noUsing
|
|
|
- macro public static function foreach <T>(v:Expr, it:Expr, b:Expr):haxe.macro.Expr
|
|
|
- {
|
|
|
+ macro public static function foreach<T>(v:Expr, it:Expr, b:Expr):haxe.macro.Expr {
|
|
|
var id = switch (v.expr) {
|
|
|
- case EConst(CIdent(x)):x;
|
|
|
+ case EConst(CIdent(x)): x;
|
|
|
case _ : Context.error("unexpected " + ExprTools.toString(v) + ": const ident expected", v.pos);
|
|
|
}
|
|
|
+
|
|
|
var iter = try {
|
|
|
- Context.typeof(macro $it.__iter__());
|
|
|
- macro $it.__iter__().getNativeIteratorRaw();
|
|
|
+ var it = macro ($it.__iter__() : python.NativeIterator.NativeIteratorRaw<T>);
|
|
|
+ Context.typeof(it);
|
|
|
+ it;
|
|
|
} catch (e:Dynamic) {
|
|
|
- macro $it.getNativeIteratorRaw();
|
|
|
- };
|
|
|
-
|
|
|
+ macro ($it : python.NativeIterable.NativeIterableRaw<T>);
|
|
|
+ }
|
|
|
|
|
|
return macro {
|
|
|
- // the first 2 expressions are only used to create a typing context for the foreach construct
|
|
|
- // TODO how can we get rid of them, so that they are not generated?
|
|
|
var $id = null;
|
|
|
- if (false) $v = $iter.__next__();
|
|
|
$self._foreach($v, $it, $b);
|
|
|
}
|
|
|
}
|