浏览代码

[cpp] use "_hx_tmp" instead of "tmp"

See https://github.com/HaxeFoundation/hxcpp/issues/365
Simon Krajewski 9 年之前
父节点
当前提交
95b1fa0bbe
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      analyzer.ml

+ 6 - 2
analyzer.ml

@@ -905,6 +905,7 @@ type analyzer_context = {
 	com : Common.context;
 	com : Common.context;
 	config : Config.t;
 	config : Config.t;
 	graph : Graph.t;
 	graph : Graph.t;
+	temp_var_name : string;
 	mutable entry : BasicBlock.t;
 	mutable entry : BasicBlock.t;
 	mutable has_unbound : bool;
 	mutable has_unbound : bool;
 	mutable loop_counter : int;
 	mutable loop_counter : int;
@@ -1090,7 +1091,7 @@ module TexprTransformer = struct
 					fl,e
 					fl,e
 			in
 			in
 			let fl,e = loop [] e in
 			let fl,e = loop [] e in
-			let v = alloc_var "tmp" e.etype in
+			let v = alloc_var ctx.temp_var_name e.etype in
 			begin match ctx.com.platform with
 			begin match ctx.com.platform with
 				| Cpp when sequential && not (Common.defined ctx.com Define.Cppia) -> ()
 				| Cpp when sequential && not (Common.defined ctx.com Define.Cppia) -> ()
 				| _ -> v.v_meta <- [Meta.CompilerGenerated,[],e.epos];
 				| _ -> v.v_meta <- [Meta.CompilerGenerated,[],e.epos];
@@ -1452,6 +1453,9 @@ module TexprTransformer = struct
 			com = com;
 			com = com;
 			config = config;
 			config = config;
 			graph = g;
 			graph = g;
+			(* For CPP we want to use variable names which are "probably" not used by users in order to
+			   avoid problems with the debugger, see https://github.com/HaxeFoundation/hxcpp/issues/365 *)
+			temp_var_name = (match com.platform with Cpp -> "_hx_tmp" | _ -> "tmp");
 			entry = g.g_unreachable;
 			entry = g.g_unreachable;
 			has_unbound = false;
 			has_unbound = false;
 			loop_counter = 0;
 			loop_counter = 0;
@@ -2234,7 +2238,7 @@ module CodeMotion = DataFlow(struct
 					let v' = if decl then begin
 					let v' = if decl then begin
 						v
 						v
 					end else begin
 					end else begin
-						let v' = alloc_var "tmp" v.v_type in
+						let v' = alloc_var ctx.temp_var_name v.v_type in
 						declare_var ctx.graph v';
 						declare_var ctx.graph v';
 						v'.v_meta <- [Meta.CompilerGenerated,[],p];
 						v'.v_meta <- [Meta.CompilerGenerated,[],p];
 						v'
 						v'