* 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 -
This commit is contained in:
Jonas Maebe 2015-12-08 14:27:23 +00:00
parent f6b99c5d6a
commit 01d93b61c3
6 changed files with 58 additions and 10 deletions

2
.gitattributes vendored
View File

@ -14874,6 +14874,7 @@ tests/webtbs/tw2886.pp svneol=native#text/plain
tests/webtbs/tw2891.pp svneol=native#text/plain
tests/webtbs/tw2892.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/tw2899.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/uw28442.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/uw2956.pp svneol=native#text/plain
tests/webtbs/uw2984.pp svneol=native#text/plain

View File

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

View File

@ -2385,6 +2385,7 @@ implementation
conststring,
constresourcestring :
begin
ppufile.getderef(constdefderef);
value.len:=ppufile.getlongint;
getmem(pc,value.len+1);
ppufile.getdata(pc^,value.len);
@ -2407,6 +2408,7 @@ implementation
end;
constguid :
begin
ppufile.getderef(constdefderef);
new(pguid(value.valueptr));
ppufile.getdata(value.valueptr^,sizeof(tguid));
end;
@ -2440,15 +2442,27 @@ implementation
procedure tconstsym.buildderef;
begin
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;
procedure tconstsym.deref;
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;
@ -2457,7 +2471,8 @@ implementation
inherited ppuwrite(ppufile);
ppufile.putbyte(byte(consttyp));
case consttyp of
constnil : ;
constnil :
ppufile.putderef(constdefderef);
constord :
begin
ppufile.putderef(constdefderef);
@ -2470,12 +2485,14 @@ implementation
end;
constwstring :
begin
{ no need to store the def, we can reconstruct it }
ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
end;
conststring,
constresourcestring :
begin
ppufile.putderef(constdefderef);
ppufile.putlongint(value.len);
ppufile.putdata(pchar(value.valueptr)^,value.len);
end;
@ -2490,7 +2507,10 @@ implementation
ppufile.putnormalset(value.valueptr^);
end;
constguid :
ppufile.putdata(value.valueptr^,sizeof(tguid));
begin
ppufile.putderef(constdefderef);
ppufile.putdata(value.valueptr^,sizeof(tguid));
end;
else
internalerror(13);
end;

View File

@ -2395,7 +2395,9 @@ begin
end;
conststring,
constresourcestring :
begin
begin
write ([space,' StringType : ']);
readderef('',constdef.TypeRef);
len:=getlongint;
getmem(pc,len+1);
getdata(pc^,len);
@ -2465,7 +2467,8 @@ begin
end;
constnil:
begin
writeln([space,' NIL pointer.']);
write([space,' NIL pointer :']);
readderef('',constdef.TypeRef);
constdef.ConstType:=ctPtr;
constdef.VInt:=0;
end;
@ -2519,8 +2522,10 @@ begin
end;
constguid:
begin
write ([space,' IntfType : ']);
readderef('',constdef.TypeRef);
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
begin
write(hexstr(guid.d4[i],2));

9
tests/webtbs/tw28964.pp Normal file
View File

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

12
tests/webtbs/uw28964.pp Normal file
View File

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