|
@@ -464,6 +464,7 @@ uses
|
|
countstr,genname,ugenname : string;
|
|
countstr,genname,ugenname : string;
|
|
srsym : tsym;
|
|
srsym : tsym;
|
|
st : tsymtable;
|
|
st : tsymtable;
|
|
|
|
+ tmpstack : tfpobjectlist;
|
|
begin
|
|
begin
|
|
context:=nil;
|
|
context:=nil;
|
|
result:=nil;
|
|
result:=nil;
|
|
@@ -472,8 +473,21 @@ uses
|
|
errorrecovery:=false;
|
|
errorrecovery:=false;
|
|
if (symname='') and
|
|
if (symname='') and
|
|
(not assigned(genericdef) or
|
|
(not assigned(genericdef) or
|
|
- not assigned(genericdef.typesym) or
|
|
|
|
- (genericdef.typesym.typ<>typesym)) then
|
|
|
|
|
|
+ (
|
|
|
|
+ (genericdef.typ<>procdef) and
|
|
|
|
+ (
|
|
|
|
+ not assigned(genericdef.typesym) or
|
|
|
|
+ (genericdef.typesym.typ<>typesym)
|
|
|
|
+ )
|
|
|
|
+ ) or
|
|
|
|
+ (
|
|
|
|
+ (genericdef.typ=procdef) and
|
|
|
|
+ (
|
|
|
|
+ not assigned(tprocdef(genericdef).procsym) or
|
|
|
|
+ (tprocdef(genericdef).procsym.typ<>procsym)
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ ) then
|
|
begin
|
|
begin
|
|
errorrecovery:=true;
|
|
errorrecovery:=true;
|
|
result:=generrordef;
|
|
result:=generrordef;
|
|
@@ -592,7 +606,12 @@ uses
|
|
{ use the name of the symbol as procvars return a user friendly version
|
|
{ use the name of the symbol as procvars return a user friendly version
|
|
of the name }
|
|
of the name }
|
|
if symname='' then
|
|
if symname='' then
|
|
- genname:=ttypesym(genericdef.typesym).realname
|
|
|
|
|
|
+ begin
|
|
|
|
+ if genericdef.typ=procdef then
|
|
|
|
+ genname:=tprocdef(genericdef).procsym.realname
|
|
|
|
+ else
|
|
|
|
+ genname:=ttypesym(genericdef.typesym).realname;
|
|
|
|
+ end
|
|
else
|
|
else
|
|
genname:=symname;
|
|
genname:=symname;
|
|
|
|
|
|
@@ -646,6 +665,28 @@ uses
|
|
else
|
|
else
|
|
found:=searchsym(ugenname,context.sym,context.symtable);
|
|
found:=searchsym(ugenname,context.sym,context.symtable);
|
|
|
|
|
|
|
|
+ if found and (context.sym.typ=absolutevarsym) and
|
|
|
|
+ (vo_is_funcret in tabstractvarsym(context.sym).varoptions) then
|
|
|
|
+ begin
|
|
|
|
+ { we found the function result alias of a generic function; go up the
|
|
|
|
+ symbol stack *before* this alias was inserted, so that we can
|
|
|
|
+ (hopefully) find the correct generic symbol }
|
|
|
|
+ tmpstack:=tfpobjectlist.create(false);
|
|
|
|
+ while assigned(symtablestack.top) do
|
|
|
|
+ begin
|
|
|
|
+ tmpstack.Add(symtablestack.top);
|
|
|
|
+ symtablestack.pop(symtablestack.top);
|
|
|
|
+ if tmpstack.Last=context.symtable then
|
|
|
|
+ break;
|
|
|
|
+ end;
|
|
|
|
+ if not assigned(symtablestack.top) then
|
|
|
|
+ internalerror(2019123001);
|
|
|
|
+ found:=searchsym(ugenname,context.sym,context.symtable);
|
|
|
|
+ for i:=tmpstack.count-1 downto 0 do
|
|
|
|
+ symtablestack.push(tsymtable(tmpstack[i]));
|
|
|
|
+ tmpstack.free;
|
|
|
|
+ end;
|
|
|
|
+
|
|
if not found or not (context.sym.typ in [typesym,procsym]) then
|
|
if not found or not (context.sym.typ in [typesym,procsym]) then
|
|
begin
|
|
begin
|
|
identifier_not_found(genname);
|
|
identifier_not_found(genname);
|
|
@@ -735,6 +776,7 @@ uses
|
|
old_current_specializedef,
|
|
old_current_specializedef,
|
|
old_current_genericdef : tstoreddef;
|
|
old_current_genericdef : tstoreddef;
|
|
old_current_procinfo : tprocinfo;
|
|
old_current_procinfo : tprocinfo;
|
|
|
|
+ old_module_procinfo : tobject;
|
|
hmodule : tmodule;
|
|
hmodule : tmodule;
|
|
oldcurrent_filepos : tfileposinfo;
|
|
oldcurrent_filepos : tfileposinfo;
|
|
recordbuf : tdynamicarray;
|
|
recordbuf : tdynamicarray;
|
|
@@ -859,7 +901,13 @@ uses
|
|
{ decide in which symtable to put the specialization }
|
|
{ decide in which symtable to put the specialization }
|
|
if parse_generic and not assigned(result) then
|
|
if parse_generic and not assigned(result) then
|
|
begin
|
|
begin
|
|
- if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
|
|
|
|
|
|
+ srsymtable:=symtablestack.top;
|
|
|
|
+ if (srsymtable.symtabletype in [localsymtable,parasymtable]) and tstoreddef(srsymtable.defowner).is_specialization then
|
|
|
|
+ { if we are currently specializing a routine we need to specialize into
|
|
|
|
+ the routine's local- or parasymtable so that they are correctly
|
|
|
|
+ registered should the specialization be finalized }
|
|
|
|
+ specializest:=srsymtable
|
|
|
|
+ else if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
|
|
{ if we are parsing the definition of a method we specialize into
|
|
{ if we are parsing the definition of a method we specialize into
|
|
the local symtable of it }
|
|
the local symtable of it }
|
|
specializest:=current_procinfo.procdef.getsymtable(gs_local)
|
|
specializest:=current_procinfo.procdef.getsymtable(gs_local)
|
|
@@ -943,8 +991,10 @@ uses
|
|
old_current_genericdef:=nil;
|
|
old_current_genericdef:=nil;
|
|
old_current_structdef:=nil;
|
|
old_current_structdef:=nil;
|
|
old_current_procinfo:=current_procinfo;
|
|
old_current_procinfo:=current_procinfo;
|
|
|
|
+ old_module_procinfo:=current_module.procinfo;
|
|
|
|
|
|
current_procinfo:=nil;
|
|
current_procinfo:=nil;
|
|
|
|
+ current_module.procinfo:=nil;
|
|
|
|
|
|
if parse_class_parent then
|
|
if parse_class_parent then
|
|
begin
|
|
begin
|
|
@@ -1126,6 +1176,7 @@ uses
|
|
|
|
|
|
block_type:=old_block_type;
|
|
block_type:=old_block_type;
|
|
current_procinfo:=old_current_procinfo;
|
|
current_procinfo:=old_current_procinfo;
|
|
|
|
+ current_module.procinfo:=old_module_procinfo;
|
|
if parse_class_parent then
|
|
if parse_class_parent then
|
|
begin
|
|
begin
|
|
current_structdef:=old_current_structdef;
|
|
current_structdef:=old_current_structdef;
|