files.pas 52 KB

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