Fixes bug 536706.
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) {
+ Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
+ return size[dim - 1];
}
} else if (array_expr is NullLiteral) {
return new CCodeConstant ("0");
cexpr = new CCodeBinaryExpression (cop, (CCodeExpression) get_ccodenode (assignment.left), cexpr);
}
- var ccall = get_property_set_call (prop, ma, cexpr);
+ var ccall = get_property_set_call (prop, ma, cexpr, assignment.right);
// assignments are expressions, so return the current property value, except if we're sure that it can't be used
if (!(assignment.parent_node is ExpressionStatement)) {
function.add_parameter (cvalueparam);
}
+ if (acc.value_type is ArrayType) {
+ var array_type = (ArrayType) acc.value_type;
+
+ var length_ctype = "int";
+ if (acc.readable) {
+ length_ctype = "int*";
+ }
+
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
+ }
+ }
+
if (prop.is_private_symbol () || (!acc.readable && !acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
function.modifiers |= CCodeModifiers.STATIC;
}
function.add_parameter (cvalueparam);
}
+ if (acc.value_type is ArrayType) {
+ var array_type = (ArrayType) acc.value_type;
+
+ var length_ctype = "int";
+ if (acc.readable) {
+ length_ctype = "int*";
+ }
+
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
+ }
+ }
+
if (prop.is_private_symbol () || !(acc.readable || acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
// accessor function should be private if the property is an internal symbol or it's a construct-only setter
function.modifiers |= CCodeModifiers.STATIC;
function.add_parameter (cvalueparam);
}
+ if (acc.value_type is ArrayType) {
+ var array_type = (ArrayType) acc.value_type;
+
+ var length_ctype = "int";
+ if (acc.readable) {
+ length_ctype = "int*";
+ }
+
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
+ }
+ }
+
if (!is_virtual) {
if (prop.is_private_symbol () || !(acc.readable || acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
// accessor function should be private if the property is an internal symbol or it's a construct-only setter
}
// return array length if appropriate
- if (current_method != null && !current_method.no_array_length && current_return_type is ArrayType) {
+ if (((current_method != null && !current_method.no_array_length) || current_property_accessor != null) && current_return_type is ArrayType) {
var return_expr_decl = get_temp_variable (stmt.return_expression.value_type, true, stmt);
var ccomma = new CCodeCommaExpression ();
}
}
- public CCodeFunctionCall get_property_set_call (Property prop, MemberAccess ma, CCodeExpression cexpr) {
+ public CCodeFunctionCall get_property_set_call (Property prop, MemberAccess ma, CCodeExpression cexpr, Expression? rhs = null) {
if (ma.inner is BaseAccess) {
if (prop.base_property != null) {
var base_class = (Class) prop.base_property.parent_symbol;
/* property name is second argument of g_object_set */
ccall.add_argument (prop.get_canonical_cconstant ());
}
-
+
ccall.add_argument (cexpr);
-
+
+ var array_type = prop.property_type as ArrayType;
+ if (array_type != null && rhs != null) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ ccall.add_argument (head.get_array_length_cexpression (rhs, dim));
+ }
+ }
+
if (prop.no_accessor_method) {
ccall.add_argument (new CCodeConstant ("NULL"));
}
var temp_var = get_temp_variable (base_property.get_accessor.value_type);
var ctemp = new CCodeIdentifier (temp_var.name);
temp_vars.add (temp_var);
- ccall.add_argument (new CCodeUnaryExpression(CCodeUnaryOperator.ADDRESS_OF, ctemp));
+ ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
ccomma.append_expression (ccall);
ccomma.append_expression (ctemp);
expr.ccodenode = ccomma;
} else {
+ var array_type = base_property.property_type as ArrayType;
+ if (array_type != null) {
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ var temp_var = get_temp_variable (int_type);
+ var ctemp = new CCodeIdentifier (temp_var.name);
+ temp_vars.add (temp_var);
+ ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
+ expr.append_array_size (ctemp);
+ }
+ }
+
expr.ccodenode = ccall;
}
} else {
*/
public ArrayList<LocalVariable> temp_vars = new ArrayList<LocalVariable> ();
+ private Gee.List<CCodeExpression> array_sizes = new ArrayList<CCodeExpression> ();
+
/**
* Returns whether this expression is constant, i.e. whether this
* expression only consists of literals and other constants.
return false;
}
+ /**
+ * Add an array size C code expression.
+ */
+ public void append_array_size (CCodeExpression size) {
+ array_sizes.add (size);
+ }
+
+ /**
+ * Get the C code expression for array sizes for all dimensions
+ * ascending from left to right.
+ */
+ public Gee.List<CCodeExpression> get_array_sizes () {
+ return new ReadOnlyList<CCodeExpression> (array_sizes);
+ }
+
public Statement? parent_statement {
get {
var expr = parent_node as Expression;
public Expression _call;
private Gee.List<Expression> argument_list = new ArrayList<Expression> ();
- private Gee.List<CCodeExpression> array_sizes = new ArrayList<CCodeExpression> ();
/**
* Creates a new invocation expression.
return new ReadOnlyList<Expression> (argument_list);
}
- /**
- * Add an array size C code expression.
- */
- public void append_array_size (CCodeExpression size) {
- array_sizes.add (size);
- }
-
- /**
- * Get the C code expression for array sizes for all dimensions
- * ascending from left to right.
- */
- public Gee.List<CCodeExpression> get_array_sizes () {
- return new ReadOnlyList<CCodeExpression> (array_sizes);
- }
-
public override void accept (CodeVisitor visitor) {
visitor.visit_method_call (this);