vala r906 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r906 - in trunk: . gobject vala
- Date: Thu, 24 Jan 2008 15:27:09 +0000 (GMT)
Author: juergbi
Date: Thu Jan 24 15:27:08 2008
New Revision: 906
URL: http://svn.gnome.org/viewvc/vala?rev=906&view=rev
Log:
2008-01-24 Juerg Billeter <j bitron ch>
* vala/valaarraytype.vala, vala/valadatatype.vala,
vala/valainterfacewriter.vala, vala/valanulltype.vala,
vala/valasemanticanalyzer.vala, vala/valasymbolresolver.vala,
gobject/valaccodeassignmentbinding.vala,
gobject/valaccodegenerator.vala,
gobject/valaccodegeneratorinvocationexpression.vala,
gobject/valaccodegeneratormethod.vala,
gobject/valaccodegeneratorsignal.vala: use ArrayType class
Modified:
trunk/ChangeLog
trunk/gobject/valaccodeassignmentbinding.vala
trunk/gobject/valaccodegenerator.vala
trunk/gobject/valaccodegeneratorinvocationexpression.vala
trunk/gobject/valaccodegeneratormethod.vala
trunk/gobject/valaccodegeneratorsignal.vala
trunk/vala/valaarraytype.vala
trunk/vala/valadatatype.vala
trunk/vala/valainterfacewriter.vala
trunk/vala/valanulltype.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasymbolresolver.vala
Modified: trunk/gobject/valaccodeassignmentbinding.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentbinding.vala (original)
+++ trunk/gobject/valaccodeassignmentbinding.vala Thu Jan 24 15:27:08 2008
@@ -1,6 +1,6 @@
/* valaccodeassignmentbinding.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
@@ -269,11 +269,11 @@
first = false;
continue;
}
- if (param.type_reference.data_type is Array && ((Array) param.type_reference.data_type).element_type != codegen.string_type.data_type) {
- var array = (Array) param.type_reference.data_type;
+ if (param.type_reference is ArrayType && ((ArrayType) param.type_reference).element_type.data_type != codegen.string_type.data_type) {
+ var array_type = (ArrayType) param.type_reference;
var carray_type = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_type_get_collection"));
carray_type.add_argument (new CCodeConstant ("\"GArray\""));
- carray_type.add_argument (new CCodeIdentifier (array.element_type.get_type_id ()));
+ carray_type.add_argument (new CCodeIdentifier (array_type.element_type.data_type.get_type_id ()));
register_call.add_argument (carray_type);
add_call.add_argument (carray_type);
} else {
@@ -339,7 +339,7 @@
bool unref_old = (assignment.left.static_type.takes_ownership);
bool array = false;
- if (assignment.left.static_type.data_type is Array) {
+ if (assignment.left.static_type is ArrayType) {
array = !(codegen.get_array_length_cexpression (assignment.left, 1) is CCodeConstant);
}
@@ -355,8 +355,8 @@
}
if (array) {
- var arr = (Array) assignment.left.static_type.data_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ var array_type = (ArrayType) assignment.left.static_type;
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var lhs_array_len = codegen.get_array_length_cexpression (assignment.left, dim);
var rhs_array_len = codegen.get_array_length_cexpression (assignment.right, dim);
ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len));
@@ -419,7 +419,7 @@
emit_property_assignment ();
} else if (assignment.left.symbol_reference is Signal) {
emit_signal_assignment ();
- } else if (assignment.left is ElementAccess && !(((ElementAccess) assignment.left).container.static_type.data_type is Array)) {
+ } else if (assignment.left is ElementAccess && !(((ElementAccess) assignment.left).container.static_type is ArrayType)) {
emit_non_array_element_access ();
} else {
emit_simple_assignment ();
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Thu Jan 24 15:27:08 2008
@@ -353,13 +353,13 @@
public override void visit_constant (Constant! c) {
c.accept_children (this);
- if (!c.is_internal_symbol () && !(c.type_reference.data_type is Array)) {
+ if (!c.is_internal_symbol () && !(c.type_reference is ArrayType)) {
var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
header_type_member_declaration.append (cdefine);
} else {
var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
var arr = "";
- if (c.type_reference.data_type is Array) {
+ if (c.type_reference is ArrayType) {
arr = "[]";
}
cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
@@ -439,11 +439,11 @@
if (f.instance) {
st.add_field (field_ctype, f.get_cname ());
- if (f.type_reference.data_type is Array && !f.no_array_length) {
+ if (f.type_reference is ArrayType && !f.no_array_length) {
// create fields to store array dimensions
- var arr = (Array) f.type_reference.data_type;
+ var array_type = (ArrayType) f.type_reference;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var len_type = int_type.copy ();
st.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
@@ -456,14 +456,14 @@
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (lhs, rhs)));
- if (f.type_reference.data_type is Array && !f.no_array_length &&
+ if (f.type_reference is ArrayType && !f.no_array_length &&
f.initializer is ArrayCreationExpression) {
- var array = (Array) f.type_reference.data_type;
+ var array_type = (ArrayType) f.type_reference;
var ma = new MemberAccess.simple (f.name);
ma.symbol_reference = f;
Gee.List<Expression> sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
- for (int dim = 1; dim <= array.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var array_len_lhs = get_array_length_cexpression (ma, dim);
var size = sizes[dim - 1];
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
@@ -892,11 +892,11 @@
public override void visit_variable_declarator (VariableDeclarator! decl) {
decl.accept_children (this);
- if (decl.type_reference.data_type is Array) {
+ if (decl.type_reference is ArrayType) {
// create variables to store array dimensions
- var arr = (Array) decl.type_reference.data_type;
+ var array_type = (ArrayType) decl.type_reference;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var len_decl = new VariableDeclarator (get_array_length_cname (decl.name, dim));
len_decl.type_reference = int_type.copy ();
@@ -919,8 +919,8 @@
rhs = (CCodeExpression) decl.initializer.ccodenode;
rhs = get_implicit_cast_expression (rhs, decl.initializer.static_type, decl.type_reference);
- if (decl.type_reference.data_type is Array) {
- var arr = (Array) decl.type_reference.data_type;
+ if (decl.type_reference is ArrayType) {
+ var array_type = (ArrayType) decl.type_reference;
var ccomma = new CCodeCommaExpression ();
@@ -928,7 +928,7 @@
temp_vars.insert (0, temp_decl);
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), rhs));
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var lhs_array_len = new CCodeIdentifier (get_array_length_cname (decl.name, dim));
var rhs_array_len = get_array_length_cexpression (decl.initializer, dim);
ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len));
@@ -968,7 +968,7 @@
public override void visit_initializer_list (InitializerList! list) {
list.accept_children (this);
- if (list.expected_type != null && list.expected_type.data_type is Array) {
+ if (list.expected_type is ArrayType) {
/* TODO */
} else {
var clist = new CCodeInitializerList ();
@@ -1109,14 +1109,14 @@
}
} else if (type.data_type == gstring_type) {
ccall.add_argument (new CCodeConstant ("TRUE"));
- } else if (type.data_type is Array) {
- var arr = (Array) type.data_type;
- if (arr.element_type == null || arr.element_type.is_reference_type ()) {
+ } else if (type is ArrayType) {
+ var array_type = (ArrayType) type;
+ if (array_type.element_type.data_type == null || array_type.element_type.data_type.is_reference_type ()) {
requires_array_free = true;
bool first = true;
CCodeExpression csizeexpr = null;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
if (first) {
csizeexpr = get_array_length_cexpression (expr, dim);
first = false;
@@ -1127,10 +1127,7 @@
ccall.call = new CCodeIdentifier ("_vala_array_free");
ccall.add_argument (csizeexpr);
- var element_type = new DataType ();
- element_type.data_type = arr.element_type;
- element_type.type_parameter = arr.element_type_parameter;
- ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (element_type), "GDestroyNotify"));
+ ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (array_type.element_type), "GDestroyNotify"));
}
}
@@ -1566,8 +1563,8 @@
cblock.add_statement (cfrag);
}
- if (stmt.collection.static_type.data_type is Array) {
- var arr = (Array) stmt.collection.static_type.data_type;
+ if (stmt.collection.static_type is ArrayType) {
+ var array_type = (ArrayType) stmt.collection.static_type;
var array_len = get_array_length_cexpression (stmt.collection, 1);
@@ -1583,9 +1580,7 @@
CCodeExpression element_expr = new CCodeIdentifier ("*%s".printf (it_name));
- var element_data_type = new DataType ();
- element_data_type.data_type = arr.element_type;
- element_expr = get_implicit_cast_expression (element_expr, element_data_type, stmt.type_reference);
+ element_expr = get_implicit_cast_expression (element_expr, array_type.element_type, stmt.type_reference);
if (stmt.type_reference.takes_ownership) {
var ma = new MemberAccess.simple (stmt.variable_name);
@@ -1629,9 +1624,7 @@
CCodeExpression element_expr = new CCodeElementAccess (new CCodeIdentifier (collection_backup.name), new CCodeIdentifier (it_name));
- var element_data_type = new DataType ();
- element_data_type.data_type = arr.element_type;
- element_expr = get_implicit_cast_expression (element_expr, element_data_type, stmt.type_reference);
+ element_expr = get_implicit_cast_expression (element_expr, array_type.element_type, stmt.type_reference);
if (stmt.type_reference.takes_ownership) {
var ma = new MemberAccess.simple (stmt.variable_name);
@@ -1657,7 +1650,7 @@
/* only check for null if the containers elements are of reference-type */
CCodeBinaryExpression ccond;
- if (arr.element_type.is_reference_type ()) {
+ if (array_type.element_type.data_type.is_reference_type ()) {
var ccond_term1 = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, array_len, new CCodeConstant ("-1"));
var ccond_term2 = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeElementAccess (new CCodeIdentifier (collection_backup.name), new CCodeIdentifier (it_name)), new CCodeConstant ("NULL"));
var ccond_term = new CCodeBinaryExpression (CCodeBinaryOperator.AND, ccond_term1, ccond_term2);
@@ -1924,15 +1917,15 @@
}
// return array length if appropriate
- if (current_method != null && !current_method.no_array_length && current_return_type.data_type is Array) {
+ if (current_method != null && !current_method.no_array_length && current_return_type is ArrayType) {
var return_expr_decl = get_temp_variable_declarator (stmt.return_expression.static_type, true, stmt);
var ccomma = new CCodeCommaExpression ();
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (return_expr_decl.name), (CCodeExpression) stmt.return_expression.ccodenode));
- var arr = (Array) current_return_type.data_type;
+ var array_type = (ArrayType) current_return_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var len_l = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (get_array_length_cname ("result", dim)));
var len_r = get_array_length_cexpression (stmt.return_expression, dim);
ccomma.append_expression (new CCodeAssignment (len_l, len_r));
Modified: trunk/gobject/valaccodegeneratorinvocationexpression.vala
==============================================================================
--- trunk/gobject/valaccodegeneratorinvocationexpression.vala (original)
+++ trunk/gobject/valaccodegeneratorinvocationexpression.vala Thu Jan 24 15:27:08 2008
@@ -162,12 +162,12 @@
// error parameter
break;
}
- if (param.type_reference.data_type is Array && ((Array) param.type_reference.data_type).element_type != string_type.data_type) {
- var array = (Array) param.type_reference.data_type;
+ if (param.type_reference is ArrayType && ((ArrayType) param.type_reference).element_type.data_type != string_type.data_type) {
+ var array_type = (ArrayType) param.type_reference;
var cdecl = new CCodeDeclaration ("GArray*");
cdecl.add_declarator (new CCodeVariableDeclarator (param.name));
cb_fun.block.add_statement (cdecl);
- cend_call.add_argument (get_dbus_array_type (array));
+ cend_call.add_argument (get_dbus_array_type (array_type));
cend_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
creply_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), "len"));
creply_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), "data"));
@@ -177,7 +177,7 @@
cb_fun.block.add_statement (cdecl);
cend_call.add_argument (new CCodeIdentifier (param.type_reference.data_type.get_type_id ()));
cend_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
- if (param.type_reference.data_type is Array && ((Array) param.type_reference.data_type).element_type == string_type.data_type) {
+ if (param.type_reference is ArrayType && ((ArrayType) param.type_reference).element_type.data_type == string_type.data_type) {
// special case string array
var cstrvlen = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
cstrvlen.add_argument (new CCodeIdentifier (param.name));
@@ -229,9 +229,9 @@
if (param.type_reference.data_type is Delegate) {
cexpr = new CCodeCastExpression (cexpr, param.type_reference.data_type.get_cname ());
} else {
- if (!param.no_array_length && param.type_reference.data_type is Array) {
- var arr = (Array) param.type_reference.data_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ if (!param.no_array_length && param.type_reference is ArrayType) {
+ var array_type = (ArrayType) param.type_reference;
+ for (int dim = 1; dim <= array_type.rank; dim++) {
ccall.add_argument (get_array_length_cexpression (arg, dim));
}
} else if (param.type_reference is DelegateType) {
@@ -325,9 +325,9 @@
param.default_expression.accept (this);
if (!param.no_array_length && param.type_reference != null &&
- param.type_reference.data_type is Array) {
- var arr = (Array) param.type_reference.data_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ param.type_reference is ArrayType) {
+ var array_type = (ArrayType) param.type_reference;
+ for (int dim = 1; dim <= array_type.rank; dim++) {
ccall.add_argument (get_array_length_cexpression (param.default_expression, dim));
}
}
@@ -337,9 +337,9 @@
}
/* add length argument for methods returning arrays */
- if (m != null && m.return_type.data_type is Array && !(m is DBusMethod)) {
- var arr = (Array) m.return_type.data_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ if (m != null && m.return_type is ArrayType && !(m is DBusMethod)) {
+ var array_type = (ArrayType) m.return_type;
+ for (int dim = 1; dim <= array_type.rank; dim++) {
if (!m.no_array_length) {
var temp_decl = get_temp_variable_declarator (int_type);
var temp_ref = new CCodeIdentifier (temp_decl.name);
@@ -473,10 +473,10 @@
expr.ccodenode = ccomma;
} else if (m is DBusMethod && m.return_type.data_type != null) {
// synchronous D-Bus method call with reply
- if (m.return_type.data_type is Array && ((Array) m.return_type.data_type).element_type != string_type.data_type) {
- var array = (Array) m.return_type.data_type;
+ if (m.return_type is ArrayType && ((ArrayType) m.return_type).element_type.data_type != string_type.data_type) {
+ var array_type = (ArrayType) m.return_type;
- ccall.add_argument (get_dbus_array_type (array));
+ ccall.add_argument (get_dbus_array_type (array_type));
var garray_type_reference = new DataType ();
garray_type_reference.data_type = garray_type;
@@ -510,7 +510,7 @@
ccomma.append_expression (new CCodeIdentifier (temp_decl.name));
expr.ccodenode = ccomma;
- if (m.return_type.data_type is Array && ((Array) m.return_type.data_type).element_type == string_type.data_type) {
+ if (m.return_type is ArrayType && ((ArrayType) m.return_type).element_type.data_type == string_type.data_type) {
// special case string array
if (!m.no_array_length) {
var cstrvlen = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
@@ -524,10 +524,10 @@
}
}
- private CCodeExpression! get_dbus_array_type (Array! array) {
+ private CCodeExpression! get_dbus_array_type (ArrayType array_type) {
var carray_type = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_type_get_collection"));
carray_type.add_argument (new CCodeConstant ("\"GArray\""));
- carray_type.add_argument (new CCodeIdentifier (array.element_type.get_type_id ()));
+ carray_type.add_argument (new CCodeIdentifier (array_type.element_type.data_type.get_type_id ()));
return carray_type;
}
}
Modified: trunk/gobject/valaccodegeneratormethod.vala
==============================================================================
--- trunk/gobject/valaccodegeneratormethod.vala (original)
+++ trunk/gobject/valaccodegeneratormethod.vala Thu Jan 24 15:27:08 2008
@@ -176,15 +176,15 @@
var params = m.get_parameters ();
foreach (FormalParameter param in params) {
- if (!param.no_array_length && param.type_reference != null && param.type_reference.data_type is Array) {
- var arr = (Array) param.type_reference.data_type;
+ if (!param.no_array_length && param.type_reference is ArrayType) {
+ var array_type = (ArrayType) param.type_reference;
var length_ctype = "int";
if (param.type_reference.is_out || param.type_reference.is_ref) {
length_ctype = "int*";
}
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeFormalParameter (get_array_length_cname (param.name, dim), length_ctype);
function.add_parameter (cparam);
if (vdeclarator != null) {
@@ -211,11 +211,11 @@
}
}
- if (!m.no_array_length && creturn_type.data_type is Array) {
+ if (!m.no_array_length && creturn_type is ArrayType) {
// return array length if appropriate
- var arr = (Array) creturn_type.data_type;
+ var array_type = (ArrayType) creturn_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
function.add_parameter (cparam);
if (vdeclarator != null) {
@@ -462,15 +462,15 @@
var params = m.get_parameters ();
foreach (FormalParameter param in params) {
- if (!param.no_array_length && param.type_reference.data_type is Array) {
- var arr = (Array) param.type_reference.data_type;
+ if (!param.no_array_length && param.type_reference is ArrayType) {
+ var array_type = (ArrayType) param.type_reference;
var length_ctype = "int";
if (param.type_reference.is_out || param.type_reference.is_ref) {
length_ctype = "int*";
}
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeFormalParameter (get_array_length_cname (param.name, dim), length_ctype);
vfunc.add_parameter (cparam);
vcall.add_argument (new CCodeIdentifier (cparam.name));
@@ -482,10 +482,10 @@
}
// return array length if appropriate
- if (!m.no_array_length && creturn_type.data_type is Array) {
- var arr = (Array) creturn_type.data_type;
+ if (!m.no_array_length && creturn_type is ArrayType) {
+ var array_type = (ArrayType) creturn_type;
- for (int dim = 1; dim <= arr.rank; dim++) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
vfunc.add_parameter (cparam);
vcall.add_argument (new CCodeIdentifier (cparam.name));
@@ -762,13 +762,13 @@
return false;
}
- if (!(param.type_reference.data_type is Array)) {
+ if (!(param.type_reference is ArrayType)) {
// parameter must be an array
return false;
}
- var array_type = (Array) param.type_reference.data_type;
- if (array_type.element_type != string_type.data_type) {
+ var array_type = (ArrayType) param.type_reference;
+ if (array_type.element_type.data_type != string_type.data_type) {
// parameter must be an array of strings
return false;
}
Modified: trunk/gobject/valaccodegeneratorsignal.vala
==============================================================================
--- trunk/gobject/valaccodegeneratorsignal.vala (original)
+++ trunk/gobject/valaccodegeneratorsignal.vala Thu Jan 24 15:27:08 2008
@@ -73,7 +73,7 @@
return t.data_type.get_cname ();
} else if (t.data_type is Enum) {
return "gint";
- } else if (t.data_type is Array) {
+ } else if (t is ArrayType) {
return "gpointer";
}
Modified: trunk/vala/valaarraytype.vala
==============================================================================
--- trunk/vala/valaarraytype.vala (original)
+++ trunk/vala/valaarraytype.vala Thu Jan 24 15:27:08 2008
@@ -1,6 +1,6 @@
/* valaarraytype.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
@@ -29,8 +29,42 @@
/**
* The element type.
*/
- public weak DataType element_type { get; set; }
+ public weak DataType element_type { get; construct set; }
- public ArrayType (construct DataType! element_type) {
+ /**
+ * The rank of this array.
+ */
+ public int rank { get; construct set; }
+
+ public ArrayType (construct DataType! element_type, construct int rank) {
+ }
+
+ construct {
+ if (element_type.data_type != null) {
+ data_type = element_type.data_type.get_array (rank);
+ } else {
+ data_type = element_type.type_parameter.get_array (rank);
+ }
+ }
+
+ public override DataType! copy () {
+ var result = new ArrayType (element_type, rank);
+ result.source_reference = source_reference;
+ result.transfers_ownership = transfers_ownership;
+ result.takes_ownership = takes_ownership;
+ result.is_out = is_out;
+ result.nullable = nullable;
+ result.floating_reference = floating_reference;
+ result.is_ref = is_ref;
+
+ foreach (DataType arg in get_type_arguments ()) {
+ result.add_type_argument (arg.copy ());
+ }
+
+ return result;
+ }
+
+ public override bool is_array () {
+ return true;
}
}
Modified: trunk/vala/valadatatype.vala
==============================================================================
--- trunk/vala/valadatatype.vala (original)
+++ trunk/vala/valadatatype.vala Thu Jan 24 15:27:08 2008
@@ -162,9 +162,9 @@
public string get_const_cname () {
string ptr;
Typesymbol t;
- /* FIXME: dirty hack to make constant arrays possible */
- if (data_type is Array) {
- t = ((Array) data_type).element_type;
+ // FIXME: workaround to make constant arrays possible
+ if (this is ArrayType) {
+ t = ((ArrayType) this).element_type.data_type;
} else {
t = data_type;
}
@@ -189,7 +189,7 @@
}
var type_args = get_type_arguments ();
- if (!(data_type is Array) && type_args.size > 0) {
+ if (!(this is ArrayType) && type_args.size > 0) {
s += "<";
bool first = true;
foreach (DataType type_arg in type_args) {
@@ -346,7 +346,7 @@
if (type_parameter != null ||
(data_type != null && (
data_type.is_reference_type () ||
- data_type is Array ||
+ this is ArrayType ||
data_type is Delegate ||
data_type.get_attribute ("PointerType") != null))) {
return true;
@@ -360,7 +360,7 @@
return true;
}
- if (data_type is Array != target_type.data_type is Array) {
+ if (this is ArrayType != target_type is ArrayType) {
return false;
}
@@ -426,7 +426,7 @@
}
public virtual bool is_array () {
- return data_type is Array;
+ return false;
}
/**
Modified: trunk/vala/valainterfacewriter.vala
==============================================================================
--- trunk/vala/valainterfacewriter.vala (original)
+++ trunk/vala/valainterfacewriter.vala Thu Jan 24 15:27:08 2008
@@ -371,7 +371,7 @@
write_string ("[CCode (cname = \"%s\")]".printf (f.get_cname ()));
}
- if (f.no_array_length && f.type_reference.data_type is Array) {
+ if (f.no_array_length && f.type_reference is ArrayType) {
write_indent ();
write_string ("[NoArrayLength]");
}
@@ -492,9 +492,9 @@
}
if (m.no_array_length) {
- bool array_found = (m.return_type != null && m.return_type.data_type is Array);
+ bool array_found = (m.return_type is ArrayType);
foreach (FormalParameter param in m.get_parameters ()) {
- if (param.type_reference != null && param.type_reference.data_type is Array) {
+ if (param.type_reference is ArrayType) {
array_found = true;
break;
}
Modified: trunk/vala/valanulltype.vala
==============================================================================
--- trunk/vala/valanulltype.vala (original)
+++ trunk/vala/valanulltype.vala Thu Jan 24 15:27:08 2008
@@ -44,7 +44,7 @@
}
if (target_type.data_type.is_reference_type () ||
- target_type.data_type is Array ||
+ target_type is ArrayType ||
target_type.data_type is Delegate) {
return !(CodeContext.is_non_null_enabled ());
}
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Thu Jan 24 15:27:08 2008
@@ -779,64 +779,30 @@
* @param list an initializer list
*/
public override void visit_initializer_list (InitializerList! list) {
- if (list.expected_type != null && list.expected_type.data_type is Array) {
+ if (list.expected_type is ArrayType) {
/* initializer is used as array initializer */
- Array edt = (Array)list.expected_type.data_type;
- var inits = list.get_initializers ();
- int rank = ((Array)list.expected_type.data_type).rank;
- var child_type = list.expected_type.copy ();
+ var array_type = (ArrayType) list.expected_type;
- if (rank > 1) {
- child_type.data_type = edt.element_type.get_array (rank - 1);
- } else {
- child_type.data_type = edt.element_type;
- }
-
- foreach (Expression e in inits) {
- e.expected_type = child_type.copy ();
+ foreach (Expression e in list.get_initializers ()) {
+ e.expected_type = array_type.element_type.copy ();
}
}
list.accept_children (this);
- if (list.expected_type != null && list.expected_type.data_type is Array) {
- Array edt = (Array)list.expected_type.data_type;
- var inits = list.get_initializers ();
- int rank = edt.rank;
- var child_type = list.expected_type.copy ();
- bool error = false;
+ if (list.expected_type is ArrayType) {
+ var array_type = (ArrayType) list.expected_type;
- if (rank > 1) {
- child_type.data_type = edt.element_type.get_array (rank - 1);
- foreach (Expression e in inits) {
- if (e.static_type == null) {
- error = true;
- continue;
- }
- if (!(e is InitializerList)) {
- error = true;
- e.error = true;
- Report.error (e.source_reference, "Initializer list expected");
- continue;
- }
- if (!e.static_type.equals (child_type)) {
- error = true;
- e.error = true;
- Report.error (e.source_reference, "Expected initializer list of type `%s' but got `%s'".printf (child_type.data_type.name, e.static_type.data_type.name));
- }
+ bool error = false;
+ foreach (Expression e in list.get_initializers ()) {
+ if (e.static_type == null) {
+ error = true;
+ continue;
}
- } else {
- child_type.data_type = edt.element_type;
- foreach (Expression e in inits) {
- if (e.static_type == null) {
- error = true;
- continue;
- }
- if (!e.static_type.compatible (child_type)) {
- error = true;
- e.error = true;
- Report.error (e.source_reference, "Expected initializer of type `%s' but got `%s'".printf (child_type.data_type.name, e.static_type.data_type.name));
- }
+ if (!e.static_type.compatible (array_type.element_type)) {
+ error = true;
+ e.error = true;
+ Report.error (e.source_reference, "Expected initializer of type `%s' but got `%s'".printf (array_type.element_type.data_type.name, e.static_type.data_type.name));
}
}
@@ -981,8 +947,8 @@
bool need_type_check = false;
if (collection_type.is_array ()) {
- var arr = (Array) collection_type.data_type;
- element_data_type.data_type = arr.element_type;
+ var array_type = (ArrayType) collection_type;
+ element_data_type = array_type.element_type;
need_type_check = true;
} else if (collection_type.compatible (glist_type) || collection_type.compatible (gslist_type)) {
if (collection_type.get_type_arguments ().size > 0) {
@@ -1173,9 +1139,8 @@
var calc_sizes = new ArrayList<LiteralExpression> ();
if (initlist != null) {
- initlist.expected_type = expr.element_type.copy ();
- initlist.expected_type.data_type = initlist.expected_type.data_type.get_array (expr.rank);
- // FIXME: add element type to type_argument
+ initlist.expected_type = new ArrayType (expr.element_type, expr.rank);
+ initlist.expected_type.add_type_argument (expr.element_type);
initlist.accept (this);
@@ -1224,12 +1189,7 @@
return;
}
- expr.static_type = expr.element_type.copy ();
- if (expr.element_type.data_type != null) {
- expr.static_type.data_type = expr.element_type.data_type.get_array (expr.rank);
- } else {
- expr.static_type.data_type = expr.element_type.type_parameter.get_array (expr.rank);
- }
+ expr.static_type = new ArrayType (expr.element_type, expr.rank);
expr.static_type.transfers_ownership = true;
expr.static_type.takes_ownership = true;
@@ -1898,7 +1858,7 @@
bool index_int_type_check = true;
/* assign a static_type when possible */
- if (container_type is Array) {
+ if (expr.container.static_type is ArrayType) {
var args = expr.container.static_type.get_type_arguments ();
if (args.size != 1) {
Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala (original)
+++ trunk/vala/valasymbolresolver.vala Thu Jan 24 15:27:08 2008
@@ -277,19 +277,24 @@
foreach (DataType type_arg in type.get_type_arguments ()) {
element_type.add_type_argument (type_arg);
}
- type.remove_all_type_arguments ();
-
+
if (type.data_type != null) {
if (type.data_type.is_reference_type ()) {
element_type.takes_ownership = type.takes_ownership;
}
- type.data_type = element_type.data_type.get_array (unresolved_type.array_rank);
} else {
element_type.takes_ownership = type.takes_ownership;
- type.data_type = element_type.type_parameter.get_array (unresolved_type.array_rank);
- type.type_parameter = null;
}
+
+ type = new ArrayType (element_type, unresolved_type.array_rank);
type.add_type_argument (element_type);
+
+ type.source_reference = unresolved_type.source_reference;
+ type.takes_ownership = unresolved_type.takes_ownership;
+ type.transfers_ownership = unresolved_type.transfers_ownership;
+ type.is_ref = unresolved_type.is_ref;
+ type.is_out = unresolved_type.is_out;
+ type.nullable = unresolved_type.nullable;
}
if (type.data_type != null && !type.data_type.is_reference_type ()) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]