瀏覽代碼

put parenthesis around function variable fields to make mxmlc happy (fixed issue #820)

Simon Krajewski 13 年之前
父節點
當前提交
3240c40b06
共有 1 個文件被更改,包括 17 次插入0 次删除
  1. 17 0
      genas3.ml

+ 17 - 0
genas3.ml

@@ -40,6 +40,16 @@ type context = {
 	mutable constructor_block : bool;
 }
 
+let is_var_field e v =
+	match e.eexpr, follow e.etype with
+	| TTypeExpr (TClassDecl c),_
+	| _,TInst(c,_) ->
+		(try
+			let f = try PMap.find v c.cl_fields	with Not_found -> PMap.find v c.cl_statics in
+			(match f.cf_kind with Var _ -> true | _ -> false)
+		with Not_found -> false)
+	| _ -> false
+
 let protect name =
 	match name with
 	| "Error" | "Namespace" -> "_" ^ name
@@ -407,6 +417,13 @@ let rec gen_call ctx e el r =
 				print ctx ")";
 			| _ -> assert false)
 		| _ -> assert false)
+	| TField(ee,v),args when is_var_field ee v ->
+		spr ctx "(";
+		gen_value ctx e;
+		spr ctx ")";
+		spr ctx "(";
+		concat ctx "," (gen_value ctx) el;
+		spr ctx ")"	
 	| _ ->
 		gen_value ctx e;
 		spr ctx "(";