|
@@ -68,6 +68,8 @@ interface
|
|
procedure writeentry(ppufile: tcompilerppufile; ibnr: byte);
|
|
procedure writeentry(ppufile: tcompilerppufile; ibnr: byte);
|
|
protected
|
|
protected
|
|
typesymderef : tderef;
|
|
typesymderef : tderef;
|
|
|
|
+ { whether this def is already registered in the unit's def list }
|
|
|
|
+ registered : boolean;
|
|
procedure ppuwrite_platform(ppufile:tcompilerppufile);virtual;
|
|
procedure ppuwrite_platform(ppufile:tcompilerppufile);virtual;
|
|
procedure ppuload_platform(ppufile:tcompilerppufile);virtual;
|
|
procedure ppuload_platform(ppufile:tcompilerppufile);virtual;
|
|
public
|
|
public
|
|
@@ -86,7 +88,7 @@ interface
|
|
{ contains additional data if this def is a generic constraint
|
|
{ contains additional data if this def is a generic constraint
|
|
Note: this class is allocated on demand! }
|
|
Note: this class is allocated on demand! }
|
|
genconstraintdata : tgenericconstraintdata;
|
|
genconstraintdata : tgenericconstraintdata;
|
|
- constructor create(dt:tdeftyp);
|
|
|
|
|
|
+ constructor create(dt:tdeftyp;doregister:boolean);
|
|
constructor ppuload(dt:tdeftyp;ppufile:tcompilerppufile);
|
|
constructor ppuload(dt:tdeftyp;ppufile:tcompilerppufile);
|
|
destructor destroy;override;
|
|
destructor destroy;override;
|
|
function getcopy : tstoreddef;virtual;
|
|
function getcopy : tstoreddef;virtual;
|
|
@@ -118,6 +120,9 @@ interface
|
|
function is_generic:boolean;inline;
|
|
function is_generic:boolean;inline;
|
|
{ same as above for specializations }
|
|
{ same as above for specializations }
|
|
function is_specialization:boolean;inline;
|
|
function is_specialization:boolean;inline;
|
|
|
|
+ { registers this def in the unit's deflist; no-op if already registered }
|
|
|
|
+ procedure register_def;
|
|
|
|
+ property is_registered: boolean read registered;
|
|
private
|
|
private
|
|
savesize : asizeuint;
|
|
savesize : asizeuint;
|
|
end;
|
|
end;
|
|
@@ -1624,9 +1629,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- constructor tstoreddef.create(dt:tdeftyp);
|
|
|
|
- var
|
|
|
|
- insertstack : psymtablestackitem;
|
|
|
|
|
|
+ constructor tstoreddef.create(dt:tdeftyp;doregister:boolean);
|
|
begin
|
|
begin
|
|
inherited create(dt);
|
|
inherited create(dt);
|
|
savesize := 0;
|
|
savesize := 0;
|
|
@@ -1640,25 +1643,9 @@ implementation
|
|
end of an type block }
|
|
end of an type block }
|
|
if (dt=forwarddef) then
|
|
if (dt=forwarddef) then
|
|
exit;
|
|
exit;
|
|
- { Register in current_module }
|
|
|
|
- if assigned(current_module) then
|
|
|
|
- begin
|
|
|
|
- current_module.deflist.Add(self);
|
|
|
|
- DefId:=current_module.deflist.Count-1;
|
|
|
|
- end;
|
|
|
|
- { Register in symtable stack }
|
|
|
|
- if assigned(symtablestack) then
|
|
|
|
- begin
|
|
|
|
- insertstack:=symtablestack.stack;
|
|
|
|
- while assigned(insertstack) and
|
|
|
|
- (insertstack^.symtable.symtabletype=withsymtable) do
|
|
|
|
- insertstack:=insertstack^.next;
|
|
|
|
- if not assigned(insertstack) then
|
|
|
|
- internalerror(200602044);
|
|
|
|
- if insertstack^.symtable.sealed then
|
|
|
|
- internalerror(2015022301);
|
|
|
|
- insertstack^.symtable.insertdef(self);
|
|
|
|
- end;
|
|
|
|
|
|
+ { register the definition if wanted }
|
|
|
|
+ if doregister then
|
|
|
|
+ register_def;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1693,6 +1680,8 @@ implementation
|
|
begin
|
|
begin
|
|
inherited create(dt);
|
|
inherited create(dt);
|
|
DefId:=ppufile.getlongint;
|
|
DefId:=ppufile.getlongint;
|
|
|
|
+ { defs loaded from ppu are always owned }
|
|
|
|
+ registered:=true;
|
|
current_module.deflist[DefId]:=self;
|
|
current_module.deflist[DefId]:=self;
|
|
{$ifdef EXTDEBUG}
|
|
{$ifdef EXTDEBUG}
|
|
fillchar(fileinfo,sizeof(fileinfo),0);
|
|
fillchar(fileinfo,sizeof(fileinfo),0);
|
|
@@ -2107,13 +2096,42 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+ procedure tstoreddef.register_def;
|
|
|
|
+ var
|
|
|
|
+ insertstack : psymtablestackitem;
|
|
|
|
+ begin
|
|
|
|
+ if registered then
|
|
|
|
+ exit;
|
|
|
|
+ { Register in current_module }
|
|
|
|
+ if assigned(current_module) then
|
|
|
|
+ begin
|
|
|
|
+ current_module.deflist.Add(self);
|
|
|
|
+ DefId:=current_module.deflist.Count-1;
|
|
|
|
+ end;
|
|
|
|
+ { Register in symtable stack }
|
|
|
|
+ if assigned(symtablestack) then
|
|
|
|
+ begin
|
|
|
|
+ insertstack:=symtablestack.stack;
|
|
|
|
+ while assigned(insertstack) and
|
|
|
|
+ (insertstack^.symtable.symtabletype=withsymtable) do
|
|
|
|
+ insertstack:=insertstack^.next;
|
|
|
|
+ if not assigned(insertstack) then
|
|
|
|
+ internalerror(200602044);
|
|
|
|
+ if insertstack^.symtable.sealed then
|
|
|
|
+ internalerror(2015022301);
|
|
|
|
+ insertstack^.symtable.insertdef(self);
|
|
|
|
+ end;
|
|
|
|
+ registered:=true;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
{****************************************************************************
|
|
{****************************************************************************
|
|
Tstringdef
|
|
Tstringdef
|
|
****************************************************************************}
|
|
****************************************************************************}
|
|
|
|
|
|
constructor tstringdef.createshort(l : byte);
|
|
constructor tstringdef.createshort(l : byte);
|
|
begin
|
|
begin
|
|
- inherited create(stringdef);
|
|
|
|
|
|
+ inherited create(stringdef,true);
|
|
stringtype:=st_shortstring;
|
|
stringtype:=st_shortstring;
|
|
encoding:=0;
|
|
encoding:=0;
|
|
len:=l;
|
|
len:=l;
|
|
@@ -2132,7 +2150,7 @@ implementation
|
|
|
|
|
|
constructor tstringdef.createlong(l : asizeint);
|
|
constructor tstringdef.createlong(l : asizeint);
|
|
begin
|
|
begin
|
|
- inherited create(stringdef);
|
|
|
|
|
|
+ inherited create(stringdef,true);
|
|
stringtype:=st_longstring;
|
|
stringtype:=st_longstring;
|
|
encoding:=0;
|
|
encoding:=0;
|
|
len:=l;
|
|
len:=l;
|
|
@@ -2151,7 +2169,7 @@ implementation
|
|
|
|
|
|
constructor tstringdef.createansi(aencoding:tstringencoding);
|
|
constructor tstringdef.createansi(aencoding:tstringencoding);
|
|
begin
|
|
begin
|
|
- inherited create(stringdef);
|
|
|
|
|
|
+ inherited create(stringdef,true);
|
|
stringtype:=st_ansistring;
|
|
stringtype:=st_ansistring;
|
|
encoding:=aencoding;
|
|
encoding:=aencoding;
|
|
len:=-1;
|
|
len:=-1;
|
|
@@ -2170,7 +2188,7 @@ implementation
|
|
|
|
|
|
constructor tstringdef.createwide;
|
|
constructor tstringdef.createwide;
|
|
begin
|
|
begin
|
|
- inherited create(stringdef);
|
|
|
|
|
|
+ inherited create(stringdef,true);
|
|
stringtype:=st_widestring;
|
|
stringtype:=st_widestring;
|
|
if target_info.endian=endian_little then
|
|
if target_info.endian=endian_little then
|
|
encoding:=CP_UTF16LE
|
|
encoding:=CP_UTF16LE
|
|
@@ -2195,7 +2213,7 @@ implementation
|
|
|
|
|
|
constructor tstringdef.createunicode;
|
|
constructor tstringdef.createunicode;
|
|
begin
|
|
begin
|
|
- inherited create(stringdef);
|
|
|
|
|
|
+ inherited create(stringdef,true);
|
|
stringtype:=st_unicodestring;
|
|
stringtype:=st_unicodestring;
|
|
if target_info.endian=endian_little then
|
|
if target_info.endian=endian_little then
|
|
encoding:=CP_UTF16LE
|
|
encoding:=CP_UTF16LE
|
|
@@ -2217,7 +2235,7 @@ implementation
|
|
|
|
|
|
function tstringdef.getcopy : tstoreddef;
|
|
function tstringdef.getcopy : tstoreddef;
|
|
begin
|
|
begin
|
|
- result:=cstringdef.create(typ);
|
|
|
|
|
|
+ result:=cstringdef.create(typ,true);
|
|
result.typ:=stringdef;
|
|
result.typ:=stringdef;
|
|
tstringdef(result).stringtype:=stringtype;
|
|
tstringdef(result).stringtype:=stringtype;
|
|
tstringdef(result).encoding:=encoding;
|
|
tstringdef(result).encoding:=encoding;
|
|
@@ -2339,7 +2357,7 @@ implementation
|
|
|
|
|
|
constructor tenumdef.create;
|
|
constructor tenumdef.create;
|
|
begin
|
|
begin
|
|
- inherited create(enumdef);
|
|
|
|
|
|
+ inherited create(enumdef,true);
|
|
minval:=0;
|
|
minval:=0;
|
|
maxval:=0;
|
|
maxval:=0;
|
|
calcsavesize;
|
|
calcsavesize;
|
|
@@ -2351,7 +2369,7 @@ implementation
|
|
|
|
|
|
constructor tenumdef.create_subrange(_basedef:tenumdef;_min,_max:asizeint);
|
|
constructor tenumdef.create_subrange(_basedef:tenumdef;_min,_max:asizeint);
|
|
begin
|
|
begin
|
|
- inherited create(enumdef);
|
|
|
|
|
|
+ inherited create(enumdef,true);
|
|
minval:=_min;
|
|
minval:=_min;
|
|
maxval:=_max;
|
|
maxval:=_max;
|
|
basedef:=_basedef;
|
|
basedef:=_basedef;
|
|
@@ -2581,7 +2599,7 @@ implementation
|
|
|
|
|
|
constructor torddef.create(t : tordtype;v,b : TConstExprInt);
|
|
constructor torddef.create(t : tordtype;v,b : TConstExprInt);
|
|
begin
|
|
begin
|
|
- inherited create(orddef);
|
|
|
|
|
|
+ inherited create(orddef,true);
|
|
low:=v;
|
|
low:=v;
|
|
high:=b;
|
|
high:=b;
|
|
ordtype:=t;
|
|
ordtype:=t;
|
|
@@ -2722,7 +2740,7 @@ implementation
|
|
|
|
|
|
constructor tfloatdef.create(t : tfloattype);
|
|
constructor tfloatdef.create(t : tfloattype);
|
|
begin
|
|
begin
|
|
- inherited create(floatdef);
|
|
|
|
|
|
+ inherited create(floatdef,true);
|
|
floattype:=t;
|
|
floattype:=t;
|
|
setsize;
|
|
setsize;
|
|
end;
|
|
end;
|
|
@@ -2845,7 +2863,7 @@ implementation
|
|
|
|
|
|
constructor tfiledef.createtext;
|
|
constructor tfiledef.createtext;
|
|
begin
|
|
begin
|
|
- inherited create(filedef);
|
|
|
|
|
|
+ inherited create(filedef,true);
|
|
filetyp:=ft_text;
|
|
filetyp:=ft_text;
|
|
typedfiledef:=nil;
|
|
typedfiledef:=nil;
|
|
end;
|
|
end;
|
|
@@ -2853,7 +2871,7 @@ implementation
|
|
|
|
|
|
constructor tfiledef.createuntyped;
|
|
constructor tfiledef.createuntyped;
|
|
begin
|
|
begin
|
|
- inherited create(filedef);
|
|
|
|
|
|
+ inherited create(filedef,true);
|
|
filetyp:=ft_untyped;
|
|
filetyp:=ft_untyped;
|
|
typedfiledef:=nil;
|
|
typedfiledef:=nil;
|
|
end;
|
|
end;
|
|
@@ -2861,7 +2879,7 @@ implementation
|
|
|
|
|
|
constructor tfiledef.createtyped(def:tdef);
|
|
constructor tfiledef.createtyped(def:tdef);
|
|
begin
|
|
begin
|
|
- inherited create(filedef);
|
|
|
|
|
|
+ inherited create(filedef,true);
|
|
filetyp:=ft_typed;
|
|
filetyp:=ft_typed;
|
|
typedfiledef:=def;
|
|
typedfiledef:=def;
|
|
end;
|
|
end;
|
|
@@ -2984,7 +3002,7 @@ implementation
|
|
|
|
|
|
constructor tvariantdef.create(v : tvarianttype);
|
|
constructor tvariantdef.create(v : tvarianttype);
|
|
begin
|
|
begin
|
|
- inherited create(variantdef);
|
|
|
|
|
|
+ inherited create(variantdef,true);
|
|
varianttype:=v;
|
|
varianttype:=v;
|
|
setsize;
|
|
setsize;
|
|
end;
|
|
end;
|
|
@@ -3060,7 +3078,7 @@ implementation
|
|
|
|
|
|
constructor tabstractpointerdef.create(dt:tdeftyp;def:tdef);
|
|
constructor tabstractpointerdef.create(dt:tdeftyp;def:tdef);
|
|
begin
|
|
begin
|
|
- inherited create(dt);
|
|
|
|
|
|
+ inherited create(dt,true);
|
|
pointeddef:=def;
|
|
pointeddef:=def;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -3276,7 +3294,7 @@ implementation
|
|
packedsavesize: aint;
|
|
packedsavesize: aint;
|
|
actual_setalloc: ShortInt;
|
|
actual_setalloc: ShortInt;
|
|
begin
|
|
begin
|
|
- inherited create(setdef);
|
|
|
|
|
|
+ inherited create(setdef,true);
|
|
elementdef:=def;
|
|
elementdef:=def;
|
|
setmax:=high;
|
|
setmax:=high;
|
|
actual_setalloc:=current_settings.setalloc;
|
|
actual_setalloc:=current_settings.setalloc;
|
|
@@ -3373,7 +3391,7 @@ implementation
|
|
|
|
|
|
constructor tformaldef.create(Atyped:boolean);
|
|
constructor tformaldef.create(Atyped:boolean);
|
|
begin
|
|
begin
|
|
- inherited create(formaldef);
|
|
|
|
|
|
+ inherited create(formaldef,true);
|
|
typed:=Atyped;
|
|
typed:=Atyped;
|
|
savesize:=0;
|
|
savesize:=0;
|
|
end;
|
|
end;
|
|
@@ -3411,7 +3429,7 @@ implementation
|
|
|
|
|
|
constructor tarraydef.create(l,h:asizeint;def:tdef);
|
|
constructor tarraydef.create(l,h:asizeint;def:tdef);
|
|
begin
|
|
begin
|
|
- inherited create(arraydef);
|
|
|
|
|
|
+ inherited create(arraydef,true);
|
|
lowrange:=l;
|
|
lowrange:=l;
|
|
highrange:=h;
|
|
highrange:=h;
|
|
rangedef:=def;
|
|
rangedef:=def;
|
|
@@ -3718,7 +3736,7 @@ implementation
|
|
|
|
|
|
constructor tabstractrecorddef.create(const n:string; dt:tdeftyp);
|
|
constructor tabstractrecorddef.create(const n:string; dt:tdeftyp);
|
|
begin
|
|
begin
|
|
- inherited create(dt);
|
|
|
|
|
|
+ inherited create(dt,true);
|
|
objname:=stringdup(upper(n));
|
|
objname:=stringdup(upper(n));
|
|
objrealname:=stringdup(n);
|
|
objrealname:=stringdup(n);
|
|
objectoptions:=[];
|
|
objectoptions:=[];
|
|
@@ -4380,7 +4398,7 @@ implementation
|
|
|
|
|
|
constructor tabstractprocdef.create(dt:tdeftyp;level:byte);
|
|
constructor tabstractprocdef.create(dt:tdeftyp;level:byte);
|
|
begin
|
|
begin
|
|
- inherited create(dt);
|
|
|
|
|
|
+ inherited create(dt,true);
|
|
parast:=tparasymtable.create(self,level);
|
|
parast:=tparasymtable.create(self,level);
|
|
paras:=nil;
|
|
paras:=nil;
|
|
minparacount:=0;
|
|
minparacount:=0;
|
|
@@ -7288,7 +7306,7 @@ implementation
|
|
|
|
|
|
constructor tforwarddef.create(const s:string;const pos:tfileposinfo);
|
|
constructor tforwarddef.create(const s:string;const pos:tfileposinfo);
|
|
begin
|
|
begin
|
|
- inherited create(forwarddef);
|
|
|
|
|
|
+ inherited create(forwarddef,true);
|
|
tosymname:=stringdup(s);
|
|
tosymname:=stringdup(s);
|
|
forwardpos:=pos;
|
|
forwardpos:=pos;
|
|
end;
|
|
end;
|
|
@@ -7317,7 +7335,7 @@ implementation
|
|
|
|
|
|
constructor tundefineddef.create;
|
|
constructor tundefineddef.create;
|
|
begin
|
|
begin
|
|
- inherited create(undefineddef);
|
|
|
|
|
|
+ inherited create(undefineddef,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -7346,7 +7364,7 @@ implementation
|
|
|
|
|
|
constructor terrordef.create;
|
|
constructor terrordef.create;
|
|
begin
|
|
begin
|
|
- inherited create(errordef);
|
|
|
|
|
|
+ inherited create(errordef,true);
|
|
{ prevent consecutive faults }
|
|
{ prevent consecutive faults }
|
|
savesize:=1;
|
|
savesize:=1;
|
|
end;
|
|
end;
|