switch return statement to external visitor
authorJuerg Billeter <j@bitron.ch>
Mon, 17 Sep 2007 18:28:38 +0000 (18:28 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 17 Sep 2007 18:28:38 +0000 (18:28 +0000)
2007-09-17  Juerg Billeter  <j@bitron.ch>

* vala/valacodevisitor.vala, vala/valamemorymanager.vala,
  vala/valareturnstatement.vala, vala/valasemanticanalyzer.vala,
  vala/valasymbolresolver.vala, gobject/valacodegenerator.vala: switch
  return statement to external visitor

svn path=/trunk/; revision=613

ChangeLog
gobject/valacodegenerator.vala
vala/valacodevisitor.vala
vala/valamemorymanager.vala
vala/valareturnstatement.vala
vala/valasemanticanalyzer.vala
vala/valasymbolresolver.vala

index 1923499..7a3f211 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-09-17  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valacodevisitor.vala, vala/valamemorymanager.vala,
+         vala/valareturnstatement.vala, vala/valasemanticanalyzer.vala,
+         vala/valasymbolresolver.vala, gobject/valacodegenerator.vala: switch
+         return statement to external visitor
+
+2007-09-17  Jürg Billeter  <j@bitron.ch>
+
        * vala/valablock.vala, vala/valacodevisitor.vala,
          vala/valaforeachstatement.vala, vala/valamemorymanager.vala,
          vala/valasemanticanalyzer.vala, vala/valaswitchsection.vala,
index 7bcc9d4..0f2815d 100644 (file)
@@ -1799,7 +1799,7 @@ public class Vala.CodeGenerator : CodeVisitor {
                expr.temp_vars.add (return_expr_decl);
        }
 
-       public override void visit_begin_return_statement (ReturnStatement! stmt) {
+       public override void visit_return_statement (ReturnStatement! stmt) {
                if (stmt.return_expression != null) {
                        // avoid unnecessary ref/unref pair
                        if (stmt.return_expression.ref_missing &&
@@ -1816,9 +1816,9 @@ public class Vala.CodeGenerator : CodeVisitor {
                                }
                        }
                }
-       }
 
-       public override void visit_end_return_statement (ReturnStatement! stmt) {
+               stmt.accept_children (this);
+
                if (stmt.return_expression == null) {
                        stmt.ccodenode = new CCodeReturnStatement ();
                        
index 5575285..aff5543 100644 (file)
@@ -348,19 +348,11 @@ public abstract class Vala.CodeVisitor : Object {
        }
 
        /**
-        * Visit operation called at beginning of return statements.
+        * Visit operation called for return statements.
         *
         * @param stmt a return statement
         */
-       public virtual void visit_begin_return_statement (ReturnStatement! stmt) {
-       }
-       
-       /**
-        * Visit operation called at end of return statements.
-        *
-        * @param stmt a return statement
-        */
-       public virtual void visit_end_return_statement (ReturnStatement! stmt) {
+       public virtual void visit_return_statement (ReturnStatement! stmt) {
        }
 
        /**
index 58884d8..f262615 100644 (file)
@@ -157,7 +157,9 @@ public class Vala.MemoryManager : CodeVisitor {
                stmt.accept_children (this);
        }
 
-       public override void visit_end_return_statement (ReturnStatement! stmt) {
+       public override void visit_return_statement (ReturnStatement! stmt) {
+               stmt.accept_children (this);
+
                if (stmt.return_expression != null) {
                        if (current_symbol is Method) {
                                var m = (Method) current_symbol;
index b082450..a588622 100644 (file)
@@ -30,9 +30,7 @@ public class Vala.ReturnStatement : CodeNode, Statement {
         * The optional expression to return.
         */
        public Expression return_expression {
-               get {
-                       return _return_expression;
-               }
+               get { return _return_expression; }
                set {
                        _return_expression = value;
                        if (_return_expression != null) {
@@ -46,25 +44,23 @@ public class Vala.ReturnStatement : CodeNode, Statement {
        /**
         * Creates a new return statement.
         *
-        * @param result the return expression
-        * @param source reference to source code
-        * @return       newly created return statement
+        * @param return_expression the return expression
+        * @param source_reference  reference to source code
+        * @return                  newly created return statement
         */
-       public ReturnStatement (Expression result = null, SourceReference source = null) {
-               return_expression = result;
-               source_reference = source;
+       public ReturnStatement (construct Expression return_expression = null, construct SourceReference source_reference = null) {
        }
-       
+
        public override void accept (CodeVisitor! visitor) {
-               visitor.visit_begin_return_statement (this);
+               visitor.visit_return_statement (this);
+       }
 
+       public override void accept_children (CodeVisitor! visitor) {
                if (return_expression != null) {
                        return_expression.accept (visitor);
                
                        visitor.visit_end_full_expression (return_expression);
                }
-
-               visitor.visit_end_return_statement (this);
        }
 
        public override void replace (CodeNode! old_node, CodeNode! new_node) {
index 004e5f9..1ded40e 100644 (file)
@@ -933,7 +933,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                stmt.tree_can_fail = stmt.collection.tree_can_fail || stmt.body.tree_can_fail;
        }
 
-       public override void visit_end_return_statement (ReturnStatement! stmt) {
+       public override void visit_return_statement (ReturnStatement! stmt) {
+               stmt.accept_children (this);
+
                if (stmt.return_expression != null && stmt.return_expression.error) {
                        // ignore inner error
                        stmt.error = true;
index 24f059e..52dd2d2 100644 (file)
@@ -315,6 +315,10 @@ public class Vala.SymbolResolver : CodeVisitor {
                stmt.accept_children (this);
        }
 
+       public override void visit_return_statement (ReturnStatement! stmt) {
+               stmt.accept_children (this);
+       }
+
        public override void visit_throw_statement (ThrowStatement! stmt) {
                stmt.accept_children (this);
        }