added size adjustment to dynamic strings

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40205
This commit is contained in:
David Anderson 2006-12-09 01:20:33 +00:00
parent 7b2455db2e
commit 34c711fffd
4 changed files with 17 additions and 3 deletions

View File

@ -626,6 +626,7 @@ SC_FUNC void char2addr(void);
SC_FUNC void charalign(void);
SC_FUNC void addconst(cell value);
SC_FUNC void setheap_save(cell value);
SC_FUNC void stradjust(regid reg);
/* Code generation functions for arithmetic operators.
*

View File

@ -2241,7 +2241,10 @@ static int declloc(int fstatic)
if (numdim == sDIMEN_MAX) {
error(53); /* exceeding maximum number of dimensions */
return (all_constant ? iARRAY : iREFARRAY);
} /* if */
} else if (numdim) { /* if */
/* If we have a dimension on the stack, push it */
pushreg(sPRI);
}
if (matchtoken(']')) {
dim[numdim++] = 0;
continue;
@ -2249,9 +2252,7 @@ static int declloc(int fstatic)
dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val);
if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) {
all_constant = 0;
pushreg(sPRI);
} else if (dim_ident == iCONSTEXPR) {
pushreg(sPRI);
dim[numdim] = dim_val.constval;
/* :TODO: :URGENT: Make sure this still works */
if (dim_sym && dim_sym->usage & uENUMROOT)
@ -2275,6 +2276,10 @@ static int declloc(int fstatic)
ident = iARRAY;
stgdel(_index, _code);
} else {
if (tag == pc_tag_string && numdim && dim[numdim-1]) {
stradjust(sPRI);
}
pushreg(sPRI);
memset(dim, 0, sizeof(int)*sDIMEN_MAX);
ident = iREFARRAY;
genarray(numdim, autozero);

View File

@ -593,6 +593,13 @@ SC_FUNC void fillarray(symbol *sym,cell size,cell value)
code_idx+=opcodes(2)+opargs(2);
}
SC_FUNC void stradjust(regid reg)
{
assert(reg==sPRI);
stgwrite("\tstradjust.pri\n");
code_idx+=opcodes(1);
}
/* Instruction to get an immediate value into the primary or the alternate
* register
*/

View File

@ -602,6 +602,7 @@ static OPCODEC opcodelist[] = {
{ 15, "stor.pri", sIN_CSEG, parm1 },
{ 18, "stor.s.alt", sIN_CSEG, parm1 },
{ 17, "stor.s.pri", sIN_CSEG, parm1 },
{164, "stradjust.pri", sIN_CSEG, parm0 },
{ 24, "strb.i", sIN_CSEG, parm1 },
{ 79, "sub", sIN_CSEG, parm0 },
{ 80, "sub.alt", sIN_CSEG, parm0 },