mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
Support struct style initializers for vectors and quaternions.
The current implementation probably needs more work, but for the case where
I needed it, it does the job.
grid.r💯 vector size = {range, range, 0};
0115 store.f range, size
0116 store.f range, [$2ac]
0117 store.f .zero, [$2ad]
This commit is contained in:
parent
e17d8ac9db
commit
463e41082a
1 changed files with 5 additions and 2 deletions
|
@ -286,7 +286,9 @@ init_elements (struct def_s *def, expr_t *eles)
|
|||
elements[i].offset = base_offset + i * type_size (array_type);
|
||||
}
|
||||
num_elements = i;
|
||||
} else if (is_struct (def->type)) {
|
||||
} else if (is_struct (def->type)
|
||||
|| def->type == &type_vector
|
||||
|| def->type == &type_quaternion) {
|
||||
symtab_t *symtab = def->type->t.symtab;
|
||||
symbol_t *field;
|
||||
|
||||
|
@ -545,7 +547,8 @@ initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
|
|||
return;
|
||||
if (init->type == ex_nil)
|
||||
convert_nil (init, type);
|
||||
if ((is_array (type) || is_struct (type))
|
||||
if ((is_array (type) || is_struct (type)
|
||||
|| type == &type_vector || type == &type_quaternion)
|
||||
&& init->type == ex_block && !init->e.block.result) {
|
||||
init_elements (sym->s.def, init);
|
||||
sym->s.def->initialized = 1;
|
||||
|
|
Loading…
Reference in a new issue