mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-08 16:52:16 +00:00
[qfcc] Implement field access to sub-algebra variables
This makes working with the plethora of types a little easier still. The check for an algebra expression in field_expr needed to be moved up because the struct code thought the algebra type was a normal vector.
This commit is contained in:
parent
55fc343383
commit
97624b84aa
2 changed files with 13 additions and 3 deletions
|
@ -1547,6 +1547,8 @@ field_expr (expr_t *e1, expr_t *e2)
|
||||||
e1 = cast_expr (pointer_type (ivar->type), e1);
|
e1 = cast_expr (pointer_type (ivar->type), e1);
|
||||||
return unary_expr ('.', e1);
|
return unary_expr ('.', e1);
|
||||||
}
|
}
|
||||||
|
} else if (is_algebra (t1)) {
|
||||||
|
return algebra_field_expr (e1, e2);
|
||||||
} else if (is_nonscalar (t1) || is_struct (t1) || is_union (t1)) {
|
} else if (is_nonscalar (t1) || is_struct (t1) || is_union (t1)) {
|
||||||
symbol_t *field;
|
symbol_t *field;
|
||||||
|
|
||||||
|
@ -1587,8 +1589,6 @@ field_expr (expr_t *e1, expr_t *e2)
|
||||||
return new_offset_alias_expr (field->type, e1, field->s.offset);
|
return new_offset_alias_expr (field->type, e1, field->s.offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (is_algebra (t1)) {
|
|
||||||
return algebra_field_expr (e1, e2);
|
|
||||||
} else if (is_class (t1)) {
|
} else if (is_class (t1)) {
|
||||||
//Class instance variables aren't allowed and thus declaring one
|
//Class instance variables aren't allowed and thus declaring one
|
||||||
//is treated as an error, so this is a follow-on error.
|
//is treated as an error, so this is a follow-on error.
|
||||||
|
|
|
@ -2267,5 +2267,15 @@ algebra_field_expr (expr_t *mvec, expr_t *field_name)
|
||||||
}
|
}
|
||||||
return new_offset_alias_expr (field->type, mvec, field->s.offset);
|
return new_offset_alias_expr (field->type, mvec, field->s.offset);
|
||||||
}
|
}
|
||||||
internal_error (mvec, "not implemented");
|
if (mvec->type == ex_multivec) {
|
||||||
|
internal_error (mvec, "not implemented");
|
||||||
|
} else {
|
||||||
|
auto multivec = mvec_type->t.multivec;
|
||||||
|
auto mvec_struct = multivec->mvec_sym->type;
|
||||||
|
auto field = get_struct_field (mvec_struct, mvec, field_name);
|
||||||
|
if (!field) {
|
||||||
|
return mvec;
|
||||||
|
}
|
||||||
|
return new_offset_alias_expr (field->type, mvec, field->s.offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue