فهرست منبع

Revert "compare v_id instead of physical equality for variables to avoid issues with interp encoding"

This reverts commit 194ba29a465374341f94ab79e5d96487b1354585.
Simon Krajewski 10 سال پیش
والد
کامیت
ba507a4d32
6فایلهای تغییر یافته به همراه13 افزوده شده و 13 حذف شده
  1. 6 6
      analyzer.ml
  2. 2 2
      codegen.ml
  3. 2 2
      filters.ml
  4. 1 1
      matcher.ml
  5. 1 1
      optimizer.ml
  6. 1 1
      typeload.ml

+ 6 - 6
analyzer.ml

@@ -188,7 +188,7 @@ module Simplifier = struct
 							let e_v',e1 = loop e_v e1 in
 							let e1 = assign e_v e1 in
 							begin match e1.eexpr with
-								| TBinop(OpAssign,{eexpr = TLocal v1},e2) when v.v_id = v1.v_id ->
+								| TBinop(OpAssign,{eexpr = TLocal v1},e2) when v == v1 ->
 									declare (Some e2)
 								| _ ->
 									declare None;
@@ -410,7 +410,7 @@ module Simplifier = struct
 	let unapply com e =
 		let var_map = ref IntMap.empty in
 		let rec get_assignment_to v e = match e.eexpr with
-			| TBinop(OpAssign,{eexpr = TLocal v2},e2) when v.v_id = v2.v_id -> Some e2
+			| TBinop(OpAssign,{eexpr = TLocal v2},e2) when v == v2 -> Some e2
 			| TBlock [e] -> get_assignment_to v e
 			| _ -> None
 		in
@@ -428,7 +428,7 @@ module Simplifier = struct
 								end
 							| TVar(v,None) when not (com.platform = Php) ->
 								begin match el with
-									| {eexpr = TBinop(OpAssign,{eexpr = TLocal v2},e2)} :: el when v.v_id = v2.v_id ->
+									| {eexpr = TBinop(OpAssign,{eexpr = TLocal v2},e2)} :: el when v == v2 ->
 										let e = {e with eexpr = TVar(v,Some e2)} in
 										loop2 (e :: el)
 									| ({eexpr = TIf(e1,e2,Some e3)} as e_if) :: el ->
@@ -716,7 +716,7 @@ module Ssa = struct
 					IntMap.iter (fun i v ->
 						try
 							let vl = IntMap.find i !vars in
-							if not (List.exists (fun (v',_) -> v.v_id = v'.v_id) vl) then
+							if not (List.exists (fun (v',_) -> v == v') vl) then
 								vars := IntMap.add i ((v,p) :: vl) !vars
 						with Not_found ->
 							()
@@ -1270,7 +1270,7 @@ module Checker = struct
 		let resolve_value v =
 			let e' = Ssa.get_var_value v in
 			begin match e'.eexpr with
-				| TLocal v' when v.v_id = v'.v_id -> e'
+				| TLocal v' when v == v' -> e'
 				| _ -> e'
 			end
 		in
@@ -1285,7 +1285,7 @@ module Checker = struct
 		let can_be_null v =
 			not (has_meta Meta.NotNull v.v_meta)
 			&& try not (List.exists (fun cond -> match cond with
-				| NotEqual(v',e) when v.v_id = v'.v_id && is_null_expr e -> true
+				| NotEqual(v',e) when v == v' && is_null_expr e -> true
 				| _ -> false
 			) (IntMap.find v.v_id ssa.var_conds)) with Not_found -> true
 		in

+ 2 - 2
codegen.ml

@@ -928,7 +928,7 @@ module PatternMatchConversion = struct
 	let is_declared cctx v =
 		let rec loop sl = match sl with
 			| stack :: sl ->
-				List.exists (fun ((v2,_),_) -> v.v_id = v2.v_id) stack || loop sl
+				List.exists (fun ((v2,_),_) -> v == v2) stack || loop sl
 			| [] ->
 				false
 		in
@@ -980,7 +980,7 @@ module PatternMatchConversion = struct
 				) catches in
 				{e with eexpr = TTry(e1,catches)}
 			| TLocal v ->
-				let v' = try snd (List.find (fun (v2,_) -> v2.v_id = v.v_id) !v_known) with Not_found -> v in
+				let v' = try List.assq v !v_known with Not_found -> v in
 				{e with eexpr = TLocal v'}
 			| _ ->
 				Type.map_expr loop e

+ 2 - 2
filters.ml

@@ -583,7 +583,7 @@ let rename_local_vars ctx e =
 				the same variable twice. In that case do not perform a rename since
 				we are sure it's actually the same variable
 			*)
-			if v.v_id = v2.v_id then raise Not_found;
+			if v == v2 then raise Not_found;
 			rename look_vars v;
 		with Not_found ->
 			());
@@ -600,7 +600,7 @@ let rename_local_vars ctx e =
 			let vars = if cfg.pf_locals_scope then vars else all_vars in
 			(try
 				let v = PMap.find name !vars in
-				if v.v_id = vtemp.v_id then raise Not_found; (* ignore *)
+				if v == vtemp then raise Not_found; (* ignore *)
 				rename (!vars) v;
 				rebuild_vars := true;
 				vars := PMap.add v.v_name v !vars

+ 1 - 1
matcher.ml

@@ -770,7 +770,7 @@ let column_sigma mctx st pmat =
 		if not g then Hashtbl.replace unguarded c.c_def true;
 	in
 	let bind_st out st v =
-		if not (List.exists (fun ((v2,p),_) -> v2.v_id = (fst v).v_id) !bindings) then bindings := (v,st) :: !bindings
+		if not (List.exists (fun ((v2,p),_) -> v2.v_id == (fst v).v_id) !bindings) then bindings := (v,st) :: !bindings
 	in
 	let rec loop pmat = match pmat with
 		| (pv,out) :: pr ->

+ 1 - 1
optimizer.ml

@@ -1315,7 +1315,7 @@ let inline_constructors ctx e =
 								match e.eexpr with
 								| TBlock el ->
 									List.iter get_assigns el
-								| TBinop (OpAssign, { eexpr = TField ({ eexpr = TLocal vv },FInstance(_,_,cf)); etype = t }, e) when v.v_id = vv.v_id ->
+								| TBinop (OpAssign, { eexpr = TField ({ eexpr = TLocal vv },FInstance(_,_,cf)); etype = t }, e) when v == vv ->
 									assigns := (cf.cf_name,e,t) :: !assigns
 								| _ ->
 									raise Exit

+ 1 - 1
typeload.ml

@@ -1868,7 +1868,7 @@ let init_class ctx c p context_init herits fields =
 								let rec has_this e = match e.eexpr with
 									| TConst TThis ->
 										display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
-									| TLocal v when (match ctx.vthis with Some v2 -> v.v_id = v2.v_id | None -> false) ->
+									| TLocal v when (match ctx.vthis with Some v2 -> v == v2 | None -> false) ->
 										display_error ctx "Cannot access this or other member field in variable initialization" e.epos;
 									| _ ->
 									Type.iter has_this e