瀏覽代碼

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

Dan Korostelev 10 年之前
父節點
當前提交
436117d897
共有 1 個文件被更改,包括 4 次插入1 次删除
  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) ->