فهرست منبع

more generated locals eliminated (close https://github.com/vshaxe/hashlink-debugger/issues/13, related to https://github.com/HaxeFoundation/haxe/issues/7258)

Nicolas Cannasse 7 سال پیش
والد
کامیت
398fb0bf06
1فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 5 3
      src/generators/genhl.ml

+ 5 - 3
src/generators/genhl.ml

@@ -960,11 +960,13 @@ let real_name v =
 	| "_gthis" -> "this"
 	| "_gthis" -> "this"
 	| name -> name
 	| name -> name
 
 
-let is_gen_local v =
-	String.length v.v_name >= 2 && String.unsafe_get v.v_name 0 = '_' && String.unsafe_get v.v_name 1 = 'g'
+let is_gen_local ctx v =
+	if has_meta Meta.CompilerGenerated v.v_meta || has_meta Meta.ForLoopVariable v.v_meta then true
+	else if String.length v.v_name >= 2 && String.unsafe_get v.v_name 0 = '_' && String.unsafe_get v.v_name 1 = 'g' then true
+	else false
 
 
 let add_assign ctx v =
 let add_assign ctx v =
-	if is_gen_local v then () else
+	if is_gen_local ctx v then () else
 	let name = real_name v in
 	let name = real_name v in
 	ctx.m.massign <- (alloc_string ctx name, current_pos ctx - 1) :: ctx.m.massign
 	ctx.m.massign <- (alloc_string ctx name, current_pos ctx - 1) :: ctx.m.massign