return cp;
}
+static ast_expression* ast_shallow_type(lex_ctx ctx, int vtype)
+{
+ ast_instantiate(ast_expression, ctx, ast_expression_delete_full);
+ self->expression.codegen = NULL;
+ self->expression.next = NULL;
+ self->expression.vtype = vtype;
+ return self;
+}
+
static ast_expression* ast_type_copy(lex_ctx ctx, const ast_expression *ex)
{
size_t i;
return NULL;
}
+ if (owner->expression.vtype != TYPE_FLOAT &&
+ owner->expression.vtype != TYPE_FIELD) {
+ printf("ast_member on an invalid owner of type %i\n", (int)owner->expression.vtype);
+ mem_d(self);
+ return NULL;
+ }
+
ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_member_codegen);
- self->expression.vtype = TYPE_FLOAT;
- self->expression.next = NULL;
+ if (owner->expression.vtype == TYPE_VECTOR) {
+ self->expression.vtype = TYPE_FLOAT;
+ self->expression.next = NULL;
+ } else {
+ self->expression.vtype = TYPE_FIELD;
+ self->expression.next = ast_shallow_type(ctx, TYPE_FLOAT);
+ }
self->owner = owner;
self->field = field;
if (!(*cgen)((ast_expression*)(self->owner), func, true, &vec))
return false;
- if (vec->vtype != TYPE_VECTOR)
+ if (vec->vtype != TYPE_VECTOR &&
+ !(vec->vtype == TYPE_FIELD && self->owner->expression.next->expression.vtype == TYPE_VECTOR))
+ {
return false;
+ }
*out = ir_value_vector_member(vec, self->field);