|
@@ -59,12 +59,16 @@ interface
|
|
inittablesymderef : tderef;
|
|
inittablesymderef : tderef;
|
|
{ local (per module) rtti and init tables }
|
|
{ local (per module) rtti and init tables }
|
|
localrttilab : array[trttitype] of tasmlabel;
|
|
localrttilab : array[trttitype] of tasmlabel;
|
|
- { linked list of global definitions }
|
|
|
|
{$ifdef EXTDEBUG}
|
|
{$ifdef EXTDEBUG}
|
|
fileinfo : tfileposinfo;
|
|
fileinfo : tfileposinfo;
|
|
{$endif}
|
|
{$endif}
|
|
|
|
+ { generic support }
|
|
|
|
+ genericdef : tstoreddef;
|
|
|
|
+ genericdefderef : tderef;
|
|
|
|
+ generictokenbuf : tdynamicarray;
|
|
constructor create;
|
|
constructor create;
|
|
constructor ppuloaddef(ppufile:tcompilerppufile);
|
|
constructor ppuloaddef(ppufile:tcompilerppufile);
|
|
|
|
+ destructor destroy;override;
|
|
procedure reset;virtual;
|
|
procedure reset;virtual;
|
|
function getcopy : tstoreddef;virtual;
|
|
function getcopy : tstoreddef;virtual;
|
|
procedure ppuwritedef(ppufile:tcompilerppufile);
|
|
procedure ppuwritedef(ppufile:tcompilerppufile);
|
|
@@ -86,6 +90,8 @@ interface
|
|
{ regvars }
|
|
{ regvars }
|
|
function is_intregable : boolean;
|
|
function is_intregable : boolean;
|
|
function is_fpuregable : boolean;
|
|
function is_fpuregable : boolean;
|
|
|
|
+ { generics }
|
|
|
|
+ procedure initgeneric;
|
|
private
|
|
private
|
|
savesize : aint;
|
|
savesize : aint;
|
|
end;
|
|
end;
|
|
@@ -136,6 +142,13 @@ interface
|
|
function gettypename:string;override;
|
|
function gettypename:string;override;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ tundefineddef = class(tstoreddef)
|
|
|
|
+ constructor create;
|
|
|
|
+ constructor ppuload(ppufile:tcompilerppufile);
|
|
|
|
+ procedure ppuwrite(ppufile:tcompilerppufile);override;
|
|
|
|
+ function gettypename:string;override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
terrordef = class(tstoreddef)
|
|
terrordef = class(tstoreddef)
|
|
constructor create;
|
|
constructor create;
|
|
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
|
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
|
@@ -552,13 +565,8 @@ interface
|
|
constructor loadshort(ppufile:tcompilerppufile);
|
|
constructor loadshort(ppufile:tcompilerppufile);
|
|
constructor createlong(l : aint);
|
|
constructor createlong(l : aint);
|
|
constructor loadlong(ppufile:tcompilerppufile);
|
|
constructor loadlong(ppufile:tcompilerppufile);
|
|
- {$ifdef ansistring_bits}
|
|
|
|
- constructor createansi(l:aint;bits:Tstringbits);
|
|
|
|
- constructor loadansi(ppufile:tcompilerppufile;bits:Tstringbits);
|
|
|
|
- {$else}
|
|
|
|
constructor createansi(l : aint);
|
|
constructor createansi(l : aint);
|
|
constructor loadansi(ppufile:tcompilerppufile);
|
|
constructor loadansi(ppufile:tcompilerppufile);
|
|
- {$endif}
|
|
|
|
constructor createwide(l : aint);
|
|
constructor createwide(l : aint);
|
|
constructor loadwide(ppufile:tcompilerppufile);
|
|
constructor loadwide(ppufile:tcompilerppufile);
|
|
function getcopy : tstoreddef;override;
|
|
function getcopy : tstoreddef;override;
|
|
@@ -634,6 +642,7 @@ interface
|
|
charpointertype, { pointer for Char-Pointerdef }
|
|
charpointertype, { pointer for Char-Pointerdef }
|
|
widecharpointertype, { pointer for WideChar-Pointerdef }
|
|
widecharpointertype, { pointer for WideChar-Pointerdef }
|
|
voidfarpointertype,
|
|
voidfarpointertype,
|
|
|
|
+ cundefinedtype,
|
|
cformaltype, { unique formal definition }
|
|
cformaltype, { unique formal definition }
|
|
voidtype, { Void (procedure) }
|
|
voidtype, { Void (procedure) }
|
|
cchartype, { Char }
|
|
cchartype, { Char }
|
|
@@ -653,13 +662,7 @@ interface
|
|
s64currencytype, { pointer to a currency type }
|
|
s64currencytype, { pointer to a currency type }
|
|
cshortstringtype, { pointer to type of short string const }
|
|
cshortstringtype, { pointer to type of short string const }
|
|
clongstringtype, { pointer to type of long string const }
|
|
clongstringtype, { pointer to type of long string const }
|
|
-{$ifdef ansistring_bits}
|
|
|
|
- cansistringtype16, { pointer to type of ansi string const }
|
|
|
|
- cansistringtype32, { pointer to type of ansi string const }
|
|
|
|
- cansistringtype64, { pointer to type of ansi string const }
|
|
|
|
-{$else}
|
|
|
|
cansistringtype, { pointer to type of ansi string const }
|
|
cansistringtype, { pointer to type of ansi string const }
|
|
-{$endif}
|
|
|
|
cwidestringtype, { pointer to type of wide string const }
|
|
cwidestringtype, { pointer to type of wide string const }
|
|
openshortstringtype, { pointer to type of an open shortstring,
|
|
openshortstringtype, { pointer to type of an open shortstring,
|
|
needed for readln() }
|
|
needed for readln() }
|
|
@@ -899,10 +902,23 @@ implementation
|
|
if registerdef then
|
|
if registerdef then
|
|
symtablestack.registerdef(self);
|
|
symtablestack.registerdef(self);
|
|
fillchar(localrttilab,sizeof(localrttilab),0);
|
|
fillchar(localrttilab,sizeof(localrttilab),0);
|
|
|
|
+ generictokenbuf:=nil;
|
|
|
|
+ genericdef:=nil;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ destructor tstoreddef.destroy;
|
|
|
|
+ begin
|
|
|
|
+ if assigned(generictokenbuf) then
|
|
|
|
+ generictokenbuf.free;
|
|
|
|
+ inherited destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile);
|
|
constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile);
|
|
|
|
+ var
|
|
|
|
+ sizeleft,i : longint;
|
|
|
|
+ buf : array[0..255] of byte;
|
|
begin
|
|
begin
|
|
inherited create;
|
|
inherited create;
|
|
{$ifdef EXTDEBUG}
|
|
{$ifdef EXTDEBUG}
|
|
@@ -917,6 +933,23 @@ implementation
|
|
ppufile.getderef(rttitablesymderef);
|
|
ppufile.getderef(rttitablesymderef);
|
|
if df_has_inittable in defoptions then
|
|
if df_has_inittable in defoptions then
|
|
ppufile.getderef(inittablesymderef);
|
|
ppufile.getderef(inittablesymderef);
|
|
|
|
+ if df_generic in defoptions then
|
|
|
|
+ begin
|
|
|
|
+ sizeleft:=ppufile.getlongint;
|
|
|
|
+ initgeneric;
|
|
|
|
+ while sizeleft>0 do
|
|
|
|
+ begin
|
|
|
|
+ if sizeleft>sizeof(buf) then
|
|
|
|
+ i:=sizeof(buf)
|
|
|
|
+ else
|
|
|
|
+ i:=sizeleft;
|
|
|
|
+ ppufile.getdata(buf,i);
|
|
|
|
+ generictokenbuf.write(buf,i);
|
|
|
|
+ dec(sizeleft,i);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ if df_specialization in defoptions then
|
|
|
|
+ ppufile.getderef(genericdefderef);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -939,6 +972,10 @@ implementation
|
|
|
|
|
|
|
|
|
|
procedure tstoreddef.ppuwritedef(ppufile:tcompilerppufile);
|
|
procedure tstoreddef.ppuwritedef(ppufile:tcompilerppufile);
|
|
|
|
+ var
|
|
|
|
+ sizeleft,i : longint;
|
|
|
|
+ buf : array[0..255] of byte;
|
|
|
|
+ oldintfcrc : boolean;
|
|
begin
|
|
begin
|
|
ppufile.putword(indexnr);
|
|
ppufile.putword(indexnr);
|
|
ppufile.putderef(typesymderef);
|
|
ppufile.putderef(typesymderef);
|
|
@@ -947,6 +984,32 @@ implementation
|
|
ppufile.putderef(rttitablesymderef);
|
|
ppufile.putderef(rttitablesymderef);
|
|
if df_has_inittable in defoptions then
|
|
if df_has_inittable in defoptions then
|
|
ppufile.putderef(inittablesymderef);
|
|
ppufile.putderef(inittablesymderef);
|
|
|
|
+ if df_generic in defoptions then
|
|
|
|
+ begin
|
|
|
|
+ oldintfcrc:=ppufile.do_interface_crc;
|
|
|
|
+ ppufile.do_interface_crc:=false;
|
|
|
|
+ if assigned(generictokenbuf) then
|
|
|
|
+ begin
|
|
|
|
+ sizeleft:=generictokenbuf.size;
|
|
|
|
+ generictokenbuf.seek(0);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ sizeleft:=0;
|
|
|
|
+ ppufile.putlongint(sizeleft);
|
|
|
|
+ while sizeleft>0 do
|
|
|
|
+ begin
|
|
|
|
+ if sizeleft>sizeof(buf) then
|
|
|
|
+ i:=sizeof(buf)
|
|
|
|
+ else
|
|
|
|
+ i:=sizeleft;
|
|
|
|
+ generictokenbuf.read(buf,i);
|
|
|
|
+ ppufile.putdata(buf,i);
|
|
|
|
+ dec(sizeleft,i);
|
|
|
|
+ end;
|
|
|
|
+ ppufile.do_interface_crc:=oldintfcrc;
|
|
|
|
+ end;
|
|
|
|
+ if df_specialization in defoptions then
|
|
|
|
+ ppufile.putderef(genericdefderef);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -955,6 +1018,7 @@ implementation
|
|
typesymderef.build(typesym);
|
|
typesymderef.build(typesym);
|
|
rttitablesymderef.build(rttitablesym);
|
|
rttitablesymderef.build(rttitablesym);
|
|
inittablesymderef.build(inittablesym);
|
|
inittablesymderef.build(inittablesym);
|
|
|
|
+ genericdefderef.build(genericdef);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -970,6 +1034,8 @@ implementation
|
|
rttitablesym:=trttisym(rttitablesymderef.resolve);
|
|
rttitablesym:=trttisym(rttitablesymderef.resolve);
|
|
if df_has_inittable in defoptions then
|
|
if df_has_inittable in defoptions then
|
|
inittablesym:=trttisym(inittablesymderef.resolve);
|
|
inittablesym:=trttisym(inittablesymderef.resolve);
|
|
|
|
+ if df_specialization in defoptions then
|
|
|
|
+ genericdef:=tstoreddef(genericdefderef.resolve);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1091,6 +1157,13 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+ procedure tstoreddef.initgeneric;
|
|
|
|
+ begin
|
|
|
|
+ if assigned(generictokenbuf) then
|
|
|
|
+ internalerror(200512131);
|
|
|
|
+ generictokenbuf:=tdynamicarray.create(256);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
|
|
{****************************************************************************
|
|
{****************************************************************************
|
|
Tstringdef
|
|
Tstringdef
|
|
@@ -1135,40 +1208,7 @@ implementation
|
|
savesize:=sizeof(aint);
|
|
savesize:=sizeof(aint);
|
|
end;
|
|
end;
|
|
|
|
|
|
-{$ifdef ansistring_bits}
|
|
|
|
- constructor tstringdef.createansi(l:aint;bits:Tstringbits);
|
|
|
|
- begin
|
|
|
|
- inherited create;
|
|
|
|
- case bits of
|
|
|
|
- sb_16:
|
|
|
|
- string_typ:=st_ansistring16;
|
|
|
|
- sb_32:
|
|
|
|
- string_typ:=st_ansistring32;
|
|
|
|
- sb_64:
|
|
|
|
- string_typ:=st_ansistring64;
|
|
|
|
- end;
|
|
|
|
- deftype:=stringdef;
|
|
|
|
- len:=l;
|
|
|
|
- savesize:=POINTER_SIZE;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
|
|
|
|
- constructor tstringdef.loadansi(ppufile:tcompilerppufile;bits:Tstringbits);
|
|
|
|
- begin
|
|
|
|
- inherited ppuloaddef(ppufile);
|
|
|
|
- deftype:=stringdef;
|
|
|
|
- case bits of
|
|
|
|
- sb_16:
|
|
|
|
- string_typ:=st_ansistring16;
|
|
|
|
- sb_32:
|
|
|
|
- string_typ:=st_ansistring32;
|
|
|
|
- sb_64:
|
|
|
|
- string_typ:=st_ansistring64;
|
|
|
|
- end;
|
|
|
|
- len:=ppufile.getaint;
|
|
|
|
- savesize:=POINTER_SIZE;
|
|
|
|
- end;
|
|
|
|
-{$else}
|
|
|
|
constructor tstringdef.createansi(l:aint);
|
|
constructor tstringdef.createansi(l:aint);
|
|
begin
|
|
begin
|
|
inherited create;
|
|
inherited create;
|
|
@@ -1180,7 +1220,6 @@ implementation
|
|
|
|
|
|
|
|
|
|
constructor tstringdef.loadansi(ppufile:tcompilerppufile);
|
|
constructor tstringdef.loadansi(ppufile:tcompilerppufile);
|
|
-
|
|
|
|
begin
|
|
begin
|
|
inherited ppuloaddef(ppufile);
|
|
inherited ppuloaddef(ppufile);
|
|
deftype:=stringdef;
|
|
deftype:=stringdef;
|
|
@@ -1188,7 +1227,7 @@ implementation
|
|
len:=ppufile.getaint;
|
|
len:=ppufile.getaint;
|
|
savesize:=sizeof(aint);
|
|
savesize:=sizeof(aint);
|
|
end;
|
|
end;
|
|
-{$endif}
|
|
|
|
|
|
+
|
|
|
|
|
|
constructor tstringdef.createwide(l : aint);
|
|
constructor tstringdef.createwide(l : aint);
|
|
begin
|
|
begin
|
|
@@ -1221,17 +1260,10 @@ implementation
|
|
|
|
|
|
|
|
|
|
function tstringdef.stringtypname:string;
|
|
function tstringdef.stringtypname:string;
|
|
-{$ifdef ansistring_bits}
|
|
|
|
- const
|
|
|
|
- typname:array[tstringtype] of string[9]=('',
|
|
|
|
- 'shortstr','longstr','ansistr16','ansistr32','ansistr64','widestr'
|
|
|
|
- );
|
|
|
|
-{$else}
|
|
|
|
const
|
|
const
|
|
typname:array[tstringtype] of string[8]=('',
|
|
typname:array[tstringtype] of string[8]=('',
|
|
'shortstr','longstr','ansistr','widestr'
|
|
'shortstr','longstr','ansistr','widestr'
|
|
);
|
|
);
|
|
-{$endif}
|
|
|
|
begin
|
|
begin
|
|
stringtypname:=typname[string_typ];
|
|
stringtypname:=typname[string_typ];
|
|
end;
|
|
end;
|
|
@@ -1252,13 +1284,7 @@ implementation
|
|
case string_typ of
|
|
case string_typ of
|
|
st_shortstring : ppufile.writeentry(ibshortstringdef);
|
|
st_shortstring : ppufile.writeentry(ibshortstringdef);
|
|
st_longstring : ppufile.writeentry(iblongstringdef);
|
|
st_longstring : ppufile.writeentry(iblongstringdef);
|
|
- {$ifdef ansistring_bits}
|
|
|
|
- st_ansistring16 : ppufile.writeentry(ibansistring16def);
|
|
|
|
- st_ansistring32 : ppufile.writeentry(ibansistring32def);
|
|
|
|
- st_ansistring64 : ppufile.writeentry(ibansistring64def);
|
|
|
|
- {$else}
|
|
|
|
st_ansistring : ppufile.writeentry(ibansistringdef);
|
|
st_ansistring : ppufile.writeentry(ibansistringdef);
|
|
- {$endif}
|
|
|
|
st_widestring : ppufile.writeentry(ibwidestringdef);
|
|
st_widestring : ppufile.writeentry(ibwidestringdef);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -1266,24 +1292,14 @@ implementation
|
|
|
|
|
|
function tstringdef.needs_inittable : boolean;
|
|
function tstringdef.needs_inittable : boolean;
|
|
begin
|
|
begin
|
|
- {$ifdef ansistring_bits}
|
|
|
|
- needs_inittable:=string_typ in [st_ansistring16,st_ansistring32,st_ansistring64,st_widestring];
|
|
|
|
- {$else}
|
|
|
|
needs_inittable:=string_typ in [st_ansistring,st_widestring];
|
|
needs_inittable:=string_typ in [st_ansistring,st_widestring];
|
|
- {$endif}
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
function tstringdef.gettypename : string;
|
|
function tstringdef.gettypename : string;
|
|
-{$ifdef ansistring_bits}
|
|
|
|
- const
|
|
|
|
- names : array[tstringtype] of string[20] = ('',
|
|
|
|
- 'shortstring','longstring','ansistring16','ansistring32','ansistring64','widestring');
|
|
|
|
-{$else}
|
|
|
|
const
|
|
const
|
|
names : array[tstringtype] of string[20] = ('',
|
|
names : array[tstringtype] of string[20] = ('',
|
|
'ShortString','LongString','AnsiString','WideString');
|
|
'ShortString','LongString','AnsiString','WideString');
|
|
-{$endif}
|
|
|
|
begin
|
|
begin
|
|
gettypename:=names[string_typ];
|
|
gettypename:=names[string_typ];
|
|
end;
|
|
end;
|
|
@@ -1312,29 +1328,11 @@ implementation
|
|
procedure tstringdef.write_rtti_data(rt:trttitype);
|
|
procedure tstringdef.write_rtti_data(rt:trttitype);
|
|
begin
|
|
begin
|
|
case string_typ of
|
|
case string_typ of
|
|
- {$ifdef ansistring_bits}
|
|
|
|
- st_ansistring16:
|
|
|
|
- begin
|
|
|
|
- asmlist[al_rtti].concat(Tai_const.Create_8bit(tkA16String));
|
|
|
|
- write_rtti_name;
|
|
|
|
- end;
|
|
|
|
- st_ansistring32:
|
|
|
|
- begin
|
|
|
|
- asmlist[al_rtti].concat(Tai_const.Create_8bit(tkA32String));
|
|
|
|
- write_rtti_name;
|
|
|
|
- end;
|
|
|
|
- st_ansistring64:
|
|
|
|
- begin
|
|
|
|
- asmlist[al_rtti].concat(Tai_const.Create_8bit(tkA64String));
|
|
|
|
- write_rtti_name;
|
|
|
|
- end;
|
|
|
|
- {$else}
|
|
|
|
st_ansistring:
|
|
st_ansistring:
|
|
begin
|
|
begin
|
|
asmlist[al_rtti].concat(Tai_const.Create_8bit(tkAString));
|
|
asmlist[al_rtti].concat(Tai_const.Create_8bit(tkAString));
|
|
write_rtti_name;
|
|
write_rtti_name;
|
|
end;
|
|
end;
|
|
- {$endif}
|
|
|
|
st_widestring:
|
|
st_widestring:
|
|
begin
|
|
begin
|
|
asmlist[al_rtti].concat(Tai_const.Create_8bit(tkWString));
|
|
asmlist[al_rtti].concat(Tai_const.Create_8bit(tkWString));
|
|
@@ -5380,6 +5378,36 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+{****************************************************************************
|
|
|
|
+ TUNDEFINEDDEF
|
|
|
|
+****************************************************************************}
|
|
|
|
+
|
|
|
|
+ constructor tundefineddef.create;
|
|
|
|
+ begin
|
|
|
|
+ inherited create;
|
|
|
|
+ deftype:=undefineddef;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ constructor tundefineddef.ppuload(ppufile:tcompilerppufile);
|
|
|
|
+ begin
|
|
|
|
+ inherited ppuloaddef(ppufile);
|
|
|
|
+ deftype:=undefineddef;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ function tundefineddef.gettypename:string;
|
|
|
|
+ begin
|
|
|
|
+ gettypename:='<undefined type>';
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tundefineddef.ppuwrite(ppufile:tcompilerppufile);
|
|
|
|
+ begin
|
|
|
|
+ inherited ppuwritedef(ppufile);
|
|
|
|
+ ppufile.writeentry(ibundefineddef);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
{****************************************************************************
|
|
{****************************************************************************
|
|
TERRORDEF
|
|
TERRORDEF
|
|
****************************************************************************}
|
|
****************************************************************************}
|