From bdd82f8c9fe3d9cb653435d2c289f7435dac600c Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Thu, 26 Oct 2000 14:15:06 +0000 Subject: [PATCH] * fixed setlength for shortstrings --- compiler/i386/n386inl.pas | 31 ++++++++++++++++++++++++++----- compiler/ninl.pas | 20 +++++++++++++++++++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/compiler/i386/n386inl.pas b/compiler/i386/n386inl.pas index 27536aab2c..30cd0ddcac 100644 --- a/compiler/i386/n386inl.pas +++ b/compiler/i386/n386inl.pas @@ -904,6 +904,7 @@ implementation r : preference; //hp : tcallparanode; hp2 : tstringconstnode; + dummycoll : tparaitem; l : longint; ispushed : boolean; hregister : tregister; @@ -1379,7 +1380,19 @@ implementation emit_push_loc(tcallparanode(hp).left.location); hp:=tcallparanode(hp).right; end; - secondpass(tcallparanode(hp).left); + { handle shortstrings separately since the hightree must be } + { pushed too (JM) } + if not(is_dynamic_array(def)) and + (pstringdef(def)^.string_typ = st_shortstring) then + begin + dummycoll.init; + dummycoll.paratyp:=vs_var; + dummycoll.paratype.setdef(openshortstringdef); + tcallparanode(hp).secondcallparan(@dummycoll,false,false,false,0,0); + if codegenerror then + exit; + end + else secondpass(tcallparanode(hp).left); if is_dynamic_array(def) then begin emitpushreferenceaddr(hr); @@ -1394,12 +1407,17 @@ implementation else { must be string } begin - emitpushreferenceaddr(tcallparanode(hp).left.location.reference); case pstringdef(def)^.string_typ of st_widestring: - emitcall('FPC_WIDESTR_SETLENGTH'); + begin + emitpushreferenceaddr(tcallparanode(hp).left.location.reference); + emitcall('FPC_WIDESTR_SETLENGTH'); + end; st_ansistring: - emitcall('FPC_ANSISTR_SETLENGTH'); + begin + emitpushreferenceaddr(tcallparanode(hp).left.location.reference); + emitcall('FPC_ANSISTR_SETLENGTH'); + end; st_shortstring: emitcall('FPC_SHORTSTR_SETLENGTH'); end; @@ -1612,7 +1630,10 @@ begin end. { $Log$ - Revision 1.2 2000-10-21 18:16:13 florian + Revision 1.3 2000-10-26 14:15:07 jonas + * fixed setlength for shortstrings + + Revision 1.2 2000/10/21 18:16:13 florian * a lot of changes: - basic dyn. array support - basic C++ support diff --git a/compiler/ninl.pas b/compiler/ninl.pas index c7a4c49423..8a99f05771 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -104,6 +104,7 @@ implementation vr : bestreal; p1,hp,hpp : tnode; ppn : tcallparanode; + dummycoll: tparaitem; {$ifndef NOCOLONCHECK} frac_para,length_para : tnode; {$endif ndef NOCOLONCHECK} @@ -691,6 +692,20 @@ implementation if (counter>1) and (not(is_dynamic_array(left.resulttype))) then CGMessage(type_e_mismatch); + + { convert shortstrings to openstring parameters } + { (generate the hightree) (JM) } + if (ppn.left.resulttype^.deftype = stringdef) and + (pstringdef(ppn.left.resulttype)^.string_typ = + st_shortstring) then + begin + dummycoll.init; + dummycoll.paratyp:=vs_var; + dummycoll.paratype.setdef(openshortstringdef); + tcallparanode(ppn).firstcallparan(@dummycoll,false); + if codegenerror then + exit; + end; end else CGMessage(type_e_mismatch); @@ -1449,7 +1464,10 @@ begin end. { $Log$ - Revision 1.10 2000-10-21 18:16:11 florian + Revision 1.11 2000-10-26 14:15:06 jonas + * fixed setlength for shortstrings + + Revision 1.10 2000/10/21 18:16:11 florian * a lot of changes: - basic dyn. array support - basic C++ support