]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
support calling non-abstract interface methods add get_base_types method
authorJürg Billeter <j@bitron.ch>
Wed, 23 Aug 2006 13:12:39 +0000 (13:12 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 23 Aug 2006 13:12:39 +0000 (13:12 +0000)
2006-08-23  Jürg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala: support calling non-abstract interface
  methods
* vala/valainterface.vala: add get_base_types method

svn path=/trunk/; revision=111

vala/ChangeLog
vala/vala/valainterface.vala
vala/vala/valasemanticanalyzer.vala

index 505773bf4bed9112a787338baa4e7e8e1bab5110..75b1dba64442e98e89f0bc35dcf477020c19457d 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-23  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valasemanticanalyzer.vala: support calling non-abstract interface
+         methods
+       * vala/valainterface.vala: add get_base_types method
+
 2006-08-20  Jürg Billeter  <j@bitron.ch>
 
        * configure.ac: Post-release version bump, fail if flex or bison not
index f6d46d857724e943c78307def67ae5eeabbded4c..f2ea018fec7934b4316521d1ec488771bb9219aa 100644 (file)
@@ -65,6 +65,15 @@ public class Vala.Interface : DataType {
        public void add_base_type (TypeReference! type) {
                base_types.append (type);
        }
+
+       /**
+        * Returns a copy of the base type list.
+        *
+        * @return list of base types
+        */
+       public ref List<TypeReference> get_base_types () {
+               return base_types.copy ();
+       }
        
        /**
         * Adds the specified method as a member to this interface.
index fb818dfb6655bf7e201e0714e312b8da6879f59e..242198e11b46b3af92ca39d92ba68b348fe0b07e 100644 (file)
@@ -172,7 +172,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                current_symbol = current_symbol.parent_symbol;
                current_return_type = null;
 
-               if (current_symbol.parent_symbol.node is Method) {
+               if (current_symbol.parent_symbol != null &&
+                   current_symbol.parent_symbol.node is Method) {
                        /* lambda expressions produce nested methods */
                        var up_method = (Method) current_symbol.parent_symbol.node;
                        current_return_type = up_method.return_type;
@@ -657,13 +658,29 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
        
        Symbol symbol_lookup_inherited (Symbol! sym, string! name) {
                var result = sym.lookup (name);
-               if (result == null && sym.node is Class) {
+               if (result != null) {
+                       return result;
+               }
+
+               if (sym.node is Class) {
                        var cl = (Class) sym.node;
-                       for (cl = cl.base_class; cl != null && result == null; cl = cl.base_class) {
-                               result = cl.symbol.lookup (name);
+                       foreach (TypeReference base_type in cl.get_base_types ()) {
+                               result = symbol_lookup_inherited (base_type.data_type.symbol, name);
+                               if (result != null) {
+                                       return result;
+                               }
+                       }
+               } else if (sym.node is Interface) {
+                       var iface = (Interface) sym.node;
+                       foreach (TypeReference base_type in iface.get_base_types ()) {
+                               result = symbol_lookup_inherited (base_type.data_type.symbol, name);
+                               if (result != null) {
+                                       return result;
+                               }
                        }
                }
-               return result;
+
+               return null;
        }
 
        public override void visit_parenthesized_expression (ParenthesizedExpression! expr) {