Skip to content

Commit

Permalink
[lua] __init__ comes before static initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonaldson committed Apr 20, 2020
1 parent ce56f30 commit adc9ed1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/generators/genlua.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2029,13 +2029,12 @@ let generate com =
newline ctx;

let b = open_block ctx in
println ctx "local _hx_static_init = function()";
(* Generate statics *)
List.iter (generate_static ctx) (List.rev ctx.statics);
(* Localize init variables inside a do-block *)
(* Note: __init__ logic can modify static variables. *)
println ctx "local _hx_static_init = function()";
(* Generate static inits *)
List.iter (gen_block_element ctx) (List.rev ctx.inits);
(* Generate statics *)
List.iter (generate_static ctx) (List.rev ctx.statics);
b();
newline ctx;
println ctx "end";
Expand Down

0 comments on commit adc9ed1

Please sign in to comment.