Some qcc changes.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3905 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-10-03 02:45:44 +00:00
parent a3a5e56b29
commit f3bbed043b
8 changed files with 570 additions and 1402 deletions

View File

@ -297,7 +297,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "bad pointer write in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
ptr->_float = (float)OPA->_int;
@ -306,7 +306,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "bad pointer write in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
ptr->_int = (int)OPA->_float;
@ -315,7 +315,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "bad pointer write in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
ptr->_int = OPA->_int;
@ -328,7 +328,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s (%x >= %x)", progfuncs->stringtable + pr_xfunction->s_name, OPB->_int, addressableused);
PR_RunError (progfuncs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(progfuncs, pr_xfunction->s_name), OPB->_int, addressableused);
}
ptr = QCPOINTER(OPB);
ptr->_int = OPA->_int;
@ -337,7 +337,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "bad pointer write in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
ptr->_vector[0] = OPA->_vector[0];
@ -349,7 +349,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "bad pointer write in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
*(unsigned char *)ptr = (char)OPA->_float;
@ -367,7 +367,7 @@ reeval:
if ((unsigned int)OPB->_int >= addressableused)
{
pr_xstatement = st-pr_statements;
PR_RunError (progfuncs, "bad pointer write in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "bad pointer write in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
OPC->_float = (ptr->_float *= OPA->_float);
@ -432,7 +432,7 @@ reeval:
{
#ifndef DEBUGABLE
pr_trace++;
printf("OP_ADDRESS references invalid entity in %s", progfuncs->stringtable + pr_xfunction->s_name);
printf("OP_ADDRESS references invalid entity in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
st--;
goto cont;
#else
@ -449,7 +449,7 @@ reeval:
#ifndef DEBUGABLE
//boot it over to the debugger
pr_trace++;
printf("assignment to read-only entity in %s", progfuncs->stringtable + pr_xfunction->s_name);
printf("assignment to read-only entity in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
st--;
goto cont;
#else
@ -458,7 +458,7 @@ reeval:
fdef_t *f;
d16 = ED_GlobalAtOfs16(progfuncs, st->a);
f = ED_FieldAtOfs(progfuncs, OPB->_int + progfuncs->fieldadjust);
PR_RunError (progfuncs, "assignment to read-only entity in %s (%s.%s)", PR_StringToNative(progfuncs, pr_xfunction->s_name), PR_StringToNative(progfuncs, d16->s_name), f?f->name:NULL);
PR_RunError (progfuncs, "assignment to read-only entity in %s (%s.%s)", PR_StringToNative(progfuncs, pr_xfunction->s_name), d16?PR_StringToNative(progfuncs, d16->s_name):NULL, f?f->name:NULL);
}
#endif
}
@ -467,7 +467,7 @@ reeval:
// if (ed->isfree)
// {
// pr_xstatement = st-pr_statements;
// PR_RunError (progfuncs, "assignment to free entitiy in %s", progfuncs->stringtable + pr_xfunction->s_name);
// PR_RunError (progfuncs, "assignment to free entitiy in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
// }
OPC->_int = ENGINEPOINTER((((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust));
break;
@ -480,7 +480,7 @@ reeval:
case OP_LOAD_S:
case OP_LOAD_FNC:
if ((unsigned)OPA->edict >= (unsigned)maxedicts)
PR_RunError (progfuncs, "OP_LOAD references invalid entity in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "OP_LOAD references invalid entity in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
ed = PROG_TO_EDICT(progfuncs, OPA->edict);
#ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range
@ -491,7 +491,7 @@ reeval:
case OP_LOAD_V:
if ((unsigned)OPA->edict >= (unsigned)maxedicts)
PR_RunError (progfuncs, "OP_LOAD_V references invalid entity in %s", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError (progfuncs, "OP_LOAD_V references invalid entity in %s", PR_StringToNative(progfuncs, pr_xfunction->s_name));
ed = PROG_TO_EDICT(progfuncs, OPA->edict);
#ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range
@ -579,7 +579,7 @@ reeval:
fnum = OPA->function;
if ((fnum & ~0xff000000)==0)
{
PR_RunError(progfuncs, "NULL function from qc (%s).\n", progfuncs->stringtable + pr_xfunction->s_name);
PR_RunError(progfuncs, "NULL function from qc (%s).\n", PR_StringToNative(progfuncs, pr_xfunction->s_name));
#ifndef DEBUGABLE
goto cont;
#endif
@ -592,24 +592,24 @@ reeval:
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
p=pr_typecurrent;
{
int callerprogs=pr_typecurrent;
//about to switch. needs caching.
//if it's an external call, switch now (before any function pointers are used)
PR_MoveParms(progfuncs, (fnum & 0xff000000)>>24, p);
PR_MoveParms(progfuncs, (fnum & 0xff000000)>>24, callerprogs);
PR_SwitchProgs(progfuncs, (fnum & 0xff000000)>>24);
newf = &pr_functions[fnum & ~0xff000000];
if (newf->first_statement < 0)
{ // negative statements are built in functions
if (pr_typecurrent != 0)
{
PR_MoveParms(progfuncs, 0, pr_typecurrent);
PR_SwitchProgs(progfuncs, 0);
}
/*calling a builtin in another progs may affect that other progs' globals instead, is the theory anyway, so args and stuff need to move over*/
if (pr_typecurrent != 0)
{
PR_MoveParms(progfuncs, 0, pr_typecurrent);
PR_SwitchProgs(progfuncs, 0);
}
i = -newf->first_statement;
// p = pr_typecurrent;
progfuncs->lastcalledbuiltinnumber = i;
@ -637,9 +637,9 @@ if (pr_typecurrent != 0)
else
current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals);
}
PR_MoveParms(progfuncs, p, pr_typecurrent);
PR_MoveParms(progfuncs, callerprogs, pr_typecurrent);
// memcpy(&pr_progstate[p].globals[OFS_RETURN], &current_progstate->globals[OFS_RETURN], sizeof(vec3_t));
PR_SwitchProgs(progfuncs, (progsnum_t)p);
PR_SwitchProgs(progfuncs, (progsnum_t)callerprogs);
//#ifndef DEBUGABLE //decide weather non debugger wants to start debugging.
s = st-pr_statements;
@ -649,8 +649,9 @@ if (pr_typecurrent != 0)
}
// PR_MoveParms((OPA->function & 0xff000000)>>24, pr_typecurrent);
// PR_SwitchProgs((OPA->function & 0xff000000)>>24);
s = PR_EnterFunction (progfuncs, newf, p);
s = PR_EnterFunction (progfuncs, newf, callerprogs);
st = &pr_statements[s];
}
goto restart;
// break;
@ -788,7 +789,7 @@ if (pr_typecurrent != 0)
case OP_LOADP_ENT:
case OP_LOADP_S:
case OP_LOADP_FNC:
ptr = QCPOINTERM(OPA->_int + OPB->_int*p);
ptr = QCPOINTERM(OPA->_int + OPB->_int*4);
OPC->_int = ptr->_int;
break;
@ -1104,7 +1105,7 @@ if (pr_typecurrent != 0)
{
pr_xstatement = s = st-pr_statements;
printf("Break point hit in %s.\n", pr_xfunction->s_name+progfuncs->stringtable);
printf("Break point hit in %s.\n", PR_StringToNative(progfuncs, pr_xfunction->s_name));
if (pr_trace<1)
pr_trace=1; //this is what it's for

View File

@ -512,6 +512,7 @@ char *ASMCALL PR_StringToNative (progfuncs_t *progfuncs, string_t str)
if (i >= prinst->numallocedstrings)
{
printf("invalid string %x\n", str);
PR_StackTrace(progfuncs);
pr_trace = 1;
return "";
}
@ -520,6 +521,7 @@ char *ASMCALL PR_StringToNative (progfuncs_t *progfuncs, string_t str)
else
{
printf("invalid string %x\n", str);
PR_StackTrace(progfuncs);
pr_trace = 1;
return ""; //urm, was freed...
}
@ -530,6 +532,7 @@ char *ASMCALL PR_StringToNative (progfuncs_t *progfuncs, string_t str)
if (i >= prinst->numtempstrings)
{
printf("invalid temp string %x\n", str);
PR_StackTrace(progfuncs);
pr_trace = 1;
return "";
}
@ -540,6 +543,7 @@ char *ASMCALL PR_StringToNative (progfuncs_t *progfuncs, string_t str)
if (str >= addressableused)
{
printf("invalid string offset %x\n", str);
PR_StackTrace(progfuncs);
pr_trace = 1;
return "";
}

View File

@ -853,7 +853,6 @@ void PR_ExecuteCode (progfuncs_t *progfuncs, int s)
dfunction_t *newf;
int runaway;
int i;
int p;
edictrun_t *ed;
eval_t *ptr;
@ -879,7 +878,7 @@ void PR_ExecuteCode (progfuncs_t *progfuncs, int s)
{ \
pr_xstatement = st-pr_statements; \
PR_StackTrace(progfuncs); \
printf ("runaway loop error"); \
printf ("runaway loop error\n"); \
while(pr_depth > prinst->exitdepth) \
PR_LeaveFunction(progfuncs); \
pr_spushed = 0; \

View File

@ -181,6 +181,8 @@ typedef struct progexterns_s {
unsigned int *sv_num_edicts; //pointer to the engine's edict count.
int (*useeditor) (progfuncs_t *prinst, char *filename, int line, int nump, char **parms); //called on syntax errors or step-by-step debugging.
void *user; /*contains the owner's world reference in FTE*/
} progparms_t, progexterns_t;
//FIXMEs

View File

@ -305,6 +305,7 @@ typedef struct QCC_type_s
unsigned int ofs; //inside a structure.
unsigned int size;
unsigned int arraysize;
char *name;
} QCC_type_t;
int typecmp(QCC_type_t *a, QCC_type_t *b);
@ -554,7 +555,7 @@ pbool QCC_PR_CheckKeyword(int keywordenabled, char *string);
#endif
void VARGS QCC_PR_ParseError (int errortype, char *error, ...);
void VARGS QCC_PR_ParseWarning (int warningtype, char *error, ...);
void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...);
pbool VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...);
void VARGS QCC_PR_Note (int type, char *file, int line, char *error, ...);
void QCC_PR_ParsePrintDef (int warningtype, QCC_def_t *def);
void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error, ...);

File diff suppressed because it is too large Load Diff

View File

@ -647,11 +647,6 @@ pbool QCC_PR_Precompiler(void)
if (*pr_file_p == '\r')
pr_file_p++;
for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
msg[a] = pr_file_p[a];
msg[a-1] = '\0';
while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
{
pr_file_p++;
@ -859,7 +854,7 @@ pbool QCC_PR_Precompiler(void)
if (!strcmp(sourcefileslist[i], qcc_token))
break;
}
if (i == numsourcefiles)
if (i == numsourcefiles && numsourcefiles < MAXSOURCEFILESLIST)
strcpy(sourcefileslist[numsourcefiles++], qcc_token);
}
else if (!QC_strcasecmp(qcc_token, "TARGET"))
@ -869,7 +864,7 @@ pbool QCC_PR_Precompiler(void)
else if (!QC_strcasecmp(msg, "H2") || !QC_strcasecmp(msg, "HEXEN2"))
{
if (numstatements)
QCC_PR_ParseWarning(WARN_BADTARGET, "Cannot switch from hexen2 target \'%s\'. Ignored.", msg);
QCC_PR_ParseWarning(WARN_BADTARGET, "Cannot switch to hexen2 target \'%s\'. Ignored.", msg);
else
qcc_targetformat = QCF_HEXEN2;
}
@ -1692,6 +1687,7 @@ void QCC_PR_LexWhitespace (void)
}
if (pr_file_p[1] == 0)
{
QCC_PR_ParseError(0, "EOF inside comment\n");
pr_file_p++;
return;
}
@ -2700,13 +2696,13 @@ void VARGS QCC_PR_Note (int type, char *file, int line, char *error, ...)
printf ("note: %s\n", string);
}
void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...)
pbool VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...)
{
va_list argptr;
char string[1024];
if (qccwarningdisabled[type])
return;
return false;
va_start (argptr,error);
QC_vsnprintf (string,sizeof(string)-1, error,argptr);
@ -2723,6 +2719,8 @@ void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...)
else
printf ("warning: %s\n", string);
pr_warning_count++;
return true;
}
@ -3428,7 +3426,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
QCC_PR_Lex();
if (QCC_PR_CheckToken("["))
{
newparm->size*=QCC_PR_IntConstExpr();
newparm->arraysize=QCC_PR_IntConstExpr();
QCC_PR_Expect("]");
}
QCC_PR_CheckToken(";");
@ -3436,7 +3434,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
else
newparm->name = QCC_CopyString("")+strings;
newparm->ofs = newt->size;
newt->size += newparm->size;
newt->size += newparm->size*newparm->arraysize;
newt->num_parms++;
if (type)
@ -3473,11 +3471,16 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
{
newparm->name = QCC_CopyString(pr_token)+strings;
QCC_PR_Lex();
if (QCC_PR_CheckToken("["))
{
newparm->arraysize=QCC_PR_IntConstExpr();
QCC_PR_Expect("]");
}
QCC_PR_Expect(";");
}
newparm->ofs = 0;
if (newparm->size > newt->size)
newt->size = newparm->size;
if (newparm->size > newt->size*newparm->arraysize)
newt->size = newparm->size*newparm->arraysize;
newt->num_parms++;
if (type)

View File

@ -98,6 +98,8 @@ hashtable_t globalstable;
hashtable_t localstable;
hashtable_t floatconstdefstable;
hashtable_t stringconstdefstable;
hashtable_t stringconstdefstable_trans;
extern int dotranslate_count;
pbool qccwarningdisabled[WARN_MAX];
@ -725,14 +727,14 @@ pbool QCC_WriteData (int crc)
}
if (def->references<=0)
{
if (def->constant)
QCC_PR_Warning(WARN_NOTREFERENCEDCONST, strings + def->s_file, def->s_line, "%s no references", def->name);
else
QCC_PR_Warning(WARN_NOTREFERENCED, strings + def->s_file, def->s_line, "%s no references", def->name);
if (!warnedunref)
int wt = def->constant?WARN_NOTREFERENCEDCONST:WARN_NOTREFERENCED;
if (QCC_PR_Warning(wt, strings + def->s_file, def->s_line, "%s no references", def->name))
{
QCC_PR_Note(WARN_NOTREFERENCED, NULL, 0, "You can use the noref prefix or pragma to silence this message.");
warnedunref = true;
if (!warnedunref)
{
QCC_PR_Note(WARN_NOTREFERENCED, NULL, 0, "You can use the noref prefix or pragma to silence this message.");
warnedunref = true;
}
}
if (opt_unreferenced && def->type->type != ev_field)
@ -1603,6 +1605,7 @@ QCC_type_t *QCC_PR_NewType (char *name, int basictype)
qcc_typeinfo[numtypeinfos].num_parms = 0;
qcc_typeinfo[numtypeinfos].param = NULL;
qcc_typeinfo[numtypeinfos].size = type_size[basictype];
qcc_typeinfo[numtypeinfos].arraysize = 1;
numtypeinfos++;
@ -1733,7 +1736,8 @@ int QCC_PR_FinishCompilation (void)
}
else
{
QCC_PR_ParseErrorPrintDef(ERR_NOFUNC, d, "function %s was not defined",d->name);
QCC_PR_ParseWarning(ERR_NOFUNC, "function %s was not defined",d->name);
QCC_PR_ParsePrintDef(ERR_NOFUNC, d);
bodylessfuncs = true;
errors = true;
}
@ -2991,10 +2995,12 @@ void QCC_main (int argc, char **argv) //as part of the quake engine
qcc_pr_globals = (void *)qccHunkAlloc(sizeof(float) * MAX_REGS);
numpr_globals=0;
Hash_InitTable(&globalstable, MAX_REGS, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS)));
Hash_InitTable(&localstable, MAX_REGS, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS)));
Hash_InitTable(&floatconstdefstable, MAX_REGS+1, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS+1)));
Hash_InitTable(&stringconstdefstable, MAX_REGS, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS)));
Hash_InitTable(&globalstable, MAX_REGS/2, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS/2)));
Hash_InitTable(&localstable, MAX_REGS/2, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS/2)));
Hash_InitTable(&floatconstdefstable, MAX_REGS/2+1, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS/2+1)));
Hash_InitTable(&stringconstdefstable, MAX_REGS/2, qccHunkAlloc(Hash_BytesForBuckets(MAX_REGS/2)));
Hash_InitTable(&stringconstdefstable_trans, 1000, qccHunkAlloc(Hash_BytesForBuckets(1000)));
dotranslate_count = 0;
// pr_global_defs = (QCC_def_t **)qccHunkAlloc(sizeof(QCC_def_t *) * MAX_REGS);