divVerent's patch to fix += operations involving function calls.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3704 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-12-22 00:13:49 +00:00
parent 47c3a6873b
commit 3a413ede89

View file

@ -1386,6 +1386,12 @@ static void QCC_LockActiveTemps(void)
}
static void QCC_LockTemp(QCC_def_t *d)
{
if (d->temp && d->temp->used)
d->temp->scope = pr_scope;
}
static void QCC_RemapLockedTemp(temp_t *t, int firststatement, int laststatement)
{
#ifdef WRITEASM
@ -2236,19 +2242,24 @@ QCC_def_t *QCC_PR_Statement ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var
//don't chain these... this expansion is not the same.
{
int st;
int need_lock = false;
for (st = numstatements-2; st>=0; st--)
{
if (statements[st].op == OP_ADDRESS)
if (statements[st].c == var_b->ofs)
break;
if ((statements[st].op >= OP_CALL0 && statements[st].op <= OP_CALL8) || (statements[st].op >= OP_CALL1H && statements[st].op <= OP_CALL8H))
need_lock = true;
if (statements[st].c == var_b->ofs)
QCC_PR_ParseWarning(0, "Temp-reuse may have broken your %s", op->name);
}
if (st < 0)
QCC_PR_ParseError(ERR_INTERNAL, "XSTOREP_F: pointer was not generated from previous statement");
var_c = QCC_GetTemp(*op->type_c);
if (need_lock)
QCC_LockTemp(var_c); /*that temp needs to be preserved over calls*/
statement_linenums[statement-statements] = statement_linenums[st];
statement->op = OP_ADDRESS;
@ -2369,11 +2380,15 @@ QCC_def_t *QCC_PR_Statement ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var
//don't chain these... this expansion is not the same.
{
int st;
int need_lock = false;
for (st = numstatements-2; st>=0; st--)
{
if (statements[st].op == OP_ADDRESS)
if (statements[st].c == var_b->ofs)
break;
if ((statements[st].op >= OP_CALL0 && statements[st].op <= OP_CALL8) || (statements[st].op >= OP_CALL1H && statements[st].op <= OP_CALL8H))
need_lock = true;
if (statements[st].c == var_b->ofs)
QCC_PR_ParseWarning(0, "Temp-reuse may have broken your %s", op->name);
@ -2381,6 +2396,8 @@ QCC_def_t *QCC_PR_Statement ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var
if (st < 0)
QCC_PR_ParseError(ERR_INTERNAL, "XSTOREP_V couldn't find pointer generation");
var_c = QCC_GetTemp(*op->type_c);
if (need_lock)
QCC_LockTemp(var_c); /*that temp needs to be preserved over calls*/
statement_linenums[statement-statements] = statement_linenums[st];
statement->op = OP_ADDRESS;
@ -8195,7 +8212,7 @@ QCC_def_t *QCC_PR_DummyFieldDef(QCC_type_t *type, char *name, QCC_def_t *scope,
def->ofs = QCC_GetFreeOffsetSpace(1);
((int *)qcc_pr_globals)[def->ofs] = *fieldofs;
*fieldofs++;
fieldofs++;
if (!first)
first = def;
}