2
0
Эх сурвалжийг харах

+ first part of support for an unicodestring type

git-svn-id: trunk@9382 -
florian 17 жил өмнө
parent
commit
5c96c4a671

+ 2 - 0
compiler/browcol.pas

@@ -1301,6 +1301,8 @@ end;
         Name:='ansistring';
       st_widestring :
         Name:='widestring';
+      st_unicodestring :
+        Name:='unicodestring';
     else ;
     end;
     GetStringDefStr:=Name;

+ 1 - 0
compiler/dbgdwarf.pas

@@ -1420,6 +1420,7 @@ implementation
              append_labelentry_ref(DW_AT_type,def_dwarf_lab(cchartype));
              finish_entry;
            end;
+         st_unicodestring,
          st_widestring:
            begin
              { looks like a pwidechar }

+ 2 - 1
compiler/dbgstabs.pas

@@ -505,6 +505,7 @@ implementation
                  charst:=def_stab_number(cchartype);
                  result:=strpnew('*'+charst);
                end;
+             st_unicodestring,
              st_widestring:
                begin
                  { looks like a pwidechar }
@@ -852,7 +853,7 @@ implementation
         case def.typ of
           stringdef :
             begin
-              if tstringdef(def).stringtype=st_widestring then
+              if tstringdef(def).stringtype in [st_widestring,st_unicodestring] then
                 insertdef(list,cwidechartype)
               else
                 begin

+ 11 - 3
compiler/defcmp.pas

@@ -331,9 +331,9 @@ implementation
                            doconv:=tc_string_2_string;
                            { Don't prefer conversions from widestring to a
                              normal string as we can loose information }
-                           if tstringdef(def_from).stringtype=st_widestring then
+                           if tstringdef(def_from).stringtype in [st_widestring,st_unicodestring] then
                              eq:=te_convert_l3
-                           else if tstringdef(def_to).stringtype=st_widestring then
+                           else if tstringdef(def_to).stringtype in [st_widestring,st_unicodestring] then
                              eq:=te_convert_l2
                            else
                              eq:=te_equal;
@@ -357,6 +357,14 @@ implementation
                                else
                                  eq:=te_convert_l3;
                              end;
+                           st_unicodestring :
+                             begin
+                               { Prefer conversions to ansistring }
+                               if tstringdef(def_to).stringtype=st_ansistring then
+                                 eq:=te_convert_l2
+                               else
+                                 eq:=te_convert_l3;
+                             end;
                            st_shortstring :
                              begin
                                { Prefer shortstrings of different length or conversions
@@ -371,7 +379,7 @@ implementation
                            st_ansistring :
                              begin
                                { Prefer conversion to widestrings }
-                               if (tstringdef(def_to).stringtype=st_widestring) then
+                               if (tstringdef(def_to).stringtype in [st_widestring,st_unicodestring]) then
                                  eq:=te_convert_l2
                                else
                                  eq:=te_convert_l3;

+ 1 - 1
compiler/htypechk.pas

@@ -2201,7 +2201,7 @@ implementation
           (tve_single,tve_dblcurrency,tve_extended,
            tve_dblcurrency,tve_dblcurrency,tve_extended);
         variantstringdef_cl: array[tstringtype] of tvariantequaltype =
-          (tve_sstring,tve_astring,tve_astring,tve_wstring);
+          (tve_sstring,tve_astring,tve_astring,tve_wstring,tve_unicodestring);
       begin
         result:=tve_incompatible;
         case def.typ of

+ 3 - 2
compiler/ncon.pas

@@ -112,7 +112,8 @@ interface
          cst_shortstring,
          cst_longstring,
          cst_ansistring,
-         cst_widestring
+         cst_widestring,
+         cst_unicodestring
        );
 
        tstringconstnode = class(tnode)
@@ -908,7 +909,7 @@ implementation
     procedure tstringconstnode.changestringtype(def:tdef);
       const
         st2cst : array[tstringtype] of tconststringtype = (
-          cst_shortstring,cst_longstring,cst_ansistring,cst_widestring
+          cst_shortstring,cst_longstring,cst_ansistring,cst_widestring,cst_unicodestring
         );
       var
         pw : pcompilerwidestring;

+ 1 - 0
compiler/ppu.pas

@@ -121,6 +121,7 @@ const
   ibwidestringdef  = 56;
   ibvariantdef     = 57;
   ibundefineddef   = 58;
+  ibunicodestringdef = 59;
   {implementation/ObjData}
   ibnodetree       = 80;
   ibasmsymbols     = 81;

+ 6 - 2
compiler/psystem.pas

@@ -141,8 +141,9 @@ implementation
         cshortstringtype:=tstringdef.createshort(255);
         { should we give a length to the default long and ansi string definition ?? }
         clongstringtype:=tstringdef.createlong(-1);
-        cansistringtype:=tstringdef.createansi(-1);
-        cwidestringtype:=tstringdef.createwide(-1);
+        cansistringtype:=tstringdef.createansi;
+        cwidestringtype:=tstringdef.createwide;
+        cunicodestringtype:=tstringdef.createunicode;
         { length=0 for shortstring is open string (needed for readln(string) }
         openshortstringtype:=tstringdef.createshort(0);
         openchararraytype:=tarraydef.create(0,-1,s32inttype);
@@ -246,6 +247,7 @@ implementation
 {$endif support_longstring}
         addtype('AnsiString',cansistringtype);
         addtype('WideString',cwidestringtype);
+        addtype('UnicodeString',cunicodestringtype);
         addtype('OpenString',openshortstringtype);
         addtype('Boolean',booltype);
         addtype('ByteBool',booltype);
@@ -285,6 +287,7 @@ implementation
         addtype('$longstring',clongstringtype);
         addtype('$ansistring',cansistringtype);
         addtype('$widestring',cwidestringtype);
+        addtype('$unicodestring',cwidestringtype);
         addtype('$openshortstring',openshortstringtype);
         addtype('$boolean',booltype);
         addtype('$boolean16',bool16type);
@@ -369,6 +372,7 @@ implementation
         loadtype('longstring',clongstringtype);
         loadtype('ansistring',cansistringtype);
         loadtype('widestring',cwidestringtype);
+        loadtype('unicodestring',cunicodestringtype);
         loadtype('openshortstring',openshortstringtype);
         loadtype('openchararray',openchararraytype);
         loadtype('s32real',s32floattype);

+ 3 - 1
compiler/symconst.pas

@@ -186,7 +186,8 @@ type
     st_shortstring,
     st_longstring,
     st_ansistring,
-    st_widestring
+    st_widestring,
+    st_unicodestring
   );
 
   { set types }
@@ -445,6 +446,7 @@ type
   tvariantequaltype = (
     tve_incompatible,
     tve_chari64,
+    tve_unicodestring,
     tve_wstring,
     tve_astring,
     tve_sstring,

+ 36 - 12
compiler/symdef.pas

@@ -500,10 +500,12 @@ interface
           constructor loadshort(ppufile:tcompilerppufile);
           constructor createlong(l : aint);
           constructor loadlong(ppufile:tcompilerppufile);
-          constructor createansi(l : aint);
+          constructor createansi;
           constructor loadansi(ppufile:tcompilerppufile);
-          constructor createwide(l : aint);
+          constructor createwide;
           constructor loadwide(ppufile:tcompilerppufile);
+          constructor createunicode;
+          constructor loadunicode(ppufile:tcompilerppufile);
           function getcopy : tstoreddef;override;
           function  stringtypname:string;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
@@ -593,6 +595,7 @@ interface
        clongstringtype,           { pointer to type of long string const   }
        cansistringtype,           { pointer to type of ansi string const  }
        cwidestringtype,           { pointer to type of wide string const  }
+       cunicodestringtype,
        openshortstringtype,       { pointer to type of an open shortstring,
                                     needed for readln() }
        openchararraytype,         { pointer to type of an open array of char,
@@ -720,6 +723,7 @@ implementation
       varlongword = 19;
       varint64 = 20;
       varqword = 21;
+      varunicodestr = 22;
 
       varUndefined = -1;
 
@@ -1127,11 +1131,11 @@ implementation
       end;
 
 
-    constructor tstringdef.createansi(l:aint);
+    constructor tstringdef.createansi;
       begin
          inherited create(stringdef);
          stringtype:=st_ansistring;
-         len:=l;
+         len:=-1;
          savesize:=sizeof(aint);
       end;
 
@@ -1145,11 +1149,11 @@ implementation
       end;
 
 
-    constructor tstringdef.createwide(l : aint);
+    constructor tstringdef.createwide;
       begin
          inherited create(stringdef);
          stringtype:=st_widestring;
-         len:=l;
+         len:=-1;
          savesize:=sizeof(aint);
       end;
 
@@ -1163,6 +1167,24 @@ implementation
       end;
 
 
+    constructor tstringdef.createunicode;
+      begin
+         inherited create(stringdef);
+         stringtype:=st_unicodestring;
+         len:=-1;
+         savesize:=sizeof(aint);
+      end;
+
+
+    constructor tstringdef.loadunicode(ppufile:tcompilerppufile);
+      begin
+         inherited ppuload(stringdef,ppufile);
+         stringtype:=st_unicodestring;
+         len:=ppufile.getaint;
+         savesize:=sizeof(aint);
+      end;
+
+
     function tstringdef.getcopy : tstoreddef;
       begin
         result:=tstringdef.create(typ);
@@ -1175,8 +1197,8 @@ implementation
 
     function tstringdef.stringtypname:string;
       const
-        typname:array[tstringtype] of string[8]=(
-          'shortstr','longstr','ansistr','widestr'
+        typname:array[tstringtype] of string[10]=(
+          'shortstr','longstr','ansistr','widestr','unicodestr'
         );
       begin
         stringtypname:=typname[stringtype];
@@ -1200,20 +1222,21 @@ implementation
             st_longstring : ppufile.writeentry(iblongstringdef);
             st_ansistring : ppufile.writeentry(ibansistringdef);
             st_widestring : ppufile.writeentry(ibwidestringdef);
+            st_unicodestring : ppufile.writeentry(ibunicodestringdef);
          end;
       end;
 
 
     function tstringdef.needs_inittable : boolean;
       begin
-         needs_inittable:=stringtype in [st_ansistring,st_widestring];
+         needs_inittable:=stringtype in [st_ansistring,st_widestring,st_unicodestring];
       end;
 
 
     function tstringdef.GetTypeName : string;
       const
-         names : array[tstringtype] of string[11] = (
-           'ShortString','LongString','AnsiString','WideString');
+         names : array[tstringtype] of string[15] = (
+           'ShortString','LongString','AnsiString','WideString','UnicodeString');
       begin
          GetTypeName:=names[stringtype];
       end;
@@ -1222,7 +1245,7 @@ implementation
     function tstringdef.getvardef : longint;
       const
         vardef : array[tstringtype] of longint = (
-          varUndefined,varUndefined,varString,varOleStr);
+          varUndefined,varUndefined,varString,varOleStr,varUnicodeStr);
       begin
         result:=vardef[stringtype];
       end;
@@ -1231,6 +1254,7 @@ implementation
     function tstringdef.alignment : shortint;
       begin
         case stringtype of
+          st_unicodestring,
           st_widestring,
           st_ansistring:
             alignment:=size_2_align(savesize);

+ 21 - 20
compiler/symtable.pas

@@ -310,27 +310,28 @@ implementation
          repeat
            b:=ppufile.readentry;
            case b of
-              ibpointerdef : def:=tpointerdef.ppuload(ppufile);
-                ibarraydef : def:=tarraydef.ppuload(ppufile);
-                  iborddef : def:=torddef.ppuload(ppufile);
-                ibfloatdef : def:=tfloatdef.ppuload(ppufile);
-                 ibprocdef : def:=tprocdef.ppuload(ppufile);
-          ibshortstringdef : def:=tstringdef.loadshort(ppufile);
-           iblongstringdef : def:=tstringdef.loadlong(ppufile);
-           ibansistringdef : def:=tstringdef.loadansi(ppufile);
-           ibwidestringdef : def:=tstringdef.loadwide(ppufile);
-               ibrecorddef : def:=trecorddef.ppuload(ppufile);
-               ibobjectdef : def:=tobjectdef.ppuload(ppufile);
-                 ibenumdef : def:=tenumdef.ppuload(ppufile);
-                  ibsetdef : def:=tsetdef.ppuload(ppufile);
-              ibprocvardef : def:=tprocvardef.ppuload(ppufile);
-                 ibfiledef : def:=tfiledef.ppuload(ppufile);
+             ibpointerdef : def:=tpointerdef.ppuload(ppufile);
+             ibarraydef : def:=tarraydef.ppuload(ppufile);
+             iborddef : def:=torddef.ppuload(ppufile);
+             ibfloatdef : def:=tfloatdef.ppuload(ppufile);
+             ibprocdef : def:=tprocdef.ppuload(ppufile);
+             ibshortstringdef : def:=tstringdef.loadshort(ppufile);
+             iblongstringdef : def:=tstringdef.loadlong(ppufile);
+             ibansistringdef : def:=tstringdef.loadansi(ppufile);
+             ibwidestringdef : def:=tstringdef.loadwide(ppufile);
+             ibunicodestringdef : def:=tstringdef.loadunicode(ppufile);
+             ibrecorddef : def:=trecorddef.ppuload(ppufile);
+             ibobjectdef : def:=tobjectdef.ppuload(ppufile);
+             ibenumdef : def:=tenumdef.ppuload(ppufile);
+             ibsetdef : def:=tsetdef.ppuload(ppufile);
+             ibprocvardef : def:=tprocvardef.ppuload(ppufile);
+             ibfiledef : def:=tfiledef.ppuload(ppufile);
              ibclassrefdef : def:=tclassrefdef.ppuload(ppufile);
-               ibformaldef : def:=tformaldef.ppuload(ppufile);
-              ibvariantdef : def:=tvariantdef.ppuload(ppufile);
-            ibundefineddef : def:=tundefineddef.ppuload(ppufile);
-                 ibenddefs : break;
-                     ibend : Message(unit_f_ppu_read_error);
+             ibformaldef : def:=tformaldef.ppuload(ppufile);
+             ibvariantdef : def:=tvariantdef.ppuload(ppufile);
+             ibundefineddef : def:=tundefineddef.ppuload(ppufile);
+             ibenddefs : break;
+             ibend : Message(unit_f_ppu_read_error);
            else
              Message1(unit_f_ppu_invalid_entry,tostr(b));
            end;