Commit 5dc789ba authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

support calling non-abstract interface methods add get_base_types method

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
parent 1c237263
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
......
......@@ -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.
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment