fmodule.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the first loading and searching of the modules
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit fmodule;
  19. {$i fpcdefs.inc}
  20. {$ifdef go32v2}
  21. {$define shortasmprefix}
  22. {$endif}
  23. {$ifdef watcom}
  24. {$define shortasmprefix}
  25. {$endif}
  26. {$ifdef tos}
  27. {$define shortasmprefix}
  28. {$endif}
  29. {$ifdef OS2}
  30. { Allthough OS/2 supports long filenames I play it safe and
  31. use 8.3 filenames, because this allows the compiler to run
  32. on a FAT partition. (DM) }
  33. {$define shortasmprefix}
  34. {$endif}
  35. interface
  36. uses
  37. cutils,cclasses,
  38. globals,finput,
  39. symbase,symsym,aasmbase;
  40. type
  41. trecompile_reason = (rr_unknown,
  42. rr_noppu,rr_sourcenewer,rr_build,rr_crcchanged
  43. );
  44. TExternalsItem=class(TLinkedListItem)
  45. public
  46. found : longbool;
  47. data : pstring;
  48. constructor Create(const s:string);
  49. Destructor Destroy;override;
  50. end;
  51. tlinkcontaineritem=class(tlinkedlistitem)
  52. public
  53. data : pstring;
  54. needlink : cardinal;
  55. constructor Create(const s:string;m:cardinal);
  56. destructor Destroy;override;
  57. end;
  58. tlinkcontainer=class(tlinkedlist)
  59. procedure add(const s : string;m:cardinal);
  60. function get(var m:cardinal) : string;
  61. function getusemask(mask:cardinal) : string;
  62. function find(const s:string):boolean;
  63. end;
  64. tmodule = class;
  65. tused_unit = class;
  66. tunitmaprec = record
  67. u : tmodule;
  68. unitsym : tunitsym;
  69. end;
  70. punitmap = ^tunitmaprec;
  71. tmodule = class(tmodulebase)
  72. do_reload, { force reloading of the unit }
  73. do_compile, { need to compile the sources }
  74. sources_avail, { if all sources are reachable }
  75. interface_compiled, { if the interface section has been parsed/compiled/loaded }
  76. is_stab_written,
  77. is_reset,
  78. is_unit,
  79. in_interface, { processing the implementation part? }
  80. in_global : boolean; { allow global settings }
  81. mode_switch_allowed : boolean; { Whether a mode switch is still allowed at this point in the parsing.}
  82. mainfilepos : tfileposinfo;
  83. recompile_reason : trecompile_reason; { the reason why the unit should be recompiled }
  84. crc,
  85. interface_crc : cardinal;
  86. flags : cardinal; { the PPU flags }
  87. islibrary : boolean; { if it is a library (win32 dll) }
  88. map : punitmap; { mapping of all used units }
  89. mapsize : longint; { number of units in the map }
  90. derefdataintflen : longint;
  91. derefdata : tdynamicarray;
  92. globalsymtable, { pointer to the global symtable of this unit }
  93. localsymtable : tsymtable;{ pointer to the local symtable of this unit }
  94. globalmacrosymtable, { pointer to the global macro symtable of this unit }
  95. localmacrosymtable : tsymtable;{ pointer to the local macro symtable of this unit }
  96. scanner : pointer; { scanner object used }
  97. procinfo : pointer; { current procedure being compiled }
  98. loaded_from : tmodule;
  99. uses_imports : boolean; { Set if the module imports from DLL's.}
  100. imports : tlinkedlist;
  101. _exports : tlinkedlist;
  102. externals : tlinkedlist; {Only for DLL scanners by using Unix-style $LINKLIB }
  103. resourcefiles : tstringlist;
  104. linkunitofiles,
  105. linkunitstaticlibs,
  106. linkunitsharedlibs,
  107. linkotherofiles, { objects,libs loaded from the source }
  108. linkothersharedlibs, { using $L or $LINKLIB or import lib (for linux) }
  109. linkotherstaticlibs : tlinkcontainer;
  110. used_units : tlinkedlist;
  111. dependent_units : tlinkedlist;
  112. localunitsearchpath, { local searchpaths }
  113. localobjectsearchpath,
  114. localincludesearchpath,
  115. locallibrarysearchpath : TSearchPathList;
  116. asmprefix : pstring; { prefix for the smartlink asmfiles }
  117. librarydata : tasmlibrarydata; { librarydata for this module }
  118. {create creates a new module which name is stored in 's'. LoadedFrom
  119. points to the module calling it. It is nil for the first compiled
  120. module. This allow inheritence of all path lists. MUST pay attention
  121. to that when creating link.res!!!!(mazen)}
  122. constructor create(LoadedFrom:TModule;const s:string;_is_unit:boolean);
  123. destructor destroy;override;
  124. procedure reset;virtual;
  125. procedure adddependency(callermodule:tmodule);
  126. procedure flagdependent(callermodule:tmodule);
  127. function addusedunit(hp:tmodule;inuses:boolean;usym:tunitsym):tused_unit;
  128. procedure numberunits;
  129. procedure allunitsused;
  130. procedure setmodulename(const s:string);
  131. end;
  132. tused_unit = class(tlinkedlistitem)
  133. checksum,
  134. interface_checksum : cardinal;
  135. in_uses,
  136. in_interface : boolean;
  137. u : tmodule;
  138. unitsym : tunitsym;
  139. constructor create(_u : tmodule;intface,inuses:boolean;usym:tunitsym);
  140. end;
  141. tdependent_unit = class(tlinkedlistitem)
  142. u : tmodule;
  143. constructor create(_u : tmodule);
  144. end;
  145. var
  146. main_module : tmodule; { Main module of the program }
  147. current_module : tmodule; { Current module which is compiled or loaded }
  148. compiled_module : tmodule; { Current module which is compiled }
  149. usedunits : tlinkedlist; { Used units for this program }
  150. loaded_units : tlinkedlist; { All loaded units }
  151. SmartLinkOFiles : TStringList; { List of .o files which are generated,
  152. used to delete them after linking }
  153. function get_source_file(moduleindex,fileindex : longint) : tinputfile;
  154. implementation
  155. uses
  156. {$IFDEF USE_SYSUTILS}
  157. SysUtils,
  158. GlobType,
  159. {$ELSE USE_SYSUTILS}
  160. dos,
  161. {$ENDIF USE_SYSUTILS}
  162. verbose,systems,
  163. scanner,
  164. procinfo;
  165. {*****************************************************************************
  166. Global Functions
  167. *****************************************************************************}
  168. function get_source_file(moduleindex,fileindex : longint) : tinputfile;
  169. var
  170. hp : tmodule;
  171. begin
  172. hp:=tmodule(loaded_units.first);
  173. while assigned(hp) and (hp.unit_index<>moduleindex) do
  174. hp:=tmodule(hp.next);
  175. if assigned(hp) then
  176. get_source_file:=hp.sourcefiles.get_file(fileindex)
  177. else
  178. get_source_file:=nil;
  179. end;
  180. {****************************************************************************
  181. TLinkContainerItem
  182. ****************************************************************************}
  183. constructor TLinkContainerItem.Create(const s:string;m:cardinal);
  184. begin
  185. inherited Create;
  186. data:=stringdup(s);
  187. needlink:=m;
  188. end;
  189. destructor TLinkContainerItem.Destroy;
  190. begin
  191. stringdispose(data);
  192. end;
  193. {****************************************************************************
  194. TLinkContainer
  195. ****************************************************************************}
  196. procedure TLinkContainer.add(const s : string;m:cardinal);
  197. begin
  198. inherited concat(TLinkContainerItem.Create(s,m));
  199. end;
  200. function TLinkContainer.get(var m:cardinal) : string;
  201. var
  202. p : tlinkcontaineritem;
  203. begin
  204. p:=tlinkcontaineritem(inherited getfirst);
  205. if p=nil then
  206. begin
  207. get:='';
  208. m:=0;
  209. end
  210. else
  211. begin
  212. get:=p.data^;
  213. m:=p.needlink;
  214. p.free;
  215. end;
  216. end;
  217. function TLinkContainer.getusemask(mask:cardinal) : string;
  218. var
  219. p : tlinkcontaineritem;
  220. found : boolean;
  221. begin
  222. found:=false;
  223. repeat
  224. p:=tlinkcontaineritem(inherited getfirst);
  225. if p=nil then
  226. begin
  227. getusemask:='';
  228. exit;
  229. end;
  230. getusemask:=p.data^;
  231. found:=(p.needlink and mask)<>0;
  232. p.free;
  233. until found;
  234. end;
  235. function TLinkContainer.find(const s:string):boolean;
  236. var
  237. newnode : tlinkcontaineritem;
  238. begin
  239. find:=false;
  240. newnode:=tlinkcontaineritem(First);
  241. while assigned(newnode) do
  242. begin
  243. if newnode.data^=s then
  244. begin
  245. find:=true;
  246. exit;
  247. end;
  248. newnode:=tlinkcontaineritem(newnode.next);
  249. end;
  250. end;
  251. {****************************************************************************
  252. TExternalsItem
  253. ****************************************************************************}
  254. constructor tExternalsItem.Create(const s:string);
  255. begin
  256. inherited Create;
  257. found:=false;
  258. data:=stringdup(s);
  259. end;
  260. destructor tExternalsItem.Destroy;
  261. begin
  262. stringdispose(data);
  263. inherited;
  264. end;
  265. {****************************************************************************
  266. TUSED_UNIT
  267. ****************************************************************************}
  268. constructor tused_unit.create(_u : tmodule;intface,inuses:boolean;usym:tunitsym);
  269. begin
  270. u:=_u;
  271. in_interface:=intface;
  272. in_uses:=inuses;
  273. unitsym:=usym;
  274. if _u.state=ms_compiled then
  275. begin
  276. checksum:=u.crc;
  277. interface_checksum:=u.interface_crc;
  278. end
  279. else
  280. begin
  281. checksum:=0;
  282. interface_checksum:=0;
  283. end;
  284. end;
  285. {****************************************************************************
  286. TDENPENDENT_UNIT
  287. ****************************************************************************}
  288. constructor tdependent_unit.create(_u : tmodule);
  289. begin
  290. u:=_u;
  291. end;
  292. {****************************************************************************
  293. TMODULE
  294. ****************************************************************************}
  295. constructor tmodule.create(LoadedFrom:TModule;const s:string;_is_unit:boolean);
  296. var
  297. p : dirstr;
  298. n : namestr;
  299. e : extstr;
  300. begin
  301. {$IFDEF USE_SYSUTILS}
  302. p := SplitPath(s);
  303. n := SplitName(s);
  304. e := SplitExtension(s);
  305. {$ELSE USE_SYSUTILS}
  306. FSplit(s,p,n,e);
  307. {$ENDIF USE_SYSUTILS}
  308. { Programs have the name 'Program' to don't conflict with dup id's }
  309. if _is_unit then
  310. inherited create(n)
  311. else
  312. inherited create('Program');
  313. mainsource:=stringdup(s);
  314. { Dos has the famous 8.3 limit :( }
  315. {$ifdef shortasmprefix}
  316. asmprefix:=stringdup(FixFileName('as'));
  317. {$else}
  318. asmprefix:=stringdup(FixFileName(n));
  319. {$endif}
  320. setfilename(p+n,true);
  321. localunitsearchpath:=TSearchPathList.Create;
  322. localobjectsearchpath:=TSearchPathList.Create;
  323. localincludesearchpath:=TSearchPathList.Create;
  324. locallibrarysearchpath:=TSearchPathList.Create;
  325. used_units:=TLinkedList.Create;
  326. dependent_units:=TLinkedList.Create;
  327. resourcefiles:=TStringList.Create;
  328. linkunitofiles:=TLinkContainer.Create;
  329. linkunitstaticlibs:=TLinkContainer.Create;
  330. linkunitsharedlibs:=TLinkContainer.Create;
  331. linkotherofiles:=TLinkContainer.Create;
  332. linkotherstaticlibs:=TLinkContainer.Create;
  333. linkothersharedlibs:=TLinkContainer.Create;
  334. crc:=0;
  335. interface_crc:=0;
  336. flags:=0;
  337. scanner:=nil;
  338. map:=nil;
  339. mapsize:=0;
  340. derefdata:=TDynamicArray.Create(1024);
  341. derefdataintflen:=0;
  342. globalsymtable:=nil;
  343. localsymtable:=nil;
  344. globalmacrosymtable:=nil;
  345. localmacrosymtable:=nil;
  346. loaded_from:=LoadedFrom;
  347. do_reload:=false;
  348. do_compile:=false;
  349. sources_avail:=true;
  350. mainfilepos.line:=0;
  351. mainfilepos.column:=0;
  352. mainfilepos.fileindex:=0;
  353. recompile_reason:=rr_unknown;
  354. in_interface:=true;
  355. in_global:=true;
  356. is_unit:=_is_unit;
  357. islibrary:=false;
  358. is_stab_written:=false;
  359. is_reset:=false;
  360. mode_switch_allowed:= true;
  361. uses_imports:=false;
  362. imports:=TLinkedList.Create;
  363. _exports:=TLinkedList.Create;
  364. externals:=TLinkedList.Create;
  365. librarydata:=tasmlibrarydata.create(realmodulename^);
  366. end;
  367. destructor tmodule.Destroy;
  368. var
  369. {$ifdef MEMDEBUG}
  370. d : tmemdebug;
  371. {$endif}
  372. hpi : tprocinfo;
  373. begin
  374. dispose(map);
  375. if assigned(imports) then
  376. imports.free;
  377. if assigned(_exports) then
  378. _exports.free;
  379. if assigned(externals) then
  380. externals.free;
  381. if assigned(scanner) then
  382. begin
  383. { also update current_scanner if it was pointing
  384. to this module }
  385. if current_scanner=tscannerfile(scanner) then
  386. current_scanner:=nil;
  387. tscannerfile(scanner).free;
  388. end;
  389. if assigned(procinfo) then
  390. begin
  391. if current_procinfo=tprocinfo(procinfo) then
  392. current_procinfo:=nil;
  393. { release procinfo tree }
  394. while assigned(procinfo) do
  395. begin
  396. hpi:=tprocinfo(procinfo).parent;
  397. tprocinfo(procinfo).free;
  398. procinfo:=hpi;
  399. end;
  400. end;
  401. used_units.free;
  402. dependent_units.free;
  403. resourcefiles.Free;
  404. linkunitofiles.Free;
  405. linkunitstaticlibs.Free;
  406. linkunitsharedlibs.Free;
  407. linkotherofiles.Free;
  408. linkotherstaticlibs.Free;
  409. linkothersharedlibs.Free;
  410. stringdispose(objfilename);
  411. stringdispose(newfilename);
  412. stringdispose(ppufilename);
  413. stringdispose(staticlibfilename);
  414. stringdispose(sharedlibfilename);
  415. stringdispose(exefilename);
  416. stringdispose(outputpath);
  417. stringdispose(path);
  418. stringdispose(realmodulename);
  419. stringdispose(mainsource);
  420. stringdispose(asmprefix);
  421. localunitsearchpath.Free;
  422. localobjectsearchpath.free;
  423. localincludesearchpath.free;
  424. locallibrarysearchpath.free;
  425. {$ifdef MEMDEBUG}
  426. d:=tmemdebug.create(modulename^+' - symtable');
  427. {$endif}
  428. derefdata.free;
  429. if assigned(globalsymtable) then
  430. globalsymtable.free;
  431. if assigned(localsymtable) then
  432. localsymtable.free;
  433. if assigned(globalmacrosymtable) then
  434. globalmacrosymtable.free;
  435. if assigned(localmacrosymtable) then
  436. localmacrosymtable.free;
  437. {$ifdef MEMDEBUG}
  438. d.free;
  439. {$endif}
  440. {$ifdef MEMDEBUG}
  441. d:=tmemdebug.create(modulename^+' - librarydata');
  442. {$endif}
  443. librarydata.free;
  444. {$ifdef MEMDEBUG}
  445. d.free;
  446. {$endif}
  447. stringdispose(modulename);
  448. inherited Destroy;
  449. end;
  450. procedure tmodule.reset;
  451. var
  452. hpi : tprocinfo;
  453. begin
  454. if assigned(scanner) then
  455. begin
  456. { also update current_scanner if it was pointing
  457. to this module }
  458. if current_scanner=tscannerfile(scanner) then
  459. current_scanner:=nil;
  460. tscannerfile(scanner).free;
  461. scanner:=nil;
  462. end;
  463. if assigned(procinfo) then
  464. begin
  465. if current_procinfo=tprocinfo(procinfo) then
  466. current_procinfo:=nil;
  467. { release procinfo tree }
  468. while assigned(procinfo) do
  469. begin
  470. hpi:=tprocinfo(procinfo).parent;
  471. tprocinfo(procinfo).free;
  472. procinfo:=hpi;
  473. end;
  474. end;
  475. if assigned(globalsymtable) then
  476. begin
  477. globalsymtable.free;
  478. globalsymtable:=nil;
  479. end;
  480. if assigned(localsymtable) then
  481. begin
  482. localsymtable.free;
  483. localsymtable:=nil;
  484. end;
  485. if assigned(globalmacrosymtable) then
  486. begin
  487. globalmacrosymtable.free;
  488. globalmacrosymtable:=nil;
  489. end;
  490. if assigned(localmacrosymtable) then
  491. begin
  492. localmacrosymtable.free;
  493. localmacrosymtable:=nil;
  494. end;
  495. derefdata.free;
  496. derefdata:=TDynamicArray.Create(1024);
  497. if assigned(map) then
  498. begin
  499. freemem(map);
  500. map:=nil;
  501. end;
  502. derefdataintflen:=0;
  503. mapsize:=0;
  504. sourcefiles.free;
  505. sourcefiles:=tinputfilemanager.create;
  506. librarydata.free;
  507. librarydata:=tasmlibrarydata.create(realmodulename^);
  508. imports.free;
  509. imports:=tlinkedlist.create;
  510. _exports.free;
  511. _exports:=tlinkedlist.create;
  512. externals.free;
  513. externals:=tlinkedlist.create;
  514. used_units.free;
  515. used_units:=TLinkedList.Create;
  516. dependent_units.free;
  517. dependent_units:=TLinkedList.Create;
  518. resourcefiles.Free;
  519. resourcefiles:=TStringList.Create;
  520. linkunitofiles.Free;
  521. linkunitofiles:=TLinkContainer.Create;
  522. linkunitstaticlibs.Free;
  523. linkunitstaticlibs:=TLinkContainer.Create;
  524. linkunitsharedlibs.Free;
  525. linkunitsharedlibs:=TLinkContainer.Create;
  526. linkotherofiles.Free;
  527. linkotherofiles:=TLinkContainer.Create;
  528. linkotherstaticlibs.Free;
  529. linkotherstaticlibs:=TLinkContainer.Create;
  530. linkothersharedlibs.Free;
  531. linkothersharedlibs:=TLinkContainer.Create;
  532. uses_imports:=false;
  533. do_compile:=false;
  534. do_reload:=false;
  535. interface_compiled:=false;
  536. in_interface:=true;
  537. in_global:=true;
  538. mode_switch_allowed:=true;
  539. is_stab_written:=false;
  540. is_reset:=false;
  541. crc:=0;
  542. interface_crc:=0;
  543. flags:=0;
  544. mainfilepos.line:=0;
  545. mainfilepos.column:=0;
  546. mainfilepos.fileindex:=0;
  547. recompile_reason:=rr_unknown;
  548. {
  549. The following fields should not
  550. be reset:
  551. mainsource
  552. state
  553. loaded_from
  554. sources_avail
  555. }
  556. end;
  557. procedure tmodule.adddependency(callermodule:tmodule);
  558. begin
  559. { This is not needed for programs }
  560. if not callermodule.is_unit then
  561. exit;
  562. Message2(unit_u_add_depend_to,callermodule.modulename^,modulename^);
  563. dependent_units.concat(tdependent_unit.create(callermodule));
  564. end;
  565. procedure tmodule.flagdependent(callermodule:tmodule);
  566. var
  567. pm : tdependent_unit;
  568. begin
  569. { flag all units that depend on this unit for reloading }
  570. pm:=tdependent_unit(current_module.dependent_units.first);
  571. while assigned(pm) do
  572. begin
  573. { We do not have to reload the unit that wants to load
  574. this unit, unless this unit is already compiled during
  575. the loading }
  576. if (pm.u=callermodule) and
  577. (pm.u.state<>ms_compiled) then
  578. Message1(unit_u_no_reload_is_caller,pm.u.modulename^)
  579. else
  580. if pm.u.state=ms_second_compile then
  581. Message1(unit_u_no_reload_in_second_compile,pm.u.modulename^)
  582. else
  583. begin
  584. pm.u.do_reload:=true;
  585. Message1(unit_u_flag_for_reload,pm.u.modulename^);
  586. end;
  587. pm:=tdependent_unit(pm.next);
  588. end;
  589. end;
  590. function tmodule.addusedunit(hp:tmodule;inuses:boolean;usym:tunitsym):tused_unit;
  591. var
  592. pu : tused_unit;
  593. begin
  594. pu:=tused_unit.create(hp,in_interface,inuses,usym);
  595. used_units.concat(pu);
  596. addusedunit:=pu;
  597. end;
  598. procedure tmodule.numberunits;
  599. var
  600. pu : tused_unit;
  601. hp : tmodule;
  602. i : integer;
  603. begin
  604. { Reset all numbers to -1 }
  605. hp:=tmodule(loaded_units.first);
  606. while assigned(hp) do
  607. begin
  608. if assigned(hp.globalsymtable) then
  609. hp.globalsymtable.unitid:=$ffff;
  610. hp:=tmodule(hp.next);
  611. end;
  612. { Allocate map }
  613. mapsize:=used_units.count+1;
  614. reallocmem(map,mapsize*sizeof(tunitmaprec));
  615. { Our own symtable gets unitid 0, for a program there is
  616. no globalsymtable }
  617. if assigned(globalsymtable) then
  618. globalsymtable.unitid:=0;
  619. map[0].u:=self;
  620. map[0].unitsym:=nil;
  621. { number units and map }
  622. i:=1;
  623. pu:=tused_unit(used_units.first);
  624. while assigned(pu) do
  625. begin
  626. if assigned(pu.u.globalsymtable) then
  627. begin
  628. tsymtable(pu.u.globalsymtable).unitid:=i;
  629. map[i].u:=pu.u;
  630. map[i].unitsym:=pu.unitsym;
  631. inc(i);
  632. end;
  633. pu:=tused_unit(pu.next);
  634. end;
  635. end;
  636. procedure tmodule.allunitsused;
  637. var
  638. i : longint;
  639. begin
  640. for i:=0 to mapsize-1 do
  641. begin
  642. if assigned(map[i].unitsym) and
  643. (map[i].unitsym.refs=0) then
  644. MessagePos2(map[i].unitsym.fileinfo,sym_n_unit_not_used,map[i].u.realmodulename^,realmodulename^);
  645. end;
  646. end;
  647. procedure tmodule.setmodulename(const s:string);
  648. begin
  649. stringdispose(modulename);
  650. stringdispose(realmodulename);
  651. modulename:=stringdup(upper(s));
  652. realmodulename:=stringdup(s);
  653. { also update asmlibrary names }
  654. librarydata.name:=modulename^;
  655. librarydata.realname:=realmodulename^;
  656. end;
  657. end.
  658. {
  659. $Log$
  660. Revision 1.51 2005-01-09 20:24:43 olle
  661. * rework of macro subsystem
  662. + exportable macros for mode macpas
  663. Revision 1.50 2004/12/28 20:43:01 hajny
  664. * 8.3 fixes (short target name in paths)
  665. Revision 1.49 2004/11/04 23:59:13 peter
  666. use filepos of main when generating the module stabs
  667. Revision 1.48 2004/10/14 18:16:17 mazen
  668. * USE_SYSUTILS merged successfully : cycles with and without defines
  669. * Need to be optimized in performance
  670. Revision 1.47 2004/10/14 17:30:09 mazen
  671. * use SysUtils unit instead of Dos Unit
  672. Revision 1.46 2004/08/30 20:23:33 peter
  673. * use realmodulename in unit not used msg
  674. Revision 1.45 2004/06/20 08:55:29 florian
  675. * logs truncated
  676. Revision 1.44 2004/03/08 22:07:46 peter
  677. * stabs updates to write stabs for def for all implictly used
  678. units
  679. }