fmodule.pas 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements the first loading and searching of the modules
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit fmodule;
  18. {$i fpcdefs.inc}
  19. {$ifdef go32v2}
  20. {$define shortasmprefix}
  21. {$endif}
  22. {$ifdef watcom}
  23. {$define shortasmprefix}
  24. {$endif}
  25. {$ifdef atari}
  26. {$define shortasmprefix}
  27. {$endif}
  28. {$ifdef OS2}
  29. { Allthough OS/2 supports long filenames I play it safe and
  30. use 8.3 filenames, because this allows the compiler to run
  31. on a FAT partition. (DM) }
  32. {$define shortasmprefix}
  33. {$endif}
  34. interface
  35. uses
  36. cutils,cclasses,cfileutl,
  37. globtype,finput,ogbase,fpkg,
  38. symbase,symsym,
  39. wpobase,
  40. aasmbase,aasmdata;
  41. const
  42. UNSPECIFIED_LIBRARY_NAME = '<none>';
  43. type
  44. trecompile_reason = (rr_unknown,
  45. rr_noppu,rr_sourcenewer,rr_build,rr_crcchanged
  46. );
  47. { unit options }
  48. tmoduleoption = (mo_none,
  49. mo_hint_deprecated,
  50. mo_hint_platform,
  51. mo_hint_library,
  52. mo_hint_unimplemented,
  53. mo_hint_experimental,
  54. mo_has_deprecated_msg
  55. );
  56. tmoduleoptions = set of tmoduleoption;
  57. tlinkcontaineritem=class(tlinkedlistitem)
  58. public
  59. data : TPathStr;
  60. needlink : cardinal;
  61. constructor Create(const s:TPathStr;m:cardinal);
  62. end;
  63. tlinkcontainer=class(tlinkedlist)
  64. procedure add(const s : TPathStr;m:cardinal);
  65. function get(var m:cardinal) : TPathStr;
  66. function getusemask(mask:cardinal) : TPathStr;
  67. function find(const s:TPathStr):boolean;
  68. end;
  69. tmodule = class;
  70. tused_unit = class;
  71. tunitmaprec = record
  72. u : tmodule;
  73. { number of references }
  74. refs : longint;
  75. { index in the derefmap }
  76. derefidx : longint;
  77. end;
  78. punitmap = ^tunitmaprec;
  79. tderefmaprec = record
  80. u : tmodule;
  81. { modulename, used during ppu load }
  82. modulename : pshortstring;
  83. end;
  84. pderefmap = ^tderefmaprec;
  85. { tmodule }
  86. tmodule = class(tmodulebase)
  87. private
  88. FImportLibraryList : TFPHashObjectList;
  89. public
  90. do_reload, { force reloading of the unit }
  91. do_compile, { need to compile the sources }
  92. sources_avail, { if all sources are reachable }
  93. interface_compiled, { if the interface section has been parsed/compiled/loaded }
  94. is_dbginfo_written,
  95. is_unit,
  96. in_interface, { processing the implementation part? }
  97. { allow global settings }
  98. in_global : boolean;
  99. { Whether a mode switch is still allowed at this point in the parsing.}
  100. mode_switch_allowed,
  101. { generate pic helper which loads eip in ecx (for leave procedures) }
  102. requires_ecx_pic_helper,
  103. { generate pic helper which loads eip in ebx (for non leave procedures) }
  104. requires_ebx_pic_helper : boolean;
  105. interface_only: boolean; { interface-only macpas unit; flag does not need saving/restoring to ppu }
  106. mainfilepos : tfileposinfo;
  107. recompile_reason : trecompile_reason; { the reason why the unit should be recompiled }
  108. crc,
  109. interface_crc,
  110. indirect_crc : cardinal;
  111. headerflags : cardinal; { the PPU header flags }
  112. longversion : cardinal; { longer version than what fits in the ppu header }
  113. moduleflags : tmoduleflags; { ppu flags that do not need to be known by just reading the ppu header }
  114. islibrary : boolean; { if it is a library (win32 dll) }
  115. IsPackage : boolean;
  116. moduleid : longint;
  117. unitmap : punitmap; { mapping of all used units }
  118. unitmapsize : longint; { number of units in the map }
  119. derefmap : pderefmap; { mapping of all units needed for deref }
  120. derefmapcnt : longint; { number of units in the map }
  121. derefmapsize : longint; { number of units in the map }
  122. derefdataintflen : longint;
  123. derefdata : tdynamicarray;
  124. checkforwarddefs,
  125. deflist,
  126. symlist : TFPObjectList;
  127. ptrdefs : THashSet; { list of pointerdefs created in this module so we can reuse them (not saved/restored) }
  128. arraydefs : THashSet; { list of single-element-arraydefs created in this module so we can reuse them (not saved/restored) }
  129. procaddrdefs : THashSet; { list of procvardefs created when getting the address of a procdef (not saved/restored) }
  130. {$ifdef llvm}
  131. llvmdefs : THashSet; { defs added for llvm-specific reasons (not saved/restored) }
  132. llvmusedsyms : TFPObjectList; { a list of asmsymbols and their defs that need to be added to llvm.used (so they're not removed by llvm optimisation passes nor by the linker) }
  133. llvmcompilerusedsyms : TFPObjectList; { a list of asmsymbols and their defs that need to be added to llvm.compiler.used (so they're not removed by llvm optimisation passes) }
  134. llvminitprocs,
  135. llvmfiniprocs : TFPList;
  136. {$endif llvm}
  137. ansistrdef : tobject; { an ansistring def redefined for the current module }
  138. wpoinfo : tunitwpoinfobase; { whole program optimization-related information that is generated during the current run for this unit }
  139. globalsymtable, { pointer to the global symtable of this unit }
  140. localsymtable : TSymtable;{ pointer to the local symtable of this unit }
  141. globalmacrosymtable, { pointer to the global macro symtable of this unit }
  142. localmacrosymtable : TSymtable;{ pointer to the local macro symtable of this unit }
  143. scanner : TObject; { scanner object used }
  144. procinfo : TObject; { current procedure being compiled }
  145. asmdata : TObject; { Assembler data }
  146. asmprefix : pshortstring; { prefix for the smartlink asmfiles }
  147. publicasmsyms : TFPHashObjectList; { contains the assembler symbols which need to be exported from a package }
  148. externasmsyms : TFPHashObjectList; { contains the assembler symbols which are imported from another unit }
  149. unitimportsyms : tfpobjectlist; { list of symbols that are imported from other units }
  150. debuginfo : TObject;
  151. loaded_from : tmodule;
  152. _exports : tlinkedlist;
  153. dllscannerinputlist : TFPHashList;
  154. resourcefiles,
  155. linkorderedsymbols : TCmdStrList;
  156. linkunitofiles,
  157. linkunitstaticlibs,
  158. linkunitsharedlibs,
  159. linkotherofiles, { objects,libs loaded from the source }
  160. linkothersharedlibs, { using $L or $LINKLIB or import lib (for linux) }
  161. linkotherstaticlibs,
  162. linkotherframeworks : tlinkcontainer;
  163. mainname : pshortstring; { alternate name for "main" procedure }
  164. package : tpackage;
  165. used_units : tlinkedlist;
  166. dependent_units : tlinkedlist;
  167. localunitsearchpath, { local searchpaths }
  168. localobjectsearchpath,
  169. localincludesearchpath,
  170. locallibrarysearchpath,
  171. localframeworksearchpath : TSearchPathList;
  172. moduleoptions: tmoduleoptions;
  173. deprecatedmsg: pshortstring;
  174. { contains a list of types that are extended by helper types; the key is
  175. the full name of the type and the data is a TFPObjectList of
  176. tobjectdef instances (the helper defs) }
  177. extendeddefs: TFPHashObjectList;
  178. { contains a list of the current topmost non-generic symbol for a
  179. typename of which at least one generic exists; the key is the
  180. non-generic typename and the data is a TFPObjectList of tgenericdummyentry
  181. instances whereby the last one is the current top most one }
  182. genericdummysyms: TFPHashObjectList;
  183. { contains a list of specializations for which the method bodies need
  184. to be generated }
  185. pendingspecializations : TFPHashObjectList;
  186. { list of attributes that are used and thus need their construction
  187. functions generated }
  188. used_rtti_attrs: tfpobjectlist;
  189. { this contains a list of units that needs to be waited for until the
  190. unit can be finished (code generated, etc.); this is needed to handle
  191. specializations in circular unit usages correctly }
  192. waitingforunit: tfpobjectlist;
  193. { this contains a list of all units that are waiting for this unit to be
  194. finished }
  195. waitingunits: tfpobjectlist;
  196. finishstate: pointer;
  197. globalstate: pointer;
  198. namespace: pshortstring; { for JVM target: corresponds to Java package name }
  199. { for targets that initialise typed constants via explicit assignments
  200. instead of by generating an initialised data section (holds typed
  201. constant assignments at the module level; does not have to be saved
  202. into the ppu file, because translated into code during compilation)
  203. -- actual type: tnode (but fmodule should not depend on node) }
  204. tcinitcode : tobject;
  205. {create creates a new module which name is stored in 's'. LoadedFrom
  206. points to the module calling it. It is nil for the first compiled
  207. module. This allow inheritence of all path lists. MUST pay attention
  208. to that when creating link.res!!!!(mazen)}
  209. constructor create(LoadedFrom:TModule;const amodulename: string; const afilename:TPathStr;_is_unit:boolean);
  210. destructor destroy;override;
  211. procedure reset;virtual;
  212. procedure adddependency(callermodule:tmodule);
  213. procedure flagdependent(callermodule:tmodule);
  214. procedure addimportedsym(sym:TSymEntry);
  215. function addusedunit(hp:tmodule;inuses:boolean;usym:tunitsym):tused_unit;
  216. procedure updatemaps;
  217. function derefidx_unit(id:longint):longint;
  218. function resolve_unit(id:longint):tmodule;
  219. procedure allunitsused;
  220. procedure end_of_parsing;virtual;
  221. procedure setmodulename(const s:string);
  222. procedure AddExternalImport(const libname,symname,symmangledname:string;OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
  223. procedure add_public_asmsym(sym:TAsmSymbol);
  224. procedure add_public_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
  225. procedure add_extern_asmsym(sym:TAsmSymbol);
  226. procedure add_extern_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
  227. property ImportLibraryList : TFPHashObjectList read FImportLibraryList;
  228. end;
  229. tused_unit = class(tlinkedlistitem)
  230. checksum,
  231. interface_checksum,
  232. indirect_checksum: cardinal;
  233. in_uses,
  234. in_interface : boolean;
  235. u : tmodule;
  236. unitsym : tunitsym;
  237. constructor create(_u : tmodule;intface,inuses:boolean;usym:tunitsym);
  238. procedure check_hints;
  239. end;
  240. tdependent_unit = class(tlinkedlistitem)
  241. u : tmodule;
  242. constructor create(_u : tmodule);
  243. end;
  244. var
  245. main_module : tmodule; { Main module of the program }
  246. current_module : tmodule; { Current module which is compiled or loaded }
  247. compiled_module : tmodule; { Current module which is compiled }
  248. usedunits : tlinkedlist; { Used units for this program }
  249. loaded_units : tlinkedlist; { All loaded units }
  250. unloaded_units : tlinkedlist; { Units removed from loaded_units, to be freed }
  251. SmartLinkOFiles : TCmdStrList; { List of .o files which are generated,
  252. used to delete them after linking }
  253. procedure set_current_module(p:tmodule);
  254. function get_module(moduleindex : longint) : tmodule;
  255. function get_source_file(moduleindex,fileindex : longint) : tinputfile;
  256. procedure addloadedunit(hp:tmodule);
  257. function find_module_from_symtable(st:tsymtable):tmodule;
  258. implementation
  259. uses
  260. SysUtils,globals,
  261. verbose,systems,
  262. scanner,ppu,dbgbase,
  263. procinfo,symdef;
  264. {$ifdef MEMDEBUG}
  265. var
  266. memsymtable : TMemDebug;
  267. {$endif}
  268. {*****************************************************************************
  269. Global Functions
  270. *****************************************************************************}
  271. function find_module_from_symtable(st:tsymtable):tmodule;
  272. var
  273. hp : tmodule;
  274. begin
  275. result:=nil;
  276. hp:=tmodule(loaded_units.first);
  277. while assigned(hp) do
  278. begin
  279. if (hp.moduleid=st.moduleid) then
  280. begin
  281. result:=hp;
  282. exit;
  283. end;
  284. hp:=tmodule(hp.next);
  285. end;
  286. end;
  287. procedure set_current_module(p:tmodule);
  288. begin
  289. { save the state of the scanner }
  290. if assigned(current_scanner) then
  291. current_scanner.tempcloseinputfile;
  292. { set new module }
  293. current_module:=p;
  294. { restore previous module settings }
  295. Fillchar(current_filepos,0,sizeof(current_filepos));
  296. if assigned(current_module) then
  297. begin
  298. current_asmdata:=tasmdata(current_module.asmdata);
  299. current_debuginfo:=tdebuginfo(current_module.debuginfo);
  300. { restore scanner and file positions }
  301. current_scanner:=tscannerfile(current_module.scanner);
  302. if assigned(current_scanner) then
  303. begin
  304. current_scanner.tempopeninputfile;
  305. current_scanner.gettokenpos;
  306. parser_current_file:=current_scanner.inputfile.name;
  307. end
  308. else
  309. begin
  310. current_filepos.moduleindex:=current_module.unit_index;
  311. parser_current_file:='';
  312. end;
  313. end
  314. else
  315. begin
  316. current_asmdata:=nil;
  317. current_scanner:=nil;
  318. current_debuginfo:=nil;
  319. end;
  320. end;
  321. function get_module(moduleindex : longint) : tmodule;
  322. var
  323. hp : tmodule;
  324. begin
  325. result:=nil;
  326. if moduleindex=0 then
  327. exit;
  328. result:=current_module;
  329. if not(assigned(loaded_units)) then
  330. exit;
  331. hp:=tmodule(loaded_units.first);
  332. while assigned(hp) and (hp.unit_index<>moduleindex) do
  333. hp:=tmodule(hp.next);
  334. result:=hp;
  335. end;
  336. function get_source_file(moduleindex,fileindex : longint) : tinputfile;
  337. var
  338. hp : tmodule;
  339. begin
  340. hp:=get_module(moduleindex);
  341. if assigned(hp) then
  342. get_source_file:=hp.sourcefiles.get_file(fileindex)
  343. else
  344. get_source_file:=nil;
  345. end;
  346. procedure addloadedunit(hp:tmodule);
  347. begin
  348. hp.moduleid:=loaded_units.count;
  349. loaded_units.concat(hp);
  350. end;
  351. {****************************************************************************
  352. TLinkContainerItem
  353. ****************************************************************************}
  354. constructor TLinkContainerItem.Create(const s:TPathStr;m:cardinal);
  355. begin
  356. inherited Create;
  357. data:=s;
  358. needlink:=m;
  359. end;
  360. {****************************************************************************
  361. TLinkContainer
  362. ****************************************************************************}
  363. procedure TLinkContainer.add(const s : TPathStr;m:cardinal);
  364. begin
  365. inherited concat(TLinkContainerItem.Create(s,m));
  366. end;
  367. function TLinkContainer.get(var m:cardinal) : TPathStr;
  368. var
  369. p : tlinkcontaineritem;
  370. begin
  371. p:=tlinkcontaineritem(inherited getfirst);
  372. if p=nil then
  373. begin
  374. get:='';
  375. m:=0;
  376. end
  377. else
  378. begin
  379. get:=p.data;
  380. m:=p.needlink;
  381. p.free;
  382. end;
  383. end;
  384. function TLinkContainer.getusemask(mask:cardinal) : TPathStr;
  385. var
  386. p : tlinkcontaineritem;
  387. found : boolean;
  388. begin
  389. found:=false;
  390. repeat
  391. p:=tlinkcontaineritem(inherited getfirst);
  392. if p=nil then
  393. begin
  394. getusemask:='';
  395. exit;
  396. end;
  397. getusemask:=p.data;
  398. found:=(p.needlink and mask)<>0;
  399. p.free;
  400. until found;
  401. end;
  402. function TLinkContainer.find(const s:TPathStr):boolean;
  403. var
  404. newnode : tlinkcontaineritem;
  405. begin
  406. find:=false;
  407. newnode:=tlinkcontaineritem(First);
  408. while assigned(newnode) do
  409. begin
  410. if newnode.data=s then
  411. begin
  412. find:=true;
  413. exit;
  414. end;
  415. newnode:=tlinkcontaineritem(newnode.next);
  416. end;
  417. end;
  418. {****************************************************************************
  419. TUSED_UNIT
  420. ****************************************************************************}
  421. constructor tused_unit.create(_u : tmodule;intface,inuses:boolean;usym:tunitsym);
  422. begin
  423. u:=_u;
  424. in_interface:=intface;
  425. in_uses:=inuses;
  426. unitsym:=usym;
  427. if _u.state=ms_compiled then
  428. begin
  429. checksum:=u.crc;
  430. interface_checksum:=u.interface_crc;
  431. indirect_checksum:=u.indirect_crc;
  432. end
  433. else
  434. begin
  435. checksum:=0;
  436. interface_checksum:=0;
  437. indirect_checksum:=0;
  438. end;
  439. end;
  440. procedure tused_unit.check_hints;
  441. var
  442. uname: pshortstring;
  443. begin
  444. uname:=u.realmodulename;
  445. if mo_hint_deprecated in u.moduleoptions then
  446. if (mo_has_deprecated_msg in u.moduleoptions) and (u.deprecatedmsg <> nil) then
  447. MessagePos2(unitsym.fileinfo,sym_w_deprecated_unit_with_msg,uname^,u.deprecatedmsg^)
  448. else
  449. MessagePos1(unitsym.fileinfo,sym_w_deprecated_unit,uname^);
  450. if mo_hint_experimental in u.moduleoptions then
  451. MessagePos1(unitsym.fileinfo,sym_w_experimental_unit,uname^);
  452. if mo_hint_platform in u.moduleoptions then
  453. MessagePos1(unitsym.fileinfo,sym_w_non_portable_unit,uname^);
  454. if mo_hint_library in u.moduleoptions then
  455. MessagePos1(unitsym.fileinfo,sym_w_library_unit,uname^);
  456. if mo_hint_unimplemented in u.moduleoptions then
  457. MessagePos1(unitsym.fileinfo,sym_w_non_implemented_unit,uname^);
  458. end;
  459. {****************************************************************************
  460. TDENPENDENT_UNIT
  461. ****************************************************************************}
  462. constructor tdependent_unit.create(_u : tmodule);
  463. begin
  464. u:=_u;
  465. end;
  466. {****************************************************************************
  467. TMODULE
  468. ****************************************************************************}
  469. constructor tmodule.create(LoadedFrom:TModule;const amodulename: string; const afilename:TPathStr;_is_unit:boolean);
  470. var
  471. n:string;
  472. fn:TPathStr;
  473. begin
  474. if amodulename='' then
  475. n:=ChangeFileExt(ExtractFileName(afilename),'')
  476. else
  477. n:=amodulename;
  478. if afilename='' then
  479. fn:=amodulename
  480. else
  481. fn:=afilename;
  482. { Programs have the name 'Program' to don't conflict with dup id's }
  483. if _is_unit then
  484. inherited create(amodulename)
  485. else
  486. inherited create('Program');
  487. mainsource:=fn;
  488. { Dos has the famous 8.3 limit :( }
  489. {$ifdef shortasmprefix}
  490. asmprefix:=stringdup(FixFileName('as'));
  491. {$else}
  492. asmprefix:=stringdup(FixFileName(n));
  493. {$endif}
  494. setfilename(fn,true);
  495. localunitsearchpath:=TSearchPathList.Create;
  496. localobjectsearchpath:=TSearchPathList.Create;
  497. localincludesearchpath:=TSearchPathList.Create;
  498. locallibrarysearchpath:=TSearchPathList.Create;
  499. localframeworksearchpath:=TSearchPathList.Create;
  500. used_units:=TLinkedList.Create;
  501. dependent_units:=TLinkedList.Create;
  502. resourcefiles:=TCmdStrList.Create;
  503. linkorderedsymbols:=TCmdStrList.Create;
  504. linkunitofiles:=TLinkContainer.Create;
  505. linkunitstaticlibs:=TLinkContainer.Create;
  506. linkunitsharedlibs:=TLinkContainer.Create;
  507. linkotherofiles:=TLinkContainer.Create;
  508. linkotherstaticlibs:=TLinkContainer.Create;
  509. linkothersharedlibs:=TLinkContainer.Create;
  510. linkotherframeworks:=TLinkContainer.Create;
  511. mainname:=nil;
  512. FImportLibraryList:=TFPHashObjectList.Create(true);
  513. crc:=0;
  514. interface_crc:=0;
  515. indirect_crc:=0;
  516. headerflags:=0;
  517. longversion:=0;
  518. moduleflags:=[];
  519. scanner:=nil;
  520. unitmap:=nil;
  521. unitmapsize:=0;
  522. derefmap:=nil;
  523. derefmapsize:=0;
  524. derefmapcnt:=0;
  525. derefdata:=TDynamicArray.Create(1024);
  526. derefdataintflen:=0;
  527. deflist:=TFPObjectList.Create(false);
  528. symlist:=TFPObjectList.Create(false);
  529. ptrdefs:=THashSet.Create(64,true,false);
  530. arraydefs:=THashSet.Create(64,true,false);
  531. procaddrdefs:=THashSet.Create(64,true,false);
  532. {$ifdef llvm}
  533. llvmdefs:=THashSet.Create(64,true,false);
  534. llvmusedsyms:=TFPObjectList.Create(true);
  535. llvmcompilerusedsyms:=TFPObjectList.Create(true);
  536. llvminitprocs:=TFPList.Create;
  537. llvmfiniprocs:=TFPList.Create;
  538. {$endif llvm}
  539. ansistrdef:=nil;
  540. wpoinfo:=nil;
  541. checkforwarddefs:=TFPObjectList.Create(false);
  542. extendeddefs:=TFPHashObjectList.Create(true);
  543. genericdummysyms:=tfphashobjectlist.create(true);
  544. pendingspecializations:=tfphashobjectlist.create(false);
  545. waitingforunit:=tfpobjectlist.create(false);
  546. waitingunits:=tfpobjectlist.create(false);
  547. used_rtti_attrs:=tfpobjectlist.create(false);
  548. globalsymtable:=nil;
  549. localsymtable:=nil;
  550. globalmacrosymtable:=nil;
  551. localmacrosymtable:=nil;
  552. loaded_from:=LoadedFrom;
  553. do_reload:=false;
  554. do_compile:=false;
  555. sources_avail:=true;
  556. mainfilepos.line:=0;
  557. mainfilepos.column:=0;
  558. mainfilepos.fileindex:=0;
  559. recompile_reason:=rr_unknown;
  560. in_interface:=true;
  561. in_global:=true;
  562. is_unit:=_is_unit;
  563. islibrary:=false;
  564. ispackage:=false;
  565. is_dbginfo_written:=false;
  566. mode_switch_allowed:= true;
  567. moduleoptions:=[];
  568. deprecatedmsg:=nil;
  569. namespace:=nil;
  570. tcinitcode:=nil;
  571. _exports:=TLinkedList.Create;
  572. dllscannerinputlist:=TFPHashList.Create;
  573. asmdata:=casmdata.create(modulename);
  574. unitimportsyms:=TFPObjectList.Create(false);
  575. publicasmsyms:=TFPHashObjectList.Create(true);
  576. externasmsyms:=TFPHashObjectList.Create(true);
  577. InitDebugInfo(self,false);
  578. end;
  579. destructor tmodule.Destroy;
  580. var
  581. i : longint;
  582. current_debuginfo_reset : boolean;
  583. begin
  584. if assigned(unitmap) then
  585. freemem(unitmap);
  586. if assigned(derefmap) then
  587. begin
  588. for i:=0 to derefmapcnt-1 do
  589. stringdispose(derefmap[i].modulename);
  590. freemem(derefmap);
  591. end;
  592. if assigned(_exports) then
  593. _exports.free;
  594. if assigned(dllscannerinputlist) then
  595. dllscannerinputlist.free;
  596. if assigned(scanner) then
  597. begin
  598. { also update current_scanner if it was pointing
  599. to this module }
  600. if current_scanner=tscannerfile(scanner) then
  601. current_scanner:=nil;
  602. tscannerfile(scanner).free;
  603. end;
  604. if assigned(asmdata) then
  605. begin
  606. if current_asmdata=asmdata then
  607. current_asmdata:=nil;
  608. asmdata.free;
  609. end;
  610. if assigned(procinfo) then
  611. begin
  612. if current_procinfo=tprocinfo(procinfo) then
  613. begin
  614. current_procinfo:=nil;
  615. current_structdef:=nil;
  616. current_genericdef:=nil;
  617. current_specializedef:=nil;
  618. end;
  619. { release procinfo tree }
  620. tprocinfo(procinfo).destroy_tree;
  621. end;
  622. DoneDebugInfo(self,current_debuginfo_reset);
  623. used_units.free;
  624. dependent_units.free;
  625. resourcefiles.Free;
  626. linkorderedsymbols.Free;
  627. linkunitofiles.Free;
  628. linkunitstaticlibs.Free;
  629. linkunitsharedlibs.Free;
  630. linkotherofiles.Free;
  631. linkotherstaticlibs.Free;
  632. linkothersharedlibs.Free;
  633. linkotherframeworks.Free;
  634. stringdispose(mainname);
  635. externasmsyms.Free;
  636. publicasmsyms.Free;
  637. unitimportsyms.Free;
  638. FImportLibraryList.Free;
  639. extendeddefs.Free;
  640. genericdummysyms.free;
  641. pendingspecializations.free;
  642. waitingforunit.free;
  643. waitingunits.free;
  644. used_rtti_attrs.free;
  645. stringdispose(asmprefix);
  646. stringdispose(deprecatedmsg);
  647. stringdispose(namespace);
  648. tcinitcode.free;
  649. localunitsearchpath.Free;
  650. localobjectsearchpath.free;
  651. localincludesearchpath.free;
  652. locallibrarysearchpath.free;
  653. localframeworksearchpath.free;
  654. {$ifdef MEMDEBUG}
  655. memsymtable.start;
  656. {$endif}
  657. derefdata.free;
  658. deflist.free;
  659. symlist.free;
  660. ptrdefs.free;
  661. arraydefs.free;
  662. procaddrdefs.free;
  663. {$ifdef llvm}
  664. llvmdefs.free;
  665. llvmusedsyms.free;
  666. llvmcompilerusedsyms.free;
  667. llvminitprocs.free;
  668. llvmfiniprocs.free;
  669. {$endif llvm}
  670. ansistrdef:=nil;
  671. wpoinfo.free;
  672. checkforwarddefs.free;
  673. globalsymtable.free;
  674. localsymtable.free;
  675. globalmacrosymtable.free;
  676. localmacrosymtable.free;
  677. {$ifdef MEMDEBUG}
  678. memsymtable.stop;
  679. {$endif}
  680. inherited Destroy;
  681. end;
  682. procedure tmodule.reset;
  683. var
  684. i : longint;
  685. current_debuginfo_reset : boolean;
  686. begin
  687. if assigned(scanner) then
  688. begin
  689. { also update current_scanner if it was pointing
  690. to this module }
  691. if current_scanner=tscannerfile(scanner) then
  692. current_scanner:=nil;
  693. tscannerfile(scanner).free;
  694. scanner:=nil;
  695. end;
  696. if assigned(procinfo) then
  697. begin
  698. if current_procinfo=tprocinfo(procinfo) then
  699. begin
  700. current_procinfo:=nil;
  701. current_structdef:=nil;
  702. current_genericdef:=nil;
  703. current_specializedef:=nil;
  704. end;
  705. { release procinfo tree }
  706. tprocinfo(procinfo).destroy_tree;
  707. end;
  708. if assigned(asmdata) then
  709. begin
  710. if current_asmdata=asmdata then
  711. current_asmdata:=nil;
  712. asmdata.free;
  713. asmdata:=nil;
  714. end;
  715. DoneDebugInfo(self,current_debuginfo_reset);
  716. globalsymtable.free;
  717. globalsymtable:=nil;
  718. localsymtable.free;
  719. localsymtable:=nil;
  720. globalmacrosymtable.free;
  721. globalmacrosymtable:=nil;
  722. localmacrosymtable.free;
  723. localmacrosymtable:=nil;
  724. deflist.free;
  725. deflist:=TFPObjectList.Create(false);
  726. symlist.free;
  727. symlist:=TFPObjectList.Create(false);
  728. ptrdefs.free;
  729. ptrdefs:=THashSet.Create(64,true,false);
  730. arraydefs.free;
  731. arraydefs:=THashSet.Create(64,true,false);
  732. procaddrdefs.free;
  733. procaddrdefs:=THashSet.Create(64,true,false);
  734. {$ifdef llvm}
  735. llvmdefs.free;
  736. llvmdefs:=THashSet.Create(64,true,false);
  737. llvmusedsyms.free;
  738. llvmusedsyms:=TFPObjectList.Create(true);
  739. llvmcompilerusedsyms.free;
  740. llvmcompilerusedsyms:=TFPObjectList.Create(true);
  741. llvminitprocs.free;
  742. llvminitprocs:=TFPList.Create;
  743. llvmfiniprocs.free;
  744. llvmfiniprocs:=TFPList.Create;
  745. {$endif llvm}
  746. wpoinfo.free;
  747. wpoinfo:=nil;
  748. checkforwarddefs.free;
  749. checkforwarddefs:=TFPObjectList.Create(false);
  750. publicasmsyms.free;
  751. publicasmsyms:=TFPHashObjectList.Create(true);
  752. externasmsyms.free;
  753. externasmsyms:=TFPHashObjectList.Create(true);
  754. unitimportsyms.free;
  755. unitimportsyms:=TFPObjectList.Create(false);
  756. derefdata.free;
  757. derefdata:=TDynamicArray.Create(1024);
  758. if assigned(unitmap) then
  759. begin
  760. freemem(unitmap);
  761. unitmap:=nil;
  762. end;
  763. if assigned(derefmap) then
  764. begin
  765. for i:=0 to derefmapcnt-1 do
  766. stringdispose(derefmap[i].modulename);
  767. freemem(derefmap);
  768. derefmap:=nil;
  769. end;
  770. unitmapsize:=0;
  771. derefmapsize:=0;
  772. derefmapcnt:=0;
  773. derefdataintflen:=0;
  774. sourcefiles.free;
  775. sourcefiles:=tinputfilemanager.create;
  776. asmdata:=casmdata.create(modulename);
  777. InitDebugInfo(self,current_debuginfo_reset);
  778. _exports.free;
  779. _exports:=tlinkedlist.create;
  780. dllscannerinputlist.free;
  781. dllscannerinputlist:=TFPHashList.create;
  782. used_units.free;
  783. used_units:=TLinkedList.Create;
  784. dependent_units.free;
  785. dependent_units:=TLinkedList.Create;
  786. resourcefiles.Free;
  787. resourcefiles:=TCmdStrList.Create;
  788. linkorderedsymbols.Free;
  789. linkorderedsymbols:=TCmdStrList.Create;;
  790. pendingspecializations.free;
  791. pendingspecializations:=tfphashobjectlist.create(false);
  792. if assigned(waitingforunit) and
  793. (waitingforunit.count<>0) then
  794. internalerror(2016070501);
  795. waitingforunit.free;
  796. waitingforunit:=tfpobjectlist.create(false);;
  797. linkunitofiles.Free;
  798. linkunitofiles:=TLinkContainer.Create;
  799. linkunitstaticlibs.Free;
  800. linkunitstaticlibs:=TLinkContainer.Create;
  801. linkunitsharedlibs.Free;
  802. linkunitsharedlibs:=TLinkContainer.Create;
  803. linkotherofiles.Free;
  804. linkotherofiles:=TLinkContainer.Create;
  805. linkotherstaticlibs.Free;
  806. linkotherstaticlibs:=TLinkContainer.Create;
  807. linkothersharedlibs.Free;
  808. linkothersharedlibs:=TLinkContainer.Create;
  809. linkotherframeworks.Free;
  810. linkotherframeworks:=TLinkContainer.Create;
  811. stringdispose(mainname);
  812. FImportLibraryList.Free;
  813. FImportLibraryList:=TFPHashObjectList.Create;
  814. do_compile:=false;
  815. do_reload:=false;
  816. interface_compiled:=false;
  817. in_interface:=true;
  818. in_global:=true;
  819. mode_switch_allowed:=true;
  820. stringdispose(deprecatedmsg);
  821. stringdispose(namespace);
  822. tcinitcode.free;
  823. tcinitcode:=nil;
  824. localunitsearchpath.Free;
  825. localunitsearchpath:=TSearchPathList.Create;
  826. localobjectsearchpath.free;
  827. localobjectsearchpath:=TSearchPathList.Create;
  828. localincludesearchpath.free;
  829. localincludesearchpath:=TSearchPathList.Create;
  830. locallibrarysearchpath.free;
  831. locallibrarysearchpath:=TSearchPathList.Create;
  832. localframeworksearchpath.free;
  833. localframeworksearchpath:=TSearchPathList.Create;
  834. moduleoptions:=[];
  835. is_dbginfo_written:=false;
  836. crc:=0;
  837. interface_crc:=0;
  838. indirect_crc:=0;
  839. headerflags:=0;
  840. longversion:=0;
  841. moduleflags:=[];
  842. mainfilepos.line:=0;
  843. mainfilepos.column:=0;
  844. mainfilepos.fileindex:=0;
  845. recompile_reason:=rr_unknown;
  846. {
  847. The following fields should not
  848. be reset:
  849. mainsource
  850. state
  851. loaded_from
  852. sources_avail
  853. }
  854. end;
  855. procedure tmodule.adddependency(callermodule:tmodule);
  856. begin
  857. { This is not needed for programs }
  858. if not callermodule.is_unit then
  859. exit;
  860. Message2(unit_u_add_depend_to,callermodule.modulename^,modulename^);
  861. dependent_units.concat(tdependent_unit.create(callermodule));
  862. end;
  863. procedure tmodule.flagdependent(callermodule:tmodule);
  864. var
  865. pm : tdependent_unit;
  866. begin
  867. { flag all units that depend on this unit for reloading }
  868. pm:=tdependent_unit(current_module.dependent_units.first);
  869. while assigned(pm) do
  870. begin
  871. { We do not have to reload the unit that wants to load
  872. this unit, unless this unit is already compiled during
  873. the loading }
  874. if (pm.u=callermodule) and
  875. (pm.u.state<>ms_compiled) then
  876. Message1(unit_u_no_reload_is_caller,pm.u.modulename^)
  877. else
  878. if pm.u.state=ms_second_compile then
  879. Message1(unit_u_no_reload_in_second_compile,pm.u.modulename^)
  880. else
  881. begin
  882. pm.u.do_reload:=true;
  883. Message1(unit_u_flag_for_reload,pm.u.modulename^);
  884. end;
  885. pm:=tdependent_unit(pm.next);
  886. end;
  887. end;
  888. procedure tmodule.addimportedsym(sym:TSymEntry);
  889. begin
  890. if unitimportsyms.IndexOf(sym)<0 then
  891. unitimportsyms.Add(sym);
  892. end;
  893. function tmodule.addusedunit(hp:tmodule;inuses:boolean;usym:tunitsym):tused_unit;
  894. var
  895. pu : tused_unit;
  896. begin
  897. pu:=tused_unit.create(hp,in_interface,inuses,usym);
  898. used_units.concat(pu);
  899. addusedunit:=pu;
  900. end;
  901. procedure tmodule.updatemaps;
  902. var
  903. oldmapsize : longint;
  904. hp : tmodule;
  905. i : longint;
  906. begin
  907. { Extend unitmap }
  908. oldmapsize:=unitmapsize;
  909. unitmapsize:=loaded_units.count;
  910. reallocmem(unitmap,unitmapsize*sizeof(tunitmaprec));
  911. fillchar(unitmap[oldmapsize],(unitmapsize-oldmapsize)*sizeof(tunitmaprec),0);
  912. { Extend Derefmap }
  913. oldmapsize:=derefmapsize;
  914. derefmapsize:=loaded_units.count;
  915. reallocmem(derefmap,derefmapsize*sizeof(tderefmaprec));
  916. fillchar(derefmap[oldmapsize],(derefmapsize-oldmapsize)*sizeof(tderefmaprec),0);
  917. { Add all units to unitmap }
  918. hp:=tmodule(loaded_units.first);
  919. i:=0;
  920. while assigned(hp) do
  921. begin
  922. if hp.moduleid>=unitmapsize then
  923. internalerror(200501151);
  924. { Verify old entries }
  925. if (i<oldmapsize) then
  926. begin
  927. if (hp.moduleid<>i) or
  928. (unitmap[hp.moduleid].u<>hp) then
  929. internalerror(200501156);
  930. end
  931. else
  932. begin
  933. unitmap[hp.moduleid].u:=hp;
  934. unitmap[hp.moduleid].derefidx:=-1;
  935. end;
  936. inc(i);
  937. hp:=tmodule(hp.next);
  938. end;
  939. end;
  940. function tmodule.derefidx_unit(id:longint):longint;
  941. begin
  942. if id>=unitmapsize then
  943. internalerror(2005011511);
  944. if unitmap[id].derefidx=-1 then
  945. begin
  946. unitmap[id].derefidx:=derefmapcnt;
  947. inc(derefmapcnt);
  948. derefmap[unitmap[id].derefidx].u:=unitmap[id].u;
  949. end;
  950. if unitmap[id].derefidx>=derefmapsize then
  951. internalerror(2005011514);
  952. result:=unitmap[id].derefidx;
  953. end;
  954. function tmodule.resolve_unit(id:longint):tmodule;
  955. var
  956. hp : tmodule;
  957. begin
  958. if id>=derefmapsize then
  959. internalerror(200306231);
  960. result:=derefmap[id].u;
  961. if not assigned(result) then
  962. begin
  963. if not assigned(derefmap[id].modulename) or
  964. (derefmap[id].modulename^='') then
  965. internalerror(200501159);
  966. hp:=tmodule(loaded_units.first);
  967. while assigned(hp) do
  968. begin
  969. { only check for units. The main program is also
  970. as a unit in the loaded_units list. We simply need
  971. to ignore this entry (PFV) }
  972. if hp.is_unit and
  973. (hp.modulename^=derefmap[id].modulename^) then
  974. break;
  975. hp:=tmodule(hp.next);
  976. end;
  977. if not assigned(hp) then
  978. internalerror(2005011510);
  979. derefmap[id].u:=hp;
  980. result:=hp;
  981. end;
  982. end;
  983. procedure tmodule.allunitsused;
  984. var
  985. pu : tused_unit;
  986. begin
  987. pu:=tused_unit(used_units.first);
  988. while assigned(pu) do
  989. begin
  990. if assigned(pu.u.globalsymtable) then
  991. begin
  992. if unitmap[pu.u.moduleid].u<>pu.u then
  993. internalerror(200501157);
  994. { Give a note when the unit is not referenced, skip
  995. this is for units with an initialization/finalization }
  996. if (unitmap[pu.u.moduleid].refs=0) and
  997. pu.in_uses and
  998. ((pu.u.moduleflags * [mf_init,mf_finalize])=[]) then
  999. CGMessagePos2(pu.unitsym.fileinfo,sym_n_unit_not_used,pu.u.realmodulename^,realmodulename^);
  1000. end;
  1001. pu:=tused_unit(pu.next);
  1002. end;
  1003. end;
  1004. procedure tmodule.end_of_parsing;
  1005. begin
  1006. { free asmdata }
  1007. if assigned(asmdata) then
  1008. begin
  1009. asmdata.free;
  1010. asmdata:=nil;
  1011. end;
  1012. { free scanner }
  1013. if assigned(scanner) then
  1014. begin
  1015. if current_scanner=tscannerfile(scanner) then
  1016. current_scanner:=nil;
  1017. tscannerfile(scanner).free;
  1018. scanner:=nil;
  1019. end;
  1020. { free symtable stack }
  1021. if assigned(symtablestack) then
  1022. begin
  1023. symtablestack.free;
  1024. symtablestack:=nil;
  1025. end;
  1026. if assigned(macrosymtablestack) then
  1027. begin
  1028. macrosymtablestack.free;
  1029. macrosymtablestack:=nil;
  1030. end;
  1031. waitingforunit.free;
  1032. waitingforunit:=nil;
  1033. localmacrosymtable.free;
  1034. localmacrosymtable:=nil;
  1035. ptrdefs.free;
  1036. ptrdefs:=nil;
  1037. arraydefs.free;
  1038. arraydefs:=nil;
  1039. procaddrdefs.free;
  1040. procaddrdefs:=nil;
  1041. {$ifdef llvm}
  1042. llvmdefs.free;
  1043. llvmdefs:=nil;
  1044. {$endif llvm}
  1045. checkforwarddefs.free;
  1046. checkforwarddefs:=nil;
  1047. tcinitcode.free;
  1048. tcinitcode:=nil;
  1049. localunitsearchpath.free;
  1050. localunitsearchpath:=nil;
  1051. localobjectsearchpath.free;
  1052. localobjectsearchpath:=nil;
  1053. localincludesearchpath.free;
  1054. localincludesearchpath:=nil;
  1055. locallibrarysearchpath.free;
  1056. locallibrarysearchpath:=nil;
  1057. localframeworksearchpath.free;
  1058. localframeworksearchpath:=nil;
  1059. end;
  1060. procedure tmodule.setmodulename(const s:string);
  1061. begin
  1062. stringdispose(modulename);
  1063. stringdispose(realmodulename);
  1064. modulename:=stringdup(upper(s));
  1065. realmodulename:=stringdup(s);
  1066. { also update asmlibrary names }
  1067. current_asmdata.name:=modulename;
  1068. end;
  1069. procedure TModule.AddExternalImport(const libname,symname,symmangledname:string;
  1070. OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
  1071. var
  1072. ImportLibrary,OtherIL : TImportLibrary;
  1073. ImportSymbol : TImportSymbol;
  1074. i : longint;
  1075. begin
  1076. ImportLibrary:=TImportLibrary(ImportLibraryList.Find(libname));
  1077. if not assigned(ImportLibrary) then
  1078. ImportLibrary:=TImportLibrary.Create(ImportLibraryList,libname);
  1079. ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList.Find(symname));
  1080. if not assigned(ImportSymbol) then
  1081. begin
  1082. { Check that the same name does not exist in another library }
  1083. { If it does and the same mangled name is used, issue a warning }
  1084. if ImportLibraryList.Count>1 then
  1085. for i:=0 To ImportLibraryList.Count-1 do
  1086. begin
  1087. OtherIL:=TImportLibrary(ImportLibraryList.Items[i]);
  1088. ImportSymbol:=TImportSymbol(OtherIL.ImportSymbolList.Find(symname));
  1089. if assigned(ImportSymbol) then
  1090. begin
  1091. if ImportSymbol.MangledName=symmangledname then
  1092. begin
  1093. CGMessage3(sym_w_library_overload,symname,libname,OtherIL.Name);
  1094. break;
  1095. end;
  1096. end;
  1097. end;
  1098. if not ImportByOrdinalOnly then
  1099. { negative ordinal number indicates import by name with ordinal number as hint }
  1100. OrdNr:=-OrdNr;
  1101. ImportSymbol:=TImportSymbol.Create(ImportLibrary.ImportSymbolList,
  1102. symname,symmangledname,OrdNr,isvar);
  1103. end;
  1104. end;
  1105. procedure tmodule.add_public_asmsym(sym:TAsmSymbol);
  1106. begin
  1107. add_public_asmsym(sym.name,sym.bind,sym.typ);
  1108. end;
  1109. procedure tmodule.add_public_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
  1110. var
  1111. sym : tasmsymbol;
  1112. begin
  1113. { ToDo: check for AB_GLOBAL, AB_EXTERNAL? }
  1114. sym:=tasmsymbol(publicasmsyms.find(name));
  1115. if assigned(sym) then
  1116. begin
  1117. if (sym.bind<>bind) or (sym.typ<>typ) then
  1118. internalerror(2016070101);
  1119. exit;
  1120. end;
  1121. tasmsymbol.create(publicasmsyms,name,bind,typ);
  1122. end;
  1123. procedure tmodule.add_extern_asmsym(sym:TAsmSymbol);
  1124. begin
  1125. add_extern_asmsym(sym.name,sym.bind,sym.typ);
  1126. end;
  1127. procedure tmodule.add_extern_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
  1128. var
  1129. sym : tasmsymbol;
  1130. begin
  1131. { ToDo: check for AB_EXTERNAL? }
  1132. sym:=tasmsymbol(externasmsyms.find(name));
  1133. if assigned(sym) then
  1134. begin
  1135. if (sym.bind<>bind) or (sym.typ<>typ) then
  1136. internalerror(2016070102);
  1137. exit;
  1138. end;
  1139. tasmsymbol.create(externasmsyms,name,bind,typ);
  1140. end;
  1141. initialization
  1142. {$ifdef MEMDEBUG}
  1143. memsymtable:=TMemDebug.create('Symtables');
  1144. memsymtable.stop;
  1145. {$endif MEMDEBUG}
  1146. finalization
  1147. {$ifdef MEMDEBUG}
  1148. memsymtable.free;
  1149. {$endif MEMDEBUG}
  1150. end.