瀏覽代碼

[java/cs] Fixed implements Dynamic

Caue Waneck 12 年之前
父節點
當前提交
09b80fec70
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      gencommon.ml

+ 18 - 0
gencommon.ml

@@ -6577,6 +6577,24 @@ struct
       epos = pos
     });
 
+    add_constructor cl ctor;
+    (* default ctor also *)
+    let ctor = mk_class_field "new" (TFun([],basic.tvoid)) false pos (Method MethNormal) [] in
+    ctor.cf_expr <- Some {
+      eexpr = TFunction {
+        tf_type = basic.tvoid;
+        tf_args = [];
+        tf_expr = {
+          eexpr = TBlock(List.map (fun (f,t) ->
+            { eexpr = TBinop(Ast.OpAssign, mk_this f t,{ eexpr = TArrayDecl([]); etype = t; epos = pos; }); etype = t; epos = pos }
+          ) fields);
+          etype = basic.tvoid;
+          epos = pos;
+        }
+      };
+      etype = ctor.cf_type;
+      epos = pos;
+    };
     add_constructor cl ctor;
     (* and finally we will return a function that transforms a TObjectDecl into a new DynamicObject() call *)
     let rec loop objdecl acc acc_f =