Bladeren bron

* save/restore the type (and hence code page) of ansistring constsyms in/from
the ppu (mantis #28964)
* also save/restore the type of constnil, constresourcestring and constguid
in/from the ppu

git-svn-id: trunk@32617 -

Jonas Maebe 9 jaren geleden
bovenliggende
commit
01d93b61c3
6 gewijzigde bestanden met toevoegingen van 58 en 10 verwijderingen
  1. 2 0
      .gitattributes
  2. 1 1
      compiler/ppu.pas
  3. 26 6
      compiler/symsym.pas
  4. 8 3
      compiler/utils/ppuutils/ppudump.pp
  5. 9 0
      tests/webtbs/tw28964.pp
  6. 12 0
      tests/webtbs/uw28964.pp

+ 2 - 0
.gitattributes

@@ -14874,6 +14874,7 @@ tests/webtbs/tw2886.pp svneol=native#text/plain
 tests/webtbs/tw2891.pp svneol=native#text/plain
 tests/webtbs/tw2891.pp svneol=native#text/plain
 tests/webtbs/tw2892.pp svneol=native#text/plain
 tests/webtbs/tw2892.pp svneol=native#text/plain
 tests/webtbs/tw28934.pp svneol=native#text/plain
 tests/webtbs/tw28934.pp svneol=native#text/plain
+tests/webtbs/tw28964.pp svneol=native#text/plain
 tests/webtbs/tw2897.pp svneol=native#text/plain
 tests/webtbs/tw2897.pp svneol=native#text/plain
 tests/webtbs/tw2899.pp svneol=native#text/plain
 tests/webtbs/tw2899.pp svneol=native#text/plain
 tests/webtbs/tw29010a.pp svneol=native#text/plain
 tests/webtbs/tw29010a.pp svneol=native#text/plain
@@ -15590,6 +15591,7 @@ tests/webtbs/uw2738.pp svneol=native#text/plain
 tests/webtbs/uw2834.pp svneol=native#text/plain
 tests/webtbs/uw2834.pp svneol=native#text/plain
 tests/webtbs/uw28442.pp svneol=native#text/pascal
 tests/webtbs/uw28442.pp svneol=native#text/pascal
 tests/webtbs/uw28766.pp svneol=native#text/pascal
 tests/webtbs/uw28766.pp svneol=native#text/pascal
+tests/webtbs/uw28964.pp svneol=native#text/plain
 tests/webtbs/uw2920.pp svneol=native#text/plain
 tests/webtbs/uw2920.pp svneol=native#text/plain
 tests/webtbs/uw2956.pp svneol=native#text/plain
 tests/webtbs/uw2956.pp svneol=native#text/plain
 tests/webtbs/uw2984.pp svneol=native#text/plain
 tests/webtbs/uw2984.pp svneol=native#text/plain

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 {$endif Test_Double_checksum}
 
 
 const
 const
-  CurrentPPUVersion = 179;
+  CurrentPPUVersion = 180;
 
 
 { buffer sizes }
 { buffer sizes }
   maxentrysize = 1024;
   maxentrysize = 1024;

+ 26 - 6
compiler/symsym.pas

@@ -2385,6 +2385,7 @@ implementation
            conststring,
            conststring,
            constresourcestring :
            constresourcestring :
              begin
              begin
+               ppufile.getderef(constdefderef);
                value.len:=ppufile.getlongint;
                value.len:=ppufile.getlongint;
                getmem(pc,value.len+1);
                getmem(pc,value.len+1);
                ppufile.getdata(pc^,value.len);
                ppufile.getdata(pc^,value.len);
@@ -2407,6 +2408,7 @@ implementation
              end;
              end;
            constguid :
            constguid :
              begin
              begin
+               ppufile.getderef(constdefderef);
                new(pguid(value.valueptr));
                new(pguid(value.valueptr));
                ppufile.getdata(value.valueptr^,sizeof(tguid));
                ppufile.getdata(value.valueptr^,sizeof(tguid));
              end;
              end;
@@ -2440,15 +2442,27 @@ implementation
     procedure tconstsym.buildderef;
     procedure tconstsym.buildderef;
       begin
       begin
         inherited;
         inherited;
-        if consttyp in [constord,constreal,constpointer,constset] then
-          constdefderef.build(constdef);
+        case consttyp  of
+          constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid:
+            constdefderef.build(constdef);
+          constwstring:
+            ;
+          else
+            internalerror(2015120802);
+        end;
       end;
       end;
 
 
 
 
     procedure tconstsym.deref;
     procedure tconstsym.deref;
       begin
       begin
-        if consttyp in [constord,constreal,constpointer,constset] then
-          constdef:=tdef(constdefderef.resolve);
+        case consttyp of
+          constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid:
+            constdef:=tdef(constdefderef.resolve);
+          constwstring:
+            constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pcompilerwidestring(value.valueptr)));
+          else
+            internalerror(2015120801);
+        end
       end;
       end;
 
 
 
 
@@ -2457,7 +2471,8 @@ implementation
          inherited ppuwrite(ppufile);
          inherited ppuwrite(ppufile);
          ppufile.putbyte(byte(consttyp));
          ppufile.putbyte(byte(consttyp));
          case consttyp of
          case consttyp of
-           constnil : ;
+           constnil :
+             ppufile.putderef(constdefderef);
            constord :
            constord :
              begin
              begin
                ppufile.putderef(constdefderef);
                ppufile.putderef(constdefderef);
@@ -2470,12 +2485,14 @@ implementation
              end;
              end;
            constwstring :
            constwstring :
              begin
              begin
+               { no need to store the def, we can reconstruct it }
                ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
                ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
                ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
                ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
              end;
              end;
            conststring,
            conststring,
            constresourcestring :
            constresourcestring :
              begin
              begin
+               ppufile.putderef(constdefderef);
                ppufile.putlongint(value.len);
                ppufile.putlongint(value.len);
                ppufile.putdata(pchar(value.valueptr)^,value.len);
                ppufile.putdata(pchar(value.valueptr)^,value.len);
              end;
              end;
@@ -2490,7 +2507,10 @@ implementation
                ppufile.putnormalset(value.valueptr^);
                ppufile.putnormalset(value.valueptr^);
              end;
              end;
            constguid :
            constguid :
-             ppufile.putdata(value.valueptr^,sizeof(tguid));
+             begin
+               ppufile.putderef(constdefderef);
+               ppufile.putdata(value.valueptr^,sizeof(tguid));
+             end;
          else
          else
            internalerror(13);
            internalerror(13);
          end;
          end;

+ 8 - 3
compiler/utils/ppuutils/ppudump.pp

@@ -2395,7 +2395,9 @@ begin
                  end;
                  end;
                conststring,
                conststring,
                constresourcestring :
                constresourcestring :
-                 begin
+               begin
+                   write ([space,'   StringType : ']);
+                   readderef('',constdef.TypeRef);
                    len:=getlongint;
                    len:=getlongint;
                    getmem(pc,len+1);
                    getmem(pc,len+1);
                    getdata(pc^,len);
                    getdata(pc^,len);
@@ -2465,7 +2467,8 @@ begin
                  end;
                  end;
                constnil:
                constnil:
                  begin
                  begin
-                   writeln([space,' NIL pointer.']);
+                   write([space,'   NIL pointer :']);
+                   readderef('',constdef.TypeRef);
                    constdef.ConstType:=ctPtr;
                    constdef.ConstType:=ctPtr;
                    constdef.VInt:=0;
                    constdef.VInt:=0;
                  end;
                  end;
@@ -2519,8 +2522,10 @@ begin
                  end;
                  end;
                constguid:
                constguid:
                  begin
                  begin
+                    write ([space,'     IntfType : ']);
+                    readderef('',constdef.TypeRef);
                     getdata(guid,sizeof(guid));
                     getdata(guid,sizeof(guid));
-                    write ([space,'     IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']);
+                    write ([space,'    IID String: {',hexstr(guid.d1,8),'-',hexstr(guid.d2,4),'-',hexstr(guid.d3,4),'-']);
                     for i:=0 to 7 do
                     for i:=0 to 7 do
                       begin
                       begin
                          write(hexstr(guid.d4[i],2));
                          write(hexstr(guid.d4[i],2));

+ 9 - 0
tests/webtbs/tw28964.pp

@@ -0,0 +1,9 @@
+{ %recompile }
+
+uses
+  uw28964;
+
+begin
+  if stringcodepage(externalconst)<>CP_UTF8 then
+    halt(1);
+end.

+ 12 - 0
tests/webtbs/uw28964.pp

@@ -0,0 +1,12 @@
+unit uw28964;
+
+interface
+
+const
+  ExternalConst = AnsiString('abc');
+  nilconst = pbyte(nil);
+  guid = iunknown;
+
+implementation
+
+end.