mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
removing ast_expression_common.variadic, adding ast_expression_common.flags, added AST_FLAG_VARIADIC and AST_FLAG_NORETURN
This commit is contained in:
parent
7c5fc26081
commit
ba434c8e22
3 changed files with 12 additions and 9 deletions
10
ast.c
10
ast.c
|
@ -71,9 +71,9 @@ static void ast_expression_init(ast_expression *self,
|
|||
self->expression.next = NULL;
|
||||
self->expression.outl = NULL;
|
||||
self->expression.outr = NULL;
|
||||
self->expression.variadic = false;
|
||||
self->expression.params = NULL;
|
||||
self->expression.count = 0;
|
||||
self->expression.flags = 0;
|
||||
}
|
||||
|
||||
static void ast_expression_delete(ast_expression *self)
|
||||
|
@ -108,8 +108,8 @@ ast_value* ast_value_copy(const ast_value *self)
|
|||
}
|
||||
fromex = &self->expression;
|
||||
selfex = &cp->expression;
|
||||
selfex->variadic = fromex->variadic;
|
||||
selfex->count = fromex->count;
|
||||
selfex->flags = fromex->flags;
|
||||
for (i = 0; i < vec_size(fromex->params); ++i) {
|
||||
ast_value *v = ast_value_copy(fromex->params[i]);
|
||||
if (!v) {
|
||||
|
@ -134,8 +134,8 @@ bool ast_type_adopt_impl(ast_expression *self, const ast_expression *other)
|
|||
}
|
||||
fromex = &other->expression;
|
||||
selfex = &self->expression;
|
||||
selfex->variadic = fromex->variadic;
|
||||
selfex->count = fromex->count;
|
||||
selfex->flags = fromex->flags;
|
||||
for (i = 0; i < vec_size(fromex->params); ++i) {
|
||||
ast_value *v = ast_value_copy(fromex->params[i]);
|
||||
if (!v)
|
||||
|
@ -186,8 +186,8 @@ ast_expression* ast_type_copy(lex_ctx ctx, const ast_expression *ex)
|
|||
else
|
||||
selfex->next = NULL;
|
||||
|
||||
selfex->variadic = fromex->variadic;
|
||||
selfex->count = fromex->count;
|
||||
selfex->flags = fromex->flags;
|
||||
for (i = 0; i < vec_size(fromex->params); ++i) {
|
||||
ast_value *v = ast_value_copy(fromex->params[i]);
|
||||
if (!v) {
|
||||
|
@ -209,7 +209,7 @@ bool ast_compare_type(ast_expression *a, ast_expression *b)
|
|||
return false;
|
||||
if (vec_size(a->expression.params) != vec_size(b->expression.params))
|
||||
return false;
|
||||
if (a->expression.variadic != b->expression.variadic)
|
||||
if (a->expression.flags != b->expression.flags)
|
||||
return false;
|
||||
if (vec_size(a->expression.params)) {
|
||||
size_t i;
|
||||
|
|
4
ast.h
4
ast.h
|
@ -131,7 +131,7 @@ typedef struct
|
|||
/* arrays get a member-count */
|
||||
size_t count;
|
||||
ast_value* *params;
|
||||
bool variadic;
|
||||
uint32_t flags;
|
||||
/* The codegen functions should store their output values
|
||||
* so we can call it multiple times without re-evaluating.
|
||||
* Store lvalue and rvalue seperately though. So that
|
||||
|
@ -140,6 +140,8 @@ typedef struct
|
|||
ir_value *outl;
|
||||
ir_value *outr;
|
||||
} ast_expression_common;
|
||||
#define AST_FLAG_VARIADIC (1<<0)
|
||||
#define AST_FLAG_NORETURN (1<<1)
|
||||
|
||||
/* Value
|
||||
*
|
||||
|
|
7
parser.c
7
parser.c
|
@ -1259,7 +1259,7 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
|
|||
return false;
|
||||
} else {
|
||||
if (vec_size(fun->expression.params) != paramcount &&
|
||||
!(fun->expression.variadic &&
|
||||
!((fun->expression.flags & AST_FLAG_VARIADIC) &&
|
||||
vec_size(fun->expression.params) < paramcount))
|
||||
{
|
||||
ast_value *fval;
|
||||
|
@ -2821,7 +2821,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (var->expression.variadic) {
|
||||
if (var->expression.flags & AST_FLAG_VARIADIC) {
|
||||
if (parsewarning(parser, WARN_VARIADIC_FUNCTION,
|
||||
"variadic function with implementation will not be able to access additional parameters"))
|
||||
{
|
||||
|
@ -3540,7 +3540,8 @@ static ast_value *parse_parameter_list(parser_t *parser, ast_value *var)
|
|||
/* now turn 'var' into a function type */
|
||||
fval = ast_value_new(ctx, "<type()>", TYPE_FUNCTION);
|
||||
fval->expression.next = (ast_expression*)var;
|
||||
fval->expression.variadic = variadic;
|
||||
if (variadic)
|
||||
fval->expression.flags |= AST_FLAG_VARIADIC;
|
||||
var = fval;
|
||||
|
||||
var->expression.params = params;
|
||||
|
|
Loading…
Reference in a new issue