files.pas 51 KB

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