From 8705adfb86b1464274f20ee2d1f7211f841cd80d Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 30 Jun 2022 04:12:24 +0000 Subject: [PATCH] Revision 6270 was bad. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6282 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/qclib/qcc_pr_comp.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index bf16c7f0..30c1ddd8 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -7068,7 +7068,7 @@ QCC_sref_t QCC_PR_GenerateFunctionCallRef (QCC_sref_t newself, QCC_sref_t func, copyop[2] = OP_LOADA_V; copyop[1] = OP_LOADA_I64; copyop[0] = OP_LOADA_F; - copyop_idx = 0; //offset the base ref + copyop_idx = -2; //offset the base ref copyop_index = arglist[i]->index; copyop_index = QCC_SupplyConversion(copyop_index, ev_integer, true); sref = arglist[i]->base; @@ -7089,6 +7089,11 @@ QCC_sref_t QCC_PR_GenerateFunctionCallRef (QCC_sref_t newself, QCC_sref_t func, copyop[0] = OP_LOAD_F; copyop_index = arglist[i]->index; copyop_idx = -1; + if (!QCC_SRef_EvalConst(copyop_index)) + { //if its a variable then its probably not a proper field (which has extra field ref values following it). do the shitty thing and make assumptions about ordering. :( + copyop_index.cast = type_integer; + copyop_idx = OP_ADD_I; + } sref = arglist[i]->base; break; case REF_POINTER: @@ -7138,6 +7143,11 @@ QCC_sref_t QCC_PR_GenerateFunctionCallRef (QCC_sref_t newself, QCC_sref_t func, newindex.ofs += ofs; QCC_UnFreeTemp(copyop_index); } + else if (copyop_idx == -2) + { //with this mode, the base reference can just be updated. no mess with the index. + newindex = copyop_index; + QCC_UnFreeTemp(copyop_index); + } else if (copyop_idx == OP_ADD_I) { if (!copyop_index.cast) @@ -7238,7 +7248,15 @@ QCC_sref_t QCC_PR_GenerateFunctionCallRef (QCC_sref_t newself, QCC_sref_t func, QCC_FreeTemp(copyop_index); } QCC_FreeTemp(newindex); - QCC_PR_SimpleStatement(&pr_opcodes[copyop[asz-1]], src, newindex, fparm, false); + + if (copyop_idx == -2) + { //with this mode, the base reference can just be updated. no mess with the index. + src.ofs += ofs; + QCC_PR_SimpleStatement(&pr_opcodes[copyop[asz-1]], src, newindex, fparm, false); + src.ofs -= ofs; + } + else + QCC_PR_SimpleStatement(&pr_opcodes[copyop[asz-1]], src, newindex, fparm, false); } ofs += asz;