]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: add code for [Profile] missed in cf193ab75
authorBen Iofel <iofelben@gmail.com>
Thu, 28 Jan 2016 03:09:43 +0000 (22:09 -0500)
committerBen Iofel <iofelben@gmail.com>
Thu, 28 Jan 2016 03:34:01 +0000 (22:34 -0500)
codegen/valaccodebasemodule.vala
codegen/valaccodemethodmodule.vala

index 78e52dc07937c7e86c3abb956153876b0e1bacf5..cda89128ce047edace1624050ca1372fa5928fe1 100644 (file)
@@ -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 ()) {
index dc70a58c4452df856a2c0e639954e06c4829be7e..710bc11519cc7a31f8421596eb82737015539785 100644 (file)
@@ -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");