[qfcc] Add a function to create typed zero expressions

Sometimes, nil's untyped 0 isn't really suitable.
This commit is contained in:
Bill Currie 2023-08-23 15:27:55 +09:00
parent deb03ca27a
commit 0d639510e3
2 changed files with 16 additions and 0 deletions

View file

@ -562,6 +562,15 @@ expr_t *new_args_expr (void);
*/
expr_t *new_value_expr (ex_value_t *value);
/** Create a new typed zero value expression node.
Similar to new_nil_expr, but is 0 of a specific type.
\param type The type to use for the zero.
\return The new value expression.
*/
expr_t *new_zero_expr (struct type_s *type);
/** Create a new symbol expression node from a name.
\param name The name for the symbol.

View file

@ -772,6 +772,13 @@ new_value_expr (ex_value_t *value)
return e;
}
expr_t *
new_zero_expr (type_t *type)
{
pr_type_t zero[type_size (type)] = {};
return new_value_expr (new_type_value (type, zero));
}
expr_t *
new_name_expr (const char *name)
{