From f53fe346ae71bcd1e201c46a91cd31efda37c632 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 14 Sep 2006 07:02:02 +0000 Subject: [PATCH] changed this a bit to be nicer --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4070 --- sourcepawn/compiler/sc3.c | 8 ++++---- sourcepawn/compiler/sc4.c | 19 +++++++++---------- sourcepawn/compiler/sc6.c | 4 +++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index c09b0fa1..8c306b34 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -1165,7 +1165,7 @@ void dynarray_from_heaplist(heapuse_list_t *heap) } free(heap); if (total) - setheap_save(total); + setheap_save(-total*sizeof(cell)); } static int hier13(value *lval) @@ -1193,11 +1193,11 @@ static int hier13(value *lval) if (lval->ident==iCONSTEXPR) /* load constant here */ ldconst(lval->constval,sPRI); sc_allowtags=(short)POPSTK_I(); /* restore */ - jumplabel(flab2); - setlabel(flab1); heap=popsaveheaplist(); dynarray_from_heaplist(heap); pushheaplist(); + jumplabel(flab2); + setlabel(flab1); needtoken(':'); if (hier13(&lval2)) rvalue(&lval2); @@ -1215,9 +1215,9 @@ static int hier13(value *lval) /* ??? if both are arrays, should check dimensions */ if (!matchtag(lval->tag,lval2.tag,FALSE)) error(213); /* tagname mismatch ('true' and 'false' expressions) */ - setlabel(flab2); heap=popsaveheaplist(); dynarray_from_heaplist(heap); + setlabel(flab2); if (array1 && array2) { markheap(HEAPUSE_DYNAMIC, 0); } diff --git a/sourcepawn/compiler/sc4.c b/sourcepawn/compiler/sc4.c index d0d11830..f4d969af 100644 --- a/sourcepawn/compiler/sc4.c +++ b/sourcepawn/compiler/sc4.c @@ -846,22 +846,21 @@ SC_FUNC void modheap(int delta) SC_FUNC void modheap_i() { - stgwrite("\theap.i\n"); - code_idx+=opcodes(1); + pushreg(sPRI); + pushreg(sALT); + stgwrite("\tpop.h.pri\n"); + stgwrite("\theap.pri\n"); + code_idx+=opcodes(2); + popreg(sALT); + popreg(sPRI); } SC_FUNC void setheap_save(cell value) { - pushreg(sPRI); - pushreg(sALT); - stgwrite("\tconst.pri "); + assert(value); + stgwrite("\tpush.h.c "); outval(value, TRUE); code_idx+=opcodes(1)+opargs(1); - stgwrite("\theap "); - outval(sizeof(cell), TRUE); - stgwrite("\tstor.pri\n"); - popreg(sALT); - popreg(sPRI); } SC_FUNC void setheap_pri(void) diff --git a/sourcepawn/compiler/sc6.c b/sourcepawn/compiler/sc6.c index c8ad1082..7539a09b 100644 --- a/sourcepawn/compiler/sc6.c +++ b/sourcepawn/compiler/sc6.c @@ -493,7 +493,7 @@ static OPCODEC opcodelist[] = { { 99, "grtr", sIN_CSEG, parm0 }, {120, "halt", sIN_CSEG, parm1 }, { 45, "heap", sIN_CSEG, parm1 }, - {160, "heap.i", sIN_CSEG, parm0 }, + {160, "heap.pri", sIN_CSEG, parm0 }, { 27, "idxaddr", sIN_CSEG, parm0 }, { 28, "idxaddr.b", sIN_CSEG, parm1 }, {109, "inc", sIN_CSEG, parm1 }, @@ -544,12 +544,14 @@ static OPCODEC opcodelist[] = { { 84, "not", sIN_CSEG, parm0 }, { 82, "or", sIN_CSEG, parm0 }, { 43, "pop.alt", sIN_CSEG, parm0 }, + {162, "pop.h.pri", sIN_CSEG, parm0 }, { 42, "pop.pri", sIN_CSEG, parm0 }, { 46, "proc", sIN_CSEG, parm0 }, { 40, "push", sIN_CSEG, parm1 }, {133, "push.adr", sIN_CSEG, parm1 }, /* version 4 */ { 37, "push.alt", sIN_CSEG, parm0 }, { 39, "push.c", sIN_CSEG, parm1 }, + {161, "push.h.c", sIN_CSEG, parm1 }, { 36, "push.pri", sIN_CSEG, parm0 }, { 38, "push.r", sIN_CSEG, parm1 }, /* obsolete (never generated) */ { 41, "push.s", sIN_CSEG, parm1 },