Procházet zdrojové kódy

Some more info in debug stack management

Hugh Sanderson před 15 roky
rodič
revize
5e663688d7
1 změnil soubory, kde provedl 8 přidání a 7 odebrání
  1. 8 7
      gencpp.ml

+ 8 - 7
gencpp.ml

@@ -144,7 +144,7 @@ type context =
 	mutable ctx_do_safe_point : bool;
 	mutable ctx_real_this_ptr : bool;
 	mutable ctx_dynamic_this_ptr : bool;
-	mutable ctx_push_src_pos : bool;
+	mutable ctx_push_src_pos : string;
 	mutable ctx_static_id_curr : int;
 	mutable ctx_static_id_used : int;
 	mutable ctx_static_id_depth : int;
@@ -164,7 +164,7 @@ let new_context common_ctx writer debug =
 	ctx_assigning = false;
 	ctx_debug = debug;
 	ctx_debug_type = debug;
-	ctx_push_src_pos = false;
+	ctx_push_src_pos = "";
 	ctx_return_from_block = false;
 	ctx_return_from_internal_node = false;
 	ctx_do_safe_point = false;
@@ -988,7 +988,7 @@ and gen_expression ctx retval expression =
 	let do_safe_point = ctx.ctx_do_safe_point in
 	ctx.ctx_do_safe_point <- false;
 	let push_src_pos = ctx.ctx_push_src_pos in
-	ctx.ctx_push_src_pos <- false;
+	ctx.ctx_push_src_pos <- "";
 
 	(* Annotate source code with debug - can get a bit verbose.  Mainly for debugging code gen,
 		rather than the run time *)
@@ -1179,7 +1179,7 @@ and gen_expression ctx retval expression =
 		end else begin
 			writer#begin_block;
 			if (do_safe_point) then output_i "__SAFE_POINT\n";
-			if (push_src_pos) then output_i "HX_SOURCE_PUSH\n";
+			if (push_src_pos<>"") then output_i ("HX_SOURCE_PUSH(\"" ^ push_src_pos ^ "\")\n");
 			(* Save old values, and equalize for new input ... *)
 			let pop_names = push_anon_names ctx in
 			let remaining = ref (List.length expr_list) in
@@ -1644,6 +1644,7 @@ let gen_field ctx class_def class_name ptr_name is_static is_external is_interfa
 		let nargs = string_of_int (List.length function_def.tf_args) in
 		let is_void = (type_string function_def.tf_type ) = "Void" in
 		let ret = if is_void  then "(void)" else "return " in
+		let src_name = class_name ^ "::" ^ field.cf_name in
 
 		if (not (is_dynamic_method field)) then begin
 			(* The actual function definition *)
@@ -1657,13 +1658,13 @@ let gen_field ctx class_def class_name ptr_name is_static is_external is_interfa
 			if (has_default_values function_def.tf_args) then begin
 				ctx.ctx_writer#begin_block;
 				generate_default_values ctx function_def.tf_args "__o_";
-				output "\tHX_SOURCE_PUSH;\n";
+				output ("\tHX_SOURCE_PUSH(\"" ^ src_name ^ "\");\n");
 				gen_expression ctx false function_def.tf_expr;
 				if (is_void) then output "return null();\n";
 				ctx.ctx_writer#end_block;
 			end else begin
 				if (is_void) then ctx.ctx_writer#begin_block;
-				ctx.ctx_push_src_pos <- true;
+				ctx.ctx_push_src_pos <- src_name;
 				gen_expression ctx false (to_block function_def.tf_expr);
 				if (is_void) then begin
 					output "return null();\n";
@@ -1684,7 +1685,7 @@ let gen_field ctx class_def class_name ptr_name is_static is_external is_interfa
 			output ("HX_BEGIN_DEFAULT_FUNC(" ^ func_name ^ "," ^ class_name ^ ")\n");
 			output return_type;
 			output (" run(" ^ (gen_arg_list function_def.tf_args "") ^ ")");
-			ctx.ctx_push_src_pos <- true;
+			ctx.ctx_push_src_pos <- src_name;
 			if (is_void) then begin
 				ctx.ctx_writer#begin_block;
 				gen_expression ctx false function_def.tf_expr;