summaryrefslogtreecommitdiff
path: root/compiler/symdef.pas
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/symdef.pas')
-rw-r--r--compiler/symdef.pas52
1 files changed, 42 insertions, 10 deletions
diff --git a/compiler/symdef.pas b/compiler/symdef.pas
index a07584ab0a..2d0543bc0d 100644
--- a/compiler/symdef.pas
+++ b/compiler/symdef.pas
@@ -175,6 +175,9 @@ interface
function is_generic:boolean;
{ same as above for specializations }
function is_specialization:boolean;
+ { generic utilities }
+ function is_generic_param_const(index:integer):boolean;inline;
+ function get_generic_param_def(index:integer):tdef;inline;
{ registers this def in the unit's deflist; no-op if already registered }
procedure register_def; override;
{ add the def to the top of the symtable stack if it's not yet owned
@@ -2407,14 +2410,32 @@ implementation
for i:=0 to genericparas.count-1 do
begin
sym:=tsym(genericparas[i]);
- if sym.typ<>symconst.typesym then
+ { sym must be either a type or const }
+ if not (sym.typ in [symconst.typesym,symconst.constsym]) then
internalerror(2014050903);
if sym.owner.defowner<>self then
exit(false);
+ if (sym.typ=symconst.constsym) and (sp_generic_const in sym.symoptions) then
+ exit(false);
end;
end;
+ function tstoreddef.is_generic_param_const(index:integer):boolean;
+ begin
+ result:=tsym(genericparas[index]).typ=constsym;
+ end;
+
+
+ function tstoreddef.get_generic_param_def(index:integer):tdef;
+ begin
+ if tsym(genericparas[index]).typ=constsym then
+ result:=tconstsym(genericparas[index]).constdef
+ else
+ result:=ttypesym(genericparas[index]).typedef;
+ end;
+
+
function tstoreddef.is_specialization: boolean;
var
i : longint;
@@ -2430,10 +2451,13 @@ implementation
for i:=0 to genericparas.count-1 do
begin
sym:=tsym(genericparas[i]);
- if sym.typ<>symconst.typesym then
+ { sym must be either a type or const }
+ if not (sym.typ in [symconst.typesym,symconst.constsym]) then
internalerror(2014050904);
if sym.owner.defowner<>self then
exit(true);
+ if (sym.typ=symconst.constsym) and (sp_generic_const in sym.symoptions) then
+ exit(true);
end;
result:=false;
end;
@@ -4179,7 +4203,7 @@ implementation
ppufile.getderef(rangedefderef);
lowrange:=ppufile.getasizeint;
highrange:=ppufile.getasizeint;
- ppufile.getset(tppuset1(arrayoptions));
+ ppufile.getset(tppuset2(arrayoptions));
ppuload_platform(ppufile);
symtable:=tarraysymtable.create(self);
tarraysymtable(symtable).ppuload(ppufile)
@@ -4219,7 +4243,7 @@ implementation
ppufile.putderef(rangedefderef);
ppufile.putasizeint(lowrange);
ppufile.putasizeint(highrange);
- ppufile.putset(tppuset1(arrayoptions));
+ ppufile.putset(tppuset2(arrayoptions));
writeentry(ppufile,ibarraydef);
tarraysymtable(symtable).ppuwrite(ppufile);
end;
@@ -4339,6 +4363,7 @@ implementation
(ado_IsDynamicArray in arrayoptions) or
(ado_IsConvertedPointer in arrayoptions) or
(ado_IsConstructor in arrayoptions) or
+ (ado_IsGeneric in arrayoptions) or
(highrange<lowrange)
) and
(size=-1) then
@@ -4543,7 +4568,8 @@ implementation
fullparas,
paramname : ansistring;
module : tmodule;
- sym : ttypesym;
+ sym : tsym;
+ def : tdef;
i : longint;
begin
{ we want at least enough space for an ellipsis }
@@ -4552,15 +4578,21 @@ implementation
fullparas:='';
for i:=0 to genericparas.count-1 do
begin
- sym:=ttypesym(genericparas[i]);
+ sym:=tsym(genericparas[i]);
module:=find_module_from_symtable(sym.owner);
if not assigned(module) then
internalerror(2014121202);
+ if not (sym.typ in [constsym,symconst.typesym]) then
+ internalerror(2020042501);
+ if sym.typ=constsym then
+ def:=tconstsym(sym).constdef
+ else
+ def:=ttypesym(sym).typedef;
paramname:=module.realmodulename^;
- if sym.typedef.typ in [objectdef,recorddef] then
- paramname:=paramname+'.'+tabstractrecorddef(sym.typedef).rttiname
+ if def.typ in [objectdef,recorddef] then
+ paramname:=paramname+'.'+tabstractrecorddef(def).rttiname
else
- paramname:=paramname+'.'+sym.typedef.typename;
+ paramname:=paramname+'.'+def.typename;
if length(fullparas)+commacount[i>0]+length(paramname)>maxlength then
begin
if i>0 then
@@ -5958,7 +5990,7 @@ implementation
if AValue then
include(implprocoptions,pio_empty)
else
- include(implprocoptions,pio_empty);
+ exclude(implprocoptions,pio_empty);
end;