[vala] codegen: Use append_array_size for constant access
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Use append_array_size for constant access
- Date: Sat, 9 Oct 2010 17:07:57 +0000 (UTC)
commit ba959134e375e1b729ed25274ffb983ec218b63f
Author: Jürg Billeter <j bitron ch>
Date: Sat Oct 9 17:42:32 2010 +0200
codegen: Use append_array_size for constant access
codegen/valaccodearraymodule.vala | 29 +++++++----------------------
codegen/valaccodememberaccessmodule.vala | 6 ++++++
2 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 3aa6628..96b9696 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -181,28 +181,13 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
return size[dim - 1];
}
} else if (array_expr.symbol_reference != null) {
- if (array_expr.symbol_reference is FormalParameter || array_expr.symbol_reference is LocalVariable || array_expr.symbol_reference is Field) {
- List<CCodeExpression> size = get_array_sizes (array_expr);
- if (size != null && size.size >= dim) {
- if (is_out) {
- // passing array as out/ref
- return new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, size[dim - 1]);
- } else {
- return size[dim - 1];
- }
- }
- } else if (array_expr.symbol_reference is Constant) {
- var constant = (Constant) array_expr.symbol_reference;
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_N_ELEMENTS"));
- ccall.add_argument (new CCodeIdentifier (constant.get_cname ()));
- return ccall;
- } else if (array_expr.symbol_reference is Property) {
- var prop = (Property) array_expr.symbol_reference;
- if (!prop.no_array_length) {
- List<CCodeExpression> size = get_array_sizes (array_expr);
- if (size != null && size.size >= dim) {
- return size[dim - 1];
- }
+ List<CCodeExpression> size = get_array_sizes (array_expr);
+ if (size != null && size.size >= dim) {
+ if (is_out) {
+ // passing array as out/ref
+ return new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, size[dim - 1]);
+ } else {
+ return size[dim - 1];
}
}
} else if (array_expr is NullLiteral) {
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index a3cec43..10a72d6 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -258,6 +258,12 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
} else {
set_cvalue (expr, new CCodeIdentifier (c.get_cname ()));
}
+
+ if (array_type != null) {
+ var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_N_ELEMENTS"));
+ ccall.add_argument (new CCodeIdentifier (c.get_cname ()));
+ append_array_size (expr, ccall);
+ }
} else if (expr.symbol_reference is Property) {
var prop = (Property) expr.symbol_reference;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]