From 0371d2cab6799891de96a38b221b666e136d5601 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 16 Dec 2005 17:15:43 +0000 Subject: [PATCH] Print out a warning count, added an entnum intrinsic. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1718 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc.h | 2 +- engine/qclib/qcc_pr_comp.c | 23 ++++++++++++++++++++++- engine/qclib/qcc_pr_lex.c | 5 +++++ engine/qclib/qccmain.c | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/engine/qclib/qcc.h b/engine/qclib/qcc.h index 6428d3d95..f5101f68c 100644 --- a/engine/qclib/qcc.h +++ b/engine/qclib/qcc.h @@ -752,7 +752,7 @@ void *QCC_PR_Malloc (int size); extern QCC_def_t *pr_scope; -extern int pr_error_count; +extern int pr_error_count, pr_warning_count; void QCC_PR_NewLine (pbool incomment); QCC_def_t *QCC_PR_GetDef (QCC_type_t *type, char *name, QCC_def_t *scope, pbool allocate, int arraysize); diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index 42ef7416d..8a81579ee 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -2471,6 +2471,26 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could def_ret.type = rettype; return &def_ret; } + else if (!strcmp(func->name, "entnum") && !QCC_PR_CheckToken(")")) + { + //t = (a/%1) / (nextent(world)/%1) + //a/%1 does a (int)entity to float conversion type thing + + e = QCC_PR_Expression(TOP_PRIORITY); + QCC_PR_Expect(")"); + e = QCC_PR_Statement(&pr_opcodes[OP_DIV_F], e, QCC_MakeIntDef(1), (QCC_dstatement_t **)0xffffffff); + + d = QCC_PR_GetDef(NULL, "nextent", NULL, false, 0); + if (!d) + QCC_PR_ParseError(0, "the nextent builtin is not defined"); + QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_STORE_F], e, &def_parms[0], (QCC_dstatement_t **)0xffffffff)); + d = QCC_PR_Statement(&pr_opcodes[OP_CALL0], d, NULL, NULL); + d = QCC_PR_Statement(&pr_opcodes[OP_DIV_F], d, QCC_MakeIntDef(1), (QCC_dstatement_t **)0xffffffff); + + e = QCC_PR_Statement(&pr_opcodes[OP_DIV_F], e, d, (QCC_dstatement_t **)0xffffffff); + + return e; + } } //so it's not an intrinsic. if (opt_precache_file) //should we strip out all precache_file calls? @@ -3276,7 +3296,8 @@ QCC_def_t *QCC_PR_ParseValue (QCC_type_t *assumeclass) if (!d) { if ( (!strcmp(name, "random" )) || - (!strcmp(name, "randomv")) ) //intrinsics, any old function with no args will do. + (!strcmp(name, "randomv")) || + (!strcmp(name, "entnum")) ) //intrinsics, any old function with no args will do. od = d = QCC_PR_GetDef (type_function, name, NULL, true, 1); else if (keyword_class && !strcmp(name, "this")) { diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index b6fa1d254..5bd577105 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -34,6 +34,7 @@ QCC_eval_t pr_immediate; char pr_immediate_string[8192]; int pr_error_count; +int pr_warning_count; CompilerConstant_t *CompilerConstant; @@ -2396,7 +2397,10 @@ void VARGS QCC_PR_ParseWarning (int type, char *error, ...) pr_error_count++; } else + { printf ("%s:%i: warning: %s\n", strings + s_file, pr_source_line, string); + pr_warning_count++; + } } void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...) @@ -2415,6 +2419,7 @@ void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...) printf ("%s:%i: warning: %s\n", file, line, string); else printf ("warning: %s\n", string); + pr_warning_count++; } diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index cea51d58b..8c0b464b3 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -1477,6 +1477,7 @@ void QCC_PR_BeginCompilation (void *memory, int memsize) pr.types = NULL; // type_function->next = NULL; pr_error_count = 0; + pr_warning_count = 0; recursivefunctiontype = 0; freeofs = NULL; @@ -3112,6 +3113,8 @@ void QCC_FinishCompile(void) printf("numtemps %i\n", numtemps); + printf("%i warnings\n", pr_warning_count); + qcc_compileactive = false; }