X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ast.h;h=d1b250d8abb5cc4a5e2ffc1ebc945e8a13a7d09f;hp=26434138cb7feb1b12cffe1635596301329c4a10;hb=b08195e2da48e041a4f027d93e944bc4715169ec;hpb=c3cc6f184e6bab86402289609ddd57ce733a7812 diff --git a/ast.h b/ast.h index 2643413..d1b250d 100644 --- a/ast.h +++ b/ast.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 + * Copyright (C) 2012, 2013, 2014 * Wolfgang Bumiller * Dale Weiler * @@ -54,27 +54,40 @@ typedef struct ast_switch_s ast_switch; typedef struct ast_label_s ast_label; typedef struct ast_goto_s ast_goto; typedef struct ast_argpipe_s ast_argpipe; +typedef struct ast_state_s ast_state; enum { - AST_FLAG_VARIADIC = 1 << 0, - AST_FLAG_NORETURN = 1 << 1, - AST_FLAG_INLINE = 1 << 2, - AST_FLAG_INITIALIZED = 1 << 3, - AST_FLAG_DEPRECATED = 1 << 4, - AST_FLAG_INCLUDE_DEF = 1 << 5, - AST_FLAG_IS_VARARG = 1 << 6, - AST_FLAG_ALIAS = 1 << 7, - AST_FLAG_ERASEABLE = 1 << 8, - AST_FLAG_ACCUMULATE = 1 << 9, - - /* - * An array declared as [] + AST_FLAG_VARIADIC = 1 << 0, + AST_FLAG_NORETURN = 1 << 1, + AST_FLAG_INLINE = 1 << 2, + AST_FLAG_INITIALIZED = 1 << 3, + AST_FLAG_DEPRECATED = 1 << 4, + AST_FLAG_INCLUDE_DEF = 1 << 5, + AST_FLAG_IS_VARARG = 1 << 6, + AST_FLAG_ALIAS = 1 << 7, + AST_FLAG_ERASEABLE = 1 << 8, + AST_FLAG_ACCUMULATE = 1 << 9, + + /* An array declared as [] * so that the size is taken from the initializer */ - AST_FLAG_ARRAY_INIT = 1 << 10, + AST_FLAG_ARRAY_INIT = 1 << 10, + + AST_FLAG_FINAL_DECL = 1 << 11, + + /* Several coverage options + * AST_FLAG_COVERAGE means there was an explicit [[coverage]] attribute, + * which will overwrite the default set via the commandline switches. + * BLOCK_COVERAGE inserts coverage() calls into every basic block. + * In the future there might be more options like tracking variable access + * by creating get/set wrapper functions. + */ + AST_FLAG_COVERAGE = 1 << 12, + AST_FLAG_BLOCK_COVERAGE = 1 << 13, AST_FLAG_LAST, - AST_FLAG_TYPE_MASK = (AST_FLAG_VARIADIC | AST_FLAG_NORETURN) + AST_FLAG_TYPE_MASK = (AST_FLAG_VARIADIC | AST_FLAG_NORETURN), + AST_FLAG_COVERAGE_MASK = (AST_FLAG_BLOCK_COVERAGE) }; enum { @@ -99,7 +112,8 @@ enum { TYPE_ast_switch, /* 18 */ TYPE_ast_label, /* 19 */ TYPE_ast_goto, /* 20 */ - TYPE_ast_argpipe /* 21 */ + TYPE_ast_argpipe, /* 21 */ + TYPE_ast_state /* 22 */ }; #define ast_istype(x, t) ( ((ast_node*)x)->nodetype == (TYPE_##t) ) @@ -202,6 +216,7 @@ struct ast_value_s bool isfield; /* this declares a field */ bool isimm; /* an immediate, not just const */ bool hasvalue; + bool inexact; /* inexact coming from folded expression */ basic_value_t constval; /* for TYPE_ARRAY we have an optional vector * of constants when an initializer list @@ -567,6 +582,19 @@ struct ast_goto_s ast_goto* ast_goto_new(lex_ctx_t ctx, const char *name); void ast_goto_set_label(ast_goto*, ast_label*); +/* STATE node + * + * For frame/think state updates: void foo() [framenum, nextthink] {} + */ +struct ast_state_s +{ + ast_expression expression; + ast_expression *framenum; + ast_expression *nextthink; +}; +ast_state* ast_state_new(lex_ctx_t ctx, ast_expression *frame, ast_expression *think); +void ast_state_delete(ast_state*); + /* CALL node * * Contains an ast_expression as target, rather than an ast_function/value.