ソースを参照

[js] Fix type names in debugger (#10894)

Rudy Ges 2 年 前
コミット
6b63b4cf10
1 ファイル変更12 行追加4 行削除
  1. 12 4
      src/generators/genjs.ml

+ 12 - 4
src/generators/genjs.ml

@@ -1332,15 +1332,17 @@ let generate_class_es3 ctx c =
 
 
 	let p = s_path ctx cl_path in
 	let p = s_path ctx cl_path in
 	let dotp = dot_path cl_path in
 	let dotp = dot_path cl_path in
-
 	let added_to_hxClasses = ctx.has_resolveClass && not is_abstract_impl in
 	let added_to_hxClasses = ctx.has_resolveClass && not is_abstract_impl in
 
 
-	if ctx.js_modern || not added_to_hxClasses then
+	(* Do not add to $hxClasses on same line as declaration to make sure not to trip js debugger *)
+	(* when it tries to get a string representation of a class. Will be added below *)
+	if ctx.com.debug || ctx.js_modern || not added_to_hxClasses then
 		print ctx "%s = " p
 		print ctx "%s = " p
 	else
 	else
 		print ctx "%s = $hxClasses[\"%s\"] = " p dotp;
 		print ctx "%s = $hxClasses[\"%s\"] = " p dotp;
 
 
-	process_expose c.cl_meta (fun () -> dotp) (fun s -> print ctx "$hx_exports%s = " (path_to_brackets s));
+	if not ctx.com.debug then
+		process_expose c.cl_meta (fun () -> dotp) (fun s -> print ctx "$hx_exports%s = " (path_to_brackets s));
 
 
 	if is_abstract_impl then begin
 	if is_abstract_impl then begin
 		(* abstract implementations only contain static members and don't need to have constructor functions *)
 		(* abstract implementations only contain static members and don't need to have constructor functions *)
@@ -1354,11 +1356,17 @@ let generate_class_es3 ctx c =
 
 
 	newline ctx;
 	newline ctx;
 
 
-	if ctx.js_modern && added_to_hxClasses then begin
+	if (ctx.js_modern || ctx.com.debug) && added_to_hxClasses then begin
 		print ctx "$hxClasses[\"%s\"] = %s" dotp p;
 		print ctx "$hxClasses[\"%s\"] = %s" dotp p;
 		newline ctx;
 		newline ctx;
 	end;
 	end;
 
 
+	if ctx.com.debug then
+		process_expose c.cl_meta (fun () -> dotp) (fun s -> begin
+			print ctx "$hx_exports%s = %s" (path_to_brackets s) p;
+			newline ctx;
+		end);
+
 	if not is_abstract_impl then begin
 	if not is_abstract_impl then begin
 		generate_class___name__ ctx cl_path;
 		generate_class___name__ ctx cl_path;
 		generate_class___isInterface__ ctx c;
 		generate_class___isInterface__ ctx c;