mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-01 09:12:14 +02:00
* factored out getting a previously created internal type by name
git-svn-id: trunk@31247 -
This commit is contained in:
parent
ddeab221c0
commit
413680f593
@ -1328,25 +1328,19 @@ implementation
|
|||||||
function ttai_typedconstbuilder.begin_anonymous_record(const optionalname: string; packrecords, recordalignmin, maxcrecordalign: shortint): trecorddef;
|
function ttai_typedconstbuilder.begin_anonymous_record(const optionalname: string; packrecords, recordalignmin, maxcrecordalign: shortint): trecorddef;
|
||||||
var
|
var
|
||||||
anonrecorddef: trecorddef;
|
anonrecorddef: trecorddef;
|
||||||
srsym: tsym;
|
typesym: ttypesym;
|
||||||
srsymtable: tsymtable;
|
|
||||||
found: boolean;
|
|
||||||
begin
|
begin
|
||||||
{ if the name is specified, we create a typesym with that name in order
|
{ if the name is specified, we create a typesym with that name in order
|
||||||
to ensure we can find it again later with that name -> reuse here as
|
to ensure we can find it again later with that name -> reuse here as
|
||||||
well if possible (and that also avoids duplicate type name issues) }
|
well if possible (and that also avoids duplicate type name issues) }
|
||||||
if optionalname<>'' then
|
if optionalname<>'' then
|
||||||
begin
|
begin
|
||||||
if optionalname[1]='$' then
|
typesym:=try_search_current_module_type(optionalname);
|
||||||
found:=searchsym_in_module(current_module,copy(optionalname,2,length(optionalname)),srsym,srsymtable)
|
if assigned(typesym) then
|
||||||
else
|
|
||||||
found:=searchsym_in_module(current_module,optionalname,srsym,srsymtable);
|
|
||||||
if found then
|
|
||||||
begin
|
begin
|
||||||
if (srsym.typ<>typesym) or
|
if typesym.typedef.typ<>recorddef then
|
||||||
(ttypesym(srsym).typedef.typ<>recorddef) then
|
internalerror(2015071401);
|
||||||
internalerror(2014091207);
|
result:=trecorddef(typesym.typedef);
|
||||||
result:=trecorddef(ttypesym(srsym).typedef);
|
|
||||||
maybe_begin_aggregate(result);
|
maybe_begin_aggregate(result);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
@ -318,6 +318,7 @@ interface
|
|||||||
function searchsym_in_helper(classh,contextclassh:tobjectdef;const s: TIDString;out srsym:tsym;out srsymtable:TSymtable;flags:tsymbol_search_flags):boolean;
|
function searchsym_in_helper(classh,contextclassh:tobjectdef;const s: TIDString;out srsym:tsym;out srsymtable:TSymtable;flags:tsymbol_search_flags):boolean;
|
||||||
function search_system_type(const s: TIDString): ttypesym;
|
function search_system_type(const s: TIDString): ttypesym;
|
||||||
function try_search_system_type(const s: TIDString): ttypesym;
|
function try_search_system_type(const s: TIDString): ttypesym;
|
||||||
|
function try_search_current_module_type(const s: TIDString): ttypesym;
|
||||||
function search_system_proc(const s: TIDString): tprocdef;
|
function search_system_proc(const s: TIDString): tprocdef;
|
||||||
function search_named_unit_globaltype(const unitname, typename: TIDString; throwerror: boolean): ttypesym;
|
function search_named_unit_globaltype(const unitname, typename: TIDString; throwerror: boolean): ttypesym;
|
||||||
function search_struct_member(pd : tabstractrecorddef;const s : string):tsym;
|
function search_struct_member(pd : tabstractrecorddef;const s : string):tsym;
|
||||||
@ -3599,6 +3600,27 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function try_search_current_module_type(const s: TIDString): ttypesym;
|
||||||
|
var
|
||||||
|
found: boolean;
|
||||||
|
srsymtable: tsymtable;
|
||||||
|
srsym: tsym;
|
||||||
|
begin
|
||||||
|
if s[1]='$' then
|
||||||
|
found:=searchsym_in_module(current_module,copy(s,2,length(s)),srsym,srsymtable)
|
||||||
|
else
|
||||||
|
found:=searchsym_in_module(current_module,s,srsym,srsymtable);
|
||||||
|
if found then
|
||||||
|
begin
|
||||||
|
if (srsym.typ<>typesym) then
|
||||||
|
internalerror(2014091207);
|
||||||
|
result:=ttypesym(srsym);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function search_system_proc(const s: TIDString): tprocdef;
|
function search_system_proc(const s: TIDString): tprocdef;
|
||||||
var
|
var
|
||||||
srsym: tsym;
|
srsym: tsym;
|
||||||
|
Loading…
Reference in New Issue
Block a user