[vala] codegen: add code for [Profile] missed in cf193ab75



commit 80126f2ad9b03ff500e23e39952fd3bed3c8adf8
Author: Ben Iofel <iofelben gmail com>
Date:   Wed Jan 27 22:09:43 2016 -0500

    codegen: add code for [Profile] missed in cf193ab75

 codegen/valaccodebasemodule.vala   |    6 ++++++
 codegen/valaccodemethodmodule.vala |    3 ++-
 2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 78e52dc..cda8912 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 dc70a58..710bc11 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");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]