files.pas 54 KB

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