]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
switch invocation expression to external visitor
authorJuerg Billeter <j@bitron.ch>
Mon, 17 Sep 2007 18:35:50 +0000 (18:35 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 17 Sep 2007 18:35:50 +0000 (18:35 +0000)
2007-09-17  Juerg Billeter  <j@bitron.ch>

* vala/valacodevisitor.vala, vala/valainvocationexpression.vala,
  vala/valamemorymanager.vala, vala/valasemanticanalyzer.vala,
  vala/valasymbolresolver.vala,
  gobject/valacodegeneratorinvocationexpression.vala: switch invocation
  expression to external visitor

svn path=/trunk/; revision=614

ChangeLog
gobject/valacodegeneratorinvocationexpression.vala
vala/valacodevisitor.vala
vala/valainvocationexpression.vala
vala/valamemorymanager.vala
vala/valasemanticanalyzer.vala
vala/valasymbolresolver.vala

index 7a3f21148263d72b209fdd0f42347e27e032c893..83beef1c56bb5de8b53282c79eea79f975c9db1b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-17  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valacodevisitor.vala, vala/valainvocationexpression.vala,
+         vala/valamemorymanager.vala, vala/valasemanticanalyzer.vala,
+         vala/valasymbolresolver.vala,
+         gobject/valacodegeneratorinvocationexpression.vala: switch invocation
+         expression to external visitor
+
 2007-09-17  Jürg Billeter  <j@bitron.ch>
 
        * vala/valacodevisitor.vala, vala/valamemorymanager.vala,
index 3f6e2f4bc4caec5812f826e2f42699ca38810a8f..218418183308f0f4c3cb8f688904bf63870eebe5 100644 (file)
@@ -25,7 +25,9 @@ using GLib;
 using Gee;
 
 public class Vala.CodeGenerator {
-       public override void visit_end_invocation_expression (InvocationExpression! expr) {
+       public override void visit_invocation_expression (InvocationExpression! expr) {
+               expr.accept_children (this);
+
                var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
                
                Method m = null;
index aff554391d89d6b19578ac45b224dedc5b56d5a1..a5520331075cee8250e5977d7f8f932063ea6630 100644 (file)
@@ -468,19 +468,11 @@ public abstract class Vala.CodeVisitor : Object {
        }
 
        /**
-        * Visit operation called at beginning of invocation expressions.
+        * Visit operation called for invocation expressions.
         *
         * @param expr an invocation expression
         */
-       public virtual void visit_begin_invocation_expression (InvocationExpression! expr) {
-       }
-
-       /**
-        * Visit operation called at end of invocation expressions.
-        *
-        * @param expr an invocation expression
-        */
-       public virtual void visit_end_invocation_expression (InvocationExpression! expr) {
+       public virtual void visit_invocation_expression (InvocationExpression! expr) {
        }
        
        /**
index be8d6a37ceffe575b145226037d28c5582d327e2..57250a19acc58c12527fc492e99ff7ff46df7318 100644 (file)
@@ -31,9 +31,7 @@ public class Vala.InvocationExpression : Expression {
         * The method to call.
         */
        public Expression! call {
-               get {
-                       return _call;
-               }
+               get { return _call; }
                set construct {
                        _call = value;
                        _call.parent_node = this;
@@ -90,15 +88,15 @@ public class Vala.InvocationExpression : Expression {
        }
 
        public override void accept (CodeVisitor! visitor) {
-               call.accept (visitor);
+               visitor.visit_invocation_expression (this);
+       }
 
-               visitor.visit_begin_invocation_expression (this);
+       public override void accept_children (CodeVisitor! visitor) {
+               call.accept (visitor);
 
                foreach (Expression expr in argument_list) {
                        expr.accept (visitor);
                }
-
-               visitor.visit_end_invocation_expression (this);
        }
 
        public override void replace (CodeNode! old_node, CodeNode! new_node) {
index f26261501d84e756d56311012a9a0b7deecd2bce..4b62463883691d43cdc049d2ef37d16f6f3ce399 100644 (file)
@@ -202,7 +202,9 @@ public class Vala.MemoryManager : CodeVisitor {
                }
        }
 
-       public override void visit_end_invocation_expression (InvocationExpression! expr) {
+       public override void visit_invocation_expression (InvocationExpression! expr) {
+               expr.accept_children (this);
+
                var msym = (Invokable) expr.call.symbol_reference;
                Collection<FormalParameter> params = msym.get_parameters ();
 
index 1ded40e98ef1bcf0de31a745c80b85f950c3fa6f..46fec8b42ec9c89f971f13726e143c90eca49871 100644 (file)
@@ -1470,7 +1470,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return expression_type.data_type.is_subtype_of (expected_type.data_type);
        }
 
-       public override void visit_begin_invocation_expression (InvocationExpression! expr) {
+       public override void visit_invocation_expression (InvocationExpression! expr) {
+               expr.call.accept (this);
+
                if (expr.call.error) {
                        /* if method resolving didn't succeed, skip this check */
                        expr.error = true;
@@ -1525,6 +1527,57 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                arg.expected_type = param.type_reference;
                        }
                }
+
+               foreach (Expression arg in expr.get_argument_list ()) {
+                       arg.accept (this);
+               }
+
+               TypeReference ret_type;
+
+               if (msym is Invokable) {
+                       var m = (Invokable) msym;
+                       ret_type = m.get_return_type ();
+                       params = m.get_parameters ();
+
+                       if (ret_type.data_type == null && ret_type.type_parameter == null) {
+                               // void return type
+                               if (!(expr.parent_node is ExpressionStatement)) {
+                                       expr.error = true;
+                                       Report.error (expr.source_reference, "invocation of void method not allowed as expression");
+                                       return;
+                               }
+                       }
+
+                       // resolve generic return values
+                       if (ret_type.type_parameter != null) {
+                               if (!(expr.call is MemberAccess)) {
+                                       Report.error (((CodeNode) m).source_reference, "internal error: unsupported generic return value");
+                                       expr.error = true;
+                                       return;
+                               }
+                               var ma = (MemberAccess) expr.call;
+                               if (ma.inner == null) {
+                                       // TODO resolve generic return values within the type hierarchy if possible
+                                       Report.error (expr.source_reference, "internal error: resolving generic return values within type hierarchy not supported yet");
+                                       expr.error = true;
+                                       return;
+                               } else {
+                                       ret_type = get_actual_type (ma.inner.static_type, msym, ret_type, expr);
+                                       if (ret_type == null) {
+                                               return;
+                                       }
+                               }
+                       }
+               }
+
+               if (msym is Method) {
+                       var m = (Method) msym;
+                       expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().size > 0);
+               }
+
+               expr.static_type = ret_type;
+
+               check_arguments (expr, msym, params, expr.get_argument_list ());
        }
 
        private bool check_arguments (Expression! expr, Symbol! msym, Collection<FormalParameter> params, Collection<Expression> args) {
@@ -1612,62 +1665,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                return true;
        }
 
-       public override void visit_end_invocation_expression (InvocationExpression! expr) {
-               if (expr.error) {
-                       return;
-               }
-
-               var msym = expr.call.symbol_reference;
-
-               TypeReference ret_type;
-               Collection<FormalParameter> params;
-
-               if (msym is Invokable) {
-                       var m = (Invokable) msym;
-                       ret_type = m.get_return_type ();
-                       params = m.get_parameters ();
-
-                       if (ret_type.data_type == null && ret_type.type_parameter == null) {
-                               // void return type
-                               if (!(expr.parent_node is ExpressionStatement)) {
-                                       expr.error = true;
-                                       Report.error (expr.source_reference, "invocation of void method not allowed as expression");
-                                       return;
-                               }
-                       }
-
-                       // resolve generic return values
-                       if (ret_type.type_parameter != null) {
-                               if (!(expr.call is MemberAccess)) {
-                                       Report.error (((CodeNode) m).source_reference, "internal error: unsupported generic return value");
-                                       expr.error = true;
-                                       return;
-                               }
-                               var ma = (MemberAccess) expr.call;
-                               if (ma.inner == null) {
-                                       // TODO resolve generic return values within the type hierarchy if possible
-                                       Report.error (expr.source_reference, "internal error: resolving generic return values within type hierarchy not supported yet");
-                                       expr.error = true;
-                                       return;
-                               } else {
-                                       ret_type = get_actual_type (ma.inner.static_type, msym, ret_type, expr);
-                                       if (ret_type == null) {
-                                               return;
-                                       }
-                               }
-                       }
-               }
-
-               if (msym is Method) {
-                       var m = (Method) msym;
-                       expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().size > 0);
-               }
-
-               expr.static_type = ret_type;
-
-               check_arguments (expr, msym, params, expr.get_argument_list ());
-       }
-
        public static TypeReference get_actual_type (TypeReference derived_instance_type, Symbol generic_member, TypeReference generic_type, CodeNode node_reference) {
                TypeReference instance_type = derived_instance_type;
                // trace type arguments back to the datatype where the method has been declared
index 52dd2d2e6af3eb6ea9afdd50b55c5fbbe4fed508..0d10e1668a46912df202ff55c15c1fa88752ee92 100644 (file)
@@ -335,6 +335,10 @@ public class Vala.SymbolResolver : CodeVisitor {
                e.accept_children (this);
        }
 
+       public override void visit_invocation_expression (InvocationExpression! expr) {
+               expr.accept_children (this);
+       }
+
        public override void visit_assignment (Assignment! a) {
                a.accept_children (this);
        }