2
0

files.pas 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774
  1. {
  2. $Id$
  3. Copyright (c) 1996-98 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,
  41. cobjects,globals,ppu;
  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. f : file; { current file handle }
  66. is_macro,
  67. endoffile, { still bytes left to read }
  68. closed : boolean; { is the file closed }
  69. buf : pchar; { buffer }
  70. bufstart, { buffer start position in the file }
  71. bufsize, { amount of bytes in the buffer }
  72. maxbufsize : longint; { size in memory for the buffer }
  73. saveinputpointer : pchar; { save fields for scanner variables }
  74. savelastlinepos,
  75. saveline_no : longint;
  76. linebuf : plongintarr; { line buffer to retrieve lines }
  77. maxlinebuf : longint;
  78. ref_count : longint; { to handle the browser refs }
  79. ref_index : longint;
  80. ref_next : pinputfile;
  81. constructor init(const fn:string);
  82. destructor done;
  83. procedure setpos(l:longint);
  84. procedure seekbuf(fpos:longint);
  85. procedure readbuf;
  86. function open:boolean;
  87. procedure close;
  88. procedure tempclose;
  89. function tempopen:boolean;
  90. procedure setmacro(p:pchar;len:longint);
  91. procedure setline(line,linepos:longint);
  92. function getlinestr(l:longint):string;
  93. end;
  94. pfilemanager = ^tfilemanager;
  95. tfilemanager = object
  96. files : pinputfile;
  97. last_ref_index : longint;
  98. cacheindex : longint;
  99. cacheinputfile : pinputfile;
  100. constructor init;
  101. destructor done;
  102. procedure register_file(f : pinputfile);
  103. procedure inverse_register_indexes;
  104. function get_file(l:longint) : pinputfile;
  105. function get_file_name(l :longint):string;
  106. function get_file_path(l :longint):string;
  107. end;
  108. plinkcontaineritem=^tlinkcontaineritem;
  109. tlinkcontaineritem=object(tcontaineritem)
  110. data : pstring;
  111. needlink : longint;
  112. constructor init(const s:string;m:longint);
  113. destructor done;virtual;
  114. end;
  115. plinkcontainer=^tlinkcontainer;
  116. tlinkcontainer=object(tcontainer)
  117. constructor Init;
  118. procedure insert(const s : string;m:longint);
  119. function get(var m:longint) : string;
  120. function getusemask(mask:longint) : string;
  121. function find(const s:string):boolean;
  122. end;
  123. {$ifndef NEWMAP}
  124. tunitmap = array[0..maxunits-1] of pointer;
  125. punitmap = ^tunitmap;
  126. pmodule = ^tmodule;
  127. {$else NEWMAP}
  128. pmodule = ^tmodule;
  129. tunitmap = array[0..maxunits-1] of pmodule;
  130. punitmap = ^tunitmap;
  131. {$endif NEWMAP}
  132. tmodule = object(tlinkedlist_item)
  133. ppufile : pppufile; { the PPU file }
  134. crc,
  135. interface_crc,
  136. flags : longint; { the PPU flags }
  137. compiled, { unit is already compiled }
  138. do_reload, { force reloading of the unit }
  139. do_assemble, { only assemble the object, don't recompile }
  140. do_compile, { need to compile the sources }
  141. sources_avail, { if all sources are reachable }
  142. is_unit,
  143. in_compile, { is it being compiled ?? }
  144. in_second_compile, { is this unit being compiled for the 2nd time? }
  145. in_second_load, { is this unit PPU loaded a 2nd time? }
  146. in_implementation, { processing the implementation part? }
  147. in_global : boolean; { allow global settings }
  148. recompile_reason : trecompile_reason; { the reason why the unit should be recompiled }
  149. islibrary : boolean; { if it is a library (win32 dll) }
  150. map : punitmap; { mapping of all used units }
  151. unitcount : word; { local unit counter }
  152. unit_index : word; { global counter for browser }
  153. globalsymtable, { pointer to the local/static symtable of this unit }
  154. localsymtable : pointer; { pointer to the psymtable of this unit }
  155. scanner : pointer; { scanner object used }
  156. loaded_from : pmodule;
  157. uses_imports : boolean; { Set if the module imports from DLL's.}
  158. imports : plinkedlist;
  159. _exports : plinkedlist;
  160. sourcefiles : pfilemanager;
  161. resourcefiles : tstringcontainer;
  162. linkunitofiles,
  163. linkunitstaticlibs,
  164. linkunitsharedlibs,
  165. linkotherofiles, { objects,libs loaded from the source }
  166. linkothersharedlibs, { using $L or $LINKLIB or import lib (for linux) }
  167. linkotherstaticlibs : tlinkcontainer;
  168. used_units : tlinkedlist;
  169. dependent_units : tlinkedlist;
  170. localunitsearchpath, { local searchpaths }
  171. localobjectsearchpath,
  172. localincludesearchpath,
  173. locallibrarysearchpath : pstring;
  174. path, { path where the module is find/created }
  175. outpath,
  176. modulename, { name of the module in uppercase }
  177. objfilename, { fullname of the objectfile }
  178. asmfilename, { fullname of the assemblerfile }
  179. ppufilename, { fullname of the ppufile }
  180. staticlibfilename, { fullname of the static libraryfile }
  181. sharedlibfilename, { fullname of the shared libraryfile }
  182. exefilename, { fullname of the exefile }
  183. asmprefix, { prefix for the smartlink asmfiles }
  184. mainsource : pstring; { name of the main sourcefile }
  185. {$ifdef Test_Double_checksum}
  186. crc_array : pointer;
  187. crc_size : longint;
  188. crc_array2 : pointer;
  189. crc_size2 : longint;
  190. {$endif def Test_Double_checksum}
  191. constructor init(const s:string;_is_unit:boolean);
  192. destructor done;virtual;
  193. procedure reset;
  194. procedure setfilename(const fn:string;allowoutput:boolean);
  195. function openppu:boolean;
  196. function search_unit(const n : string;onlysource:boolean):boolean;
  197. end;
  198. pused_unit = ^tused_unit;
  199. tused_unit = object(tlinkedlist_item)
  200. unitid : word;
  201. name : pstring;
  202. checksum,
  203. interface_checksum : longint;
  204. loaded : boolean;
  205. in_uses,
  206. in_interface,
  207. is_stab_written : boolean;
  208. u : pmodule;
  209. constructor init(_u : pmodule;intface:boolean);
  210. constructor init_to_load(const n:string;c,intfc:longint;intface:boolean);
  211. destructor done;virtual;
  212. end;
  213. pdependent_unit = ^tdependent_unit;
  214. tdependent_unit = object(tlinkedlist_item)
  215. u : pmodule;
  216. constructor init(_u : pmodule);
  217. end;
  218. var
  219. main_module : pmodule; { Main module of the program }
  220. current_module : pmodule; { Current module which is compiled or loaded }
  221. compiled_module : pmodule; { Current module which is compiled }
  222. current_ppu : pppufile; { Current ppufile which is read }
  223. global_unit_count : word;
  224. usedunits : tlinkedlist; { Used units for this program }
  225. loaded_units : tlinkedlist; { All loaded units }
  226. function get_source_file(moduleindex,fileindex : word) : pinputfile;
  227. implementation
  228. uses
  229. {$ifdef Delphi}
  230. dmisc,
  231. {$else Delphi}
  232. dos,
  233. {$endif Delphi}
  234. verbose,systems,
  235. symtable,scanner;
  236. {****************************************************************************
  237. TINPUTFILE
  238. ****************************************************************************}
  239. constructor tinputfile.init(const fn:string);
  240. var
  241. p:dirstr;
  242. n:namestr;
  243. e:extstr;
  244. begin
  245. FSplit(fn,p,n,e);
  246. name:=stringdup(n+e);
  247. path:=stringdup(p);
  248. next:=nil;
  249. { file info }
  250. is_macro:=false;
  251. endoffile:=false;
  252. closed:=true;
  253. buf:=nil;
  254. bufstart:=0;
  255. bufsize:=0;
  256. maxbufsize:=InputFileBufSize;
  257. { save fields }
  258. saveinputpointer:=nil;
  259. saveline_no:=0;
  260. savelastlinepos:=0;
  261. { indexing refs }
  262. ref_next:=nil;
  263. ref_count:=0;
  264. ref_index:=0;
  265. { line buffer }
  266. linebuf:=nil;
  267. maxlinebuf:=0;
  268. end;
  269. destructor tinputfile.done;
  270. begin
  271. if not closed then
  272. close;
  273. stringdispose(path);
  274. stringdispose(name);
  275. { free memory }
  276. if assigned(linebuf) then
  277. freemem(linebuf,maxlinebuf shl 2);
  278. end;
  279. procedure tinputfile.setpos(l:longint);
  280. begin
  281. bufstart:=l;
  282. end;
  283. procedure tinputfile.seekbuf(fpos:longint);
  284. begin
  285. if closed then
  286. exit;
  287. seek(f,fpos);
  288. bufstart:=fpos;
  289. bufsize:=0;
  290. end;
  291. procedure tinputfile.readbuf;
  292. {$ifdef TP}
  293. var
  294. w : word;
  295. {$endif}
  296. begin
  297. if is_macro then
  298. endoffile:=true;
  299. if closed then
  300. exit;
  301. inc(bufstart,bufsize);
  302. {$ifdef VER70}
  303. blockread(f,buf^,maxbufsize-1,w);
  304. bufsize:=w;
  305. {$else}
  306. blockread(f,buf^,maxbufsize-1,bufsize);
  307. {$endif}
  308. buf[bufsize]:=#0;
  309. endoffile:=eof(f);
  310. end;
  311. function tinputfile.open:boolean;
  312. var
  313. ofm : byte;
  314. begin
  315. open:=false;
  316. if not closed then
  317. Close;
  318. ofm:=filemode;
  319. filemode:=0;
  320. Assign(f,path^+name^);
  321. {$I-}
  322. reset(f,1);
  323. {$I+}
  324. filemode:=ofm;
  325. if ioresult<>0 then
  326. exit;
  327. { file }
  328. endoffile:=false;
  329. closed:=false;
  330. Getmem(buf,MaxBufsize);
  331. bufstart:=0;
  332. bufsize:=0;
  333. open:=true;
  334. end;
  335. procedure tinputfile.close;
  336. var
  337. i : word;
  338. begin
  339. if is_macro then
  340. begin
  341. if assigned(buf) then
  342. Freemem(buf,maxbufsize);
  343. buf:=nil;
  344. {is_macro:=false;
  345. still needed for dispose in scanner PM }
  346. closed:=true;
  347. exit;
  348. end;
  349. if not closed then
  350. begin
  351. {$I-}
  352. system.close(f);
  353. {$I+}
  354. i:=ioresult;
  355. closed:=true;
  356. end;
  357. if assigned(buf) then
  358. begin
  359. Freemem(buf,maxbufsize);
  360. buf:=nil;
  361. end;
  362. bufstart:=0;
  363. end;
  364. procedure tinputfile.tempclose;
  365. var
  366. i : word;
  367. begin
  368. if is_macro then
  369. exit;
  370. if not closed then
  371. begin
  372. {$I-}
  373. system.close(f);
  374. {$I+}
  375. i:=ioresult;
  376. Freemem(buf,maxbufsize);
  377. buf:=nil;
  378. closed:=true;
  379. end;
  380. end;
  381. function tinputfile.tempopen:boolean;
  382. var
  383. ofm : byte;
  384. begin
  385. tempopen:=false;
  386. if is_macro then
  387. begin
  388. { seek buffer postion to bufstart }
  389. if bufstart>0 then
  390. begin
  391. move(buf[bufstart],buf[0],bufsize-bufstart+1);
  392. bufstart:=0;
  393. end;
  394. tempopen:=true;
  395. exit;
  396. end;
  397. if not closed then
  398. exit;
  399. ofm:=filemode;
  400. filemode:=0;
  401. Assign(f,path^+name^);
  402. {$I-}
  403. reset(f,1);
  404. {$I+}
  405. filemode:=ofm;
  406. if ioresult<>0 then
  407. exit;
  408. closed:=false;
  409. { get new mem }
  410. Getmem(buf,maxbufsize);
  411. { restore state }
  412. seek(f,BufStart);
  413. bufsize:=0;
  414. readbuf;
  415. tempopen:=true;
  416. end;
  417. procedure tinputfile.setmacro(p:pchar;len:longint);
  418. begin
  419. { create new buffer }
  420. getmem(buf,len+1);
  421. move(p^,buf^,len);
  422. buf[len]:=#0;
  423. { reset }
  424. bufstart:=0;
  425. bufsize:=len;
  426. maxbufsize:=len+1;
  427. is_macro:=true;
  428. endoffile:=true;
  429. closed:=true;
  430. end;
  431. procedure tinputfile.setline(line,linepos:longint);
  432. var
  433. oldlinebuf : plongintarr;
  434. begin
  435. if line<1 then
  436. exit;
  437. while (line>=maxlinebuf) do
  438. begin
  439. oldlinebuf:=linebuf;
  440. { create new linebuf and move old info }
  441. getmem(linebuf,(maxlinebuf+linebufincrease) shl 2);
  442. if assigned(oldlinebuf) then
  443. begin
  444. move(oldlinebuf^,linebuf^,maxlinebuf shl 2);
  445. freemem(oldlinebuf,maxlinebuf shl 2);
  446. end;
  447. fillchar(linebuf^[maxlinebuf],linebufincrease shl 2,0);
  448. inc(maxlinebuf,linebufincrease);
  449. end;
  450. linebuf^[line]:=linepos;
  451. end;
  452. function tinputfile.getlinestr(l:longint):string;
  453. var
  454. c : char;
  455. i,
  456. fpos : longint;
  457. p : pchar;
  458. begin
  459. getlinestr:='';
  460. if l<maxlinebuf then
  461. begin
  462. fpos:=linebuf^[l];
  463. { fpos is set negativ if the line was already written }
  464. { but we still know the correct value }
  465. if fpos<0 then
  466. fpos:=-fpos+1;
  467. if closed then
  468. open;
  469. { in current buf ? }
  470. if (fpos<bufstart) or (fpos>bufstart+bufsize) then
  471. begin
  472. seekbuf(fpos);
  473. readbuf;
  474. end;
  475. { the begin is in the buf now simply read until #13,#10 }
  476. i:=0;
  477. p:=@buf[fpos-bufstart];
  478. repeat
  479. c:=p^;
  480. if c=#0 then
  481. begin
  482. if endoffile then
  483. break;
  484. readbuf;
  485. p:=buf;
  486. c:=p^;
  487. end;
  488. if c in [#10,#13] then
  489. break;
  490. inc(i);
  491. getlinestr[i]:=c;
  492. inc(longint(p));
  493. until (i=255);
  494. {$ifndef TP}
  495. {$ifopt H+}
  496. setlength(getlinestr,i);
  497. {$else}
  498. getlinestr[0]:=chr(i);
  499. {$endif}
  500. {$else}
  501. getlinestr[0]:=chr(i);
  502. {$endif}
  503. end;
  504. end;
  505. {****************************************************************************
  506. TFILEMANAGER
  507. ****************************************************************************}
  508. constructor tfilemanager.init;
  509. begin
  510. files:=nil;
  511. last_ref_index:=0;
  512. cacheindex:=0;
  513. cacheinputfile:=nil;
  514. end;
  515. destructor tfilemanager.done;
  516. var
  517. hp : pinputfile;
  518. begin
  519. hp:=files;
  520. while assigned(hp) do
  521. begin
  522. files:=files^.ref_next;
  523. dispose(hp,done);
  524. hp:=files;
  525. end;
  526. last_ref_index:=0;
  527. end;
  528. procedure tfilemanager.register_file(f : pinputfile);
  529. begin
  530. { don't register macro's }
  531. if f^.is_macro then
  532. exit;
  533. inc(last_ref_index);
  534. f^.ref_next:=files;
  535. f^.ref_index:=last_ref_index;
  536. files:=f;
  537. { update cache }
  538. cacheindex:=last_ref_index;
  539. cacheinputfile:=f;
  540. {$ifdef FPC}
  541. {$ifdef heaptrc}
  542. writeln(stderr,f^.name^,' index ',current_module^.unit_index*100000+f^.ref_index);
  543. {$endif heaptrc}
  544. {$endif FPC}
  545. end;
  546. { this procedure is necessary after loading the
  547. sources files from a PPU file PM }
  548. procedure tfilemanager.inverse_register_indexes;
  549. var
  550. f : pinputfile;
  551. begin
  552. f:=files;
  553. while assigned(f) do
  554. begin
  555. f^.ref_index:=last_ref_index-f^.ref_index+1;
  556. f:=f^.ref_next;
  557. end;
  558. { reset cache }
  559. cacheindex:=0;
  560. cacheinputfile:=nil;
  561. end;
  562. function tfilemanager.get_file(l :longint) : pinputfile;
  563. var
  564. ff : pinputfile;
  565. begin
  566. { check cache }
  567. if (l=cacheindex) and assigned(cacheinputfile) then
  568. begin
  569. get_file:=cacheinputfile;
  570. exit;
  571. end;
  572. ff:=files;
  573. while assigned(ff) and (ff^.ref_index<>l) do
  574. ff:=ff^.ref_next;
  575. get_file:=ff;
  576. end;
  577. function tfilemanager.get_file_name(l :longint):string;
  578. var
  579. hp : pinputfile;
  580. begin
  581. hp:=get_file(l);
  582. if assigned(hp) then
  583. get_file_name:=hp^.name^
  584. else
  585. get_file_name:='';
  586. end;
  587. function tfilemanager.get_file_path(l :longint):string;
  588. var
  589. hp : pinputfile;
  590. begin
  591. hp:=get_file(l);
  592. if assigned(hp) then
  593. get_file_path:=hp^.path^
  594. else
  595. get_file_path:='';
  596. end;
  597. function get_source_file(moduleindex,fileindex : word) : pinputfile;
  598. var
  599. hp : pmodule;
  600. f : pinputfile;
  601. begin
  602. hp:=pmodule(loaded_units.first);
  603. while assigned(hp) and (hp^.unit_index<>moduleindex) do
  604. hp:=pmodule(hp^.next);
  605. get_source_file:=nil;
  606. if not assigned(hp) then
  607. exit;
  608. f:=pinputfile(hp^.sourcefiles^.files);
  609. while assigned(f) do
  610. begin
  611. if f^.ref_index=fileindex then
  612. begin
  613. get_source_file:=f;
  614. exit;
  615. end;
  616. f:=pinputfile(f^.ref_next);
  617. end;
  618. end;
  619. {****************************************************************************
  620. TLinkContainerItem
  621. ****************************************************************************}
  622. constructor TLinkContainerItem.Init(const s:string;m:longint);
  623. begin
  624. inherited Init;
  625. data:=stringdup(s);
  626. needlink:=m;
  627. end;
  628. destructor TLinkContainerItem.Done;
  629. begin
  630. stringdispose(data);
  631. end;
  632. {****************************************************************************
  633. TLinkContainer
  634. ****************************************************************************}
  635. constructor TLinkContainer.Init;
  636. begin
  637. inherited init;
  638. end;
  639. procedure TLinkContainer.insert(const s : string;m:longint);
  640. var
  641. newnode : plinkcontaineritem;
  642. begin
  643. {if find(s) then
  644. exit; }
  645. new(newnode,init(s,m));
  646. inherited insert(newnode);
  647. end;
  648. function TLinkContainer.get(var m:longint) : string;
  649. var
  650. p : plinkcontaineritem;
  651. begin
  652. p:=plinkcontaineritem(inherited get);
  653. if p=nil then
  654. begin
  655. get:='';
  656. m:=0;
  657. exit;
  658. end;
  659. get:=p^.data^;
  660. m:=p^.needlink;
  661. dispose(p,done);
  662. end;
  663. function TLinkContainer.getusemask(mask:longint) : string;
  664. var
  665. p : plinkcontaineritem;
  666. found : boolean;
  667. begin
  668. found:=false;
  669. repeat
  670. p:=plinkcontaineritem(inherited get);
  671. if p=nil then
  672. begin
  673. getusemask:='';
  674. exit;
  675. end;
  676. getusemask:=p^.data^;
  677. found:=(p^.needlink and mask)<>0;
  678. dispose(p,done);
  679. until found;
  680. end;
  681. function TLinkContainer.find(const s:string):boolean;
  682. var
  683. newnode : plinkcontaineritem;
  684. begin
  685. find:=false;
  686. newnode:=plinkcontaineritem(root);
  687. while assigned(newnode) do
  688. begin
  689. if newnode^.data^=s then
  690. begin
  691. find:=true;
  692. exit;
  693. end;
  694. newnode:=plinkcontaineritem(newnode^.next);
  695. end;
  696. end;
  697. {****************************************************************************
  698. TMODULE
  699. ****************************************************************************}
  700. procedure tmodule.setfilename(const fn:string;allowoutput:boolean);
  701. var
  702. p : dirstr;
  703. n : NameStr;
  704. e : ExtStr;
  705. begin
  706. stringdispose(objfilename);
  707. stringdispose(asmfilename);
  708. stringdispose(ppufilename);
  709. stringdispose(staticlibfilename);
  710. stringdispose(sharedlibfilename);
  711. stringdispose(exefilename);
  712. stringdispose(outpath);
  713. stringdispose(path);
  714. { Create names }
  715. fsplit(fn,p,n,e);
  716. n:=FixFileName(n);
  717. { set path }
  718. path:=stringdup(FixPath(p,false));
  719. { obj,asm,ppu names }
  720. p:=path^;
  721. if AllowOutput then
  722. begin
  723. if (OutputUnitDir<>'') then
  724. p:=OutputUnitDir
  725. else
  726. if (OutputExeDir<>'') then
  727. p:=OutputExeDir;
  728. end;
  729. outpath:=stringdup(p);
  730. objfilename:=stringdup(p+n+target_info.objext);
  731. asmfilename:=stringdup(p+n+target_info.asmext);
  732. ppufilename:=stringdup(p+n+target_info.unitext);
  733. { lib and exe could be loaded with a file specified with -o }
  734. if AllowOutput and (OutputFile<>'') then
  735. n:=OutputFile;
  736. staticlibfilename:=stringdup(p+target_os.libprefix+n+target_os.staticlibext);
  737. if target_info.target=target_i386_WIN32 then
  738. sharedlibfilename:=stringdup(p+n+target_os.sharedlibext)
  739. else
  740. sharedlibfilename:=stringdup(p+target_os.libprefix+n+target_os.sharedlibext);
  741. { output dir of exe can be specified separatly }
  742. if AllowOutput and (OutputExeDir<>'') then
  743. p:=OutputExeDir
  744. else
  745. p:=path^;
  746. exefilename:=stringdup(p+n+target_info.exeext);
  747. end;
  748. function tmodule.openppu:boolean;
  749. var
  750. objfiletime,
  751. ppufiletime,
  752. asmfiletime : longint;
  753. begin
  754. openppu:=false;
  755. Message1(unit_t_ppu_loading,ppufilename^);
  756. { Get ppufile time (also check if the file exists) }
  757. ppufiletime:=getnamedfiletime(ppufilename^);
  758. if ppufiletime=-1 then
  759. exit;
  760. { Open the ppufile }
  761. Message1(unit_u_ppu_name,ppufilename^);
  762. ppufile:=new(pppufile,init(ppufilename^));
  763. ppufile^.change_endian:=source_os.endian<>target_os.endian;
  764. if not ppufile^.open then
  765. begin
  766. dispose(ppufile,done);
  767. Message(unit_u_ppu_file_too_short);
  768. exit;
  769. end;
  770. { check for a valid PPU file }
  771. if not ppufile^.CheckPPUId then
  772. begin
  773. dispose(ppufile,done);
  774. Message(unit_u_ppu_invalid_header);
  775. exit;
  776. end;
  777. { check for allowed PPU versions }
  778. if not (ppufile^.GetPPUVersion = CurrentPPUVersion) then
  779. begin
  780. dispose(ppufile,done);
  781. Message1(unit_u_ppu_invalid_version,tostr(ppufile^.GetPPUVersion));
  782. exit;
  783. end;
  784. { check the target processor }
  785. if ttargetcpu(ppufile^.header.cpu)<>target_cpu then
  786. begin
  787. dispose(ppufile,done);
  788. Message(unit_u_ppu_invalid_processor);
  789. exit;
  790. end;
  791. { check target }
  792. if ttarget(ppufile^.header.target)<>target_info.target then
  793. begin
  794. dispose(ppufile,done);
  795. Message(unit_u_ppu_invalid_target);
  796. exit;
  797. end;
  798. { Load values to be access easier }
  799. flags:=ppufile^.header.flags;
  800. crc:=ppufile^.header.checksum;
  801. interface_crc:=ppufile^.header.interface_checksum;
  802. { Show Debug info }
  803. Message1(unit_u_ppu_time,filetimestring(ppufiletime));
  804. Message1(unit_u_ppu_flags,tostr(flags));
  805. Message1(unit_u_ppu_crc,tostr(ppufile^.header.checksum));
  806. Message1(unit_u_ppu_crc,tostr(ppufile^.header.interface_checksum)+' (intfc)');
  807. { check the object and assembler file to see if we need only to
  808. assemble, only if it's not in a library }
  809. do_compile:=false;
  810. if (flags and uf_in_library)=0 then
  811. begin
  812. if (flags and uf_smart_linked)<>0 then
  813. begin
  814. objfiletime:=getnamedfiletime(staticlibfilename^);
  815. Message2(unit_u_check_time,staticlibfilename^,filetimestring(objfiletime));
  816. if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
  817. begin
  818. recompile_reason:=rr_libolder;
  819. Message(unit_u_recompile_staticlib_is_older);
  820. do_compile:=true;
  821. exit;
  822. end;
  823. end;
  824. if (flags and uf_static_linked)<>0 then
  825. begin
  826. { the objectfile should be newer than the ppu file }
  827. objfiletime:=getnamedfiletime(objfilename^);
  828. Message2(unit_u_check_time,objfilename^,filetimestring(objfiletime));
  829. if (ppufiletime<0) or (objfiletime<0) or (ppufiletime>objfiletime) then
  830. begin
  831. { check if assembler file is older than ppu file }
  832. asmfileTime:=GetNamedFileTime(asmfilename^);
  833. Message2(unit_u_check_time,asmfilename^,filetimestring(asmfiletime));
  834. if (asmfiletime<0) or (ppufiletime>asmfiletime) then
  835. begin
  836. Message(unit_u_recompile_obj_and_asm_older);
  837. recompile_reason:=rr_objolder;
  838. do_compile:=true;
  839. exit;
  840. end
  841. else
  842. begin
  843. Message(unit_u_recompile_obj_older_than_asm);
  844. if not(cs_asm_extern in aktglobalswitches) then
  845. begin
  846. do_compile:=true;
  847. recompile_reason:=rr_asmolder;
  848. exit;
  849. end;
  850. end;
  851. end;
  852. end;
  853. end;
  854. openppu:=true;
  855. end;
  856. function tmodule.search_unit(const n : string;onlysource:boolean):boolean;
  857. var
  858. singlepathstring,
  859. filename : string;
  860. Function UnitExists(const ext:string):boolean;
  861. begin
  862. Message1(unit_t_unitsearch,Singlepathstring+filename+ext);
  863. UnitExists:=FileExists(Singlepathstring+FileName+ext);
  864. end;
  865. Function SearchPath(unitpath:string):boolean;
  866. var
  867. found : boolean;
  868. start,i : longint;
  869. ext : string[8];
  870. begin
  871. start:=1;
  872. Found:=false;
  873. repeat
  874. { Create current path to check }
  875. i:=pos(';',unitpath);
  876. if i=0 then
  877. i:=length(unitpath)+1;
  878. singlepathstring:=FixPath(copy(unitpath,start,i-start),false);
  879. delete(unitpath,start,i-start+1);
  880. if not onlysource then
  881. begin
  882. { Check for PPL file }
  883. if not Found then
  884. begin
  885. Found:=UnitExists(target_info.unitlibext);
  886. if Found then
  887. Begin
  888. SetFileName(SinglePathString+FileName,false);
  889. Found:=OpenPPU;
  890. End;
  891. end;
  892. { Check for PPU file }
  893. if not Found then
  894. begin
  895. Found:=UnitExists(target_info.unitext);
  896. if Found then
  897. Begin
  898. SetFileName(SinglePathString+FileName,false);
  899. Found:=OpenPPU;
  900. End;
  901. end;
  902. end;
  903. { Check for Sources }
  904. if not Found then
  905. begin
  906. ppufile:=nil;
  907. do_compile:=true;
  908. recompile_reason:=rr_noppu;
  909. {Check for .pp file}
  910. Found:=UnitExists(target_os.sourceext);
  911. if Found then
  912. Ext:=target_os.sourceext
  913. else
  914. begin
  915. {Check for .pas}
  916. Found:=UnitExists(target_os.pasext);
  917. if Found then
  918. Ext:=target_os.pasext;
  919. end;
  920. stringdispose(mainsource);
  921. if Found then
  922. begin
  923. sources_avail:=true;
  924. {Load Filenames when found}
  925. mainsource:=StringDup(SinglePathString+FileName+Ext);
  926. SetFileName(SinglePathString+FileName,false);
  927. end
  928. else
  929. sources_avail:=false;
  930. end;
  931. until Found or (unitpath='');
  932. SearchPath:=Found;
  933. end;
  934. var
  935. fnd : boolean;
  936. begin
  937. filename:=FixFileName(n);
  938. { try to find unit
  939. 1. cwd
  940. 2. local unit path
  941. 3. global unit path }
  942. fnd:=SearchPath('.');
  943. if (not fnd) and assigned(current_module^.LocalUnitSearchPath) then
  944. fnd:=SearchPath(current_module^.LocalUnitSearchPath^);
  945. if (not fnd) then
  946. fnd:=SearchPath(UnitSearchPath);
  947. { try to find a file with the first 8 chars of the modulename, like
  948. dos }
  949. if (not fnd) and (length(filename)>8) then
  950. begin
  951. filename:=copy(filename,1,8);
  952. fnd:=SearchPath('.');
  953. if (not fnd) and assigned(current_module^.LocalUnitSearchPath) then
  954. fnd:=SearchPath(current_module^.LocalUnitSearchPath^);
  955. if not fnd then
  956. fnd:=SearchPath(UnitSearchPath);
  957. end;
  958. search_unit:=fnd;
  959. end;
  960. procedure tmodule.reset;
  961. var
  962. pm : pdependent_unit;
  963. begin
  964. if assigned(scanner) then
  965. pscannerfile(scanner)^.invalid:=true;
  966. if assigned(globalsymtable) then
  967. begin
  968. dispose(punitsymtable(globalsymtable),done);
  969. globalsymtable:=nil;
  970. end;
  971. if assigned(localsymtable) then
  972. begin
  973. dispose(punitsymtable(localsymtable),done);
  974. localsymtable:=nil;
  975. end;
  976. if assigned(map) then
  977. begin
  978. dispose(map);
  979. map:=nil;
  980. end;
  981. if assigned(ppufile) then
  982. begin
  983. dispose(ppufile,done);
  984. ppufile:=nil;
  985. end;
  986. sourcefiles^.done;
  987. sourcefiles^.init;
  988. imports^.done;
  989. imports^.init;
  990. _exports^.done;
  991. _exports^.init;
  992. used_units.done;
  993. used_units.init;
  994. { all units that depend on this one must be recompiled ! }
  995. pm:=pdependent_unit(dependent_units.first);
  996. while assigned(pm) do
  997. begin
  998. if pm^.u^.in_second_compile then
  999. Comment(v_debug,'No reload already in second compile: '+pm^.u^.modulename^)
  1000. else
  1001. begin
  1002. pm^.u^.do_reload:=true;
  1003. Comment(v_debug,'Reloading '+pm^.u^.modulename^+' needed because '+modulename^+' is reloaded');
  1004. end;
  1005. pm:=pdependent_unit(pm^.next);
  1006. end;
  1007. dependent_units.done;
  1008. dependent_units.init;
  1009. resourcefiles.done;
  1010. resourcefiles.init;
  1011. linkunitofiles.done;
  1012. linkunitofiles.init;
  1013. linkunitstaticlibs.done;
  1014. linkunitstaticlibs.init;
  1015. linkunitsharedlibs.done;
  1016. linkunitsharedlibs.init;
  1017. linkotherofiles.done;
  1018. linkotherofiles.init;
  1019. linkotherstaticlibs.done;
  1020. linkotherstaticlibs.init;
  1021. linkothersharedlibs.done;
  1022. linkothersharedlibs.init;
  1023. uses_imports:=false;
  1024. do_assemble:=false;
  1025. do_compile:=false;
  1026. { sources_avail:=true;
  1027. should not be changed PM }
  1028. compiled:=false;
  1029. in_implementation:=false;
  1030. in_global:=true;
  1031. loaded_from:=nil;
  1032. flags:=0;
  1033. crc:=0;
  1034. interface_crc:=0;
  1035. unitcount:=1;
  1036. recompile_reason:=rr_unknown;
  1037. end;
  1038. constructor tmodule.init(const s:string;_is_unit:boolean);
  1039. var
  1040. p : dirstr;
  1041. n : namestr;
  1042. e : extstr;
  1043. begin
  1044. FSplit(s,p,n,e);
  1045. { Programs have the name program to don't conflict with dup id's }
  1046. if _is_unit then
  1047. modulename:=stringdup(GetUnitAlias(Upper(n)))
  1048. else
  1049. modulename:=stringdup('PROGRAM');
  1050. mainsource:=stringdup(s);
  1051. ppufilename:=nil;
  1052. objfilename:=nil;
  1053. asmfilename:=nil;
  1054. staticlibfilename:=nil;
  1055. sharedlibfilename:=nil;
  1056. exefilename:=nil;
  1057. outpath:=nil;
  1058. { Dos has the famous 8.3 limit :( }
  1059. {$ifdef SHORTASMPREFIX}
  1060. asmprefix:=stringdup(FixFileName('as'));
  1061. {$else}
  1062. asmprefix:=stringdup(FixFileName(n));
  1063. {$endif}
  1064. path:=nil;
  1065. setfilename(p+n,true);
  1066. localunitsearchpath:=nil;
  1067. localobjectsearchpath:=nil;
  1068. localincludesearchpath:=nil;
  1069. locallibrarysearchpath:=nil;
  1070. used_units.init;
  1071. dependent_units.init;
  1072. new(sourcefiles,init);
  1073. resourcefiles.init;
  1074. linkunitofiles.init;
  1075. linkunitstaticlibs.init;
  1076. linkunitsharedlibs.init;
  1077. linkotherofiles.init;
  1078. linkotherstaticlibs.init;
  1079. linkothersharedlibs.init;
  1080. ppufile:=nil;
  1081. scanner:=nil;
  1082. map:=nil;
  1083. globalsymtable:=nil;
  1084. localsymtable:=nil;
  1085. loaded_from:=nil;
  1086. flags:=0;
  1087. crc:=0;
  1088. interface_crc:=0;
  1089. do_reload:=false;
  1090. unitcount:=1;
  1091. inc(global_unit_count);
  1092. unit_index:=global_unit_count;
  1093. do_assemble:=false;
  1094. do_compile:=false;
  1095. sources_avail:=true;
  1096. compiled:=false;
  1097. recompile_reason:=rr_unknown;
  1098. in_second_load:=false;
  1099. in_compile:=false;
  1100. in_second_compile:=false;
  1101. in_implementation:=false;
  1102. in_global:=true;
  1103. is_unit:=_is_unit;
  1104. islibrary:=false;
  1105. uses_imports:=false;
  1106. imports:=new(plinkedlist,init);
  1107. _exports:=new(plinkedlist,init);
  1108. { search the PPU file if it is an unit }
  1109. if is_unit then
  1110. search_unit(modulename^,false);
  1111. end;
  1112. destructor tmodule.done;
  1113. {$ifdef MEMDEBUG}
  1114. var
  1115. d : tmemdebug;
  1116. {$endif}
  1117. begin
  1118. if assigned(map) then
  1119. dispose(map);
  1120. if assigned(ppufile) then
  1121. dispose(ppufile,done);
  1122. ppufile:=nil;
  1123. if assigned(imports) then
  1124. dispose(imports,done);
  1125. imports:=nil;
  1126. if assigned(_exports) then
  1127. dispose(_exports,done);
  1128. _exports:=nil;
  1129. if assigned(scanner) then
  1130. pscannerfile(scanner)^.invalid:=true;
  1131. if assigned(sourcefiles) then
  1132. dispose(sourcefiles,done);
  1133. sourcefiles:=nil;
  1134. used_units.done;
  1135. dependent_units.done;
  1136. resourcefiles.done;
  1137. linkunitofiles.done;
  1138. linkunitstaticlibs.done;
  1139. linkunitsharedlibs.done;
  1140. linkotherofiles.done;
  1141. linkotherstaticlibs.done;
  1142. linkothersharedlibs.done;
  1143. stringdispose(objfilename);
  1144. stringdispose(asmfilename);
  1145. stringdispose(ppufilename);
  1146. stringdispose(staticlibfilename);
  1147. stringdispose(sharedlibfilename);
  1148. stringdispose(exefilename);
  1149. stringdispose(outpath);
  1150. stringdispose(path);
  1151. stringdispose(modulename);
  1152. stringdispose(mainsource);
  1153. stringdispose(asmprefix);
  1154. stringdispose(localunitsearchpath);
  1155. stringdispose(localobjectsearchpath);
  1156. stringdispose(localincludesearchpath);
  1157. stringdispose(locallibrarysearchpath);
  1158. {$ifdef MEMDEBUG}
  1159. d.init('symtable');
  1160. {$endif}
  1161. if assigned(globalsymtable) then
  1162. dispose(punitsymtable(globalsymtable),done);
  1163. globalsymtable:=nil;
  1164. if assigned(localsymtable) then
  1165. dispose(punitsymtable(localsymtable),done);
  1166. localsymtable:=nil;
  1167. {$ifdef MEMDEBUG}
  1168. d.done;
  1169. {$endif}
  1170. inherited done;
  1171. end;
  1172. {****************************************************************************
  1173. TUSED_UNIT
  1174. ****************************************************************************}
  1175. constructor tused_unit.init(_u : pmodule;intface:boolean);
  1176. begin
  1177. u:=_u;
  1178. in_interface:=intface;
  1179. in_uses:=false;
  1180. is_stab_written:=false;
  1181. loaded:=true;
  1182. name:=stringdup(_u^.modulename^);
  1183. checksum:=_u^.crc;
  1184. interface_checksum:=_u^.interface_crc;
  1185. unitid:=0;
  1186. end;
  1187. constructor tused_unit.init_to_load(const n:string;c,intfc:longint;intface:boolean);
  1188. begin
  1189. u:=nil;
  1190. in_interface:=intface;
  1191. in_uses:=false;
  1192. is_stab_written:=false;
  1193. loaded:=false;
  1194. name:=stringdup(n);
  1195. checksum:=c;
  1196. interface_checksum:=intfc;
  1197. unitid:=0;
  1198. end;
  1199. destructor tused_unit.done;
  1200. begin
  1201. stringdispose(name);
  1202. inherited done;
  1203. end;
  1204. {****************************************************************************
  1205. TDENPENDENT_UNIT
  1206. ****************************************************************************}
  1207. constructor tdependent_unit.init(_u : pmodule);
  1208. begin
  1209. u:=_u;
  1210. end;
  1211. end.
  1212. {
  1213. $Log$
  1214. Revision 1.106 1999-11-04 10:54:02 peter
  1215. + -Ua<oldname>=<newname> unit alias support
  1216. Revision 1.105 1999/10/28 13:14:00 pierre
  1217. * allow doubles in TLinkContainer needed for double libraries
  1218. Revision 1.104 1999/09/27 23:40:12 peter
  1219. * fixed macro within macro endless-loop
  1220. Revision 1.103 1999/09/16 08:00:50 pierre
  1221. + compiled_module to avoid wrong file info when load PPU files
  1222. Revision 1.102 1999/08/31 15:51:10 pierre
  1223. * in_second_compile cleaned up, in_compile and in_second_load added
  1224. Revision 1.101 1999/08/27 10:43:20 pierre
  1225. + interface CRC check with ifdef Test_double_checksum added
  1226. Revision 1.100 1999/08/24 13:14:01 peter
  1227. * MEMDEBUG to see the sizes of asmlist,asmsymbols,symtables
  1228. Revision 1.99 1999/07/18 14:47:26 florian
  1229. * bug 487 fixed, (inc(<property>) isn't allowed)
  1230. * more fixes to compile with Delphi
  1231. Revision 1.98 1999/07/18 10:19:51 florian
  1232. * made it compilable with Dlephi 4 again
  1233. + fixed problem with large stack allocations on win32
  1234. Revision 1.97 1999/07/14 21:19:03 florian
  1235. + implemented a better error message if a PPU file isn't found as suggested
  1236. by Lee John
  1237. Revision 1.96 1999/07/03 00:29:47 peter
  1238. * new link writing to the ppu, one .ppu is needed for all link types,
  1239. static (.o) is now always created also when smartlinking is used
  1240. Revision 1.95 1999/05/13 21:59:25 peter
  1241. * removed oldppu code
  1242. * warning if objpas is loaded from uses
  1243. * first things for new deref writing
  1244. Revision 1.94 1999/05/04 21:44:42 florian
  1245. * changes to compile it with Delphi 4.0
  1246. Revision 1.93 1999/04/26 13:31:29 peter
  1247. * release storenumber,double_checksum
  1248. Revision 1.92 1999/04/25 15:08:36 peter
  1249. * small fixes for double_checksum
  1250. Revision 1.91 1999/04/21 09:43:36 peter
  1251. * storenumber works
  1252. * fixed some typos in double_checksum
  1253. + incompatible types type1 and type2 message (with storenumber)
  1254. Revision 1.90 1999/04/14 09:14:48 peter
  1255. * first things to store the symbol/def number in the ppu
  1256. Revision 1.89 1999/04/07 15:39:29 pierre
  1257. + double_checksum code added
  1258. Revision 1.88 1999/03/25 16:55:29 peter
  1259. + unitpath,librarypath,includepath,objectpath directives
  1260. Revision 1.87 1999/02/16 00:48:23 peter
  1261. * save in the ppu if linked with obj file instead of using the
  1262. library flag, so the .inc files are also checked
  1263. Revision 1.86 1999/02/05 08:54:24 pierre
  1264. + linkofiles splitted inot linkofiles and linkunitfiles
  1265. because linkofiles must be stored with directory
  1266. to enabled linking of different objects with same name
  1267. in a different directory
  1268. Revision 1.85 1999/01/14 21:47:11 peter
  1269. * status.currentmodule is now also updated
  1270. + status.currentsourcepath
  1271. Revision 1.84 1999/01/14 11:38:39 daniel
  1272. * Exe name derived from target_info instead of target_os
  1273. Revision 1.83 1999/01/13 15:02:00 daniel
  1274. * Tinputfile.readbuf eof bugfix
  1275. Revision 1.82 1999/01/12 14:25:26 peter
  1276. + BrowserLog for browser.log generation
  1277. + BrowserCol for browser info in TCollections
  1278. * released all other UseBrowser
  1279. Revision 1.81 1998/12/28 23:26:14 peter
  1280. + resource file handling ($R directive) for Win32
  1281. Revision 1.80 1998/12/16 00:27:19 peter
  1282. * removed some obsolete version checks
  1283. Revision 1.79 1998/12/11 00:03:14 peter
  1284. + globtype,tokens,version unit splitted from globals
  1285. Revision 1.78 1998/12/04 10:18:07 florian
  1286. * some stuff for procedures of object added
  1287. * bug with overridden virtual constructors fixed (reported by Italo Gomes)
  1288. Revision 1.77 1998/12/02 16:23:37 jonas
  1289. * changed "if longintvar in set" to case or "if () or () .." statements
  1290. * tree.pas: changed inlinenumber (and associated constructor/vars) to a byte
  1291. Revision 1.76 1998/12/01 12:51:19 peter
  1292. * fixed placing of ppas.sh and link.res when using -FE
  1293. Revision 1.75 1998/11/16 15:41:40 peter
  1294. * tp7 didn't like my ifopt H+ :(
  1295. Revision 1.74 1998/11/16 12:18:01 peter
  1296. * H+ fixes
  1297. Revision 1.73 1998/11/16 11:28:58 pierre
  1298. * stackcheck removed for i386_win32
  1299. * exportlist does not crash at least !!
  1300. (was need for tests dir !)z
  1301. Revision 1.72 1998/11/15 16:32:35 florian
  1302. * some stuff of Pavel implement (win32 dll creation)
  1303. * bug with ansistring function results fixed
  1304. Revision 1.71 1998/11/06 09:45:40 pierre
  1305. * bug on errors (file used after dispose !) fixed
  1306. Revision 1.70 1998/11/03 11:33:14 peter
  1307. + search_unit arg to only search for sources
  1308. Revision 1.69 1998/10/29 11:35:44 florian
  1309. * some dll support for win32
  1310. * fixed assembler writing for PalmOS
  1311. Revision 1.68 1998/10/27 10:22:34 florian
  1312. + First things for win32 export sections
  1313. Revision 1.67 1998/10/26 22:23:29 peter
  1314. + fixpath() has an extra option to allow a ./ as path
  1315. Revision 1.66 1998/10/19 18:07:11 peter
  1316. + external dll_name name func support for linux
  1317. Revision 1.65 1998/10/15 12:22:25 pierre
  1318. * close include files immediately after end reading
  1319. instead of waiting until unit compilation ended !
  1320. Revision 1.64 1998/10/14 13:38:19 peter
  1321. * fixed path with staticlib/objects in ppufiles
  1322. Revision 1.63 1998/10/14 11:02:49 daniel
  1323. * Stupid typo fixed.
  1324. Revision 1.62 1998/10/14 10:59:37 daniel
  1325. * Staticlibfilename now doesn't include path.
  1326. Revision 1.61 1998/10/14 10:57:25 daniel
  1327. * Dirstr, namestr, extstr.
  1328. * $V+ to prevent Peter from forgetting this.
  1329. * OS/2 compiler uses 8.3 filenames to support running the compiler on an old
  1330. DOS FAT partition.
  1331. Revision 1.60 1998/10/14 10:45:07 pierre
  1332. * ppu problems for m68k fixed (at least in cross compiling)
  1333. * one last memory leak for sysamiga fixed
  1334. * the amiga RTL compiles now completely !!
  1335. Revision 1.59 1998/10/13 14:01:07 peter
  1336. * fixed -al
  1337. Revision 1.58 1998/10/12 11:59:00 peter
  1338. + show name and date of .o and .s files which the compiler checks
  1339. Revision 1.57 1998/10/09 16:36:03 pierre
  1340. * some memory leaks specific to usebrowser define fixed
  1341. * removed tmodule.implsymtable (was like tmodule.localsymtable)
  1342. Revision 1.56 1998/10/09 08:56:26 pierre
  1343. * several memory leaks fixed
  1344. Revision 1.55 1998/10/08 23:28:54 peter
  1345. * -vu shows unit info, -vt shows tried/used files
  1346. Revision 1.54 1998/10/08 17:17:19 pierre
  1347. * current_module old scanner tagged as invalid if unit is recompiled
  1348. + added ppheap for better info on tracegetmem of heaptrc
  1349. (adds line column and file index)
  1350. * several memory leaks removed ith help of heaptrc !!
  1351. Revision 1.53 1998/10/08 13:48:43 peter
  1352. * fixed memory leaks for do nothing source
  1353. * fixed unit interdependency
  1354. Revision 1.52 1998/10/06 22:09:48 peter
  1355. * fixed for compiling with 0.99.8 due circular units
  1356. Revision 1.51 1998/10/06 17:16:47 pierre
  1357. * some memory leaks fixed (thanks to Peter for heaptrc !)
  1358. Revision 1.50 1998/09/30 16:43:34 peter
  1359. * fixed unit interdependency with circular uses
  1360. Revision 1.49 1998/09/28 16:57:20 pierre
  1361. * changed all length(p^.value_str^) into str_length(p)
  1362. to get it work with and without ansistrings
  1363. * changed sourcefiles field of tmodule to a pointer
  1364. Revision 1.48 1998/09/24 23:46:34 peter
  1365. + outputdir support
  1366. Revision 1.47 1998/09/22 17:13:43 pierre
  1367. + browsing updated and developed
  1368. records and objects fields are also stored
  1369. Revision 1.46 1998/09/21 08:45:10 pierre
  1370. + added vmt_offset in tobjectdef.write for fututre use
  1371. (first steps to have objects without vmt if no virtual !!)
  1372. + added fpu_used field for tabstractprocdef :
  1373. sets this level to 2 if the functions return with value in FPU
  1374. (is then set to correct value at parsing of implementation)
  1375. THIS MIGHT refuse some code with FPU expression too complex
  1376. that were accepted before and even in some cases
  1377. that don't overflow in fact
  1378. ( like if f : float; is a forward that finally in implementation
  1379. only uses one fpu register !!)
  1380. Nevertheless I think that it will improve security on
  1381. FPU operations !!
  1382. * most other changes only for UseBrowser code
  1383. (added symtable references for record and objects)
  1384. local switch for refs to args and local of each function
  1385. (static symtable still missing)
  1386. UseBrowser still not stable and probably broken by
  1387. the definition hash array !!
  1388. Revision 1.45 1998/09/18 09:58:51 peter
  1389. * -s doesn't require the .o to be available, this allows compiling of
  1390. everything on other platforms (profiling the windows.pp loading ;)
  1391. Revision 1.44 1998/09/10 13:51:32 peter
  1392. * tp compiler also uses 'as' as asmprefix
  1393. Revision 1.43 1998/09/03 17:08:45 pierre
  1394. * better lines for stabs
  1395. (no scroll back to if before else part
  1396. no return to case line at jump outside case)
  1397. + source lines also if not in order
  1398. Revision 1.42 1998/09/03 11:24:00 peter
  1399. * moved more inputfile things from tscannerfile to tinputfile
  1400. * changed ifdef Sourceline to cs_asm_source
  1401. Revision 1.41 1998/08/26 15:35:30 peter
  1402. * fixed scannerfiles for macros
  1403. + $I %<environment>%
  1404. Revision 1.40 1998/08/26 10:08:48 peter
  1405. * fixed problem with libprefix at the wrong place
  1406. * fixed lib generation with smartlinking and no -CS used
  1407. Revision 1.39 1998/08/25 16:44:16 pierre
  1408. * openppu was true even if the object file is missing
  1409. this lead to trying to open a filename without extension
  1410. and prevented the 'make cycle' to work for win32
  1411. Revision 1.38 1998/08/19 10:06:12 peter
  1412. * fixed filenames and removedir which supports slash at the end
  1413. Revision 1.37 1998/08/18 20:52:19 peter
  1414. * renamed in_main to in_global which is more logical
  1415. Revision 1.36 1998/08/17 10:10:07 peter
  1416. - removed OLDPPU
  1417. Revision 1.35 1998/08/17 09:17:44 peter
  1418. * static/shared linking updates
  1419. Revision 1.34 1998/08/14 21:56:31 peter
  1420. * setting the outputfile using -o works now to create static libs
  1421. Revision 1.33 1998/08/11 14:09:08 peter
  1422. * fixed some messages and smaller msgtxt.inc
  1423. Revision 1.32 1998/08/10 14:49:58 peter
  1424. + localswitches, moduleswitches, globalswitches splitting
  1425. Revision 1.31 1998/07/14 14:46:48 peter
  1426. * released NEWINPUT
  1427. Revision 1.30 1998/07/07 11:19:55 peter
  1428. + NEWINPUT for a better inputfile and scanner object
  1429. Revision 1.29 1998/06/25 10:51:00 pierre
  1430. * removed a remaining ifndef NEWPPU
  1431. replaced by ifdef OLDPPU
  1432. * added uf_finalize to ppu unit
  1433. Revision 1.28 1998/06/25 08:48:12 florian
  1434. * first version of rtti support
  1435. Revision 1.27 1998/06/24 14:48:34 peter
  1436. * ifdef newppu -> ifndef oldppu
  1437. Revision 1.26 1998/06/17 14:36:19 peter
  1438. * forgot an $ifndef OLDPPU :(
  1439. Revision 1.25 1998/06/17 14:10:11 peter
  1440. * small os2 fixes
  1441. * fixed interdependent units with newppu (remake3 under linux works now)
  1442. Revision 1.24 1998/06/16 08:56:20 peter
  1443. + targetcpu
  1444. * cleaner pmodules for newppu
  1445. Revision 1.23 1998/06/15 14:44:36 daniel
  1446. * BP updates.
  1447. Revision 1.22 1998/06/14 18:25:41 peter
  1448. * small fix with crc in newppu
  1449. Revision 1.21 1998/06/13 00:10:05 peter
  1450. * working browser and newppu
  1451. * some small fixes against crashes which occured in bp7 (but not in
  1452. fpc?!)
  1453. Revision 1.20 1998/06/12 14:50:48 peter
  1454. * removed the tree dependency to types.pas
  1455. * long_fil.pas support (not fully tested yet)
  1456. Revision 1.19 1998/06/12 10:32:26 pierre
  1457. * column problem hopefully solved
  1458. + C vars declaration changed
  1459. Revision 1.18 1998/06/11 13:58:07 peter
  1460. * small fix to let newppu compile
  1461. Revision 1.17 1998/06/09 16:01:40 pierre
  1462. + added procedure directive parsing for procvars
  1463. (accepted are popstack cdecl and pascal)
  1464. + added C vars with the following syntax
  1465. var C calias 'true_c_name';(can be followed by external)
  1466. reason is that you must add the Cprefix
  1467. which is target dependent
  1468. Revision 1.16 1998/06/04 10:42:19 pierre
  1469. * small bug fix in load_ppu or openppu
  1470. Revision 1.15 1998/05/28 14:37:53 peter
  1471. * default programname is PROGRAM (like TP7) to avoid dup id's
  1472. Revision 1.14 1998/05/27 19:45:02 peter
  1473. * symtable.pas splitted into includefiles
  1474. * symtable adapted for $ifndef OLDPPU
  1475. Revision 1.13 1998/05/23 01:21:05 peter
  1476. + aktasmmode, aktoptprocessor, aktoutputformat
  1477. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1478. + $LIBNAME to set the library name where the unit will be put in
  1479. * splitted cgi386 a bit (codeseg to large for bp7)
  1480. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1481. Revision 1.12 1998/05/20 09:42:33 pierre
  1482. + UseTokenInfo now default
  1483. * unit in interface uses and implementation uses gives error now
  1484. * only one error for unknown symbol (uses lastsymknown boolean)
  1485. the problem came from the label code !
  1486. + first inlined procedures and function work
  1487. (warning there might be allowed cases were the result is still wrong !!)
  1488. * UseBrower updated gives a global list of all position of all used symbols
  1489. with switch -gb
  1490. Revision 1.11 1998/05/12 10:46:59 peter
  1491. * moved printstatus to verb_def
  1492. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1493. prefix like error: warning: and is included in V_Default
  1494. * fixed some messages
  1495. * first time parameter scan is only for -v and -T
  1496. - removed old style messages
  1497. Revision 1.10 1998/05/11 13:07:53 peter
  1498. + $ifndef OLDPPU for the new ppuformat
  1499. + $define GDB not longer required
  1500. * removed all warnings and stripped some log comments
  1501. * no findfirst/findnext anymore to remove smartlink *.o files
  1502. Revision 1.9 1998/05/06 15:04:20 pierre
  1503. + when trying to find source files of a ppufile
  1504. check the includepathlist for included files
  1505. the main file must still be in the same directory
  1506. Revision 1.8 1998/05/04 17:54:25 peter
  1507. + smartlinking works (only case jumptable left todo)
  1508. * redesign of systems.pas to support assemblers and linkers
  1509. + Unitname is now also in the PPU-file, increased version to 14
  1510. Revision 1.7 1998/05/01 16:38:44 florian
  1511. * handling of private and protected fixed
  1512. + change_keywords_to_tp implemented to remove
  1513. keywords which aren't supported by tp
  1514. * break and continue are now symbols of the system unit
  1515. + widestring, longstring and ansistring type released
  1516. Revision 1.6 1998/05/01 07:43:53 florian
  1517. + basics for rtti implemented
  1518. + switch $m (generate rtti for published sections)
  1519. Revision 1.5 1998/04/30 15:59:40 pierre
  1520. * GDB works again better :
  1521. correct type info in one pass
  1522. + UseTokenInfo for better source position
  1523. * fixed one remaining bug in scanner for line counts
  1524. * several little fixes
  1525. Revision 1.4 1998/04/29 10:33:52 pierre
  1526. + added some code for ansistring (not complete nor working yet)
  1527. * corrected operator overloading
  1528. * corrected nasm output
  1529. + started inline procedures
  1530. + added starstarn : use ** for exponentiation (^ gave problems)
  1531. + started UseTokenInfo cond to get accurate positions
  1532. Revision 1.3 1998/04/27 23:10:28 peter
  1533. + new scanner
  1534. * $makelib -> if smartlink
  1535. * small filename fixes pmodule.setfilename
  1536. * moved import from files.pas -> import.pas
  1537. Revision 1.2 1998/04/21 10:16:47 peter
  1538. * patches from strasbourg
  1539. * objects is not used anymore in the fpc compiled version
  1540. }