files.pas 53 KB

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