From 9ceadeb88fd3dac50e5336f158e4507cbd7ee115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Lemi=C3=A8re?= Date: Fri, 18 Aug 2017 15:13:28 +0200 Subject: [PATCH 1/3] Support for haxe 4 EIn change to EBinop(OpIn) --- src/tink/macro/Exprs.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tink/macro/Exprs.hx b/src/tink/macro/Exprs.hx index 410b107..c18a8d4 100644 --- a/src/tink/macro/Exprs.hx +++ b/src/tink/macro/Exprs.hx @@ -241,7 +241,7 @@ class Exprs { } static public inline function iterate(target:Expr, body:Expr, ?loopVar:String = 'i', ?pos:Position) - return EFor(EIn(loopVar.resolve(pos), target).at(pos), body).at(pos); + return EFor(#if (haxe_ver < 4) EIn( #else EBinop(OpIn, #end loopVar.resolve(pos), target).at(pos), body).at(pos); static public function toFields(object:Dynamic, ?pos:Position) return EObjectDecl([for (field in Reflect.fields(object)) From 58262a18102d3d8ee11f590ad5c12e2bf825dace Mon Sep 17 00:00:00 2001 From: Juraj Kirchheim Date: Fri, 18 Aug 2017 15:38:58 +0200 Subject: [PATCH 2/3] Use reification to abstract over Haxe version specific differences. --- src/tink/macro/Exprs.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tink/macro/Exprs.hx b/src/tink/macro/Exprs.hx index c18a8d4..667928f 100644 --- a/src/tink/macro/Exprs.hx +++ b/src/tink/macro/Exprs.hx @@ -241,7 +241,7 @@ class Exprs { } static public inline function iterate(target:Expr, body:Expr, ?loopVar:String = 'i', ?pos:Position) - return EFor(#if (haxe_ver < 4) EIn( #else EBinop(OpIn, #end loopVar.resolve(pos), target).at(pos), body).at(pos); + return macro @:pos(pos.sanitize()) for ($i{loopVar) in $target) $body; static public function toFields(object:Dynamic, ?pos:Position) return EObjectDecl([for (field in Reflect.fields(object)) From 5879773566618c6d8059d8a4837cc3cbe5de6531 Mon Sep 17 00:00:00 2001 From: Juraj Kirchheim Date: Fri, 18 Aug 2017 15:41:31 +0200 Subject: [PATCH 3/3] Fix typo. --- src/tink/macro/Exprs.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tink/macro/Exprs.hx b/src/tink/macro/Exprs.hx index 667928f..d163cf3 100644 --- a/src/tink/macro/Exprs.hx +++ b/src/tink/macro/Exprs.hx @@ -241,7 +241,7 @@ class Exprs { } static public inline function iterate(target:Expr, body:Expr, ?loopVar:String = 'i', ?pos:Position) - return macro @:pos(pos.sanitize()) for ($i{loopVar) in $target) $body; + return macro @:pos(pos.sanitize()) for ($i{loopVar} in $target) $body; static public function toFields(object:Dynamic, ?pos:Position) return EObjectDecl([for (field in Reflect.fields(object))