From: Dale Weiler Date: Wed, 14 Jan 2015 02:36:09 +0000 (-0500) Subject: More cleanup X-Git-Tag: xonotic-v0.8.2~61 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0a00807e57ee1c84b3c0e8105c3e735bfebd7965;p=xonotic%2Fgmqcc.git More cleanup --- diff --git a/ast.h b/ast.h index 5b556e1..d8889ad 100644 --- a/ast.h +++ b/ast.h @@ -666,15 +666,6 @@ struct ast_function_s ir_block **breakblocks; ir_block **continueblocks; -#if 0 - /* In order for early-out logic not to go over - * excessive jumps, we remember their target - * blocks... - */ - ir_block *iftrue; - ir_block *iffalse; -#endif - size_t labelcount; /* in order for thread safety - for the optional * channel abesed multithreading... keeping a buffer diff --git a/code.c b/code.c index 811b085..d98a705 100644 --- a/code.c +++ b/code.c @@ -318,79 +318,6 @@ static void code_stats(const char *filename, const char *lnofile, code_t *code, con_out("\n"); } -/* - * Same principle except this one allocates memory and writes the lno(optional) and the dat file - * directly out to allocated memory. Which is actually very useful for the future library support - * we're going to add. - */ -#if 0 -static bool code_write_memory(code_t *code, uint8_t **datmem, size_t *sizedat, uint8_t **lnomem, size_t *sizelno) GMQCC_UNUSED { - prog_header_t code_header; - uint32_t offset = 0; - - if (!datmem) - return false; - - code_create_header(code, &code_header, "<>", "<>"); - - #define WRITE_CHUNK(C,X,S) \ - do { \ - memcpy((void*)(&(*C)[offset]), (const void*)(X), (S)); \ - offset += (S); \ - } while (0) - - /* Calculate size required to store entire file out to memory */ - if (lnomem) { - uint32_t version = 1; - - *sizelno = code_size_debug(code, &code_header); - *lnomem = (uint8_t*)mem_a(*sizelno); - - WRITE_CHUNK(lnomem, "LNOF", 4); - WRITE_CHUNK(lnomem, &version, sizeof(version)); - WRITE_CHUNK(lnomem, &code_header.defs.length, sizeof(code_header.defs.length)); - WRITE_CHUNK(lnomem, &code_header.globals.length, sizeof(code_header.globals.length)); - WRITE_CHUNK(lnomem, &code_header.fields.length, sizeof(code_header.fields.length)); - WRITE_CHUNK(lnomem, &code_header.statements.length, sizeof(code_header.statements.length)); - - /* something went terribly wrong */ - if (offset != *sizelno) { - mem_d(*lnomem); - *sizelno = 0; - return false; - } - offset = 0; - } - - /* Write out the dat */ - *sizedat = code_size_binary(code, &code_header); - *datmem = (uint8_t*)mem_a(*sizedat); - - WRITE_CHUNK(datmem, &code_header, sizeof(prog_header_t)); - WRITE_CHUNK(datmem, code->statements, sizeof(prog_section_statement_t) * vec_size(code->statements)); - WRITE_CHUNK(datmem, code->defs, sizeof(prog_section_def_t) * vec_size(code->defs)); - WRITE_CHUNK(datmem, code->fields, sizeof(prog_section_field_t) * vec_size(code->fields)); - WRITE_CHUNK(datmem, code->functions, sizeof(prog_section_function_t) * vec_size(code->functions)); - WRITE_CHUNK(datmem, code->globals, sizeof(int32_t) * vec_size(code->globals)); - WRITE_CHUNK(datmem, code->chars, 1 * vec_size(code->chars)); - - vec_free(code->statements); - vec_free(code->linenums); - vec_free(code->columnnums); - vec_free(code->defs); - vec_free(code->fields); - vec_free(code->functions); - vec_free(code->globals); - vec_free(code->chars); - - util_htdel(code->string_cache); - mem_d(code); - code_stats("<>", (lnomem) ? "<>" : NULL, code, &code_header); - return true; -} -#endif /*!#if 0 reenable when ready to be used */ -#undef WRITE_CHUNK - bool code_write(code_t *code, const char *filename, const char *lnofile) { prog_header_t code_header; FILE *fp = NULL; diff --git a/ftepp.c b/ftepp.c index a94eb11..c709366 100644 --- a/ftepp.c +++ b/ftepp.c @@ -251,13 +251,7 @@ static pptoken *pptoken_make(ftepp_t *ftepp) { pptoken *token = (pptoken*)mem_a(sizeof(pptoken)); token->token = ftepp->token; -#if 0 - if (token->token == TOKEN_WHITE) - token->value = util_strdup(" "); - else -#else - token->value = util_strdup(ftepp_tokval(ftepp)); -#endif + token->value = util_strdup(ftepp_tokval(ftepp)); memcpy(&token->constval, &ftepp->lex->tok.constval, sizeof(token->constval)); return token; } @@ -1754,10 +1748,6 @@ static bool ftepp_preprocess(ftepp_t *ftepp) { if (ftepp->token >= TOKEN_EOF) break; -#if 0 - newline = true; -#endif - switch (ftepp->token) { case TOKEN_KEYWORD: case TOKEN_IDENT: diff --git a/gmqcc.h b/gmqcc.h index 1bdce34..a6b5b1f 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -253,7 +253,7 @@ typedef struct { /* hidden interface */ void _util_vec_grow(void **a, size_t i, size_t s); -void _util_vec_delete(void *vec, size_t line, const char *file); +void _util_vec_delete(void *vec); #define GMQCC_VEC_WILLGROW(X, Y) ( \ ((!(X) || vec_meta(X)->used + Y >= vec_meta(X)->allocated)) ? \ @@ -263,7 +263,7 @@ void _util_vec_delete(void *vec, size_t line, const char *file); /* exposed interface */ #define vec_meta(A) ((vector_t*)(((char *)(A)) - sizeof(vector_t))) -#define vec_free(A) ((void)((A) ? (_util_vec_delete((void *)(A), __LINE__, __FILE__), (A) = NULL) : 0)) +#define vec_free(A) ((void)((A) ? (_util_vec_delete((void *)(A)), (A) = NULL) : 0)) #define vec_push(A,V) (GMQCC_VEC_WILLGROW((A),1), (A)[vec_meta(A)->used++] = (V)) #define vec_size(A) ((A) ? vec_meta(A)->used : 0) #define vec_add(A,N) (GMQCC_VEC_WILLGROW((A),(N)), vec_meta(A)->used += (N), &(A)[vec_meta(A)->used-(N)]) diff --git a/lexer.h b/lexer.h index 2d5ec0d..5e5d69e 100644 --- a/lexer.h +++ b/lexer.h @@ -38,22 +38,9 @@ struct token_s { int t; /* type */ } constval; -#if 0 - struct token_s *next; - struct token_s *prev; -#endif - lex_ctx_t ctx; }; -#if 0 -token* token_new(); -void token_delete(token*); -token* token_copy(const token *cp); -void token_delete_all(token *t); -token* token_copy_all(const token *cp); -#endif - /* Lexer * */ diff --git a/main.c b/main.c index 3f6f6ef..9f533b6 100644 --- a/main.c +++ b/main.c @@ -145,8 +145,6 @@ static bool options_parse(int argc, char **argv) { bool argend = false; size_t itr; char buffer[1024]; - char *redirout = NULL; - char *redirerr = NULL; char *config = NULL; char *memdumpcols = NULL; diff --git a/parser.c b/parser.c index 75014cb..6f35c11 100644 --- a/parser.c +++ b/parser.c @@ -426,18 +426,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) return false; } out = (ast_expression*)ast_array_index_new(ctx, exprs[0], exprs[1]); - if (rotate_entfield_array_index_nodes(&out)) - { -#if 0 - /* This is not broken in fteqcc anymore */ - if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) { - /* this error doesn't need to make us bail out */ - (void)!parsewarning(parser, WARN_EXTENSIONS, - "accessing array-field members of an entity without parenthesis\n" - " -> this is an extension from -std=gmqcc"); - } -#endif - } + rotate_entfield_array_index_nodes(&out); break; case opid1(','): @@ -1915,10 +1904,6 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma else if (!wantop) { if (!parse_sya_operand(parser, &sy, with_labels)) goto onerr; -#if 0 - if (vec_size(sy.paren) && vec_last(sy.ops).isparen && vec_last(sy.paren) == PAREN_FUNC) - vec_last(sy.argc)++; -#endif wantop = true; } else { @@ -2521,13 +2506,6 @@ static bool parse_for_go(parser_t *parser, ast_block *block, ast_expression **ou typevar = parser_find_typedef(parser, parser_tokval(parser), 0); if (typevar || parser->tok == TOKEN_TYPENAME) { -#if 0 - if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) { - if (parsewarning(parser, WARN_EXTENSIONS, - "current standard does not allow variable declarations in for-loop initializers")) - goto onerr; - } -#endif if (!parse_variable(parser, block, true, CV_VAR, typevar, false, false, 0, NULL)) goto onerr; } diff --git a/stat.c b/stat.c index 3643dfc..77955a7 100644 --- a/stat.c +++ b/stat.c @@ -69,7 +69,7 @@ void _util_vec_grow(void **a, size_t i, size_t s) { *a = d + 1; } -void _util_vec_delete(void *data, size_t line, const char *file) { +void _util_vec_delete(void *data) { mem_d(vec_meta(data)); }