}
if (type->is_array()) {
- const unsigned elements_supplied = values->length();
- if (elements_supplied != type->length) {
- ir_read_error(st, values, "expected exactly %u array elements, "
- "given %u", type->length, elements_supplied);
- return NULL;
- }
-
+ unsigned elements_supplied = 0;
exec_list elements;
foreach_iter(exec_list_iterator, it, values->subexpressions) {
s_expression *expr = (s_expression *) it.get();
if (ir_elt == NULL)
return NULL;
elements.push_tail(ir_elt);
+ elements_supplied++;
+ }
+
+ if (elements_supplied != type->length) {
+ ir_read_error(st, values, "expected exactly %u array elements, "
+ "given %u", type->length, elements_supplied);
+ return NULL;
}
return new(ctx) ir_constant(type, &elements);
}
{
}
-unsigned
-s_list::length() const
-{
- unsigned i = 0;
- foreach_iter(exec_list_iterator, it, this->subexpressions) {
- i++;
- }
- return i;
-}
-
static s_expression *
read_atom(void *ctx, const char *& src)
{