Explorar el Código

fallback on dynamic access when creating closures on interface methods (close #6703)

Nicolas Cannasse hace 7 años
padre
commit
69d6a6c5f2
Se han modificado 2 ficheros con 8 adiciones y 14 borrados
  1. 8 1
      src/generators/genhl.ml
  2. 0 13
      src/generators/hlinterp.ml

+ 8 - 1
src/generators/genhl.ml

@@ -2070,7 +2070,14 @@ and eval_expr ctx e =
 			op ctx (match ethis.eexpr with TConst TThis -> OGetThis (r,fid) | _ -> OField (r,robj,fid));
 		| AInstanceProto (ethis,fid) | AVirtualMethod (ethis, fid) ->
 			let robj = eval_null_check ctx ethis in
-			op ctx (OVirtualClosure (r,robj,fid));
+			(match rtype ctx robj with
+			| HObj _ ->
+				op ctx (OVirtualClosure (r,robj,fid))
+			| HVirtual vp ->
+				let _, sid, _ = vp.vfields.(fid) in
+				op ctx (ODynGet (r,robj, sid))
+			| _ ->
+				assert false)
 		| ADynamic (ethis, f) ->
 			let robj = eval_null_check ctx ethis in
 			op ctx (ODynGet (r,robj,f))

+ 0 - 13
src/generators/hlinterp.ml

@@ -969,16 +969,6 @@ let interp ctx f args =
 			let m = (match get o with
 			| VObj v as obj -> VClosure (v.oproto.pmethods.(m), Some obj)
 			| VNull -> null_access()
-			| VVirtual v ->
-				let name, _, _ = v.vtype.vfields.(m) in
-				(match v.vvalue with
-				| VObj o as obj ->
-					(try
-						let m = PMap.find name o.oproto.pclass.pfunctions in
-						VClosure (get_function ctx m, Some obj)
-					with Not_found ->
-						VNull)
-				| _ -> assert false)
 			| _ -> assert false
 			) in
 			set r (if m = VNull then m else dyn_cast ctx m (match get_type m with None -> assert false | Some v -> v) (rtype r))
@@ -2380,9 +2370,6 @@ let check code macros =
 						reg r (HFun (tl,tret));
 					| _ ->
 						assert false)
-				| HVirtual v ->
-					let _,_, t = v.vfields.(fid) in
-					reg r t;
 				| _ ->
 					is_obj o)
 			| OInstanceClosure (r,f,arg) ->