69
68
procedure buildderefimpl;virtual;
70
69
procedure deref;virtual;
71
70
procedure derefimpl;virtual;
72
procedure duplicatesym(dupsym,sym:tsymentry);
73
71
procedure insert(sym : tsymentry);override;
74
72
procedure reset_all_defs;virtual;
75
73
function speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
99
97
procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
100
98
procedure write_references(ppufile:tcompilerppufile;locals:boolean);override;
101
99
procedure insertfield(sym:tfieldvarsym;addsym:boolean);
100
procedure derefimpl; override;
102
101
procedure addalignmentpadding;
200
199
function findunitsymtable(st:tsymtable):tsymtable;
201
200
function FullTypeName(def,otherdef:tdef):string;
202
201
procedure incompatibletypes(def1,def2:tdef);
202
procedure hidesym(sym:tsymentry);
203
procedure duplicatesym(dupsym,sym:tsymentry);
205
206
function searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
228
229
{Name can be given in any case (it will be converted to upper case).}
229
230
procedure def_system_macro(const name : string);
230
231
procedure set_system_macro(const name, value : string);
232
procedure set_system_compvar(const name, value : string);
231
233
procedure undef_system_macro(const name : string);
233
235
{*** symtable stack ***}
582
582
hp:=tdef(hp.indexnext);
587
procedure tstoredsymtable.duplicatesym(dupsym,sym:tsymentry);
591
Message1(sym_e_duplicate_id,tsym(sym).realname);
592
st:=findunitsymtable(sym.owner);
593
with tsym(sym).fileinfo do
596
(st.symtabletype=globalsymtable) and
597
(not st.iscurrentunit) then
598
Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
600
Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
602
{ Rename duplicate sym to an unreachable name, but it can be
603
inserted in the symtable without errors }
604
if assigned(dupsym) then
607
dupsym.name:='dup'+tostr(dupnr)+dupsym.name;
585
hs:=tsym(symindex.first);
586
while assigned(hs) do
589
hs:=tsym(hs.indexnext);
710
692
tprocsym(sym).check_forward
711
693
{ check also object method table }
712
694
{ we needn't to test the def list }
713
{ because each object has to have a type sym }
695
{ because each object has to have a type sym,
696
only test objects declarations, not type renamings }
715
698
if (tsym(sym).typ=typesym) and
716
699
assigned(ttypesym(sym).restype.def) and
700
(ttypesym(sym).restype.def.typesym=ttypesym(sym)) and
717
701
(ttypesym(sym).restype.def.deftype=objectdef) then
718
702
tobjectdef(ttypesym(sym).restype.def).check_forwards;
744
728
{ also don't count the value parameters which have local copies }
745
729
{ also don't claim for high param of open parameters (PM) }
746
730
if (Errorcount<>0) or
747
(vo_is_hidden_para in tabstractvarsym(p).varoptions) then
731
([vo_is_hidden_para,vo_is_funcret] * tabstractvarsym(p).varoptions = [vo_is_hidden_para]) then
749
733
if (tstoredsym(p).refs=0) then
763
747
MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_not_used,tsym(p).realname);
765
else if tabstractvarsym(p).varstate=vs_assigned then
749
else if tabstractvarsym(p).varstate in [vs_written,vs_initialised] then
767
751
if (tsym(p).owner.symtabletype=parasymtable) then
775
759
else if not(vo_is_exported in tabstractvarsym(p).varoptions) and
776
760
not(vo_is_funcret in tabstractvarsym(p).varoptions) then
777
761
MessagePos1(tsym(p).fileinfo,sym_n_local_identifier_only_set,tsym(p).realname);
763
else if (tabstractvarsym(p).varstate = vs_read_not_warned) and
764
([vo_is_exported,vo_is_external] * tabstractvarsym(p).varoptions = []) then
765
MessagePos1(tsym(p).fileinfo,sym_w_identifier_only_read,tsym(p).realname)
780
767
else if ((tsym(p).owner.symtabletype in
781
768
[objectsymtable,parasymtable,localsymtable,staticsymtable])) then
1011
procedure tabstractrecordsymtable.derefimpl;
1013
storesymtable : tsymtable;
1015
storesymtable:=aktrecordsymtable;
1016
aktrecordsymtable:=self;
1018
inherited derefimpl;
1020
aktrecordsymtable:=storesymtable;
1023
1024
procedure tabstractrecordsymtable.insertfield(sym : tfieldvarsym;addsym:boolean);
1197
1198
{ but private ids can be reused }
1198
1199
hsym:=search_class_member(tobjectdef(defowner),sym.name);
1199
1200
if assigned(hsym) and
1200
Tsym(hsym).is_visible_for_object(tobjectdef(defowner)) then
1201
tsym(hsym).is_visible_for_object(tobjectdef(defowner),tobjectdef(defowner)) then
1201
1202
DuplicateSym(sym,hsym);
1203
1204
inherited insert(sym);
1251
1252
(vo_is_funcret in tabstractvarsym(hsym).varoptions) and
1252
1253
not((m_result in aktmodeswitches) and
1253
1254
(vo_is_result in tabstractvarsym(hsym).varoptions)) then
1254
hsym.owner.rename(hsym.name,'hidden'+hsym.name)
1256
1257
DuplicateSym(sym,hsym);
1283
1284
hsym:=search_class_member(tobjectdef(next.next.defowner),sym.name);
1284
1285
if assigned(hsym) and
1285
1286
{ private ids can be reused }
1286
(hsym.is_visible_for_object(tobjectdef(next.next.defowner)) or
1287
(hsym.is_visible_for_object(tobjectdef(next.next.defowner),tobjectdef(next.next.defowner)) or
1287
1288
(hsym.owner.defowner.owner.symtabletype<>globalsymtable)) then
1289
1290
{ delphi allows to reuse the names in a class, but not
1324
1325
hsym:=search_class_member(tobjectdef(next.defowner),sym.name);
1325
1326
{ private ids can be reused }
1326
1327
if assigned(hsym) and
1327
Tsym(hsym).is_visible_for_object(tobjectdef(next.defowner)) then
1328
Tsym(hsym).is_visible_for_object(tobjectdef(next.defowner),tobjectdef(next.defowner)) then
1329
1330
{ delphi allows to reuse the names in a class, but not
1330
1331
in object (tp7 compatible) }
1507
1508
<unit>.<id>, so we can hide the symbol }
1508
1509
if (m_duplicate_names in aktmodeswitches) and
1509
1510
(hsym.typ=symconst.unitsym) then
1510
hsym.owner.rename(hsym.name,'hidden'+hsym.name)
1512
1513
DuplicateSym(sym,hsym);
1641
1642
<unit>.<id>, so we can hide the symbol }
1642
1643
if (m_duplicate_names in aktmodeswitches) and
1643
1644
(hsym.typ=symconst.unitsym) then
1644
hsym.owner.rename(hsym.name,'hidden'+hsym.name)
1646
1647
DuplicateSym(sym,hsym);
1806
procedure hidesym(sym:tsymentry);
1810
if assigned(sym.owner) then
1811
sym.owner.rename(sym.name,'hidden'+sym.name)
1813
sym.name:='hidden'+sym.name;
1814
s:='hidden'+tsym(sym).realname;
1815
stringdispose(tsym(sym)._realname);
1816
tsym(sym)._realname:=stringdup(s);
1821
dupnr : longint; { unique number for duplicate symbols }
1823
procedure duplicatesym(dupsym,sym:tsymentry);
1827
Message1(sym_e_duplicate_id,tsym(sym).realname);
1828
st:=findunitsymtable(sym.owner);
1829
with tsym(sym).fileinfo do
1832
(st.symtabletype=globalsymtable) and
1833
(not st.iscurrentunit) then
1834
Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
1836
Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
1838
{ Rename duplicate sym to an unreachable name, but it can be
1839
inserted in the symtable without errors }
1840
if assigned(dupsym) then
1843
dupsym.name:='dup'+tostr(dupnr)+dupsym.name;
1844
include(tsym(dupsym).symoptions,sp_implicitrename);
1805
1849
{*****************************************************************************
1807
1851
*****************************************************************************}
1832
1877
if assigned(current_procinfo) then
1833
1878
topclass:=current_procinfo.procdef._class;
1835
if Tsym(srsym).is_visible_for_object(topclass) then
1880
if assigned(current_procinfo) then
1881
context:=current_procinfo.procdef._class
1884
if tsym(srsym).is_visible_for_object(topclass,context) then
1837
1886
{ we need to know if a procedure references symbols
1838
1887
in the static symtable, because then it can't be
1869
1918
srsym:=tsym(srsymtable.speedsearch(s,speedvalue));
1870
1919
if assigned(srsym) and
1871
1920
(not assigned(current_procinfo) or
1872
Tsym(srsym).is_visible_for_object(current_procinfo.procdef._class)) then
1921
tsym(srsym).is_visible_for_object(current_procinfo.procdef._class,current_procinfo.procdef._class)) then
1938
1987
sym:=tsym(classh.symtable.speedsearch(s,speedvalue));
1939
1988
if assigned(sym) and
1940
Tsym(sym).is_visible_for_object(topclassh) then
1989
tsym(sym).is_visible_for_object(topclassh,current_procinfo.procdef._class) then
1942
1993
classh:=classh.childof;
1944
1995
searchsym_in_class:=sym;
1948
function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint):tsym;
1999
function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint):tsym;
1950
2001
topclassh : tobjectdef;
2064
2120
if sym.typ<>procsym then
2065
2121
internalerror(200402031);
2066
search_assignment_operator:=sym.search_procdef_assignment_operator(from_def,to_def);
2067
if search_assignment_operator<>nil then
2122
{ if the source type is an alias then this is only the second choice,
2123
if you mess with this code, check tw4093 }
2124
currpd:=sym.search_procdef_assignment_operator(from_def,to_def,curreq);
2125
if curreq>besteq then
2129
if (besteq=te_exact) then
2074
2138
function searchsystype(const s: stringid; var srsym: ttypesym): boolean;
2217
2281
if (srsym.typ<>procsym) then
2218
2282
internalerror(200111022);
2219
if srsym.is_visible_for_object(tobjectdef(aprocsym.owner.defowner)) then
2283
if srsym.is_visible_for_object(tobjectdef(aprocsym.owner.defowner),tobjectdef(aprocsym.owner.defowner)) then
2221
2285
srsym.add_para_match_to(Aprocsym,[cpo_ignorehidden,cpo_allowdefaults]);
2222
2286
{ we can stop if the overloads were already added
2312
2376
mac.defined:=true;
2379
procedure set_system_compvar(const name, value : string);
2385
internalerror(2004121201);
2387
mac:=tmacro(search_macro(s));
2388
if not assigned(mac) then
2390
mac:=tmacro.create(s);
2391
mac.is_compiler_var:=true;
2392
if macrosymtablestack.symtabletype=localmacrosymtable then
2393
macrosymtablestack.insert(mac)
2395
macrosymtablestack.next.insert(mac)
2399
mac.is_compiler_var:=true;
2400
if assigned(mac.buftext) then
2401
freemem(mac.buftext,mac.buflen);
2403
Message2(parser_c_macro_set_to,mac.name,value);
2404
mac.buflen:=length(value);
2405
getmem(mac.buftext,mac.buflen);
2406
move(value[1],mac.buftext^,mac.buflen);
2315
2410
procedure undef_system_macro(const name : string);
2470
$Log: symtable.pas,v $
2471
Revision 1.172 2005/03/13 12:15:44 florian
2472
+ reset in InitSymtable some global vars to avoid trouble with the ide
2474
Revision 1.171 2005/02/14 17:13:08 peter
2477
Revision 1.170 2005/01/20 16:38:45 peter
2478
* load jmp_buf_size from system unit
2480
Revision 1.169 2005/01/19 22:19:41 peter
2481
* unit mapping rewrite
2482
* new derefmap added
2484
Revision 1.168 2005/01/09 20:24:43 olle
2485
* rework of macro subsystem
2486
+ exportable macros for mode macpas