psub.pas 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Daniel Mantione
  4. Does the parsing and codegeneration at subroutine level
  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 psub;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. symdef;
  23. procedure printnode_reset;
  24. procedure compile_proc_body(pd:tprocdef;make_global,parent_has_class:boolean);
  25. { reads the declaration blocks }
  26. procedure read_declarations(islibrary : boolean);
  27. { reads declarations in the interface part of a unit }
  28. procedure read_interface_declarations;
  29. implementation
  30. uses
  31. { common }
  32. cutils,cclasses,
  33. { global }
  34. globtype,globals,tokens,verbose,comphook,
  35. systems,
  36. { aasm }
  37. cpubase,cpuinfo,aasmbase,aasmtai,
  38. { symtable }
  39. symconst,symbase,symsym,symtype,symtable,defutil,
  40. paramgr,
  41. ppu,fmodule,
  42. { pass 1 }
  43. node,
  44. nutils,nbas,nld,ncal,ncon,nflw,nadd,ncnv,nmem,
  45. pass_1,
  46. {$ifdef state_tracking}
  47. nstate,
  48. {$endif state_tracking}
  49. { pass 2 }
  50. {$ifndef NOPASS2}
  51. pass_2,
  52. {$endif}
  53. { parser }
  54. scanner,
  55. pbase,pstatmnt,pdecl,pdecsub,pexports,
  56. { codegen }
  57. tgobj,cgbase,rgobj,rgcpu,
  58. ncgutil
  59. {$ifndef NOOPT}
  60. {$ifdef i386}
  61. ,aopt386
  62. {$else i386}
  63. ,aoptcpu
  64. {$endif i386}
  65. {$endif}
  66. ;
  67. {****************************************************************************
  68. PROCEDURE/FUNCTION BODY PARSING
  69. ****************************************************************************}
  70. procedure initializevars(p:tnamedindexitem;arg:pointer);
  71. var
  72. b : tblocknode;
  73. begin
  74. if tsym(p).typ<>varsym then
  75. exit;
  76. with tvarsym(p) do
  77. begin
  78. if assigned(defaultconstsym) then
  79. begin
  80. b:=tblocknode(arg);
  81. b.left:=cstatementnode.create(
  82. cassignmentnode.create(
  83. cloadnode.create(tsym(p),tsym(p).owner),
  84. cloadnode.create(defaultconstsym,defaultconstsym.owner)),
  85. b.left);
  86. end;
  87. end;
  88. end;
  89. function block(islibrary : boolean) : tnode;
  90. begin
  91. { parse const,types and vars }
  92. read_declarations(islibrary);
  93. current_procinfo.handle_body_start;
  94. { do we have an assembler block without the po_assembler?
  95. we should allow this for Delphi compatibility (PFV) }
  96. if (token=_ASM) and (m_delphi in aktmodeswitches) then
  97. include(current_procdef.procoptions,po_assembler);
  98. { Handle assembler block different }
  99. if (po_assembler in current_procdef.procoptions) then
  100. begin
  101. block:=assembler_block;
  102. exit;
  103. end;
  104. {Unit initialization?.}
  105. if (
  106. assigned(current_procdef.localst) and
  107. (current_procdef.localst.symtablelevel=main_program_level) and
  108. (current_module.is_unit)
  109. ) or
  110. islibrary then
  111. begin
  112. if (token=_END) then
  113. begin
  114. consume(_END);
  115. { We need at least a node, else the entry/exit code is not
  116. generated and thus no PASCALMAIN symbol which we need (PFV) }
  117. if islibrary then
  118. block:=cnothingnode.create
  119. else
  120. block:=nil;
  121. end
  122. else
  123. begin
  124. if token=_INITIALIZATION then
  125. begin
  126. { The library init code is already called and does not
  127. need to be in the initfinal table (PFV) }
  128. if not islibrary then
  129. current_module.flags:=current_module.flags or uf_init;
  130. block:=statement_block(_INITIALIZATION);
  131. end
  132. else if (token=_FINALIZATION) then
  133. begin
  134. if (current_module.flags and uf_finalize)<>0 then
  135. block:=statement_block(_FINALIZATION)
  136. else
  137. begin
  138. { can we allow no INITIALIZATION for DLL ??
  139. I think it should work PM }
  140. block:=nil;
  141. exit;
  142. end;
  143. end
  144. else
  145. begin
  146. { The library init code is already called and does not
  147. need to be in the initfinal table (PFV) }
  148. if not islibrary then
  149. current_module.flags:=current_module.flags or uf_init;
  150. block:=statement_block(_BEGIN);
  151. end;
  152. end;
  153. end
  154. else
  155. begin
  156. block:=statement_block(_BEGIN);
  157. if symtablestack.symtabletype=localsymtable then
  158. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}initializevars,block);
  159. end;
  160. end;
  161. {****************************************************************************
  162. PROCEDURE/FUNCTION COMPILING
  163. ****************************************************************************}
  164. procedure printnode_reset;
  165. begin
  166. assign(printnodefile,treelogfilename);
  167. {$I-}
  168. rewrite(printnodefile);
  169. {$I+}
  170. if ioresult<>0 then
  171. begin
  172. Comment(V_Error,'Error creating '+treelogfilename);
  173. exit;
  174. end;
  175. close(printnodefile);
  176. end;
  177. procedure printnode_procdef(pd:tprocdef);
  178. begin
  179. assign(printnodefile,treelogfilename);
  180. {$I-}
  181. append(printnodefile);
  182. if ioresult<>0 then
  183. rewrite(printnodefile);
  184. {$I+}
  185. if ioresult<>0 then
  186. begin
  187. Comment(V_Error,'Error creating '+treelogfilename);
  188. exit;
  189. end;
  190. writeln(printnodefile);
  191. writeln(printnodefile,'*******************************************************************************');
  192. writeln(printnodefile,current_procdef.fullprocname(false));
  193. writeln(printnodefile,'*******************************************************************************');
  194. printnode(printnodefile,pd.code);
  195. close(printnodefile);
  196. end;
  197. function generate_initialize_block:tnode;
  198. var
  199. srsym : tsym;
  200. para : tcallparanode;
  201. newstatement : tstatementnode;
  202. htype : ttype;
  203. begin
  204. result:=internalstatements(newstatement,true);
  205. if assigned(current_procdef._class) then
  206. begin
  207. { a constructor needs a help procedure }
  208. if (current_procdef.proctypeoption=potype_constructor) then
  209. begin
  210. if is_class(current_procdef._class) then
  211. begin
  212. if (cs_implicit_exceptions in aktmoduleswitches) then
  213. include(current_procinfo.flags,pi_needs_implicit_finally);
  214. srsym:=search_class_member(current_procdef._class,'NEWINSTANCE');
  215. if assigned(srsym) and
  216. (srsym.typ=procsym) then
  217. begin
  218. { if vmt<>0 then newinstance }
  219. addstatement(newstatement,cifnode.create(
  220. caddnode.create(unequaln,
  221. load_vmt_pointer_node,
  222. cnilnode.create),
  223. cassignmentnode.create(
  224. ctypeconvnode.create_explicit(
  225. load_self_pointer_node,
  226. voidpointertype),
  227. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_vmt_pointer_node)),
  228. nil));
  229. end
  230. else
  231. internalerror(200305108);
  232. end
  233. else
  234. if is_object(current_procdef._class) then
  235. begin
  236. htype.setdef(current_procdef._class);
  237. htype.setdef(tpointerdef.create(htype));
  238. { parameter 3 : vmt_offset }
  239. { parameter 2 : address of pointer to vmt,
  240. this is required to allow setting the vmt to -1 to indicate
  241. that memory was allocated }
  242. { parameter 1 : self pointer }
  243. para:=ccallparanode.create(
  244. cordconstnode.create(current_procdef._class.vmt_offset,s32bittype,false),
  245. ccallparanode.create(
  246. ctypeconvnode.create_explicit(
  247. load_vmt_pointer_node,
  248. voidpointertype),
  249. ccallparanode.create(
  250. ctypeconvnode.create_explicit(
  251. load_self_pointer_node,
  252. voidpointertype),
  253. nil)));
  254. addstatement(newstatement,cassignmentnode.create(
  255. ctypeconvnode.create_explicit(
  256. load_self_pointer_node,
  257. voidpointertype),
  258. ccallnode.createintern('fpc_help_constructor',para)));
  259. end
  260. else
  261. internalerror(200305103);
  262. { if self=nil then exit
  263. calling fail instead of exit is useless because
  264. there is nothing to dispose (PFV) }
  265. addstatement(newstatement,cifnode.create(
  266. caddnode.create(equaln,
  267. load_self_pointer_node,
  268. cnilnode.create),
  269. cexitnode.create(nil),
  270. nil));
  271. end;
  272. { maybe call BeforeDestruction for classes }
  273. if (current_procdef.proctypeoption=potype_destructor) and
  274. is_class(current_procdef._class) then
  275. begin
  276. srsym:=search_class_member(current_procdef._class,'BEFOREDESTRUCTION');
  277. if assigned(srsym) and
  278. (srsym.typ=procsym) then
  279. begin
  280. { if vmt<>0 then beforedestruction }
  281. addstatement(newstatement,cifnode.create(
  282. caddnode.create(unequaln,
  283. load_vmt_pointer_node,
  284. cnilnode.create),
  285. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  286. nil));
  287. end
  288. else
  289. internalerror(200305104);
  290. end;
  291. end;
  292. end;
  293. function generate_finalize_block:tnode;
  294. begin
  295. result:=cnothingnode.create;
  296. end;
  297. function generate_entry_block:tnode;
  298. begin
  299. result:=cnothingnode.create;
  300. end;
  301. function generate_exit_block:tnode;
  302. var
  303. srsym : tsym;
  304. para : tcallparanode;
  305. newstatement : tstatementnode;
  306. begin
  307. generate_exit_block:=internalstatements(newstatement,true);
  308. if assigned(current_procdef._class) then
  309. begin
  310. { maybe call AfterConstruction for classes }
  311. if (current_procdef.proctypeoption=potype_constructor) and
  312. is_class(current_procdef._class) then
  313. begin
  314. srsym:=search_class_member(current_procdef._class,'AFTERCONSTRUCTION');
  315. if assigned(srsym) and
  316. (srsym.typ=procsym) then
  317. begin
  318. { if vmt<>0 then afterconstruction }
  319. addstatement(newstatement,cifnode.create(
  320. caddnode.create(unequaln,
  321. load_vmt_pointer_node,
  322. cnilnode.create),
  323. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  324. nil));
  325. end
  326. else
  327. internalerror(200305106);
  328. end;
  329. { a destructor needs a help procedure }
  330. if (current_procdef.proctypeoption=potype_destructor) then
  331. begin
  332. if is_class(current_procdef._class) then
  333. begin
  334. srsym:=search_class_member(current_procdef._class,'FREEINSTANCE');
  335. if assigned(srsym) and
  336. (srsym.typ=procsym) then
  337. begin
  338. { if self<>0 and vmt=1 then freeinstance }
  339. addstatement(newstatement,cifnode.create(
  340. caddnode.create(andn,
  341. caddnode.create(unequaln,
  342. load_self_pointer_node,
  343. cnilnode.create),
  344. caddnode.create(equaln,
  345. ctypeconvnode.create(
  346. load_vmt_pointer_node,
  347. voidpointertype),
  348. cpointerconstnode.create(1,voidpointertype))),
  349. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  350. nil));
  351. end
  352. else
  353. internalerror(200305108);
  354. end
  355. else
  356. if is_object(current_procdef._class) then
  357. begin
  358. { parameter 3 : vmt_offset }
  359. { parameter 2 : pointer to vmt }
  360. { parameter 1 : self pointer }
  361. para:=ccallparanode.create(
  362. cordconstnode.create(current_procdef._class.vmt_offset,s32bittype,false),
  363. ccallparanode.create(
  364. ctypeconvnode.create_explicit(
  365. load_vmt_pointer_node,
  366. voidpointertype),
  367. ccallparanode.create(
  368. ctypeconvnode.create_explicit(
  369. load_self_pointer_node,
  370. voidpointertype),
  371. nil)));
  372. addstatement(newstatement,
  373. ccallnode.createintern('fpc_help_destructor',para));
  374. end
  375. else
  376. internalerror(200305105);
  377. end;
  378. end;
  379. end;
  380. function generate_except_block:tnode;
  381. var
  382. pd : tprocdef;
  383. newstatement : tstatementnode;
  384. begin
  385. generate_except_block:=internalstatements(newstatement,true);
  386. { a constructor needs call destructor (if available) when it
  387. is not inherited }
  388. if assigned(current_procdef._class) and
  389. (current_procdef.proctypeoption=potype_constructor) then
  390. begin
  391. pd:=current_procdef._class.searchdestructor;
  392. if assigned(pd) then
  393. begin
  394. { if vmt<>0 then call destructor }
  395. addstatement(newstatement,cifnode.create(
  396. caddnode.create(unequaln,
  397. load_vmt_pointer_node,
  398. cnilnode.create),
  399. ccallnode.create(nil,tprocsym(pd.procsym),pd.procsym.owner,load_self_node),
  400. nil));
  401. end;
  402. end
  403. else
  404. begin
  405. { no constructor }
  406. { must be the return value finalized before reraising the exception? }
  407. if (not is_void(current_procdef.rettype.def)) and
  408. (current_procdef.rettype.def.needs_inittable) and
  409. (not is_class(current_procdef.rettype.def)) then
  410. finalize_data_node(caddrnode.create(load_result_node));
  411. end;
  412. end;
  413. procedure add_entry_exit_code(var code:tnode;const entrypos,exitpos:tfileposinfo);
  414. var
  415. initializecode,
  416. finalizecode,
  417. entrycode,
  418. exitcode,
  419. exceptcode : tnode;
  420. codeblock,
  421. newblock : tblocknode;
  422. codestatement,
  423. newstatement : tstatementnode;
  424. oldfilepos : tfileposinfo;
  425. begin
  426. oldfilepos:=aktfilepos;
  427. { Generate entry,exit and init,final blocks }
  428. aktfilepos:=entrypos;
  429. initializecode:=generate_initialize_block;
  430. entrycode:=generate_entry_block;
  431. aktfilepos:=exitpos;
  432. exitcode:=generate_exit_block;
  433. finalizecode:=generate_finalize_block;
  434. exceptcode:=generate_except_block;
  435. { Generate body of the procedure by combining entry+body+exit }
  436. codeblock:=internalstatements(codestatement,true);
  437. addstatement(codestatement,entrycode);
  438. addstatement(codestatement,code);
  439. addstatement(codestatement,exitcode);
  440. { Generate procedure by combining init+body+final,
  441. depending on the implicit finally we need to add
  442. an try...finally...end wrapper }
  443. newblock:=internalstatements(newstatement,true);
  444. if (pi_needs_implicit_finally in current_procinfo.flags) and
  445. { but it's useless in init/final code of units }
  446. not(current_procdef.proctypeoption in [potype_unitfinalize,potype_unitinit]) then
  447. begin
  448. addstatement(newstatement,initializecode);
  449. aktfilepos:=entrypos;
  450. addstatement(newstatement,ctryfinallynode.create_implicit(
  451. codeblock,
  452. finalizecode,
  453. exceptcode));
  454. end
  455. else
  456. begin
  457. addstatement(newstatement,initializecode);
  458. addstatement(newstatement,codeblock);
  459. addstatement(newstatement,finalizecode);
  460. end;
  461. resulttypepass(newblock);
  462. code:=newblock;
  463. aktfilepos:=oldfilepos;
  464. end;
  465. procedure compile_proc_body(pd:tprocdef;make_global,parent_has_class:boolean);
  466. {
  467. Compile the body of a procedure
  468. }
  469. var
  470. oldexitlabel,oldexit2label : tasmlabel;
  471. oldquickexitlabel:tasmlabel;
  472. _class,hp:tobjectdef;
  473. { switches can change inside the procedure }
  474. entryswitches, exitswitches : tlocalswitches;
  475. oldaktmaxfpuregisters,localmaxfpuregisters : longint;
  476. { code for the subroutine as tree }
  477. code:tnode;
  478. { true when no stackframe is required }
  479. nostackframe:boolean;
  480. { number of bytes which have to be cleared by RET }
  481. parasize:longint;
  482. { filepositions }
  483. entrypos,
  484. savepos,
  485. exitpos : tfileposinfo;
  486. oldprocdef : tprocdef;
  487. begin
  488. oldprocdef:=current_procdef;
  489. current_procdef:=pd;
  490. { calculate the lexical level }
  491. if current_procdef.parast.symtablelevel>maxnesting then
  492. Message(parser_e_too_much_lexlevel);
  493. { static is also important for local procedures !! }
  494. if (po_staticmethod in current_procdef.procoptions) then
  495. allow_only_static:=true
  496. else if (current_procdef.parast.symtablelevel=normal_function_level) then
  497. allow_only_static:=false;
  498. { save old labels }
  499. oldexitlabel:=aktexitlabel;
  500. oldexit2label:=aktexit2label;
  501. oldquickexitlabel:=quickexitlabel;
  502. { get new labels }
  503. objectlibrary.getlabel(aktexitlabel);
  504. objectlibrary.getlabel(aktexit2label);
  505. { exit for fail in constructors }
  506. if (current_procdef.proctypeoption=potype_constructor) then
  507. objectlibrary.getlabel(quickexitlabel);
  508. { reset break and continue labels }
  509. block_type:=bt_general;
  510. aktbreaklabel:=nil;
  511. aktcontinuelabel:=nil;
  512. {$ifdef state_tracking}
  513. { aktstate:=Tstate_storage.create;}
  514. {$endif state_tracking}
  515. { insert symtables for the class, but only if it is no nested function }
  516. if assigned(current_procdef._class) and not(parent_has_class) then
  517. begin
  518. { insert them in the reverse order }
  519. hp:=nil;
  520. repeat
  521. _class:=current_procdef._class;
  522. while _class.childof<>hp do
  523. _class:=_class.childof;
  524. hp:=_class;
  525. _class.symtable.next:=symtablestack;
  526. symtablestack:=_class.symtable;
  527. until hp=current_procdef._class;
  528. end;
  529. { insert parasymtable in symtablestack when parsing
  530. a function }
  531. if current_procdef.parast.symtablelevel>=normal_function_level then
  532. begin
  533. current_procdef.parast.next:=symtablestack;
  534. symtablestack:=current_procdef.parast;
  535. end;
  536. { create a local symbol table for this routine }
  537. if not assigned(current_procdef.localst) then
  538. current_procdef.insert_localst;
  539. { insert localsymtable in symtablestack}
  540. current_procdef.localst.next:=symtablestack;
  541. symtablestack:=current_procdef.localst;
  542. { constant symbols are inserted in this symboltable }
  543. constsymtable:=symtablestack;
  544. { reset the temporary memory }
  545. rg.cleartempgen;
  546. rg.usedinproc:=[];
  547. rg.usedbyproc:=[];
  548. { save entry info }
  549. entrypos:=aktfilepos;
  550. entryswitches:=aktlocalswitches;
  551. localmaxfpuregisters:=aktmaxfpuregisters;
  552. { parse the code ... }
  553. code:=block(current_module.islibrary);
  554. { get a better entry point }
  555. if assigned(code) then
  556. entrypos:=code.fileinfo;
  557. { save exit info }
  558. exitswitches:=aktlocalswitches;
  559. exitpos:=last_endtoken_filepos;
  560. { save current filepos }
  561. savepos:=aktfilepos;
  562. { add implicit entry and exit code }
  563. if assigned(code) then
  564. add_entry_exit_code(code,entrypos,exitpos);
  565. { store a copy of the original tree for inline, for
  566. normal procedures only store a reference to the
  567. current tree }
  568. if (current_procdef.proccalloption=pocall_inline) then
  569. current_procdef.code:=code.getcopy
  570. else
  571. current_procdef.code:=code;
  572. {When we are called to compile the body of a unit, aktprocsym should
  573. point to the unit initialization. If the unit has no initialization,
  574. aktprocsym=nil. But in that case code=nil. Thus we should check for
  575. code=nil, when we use aktprocsym.}
  576. { set the start offset to the start of the temp area in the stack }
  577. tg.setfirsttemp(current_procinfo.firsttemp_offset);
  578. { ... and generate assembler }
  579. { but set the right switches for entry !! }
  580. aktlocalswitches:=entryswitches;
  581. oldaktmaxfpuregisters:=aktmaxfpuregisters;
  582. aktmaxfpuregisters:=localmaxfpuregisters;
  583. if assigned(code) then
  584. begin
  585. { the procedure is now defined }
  586. current_procdef.forwarddef:=false;
  587. if paraprintnodetree=1 then
  588. printnode_procdef(current_procdef);
  589. { only generate the code if no type errors are found, else
  590. finish at least the type checking pass }
  591. {$ifndef NOPASS2}
  592. if (status.errorcount=0) then
  593. begin
  594. generatecode(code);
  595. { first generate entry code with the correct position and switches }
  596. aktfilepos:=entrypos;
  597. aktlocalswitches:=entryswitches;
  598. genentrycode(current_procinfo.aktentrycode,make_global,0,parasize,nostackframe,false);
  599. { FPC_POPADDRSTACK destroys all registers (JM) }
  600. if (pi_needs_implicit_finally in current_procinfo.flags) or
  601. (pi_uses_exceptions in current_procinfo.flags) then
  602. begin
  603. rg.usedinproc := ALL_REGISTERS;
  604. end;
  605. { now generate exit code with the correct position and switches }
  606. aktfilepos:=exitpos;
  607. aktlocalswitches:=exitswitches;
  608. genexitcode(current_procinfo.aktexitcode,parasize,nostackframe,false);
  609. { now all the registers used are known }
  610. current_procdef.usedintregisters:=rg.usedintinproc;
  611. current_procdef.usedotherregisters:=rg.usedinproc;
  612. current_procinfo.aktproccode.insertlist(current_procinfo.aktentrycode);
  613. current_procinfo.aktproccode.concatlist(current_procinfo.aktexitcode);
  614. {$ifdef newra}
  615. { rg.writegraph;}
  616. {$endif}
  617. if not(cs_no_regalloc in aktglobalswitches) then
  618. begin
  619. {$ifdef newra}
  620. {Do register allocation.}
  621. repeat
  622. rg.prepare_colouring;
  623. rg.colour_registers;
  624. rg.epilogue_colouring;
  625. {Are there spilled registers? We cannot do that yet.}
  626. if rg.spillednodes<>'' then
  627. internalerror(200304221);
  628. {if not try_fast_spill(rg) then
  629. slow_spill(rg);
  630. }
  631. until rg.spillednodes='';
  632. current_procinfo.aktproccode.translate_registers(rg.colour);
  633. current_procinfo.aktproccode.convert_registers;
  634. {$else newra}
  635. current_procinfo.aktproccode.convert_registers;
  636. {$ifndef NoOpt}
  637. if (cs_optimize in aktglobalswitches) and
  638. { do not optimize pure assembler procedures }
  639. not(pi_is_assembler in current_procinfo.flags) then
  640. optimize(current_procinfo.aktproccode);
  641. {$endif NoOpt}
  642. {$endif newra}
  643. end;
  644. { save local data (casetable) also in the same file }
  645. if assigned(current_procinfo.aktlocaldata) and
  646. (not current_procinfo.aktlocaldata.empty) then
  647. begin
  648. current_procinfo.aktproccode.concat(Tai_section.Create(sec_data));
  649. current_procinfo.aktproccode.concatlist(current_procinfo.aktlocaldata);
  650. current_procinfo.aktproccode.concat(Tai_section.Create(sec_code));
  651. end;
  652. { add the procedure to the codesegment }
  653. if (cs_create_smart in aktmoduleswitches) then
  654. codeSegment.concat(Tai_cut.Create);
  655. codeSegment.concatlist(current_procinfo.aktproccode);
  656. end
  657. else
  658. do_resulttypepass(code);
  659. {$else NOPASS2}
  660. do_resulttypepass(code);
  661. {$endif NOPASS2}
  662. end;
  663. { ... remove symbol tables }
  664. if current_procdef.parast.symtablelevel>=normal_function_level then
  665. symtablestack:=symtablestack.next.next
  666. else
  667. symtablestack:=symtablestack.next;
  668. { ... check for unused symbols }
  669. { but only if there is no asm block }
  670. if assigned(code) then
  671. begin
  672. if (Errorcount=0) then
  673. begin
  674. { check if forwards are resolved }
  675. tstoredsymtable(current_procdef.localst).check_forwards;
  676. { check if all labels are used }
  677. tstoredsymtable(current_procdef.localst).checklabels;
  678. { remove cross unit overloads }
  679. tstoredsymtable(current_procdef.localst).unchain_overloaded;
  680. end;
  681. if not(pi_uses_asm in current_procinfo.flags) then
  682. begin
  683. { not for unit init, becuase the var can be used in finalize,
  684. it will be done in proc_unit }
  685. if not(current_procdef.proctypeoption
  686. in [potype_proginit,potype_unitinit,potype_unitfinalize]) then
  687. tstoredsymtable(current_procdef.localst).allsymbolsused;
  688. tstoredsymtable(current_procdef.parast).allsymbolsused;
  689. end;
  690. end;
  691. { the local symtables can be deleted, but the parast }
  692. { doesn't, (checking definitons when calling a }
  693. { function }
  694. { not for a inline procedure !! (PM) }
  695. { at lexlevel = 1 localst is the staticsymtable itself }
  696. { so no dispose here !! }
  697. if assigned(code) and
  698. not(cs_browser in aktmoduleswitches) and
  699. (current_procdef.proccalloption<>pocall_inline) then
  700. begin
  701. if current_procdef.parast.symtablelevel>=normal_function_level then
  702. current_procdef.localst.free;
  703. current_procdef.localst:=nil;
  704. end;
  705. { all registers can be used again }
  706. rg.resetusableregisters;
  707. { only now we can remove the temps }
  708. tg.resettempgen;
  709. { remove code tree, if not inline procedure }
  710. if assigned(code) then
  711. begin
  712. { the inline procedure has already got a copy of the tree
  713. stored in current_procdef.code }
  714. code.free;
  715. if (current_procdef.proccalloption<>pocall_inline) then
  716. current_procdef.code:=nil;
  717. end;
  718. { remove class member symbol tables }
  719. while symtablestack.symtabletype=objectsymtable do
  720. symtablestack:=symtablestack.next;
  721. aktmaxfpuregisters:=oldaktmaxfpuregisters;
  722. {$ifdef state_tracking}
  723. { aktstate.destroy;}
  724. {$endif state_tracking}
  725. { restore filepos, the switches are already set }
  726. aktfilepos:=savepos;
  727. { restore labels }
  728. aktexitlabel:=oldexitlabel;
  729. aktexit2label:=oldexit2label;
  730. quickexitlabel:=oldquickexitlabel;
  731. { reset to normal non static function }
  732. if (current_procdef.parast.symtablelevel=normal_function_level) then
  733. allow_only_static:=false;
  734. current_procdef:=oldprocdef;
  735. end;
  736. {****************************************************************************
  737. PROCEDURE/FUNCTION PARSING
  738. ****************************************************************************}
  739. procedure insert_local_value_para(p:tnamedindexitem;arg:pointer);
  740. var
  741. vs : tvarsym;
  742. pd : tprocdef;
  743. begin
  744. if tsym(p).typ<>varsym then
  745. exit;
  746. with tvarsym(p) do
  747. begin
  748. if copy(name,1,3)='val' then
  749. begin
  750. pd:=tprocdef(owner.defowner);
  751. vs:=tvarsym.create(Copy(name,4,255),varspez,vartype);
  752. vs.fileinfo:=fileinfo;
  753. if not assigned(pd.localst) then
  754. pd.insert_localst;
  755. pd.localst.insert(vs);
  756. pd.localst.insertvardata(vs);
  757. include(vs.varoptions,vo_is_local_copy);
  758. vs.varstate:=vs_assigned;
  759. localvarsym:=vs;
  760. inc(refs); { the para was used to set the local copy ! }
  761. { warnings only on local copy ! }
  762. varstate:=vs_used;
  763. end;
  764. end;
  765. end;
  766. procedure read_proc;
  767. {
  768. Parses the procedure directives, then parses the procedure body, then
  769. generates the code for it
  770. }
  771. var
  772. oldprocdef : tprocdef;
  773. old_current_procinfo : tprocinfo;
  774. oldconstsymtable : tsymtable;
  775. oldselftokenmode,
  776. oldfailtokenmode : tmodeswitch;
  777. pdflags : word;
  778. pd : tprocdef;
  779. begin
  780. { save old state }
  781. oldprocdef:=current_procdef;
  782. oldconstsymtable:=constsymtable;
  783. old_current_procinfo:=current_procinfo;
  784. { reset current_procdef to nil to be sure that nothing is writing
  785. to an other procdef }
  786. current_procdef:=nil;
  787. { create a new procedure }
  788. current_procinfo:=cprocinfo.create(old_current_procinfo);
  789. current_module.procinfo:=current_procinfo;
  790. { parse procedure declaration }
  791. if assigned(current_procinfo.parent) and
  792. assigned(current_procinfo.parent.procdef) then
  793. pd:=parse_proc_dec(current_procinfo.parent.procdef._class)
  794. else
  795. pd:=parse_proc_dec(nil);
  796. current_procinfo.procdef:=pd;
  797. { set the default function options }
  798. if parse_only then
  799. begin
  800. pd.forwarddef:=true;
  801. { set also the interface flag, for better error message when the
  802. implementation doesn't much this header }
  803. pd.interfacedef:=true;
  804. pdflags:=pd_interface;
  805. end
  806. else
  807. begin
  808. pdflags:=pd_body;
  809. if (not current_module.in_interface) then
  810. pdflags:=pdflags or pd_implemen;
  811. if (not current_module.is_unit) or (cs_create_smart in aktmoduleswitches) then
  812. pdflags:=pdflags or pd_global;
  813. pd.forwarddef:=false;
  814. end;
  815. { parse the directives that may follow }
  816. parse_proc_directives(pd,pdflags);
  817. { hint directives, these can be separated by semicolons here,
  818. that needs to be handled here with a loop (PFV) }
  819. while try_consume_hintdirective(pd.symoptions) do
  820. Consume(_SEMICOLON);
  821. { everything of the proc definition is known, we can now
  822. calculate the parameters }
  823. calc_parast(pd);
  824. { search for forward declarations }
  825. if not proc_add_definition(pd) then
  826. begin
  827. { A method must be forward defined (in the object declaration) }
  828. if assigned(pd._class) and
  829. (not assigned(current_procinfo.parent.procdef._class)) then
  830. begin
  831. Message1(parser_e_header_dont_match_any_member,pd.fullprocname(false));
  832. tprocsym(pd.procsym).write_parameter_lists(pd);
  833. end
  834. else
  835. begin
  836. { Give a better error if there is a forward def in the interface and only
  837. a single implementation }
  838. if (not pd.forwarddef) and
  839. (not pd.interfacedef) and
  840. (tprocsym(pd.procsym).procdef_count>1) and
  841. tprocsym(pd.procsym).first_procdef.forwarddef and
  842. tprocsym(pd.procsym).first_procdef.interfacedef and
  843. not(tprocsym(pd.procsym).procdef_count>2) then
  844. begin
  845. Message1(parser_e_header_dont_match_forward,pd.fullprocname(false));
  846. tprocsym(pd.procsym).write_parameter_lists(pd);
  847. end
  848. else
  849. begin
  850. { check the global flag, for delphi this is not
  851. required }
  852. if not(m_delphi in aktmodeswitches) and
  853. (pi_is_global in current_procinfo.flags) then
  854. Message(parser_e_overloaded_must_be_all_global);
  855. end;
  856. end;
  857. end;
  858. { update procinfo, because the procdef can be
  859. changed by check_identical_proc (PFV) }
  860. current_procinfo.procdef:=pd;
  861. { compile procedure when a body is needed }
  862. if (pdflags and pd_body)<>0 then
  863. begin
  864. Message1(parser_d_procedure_start,pd.fullprocname(false));
  865. pd.aliasnames.insert(pd.mangledname);
  866. { Insert result variables in the localst }
  867. insert_funcret_local(pd);
  868. { Insert local copies for value para }
  869. pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}insert_local_value_para,nil);
  870. { Update parameter information }
  871. current_procinfo.allocate_implicit_parameter;
  872. {$ifdef i386}
  873. { add implicit pushes for interrupt routines }
  874. if (po_interrupt in pd.procoptions) then
  875. current_procinfo.allocate_interrupt_stackframe;
  876. {$endif i386}
  877. { Calculate offsets }
  878. current_procinfo.after_header;
  879. { set _FAIL as keyword if constructor }
  880. if (pd.proctypeoption=potype_constructor) then
  881. begin
  882. oldfailtokenmode:=tokeninfo^[_FAIL].keyword;
  883. tokeninfo^[_FAIL].keyword:=m_all;
  884. end;
  885. { set _SELF as keyword if methods }
  886. if assigned(pd._class) then
  887. begin
  888. oldselftokenmode:=tokeninfo^[_SELF].keyword;
  889. tokeninfo^[_SELF].keyword:=m_all;
  890. end;
  891. compile_proc_body(pd,((pdflags and pd_global)<>0),assigned(current_procinfo.parent.procdef._class));
  892. { reset _FAIL as _SELF normal }
  893. if (pd.proctypeoption=potype_constructor) then
  894. tokeninfo^[_FAIL].keyword:=oldfailtokenmode;
  895. if assigned(pd._class) then
  896. tokeninfo^[_SELF].keyword:=oldselftokenmode;
  897. consume(_SEMICOLON);
  898. end;
  899. { release procinfo }
  900. if tprocinfo(current_module.procinfo)<>current_procinfo then
  901. internalerror(200304274);
  902. current_module.procinfo:=current_procinfo.parent;
  903. current_procinfo.free;
  904. { Restore old state }
  905. constsymtable:=oldconstsymtable;
  906. current_procdef:=oldprocdef;
  907. current_procinfo:=old_current_procinfo;
  908. end;
  909. {****************************************************************************
  910. DECLARATION PARSING
  911. ****************************************************************************}
  912. { search in symtablestack for not complete classes }
  913. procedure check_forward_class(p : tnamedindexitem;arg:pointer);
  914. begin
  915. if (tsym(p).typ=typesym) and
  916. (ttypesym(p).restype.def.deftype=objectdef) and
  917. (oo_is_forward in tobjectdef(ttypesym(p).restype.def).objectoptions) then
  918. MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
  919. end;
  920. procedure read_declarations(islibrary : boolean);
  921. procedure Not_supported_for_inline(t : ttoken);
  922. begin
  923. if (current_procdef.proccalloption=pocall_inline) then
  924. Begin
  925. Message1(parser_w_not_supported_for_inline,tokenstring(t));
  926. Message(parser_w_inlining_disabled);
  927. current_procdef.proccalloption:=pocall_fpccall;
  928. End;
  929. end;
  930. begin
  931. repeat
  932. if not assigned(current_procdef) then
  933. internalerror(200304251);
  934. case token of
  935. _LABEL:
  936. begin
  937. Not_supported_for_inline(token);
  938. label_dec;
  939. end;
  940. _CONST:
  941. begin
  942. Not_supported_for_inline(token);
  943. const_dec;
  944. end;
  945. _TYPE:
  946. begin
  947. Not_supported_for_inline(token);
  948. type_dec;
  949. end;
  950. _VAR:
  951. var_dec;
  952. _THREADVAR:
  953. threadvar_dec;
  954. _CONSTRUCTOR,_DESTRUCTOR,
  955. _FUNCTION,_PROCEDURE,_OPERATOR,_CLASS:
  956. begin
  957. Not_supported_for_inline(token);
  958. read_proc;
  959. end;
  960. _RESOURCESTRING:
  961. resourcestring_dec;
  962. _EXPORTS:
  963. begin
  964. Not_supported_for_inline(token);
  965. if not(assigned(current_procdef.localst)) or
  966. (current_procdef.localst.symtablelevel>main_program_level) or
  967. (current_module.is_unit) then
  968. begin
  969. Message(parser_e_syntax_error);
  970. consume_all_until(_SEMICOLON);
  971. end
  972. else if islibrary or
  973. (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware]) then
  974. read_exports
  975. else
  976. begin
  977. Message(parser_w_unsupported_feature);
  978. consume(_BEGIN);
  979. end;
  980. end
  981. else break;
  982. end;
  983. until false;
  984. { check for incomplete class definitions, this is only required
  985. for fpc modes }
  986. if (m_fpc in aktmodeswitches) then
  987. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  988. end;
  989. procedure read_interface_declarations;
  990. begin
  991. repeat
  992. case token of
  993. _CONST :
  994. const_dec;
  995. _TYPE :
  996. type_dec;
  997. _VAR :
  998. var_dec;
  999. _THREADVAR :
  1000. threadvar_dec;
  1001. _RESOURCESTRING:
  1002. resourcestring_dec;
  1003. _FUNCTION,
  1004. _PROCEDURE,
  1005. _OPERATOR :
  1006. read_proc;
  1007. else
  1008. break;
  1009. end;
  1010. until false;
  1011. { check for incomplete class definitions, this is only required
  1012. for fpc modes }
  1013. if (m_fpc in aktmodeswitches) then
  1014. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  1015. end;
  1016. end.
  1017. {
  1018. $Log$
  1019. Revision 1.112 2003-05-13 21:26:38 peter
  1020. * only call destructor in except block when there is a destructor
  1021. available
  1022. Revision 1.111 2003/05/13 19:14:41 peter
  1023. * failn removed
  1024. * inherited result code check moven to pexpr
  1025. Revision 1.110 2003/05/13 15:18:49 peter
  1026. * fixed various crashes
  1027. Revision 1.109 2003/05/11 21:37:03 peter
  1028. * moved implicit exception frame from ncgutil to psub
  1029. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1030. Revision 1.108 2003/05/09 17:47:03 peter
  1031. * self moved to hidden parameter
  1032. * removed hdisposen,hnewn,selfn
  1033. Revision 1.107 2003/04/27 11:21:34 peter
  1034. * aktprocdef renamed to current_procdef
  1035. * procinfo renamed to current_procinfo
  1036. * procinfo will now be stored in current_module so it can be
  1037. cleaned up properly
  1038. * gen_main_procsym changed to create_main_proc and release_main_proc
  1039. to also generate a tprocinfo structure
  1040. * fixed unit implicit initfinal
  1041. Revision 1.106 2003/04/27 07:29:50 peter
  1042. * current_procdef cleanup, current_procdef is now always nil when parsing
  1043. a new procdef declaration
  1044. * aktprocsym removed
  1045. * lexlevel removed, use symtable.symtablelevel instead
  1046. * implicit init/final code uses the normal genentry/genexit
  1047. * funcret state checking updated for new funcret handling
  1048. Revision 1.105 2003/04/26 00:31:42 peter
  1049. * set return_offset moved to after_header
  1050. Revision 1.104 2003/04/25 20:59:34 peter
  1051. * removed funcretn,funcretsym, function result is now in varsym
  1052. and aliases for result and function name are added using absolutesym
  1053. * vs_hidden parameter for funcret passed in parameter
  1054. * vs_hidden fixes
  1055. * writenode changed to printnode and released from extdebug
  1056. * -vp option added to generate a tree.log with the nodetree
  1057. * nicer printnode for statements, callnode
  1058. Revision 1.103 2003/04/24 13:03:01 florian
  1059. * comp is now written with its bit pattern to the ppu instead as an extended
  1060. Revision 1.102 2003/04/23 12:35:34 florian
  1061. * fixed several issues with powerpc
  1062. + applied a patch from Jonas for nested function calls (PowerPC only)
  1063. * ...
  1064. Revision 1.101 2003/04/22 14:33:38 peter
  1065. * removed some notes/hints
  1066. Revision 1.100 2003/04/22 13:47:08 peter
  1067. * fixed C style array of const
  1068. * fixed C array passing
  1069. * fixed left to right with high parameters
  1070. Revision 1.99 2003/04/22 10:09:35 daniel
  1071. + Implemented the actual register allocator
  1072. + Scratch registers unavailable when new register allocator used
  1073. + maybe_save/maybe_restore unavailable when new register allocator used
  1074. Revision 1.98 2003/04/17 07:50:24 daniel
  1075. * Some work on interference graph construction
  1076. Revision 1.97 2003/04/16 09:26:55 jonas
  1077. * assembler procedures now again get a stackframe if they have local
  1078. variables. No space is reserved for a function result however.
  1079. Also, the register parameters aren't automatically saved on the stack
  1080. anymore in assembler procedures.
  1081. Revision 1.96 2003/04/05 21:09:31 jonas
  1082. * several ppc/generic result offset related fixes. The "normal" result
  1083. offset seems now to be calculated correctly and a lot of duplicate
  1084. calculations have been removed. Nested functions accessing the parent's
  1085. function result don't work at all though :(
  1086. Revision 1.95 2003/04/02 16:11:34 peter
  1087. * give error when exports is not supported
  1088. Revision 1.94 2003/03/12 22:43:38 jonas
  1089. * more powerpc and generic fixes related to the new register allocator
  1090. Revision 1.93 2003/03/08 08:59:07 daniel
  1091. + $define newra will enable new register allocator
  1092. + getregisterint will return imaginary registers with $newra
  1093. + -sr switch added, will skip register allocation so you can see
  1094. the direct output of the code generator before register allocation
  1095. Revision 1.92 2003/02/19 22:00:14 daniel
  1096. * Code generator converted to new register notation
  1097. - Horribily outdated todo.txt removed
  1098. Revision 1.91 2003/01/09 21:52:37 peter
  1099. * merged some verbosity options.
  1100. * V_LineInfo is a verbosity flag to include line info
  1101. Revision 1.90 2003/01/09 20:40:59 daniel
  1102. * Converted some code in cgx86.pas to new register numbering
  1103. Revision 1.89 2003/01/09 15:49:56 daniel
  1104. * Added register conversion
  1105. Revision 1.88 2003/01/08 18:43:56 daniel
  1106. * Tregister changed into a record
  1107. Revision 1.87 2003/01/03 20:35:08 peter
  1108. * check also interfacedef when checking for matching forwarddef
  1109. Revision 1.86 2003/01/02 11:14:02 michael
  1110. + Patch from peter to support initial values for local variables
  1111. Revision 1.85 2002/12/29 18:59:34 peter
  1112. * fixed parsing of declarations before asm statement
  1113. Revision 1.84 2002/12/29 18:25:18 peter
  1114. * parse declarations before check _ASM token
  1115. Revision 1.83 2002/12/29 14:57:50 peter
  1116. * unit loading changed to first register units and load them
  1117. afterwards. This is needed to support uses xxx in yyy correctly
  1118. * unit dependency check fixed
  1119. Revision 1.82 2002/12/25 01:26:56 peter
  1120. * duplicate procsym-unitsym fix
  1121. Revision 1.81 2002/12/15 13:37:15 peter
  1122. * don't include uf_init for library. The code is already called and
  1123. does not need to be in the initfinal table
  1124. Revision 1.80 2002/12/07 14:27:09 carl
  1125. * 3% memory optimization
  1126. * changed some types
  1127. + added type checking with different size for call node and for
  1128. parameters
  1129. Revision 1.79 2002/11/25 18:43:32 carl
  1130. - removed the invalid if <> checking (Delphi is strange on this)
  1131. + implemented abstract warning on instance creation of class with
  1132. abstract methods.
  1133. * some error message cleanups
  1134. Revision 1.78 2002/11/25 17:43:23 peter
  1135. * splitted defbase in defutil,symutil,defcmp
  1136. * merged isconvertable and is_equal into compare_defs(_ext)
  1137. * made operator search faster by walking the list only once
  1138. Revision 1.77 2002/11/23 22:50:06 carl
  1139. * some small speed optimizations
  1140. + added several new warnings/hints
  1141. Revision 1.76 2002/11/18 17:31:58 peter
  1142. * pass proccalloption to ret_in_xxx and push_xxx functions
  1143. Revision 1.75 2002/11/17 16:31:57 carl
  1144. * memory optimization (3-4%) : cleanup of tai fields,
  1145. cleanup of tdef and tsym fields.
  1146. * make it work for m68k
  1147. Revision 1.74 2002/11/15 01:58:53 peter
  1148. * merged changes from 1.0.7 up to 04-11
  1149. - -V option for generating bug report tracing
  1150. - more tracing for option parsing
  1151. - errors for cdecl and high()
  1152. - win32 import stabs
  1153. - win32 records<=8 are returned in eax:edx (turned off by default)
  1154. - heaptrc update
  1155. - more info for temp management in .s file with EXTDEBUG
  1156. Revision 1.73 2002/11/09 15:32:30 carl
  1157. * noopt for non-i386 targets
  1158. Revision 1.72 2002/09/10 20:31:48 florian
  1159. * call to current_procinfo.after_header added
  1160. Revision 1.71 2002/09/07 15:25:07 peter
  1161. * old logs removed and tabs fixed
  1162. Revision 1.70 2002/09/03 16:26:27 daniel
  1163. * Make Tprocdef.defs protected
  1164. Revision 1.69 2002/08/25 19:25:20 peter
  1165. * sym.insert_in_data removed
  1166. * symtable.insertvardata/insertconstdata added
  1167. * removed insert_in_data call from symtable.insert, it needs to be
  1168. called separatly. This allows to deref the address calculation
  1169. * procedures now calculate the parast addresses after the procedure
  1170. directives are parsed. This fixes the cdecl parast problem
  1171. * push_addr_param has an extra argument that specifies if cdecl is used
  1172. or not
  1173. Revision 1.68 2002/08/17 09:23:41 florian
  1174. * first part of procinfo rewrite
  1175. Revision 1.67 2002/08/16 14:24:59 carl
  1176. * issameref() to test if two references are the same (then emit no opcodes)
  1177. + ret_in_reg to replace ret_in_acc
  1178. (fix some register allocation bugs at the same time)
  1179. + save_std_register now has an extra parameter which is the
  1180. usedinproc registers
  1181. Revision 1.66 2002/08/11 14:32:27 peter
  1182. * renamed current_library to objectlibrary
  1183. Revision 1.65 2002/08/11 13:24:13 peter
  1184. * saving of asmsymbols in ppu supported
  1185. * asmsymbollist global is removed and moved into a new class
  1186. tasmlibrarydata that will hold the info of a .a file which
  1187. corresponds with a single module. Added librarydata to tmodule
  1188. to keep the library info stored for the module. In the future the
  1189. objectfiles will also be stored to the tasmlibrarydata class
  1190. * all getlabel/newasmsymbol and friends are moved to the new class
  1191. Revision 1.64 2002/08/09 19:14:28 carl
  1192. * fixed stackframe parameter (should only contain local size),
  1193. set to zero currently
  1194. Revision 1.63 2002/08/06 20:55:22 florian
  1195. * first part of ppc calling conventions fix
  1196. Revision 1.62 2002/07/26 21:15:41 florian
  1197. * rewrote the system handling
  1198. Revision 1.61 2002/07/20 11:57:56 florian
  1199. * types.pas renamed to defbase.pas because D6 contains a types
  1200. unit so this would conflicts if D6 programms are compiled
  1201. + Willamette/SSE2 instructions to assembler added
  1202. Revision 1.60 2002/07/19 11:41:36 daniel
  1203. * State tracker work
  1204. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1205. allows the state tracker to change while nodes automatically into
  1206. repeat nodes.
  1207. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1208. 'not(a>b)' is optimized into 'a<=b'.
  1209. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1210. by removing the notn and later switchting the true and falselabels. The
  1211. same is done with 'repeat until not a'.
  1212. Revision 1.59 2002/07/15 18:03:15 florian
  1213. * readded removed changes
  1214. Revision 1.57 2002/07/11 14:41:28 florian
  1215. * start of the new generic parameter handling
  1216. Revision 1.58 2002/07/14 18:00:44 daniel
  1217. + Added the beginning of a state tracker. This will track the values of
  1218. variables through procedures and optimize things away.
  1219. Revision 1.56 2002/07/07 09:52:32 florian
  1220. * powerpc target fixed, very simple units can be compiled
  1221. * some basic stuff for better callparanode handling, far from being finished
  1222. Revision 1.55 2002/07/04 20:43:01 florian
  1223. * first x86-64 patches
  1224. Revision 1.54 2002/07/01 18:46:25 peter
  1225. * internal linker
  1226. * reorganized aasm layer
  1227. Revision 1.53 2002/05/18 13:34:14 peter
  1228. * readded missing revisions
  1229. Revision 1.52 2002/05/16 19:46:44 carl
  1230. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1231. + try to fix temp allocation (still in ifdef)
  1232. + generic constructor calls
  1233. + start of tassembler / tmodulebase class cleanup
  1234. Revision 1.51 2002/05/14 19:34:49 peter
  1235. * removed old logs and updated copyright year
  1236. }