From: Jürg Billeter Date: Wed, 23 Aug 2006 13:12:39 +0000 (+0000) Subject: support calling non-abstract interface methods add get_base_types method X-Git-Tag: VALA_0_0_4~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5dc789bad385a23d04fe403aeaecb438f9595df4;p=thirdparty%2Fvala.git support calling non-abstract interface methods add get_base_types method 2006-08-23 Jürg Billeter * vala/valasemanticanalyzer.vala: support calling non-abstract interface methods * vala/valainterface.vala: add get_base_types method svn path=/trunk/; revision=111 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index 505773bf4..75b1dba64 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,9 @@ +2006-08-23 Jürg Billeter + + * vala/valasemanticanalyzer.vala: support calling non-abstract interface + methods + * vala/valainterface.vala: add get_base_types method + 2006-08-20 Jürg Billeter * configure.ac: Post-release version bump, fail if flex or bison not diff --git a/vala/vala/valainterface.vala b/vala/vala/valainterface.vala index f6d46d857..f2ea018fe 100644 --- a/vala/vala/valainterface.vala +++ b/vala/vala/valainterface.vala @@ -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 get_base_types () { + return base_types.copy (); + } /** * Adds the specified method as a member to this interface. diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index fb818dfb6..242198e11 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -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) {