mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 22:01:33 +00:00
[qfcc] Simplify algebra_field_expr
This removes all the special cases and thus it should be more robust. It did show up some out-by-one (or a factor of two!) errors elsewhere in the group mask calculations.
This commit is contained in:
parent
c066e638e5
commit
eb9954700a
1 changed files with 28 additions and 50 deletions
|
@ -49,7 +49,7 @@ get_group (type_t *type, algebra_t *algebra)
|
|||
if (!is_algebra (type)) {
|
||||
internal_error (0, "non-algebra type");
|
||||
}
|
||||
pr_uint_t group_mask = (1u << (layout->count + 1)) - 1;
|
||||
pr_uint_t group_mask = (1u << layout->count) - 1;
|
||||
if (type->type != ev_invalid) {
|
||||
group_mask = type->t.multivec->group_mask;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ mvec_expr (expr_t *expr, algebra_t *algebra)
|
|||
}
|
||||
|
||||
auto layout = &algebra->layout;
|
||||
pr_uint_t group_mask = (1u << (layout->count + 1)) - 1;
|
||||
pr_uint_t group_mask = (1u << layout->count) - 1;
|
||||
if (mvtype->type != ev_invalid) {
|
||||
group_mask = mvtype->t.multivec->group_mask;
|
||||
}
|
||||
|
@ -2281,22 +2281,12 @@ algebra_field_expr (expr_t *mvec, expr_t *field_name)
|
|||
auto mvec_type = get_type (mvec);
|
||||
auto algebra = algebra_get (mvec_type);
|
||||
|
||||
if (mvec_type->type == ev_invalid) {
|
||||
auto mvec_struct = algebra->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);
|
||||
}
|
||||
if (mvec->type == ex_multivec) {
|
||||
auto field_sym = get_name (field_name);
|
||||
if (!field_sym) {
|
||||
return error (field_name, "multi-vector reference is not a name");
|
||||
}
|
||||
auto multivec = mvec_type->t.multivec;
|
||||
auto mvec_struct = multivec->mvec_sym->type->t.symtab;
|
||||
auto field = symtab_lookup (mvec_struct, field_sym->name);
|
||||
auto mvec_struct = get_mvec_struct (mvec_type);
|
||||
auto field = mvec_struct ? symtab_lookup (mvec_struct, field_sym->name) : 0;
|
||||
if (!field) {
|
||||
mvec_struct = algebra->mvec_sym->type->t.symtab;
|
||||
field = symtab_lookup (mvec_struct, field_sym->name);
|
||||
|
@ -2320,16 +2310,4 @@ algebra_field_expr (expr_t *mvec, expr_t *field_name)
|
|||
}
|
||||
}
|
||||
return mvec_gather (a, algebra);
|
||||
} else {
|
||||
auto multivec = mvec_type->t.multivec;
|
||||
if (!multivec->mvec_sym) {
|
||||
return error (mvec, "'%s' not a multi-vector", mvec_type->name);
|
||||
}
|
||||
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