files.pas 52 KB

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