files.pas 49 KB

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