Browse Source

[cpp] Respect the noDebug meta on functions. Use better version of 'rethrow'. Closes #5842

hughsando 8 years ago
parent
commit
6eaa00844a
3 changed files with 16 additions and 9 deletions
  1. 9 6
      src/generators/gencpp.ml
  2. 5 1
      std/cpp/Lib.hx
  3. 2 2
      std/haxe/CallStack.hx

+ 9 - 6
src/generators/gencpp.ml

@@ -2180,7 +2180,7 @@ let cpp_var_debug_name_of v =
 
 
 
 
 let cpp_no_debug_synbol ctx var =
 let cpp_no_debug_synbol ctx var =
-   (has_meta_key var.v_meta Meta.CompilerGenerated) ||
+   (ctx.ctx_debug_level=0) || (has_meta_key var.v_meta Meta.CompilerGenerated) ||
       match cpp_type_of ctx var.v_type with
       match cpp_type_of ctx var.v_type with
       | TCppStar _ | TCppReference _ -> true
       | TCppStar _ | TCppReference _ -> true
       | TCppInst (class_def) when (has_meta_key class_def.cl_meta Meta.StructAccess) -> true
       | TCppInst (class_def) when (has_meta_key class_def.cl_meta Meta.StructAccess) -> true
@@ -2250,6 +2250,7 @@ let cpp_is_static_extension ctx member =
    has_meta_key member.cf_meta Meta.NativeStaticExtension
    has_meta_key member.cf_meta Meta.NativeStaticExtension
 ;;
 ;;
 
 
+
 let cpp_template_param path native =
 let cpp_template_param path native =
    let path = "::" ^ (join_class_path_remap (path) "::" ) in
    let path = "::" ^ (join_class_path_remap (path) "::" ) in
    if (native) then
    if (native) then
@@ -3949,9 +3950,10 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
 (* } *)
 (* } *)
 
 
 
 
-let gen_cpp_function_body ctx clazz is_static func_name function_def head_code tail_code =
+let gen_cpp_function_body ctx clazz is_static func_name function_def head_code tail_code no_debug =
    let output = ctx.ctx_output in
    let output = ctx.ctx_output in
    let dot_name = join_class_path clazz.cl_path "." in
    let dot_name = join_class_path clazz.cl_path "." in
+   if no_debug then ctx.ctx_debug_level <- 0;
    let prologue = function gc_stack ->
    let prologue = function gc_stack ->
       let spacer = "            \t" in
       let spacer = "            \t" in
       let output_i = fun s -> output (spacer ^ s) in
       let output_i = fun s -> output (spacer ^ s) in
@@ -4092,6 +4094,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
       let is_void = (cpp_type_of ctx function_def.tf_type ) = TCppVoid in
       let is_void = (cpp_type_of ctx function_def.tf_type ) = TCppVoid in
       let ret = if is_void  then "(void)" else "return " in
       let ret = if is_void  then "(void)" else "return " in
       let orig_debug = ctx.ctx_debug_level in
       let orig_debug = ctx.ctx_debug_level in
+      let no_debug = has_meta_key field.cf_meta Meta.NoDebug in
 
 
       if (not (is_dynamic_haxe_method field)) then begin
       if (not (is_dynamic_haxe_method field)) then begin
          (* The actual function definition *)
          (* The actual function definition *)
@@ -4110,7 +4113,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
             output ("\t" ^ ret ^ "::" ^ nativeImpl ^ "(" ^ (ctx_arg_list_name ctx function_def.tf_args "__o_") ^ ");\n");
             output ("\t" ^ ret ^ "::" ^ nativeImpl ^ "(" ^ (ctx_arg_list_name ctx function_def.tf_args "__o_") ^ ");\n");
             output "}\n\n";
             output "}\n\n";
          end else
          end else
-            gen_cpp_function_body ctx class_def is_static field.cf_name function_def code tail_code;
+            gen_cpp_function_body ctx class_def is_static field.cf_name function_def code tail_code no_debug;
 
 
          output "\n\n";
          output "\n\n";
          let nonVirtual = has_meta_key field.cf_meta Meta.NonVirtual in
          let nonVirtual = has_meta_key field.cf_meta Meta.NonVirtual in
@@ -4128,7 +4131,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
          output ("HX_BEGIN_DEFAULT_FUNC(" ^ func_name ^ "," ^ class_name ^ ")\n");
          output ("HX_BEGIN_DEFAULT_FUNC(" ^ func_name ^ "," ^ class_name ^ ")\n");
          output return_type;
          output return_type;
          output (" _hx_run(" ^ (ctx_arg_list ctx function_def.tf_args "__o_") ^ ")");
          output (" _hx_run(" ^ (ctx_arg_list ctx function_def.tf_args "__o_") ^ ")");
-         gen_cpp_function_body ctx class_def is_static func_name function_def "" "";
+         gen_cpp_function_body ctx class_def is_static func_name function_def "" "" no_debug;
 
 
          output ("HX_END_LOCAL_FUNC" ^ nargs ^ "(" ^ ret ^ ")\n");
          output ("HX_END_LOCAL_FUNC" ^ nargs ^ "(" ^ ret ^ ")\n");
          output ("HX_END_DEFAULT_FUNC\n\n");
          output ("HX_END_DEFAULT_FUNC\n\n");
@@ -5355,7 +5358,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
             if has_meta_key definition.cf_meta Meta.NoDebug then
             if has_meta_key definition.cf_meta Meta.NoDebug then
                ctx.ctx_debug_level <- 0;
                ctx.ctx_debug_level <- 0;
             ctx.ctx_real_this_ptr <- false;
             ctx.ctx_real_this_ptr <- false;
-            gen_cpp_function_body ctx class_def false "new" function_def "" "";
+            gen_cpp_function_body ctx class_def false "new" function_def "" "" (has_meta_key definition.cf_meta Meta.NoDebug);
             out "\n";
             out "\n";
 
 
             ctx.ctx_debug_level <- old_debug;
             ctx.ctx_debug_level <- old_debug;
@@ -5419,7 +5422,7 @@ let generate_class_files baseCtx super_deps constructor_deps class_def inScripta
             if has_meta_key definition.cf_meta Meta.NoDebug then
             if has_meta_key definition.cf_meta Meta.NoDebug then
                ctx.ctx_debug_level <- 0;
                ctx.ctx_debug_level <- 0;
 
 
-            gen_cpp_function_body ctx class_def false "new" function_def "" "";
+            gen_cpp_function_body ctx class_def false "new" function_def "" "" (has_meta_key definition.cf_meta Meta.NoDebug);
             output_cpp "\n";
             output_cpp "\n";
 
 
             ctx.ctx_debug_level <- old_debug;
             ctx.ctx_debug_level <- old_debug;

+ 5 - 1
std/cpp/Lib.hx

@@ -81,7 +81,11 @@ class Lib {
 		return null;
 		return null;
 	}
 	}
 
 
-	public static function rethrow(inExp:Dynamic) { throw inExp; }
+	@:extern  @:noDebug @:native("HX_STACK_DO_RETHROW")
+	static function do_rethrow(inExp:Dynamic) { throw inExp; }
+
+	@:noDebug #if(!cppia) inline #end
+	public static function rethrow(inExp:Dynamic) { do_rethrow(inExp); }
 
 
 	public static function stringReference(inBytes:haxe.io.Bytes) : String
 	public static function stringReference(inBytes:haxe.io.Bytes) : String
 	{
 	{

+ 2 - 2
std/haxe/CallStack.hx

@@ -152,7 +152,7 @@ class CallStack {
 		the place the last exception was thrown and the place it was
 		the place the last exception was thrown and the place it was
 		caught, or an empty array if not available.
 		caught, or an empty array if not available.
 	**/
 	**/
-	#if cpp @:noStack #end /* Do not mess up the exception stack */
+	#if cpp @:noDebug #end /* Do not mess up the exception stack */
 	public static function exceptionStack() : Array<StackItem> {
 	public static function exceptionStack() : Array<StackItem> {
 		#if neko
 		#if neko
 			return makeStack(untyped __dollar__excstack());
 			return makeStack(untyped __dollar__excstack());
@@ -256,7 +256,7 @@ class CallStack {
 		}
 		}
 	}
 	}
 
 
-	#if cpp @:noStack #end /* Do not mess up the exception stack */
+	#if cpp @:noDebug #end /* Do not mess up the exception stack */
 	private static function makeStack(s #if cs : cs.system.diagnostics.StackTrace #elseif hl : hl.NativeArray<hl.Bytes> #end) {
 	private static function makeStack(s #if cs : cs.system.diagnostics.StackTrace #elseif hl : hl.NativeArray<hl.Bytes> #end) {
 		#if neko
 		#if neko
 			var a = new Array();
 			var a = new Array();