vala r897 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r897 - in trunk: . gobject vala
- Date: Wed, 23 Jan 2008 18:58:38 +0000 (GMT)
Author: juergbi
Date: Wed Jan 23 18:58:37 2008
New Revision: 897
URL: http://svn.gnome.org/viewvc/vala?rev=897&view=rev
Log:
2008-01-23 Juerg Billeter <j bitron ch>
* vala/valamethodtype.vala, vala/valasemanticanalyzer.vala,
vala/valasignaltype.vala, gobject/valaccodegenerator.vala,
gobject/valaccodegeneratormemberaccess.vala: improve generic type
resolution to support generic fields, fixes bug 475524
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/gobject/valaccodegeneratormemberaccess.vala
trunk/vala/valamethodtype.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasignaltype.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Wed Jan 23 18:58:37 2008
@@ -2923,6 +2923,8 @@
cconv.add_argument (cexpr);
result = cconv;
}
+ } else if (actual_type.data_type != null && actual_type.data_type.is_reference_type ()) {
+ result = new CCodeCastExpression (cexpr, actual_type.get_cname ());
}
return result;
}
Modified: trunk/gobject/valaccodegeneratormemberaccess.vala
==============================================================================
--- trunk/gobject/valaccodegeneratormemberaccess.vala (original)
+++ trunk/gobject/valaccodegeneratormemberaccess.vala Wed Jan 23 18:58:37 2008
@@ -1,6 +1,6 @@
/* valaccodegeneratormemberaccess.vala
*
- * Copyright (C) 2006-2007 JÃrg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2008 JÃrg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -96,6 +96,10 @@
} else {
expr.ccodenode = new CCodeIdentifier (f.get_cname ());
}
+
+ if (f.type_reference.type_parameter != null && expr.static_type.type_parameter == null) {
+ expr.ccodenode = convert_from_generic_pointer ((CCodeExpression) expr.ccodenode, expr.static_type);
+ }
} else if (expr.symbol_reference is Constant) {
var c = (Constant) expr.symbol_reference;
expr.ccodenode = new CCodeIdentifier (c.get_cname ());
Modified: trunk/vala/valamethodtype.vala
==============================================================================
--- trunk/vala/valamethodtype.vala (original)
+++ trunk/vala/valamethodtype.vala Wed Jan 23 18:58:37 2008
@@ -1,6 +1,6 @@
/* valamethodtype.vala
*
- * Copyright (C) 2007 JÃrg Billeter
+ * Copyright (C) 2007-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,4 +43,8 @@
public override Collection<FormalParameter> get_parameters () {
return method_symbol.get_parameters ();
}
+
+ public override DataType! copy () {
+ return new MethodType (method_symbol);
+ }
}
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Wed Jan 23 18:58:37 2008
@@ -1511,6 +1511,16 @@
// no static type for prototype access
} else {
expr.static_type = get_static_type_for_symbol (expr.symbol_reference);
+
+ // resolve generic return values
+ if (expr.static_type != null && expr.static_type.type_parameter != null) {
+ if (expr.inner != null) {
+ expr.static_type = get_actual_type (expr.inner.static_type, expr.symbol_reference, expr.static_type, expr);
+ if (expr.static_type == null) {
+ return;
+ }
+ }
+ }
}
current_source_file.add_symbol_dependency (expr.symbol_reference, SourceFileDependencyType.SOURCE);
@@ -1767,6 +1777,12 @@
public static DataType get_actual_type (DataType derived_instance_type, Symbol generic_member, DataType generic_type, CodeNode node_reference) {
DataType instance_type = derived_instance_type;
+
+ while (instance_type is PointerType) {
+ var instance_pointer_type = (PointerType) instance_type;
+ instance_type = instance_pointer_type.base_type;
+ }
+
// trace type arguments back to the datatype where the method has been declared
while (instance_type.data_type != generic_member.parent_symbol) {
DataType instance_base_type = null;
@@ -1795,6 +1811,14 @@
}
}
}
+ } else if (instance_type.data_type is Struct) {
+ var st = (Struct) instance_type.data_type;
+ foreach (DataType base_type in st.get_base_types ()) {
+ if (base_type.data_type.scope.lookup (generic_member.name) == generic_member) {
+ instance_base_type = get_instance_base_type (instance_type, base_type, node_reference);
+ break;
+ }
+ }
} else if (instance_type.data_type is Interface) {
var iface = (Interface) instance_type.data_type;
// first check interface prerequisites recursively
@@ -1824,9 +1848,16 @@
}
if (instance_base_type == null) {
+ Report.error (node_reference.source_reference, "internal error: unable to find generic member `%s'".printf (generic_member.name));
+ node_reference.error = true;
return null;
}
instance_type = instance_base_type;
+
+ while (instance_type is PointerType) {
+ var instance_pointer_type = (PointerType) instance_type;
+ instance_type = instance_pointer_type.base_type;
+ }
}
if (instance_type.data_type != generic_member.parent_symbol) {
Report.error (node_reference.source_reference, "internal error: generic type parameter tracing not supported yet");
Modified: trunk/vala/valasignaltype.vala
==============================================================================
--- trunk/vala/valasignaltype.vala (original)
+++ trunk/vala/valasignaltype.vala Wed Jan 23 18:58:37 2008
@@ -1,6 +1,6 @@
/* valasignaltype.vala
*
- * Copyright (C) 2007 JÃrg Billeter
+ * Copyright (C) 2007-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,4 +43,8 @@
public override Collection<FormalParameter> get_parameters () {
return signal_symbol.get_parameters ();
}
+
+ public override DataType! copy () {
+ return new SignalType (signal_symbol);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]