vala r2066 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2066 - in trunk: . gobject vala
- Date: Fri, 28 Nov 2008 09:55:10 +0000 (UTC)
Author: juergbi
Date: Fri Nov 28 09:55:10 2008
New Revision: 2066
URL: http://svn.gnome.org/viewvc/vala?rev=2066&view=rev
Log:
2008-11-28 JÃrg Billeter <j bitron ch>
* vala/valabinaryexpression.vala:
* vala/valaelementaccess.vala:
* vala/valaforeachstatement.vala:
* vala/valamemberaccess.vala:
* vala/valamethodcall.vala:
* vala/valasemanticanalyzer.vala:
* gobject/valaccodearraymodule.vala:
* gobject/valaccodeassignmentmodule.vala:
* gobject/valaccodecontrolflowmodule.vala:
Improve get_actual_type signature
Modified:
trunk/ChangeLog
trunk/gobject/valaccodearraymodule.vala
trunk/gobject/valaccodeassignmentmodule.vala
trunk/gobject/valaccodecontrolflowmodule.vala
trunk/vala/valabinaryexpression.vala
trunk/vala/valaelementaccess.vala
trunk/vala/valaforeachstatement.vala
trunk/vala/valamemberaccess.vala
trunk/vala/valamethodcall.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/gobject/valaccodearraymodule.vala
==============================================================================
--- trunk/gobject/valaccodearraymodule.vala (original)
+++ trunk/gobject/valaccodearraymodule.vala Fri Nov 28 09:55:10 2008
@@ -270,8 +270,8 @@
get_params_it.next ();
var get_param = get_params_it.get ();
- if (get_param.parameter_type.type_parameter != null) {
- var index_type = SemanticAnalyzer.get_actual_type (expr.container.value_type, get_method, get_param.parameter_type, expr);
+ if (get_param.parameter_type is GenericType) {
+ var index_type = SemanticAnalyzer.get_actual_type (expr.container.value_type, (GenericType) get_param.parameter_type, expr);
cindex = convert_to_generic_pointer (cindex, index_type);
}
Modified: trunk/gobject/valaccodeassignmentmodule.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentmodule.vala (original)
+++ trunk/gobject/valaccodeassignmentmodule.vala Fri Nov 28 09:55:10 2008
@@ -119,8 +119,8 @@
set_params_it.next ();
var set_param = set_params_it.get ();
- if (set_param.parameter_type.type_parameter != null) {
- var index_type = SemanticAnalyzer.get_actual_type (expr.container.value_type, set_method, set_param.parameter_type, assignment);
+ if (set_param.parameter_type is GenericType) {
+ var index_type = SemanticAnalyzer.get_actual_type (expr.container.value_type, (GenericType) set_param.parameter_type, assignment);
cindex = convert_to_generic_pointer (cindex, index_type);
}
Modified: trunk/gobject/valaccodecontrolflowmodule.vala
==============================================================================
--- trunk/gobject/valaccodecontrolflowmodule.vala (original)
+++ trunk/gobject/valaccodecontrolflowmodule.vala Fri Nov 28 09:55:10 2008
@@ -470,7 +470,7 @@
get_ccall.add_argument (new CCodeIdentifier (it_name));
CCodeExpression element_expr = get_ccall;
- var element_type = SemanticAnalyzer.get_actual_type (stmt.collection.value_type, get_method, get_method.return_type, stmt);
+ var element_type = SemanticAnalyzer.get_actual_type (stmt.collection.value_type, (GenericType) get_method.return_type, stmt);
element_expr = transform_expression (element_expr, element_type, stmt.type_reference);
@@ -520,7 +520,7 @@
Iterator<DataType> type_arg_it = it_method.return_type.get_type_arguments ().iterator ();
type_arg_it.next ();
- var it_type = SemanticAnalyzer.get_actual_type (stmt.collection.value_type, it_method, type_arg_it.get (), stmt);
+ var it_type = SemanticAnalyzer.get_actual_type (stmt.collection.value_type, (GenericType) type_arg_it.get (), stmt);
element_expr = transform_expression (element_expr, it_type, stmt.type_reference);
Modified: trunk/vala/valabinaryexpression.vala
==============================================================================
--- trunk/vala/valabinaryexpression.vala (original)
+++ trunk/vala/valabinaryexpression.vala Fri Nov 28 09:55:10 2008
@@ -288,7 +288,7 @@
contains_params_it.next ();
var contains_param = contains_params_it.get ();
- var key_type = analyzer.get_actual_type (right.value_type, contains_method, contains_param.parameter_type, this);
+ var key_type = analyzer.get_actual_type (right.value_type, (GenericType) contains_param.parameter_type, this);
left.target_type = key_type;
}
Modified: trunk/vala/valaelementaccess.vala
==============================================================================
--- trunk/vala/valaelementaccess.vala (original)
+++ trunk/vala/valaelementaccess.vala Fri Nov 28 09:55:10 2008
@@ -165,8 +165,8 @@
var get_param = get_params_it.get ();
var index_type = get_param.parameter_type;
- if (index_type.type_parameter != null) {
- index_type = analyzer.get_actual_type (container.value_type, get_method, get_param.parameter_type, this);
+ if (index_type is GenericType) {
+ index_type = analyzer.get_actual_type (container.value_type, (GenericType) index_type, this);
}
if (!index.value_type.compatible (index_type)) {
@@ -175,7 +175,7 @@
return false;
}
- value_type = analyzer.get_actual_type (container.value_type, get_method, get_method.return_type, this).copy ();
+ value_type = analyzer.get_actual_type (container.value_type, (GenericType) get_method.return_type, this).copy ();
if (lvalue) {
// get () returns owned value, set () accepts unowned value
value_type.value_owned = false;
Modified: trunk/vala/valaforeachstatement.vala
==============================================================================
--- trunk/vala/valaforeachstatement.vala (original)
+++ trunk/vala/valaforeachstatement.vala Fri Nov 28 09:55:10 2008
@@ -183,8 +183,8 @@
var it_method = (Method) analyzer.iterable_type.data_type.scope.lookup ("iterator");
if (it_method.return_type.get_type_arguments ().size > 0) {
var type_arg = it_method.return_type.get_type_arguments ().get (0);
- if (type_arg.type_parameter != null) {
- element_data_type = SemanticAnalyzer.get_actual_type (collection_type, it_method, type_arg, this);
+ if (type_arg is GenericType) {
+ element_data_type = SemanticAnalyzer.get_actual_type (collection_type, (GenericType) type_arg, this);
} else {
element_data_type = type_arg;
}
Modified: trunk/vala/valamemberaccess.vala
==============================================================================
--- trunk/vala/valamemberaccess.vala (original)
+++ trunk/vala/valamemberaccess.vala Fri Nov 28 09:55:10 2008
@@ -490,9 +490,9 @@
value_type = analyzer.get_value_type_for_symbol (symbol_reference, lvalue);
// resolve generic return values
- if (value_type != null && value_type.type_parameter != null) {
+ if (value_type is GenericType) {
if (inner != null) {
- value_type = analyzer.get_actual_type (inner.value_type, symbol_reference, value_type, this);
+ value_type = analyzer.get_actual_type (inner.value_type, (GenericType) value_type, this);
if (value_type == null) {
return false;
}
Modified: trunk/vala/valamethodcall.vala
==============================================================================
--- trunk/vala/valamethodcall.vala (original)
+++ trunk/vala/valamethodcall.vala Fri Nov 28 09:55:10 2008
@@ -224,9 +224,9 @@
// resolve generic type parameters
var ma = call as MemberAccess;
- if (arg.target_type.type_parameter != null) {
+ if (arg.target_type is GenericType) {
if (ma != null && ma.inner != null) {
- arg.target_type = analyzer.get_actual_type (ma.inner.value_type, ma.symbol_reference, arg.target_type, arg);
+ arg.target_type = analyzer.get_actual_type (ma.inner.value_type, (GenericType) arg.target_type, arg);
assert (arg.target_type != null);
}
}
@@ -393,9 +393,9 @@
// resolve generic return values
var ma = call as MemberAccess;
- if (ret_type.type_parameter != null) {
+ if (ret_type is GenericType) {
if (ma != null && ma.inner != null) {
- ret_type = analyzer.get_actual_type (ma.inner.value_type, ma.symbol_reference, ret_type, this);
+ ret_type = analyzer.get_actual_type (ma.inner.value_type, (GenericType) ret_type, this);
if (ret_type == null) {
return false;
}
@@ -403,8 +403,8 @@
}
Gee.List<DataType> resolved_type_args = new ArrayList<DataType> ();
foreach (DataType type_arg in ret_type.get_type_arguments ()) {
- if (type_arg.type_parameter != null && ma != null && ma.inner != null) {
- resolved_type_args.add (analyzer.get_actual_type (ma.inner.value_type, ma.symbol_reference, type_arg, this));
+ if (type_arg is GenericType && ma != null && ma.inner != null) {
+ resolved_type_args.add (analyzer.get_actual_type (ma.inner.value_type, (GenericType) type_arg, this));
} else {
resolved_type_args.add (type_arg);
}
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Fri Nov 28 09:55:10 2008
@@ -474,7 +474,7 @@
return instance_base_type;
}
- static DataType? get_instance_base_type_for_member (DataType derived_instance_type, Symbol member, CodeNode node_reference) {
+ static DataType? get_instance_base_type_for_member (DataType derived_instance_type, TypeSymbol type_symbol, CodeNode node_reference) {
DataType instance_type = derived_instance_type;
while (instance_type is PointerType) {
@@ -482,7 +482,7 @@
instance_type = instance_pointer_type.base_type;
}
- if (instance_type.data_type == member.parent_symbol) {
+ if (instance_type.data_type == type_symbol) {
return instance_type;
}
@@ -495,7 +495,7 @@
// (prerequisites can be assumed to be met already)
foreach (DataType base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
- instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), member, node_reference);
+ instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
@@ -505,7 +505,7 @@
if (instance_base_type == null) {
foreach (DataType base_type in cl.get_base_types ()) {
if (base_type.data_type is Class) {
- instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), member, node_reference);
+ instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
@@ -515,7 +515,7 @@
} else if (instance_type.data_type is Struct) {
var st = (Struct) instance_type.data_type;
foreach (DataType base_type in st.get_base_types ()) {
- instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), member, node_reference);
+ instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
@@ -525,7 +525,7 @@
// first check interface prerequisites recursively
foreach (DataType prerequisite in iface.get_prerequisites ()) {
if (prerequisite.data_type is Interface) {
- instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, prerequisite, node_reference), member, node_reference);
+ instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, prerequisite, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
@@ -535,7 +535,7 @@
// then check class prerequisite recursively
foreach (DataType prerequisite in iface.get_prerequisites ()) {
if (prerequisite.data_type is Class) {
- instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, prerequisite, node_reference), member, node_reference);
+ instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, prerequisite, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
@@ -547,15 +547,11 @@
return null;
}
- public static DataType? get_actual_type (DataType derived_instance_type, Symbol generic_member, DataType generic_type, CodeNode node_reference) {
+ public static DataType? get_actual_type (DataType derived_instance_type, GenericType generic_type, CodeNode node_reference) {
// trace type arguments back to the datatype where the method has been declared
- var instance_type = get_instance_base_type_for_member (derived_instance_type, generic_member, node_reference);
+ var instance_type = get_instance_base_type_for_member (derived_instance_type, (TypeSymbol) generic_type.type_parameter.parent_symbol, node_reference);
- if (instance_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;
- }
+ assert (instance_type != null);
int param_index = instance_type.data_type.get_type_parameter_index (generic_type.type_parameter.name);
if (param_index == -1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]