files.pas 53 KB

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