From: Ben Iofel Date: Thu, 28 Jan 2016 03:09:43 +0000 (-0500) Subject: codegen: add code for [Profile] missed in cf193ab75 X-Git-Tag: 0.31.1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80126f2ad9b03ff500e23e39952fd3bed3c8adf8;p=thirdparty%2Fvala.git codegen: add code for [Profile] missed in cf193ab75 --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 78e52dc07..cda89128c 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -3700,14 +3700,20 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { } } + // TODO: don't duplicate the code in CCodeMethodModule, we do this right now because it needs to be before return if (current_method != null && current_method.get_attribute ("Profile") != null) { string prefix = "_vala_prof_%s".printf (get_ccode_real_name (current_method)); + var level = new CCodeIdentifier (prefix + "_level"); + ccode.open_if (new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, new CCodeUnaryExpression (CCodeUnaryOperator.PREFIX_DECREMENT, level))); + var timer = new CCodeIdentifier (prefix + "_timer"); var stop_call = new CCodeFunctionCall (new CCodeIdentifier ("g_timer_stop")); stop_call.add_argument (timer); ccode.add_expression (stop_call); + + ccode.close (); } if (is_in_constructor ()) { diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index dc70a58c4..710bc1151 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -696,7 +696,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { m.body.emit (this); } - if (profile) { + // we generate the same code if we see a return statement, this handles the case without returns + if (profile && m.return_type is VoidType) { string prefix = "_vala_prof_%s".printf (real_name); var level = new CCodeIdentifier (prefix + "_level");