mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 06:29:32 +02:00
* apply patch by Blaise.ru:
- avoid creation of a dummy typesym just to call parse_var_proc_directives() by introducing a new parse_proctype_directives() that takes a tprocvardef instead of a symbol like the former does - have parse_var_proc_directives() call parse_proctype_directives() to avoid duplicated code
This commit is contained in:
parent
542c3f0c4c
commit
0bbfad1add
@ -69,6 +69,7 @@ interface
|
||||
procedure parse_parameter_dec(pd:tabstractprocdef);
|
||||
procedure parse_proc_directives(pd:tabstractprocdef;var pdflags:tpdflags);
|
||||
procedure parse_var_proc_directives(sym:tsym);
|
||||
procedure parse_proctype_directives(pd:tprocvardef);
|
||||
procedure parse_object_proc_directives(pd:tabstractprocdef);
|
||||
procedure parse_record_proc_directives(pd:tabstractprocdef);
|
||||
function parse_proc_head(astruct:tabstractrecorddef;potype:tproctypeoption;flags:tparse_proc_flags;genericdef:tdef;generictypelist:tfphashobjectlist;out pd:tprocdef):boolean;
|
||||
@ -218,7 +219,6 @@ implementation
|
||||
parseprocvar : tppv;
|
||||
locationstr : string;
|
||||
paranr : integer;
|
||||
dummytype : ttypesym;
|
||||
explicit_paraloc,
|
||||
need_array,
|
||||
is_univ: boolean;
|
||||
@ -352,22 +352,16 @@ implementation
|
||||
single_type(pv.returndef,[]);
|
||||
block_type:=bt_var;
|
||||
end;
|
||||
hdef:=pv;
|
||||
{ possible proc directives }
|
||||
if check_proc_directive(true) then
|
||||
begin
|
||||
dummytype:=ctypesym.create('unnamed',hdef);
|
||||
parse_var_proc_directives(tsym(dummytype));
|
||||
dummytype.typedef:=nil;
|
||||
hdef.typesym:=nil;
|
||||
dummytype.free;
|
||||
end;
|
||||
parse_proctype_directives(pv);
|
||||
{ Add implicit hidden parameters and function result }
|
||||
handle_calling_convention(pv,hcc_default_actions_intf);
|
||||
{$ifdef jvm}
|
||||
{ anonymous -> no name }
|
||||
jvm_create_procvar_class('',pv);
|
||||
{$endif}
|
||||
hdef:=pv;
|
||||
end
|
||||
else
|
||||
{ read type declaration, force reading for value paras }
|
||||
@ -3440,25 +3434,30 @@ const
|
||||
|
||||
procedure parse_var_proc_directives(sym:tsym);
|
||||
var
|
||||
pdflags : tpdflags;
|
||||
pd : tabstractprocdef;
|
||||
pd : tprocvardef;
|
||||
begin
|
||||
pdflags:=[pd_procvar];
|
||||
pd:=nil;
|
||||
case sym.typ of
|
||||
fieldvarsym,
|
||||
staticvarsym,
|
||||
localvarsym,
|
||||
paravarsym :
|
||||
pd:=tabstractprocdef(tabstractvarsym(sym).vardef);
|
||||
pd:=tprocvardef(tabstractvarsym(sym).vardef);
|
||||
typesym :
|
||||
pd:=tabstractprocdef(ttypesym(sym).typedef);
|
||||
pd:=tprocvardef(ttypesym(sym).typedef);
|
||||
else
|
||||
internalerror(2003042617);
|
||||
end;
|
||||
if pd.typ<>procvardef then
|
||||
internalerror(2003042618);
|
||||
{ names should never be used anyway }
|
||||
parse_proctype_directives(pd);
|
||||
end;
|
||||
|
||||
|
||||
procedure parse_proctype_directives(pd:tprocvardef);
|
||||
var
|
||||
pdflags : tpdflags;
|
||||
begin
|
||||
pdflags:=[pd_procvar];
|
||||
parse_proc_directives(pd,pdflags);
|
||||
end;
|
||||
|
||||
|
@ -886,8 +886,6 @@ implementation
|
||||
|
||||
|
||||
function maybe_parse_proc_directives(def:tdef):boolean;
|
||||
var
|
||||
newtype : ttypesym;
|
||||
begin
|
||||
result:=false;
|
||||
{ Process procvar directives before = and ; }
|
||||
@ -895,11 +893,7 @@ implementation
|
||||
(def.typesym=nil) and
|
||||
check_proc_directive(true) then
|
||||
begin
|
||||
newtype:=ctypesym.create('unnamed',def);
|
||||
parse_var_proc_directives(tsym(newtype));
|
||||
newtype.typedef:=nil;
|
||||
def.typesym:=nil;
|
||||
newtype.free;
|
||||
parse_proctype_directives(tprocvardef(def));
|
||||
result:=true;
|
||||
end;
|
||||
end;
|
||||
|
@ -1565,8 +1565,7 @@ implementation
|
||||
function procvar_dec(genericdef:tstoreddef;genericlist:tfphashobjectlist;doregister:boolean):tdef;
|
||||
var
|
||||
is_func:boolean;
|
||||
pd:tabstractprocdef;
|
||||
newtype:ttypesym;
|
||||
pd:tprocvardef;
|
||||
old_current_genericdef,
|
||||
old_current_specializedef: tstoreddef;
|
||||
old_parse_generic: boolean;
|
||||
@ -1628,18 +1627,11 @@ implementation
|
||||
end;
|
||||
symtablestack.pop(pd.parast);
|
||||
tparasymtable(pd.parast).readonly:=false;
|
||||
result:=pd;
|
||||
{ possible proc directives }
|
||||
if parseprocvardir then
|
||||
begin
|
||||
if check_proc_directive(true) then
|
||||
begin
|
||||
newtype:=ctypesym.create('unnamed',result);
|
||||
parse_var_proc_directives(tsym(newtype));
|
||||
newtype.typedef:=nil;
|
||||
result.typesym:=nil;
|
||||
newtype.free;
|
||||
end;
|
||||
parse_proctype_directives(pd);
|
||||
{ Add implicit hidden parameters and function result }
|
||||
handle_calling_convention(pd,hcc_default_actions_intf);
|
||||
end;
|
||||
@ -1647,6 +1639,8 @@ implementation
|
||||
parse_generic:=old_parse_generic;
|
||||
current_genericdef:=old_current_genericdef;
|
||||
current_specializedef:=old_current_specializedef;
|
||||
|
||||
result:=pd;
|
||||
end;
|
||||
|
||||
const
|
||||
|
Loading…
Reference in New Issue
Block a user