fppu.pas 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the first loading and searching of the modules
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit fppu;
  19. {$i fpcdefs.inc}
  20. { close ppufiles on system that are
  21. short on file handles like DOS system PM }
  22. {$ifdef GO32V2}
  23. {$define SHORT_ON_FILE_HANDLES}
  24. {$endif GO32V2}
  25. interface
  26. uses
  27. cutils,cclasses,
  28. globtype,globals,finput,fmodule,
  29. symbase,symppu,ppu;
  30. type
  31. tppumodule = class(tmodule)
  32. ppufile : tcompilerppufile; { the PPU file }
  33. sourcefn : pstring; { Source specified with "uses .. in '..'" }
  34. {$ifdef Test_Double_checksum}
  35. crc_array : pointer;
  36. crc_size : longint;
  37. crc_array2 : pointer;
  38. crc_size2 : longint;
  39. {$endif def Test_Double_checksum}
  40. constructor create(LoadedFrom:TModule;const s:string;const fn:string;_is_unit:boolean);
  41. destructor destroy;override;
  42. procedure reset;override;
  43. function openppu:boolean;
  44. procedure getppucrc;
  45. procedure writeppu;
  46. procedure loadppu;
  47. private
  48. function search_unit(onlysource,shortname:boolean):boolean;
  49. procedure load_interface;
  50. procedure load_implementation;
  51. procedure load_symtable_refs;
  52. procedure load_usedunits;
  53. procedure writeusedmacro(p:TNamedIndexItem;arg:pointer);
  54. procedure writeusedmacros;
  55. procedure writesourcefiles;
  56. procedure writeusedunit;
  57. procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
  58. procedure putasmsymbol_in_idx(s:tnamedindexitem;arg:pointer);
  59. procedure writeasmsymbols;
  60. procedure readusedmacros;
  61. procedure readsourcefiles;
  62. procedure readloadunit;
  63. procedure readlinkcontainer(var p:tlinkcontainer);
  64. procedure readasmsymbols;
  65. end;
  66. function registerunit(callermodule:tmodule;const s : stringid;const fn:string) : tppumodule;
  67. implementation
  68. uses
  69. verbose,systems,version,
  70. symtable,
  71. scanner,
  72. aasmbase,
  73. parser;
  74. {****************************************************************************
  75. TPPUMODULE
  76. ****************************************************************************}
  77. constructor tppumodule.create(LoadedFrom:TModule;const s:string;const fn:string;_is_unit:boolean);
  78. begin
  79. inherited create(LoadedFrom,s,_is_unit);
  80. ppufile:=nil;
  81. sourcefn:=stringdup(fn);
  82. end;
  83. destructor tppumodule.Destroy;
  84. begin
  85. if assigned(ppufile) then
  86. ppufile.free;
  87. ppufile:=nil;
  88. stringdispose(sourcefn);
  89. inherited Destroy;
  90. end;
  91. procedure tppumodule.reset;
  92. begin
  93. if assigned(ppufile) then
  94. begin
  95. ppufile.free;
  96. ppufile:=nil;
  97. end;
  98. inherited reset;
  99. end;
  100. function tppumodule.openppu:boolean;
  101. var
  102. ppufiletime : longint;
  103. begin
  104. openppu:=false;
  105. Message1(unit_t_ppu_loading,ppufilename^);
  106. { Get ppufile time (also check if the file exists) }
  107. ppufiletime:=getnamedfiletime(ppufilename^);
  108. if ppufiletime=-1 then
  109. exit;
  110. { Open the ppufile }
  111. Message1(unit_u_ppu_name,ppufilename^);
  112. ppufile:=tcompilerppufile.create(ppufilename^);
  113. if not ppufile.openfile then
  114. begin
  115. ppufile.free;
  116. ppufile:=nil;
  117. Message(unit_u_ppu_file_too_short);
  118. exit;
  119. end;
  120. { check for a valid PPU file }
  121. if not ppufile.CheckPPUId then
  122. begin
  123. ppufile.free;
  124. ppufile:=nil;
  125. Message(unit_u_ppu_invalid_header);
  126. exit;
  127. end;
  128. { check for allowed PPU versions }
  129. if not (ppufile.GetPPUVersion = CurrentPPUVersion) then
  130. begin
  131. Message1(unit_u_ppu_invalid_version,tostr(ppufile.GetPPUVersion));
  132. ppufile.free;
  133. ppufile:=nil;
  134. exit;
  135. end;
  136. { check the target processor }
  137. if tsystemcpu(ppufile.header.cpu)<>target_cpu then
  138. begin
  139. ppufile.free;
  140. ppufile:=nil;
  141. Message(unit_u_ppu_invalid_processor);
  142. exit;
  143. end;
  144. { check target }
  145. if tsystem(ppufile.header.target)<>target_info.system then
  146. begin
  147. ppufile.free;
  148. ppufile:=nil;
  149. Message(unit_u_ppu_invalid_target);
  150. exit;
  151. end;
  152. {$ifdef cpufpemu}
  153. { check if floating point emulation is on?}
  154. if ((ppufile.header.flags and uf_fpu_emulation)<>0) and
  155. (cs_fp_emulation in aktmoduleswitches) then
  156. begin
  157. ppufile.free;
  158. ppufile:=nil;
  159. Message(unit_u_ppu_invalid_fpumode);
  160. exit;
  161. end;
  162. {$endif cpufpemu}
  163. { Load values to be access easier }
  164. flags:=ppufile.header.flags;
  165. crc:=ppufile.header.checksum;
  166. interface_crc:=ppufile.header.interface_checksum;
  167. { Show Debug info }
  168. Message1(unit_u_ppu_time,filetimestring(ppufiletime));
  169. Message1(unit_u_ppu_flags,tostr(flags));
  170. Message1(unit_u_ppu_crc,hexstr(ppufile.header.checksum,8));
  171. Message1(unit_u_ppu_crc,hexstr(ppufile.header.interface_checksum,8)+' (intfc)');
  172. do_compile:=false;
  173. openppu:=true;
  174. end;
  175. function tppumodule.search_unit(onlysource,shortname:boolean):boolean;
  176. var
  177. singlepathstring,
  178. filename : string;
  179. Function UnitExists(const ext:string;var foundfile:string):boolean;
  180. begin
  181. Message1(unit_t_unitsearch,Singlepathstring+filename+ext);
  182. UnitExists:=FindFile(FileName+ext,Singlepathstring,foundfile);
  183. end;
  184. Function PPUSearchPath(const s:string):boolean;
  185. var
  186. found : boolean;
  187. hs : string;
  188. begin
  189. Found:=false;
  190. singlepathstring:=FixPath(s,false);
  191. { Check for PPU file }
  192. Found:=UnitExists(target_info.unitext,hs);
  193. if Found then
  194. Begin
  195. SetFileName(hs,false);
  196. Found:=OpenPPU;
  197. End;
  198. PPUSearchPath:=Found;
  199. end;
  200. Function SourceSearchPath(const s:string):boolean;
  201. var
  202. found : boolean;
  203. hs : string;
  204. begin
  205. Found:=false;
  206. singlepathstring:=FixPath(s,false);
  207. { Check for Sources }
  208. ppufile:=nil;
  209. do_compile:=true;
  210. recompile_reason:=rr_noppu;
  211. {Check for .pp file}
  212. Found:=UnitExists(target_info.sourceext,hs);
  213. if not Found then
  214. begin
  215. { Check for .pas }
  216. Found:=UnitExists(target_info.pasext,hs);
  217. end;
  218. stringdispose(mainsource);
  219. if Found then
  220. begin
  221. sources_avail:=true;
  222. { Load Filenames when found }
  223. mainsource:=StringDup(hs);
  224. SetFileName(hs,false);
  225. end
  226. else
  227. sources_avail:=false;
  228. SourceSearchPath:=Found;
  229. end;
  230. Function SearchPath(const s:string):boolean;
  231. var
  232. found : boolean;
  233. begin
  234. { First check for a ppu, then for the source }
  235. found:=false;
  236. if not onlysource then
  237. found:=PPUSearchPath(s);
  238. if not found then
  239. found:=SourceSearchPath(s);
  240. SearchPath:=found;
  241. end;
  242. Function SearchPathList(list:TSearchPathList):boolean;
  243. var
  244. hp : TStringListItem;
  245. found : boolean;
  246. begin
  247. found:=false;
  248. hp:=TStringListItem(list.First);
  249. while assigned(hp) do
  250. begin
  251. found:=SearchPath(hp.Str);
  252. if found then
  253. break;
  254. hp:=TStringListItem(hp.next);
  255. end;
  256. SearchPathList:=found;
  257. end;
  258. var
  259. fnd : boolean;
  260. hs : string;
  261. begin
  262. if shortname then
  263. filename:=FixFileName(Copy(realmodulename^,1,8))
  264. else
  265. filename:=FixFileName(realmodulename^);
  266. { try to find unit
  267. 1. look for ppu in cwd
  268. 2. look for ppu in outputpath if set, this is tp7 compatible (PFV)
  269. 3. look for the specified source file (from the uses line)
  270. 4. look for source in cwd
  271. 5. local unit pathlist
  272. 6. global unit pathlist }
  273. fnd:=false;
  274. if not onlysource then
  275. begin
  276. fnd:=PPUSearchPath('.');
  277. if (not fnd) and (outputpath^<>'') then
  278. fnd:=PPUSearchPath(outputpath^);
  279. end;
  280. if (not fnd) and (sourcefn^<>'') then
  281. begin
  282. { the full filename is specified so we can't use here the
  283. searchpath (PFV) }
  284. Message1(unit_t_unitsearch,AddExtension(sourcefn^,target_info.sourceext));
  285. fnd:=FindFile(AddExtension(sourcefn^,target_info.sourceext),'',hs);
  286. if not fnd then
  287. begin
  288. Message1(unit_t_unitsearch,AddExtension(sourcefn^,target_info.pasext));
  289. fnd:=FindFile(AddExtension(sourcefn^,target_info.pasext),'',hs);
  290. end;
  291. if fnd then
  292. begin
  293. sources_avail:=true;
  294. do_compile:=true;
  295. recompile_reason:=rr_noppu;
  296. stringdispose(mainsource);
  297. mainsource:=StringDup(hs);
  298. SetFileName(hs,false);
  299. end;
  300. end;
  301. if not fnd then
  302. fnd:=SourceSearchPath('.');
  303. if (not fnd) and Assigned(Loaded_From) then
  304. fnd:=SearchPathList(Loaded_From.LocalUnitSearchPath);
  305. if not fnd then
  306. fnd:=SearchPathList(UnitSearchPath);
  307. { try to find a file with the first 8 chars of the modulename, like
  308. dos }
  309. if (not fnd) and (length(filename)>8) then
  310. begin
  311. filename:=copy(filename,1,8);
  312. fnd:=SearchPath('.');
  313. if (not fnd) then
  314. fnd:=SearchPathList(LocalUnitSearchPath);
  315. if not fnd then
  316. fnd:=SearchPathList(UnitSearchPath);
  317. end;
  318. search_unit:=fnd;
  319. end;
  320. {**********************************
  321. PPU Reading/Writing Helpers
  322. ***********************************}
  323. procedure tppumodule.writeusedmacro(p:TNamedIndexItem;arg:pointer);
  324. begin
  325. if tmacro(p).is_used or tmacro(p).defined_at_startup then
  326. begin
  327. ppufile.putstring(p.name);
  328. ppufile.putbyte(byte(tmacro(p).defined_at_startup));
  329. ppufile.putbyte(byte(tmacro(p).is_used));
  330. end;
  331. end;
  332. procedure tppumodule.writeusedmacros;
  333. begin
  334. ppufile.do_crc:=false;
  335. tscannerfile(scanner).macros.foreach({$ifdef FPCPROCVAR}@{$endif}writeusedmacro,nil);
  336. ppufile.writeentry(ibusedmacros);
  337. ppufile.do_crc:=true;
  338. end;
  339. procedure tppumodule.writesourcefiles;
  340. var
  341. hp : tinputfile;
  342. i,j : longint;
  343. begin
  344. { second write the used source files }
  345. ppufile.do_crc:=false;
  346. hp:=sourcefiles.files;
  347. { write source files directly in good order }
  348. j:=0;
  349. while assigned(hp) do
  350. begin
  351. inc(j);
  352. hp:=hp.ref_next;
  353. end;
  354. while j>0 do
  355. begin
  356. hp:=sourcefiles.files;
  357. for i:=1 to j-1 do
  358. hp:=hp.ref_next;
  359. ppufile.putstring(hp.name^);
  360. ppufile.putlongint(hp.getfiletime);
  361. dec(j);
  362. end;
  363. ppufile.writeentry(ibsourcefiles);
  364. ppufile.do_crc:=true;
  365. end;
  366. procedure tppumodule.writeusedunit;
  367. var
  368. hp : tused_unit;
  369. begin
  370. { renumber the units for derefence writing }
  371. numberunits;
  372. { write a reference for each used unit }
  373. hp:=tused_unit(used_units.first);
  374. while assigned(hp) do
  375. begin
  376. { implementation units should not change
  377. the CRC PM }
  378. ppufile.do_crc:=hp.in_interface;
  379. ppufile.putstring(hp.u.realmodulename^);
  380. { the checksum should not affect the crc of this unit ! (PFV) }
  381. ppufile.do_crc:=false;
  382. ppufile.putlongint(longint(hp.checksum));
  383. ppufile.putlongint(longint(hp.interface_checksum));
  384. ppufile.putbyte(byte(hp.in_interface));
  385. ppufile.do_crc:=true;
  386. hp:=tused_unit(hp.next);
  387. end;
  388. ppufile.do_interface_crc:=true;
  389. ppufile.writeentry(ibloadunit);
  390. end;
  391. procedure tppumodule.writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
  392. var
  393. hcontainer : tlinkcontainer;
  394. s : string;
  395. mask : cardinal;
  396. begin
  397. hcontainer:=TLinkContainer.Create;
  398. while not p.empty do
  399. begin
  400. s:=p.get(mask);
  401. if strippath then
  402. ppufile.putstring(SplitFileName(s))
  403. else
  404. ppufile.putstring(s);
  405. ppufile.putlongint(mask);
  406. hcontainer.add(s,mask);
  407. end;
  408. ppufile.writeentry(id);
  409. p.Free;
  410. p:=hcontainer;
  411. end;
  412. procedure tppumodule.putasmsymbol_in_idx(s:tnamedindexitem;arg:pointer);
  413. begin
  414. if tasmsymbol(s).ppuidx<>-1 then
  415. librarydata.asmsymbolidx^[tasmsymbol(s).ppuidx-1]:=tasmsymbol(s);
  416. end;
  417. procedure tppumodule.writeasmsymbols;
  418. var
  419. s : tasmsymbol;
  420. i : longint;
  421. asmsymtype : byte;
  422. begin
  423. { get an ordered list of all symbols to put in the ppu }
  424. getmem(librarydata.asmsymbolidx,librarydata.asmsymbolppuidx*sizeof(pointer));
  425. fillchar(librarydata.asmsymbolidx^,librarydata.asmsymbolppuidx*sizeof(pointer),0);
  426. librarydata.symbolsearch.foreach({$ifdef FPCPROCVAR}@{$endif}putasmsymbol_in_idx,nil);
  427. { write the number of symbols }
  428. ppufile.putlongint(librarydata.asmsymbolppuidx);
  429. { write the symbols from the indexed list to the ppu }
  430. for i:=1 to librarydata.asmsymbolppuidx do
  431. begin
  432. s:=librarydata.asmsymbolidx^[i-1];
  433. if not assigned(s) then
  434. internalerror(200208071);
  435. asmsymtype:=1;
  436. if s.Classtype=tasmlabel then
  437. begin
  438. if tasmlabel(s).is_addr then
  439. asmsymtype:=4
  440. else if tasmlabel(s).typ=AT_DATA then
  441. asmsymtype:=3
  442. else
  443. asmsymtype:=2;
  444. end;
  445. ppufile.putbyte(asmsymtype);
  446. case asmsymtype of
  447. 1 :
  448. ppufile.putstring(s.name);
  449. 2 :
  450. ppufile.putlongint(tasmlabel(s).labelnr);
  451. end;
  452. ppufile.putbyte(byte(s.defbind));
  453. ppufile.putbyte(byte(s.typ));
  454. end;
  455. ppufile.writeentry(ibasmsymbols);
  456. end;
  457. procedure tppumodule.readusedmacros;
  458. var
  459. hs : string;
  460. mac : tmacro;
  461. was_defined_at_startup,
  462. was_used : boolean;
  463. begin
  464. { only possible when we've a scanner of the current file }
  465. if not assigned(current_scanner) then
  466. exit;
  467. while not ppufile.endofentry do
  468. begin
  469. hs:=ppufile.getstring;
  470. was_defined_at_startup:=boolean(ppufile.getbyte);
  471. was_used:=boolean(ppufile.getbyte);
  472. mac:=tmacro(tscannerfile(current_scanner).macros.search(hs));
  473. if assigned(mac) then
  474. begin
  475. {$ifndef EXTDEBUG}
  476. { if we don't have the sources why tell }
  477. if sources_avail then
  478. {$endif ndef EXTDEBUG}
  479. if (not was_defined_at_startup) and
  480. was_used and
  481. mac.defined_at_startup then
  482. Message2(unit_h_cond_not_set_in_last_compile,hs,mainsource^);
  483. end
  484. else { not assigned }
  485. if was_defined_at_startup and
  486. was_used then
  487. Message2(unit_h_cond_set_in_last_compile,hs,mainsource^);
  488. end;
  489. end;
  490. procedure tppumodule.readsourcefiles;
  491. var
  492. temp,hs : string;
  493. temp_dir : string;
  494. main_dir : string;
  495. incfile_found,
  496. main_found,
  497. is_main : boolean;
  498. orgfiletime,
  499. source_time : longint;
  500. hp : tinputfile;
  501. begin
  502. sources_avail:=true;
  503. is_main:=true;
  504. main_dir:='';
  505. while not ppufile.endofentry do
  506. begin
  507. hs:=ppufile.getstring;
  508. orgfiletime:=ppufile.getlongint;
  509. temp_dir:='';
  510. if (flags and uf_in_library)<>0 then
  511. begin
  512. sources_avail:=false;
  513. temp:=' library';
  514. end
  515. else if pos('Macro ',hs)=1 then
  516. begin
  517. { we don't want to find this file }
  518. { but there is a problem with file indexing !! }
  519. temp:='';
  520. end
  521. else
  522. begin
  523. { check the date of the source files }
  524. Source_Time:=GetNamedFileTime(path^+hs);
  525. incfile_found:=false;
  526. main_found:=false;
  527. if Source_Time<>-1 then
  528. hs:=path^+hs
  529. else
  530. if not(is_main) then
  531. begin
  532. Source_Time:=GetNamedFileTime(main_dir+hs);
  533. if Source_Time<>-1 then
  534. hs:=main_dir+hs;
  535. end;
  536. if (Source_Time=-1) then
  537. begin
  538. if is_main then
  539. main_found:=unitsearchpath.FindFile(hs,temp_dir)
  540. else
  541. incfile_found:=includesearchpath.FindFile(hs,temp_dir);
  542. if incfile_found or main_found then
  543. begin
  544. Source_Time:=GetNamedFileTime(temp_dir);
  545. if Source_Time<>-1 then
  546. hs:=temp_dir;
  547. end;
  548. end;
  549. if Source_Time=-1 then
  550. begin
  551. sources_avail:=false;
  552. temp:=' not found';
  553. end
  554. else
  555. begin
  556. if main_found then
  557. main_dir:=temp_dir;
  558. { time newer? But only allow if the file is not searched
  559. in the include path (PFV), else you've problems with
  560. units which use the same includefile names }
  561. if incfile_found then
  562. temp:=' found'
  563. else
  564. begin
  565. temp:=' time '+filetimestring(source_time);
  566. if (orgfiletime<>-1) and
  567. (source_time<>orgfiletime) then
  568. begin
  569. if ((flags and uf_release)=0) then
  570. begin
  571. do_compile:=true;
  572. recompile_reason:=rr_sourcenewer;
  573. end
  574. else
  575. Message2(unit_h_source_modified,hs,ppufilename^);
  576. temp:=temp+' *';
  577. end;
  578. end;
  579. end;
  580. hp:=tinputfile.create(hs);
  581. { the indexing is wrong here PM }
  582. sourcefiles.register_file(hp);
  583. end;
  584. if is_main then
  585. begin
  586. stringdispose(mainsource);
  587. mainsource:=stringdup(hs);
  588. end;
  589. Message1(unit_u_ppu_source,hs+temp);
  590. is_main:=false;
  591. end;
  592. { check if we want to rebuild every unit, only if the sources are
  593. available }
  594. if do_build and sources_avail and
  595. ((flags and uf_release)=0) then
  596. begin
  597. do_compile:=true;
  598. recompile_reason:=rr_build;
  599. end;
  600. end;
  601. procedure tppumodule.readloadunit;
  602. var
  603. hs : string;
  604. pu : tused_unit;
  605. hp : tppumodule;
  606. intfchecksum,
  607. checksum : cardinal;
  608. begin
  609. while not ppufile.endofentry do
  610. begin
  611. hs:=ppufile.getstring;
  612. checksum:=cardinal(ppufile.getlongint);
  613. intfchecksum:=cardinal(ppufile.getlongint);
  614. in_interface:=(ppufile.getbyte<>0);
  615. { set the state of this unit before registering, this is
  616. needed for a correct circular dependency check }
  617. hp:=registerunit(self,hs,'');
  618. pu:=addusedunit(hp,false);
  619. pu.checksum:=checksum;
  620. pu.interface_checksum:=intfchecksum;
  621. end;
  622. in_interface:=false;
  623. end;
  624. procedure tppumodule.readlinkcontainer(var p:tlinkcontainer);
  625. var
  626. s : string;
  627. m : longint;
  628. begin
  629. while not ppufile.endofentry do
  630. begin
  631. s:=ppufile.getstring;
  632. m:=ppufile.getlongint;
  633. p.add(s,m);
  634. end;
  635. end;
  636. procedure tppumodule.readasmsymbols;
  637. var
  638. labelnr,
  639. i : longint;
  640. name : string;
  641. bind : TAsmSymBind;
  642. typ : TAsmSymType;
  643. asmsymtype : byte;
  644. begin
  645. librarydata.asmsymbolppuidx:=ppufile.getlongint;
  646. if librarydata.asmsymbolppuidx>0 then
  647. begin
  648. getmem(librarydata.asmsymbolidx,librarydata.asmsymbolppuidx*sizeof(pointer));
  649. fillchar(librarydata.asmsymbolidx^,librarydata.asmsymbolppuidx*sizeof(pointer),0);
  650. for i:=1 to librarydata.asmsymbolppuidx do
  651. begin
  652. asmsymtype:=ppufile.getbyte;
  653. case asmsymtype of
  654. 1 :
  655. name:=ppufile.getstring;
  656. 2..4 :
  657. labelnr:=ppufile.getlongint;
  658. else
  659. internalerror(200208192);
  660. end;
  661. bind:=tasmsymbind(ppufile.getbyte);
  662. typ:=tasmsymtype(ppufile.getbyte);
  663. case asmsymtype of
  664. 1 :
  665. librarydata.asmsymbolidx^[i-1]:=librarydata.newasmsymboltype(name,bind,typ);
  666. 2 :
  667. librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,false,false);
  668. 3 :
  669. librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,true,false);
  670. 4 :
  671. librarydata.asmsymbolidx^[i-1]:=librarydata.newasmlabel(labelnr,false,true);
  672. end;
  673. end;
  674. end;
  675. end;
  676. procedure tppumodule.load_interface;
  677. var
  678. b : byte;
  679. newmodulename : string;
  680. begin
  681. { read interface part }
  682. repeat
  683. b:=ppufile.readentry;
  684. case b of
  685. ibmodulename :
  686. begin
  687. newmodulename:=ppufile.getstring;
  688. if (cs_check_unit_name in aktglobalswitches) and
  689. (upper(newmodulename)<>modulename^) then
  690. Message2(unit_f_unit_name_error,realmodulename^,newmodulename);
  691. stringdispose(modulename);
  692. stringdispose(realmodulename);
  693. modulename:=stringdup(upper(newmodulename));
  694. realmodulename:=stringdup(newmodulename);
  695. end;
  696. ibsourcefiles :
  697. readsourcefiles;
  698. ibusedmacros :
  699. readusedmacros;
  700. ibloadunit :
  701. readloadunit;
  702. iblinkunitofiles :
  703. readlinkcontainer(LinkUnitOFiles);
  704. iblinkunitstaticlibs :
  705. readlinkcontainer(LinkUnitStaticLibs);
  706. iblinkunitsharedlibs :
  707. readlinkcontainer(LinkUnitSharedLibs);
  708. iblinkotherofiles :
  709. readlinkcontainer(LinkotherOFiles);
  710. iblinkotherstaticlibs :
  711. readlinkcontainer(LinkotherStaticLibs);
  712. iblinkothersharedlibs :
  713. readlinkcontainer(LinkotherSharedLibs);
  714. ibendinterface :
  715. break;
  716. else
  717. Message1(unit_f_ppu_invalid_entry,tostr(b));
  718. end;
  719. until false;
  720. end;
  721. procedure tppumodule.load_implementation;
  722. var
  723. b : byte;
  724. oldobjectlibrary : tasmlibrarydata;
  725. begin
  726. { read implementation part }
  727. repeat
  728. b:=ppufile.readentry;
  729. case b of
  730. ibasmsymbols :
  731. readasmsymbols;
  732. ibendimplementation :
  733. break;
  734. else
  735. Message1(unit_f_ppu_invalid_entry,tostr(b));
  736. end;
  737. until false;
  738. { we can now derefence all pointers to the implementation parts }
  739. oldobjectlibrary:=objectlibrary;
  740. objectlibrary:=librarydata;
  741. tstoredsymtable(globalsymtable).derefimpl;
  742. if assigned(localsymtable) then
  743. tstoredsymtable(localsymtable).derefimpl;
  744. objectlibrary:=oldobjectlibrary;
  745. end;
  746. procedure tppumodule.load_symtable_refs;
  747. var
  748. b : byte;
  749. unitindex : word;
  750. begin
  751. { load local symtable first }
  752. if ((flags and uf_local_browser)<>0) then
  753. begin
  754. localsymtable:=tstaticsymtable.create(modulename^);
  755. tstaticsymtable(localsymtable).ppuload(ppufile);
  756. end;
  757. { load browser }
  758. if (flags and uf_has_browser)<>0 then
  759. begin
  760. tstoredsymtable(globalsymtable).load_references(ppufile,true);
  761. unitindex:=1;
  762. while assigned(map^[unitindex]) do
  763. begin
  764. { each unit wrote one browser entry }
  765. tstoredsymtable(globalsymtable).load_references(ppufile,false);
  766. inc(unitindex);
  767. end;
  768. b:=ppufile.readentry;
  769. if b<>ibendbrowser then
  770. Message1(unit_f_ppu_invalid_entry,tostr(b));
  771. end;
  772. if ((flags and uf_local_browser)<>0) then
  773. tstaticsymtable(localsymtable).load_references(ppufile,true);
  774. end;
  775. procedure tppumodule.writeppu;
  776. var
  777. pu : tused_unit;
  778. begin
  779. Message1(unit_u_ppu_write,realmodulename^);
  780. { create unit flags }
  781. {$ifdef GDB}
  782. if cs_gdb_dbx in aktglobalswitches then
  783. flags:=flags or uf_has_dbx;
  784. {$endif GDB}
  785. if cs_browser in aktmoduleswitches then
  786. flags:=flags or uf_has_browser;
  787. if cs_local_browser in aktmoduleswitches then
  788. flags:=flags or uf_local_browser;
  789. if do_release then
  790. flags:=flags or uf_release;
  791. {$ifdef cpufpemu}
  792. if (cs_fp_emulation in aktmoduleswitches) then
  793. flags:=flags or uf_fpu_emulation;
  794. {$endif cpufpemu}
  795. {$ifdef Test_Double_checksum_write}
  796. Assign(CRCFile,s+'.IMP');
  797. Rewrite(CRCFile);
  798. {$endif def Test_Double_checksum_write}
  799. { create new ppufile }
  800. ppufile:=tcompilerppufile.create(ppufilename^);
  801. if not ppufile.createfile then
  802. Message(unit_f_ppu_cannot_write);
  803. { first the unitname }
  804. ppufile.putstring(realmodulename^);
  805. ppufile.writeentry(ibmodulename);
  806. writesourcefiles;
  807. writeusedmacros;
  808. writeusedunit;
  809. { write the objectfiles and libraries that come for this unit,
  810. preserve the containers becuase they are still needed to load
  811. the link.res. All doesn't depend on the crc! It doesn't matter
  812. if a unit is in a .o or .a file }
  813. ppufile.do_crc:=false;
  814. writelinkcontainer(linkunitofiles,iblinkunitofiles,true);
  815. writelinkcontainer(linkunitstaticlibs,iblinkunitstaticlibs,true);
  816. writelinkcontainer(linkunitsharedlibs,iblinkunitsharedlibs,true);
  817. writelinkcontainer(linkotherofiles,iblinkotherofiles,false);
  818. writelinkcontainer(linkotherstaticlibs,iblinkotherstaticlibs,true);
  819. writelinkcontainer(linkothersharedlibs,iblinkothersharedlibs,true);
  820. ppufile.do_crc:=true;
  821. ppufile.writeentry(ibendinterface);
  822. { write the symtable entries }
  823. tstoredsymtable(globalsymtable).ppuwrite(ppufile);
  824. { everything after this doesn't affect the crc }
  825. ppufile.do_crc:=false;
  826. { write asmsymbols }
  827. writeasmsymbols;
  828. { end of implementation }
  829. ppufile.writeentry(ibendimplementation);
  830. { write static symtable
  831. needed for local debugging of unit functions }
  832. if ((flags and uf_local_browser)<>0) and
  833. assigned(localsymtable) then
  834. tstoredsymtable(localsymtable).ppuwrite(ppufile);
  835. { write all browser section }
  836. if (flags and uf_has_browser)<>0 then
  837. begin
  838. tstoredsymtable(globalsymtable).write_references(ppufile,true);
  839. pu:=tused_unit(used_units.first);
  840. while assigned(pu) do
  841. begin
  842. tstoredsymtable(pu.u.globalsymtable).write_references(ppufile,false);
  843. pu:=tused_unit(pu.next);
  844. end;
  845. ppufile.writeentry(ibendbrowser);
  846. end;
  847. if ((flags and uf_local_browser)<>0) and
  848. assigned(localsymtable) then
  849. tstaticsymtable(localsymtable).write_references(ppufile,true);
  850. { the last entry ibend is written automaticly }
  851. { flush to be sure }
  852. ppufile.flush;
  853. { create and write header }
  854. ppufile.header.size:=ppufile.size;
  855. ppufile.header.checksum:=ppufile.crc;
  856. ppufile.header.interface_checksum:=ppufile.interface_crc;
  857. ppufile.header.compiler:=wordversion;
  858. ppufile.header.cpu:=word(target_cpu);
  859. ppufile.header.target:=word(target_info.system);
  860. ppufile.header.flags:=flags;
  861. ppufile.writeheader;
  862. { save crc in current module also }
  863. crc:=ppufile.crc;
  864. interface_crc:=ppufile.interface_crc;
  865. {$ifdef Test_Double_checksum_write}
  866. close(CRCFile);
  867. {$endif Test_Double_checksum_write}
  868. ppufile.closefile;
  869. ppufile.free;
  870. ppufile:=nil;
  871. end;
  872. procedure tppumodule.getppucrc;
  873. begin
  874. {$ifdef Test_Double_checksum_write}
  875. Assign(CRCFile,s+'.INT')
  876. Rewrite(CRCFile);
  877. {$endif def Test_Double_checksum_write}
  878. { create new ppufile }
  879. ppufile:=tcompilerppufile.create(ppufilename^);
  880. ppufile.crc_only:=true;
  881. if not ppufile.createfile then
  882. Message(unit_f_ppu_cannot_write);
  883. { first the unitname }
  884. ppufile.putstring(realmodulename^);
  885. ppufile.writeentry(ibmodulename);
  886. { the interface units affect the crc }
  887. writeusedunit;
  888. ppufile.writeentry(ibendinterface);
  889. { write the symtable entries }
  890. tstoredsymtable(globalsymtable).ppuwrite(ppufile);
  891. { save crc }
  892. crc:=ppufile.crc;
  893. interface_crc:=ppufile.interface_crc;
  894. { end of implementation, to generate a correct ppufile
  895. for ppudump when using INTFPPU define }
  896. ppufile.writeentry(ibendimplementation);
  897. {$ifdef Test_Double_checksum}
  898. crc_array:=ppufile.crc_test;
  899. ppufile.crc_test:=nil;
  900. crc_size:=ppufile.crc_index2;
  901. crc_array2:=ppufile.crc_test2;
  902. ppufile.crc_test2:=nil;
  903. crc_size2:=ppufile.crc_index2;
  904. {$endif Test_Double_checksum}
  905. {$ifdef Test_Double_checksum_write}
  906. close(CRCFile);
  907. {$endif Test_Double_checksum_write}
  908. ppufile.closefile;
  909. ppufile.free;
  910. ppufile:=nil;
  911. end;
  912. procedure tppumodule.load_usedunits;
  913. var
  914. pu : tused_unit;
  915. load_refs : boolean;
  916. nextmapentry : longint;
  917. begin
  918. if current_module<>self then
  919. internalerror(200212284);
  920. load_refs:=true;
  921. { init the map }
  922. new(map);
  923. fillchar(map^,sizeof(tunitmap),#0);
  924. map^[0]:=self;
  925. nextmapentry:=1;
  926. { load the used units from interface }
  927. in_interface:=true;
  928. pu:=tused_unit(used_units.first);
  929. while assigned(pu) do
  930. begin
  931. if pu.in_interface then
  932. begin
  933. tppumodule(pu.u).loadppu;
  934. { if this unit is compiled we can stop }
  935. if state=ms_compiled then
  936. exit;
  937. { add this unit to the dependencies }
  938. pu.u.adddependency(self);
  939. { need to recompile the current unit ? }
  940. if pu.u.crc<>pu.checksum then
  941. begin
  942. Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^);
  943. recompile_reason:=rr_crcchanged;
  944. do_compile:=true;
  945. dispose(map);
  946. map:=nil;
  947. exit;
  948. end;
  949. { setup the map entry for deref }
  950. map^[nextmapentry]:=pu.u;
  951. inc(nextmapentry);
  952. if nextmapentry>maxunits then
  953. Message(unit_f_too_much_units);
  954. end;
  955. pu:=tused_unit(pu.next);
  956. end;
  957. { ok, now load the interface of this unit }
  958. if current_module<>self then
  959. internalerror(200208187);
  960. globalsymtable:=tglobalsymtable.create(modulename^);
  961. tstoredsymtable(globalsymtable).ppuload(ppufile);
  962. { now only read the implementation uses }
  963. in_interface:=false;
  964. pu:=tused_unit(used_units.first);
  965. while assigned(pu) do
  966. begin
  967. if (not pu.in_interface) then
  968. begin
  969. tppumodule(pu.u).loadppu;
  970. { if this unit is compiled we can stop }
  971. if state=ms_compiled then
  972. exit;
  973. { add this unit to the dependencies }
  974. pu.u.adddependency(self);
  975. { need to recompile the current unit ? }
  976. if (pu.u.interface_crc<>pu.interface_checksum) then
  977. begin
  978. Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^+' {impl}');
  979. recompile_reason:=rr_crcchanged;
  980. do_compile:=true;
  981. dispose(map);
  982. map:=nil;
  983. exit;
  984. end;
  985. { setup the map entry for deref }
  986. map^[nextmapentry]:=pu.u;
  987. inc(nextmapentry);
  988. if nextmapentry>maxunits then
  989. Message(unit_f_too_much_units);
  990. end;
  991. pu:=tused_unit(pu.next);
  992. end;
  993. { read the implementation/objectdata part }
  994. load_implementation;
  995. { load browser info if stored }
  996. if ((flags and uf_has_browser)<>0) and load_refs then
  997. begin
  998. if current_module<>self then
  999. internalerror(200208188);
  1000. load_symtable_refs;
  1001. end;
  1002. { remove the map, it's not needed anymore }
  1003. dispose(map);
  1004. map:=nil;
  1005. end;
  1006. procedure tppumodule.loadppu;
  1007. const
  1008. ImplIntf : array[boolean] of string[15]=('implementation','interface');
  1009. var
  1010. second_time : boolean;
  1011. hp,
  1012. old_current_module : tmodule;
  1013. begin
  1014. old_current_module:=current_module;
  1015. Message3(unit_u_load_unit,old_current_module.modulename^,
  1016. ImplIntf[old_current_module.in_interface],
  1017. modulename^);
  1018. { check if the globalsymtable is already available, but
  1019. we must reload when the do_reload flag is set }
  1020. if do_reload then
  1021. begin
  1022. Comment(V_Used,'Forced reloading');
  1023. do_reload:=false;
  1024. end
  1025. else
  1026. begin
  1027. if assigned(globalsymtable) then
  1028. exit;
  1029. end;
  1030. { reset }
  1031. second_time:=false;
  1032. current_module:=self;
  1033. SetCompileModule(current_module);
  1034. Fillchar(aktfilepos,0,sizeof(aktfilepos));
  1035. { we are loading a new module, save the state of the scanner
  1036. and reset scanner+module }
  1037. if assigned(current_scanner) then
  1038. current_scanner.tempcloseinputfile;
  1039. current_scanner:=nil;
  1040. { loading the unit for a second time? }
  1041. if state=ms_registered then
  1042. state:=ms_load
  1043. else
  1044. begin
  1045. { try to load the unit a second time first }
  1046. Message1(unit_u_second_load_unit,modulename^);
  1047. Comment(V_Used,'Previous state '+modulename^+': '+ModuleStateStr[state]);
  1048. { Flag modules to reload }
  1049. flagdependent(old_current_module);
  1050. { Reset the module }
  1051. reset;
  1052. if state=ms_compile then
  1053. begin
  1054. Comment(V_Used,'Already compiling '+modulename^+' setting second compile');
  1055. state:=ms_second_compile;
  1056. do_compile:=true;
  1057. end
  1058. else
  1059. state:=ms_second_load;
  1060. second_time:=true;
  1061. end;
  1062. { close old_current_ppu on system that are
  1063. short on file handles like DOS PM }
  1064. {$ifdef SHORT_ON_FILE_HANDLES}
  1065. if old_current_module.is_unit and
  1066. assigned(tppumodule(old_current_module).ppufile) then
  1067. tppumodule(old_current_module).ppufile.tempclose;
  1068. {$endif SHORT_ON_FILE_HANDLES}
  1069. { try to opening ppu, skip this when we already
  1070. know that we need to compile the unit }
  1071. if not do_compile then
  1072. begin
  1073. Comment(V_Used,'Loading module '+modulename^);
  1074. search_unit(false,false);
  1075. if not do_compile then
  1076. begin
  1077. load_interface;
  1078. if not do_compile then
  1079. begin
  1080. load_usedunits;
  1081. if not do_compile then
  1082. Comment(V_Used,'Finished loading module '+modulename^);
  1083. end;
  1084. end;
  1085. { PPU is not needed anymore }
  1086. if assigned(ppufile) then
  1087. begin
  1088. ppufile.closefile;
  1089. ppufile.free;
  1090. ppufile:=nil;
  1091. end;
  1092. end;
  1093. { Do we need to recompile the unit }
  1094. if do_compile then
  1095. begin
  1096. { recompile the unit or give a fatal error if sources not available }
  1097. if not(sources_avail) then
  1098. begin
  1099. if (not search_unit(true,false)) and
  1100. (length(modulename^)>8) then
  1101. search_unit(true,true);
  1102. if not(sources_avail) then
  1103. begin
  1104. if recompile_reason=rr_noppu then
  1105. Message1(unit_f_cant_find_ppu,modulename^)
  1106. else
  1107. Message1(unit_f_cant_compile_unit,modulename^);
  1108. end;
  1109. end;
  1110. { Flag modules to reload }
  1111. flagdependent(old_current_module);
  1112. { Reset the module }
  1113. reset;
  1114. { compile this module }
  1115. if not(state in [ms_compile,ms_second_compile]) then
  1116. state:=ms_compile;
  1117. compile(mainsource^);
  1118. end;
  1119. { set compiled flag }
  1120. if current_module<>self then
  1121. internalerror(200212282);
  1122. state:=ms_compiled;
  1123. if in_interface then
  1124. internalerror(200212283);
  1125. { for a second_time recompile reload all dependent units,
  1126. for a first time compile register the unit _once_ }
  1127. if second_time then
  1128. begin
  1129. { now reload all dependent units }
  1130. hp:=tmodule(loaded_units.first);
  1131. while assigned(hp) do
  1132. begin
  1133. if hp.do_reload then
  1134. tppumodule(hp).loadppu;
  1135. hp:=tmodule(hp.next);
  1136. end;
  1137. end
  1138. else
  1139. usedunits.concat(tused_unit.create(self,true,false));
  1140. { reopen the old module }
  1141. {$ifdef SHORT_ON_FILE_HANDLES}
  1142. if old_current_module.is_unit and
  1143. assigned(tppumodule(old_current_module).ppufile) then
  1144. tppumodule(old_current_module).ppufile.tempopen;
  1145. {$endif SHORT_ON_FILE_HANDLES}
  1146. { we are back, restore current_module and current_scanner }
  1147. current_module:=old_current_module;
  1148. current_scanner:=tscannerfile(current_module.scanner);
  1149. if assigned(current_scanner) then
  1150. begin
  1151. current_scanner.tempopeninputfile;
  1152. current_scanner.gettokenpos;
  1153. end
  1154. else
  1155. fillchar(aktfilepos,sizeof(aktfilepos),0);
  1156. SetCompileModule(current_module);
  1157. end;
  1158. {*****************************************************************************
  1159. RegisterUnit
  1160. *****************************************************************************}
  1161. function registerunit(callermodule:tmodule;const s : stringid;const fn:string) : tppumodule;
  1162. var
  1163. ups : stringid;
  1164. hp : tppumodule;
  1165. hp2,
  1166. shortnamehp : tmodule;
  1167. begin
  1168. { Info }
  1169. ups:=upper(s);
  1170. { search all loaded units }
  1171. shortnamehp:=nil;
  1172. hp:=tppumodule(loaded_units.first);
  1173. while assigned(hp) do
  1174. begin
  1175. if hp.modulename^=ups then
  1176. begin
  1177. { only check for units. The main program is also
  1178. as a unit in the loaded_units list. We simply need
  1179. to ignore this entry (PFV) }
  1180. if hp.is_unit then
  1181. begin
  1182. { both units in interface ? }
  1183. if callermodule.in_interface and
  1184. hp.in_interface then
  1185. begin
  1186. { check for a cycle }
  1187. hp2:=callermodule.loaded_from;
  1188. while assigned(hp2) and (hp2<>hp) do
  1189. begin
  1190. if hp2.in_interface then
  1191. hp2:=hp2.loaded_from
  1192. else
  1193. hp2:=nil;
  1194. end;
  1195. if assigned(hp2) then
  1196. Message2(unit_f_circular_unit_reference,callermodule.modulename^,hp.modulename^);
  1197. end;
  1198. break;
  1199. end;
  1200. end
  1201. else
  1202. if copy(hp.modulename^,1,8)=ups then
  1203. shortnamehp:=hp;
  1204. { the next unit }
  1205. hp:=tppumodule(hp.next);
  1206. end;
  1207. if assigned(shortnamehp) and not assigned(hp) then
  1208. Message2(unit_w_unit_name_error,s,shortnamehp.modulename^);
  1209. { the unit is not in the loaded units,
  1210. we create an entry and register the unit }
  1211. if not assigned(hp) then
  1212. begin
  1213. Comment(V_Used,'Registering new unit '+Upper(s));
  1214. hp:=tppumodule.create(callermodule,s,fn,true);
  1215. hp.loaded_from:=callermodule;
  1216. loaded_units.insert(hp);
  1217. end;
  1218. { return }
  1219. registerunit:=hp;
  1220. end;
  1221. end.
  1222. {
  1223. $Log$
  1224. Revision 1.33 2003-04-27 11:21:32 peter
  1225. * aktprocdef renamed to current_procdef
  1226. * procinfo renamed to current_procinfo
  1227. * procinfo will now be stored in current_module so it can be
  1228. cleaned up properly
  1229. * gen_main_procsym changed to create_main_proc and release_main_proc
  1230. to also generate a tprocinfo structure
  1231. * fixed unit implicit initfinal
  1232. Revision 1.32 2003/04/27 07:29:50 peter
  1233. * current_procdef cleanup, current_procdef is now always nil when parsing
  1234. a new procdef declaration
  1235. * aktprocsym removed
  1236. * lexlevel removed, use symtable.symtablelevel instead
  1237. * implicit init/final code uses the normal genentry/genexit
  1238. * funcret state checking updated for new funcret handling
  1239. Revision 1.31 2003/04/26 00:30:52 peter
  1240. * reset aktfilepos when setting new module for compile
  1241. Revision 1.30 2003/03/27 17:44:13 peter
  1242. * fixed small mem leaks
  1243. Revision 1.29 2002/12/29 14:57:50 peter
  1244. * unit loading changed to first register units and load them
  1245. afterwards. This is needed to support uses xxx in yyy correctly
  1246. * unit dependency check fixed
  1247. Revision 1.28 2002/12/06 16:56:57 peter
  1248. * only compile cs_fp_emulation support when cpufpuemu is defined
  1249. * define cpufpuemu for m68k only
  1250. Revision 1.27 2002/11/20 12:36:24 mazen
  1251. * $UNITPATH directive is now working
  1252. Revision 1.26 2002/11/15 01:58:46 peter
  1253. * merged changes from 1.0.7 up to 04-11
  1254. - -V option for generating bug report tracing
  1255. - more tracing for option parsing
  1256. - errors for cdecl and high()
  1257. - win32 import stabs
  1258. - win32 records<=8 are returned in eax:edx (turned off by default)
  1259. - heaptrc update
  1260. - more info for temp management in .s file with EXTDEBUG
  1261. Revision 1.25 2002/10/20 14:49:31 peter
  1262. * store original source time in ppu so it can be compared instead of
  1263. comparing with the ppu time
  1264. Revision 1.24 2002/10/04 20:13:10 peter
  1265. * set in_second_load flag before resetting the module, this is
  1266. required to skip some checkings
  1267. Revision 1.23 2002/08/19 19:36:42 peter
  1268. * More fixes for cross unit inlining, all tnodes are now implemented
  1269. * Moved pocall_internconst to po_internconst because it is not a
  1270. calling type at all and it conflicted when inlining of these small
  1271. functions was requested
  1272. Revision 1.22 2002/08/18 19:58:28 peter
  1273. * more current_scanner fixes
  1274. Revision 1.21 2002/08/15 15:09:41 carl
  1275. + fpu emulation helpers (ppu checking also)
  1276. Revision 1.20 2002/08/12 16:46:04 peter
  1277. * tscannerfile is now destroyed in tmodule.reset and current_scanner
  1278. is updated accordingly. This removes all the loading and saving of
  1279. the old scanner and the invalid flag marking
  1280. Revision 1.19 2002/08/11 14:28:19 peter
  1281. * TScannerFile.SetInvalid added that will also reset inputfile
  1282. Revision 1.18 2002/08/11 13:24:11 peter
  1283. * saving of asmsymbols in ppu supported
  1284. * asmsymbollist global is removed and moved into a new class
  1285. tasmlibrarydata that will hold the info of a .a file which
  1286. corresponds with a single module. Added librarydata to tmodule
  1287. to keep the library info stored for the module. In the future the
  1288. objectfiles will also be stored to the tasmlibrarydata class
  1289. * all getlabel/newasmsymbol and friends are moved to the new class
  1290. Revision 1.17 2002/07/26 21:15:37 florian
  1291. * rewrote the system handling
  1292. Revision 1.16 2002/05/16 19:46:36 carl
  1293. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1294. + try to fix temp allocation (still in ifdef)
  1295. + generic constructor calls
  1296. + start of tassembler / tmodulebase class cleanup
  1297. Revision 1.15 2002/05/14 19:34:41 peter
  1298. * removed old logs and updated copyright year
  1299. Revision 1.14 2002/05/12 16:53:05 peter
  1300. * moved entry and exitcode to ncgutil and cgobj
  1301. * foreach gets extra argument for passing local data to the
  1302. iterator function
  1303. * -CR checks also class typecasts at runtime by changing them
  1304. into as
  1305. * fixed compiler to cycle with the -CR option
  1306. * fixed stabs with elf writer, finally the global variables can
  1307. be watched
  1308. * removed a lot of routines from cga unit and replaced them by
  1309. calls to cgobj
  1310. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1311. u32bit then the other is typecasted also to u32bit without giving
  1312. a rangecheck warning/error.
  1313. * fixed pascal calling method with reversing also the high tree in
  1314. the parast, detected by tcalcst3 test
  1315. Revision 1.13 2002/04/04 19:05:56 peter
  1316. * removed unused units
  1317. * use tlocation.size in cg.a_*loc*() routines
  1318. Revision 1.12 2002/03/28 20:46:44 carl
  1319. - remove go32v1 support
  1320. Revision 1.11 2002/01/19 14:20:13 peter
  1321. * check for -Un when loading ppu with wrong name
  1322. }