|
@@ -860,6 +860,7 @@ let generate_package_create ctx (p,_) =
|
|
|
else
|
|
|
print ctx "if(!%s) %s = {}" p p
|
|
|
);
|
|
|
+ ctx.separator <- true;
|
|
|
newline ctx;
|
|
|
loop (p :: acc) l
|
|
|
in
|
|
@@ -889,7 +890,6 @@ let gen_class_static_field ctx c f =
|
|
|
ctx.id_counter <- 0;
|
|
|
print ctx "%s = " path;
|
|
|
gen_value ctx e;
|
|
|
- ctx.separator <- false;
|
|
|
newline ctx;
|
|
|
handle_expose ctx path f.cf_meta
|
|
|
| _ ->
|
|
@@ -944,7 +944,7 @@ let generate_class ctx c =
|
|
|
print ctx "%s = $hxClasses[\"%s\"] = " p (dot_path c.cl_path);
|
|
|
(match c.cl_constructor with
|
|
|
| Some { cf_expr = Some e } -> gen_expr ctx e
|
|
|
- | _ -> print ctx "function() { }");
|
|
|
+ | _ -> (print ctx "function() { }"); ctx.separator <- true);
|
|
|
newline ctx;
|
|
|
if ctx.js_modern && hxClasses then begin
|
|
|
print ctx "$hxClasses[\"%s\"] = %s" (dot_path c.cl_path) p;
|
|
@@ -1008,7 +1008,7 @@ let generate_class ctx c =
|
|
|
|
|
|
bend();
|
|
|
print ctx "\n}";
|
|
|
- (match c.cl_super with None -> () | _ -> print ctx ")");
|
|
|
+ (match c.cl_super with None -> ctx.separator <- true | _ -> print ctx ")");
|
|
|
newline ctx
|
|
|
end
|
|
|
|
|
@@ -1024,6 +1024,7 @@ let generate_enum ctx e =
|
|
|
print ctx "{";
|
|
|
if has_feature ctx "js.Boot.isEnum" then print ctx " __ename__ : %s," (if has_feature ctx "Type.getEnumName" then "[" ^ String.concat "," ename ^ "]" else "true");
|
|
|
print ctx " __constructs__ : [%s] }" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names));
|
|
|
+ ctx.separator <- true;
|
|
|
newline ctx;
|
|
|
List.iter (fun n ->
|
|
|
let f = PMap.find n e.e_constrs in
|
|
@@ -1032,6 +1033,7 @@ let generate_enum ctx e =
|
|
|
| TFun (args,_) ->
|
|
|
let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in
|
|
|
print ctx "function(%s) { var $x = [\"%s\",%d,%s]; $x.__enum__ = %s; $x.toString = $estr; return $x; }" sargs f.ef_name f.ef_index sargs p;
|
|
|
+ ctx.separator <- true;
|
|
|
| _ ->
|
|
|
print ctx "[\"%s\",%d]" f.ef_name f.ef_index;
|
|
|
newline ctx;
|
|
@@ -1148,7 +1150,7 @@ let generate com =
|
|
|
);
|
|
|
if List.exists (function TClassDecl { cl_extern = false; cl_super = Some _ } -> true | _ -> false) com.types then begin
|
|
|
print ctx "function $extend(from, fields) {
|
|
|
- function inherit() {}; inherit.prototype = from; var proto = new inherit();
|
|
|
+ function Inherit() {} Inherit.prototype = from; var proto = new Inherit();
|
|
|
for (var name in fields) proto[name] = fields[name];
|
|
|
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
|
|
|
return proto;
|
|
@@ -1169,14 +1171,12 @@ let generate com =
|
|
|
if has_feature ctx "use.$iterator" then begin
|
|
|
add_feature ctx "use.$bind";
|
|
|
print ctx "function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; }";
|
|
|
- ctx.separator <- true;
|
|
|
newline ctx;
|
|
|
end;
|
|
|
if has_feature ctx "use.$bind" then begin
|
|
|
print ctx "var $_, $fid = 0";
|
|
|
newline ctx;
|
|
|
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; }";
|
|
|
- ctx.separator <- true;
|
|
|
newline ctx;
|
|
|
end;
|
|
|
List.iter (gen_block ~after:true ctx) (List.rev ctx.inits);
|