Explorar o código

[js] support @:selfCall for constructors (closes #3441)

Dan Korostelev %!s(int64=10) %!d(string=hai) anos
pai
achega
436117d897
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      genjs.ml

+ 4 - 1
genjs.ml

@@ -584,7 +584,10 @@ and gen_expr ctx e =
 	| TNew ({ cl_path = [],"Array" },_,[]) ->
 		print ctx "[]"
 	| TNew (c,_,el) ->
-		print ctx "new %s(" (ctx.type_accessor (TClassDecl c));
+		(match c.cl_constructor with
+		| Some cf when Meta.has Meta.SelfCall cf.cf_meta -> ()
+		| _ -> print ctx "new ");
+		print ctx "%s(" (ctx.type_accessor (TClassDecl c));
 		concat ctx "," (gen_value ctx) el;
 		spr ctx ")"
 	| TIf (cond,e,eelse) ->