files.pas 53 KB

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