added size adjustment to dynamic strings
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40205
This commit is contained in:
		
							parent
							
								
									7b2455db2e
								
							
						
					
					
						commit
						34c711fffd
					
				| @ -626,6 +626,7 @@ SC_FUNC void char2addr(void); | |||||||
| SC_FUNC void charalign(void); | SC_FUNC void charalign(void); | ||||||
| SC_FUNC void addconst(cell value); | SC_FUNC void addconst(cell value); | ||||||
| SC_FUNC void setheap_save(cell value); | SC_FUNC void setheap_save(cell value); | ||||||
|  | SC_FUNC void stradjust(regid reg); | ||||||
| 
 | 
 | ||||||
| /*  Code generation functions for arithmetic operators.
 | /*  Code generation functions for arithmetic operators.
 | ||||||
|  * |  * | ||||||
|  | |||||||
| @ -2241,7 +2241,10 @@ static int declloc(int fstatic) | |||||||
|         if (numdim == sDIMEN_MAX) { |         if (numdim == sDIMEN_MAX) { | ||||||
|           error(53);                      /* exceeding maximum number of dimensions */ |           error(53);                      /* exceeding maximum number of dimensions */ | ||||||
|           return (all_constant ? iARRAY : iREFARRAY); |           return (all_constant ? iARRAY : iREFARRAY); | ||||||
|         } /* if */ |         } else if (numdim) { /* if */ | ||||||
|  |           /* If we have a dimension on the stack, push it */ | ||||||
|  |           pushreg(sPRI); | ||||||
|  |         } | ||||||
|         if (matchtoken(']')) { |         if (matchtoken(']')) { | ||||||
|           dim[numdim++] = 0; |           dim[numdim++] = 0; | ||||||
|           continue; |           continue; | ||||||
| @ -2249,9 +2252,7 @@ static int declloc(int fstatic) | |||||||
|         dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val); |         dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val); | ||||||
|         if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) { |         if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) { | ||||||
|           all_constant = 0; |           all_constant = 0; | ||||||
|           pushreg(sPRI); |  | ||||||
|         } else if (dim_ident == iCONSTEXPR) { |         } else if (dim_ident == iCONSTEXPR) { | ||||||
|           pushreg(sPRI); |  | ||||||
|           dim[numdim] = dim_val.constval; |           dim[numdim] = dim_val.constval; | ||||||
| 		  /* :TODO: :URGENT: Make sure this still works */ | 		  /* :TODO: :URGENT: Make sure this still works */ | ||||||
|           if (dim_sym && dim_sym->usage & uENUMROOT) |           if (dim_sym && dim_sym->usage & uENUMROOT) | ||||||
| @ -2275,6 +2276,10 @@ static int declloc(int fstatic) | |||||||
|         ident = iARRAY; |         ident = iARRAY; | ||||||
|         stgdel(_index, _code); |         stgdel(_index, _code); | ||||||
|       } else { |       } else { | ||||||
|  |         if (tag == pc_tag_string && numdim && dim[numdim-1]) { | ||||||
|  |           stradjust(sPRI); | ||||||
|  |         } | ||||||
|  |         pushreg(sPRI); | ||||||
|         memset(dim, 0, sizeof(int)*sDIMEN_MAX); |         memset(dim, 0, sizeof(int)*sDIMEN_MAX); | ||||||
|         ident = iREFARRAY; |         ident = iREFARRAY; | ||||||
|         genarray(numdim, autozero); |         genarray(numdim, autozero); | ||||||
|  | |||||||
| @ -593,6 +593,13 @@ SC_FUNC void fillarray(symbol *sym,cell size,cell value) | |||||||
|   code_idx+=opcodes(2)+opargs(2); |   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
 | /* Instruction to get an immediate value into the primary or the alternate
 | ||||||
|  * register |  * register | ||||||
|  */ |  */ | ||||||
|  | |||||||
| @ -602,6 +602,7 @@ static OPCODEC opcodelist[] = { | |||||||
|   { 15, "stor.pri",   sIN_CSEG, parm1 }, |   { 15, "stor.pri",   sIN_CSEG, parm1 }, | ||||||
|   { 18, "stor.s.alt", sIN_CSEG, parm1 }, |   { 18, "stor.s.alt", sIN_CSEG, parm1 }, | ||||||
|   { 17, "stor.s.pri", sIN_CSEG, parm1 }, |   { 17, "stor.s.pri", sIN_CSEG, parm1 }, | ||||||
|  |   {164, "stradjust.pri", sIN_CSEG, parm0 }, | ||||||
|   { 24, "strb.i",     sIN_CSEG, parm1 }, |   { 24, "strb.i",     sIN_CSEG, parm1 }, | ||||||
|   { 79, "sub",        sIN_CSEG, parm0 }, |   { 79, "sub",        sIN_CSEG, parm0 }, | ||||||
|   { 80, "sub.alt",    sIN_CSEG, parm0 }, |   { 80, "sub.alt",    sIN_CSEG, parm0 }, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user