fmodule.pas 43 KB

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