|
@@ -492,6 +492,12 @@ and gen_expr ctx e =
|
|
|
print ctx "$iterator(";
|
|
|
gen_value ctx x;
|
|
|
print ctx ")";
|
|
|
+ | TField (x,FClosure (Some {cl_path=[],"Array"}, {cf_name="push"})) ->
|
|
|
+ (* see https://github.com/HaxeFoundation/haxe/issues/1997 *)
|
|
|
+ add_feature ctx "use.$arrayPushClosure";
|
|
|
+ print ctx "$arrayPushClosure(";
|
|
|
+ gen_value ctx x;
|
|
|
+ print ctx ")"
|
|
|
| TField (x,FClosure (_,f)) ->
|
|
|
add_feature ctx "use.$bind";
|
|
|
(match x.eexpr with
|
|
@@ -1309,6 +1315,12 @@ let generate com =
|
|
|
print ctx "function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; }";
|
|
|
newline ctx;
|
|
|
end;
|
|
|
+ if has_feature ctx "use.$arrayPushClosure" then begin
|
|
|
+ print ctx "function $arrayPushClosure(a) {";
|
|
|
+ print ctx " return function(x) { a.push(x); }; ";
|
|
|
+ print ctx "}";
|
|
|
+ newline ctx
|
|
|
+ end;
|
|
|
List.iter (gen_block_element ~after:true ctx) (List.rev ctx.inits);
|
|
|
List.iter (generate_static ctx) (List.rev ctx.statics);
|
|
|
(match com.main with
|