|
@@ -24,7 +24,6 @@ type ctx = {
|
|
|
buf : Buffer.t;
|
|
|
packages : (string list,unit) Hashtbl.t;
|
|
|
stack : Codegen.stack_context;
|
|
|
- check_package : bool;
|
|
|
mutable current : tclass;
|
|
|
mutable statics : (tclass * string * texpr) list;
|
|
|
mutable inits : texpr list;
|
|
@@ -581,11 +580,10 @@ let generate_package_create ctx (p,_) =
|
|
|
Hashtbl.add ctx.packages (p :: acc) ();
|
|
|
(match acc with
|
|
|
| [] ->
|
|
|
- if ctx.check_package then print ctx "try { if( %s == null ) %s = {}; } catch(_) { %s = {}; } " p p p else print ctx "%s = {}" p;
|
|
|
+ print ctx "if(typeof %s=='undefined') %s = {}" p p;
|
|
|
| _ ->
|
|
|
let p = String.concat "." (List.rev acc) ^ (field p) in
|
|
|
- if ctx.check_package then print ctx "if( !%s ) " p;
|
|
|
- print ctx "%s = {}" p);
|
|
|
+ print ctx "if(!%s) %s = {}" p p);
|
|
|
newline ctx;
|
|
|
loop (p :: acc) l
|
|
|
in
|
|
@@ -699,7 +697,6 @@ let generate com =
|
|
|
com = com;
|
|
|
stack = Codegen.stack_init com false;
|
|
|
buf = Buffer.create 16000;
|
|
|
- check_package = Common.defined com "check-js-packages";
|
|
|
packages = Hashtbl.create 0;
|
|
|
statics = [];
|
|
|
inits = [];
|