files.pas 52 KB

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