[vala] codegen: Fix access to arrays with fixed length
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix access to arrays with fixed length
- Date: Sun, 12 Jun 2011 07:53:34 +0000 (UTC)
commit e83585bd7cafcf09e0cb94082642f4711a99fc23
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jun 12 09:42:52 2011 +0200
codegen: Fix access to arrays with fixed length
Fixes bug 652380.
codegen/valaccodememberaccessmodule.vala | 9 ++++++---
tests/Makefile.am | 1 +
tests/basic-types/bug652380.vala | 4 ++++
3 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 6f2478b..4387a32 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -355,7 +355,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
// captured variables are stored on the heap
var block = (Block) local.parent_symbol;
result.cvalue = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (local.name));
- if (array_type != null) {
+ if (array_type != null && !array_type.fixed_length) {
for (int dim = 1; dim <= array_type.rank; dim++) {
result.append_array_length_cvalue (new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_array_length_cname (get_variable_cname (local.name), dim)));
}
@@ -370,7 +370,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
} else {
result.cvalue = get_variable_cexpression (local.name);
- if (array_type != null) {
+ if (array_type != null && !array_type.fixed_length) {
for (int dim = 1; dim <= array_type.rank; dim++) {
result.append_array_length_cvalue (get_variable_cexpression (get_array_length_cname (get_variable_cname (local.name), dim)));
}
@@ -663,7 +663,10 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
var array_type = result.value_type as ArrayType;
var delegate_type = result.value_type as DelegateType;
if (array_type != null) {
- if (variable.array_null_terminated) {
+ if (array_type.fixed_length) {
+ result.array_length_cvalues = null;
+ result.append_array_length_cvalue (new CCodeConstant (array_type.length.to_string ()));
+ } else if (variable.array_null_terminated) {
requires_array_length = true;
var len_call = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_length"));
len_call.add_argument (result.cvalue);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 820f42b..9e3ee86 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -26,6 +26,7 @@ TESTS = \
basic-types/bug596785.vala \
basic-types/bug632322.vala \
basic-types/bug650993.vala \
+ basic-types/bug652380.vala \
namespaces.vala \
methods/lambda.vala \
methods/closures.vala \
diff --git a/tests/basic-types/bug652380.vala b/tests/basic-types/bug652380.vala
new file mode 100644
index 0000000..f616896
--- /dev/null
+++ b/tests/basic-types/bug652380.vala
@@ -0,0 +1,4 @@
+void main () {
+ int foo[3];
+ int[] bar = foo;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]