瀏覽代碼

[lua] bind instance methods, then wrap them in staticToInstance when assigning to instance fields

Justin Donaldson 9 年之前
父節點
當前提交
4d689637dc
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/generators/genlua.ml

+ 8 - 2
src/generators/genlua.ml

@@ -1080,7 +1080,7 @@ and gen_value ctx e =
 		v()
 
 and is_function_type ctx t =
-    match t.v_type with
+    match t with
     | TFun _ -> true
     | TMono r -> (match !r with | Some (TFun _) -> true | _ -> false)
     | _ -> false;
@@ -1122,7 +1122,13 @@ and gen_tbinop ctx op e1 e2 =
 		gen_value ctx e1;
 		spr ctx " = ";
 		gen_value ctx e3;
-	    | TField(e3, FInstance _ ), TLocal t  when (is_function_type ctx t)   ->
+	    | TField(e3, FInstance _ ), TField(e4, FClosure _ )  ->
+		gen_value ctx e1;
+		print ctx " %s " (Ast.s_binop op);
+		spr ctx "_hx_functionToInstanceFunction(";
+		gen_value ctx e2;
+		spr ctx ")";
+	    | TField(_, FInstance _ ), TLocal t  when (is_function_type ctx t.v_type)   ->
 		gen_value ctx e1;
 		print ctx " %s " (Ast.s_binop op);
 		spr ctx "_hx_functionToInstanceFunction(";