files.pas 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This unit implements an extended file management and the first loading
  5. and searching of the modules (ppufiles)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit files;
  20. {$ifdef TP}
  21. {$V+}
  22. {$endif}
  23. {$ifdef TP}
  24. {$define SHORTASMPREFIX}
  25. {$endif}
  26. {$ifdef go32v1}
  27. {$define SHORTASMPREFIX}
  28. {$endif}
  29. {$ifdef go32v2}
  30. {$define SHORTASMPREFIX}
  31. {$endif}
  32. {$ifdef OS2}
  33. { Allthough OS/2 supports long filenames I play it safe and
  34. use 8.3 filenames, because this allows the compiler to run
  35. on a FAT partition. (DM) }
  36. {$define SHORTASMPREFIX}
  37. {$endif}
  38. interface
  39. uses
  40. globtype,cobjects,globals,ppu
  41. {$IFDEF NEWST},objects{$ENDIF};
  42. const
  43. {$ifdef FPC}
  44. maxunits = 1024;
  45. InputFileBufSize=32*1024;
  46. linebufincrease=512;
  47. {$else}
  48. maxunits = 128;
  49. InputFileBufSize=1024;
  50. linebufincrease=64;
  51. {$endif}
  52. type
  53. trecompile_reason = (rr_unknown,rr_noppu,rr_sourcenewer,
  54. rr_build,rr_libolder,rr_objolder,rr_asmolder,rr_crcchanged);
  55. {$ifdef FPC}
  56. tlongintarr = array[0..1000000] of longint;
  57. {$else}
  58. tlongintarr = array[0..16000] of longint;
  59. {$endif}
  60. plongintarr = ^tlongintarr;
  61. pinputfile = ^tinputfile;
  62. tinputfile = object
  63. path,name : pstring; { path and filename }
  64. next : pinputfile; { next file for reading }
  65. is_macro,
  66. endoffile, { still bytes left to read }
  67. closed : boolean; { is the file closed }
  68. buf : pchar; { buffer }
  69. bufstart, { buffer start position in the file }
  70. bufsize, { amount of bytes in the buffer }
  71. maxbufsize : longint; { size in memory for the buffer }
  72. saveinputpointer : pchar; { save fields for scanner variables }
  73. savelastlinepos,
  74. saveline_no : longint;
  75. linebuf : plongintarr; { line buffer to retrieve lines }
  76. maxlinebuf : longint;
  77. ref_count : longint; { to handle the browser refs }
  78. ref_index : longint;
  79. ref_next : pinputfile;
  80. constructor init(const fn:string);
  81. destructor done;
  82. procedure setpos(l:longint);
  83. procedure seekbuf(fpos:longint);
  84. procedure readbuf;
  85. function open:boolean;
  86. procedure close;
  87. procedure tempclose;
  88. function tempopen:boolean;
  89. procedure setmacro(p:pchar;len:longint);
  90. procedure setline(line,linepos:longint);
  91. function getlinestr(l:longint):string;
  92. {$ifdef FPC}protected{$else}public{$endif}
  93. function fileopen(const filename: string): boolean; virtual;
  94. function fileseek(pos: longint): boolean; virtual;
  95. function fileread(var databuf; maxsize: longint): longint; virtual;
  96. function fileeof: boolean; virtual;
  97. function fileclose: boolean; virtual;
  98. end;
  99. pdosinputfile = ^tdosinputfile;
  100. tdosinputfile = object(tinputfile)
  101. {$ifdef FPC}protected{$else}public{$endif}
  102. function fileopen(const filename: string): boolean; virtual;
  103. function fileseek(pos: longint): boolean; virtual;
  104. function fileread(var databuf; maxsize: longint): longint; virtual;
  105. function fileeof: boolean; virtual;
  106. function fileclose: boolean; virtual;
  107. private
  108. f : file; { current file handle }
  109. end;
  110. pfilemanager = ^tfilemanager;
  111. tfilemanager = object
  112. files : pinputfile;
  113. last_ref_index : longint;
  114. cacheindex : longint;
  115. cacheinputfile : pinputfile;
  116. constructor init;
  117. destructor done;
  118. procedure register_file(f : pinputfile);
  119. procedure inverse_register_indexes;
  120. function get_file(l:longint) : pinputfile;
  121. function get_file_name(l :longint):string;
  122. function get_file_path(l :longint):string;
  123. end;
  124. {$IFDEF NEWST}
  125. Plinkitem=^Tlinkitem;
  126. Tlinkitem=object(Tobject)
  127. data : pstring;
  128. needlink : longint;
  129. constructor init(const s:string;m:longint);
  130. destructor done;virtual;
  131. end;
  132. {$ELSE}
  133. plinkcontaineritem=^tlinkcontaineritem;
  134. tlinkcontaineritem=object(tcontaineritem)
  135. data : pstring;
  136. needlink : longint;
  137. constructor init(const s:string;m:longint);
  138. destructor done;virtual;
  139. end;
  140. plinkcontainer=^tlinkcontainer;
  141. tlinkcontainer=object(tcontainer)
  142. constructor Init;
  143. procedure insert(const s : string;m:longint);
  144. function get(var m:longint) : string;
  145. function getusemask(mask:longint) : string;
  146. function find(const s:string):boolean;
  147. end;
  148. {$ENDIF NEWST}
  149. {$ifndef NEWMAP}
  150. tunitmap = array[0..maxunits-1] of pointer;
  151. punitmap = ^tunitmap;
  152. pmodule = ^tmodule;
  153. {$else NEWMAP}
  154. pmodule = ^tmodule;
  155. tunitmap = array[0..maxunits-1] of pmodule;
  156. punitmap = ^tunitmap;
  157. {$endif NEWMAP}
  158. tmodule = object(tlinkedlist_item)
  159. ppufile : pppufile; { the PPU file }
  160. crc,
  161. interface_crc,
  162. flags : longint; { the PPU flags }
  163. compiled, { unit is already compiled }
  164. do_reload, { force reloading of the unit }
  165. do_assemble, { only assemble the object, don't recompile }
  166. do_compile, { need to compile the sources }
  167. sources_avail, { if all sources are reachable }
  168. sources_checked, { if there is already done a check for the sources }
  169. is_unit,
  170. in_compile, { is it being compiled ?? }
  171. in_second_compile, { is this unit being compiled for the 2nd time? }
  172. in_second_load, { is this unit PPU loaded a 2nd time? }
  173. in_implementation, { processing the implementation part? }
  174. in_global : boolean; { allow global settings }
  175. recompile_reason : trecompile_reason; { the reason why the unit should be recompiled }
  176. islibrary : boolean; { if it is a library (win32 dll) }
  177. map : punitmap; { mapping of all used units }
  178. unitcount : word; { local unit counter }
  179. unit_index : word; { global counter for browser }
  180. globalsymtable, { pointer to the local/static symtable of this unit }
  181. localsymtable : pointer; { pointer to the psymtable of this unit }
  182. scanner : pointer; { scanner object used }
  183. loaded_from : pmodule;
  184. uses_imports : boolean; { Set if the module imports from DLL's.}
  185. imports : plinkedlist;
  186. _exports : plinkedlist;
  187. sourcefiles : pfilemanager;
  188. resourcefiles : tstringcontainer;
  189. {$IFDEF NEWST}
  190. linkunitofiles,
  191. linkunitstaticlibs,
  192. linkunitsharedlibs,
  193. linkotherofiles, { objects,libs loaded from the source }
  194. linkothersharedlibs, { using $L or $LINKLIB or import lib (for linux) }
  195. linkotherstaticlibs : Tcollection;
  196. {$ELSE}
  197. linkunitofiles,
  198. linkunitstaticlibs,
  199. linkunitsharedlibs,
  200. linkotherofiles, { objects,libs loaded from the source }
  201. linkothersharedlibs, { using $L or $LINKLIB or import lib (for linux) }
  202. linkotherstaticlibs : tlinkcontainer;
  203. {$ENDIF NEWST}
  204. used_units : tlinkedlist;
  205. dependent_units : tlinkedlist;
  206. localunitsearchpath, { local searchpaths }
  207. localobjectsearchpath,
  208. localincludesearchpath,
  209. locallibrarysearchpath : TSearchPathList;
  210. path, { path where the module is find/created }
  211. outputpath, { path where the .s / .o / exe are created }
  212. modulename, { name of the module in uppercase }
  213. objfilename, { fullname of the objectfile }
  214. asmfilename, { fullname of the assemblerfile }
  215. ppufilename, { fullname of the ppufile }
  216. staticlibfilename, { fullname of the static libraryfile }
  217. sharedlibfilename, { fullname of the shared libraryfile }
  218. exefilename, { fullname of the exefile }
  219. asmprefix, { prefix for the smartlink asmfiles }
  220. mainsource : pstring; { name of the main sourcefile }
  221. {$ifdef Test_Double_checksum}
  222. crc_array : pointer;
  223. crc_size : longint;
  224. crc_array2 : pointer;
  225. crc_size2 : longint;
  226. {$endif def Test_Double_checksum}
  227. constructor init(const s:string;_is_unit:boolean);
  228. destructor done;virtual;
  229. procedure reset;
  230. procedure setfilename(const fn:string;allowoutput:boolean);
  231. function openppu:boolean;
  232. function search_unit(const n : string;onlysource:boolean):boolean;
  233. end;
  234. pused_unit = ^tused_unit;
  235. tused_unit = object(tlinkedlist_item)
  236. unitid : word;
  237. name : pstring;
  238. checksum,
  239. interface_checksum : longint;
  240. loaded : boolean;
  241. in_uses,
  242. in_interface,
  243. is_stab_written : boolean;
  244. u : pmodule;
  245. constructor init(_u : pmodule;intface:boolean);
  246. constructor init_to_load(const n:string;c,intfc:longint;intface:boolean);
  247. destructor done;virtual;
  248. end;
  249. pdependent_unit = ^tdependent_unit;
  250. tdependent_unit = object(tlinkedlist_item)
  251. u : pmodule;
  252. constructor init(_u : pmodule);
  253. end;
  254. var
  255. main_module : pmodule; { Main module of the program }
  256. current_module : pmodule; { Current module which is compiled or loaded }
  257. compiled_module : pmodule; { Current module which is compiled }
  258. current_ppu : pppufile; { Current ppufile which is read }
  259. global_unit_count : word;
  260. usedunits : tlinkedlist; { Used units for this program }
  261. loaded_units : tlinkedlist; { All loaded units }
  262. SmartLinkOFiles : TStringContainer; { List of .o files which are generated,
  263. used to delete them after linking }
  264. function get_source_file(moduleindex,fileindex : word) : pinputfile;
  265. implementation
  266. uses
  267. {$ifdef Delphi}
  268. dmisc,
  269. {$else Delphi}
  270. dos,
  271. {$endif Delphi}
  272. verbose,systems,
  273. symtable,scanner{$IFDEF NEWST},symtablt{$ENDIF};
  274. {****************************************************************************
  275. TINPUTFILE
  276. ****************************************************************************}
  277. constructor tinputfile.init(const fn:string);
  278. var
  279. p:dirstr;
  280. n:namestr;
  281. e:extstr;
  282. begin
  283. FSplit(fn,p,n,e);
  284. name:=stringdup(n+e);
  285. path:=stringdup(p);
  286. next:=nil;
  287. { file info }
  288. is_macro:=false;
  289. endoffile:=false;
  290. closed:=true;
  291. buf:=nil;
  292. bufstart:=0;
  293. bufsize:=0;
  294. maxbufsize:=InputFileBufSize;
  295. { save fields }
  296. saveinputpointer:=nil;
  297. saveline_no:=0;
  298. savelastlinepos:=0;
  299. { indexing refs }
  300. ref_next:=nil;
  301. ref_count:=0;
  302. ref_index:=0;
  303. { line buffer }
  304. linebuf:=nil;
  305. maxlinebuf:=0;
  306. end;
  307. destructor tinputfile.done;
  308. begin
  309. if not closed then
  310. close;
  311. stringdispose(path);
  312. stringdispose(name);
  313. { free memory }
  314. if assigned(linebuf) then
  315. freemem(linebuf,maxlinebuf shl 2);
  316. end;
  317. procedure tinputfile.setpos(l:longint);
  318. begin
  319. bufstart:=l;
  320. end;
  321. procedure tinputfile.seekbuf(fpos:longint);
  322. begin
  323. if closed then
  324. exit;
  325. fileseek(fpos);
  326. bufstart:=fpos;
  327. bufsize:=0;
  328. end;
  329. procedure tinputfile.readbuf;
  330. begin
  331. if is_macro then
  332. endoffile:=true;
  333. if closed then
  334. exit;
  335. inc(bufstart,bufsize);
  336. bufsize:=fileread(buf^,maxbufsize-1);
  337. buf[bufsize]:=#0;
  338. endoffile:=fileeof;
  339. end;
  340. function tinputfile.open:boolean;
  341. begin
  342. open:=false;
  343. if not closed then
  344. Close;
  345. if not fileopen(path^+name^) then
  346. exit;
  347. { file }
  348. endoffile:=false;
  349. closed:=false;
  350. Getmem(buf,MaxBufsize);
  351. bufstart:=0;
  352. bufsize:=0;
  353. open:=true;
  354. end;
  355. procedure tinputfile.close;
  356. begin
  357. if is_macro then
  358. begin
  359. if assigned(buf) then
  360. Freemem(buf,maxbufsize);
  361. buf:=nil;
  362. {is_macro:=false;
  363. still needed for dispose in scanner PM }
  364. closed:=true;
  365. exit;
  366. end;
  367. if not closed then
  368. begin
  369. if fileclose then;
  370. closed:=true;
  371. end;
  372. if assigned(buf) then
  373. begin
  374. Freemem(buf,maxbufsize);
  375. buf:=nil;
  376. end;
  377. bufstart:=0;
  378. end;
  379. procedure tinputfile.tempclose;
  380. begin
  381. if is_macro then
  382. exit;
  383. if not closed then
  384. begin
  385. if fileclose then;
  386. Freemem(buf,maxbufsize);
  387. buf:=nil;
  388. closed:=true;
  389. end;
  390. end;
  391. function tinputfile.tempopen:boolean;
  392. begin
  393. tempopen:=false;
  394. if is_macro then
  395. begin
  396. { seek buffer postion to bufstart }
  397. if bufstart>0 then
  398. begin
  399. move(buf[bufstart],buf[0],bufsize-bufstart+1);
  400. bufstart:=0;
  401. end;
  402. tempopen:=true;
  403. exit;
  404. end;
  405. if not closed then
  406. exit;
  407. if not fileopen(path^+name^) then
  408. exit;
  409. closed:=false;
  410. { get new mem }
  411. Getmem(buf,maxbufsize);
  412. { restore state }
  413. fileseek(BufStart);
  414. bufsize:=0;
  415. readbuf;
  416. tempopen:=true;
  417. end;
  418. procedure tinputfile.setmacro(p:pchar;len:longint);
  419. begin
  420. { create new buffer }
  421. getmem(buf,len+1);
  422. move(p^,buf^,len);
  423. buf[len]:=#0;
  424. { reset }
  425. bufstart:=0;
  426. bufsize:=len;
  427. maxbufsize:=len+1;
  428. is_macro:=true;
  429. endoffile:=true;
  430. closed:=true;
  431. end;
  432. procedure tinputfile.setline(line,linepos:longint);
  433. var
  434. oldlinebuf : plongintarr;
  435. begin
  436. if line<1 then
  437. exit;
  438. while (line>=maxlinebuf) do
  439. begin
  440. oldlinebuf:=linebuf;
  441. { create new linebuf and move old info }
  442. getmem(linebuf,(maxlinebuf+linebufincrease) shl 2);
  443. if assigned(oldlinebuf) then
  444. begin
  445. move(oldlinebuf^,linebuf^,maxlinebuf shl 2);
  446. freemem(oldlinebuf,maxlinebuf shl 2);
  447. end;
  448. fillchar(linebuf^[maxlinebuf],linebufincrease shl 2,0);
  449. inc(maxlinebuf,linebufincrease);
  450. end;
  451. linebuf^[line]:=linepos;
  452. end;
  453. function tinputfile.getlinestr(l:longint):string;
  454. var
  455. c : char;
  456. i,
  457. fpos : longint;
  458. p : pchar;
  459. begin
  460. getlinestr:='';
  461. if l<maxlinebuf then
  462. begin
  463. fpos:=linebuf^[l];
  464. { fpos is set negativ if the line was already written }
  465. { but we still know the correct value }
  466. if fpos<0 then
  467. fpos:=-fpos+1;
  468. if closed then
  469. open;
  470. { in current buf ? }
  471. if (fpos<bufstart) or (fpos>bufstart+bufsize) then
  472. begin
  473. seekbuf(fpos);
  474. readbuf;
  475. end;
  476. { the begin is in the buf now simply read until #13,#10 }
  477. i:=0;
  478. p:=@buf[fpos-bufstart];
  479. repeat
  480. c:=p^;
  481. if c=#0 then
  482. begin
  483. if endoffile then
  484. break;
  485. readbuf;
  486. p:=buf;
  487. c:=p^;
  488. end;
  489. if c in [#10,#13] then
  490. break;
  491. inc(i);
  492. getlinestr[i]:=c;
  493. inc(longint(p));
  494. until (i=255);
  495. {$ifndef TP}
  496. {$ifopt H+}
  497. setlength(getlinestr,i);
  498. {$else}
  499. getlinestr[0]:=chr(i);
  500. {$endif}
  501. {$else}
  502. getlinestr[0]:=chr(i);
  503. {$endif}
  504. end;
  505. end;
  506. function tinputfile.fileopen(const filename: string): boolean;
  507. begin
  508. abstract;
  509. fileopen:=false;
  510. end;
  511. function tinputfile.fileseek(pos: longint): boolean;
  512. begin
  513. abstract;
  514. fileseek:=false;
  515. end;
  516. function tinputfile.fileread(var databuf; maxsize: longint): longint;
  517. begin
  518. abstract;
  519. fileread:=0;
  520. end;
  521. function tinputfile.fileeof: boolean;
  522. begin
  523. abstract;
  524. fileeof:=false;
  525. end;
  526. function tinputfile.fileclose: boolean;
  527. begin
  528. abstract;
  529. fileclose:=false;
  530. end;
  531. {****************************************************************************
  532. TDOSINPUTFILE
  533. ****************************************************************************}
  534. function tdosinputfile.fileopen(const filename: string): boolean;
  535. var
  536. ofm : byte;
  537. begin
  538. ofm:=filemode;
  539. filemode:=0;
  540. Assign(f,filename);
  541. {$I-}
  542. reset(f,1);
  543. {$I+}
  544. filemode:=ofm;
  545. fileopen:=(ioresult=0);
  546. end;
  547. function tdosinputfile.fileseek(pos: longint): boolean;
  548. begin
  549. {$I-}
  550. seek(f,BufStart);
  551. {$I+}
  552. fileseek:=(ioresult=0);
  553. end;
  554. function tdosinputfile.fileread(var databuf; maxsize: longint): longint;
  555. var w: {$ifdef TP}word{$else}longint{$endif};
  556. begin
  557. blockread(f,databuf,maxsize,w);
  558. fileread:=w;
  559. end;
  560. function tdosinputfile.fileeof: boolean;
  561. begin
  562. fileeof:=eof(f);
  563. end;
  564. function tdosinputfile.fileclose: boolean;
  565. begin
  566. {$I-}
  567. system.close(f);
  568. {$I+}
  569. fileclose:=(ioresult=0);
  570. end;
  571. {****************************************************************************
  572. TFILEMANAGER
  573. ****************************************************************************}
  574. constructor tfilemanager.init;
  575. begin
  576. files:=nil;
  577. last_ref_index:=0;
  578. cacheindex:=0;
  579. cacheinputfile:=nil;
  580. end;
  581. destructor tfilemanager.done;
  582. var
  583. hp : pinputfile;
  584. begin
  585. hp:=files;
  586. while assigned(hp) do
  587. begin
  588. files:=files^.ref_next;
  589. dispose(hp,done);
  590. hp:=files;
  591. end;
  592. last_ref_index:=0;
  593. end;
  594. procedure tfilemanager.register_file(f : pinputfile);
  595. begin
  596. { don't register macro's }
  597. if f^.is_macro then
  598. exit;
  599. inc(last_ref_index);
  600. f^.ref_next:=files;
  601. f^.ref_index:=last_ref_index;
  602. files:=f;
  603. { update cache }
  604. cacheindex:=last_ref_index;
  605. cacheinputfile:=f;
  606. {$ifdef FPC}
  607. {$ifdef heaptrc}
  608. writeln(stderr,f^.name^,' index ',current_module^.unit_index*100000+f^.ref_index);
  609. {$endif heaptrc}
  610. {$endif FPC}
  611. end;
  612. { this procedure is necessary after loading the
  613. sources files from a PPU file PM }
  614. procedure tfilemanager.inverse_register_indexes;
  615. var
  616. f : pinputfile;
  617. begin
  618. f:=files;
  619. while assigned(f) do
  620. begin
  621. f^.ref_index:=last_ref_index-f^.ref_index+1;
  622. f:=f^.ref_next;
  623. end;
  624. { reset cache }
  625. cacheindex:=0;
  626. cacheinputfile:=nil;
  627. end;
  628. function tfilemanager.get_file(l :longint) : pinputfile;
  629. var
  630. ff : pinputfile;
  631. begin
  632. { check cache }
  633. if (l=cacheindex) and assigned(cacheinputfile) then
  634. begin
  635. get_file:=cacheinputfile;
  636. exit;
  637. end;
  638. ff:=files;
  639. while assigned(ff) and (ff^.ref_index<>l) do
  640. ff:=ff^.ref_next;
  641. get_file:=ff;
  642. end;
  643. function tfilemanager.get_file_name(l :longint):string;
  644. var
  645. hp : pinputfile;
  646. begin
  647. hp:=get_file(l);
  648. if assigned(hp) then
  649. get_file_name:=hp^.name^
  650. else
  651. get_file_name:='';
  652. end;
  653. function tfilemanager.get_file_path(l :longint):string;
  654. var
  655. hp : pinputfile;
  656. begin
  657. hp:=get_file(l);
  658. if assigned(hp) then
  659. get_file_path:=hp^.path^
  660. else
  661. get_file_path:='';
  662. end;
  663. function get_source_file(moduleindex,fileindex : word) : pinputfile;
  664. var
  665. hp : pmodule;
  666. f : pinputfile;
  667. begin
  668. hp:=pmodule(loaded_units.first);
  669. while assigned(hp) and (hp^.unit_index<>moduleindex) do
  670. hp:=pmodule(hp^.next);
  671. get_source_file:=nil;
  672. if not assigned(hp) then
  673. exit;
  674. f:=pinputfile(hp^.sourcefiles^.files);
  675. while assigned(f) do
  676. begin
  677. if f^.ref_index=fileindex then
  678. begin
  679. get_source_file:=f;
  680. exit;
  681. end;
  682. f:=pinputfile(f^.ref_next);
  683. end;
  684. end;
  685. {****************************************************************************
  686. TLinkContainerItem
  687. ****************************************************************************}
  688. {$IFDEF NEWST}
  689. constructor TLinkItem.Init(const s:string;m:longint);
  690. begin
  691. inherited Init;
  692. data:=stringdup(s);
  693. needlink:=m;
  694. end;
  695. destructor TLinkItem.Done;
  696. begin
  697. stringdispose(data);
  698. end;
  699. {$ELSE}
  700. constructor TLinkContainerItem.Init(const s:string;m:longint);
  701. begin
  702. inherited Init;
  703. data:=stringdup(s);
  704. needlink:=m;
  705. end;
  706. destructor TLinkContainerItem.Done;
  707. begin
  708. stringdispose(data);
  709. end;
  710. {$ENDIF NEWST}
  711. {****************************************************************************
  712. TLinkContainer
  713. ****************************************************************************}
  714. {$IFNDEF NEWST}
  715. constructor TLinkContainer.Init;
  716. begin
  717. inherited init;
  718. end;
  719. procedure TLinkContainer.insert(const s : string;m:longint);
  720. var
  721. newnode : plinkcontaineritem;
  722. begin
  723. {if find(s) then
  724. exit; }
  725. new(newnode,init(s,m));
  726. inherited insert(newnode);
  727. end;
  728. function TLinkContainer.get(var m:longint) : string;
  729. var
  730. p : plinkcontaineritem;
  731. begin
  732. p:=plinkcontaineritem(inherited get);
  733. if p=nil then
  734. begin
  735. get:='';
  736. m:=0;
  737. exit;
  738. end;
  739. get:=p^.data^;
  740. m:=p^.needlink;
  741. dispose(p,done);
  742. end;
  743. function TLinkContainer.getusemask(mask:longint) : string;
  744. var
  745. p : plinkcontaineritem;
  746. found : boolean;
  747. begin
  748. found:=false;
  749. repeat
  750. p:=plinkcontaineritem(inherited get);
  751. if p=nil then
  752. begin
  753. getusemask:='';
  754. exit;
  755. end;
  756. getusemask:=p^.data^;
  757. found:=(p^.needlink and mask)<>0;
  758. dispose(p,done);
  759. until found;
  760. end;
  761. function TLinkContainer.find(const s:string):boolean;
  762. var
  763. newnode : plinkcontaineritem;
  764. begin
  765. find:=false;
  766. newnode:=plinkcontaineritem(root);
  767. while assigned(newnode) do
  768. begin
  769. if newnode^.data^=s then
  770. begin
  771. find:=true;
  772. exit;
  773. end;
  774. newnode:=plinkcontaineritem(newnode^.next);
  775. end;
  776. end;
  777. {$ENDIF NEWST}
  778. {****************************************************************************
  779. TMODULE
  780. ****************************************************************************}
  781. procedure tmodule.setfilename(const fn:string;allowoutput:boolean);
  782. var
  783. p : dirstr;
  784. n : NameStr;
  785. e : ExtStr;
  786. begin
  787. stringdispose(objfilename);
  788. stringdispose(asmfilename);
  789. stringdispose(ppufilename);
  790. stringdispose(staticlibfilename);
  791. stringdispose(sharedlibfilename);
  792. stringdispose(exefilename);
  793. stringdispose(outputpath);
  794. stringdispose(path);
  795. { Create names }
  796. fsplit(fn,p,n,e);
  797. n:=FixFileName(n);
  798. { set path }
  799. path:=stringdup(FixPath(p,false));
  800. { obj,asm,ppu names }
  801. p:=path^;
  802. if AllowOutput then
  803. begin
  804. if (OutputUnitDir<>'') then
  805. p:=OutputUnitDir
  806. else
  807. if (OutputExeDir<>'') then
  808. p:=OutputExeDir;
  809. end;
  810. outputpath:=stringdup(p);
  811. objfilename:=stringdup(p+n+target_info.objext);
  812. asmfilename:=stringdup(p+n+target_info.asmext);
  813. ppufilename:=stringdup(p+n+target_info.unitext);
  814. { lib and exe could be loaded with a file specified with -o }
  815. if AllowOutput and (OutputFile<>'') and (compile_level=1) then
  816. n:=OutputFile;
  817. staticlibfilename:=stringdup(p+target_os.libprefix+n+target_os.staticlibext);
  818. if target_info.target=target_i386_WIN32 then
  819. sharedlibfilename:=stringdup(p+n+target_os.sharedlibext)
  820. else
  821. sharedlibfilename:=stringdup(p+target_os.libprefix+n+target_os.sharedlibext);
  822. { output dir of exe can be specified separatly }
  823. if AllowOutput and (OutputExeDir<>'') then
  824. p:=OutputExeDir
  825. else
  826. p:=path^;
  827. exefilename:=stringdup(p+n+target_info.exeext);
  828. end;
  829. function tmodule.openppu:boolean;
  830. var
  831. objfiletime,
  832. ppufiletime,
  833. asmfiletime : longint;
  834. begin
  835. openppu:=false;
  836. Message1(unit_t_ppu_loading,ppufilename^);
  837. { Get ppufile time (also check if the file exists) }
  838. ppufiletime:=getnamedfiletime(ppufilename^);
  839. if ppufiletime=-1 then
  840. exit;
  841. { Open the ppufile }
  842. Message1(unit_u_ppu_name,ppufilename^);
  843. ppufile:=new(pppufile,init(ppufilename^));
  844. ppufile^.change_endian:=source_os.endian<>target_os.endian;
  845. if not ppufile^.open then
  846. begin
  847. dispose(ppufile,done);
  848. Message(unit_u_ppu_file_too_short);
  849. exit;
  850. end;
  851. { check for a valid PPU file }
  852. if not ppufile^.CheckPPUId then
  853. begin
  854. dispose(ppufile,done);
  855. Message(unit_u_ppu_invalid_header);
  856. exit;
  857. end;
  858. { check for allowed PPU versions }
  859. if not (ppufile^.GetPPUVersion = CurrentPPUVersion) then
  860. begin
  861. dispose(ppufile,done);
  862. Message1(unit_u_ppu_invalid_version,tostr(ppufile^.GetPPUVersion));
  863. exit;
  864. end;
  865. { check the target processor }
  866. if ttargetcpu(ppufile^.header.cpu)<>target_cpu then
  867. begin
  868. dispose(ppufile,done);
  869. Message(unit_u_ppu_invalid_processor);
  870. exit;
  871. end;
  872. { check target }
  873. if ttarget(ppufile^.header.target)<>target_info.target then
  874. begin
  875. dispose(ppufile,done);
  876. Message(unit_u_ppu_invalid_target);
  877. exit;
  878. end;
  879. { Load values to be access easier }
  880. flags:=ppufile^.header.flags;
  881. crc:=ppufile^.header.checksum;
  882. interface_crc:=ppufile^.header.interface_checksum;
  883. { Show Debug info }
  884. Message1(unit_u_ppu_time,filetimestring(ppufiletime));
  885. Message1(unit_u_ppu_flags,tostr(flags));
  886. Message1(unit_u_ppu_crc,tostr(ppufile^.header.checksum));
  887. Message1(unit_u_ppu_crc,tostr(ppufile^.header.interface_checksum)+' (intfc)');
  888. { check the object and assembler file to see if we need only to
  889. assemble, only if it's not in a library }
  890. do_compile:=false;
  891. if (flags and uf_in_library)=0 then
  892. begin
  893. if (flags and uf_smart_linked)<>0 then
  894. begin
  895. objfiletime:=getnamedfiletime(staticlibfilename^);
  896. Message2(unit_u_check_time,staticlibfilename^,filetimestring(objfiletime));
  897. if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
  898. begin
  899. recompile_reason:=rr_libolder;
  900. Message(unit_u_recompile_staticlib_is_older);
  901. do_compile:=true;
  902. exit;
  903. end;
  904. end;
  905. if (flags and uf_static_linked)<>0 then
  906. begin
  907. { the objectfile should be newer than the ppu file }
  908. objfiletime:=getnamedfiletime(objfilename^);
  909. Message2(unit_u_check_time,objfilename^,filetimestring(objfiletime));
  910. if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
  911. begin
  912. { check if assembler file is older than ppu file }
  913. asmfileTime:=GetNamedFileTime(asmfilename^);
  914. Message2(unit_u_check_time,asmfilename^,filetimestring(asmfiletime));
  915. if (asmfiletime<0) or (ppufiletime>asmfiletime) then
  916. begin
  917. Message(unit_u_recompile_obj_and_asm_older);
  918. recompile_reason:=rr_objolder;
  919. do_compile:=true;
  920. exit;
  921. end
  922. else
  923. begin
  924. Message(unit_u_recompile_obj_older_than_asm);
  925. if not(cs_asm_extern in aktglobalswitches) then
  926. begin
  927. do_compile:=true;
  928. recompile_reason:=rr_asmolder;
  929. exit;
  930. end;
  931. end;
  932. end;
  933. end;
  934. end;
  935. openppu:=true;
  936. end;
  937. function tmodule.search_unit(const n : string;onlysource:boolean):boolean;
  938. var
  939. singlepathstring,
  940. filename : string;
  941. Function UnitExists(const ext:string):boolean;
  942. begin
  943. Message1(unit_t_unitsearch,Singlepathstring+filename+ext);
  944. UnitExists:=FileExists(Singlepathstring+FileName+ext);
  945. end;
  946. Function PPUSearchPath(const s:string):boolean;
  947. var
  948. found : boolean;
  949. begin
  950. Found:=false;
  951. singlepathstring:=FixPath(s,false);
  952. { Check for PPU file }
  953. Found:=UnitExists(target_info.unitext);
  954. if Found then
  955. Begin
  956. SetFileName(SinglePathString+FileName,false);
  957. Found:=OpenPPU;
  958. End;
  959. PPUSearchPath:=Found;
  960. end;
  961. Function SourceSearchPath(const s:string):boolean;
  962. var
  963. found : boolean;
  964. ext : string[8];
  965. begin
  966. Found:=false;
  967. singlepathstring:=FixPath(s,false);
  968. { Check for Sources }
  969. ppufile:=nil;
  970. do_compile:=true;
  971. recompile_reason:=rr_noppu;
  972. {Check for .pp file}
  973. Found:=UnitExists(target_os.sourceext);
  974. if Found then
  975. Ext:=target_os.sourceext
  976. else
  977. begin
  978. {Check for .pas}
  979. Found:=UnitExists(target_os.pasext);
  980. if Found then
  981. Ext:=target_os.pasext;
  982. end;
  983. stringdispose(mainsource);
  984. if Found then
  985. begin
  986. sources_avail:=true;
  987. {Load Filenames when found}
  988. mainsource:=StringDup(SinglePathString+FileName+Ext);
  989. SetFileName(SinglePathString+FileName,false);
  990. end
  991. else
  992. sources_avail:=false;
  993. SourceSearchPath:=Found;
  994. end;
  995. Function SearchPath(const s:string):boolean;
  996. var
  997. found : boolean;
  998. begin
  999. { First check for a ppu, then for the source }
  1000. found:=false;
  1001. if not onlysource then
  1002. found:=PPUSearchPath(s);
  1003. if not found then
  1004. found:=SourceSearchPath(s);
  1005. SearchPath:=found;
  1006. end;
  1007. Function SearchPathList(list:TSearchPathList):boolean;
  1008. var
  1009. hp : PStringQueueItem;
  1010. found : boolean;
  1011. begin
  1012. found:=false;
  1013. hp:=list.First;
  1014. while assigned(hp) do
  1015. begin
  1016. found:=SearchPath(hp^.data^);
  1017. if found then
  1018. break;
  1019. hp:=hp^.next;
  1020. end;
  1021. SearchPathList:=found;
  1022. end;
  1023. var
  1024. fnd : boolean;
  1025. begin
  1026. filename:=FixFileName(n);
  1027. { try to find unit
  1028. 1. look for ppu in cwd
  1029. 2. look for ppu in outputpath if set, this is tp7 compatible (PFV)
  1030. 3. look for source in cwd
  1031. 4. local unit pathlist
  1032. 5. global unit pathlist }
  1033. fnd:=false;
  1034. if not onlysource then
  1035. begin
  1036. fnd:=PPUSearchPath('.');
  1037. if (not fnd) and (current_module^.outputpath^<>'') then
  1038. fnd:=PPUSearchPath(current_module^.outputpath^);
  1039. end;
  1040. if (not fnd) then
  1041. fnd:=SourceSearchPath('.');
  1042. if (not fnd) then
  1043. fnd:=SearchPathList(current_module^.LocalUnitSearchPath);
  1044. if (not fnd) then
  1045. fnd:=SearchPathList(UnitSearchPath);
  1046. { try to find a file with the first 8 chars of the modulename, like
  1047. dos }
  1048. if (not fnd) and (length(filename)>8) then
  1049. begin
  1050. filename:=copy(filename,1,8);
  1051. fnd:=SearchPath('.');
  1052. if (not fnd) then
  1053. fnd:=SearchPathList(current_module^.LocalUnitSearchPath);
  1054. if not fnd then
  1055. fnd:=SearchPathList(UnitSearchPath);
  1056. end;
  1057. search_unit:=fnd;
  1058. end;
  1059. procedure tmodule.reset;
  1060. var
  1061. pm : pdependent_unit;
  1062. begin
  1063. if assigned(scanner) then
  1064. pscannerfile(scanner)^.invalid:=true;
  1065. if assigned(globalsymtable) then
  1066. begin
  1067. dispose(punitsymtable(globalsymtable),done);
  1068. globalsymtable:=nil;
  1069. end;
  1070. if assigned(localsymtable) then
  1071. begin
  1072. dispose(punitsymtable(localsymtable),done);
  1073. localsymtable:=nil;
  1074. end;
  1075. if assigned(map) then
  1076. begin
  1077. dispose(map);
  1078. map:=nil;
  1079. end;
  1080. if assigned(ppufile) then
  1081. begin
  1082. dispose(ppufile,done);
  1083. ppufile:=nil;
  1084. end;
  1085. sourcefiles^.done;
  1086. sourcefiles^.init;
  1087. imports^.done;
  1088. imports^.init;
  1089. _exports^.done;
  1090. _exports^.init;
  1091. used_units.done;
  1092. used_units.init;
  1093. { all units that depend on this one must be recompiled ! }
  1094. pm:=pdependent_unit(dependent_units.first);
  1095. while assigned(pm) do
  1096. begin
  1097. if pm^.u^.in_second_compile then
  1098. Comment(v_debug,'No reload already in second compile: '+pm^.u^.modulename^)
  1099. else
  1100. begin
  1101. pm^.u^.do_reload:=true;
  1102. Comment(v_debug,'Reloading '+pm^.u^.modulename^+' needed because '+modulename^+' is reloaded');
  1103. end;
  1104. pm:=pdependent_unit(pm^.next);
  1105. end;
  1106. dependent_units.done;
  1107. dependent_units.init;
  1108. resourcefiles.done;
  1109. resourcefiles.init;
  1110. linkunitofiles.done;
  1111. linkunitofiles.init{$IFDEF NEWST}(8,4){$ENDIF};
  1112. linkunitstaticlibs.done;
  1113. linkunitstaticlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1114. linkunitsharedlibs.done;
  1115. linkunitsharedlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1116. linkotherofiles.done;
  1117. linkotherofiles.init{$IFDEF NEWST}(8,4){$ENDIF};
  1118. linkotherstaticlibs.done;
  1119. linkotherstaticlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1120. linkothersharedlibs.done;
  1121. linkothersharedlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1122. uses_imports:=false;
  1123. do_assemble:=false;
  1124. do_compile:=false;
  1125. { sources_avail:=true;
  1126. should not be changed PM }
  1127. compiled:=false;
  1128. in_implementation:=false;
  1129. in_global:=true;
  1130. {loaded_from:=nil;
  1131. should not be changed PFV }
  1132. flags:=0;
  1133. crc:=0;
  1134. interface_crc:=0;
  1135. unitcount:=1;
  1136. recompile_reason:=rr_unknown;
  1137. end;
  1138. constructor tmodule.init(const s:string;_is_unit:boolean);
  1139. var
  1140. p : dirstr;
  1141. n : namestr;
  1142. e : extstr;
  1143. begin
  1144. FSplit(s,p,n,e);
  1145. { Programs have the name program to don't conflict with dup id's }
  1146. if _is_unit then
  1147. {$ifdef UNITALIASES}
  1148. modulename:=stringdup(GetUnitAlias(Upper(n)))
  1149. {$else}
  1150. modulename:=stringdup(Upper(n))
  1151. {$endif}
  1152. else
  1153. modulename:=stringdup('PROGRAM');
  1154. mainsource:=stringdup(s);
  1155. ppufilename:=nil;
  1156. objfilename:=nil;
  1157. asmfilename:=nil;
  1158. staticlibfilename:=nil;
  1159. sharedlibfilename:=nil;
  1160. exefilename:=nil;
  1161. { Dos has the famous 8.3 limit :( }
  1162. {$ifdef SHORTASMPREFIX}
  1163. asmprefix:=stringdup(FixFileName('as'));
  1164. {$else}
  1165. asmprefix:=stringdup(FixFileName(n));
  1166. {$endif}
  1167. outputpath:=nil;
  1168. path:=nil;
  1169. setfilename(p+n,true);
  1170. localunitsearchpath.init;
  1171. localobjectsearchpath.init;
  1172. localincludesearchpath.init;
  1173. locallibrarysearchpath.init;
  1174. used_units.init;
  1175. dependent_units.init;
  1176. new(sourcefiles,init);
  1177. resourcefiles.init;
  1178. linkunitofiles.init{$IFDEF NEWST}(8,4){$ENDIF};
  1179. linkunitstaticlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1180. linkunitsharedlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1181. linkotherofiles.init{$IFDEF NEWST}(8,4){$ENDIF};
  1182. linkotherstaticlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1183. linkothersharedlibs.init{$IFDEF NEWST}(8,4){$ENDIF};
  1184. ppufile:=nil;
  1185. scanner:=nil;
  1186. map:=nil;
  1187. globalsymtable:=nil;
  1188. localsymtable:=nil;
  1189. loaded_from:=nil;
  1190. flags:=0;
  1191. crc:=0;
  1192. interface_crc:=0;
  1193. do_reload:=false;
  1194. unitcount:=1;
  1195. inc(global_unit_count);
  1196. unit_index:=global_unit_count;
  1197. do_assemble:=false;
  1198. do_compile:=false;
  1199. sources_avail:=true;
  1200. sources_checked:=false;
  1201. compiled:=false;
  1202. recompile_reason:=rr_unknown;
  1203. in_second_load:=false;
  1204. in_compile:=false;
  1205. in_second_compile:=false;
  1206. in_implementation:=false;
  1207. in_global:=true;
  1208. is_unit:=_is_unit;
  1209. islibrary:=false;
  1210. uses_imports:=false;
  1211. imports:=new(plinkedlist,init);
  1212. _exports:=new(plinkedlist,init);
  1213. { search the PPU file if it is an unit }
  1214. if is_unit then
  1215. begin
  1216. search_unit(modulename^,false);
  1217. { it the sources_available is changed then we know that
  1218. the sources aren't available }
  1219. if not sources_avail then
  1220. sources_checked:=true;
  1221. end;
  1222. end;
  1223. destructor tmodule.done;
  1224. {$ifdef MEMDEBUG}
  1225. var
  1226. d : tmemdebug;
  1227. {$endif}
  1228. begin
  1229. if assigned(map) then
  1230. dispose(map);
  1231. if assigned(ppufile) then
  1232. dispose(ppufile,done);
  1233. ppufile:=nil;
  1234. if assigned(imports) then
  1235. dispose(imports,done);
  1236. imports:=nil;
  1237. if assigned(_exports) then
  1238. dispose(_exports,done);
  1239. _exports:=nil;
  1240. if assigned(scanner) then
  1241. pscannerfile(scanner)^.invalid:=true;
  1242. if assigned(sourcefiles) then
  1243. dispose(sourcefiles,done);
  1244. sourcefiles:=nil;
  1245. used_units.done;
  1246. dependent_units.done;
  1247. resourcefiles.done;
  1248. linkunitofiles.done;
  1249. linkunitstaticlibs.done;
  1250. linkunitsharedlibs.done;
  1251. linkotherofiles.done;
  1252. linkotherstaticlibs.done;
  1253. linkothersharedlibs.done;
  1254. stringdispose(objfilename);
  1255. stringdispose(asmfilename);
  1256. stringdispose(ppufilename);
  1257. stringdispose(staticlibfilename);
  1258. stringdispose(sharedlibfilename);
  1259. stringdispose(exefilename);
  1260. stringdispose(outputpath);
  1261. stringdispose(path);
  1262. stringdispose(modulename);
  1263. stringdispose(mainsource);
  1264. stringdispose(asmprefix);
  1265. localunitsearchpath.done;
  1266. localobjectsearchpath.done;
  1267. localincludesearchpath.done;
  1268. locallibrarysearchpath.done;
  1269. {$ifdef MEMDEBUG}
  1270. d.init('symtable');
  1271. {$endif}
  1272. if assigned(globalsymtable) then
  1273. dispose(punitsymtable(globalsymtable),done);
  1274. globalsymtable:=nil;
  1275. if assigned(localsymtable) then
  1276. dispose(punitsymtable(localsymtable),done);
  1277. localsymtable:=nil;
  1278. {$ifdef MEMDEBUG}
  1279. d.done;
  1280. {$endif}
  1281. inherited done;
  1282. end;
  1283. {****************************************************************************
  1284. TUSED_UNIT
  1285. ****************************************************************************}
  1286. constructor tused_unit.init(_u : pmodule;intface:boolean);
  1287. begin
  1288. u:=_u;
  1289. in_interface:=intface;
  1290. in_uses:=false;
  1291. is_stab_written:=false;
  1292. loaded:=true;
  1293. name:=stringdup(_u^.modulename^);
  1294. checksum:=_u^.crc;
  1295. interface_checksum:=_u^.interface_crc;
  1296. unitid:=0;
  1297. end;
  1298. constructor tused_unit.init_to_load(const n:string;c,intfc:longint;intface:boolean);
  1299. begin
  1300. u:=nil;
  1301. in_interface:=intface;
  1302. in_uses:=false;
  1303. is_stab_written:=false;
  1304. loaded:=false;
  1305. name:=stringdup(n);
  1306. checksum:=c;
  1307. interface_checksum:=intfc;
  1308. unitid:=0;
  1309. end;
  1310. destructor tused_unit.done;
  1311. begin
  1312. stringdispose(name);
  1313. inherited done;
  1314. end;
  1315. {****************************************************************************
  1316. TDENPENDENT_UNIT
  1317. ****************************************************************************}
  1318. constructor tdependent_unit.init(_u : pmodule);
  1319. begin
  1320. u:=_u;
  1321. end;
  1322. end.
  1323. {
  1324. $Log$
  1325. Revision 1.3 2000-08-12 15:30:44 peter
  1326. * IDE patch for stream reading (merged)
  1327. Revision 1.2 2000/07/13 11:32:41 michael
  1328. + removed logs
  1329. }