psub.pas 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905
  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. cclasses,globals,
  23. node,nbas,
  24. symdef,procinfo;
  25. type
  26. tcgprocinfo=class(tprocinfo)
  27. { code for the subroutine as tree }
  28. code : tnode;
  29. { positions in the tree for init/final }
  30. entry_asmnode,
  31. loadpara_asmnode,
  32. exitlabel_asmnode,
  33. init_asmnode,
  34. final_asmnode : tasmnode;
  35. { list to store the procinfo's of the nested procedures }
  36. nestedprocs : tlinkedlist;
  37. constructor create(aparent:tprocinfo);override;
  38. destructor destroy;override;
  39. procedure generate_code;
  40. procedure resetprocdef;
  41. procedure add_to_symtablestack;
  42. procedure remove_from_symtablestack;
  43. procedure parse_body;
  44. procedure add_entry_exit_code;
  45. end;
  46. procedure printnode_reset;
  47. { reads the declaration blocks }
  48. procedure read_declarations(islibrary : boolean);
  49. { reads declarations in the interface part of a unit }
  50. procedure read_interface_declarations;
  51. implementation
  52. uses
  53. { common }
  54. cutils,
  55. { global }
  56. globtype,tokens,verbose,comphook,
  57. systems,
  58. { aasm }
  59. cpubase,aasmtai,
  60. { symtable }
  61. symconst,symbase,symsym,symtype,symtable,defutil,
  62. paramgr,
  63. ppu,fmodule,
  64. { pass 1 }
  65. nutils,nld,ncal,ncon,nflw,nadd,ncnv,nmem,
  66. pass_1,
  67. {$ifdef state_tracking}
  68. nstate,
  69. {$endif state_tracking}
  70. { pass 2 }
  71. {$ifndef NOPASS2}
  72. pass_2,
  73. {$endif}
  74. { parser }
  75. scanner,
  76. pbase,pstatmnt,pdecl,pdecsub,pexports,
  77. { codegen }
  78. tgobj,cgobj,
  79. ncgutil,regvars
  80. {$ifndef NOOPT}
  81. {$ifdef i386}
  82. ,aopt386
  83. {$else i386}
  84. ,aoptcpu
  85. {$endif i386}
  86. {$endif}
  87. ;
  88. {****************************************************************************
  89. PROCEDURE/FUNCTION BODY PARSING
  90. ****************************************************************************}
  91. procedure initializevars(p:tnamedindexitem;arg:pointer);
  92. var
  93. b : tblocknode;
  94. begin
  95. if tsym(p).typ<>varsym then
  96. exit;
  97. with tvarsym(p) do
  98. begin
  99. if assigned(defaultconstsym) then
  100. begin
  101. b:=tblocknode(arg);
  102. b.left:=cstatementnode.create(
  103. cassignmentnode.create(
  104. cloadnode.create(tsym(p),tsym(p).owner),
  105. cloadnode.create(defaultconstsym,defaultconstsym.owner)),
  106. b.left);
  107. end;
  108. end;
  109. end;
  110. function block(islibrary : boolean) : tnode;
  111. begin
  112. { parse const,types and vars }
  113. read_declarations(islibrary);
  114. { do we have an assembler block without the po_assembler?
  115. we should allow this for Delphi compatibility (PFV) }
  116. if (token=_ASM) and (m_delphi in aktmodeswitches) then
  117. include(current_procinfo.procdef.procoptions,po_assembler);
  118. { Handle assembler block different }
  119. if (po_assembler in current_procinfo.procdef.procoptions) then
  120. begin
  121. block:=assembler_block;
  122. exit;
  123. end;
  124. {Unit initialization?.}
  125. if (
  126. assigned(current_procinfo.procdef.localst) and
  127. (current_procinfo.procdef.localst.symtablelevel=main_program_level) and
  128. (current_module.is_unit)
  129. ) or
  130. islibrary then
  131. begin
  132. if (token=_END) then
  133. begin
  134. consume(_END);
  135. { We need at least a node, else the entry/exit code is not
  136. generated and thus no PASCALMAIN symbol which we need (PFV) }
  137. if islibrary then
  138. block:=cnothingnode.create
  139. else
  140. block:=nil;
  141. end
  142. else
  143. begin
  144. if token=_INITIALIZATION then
  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(_INITIALIZATION);
  151. end
  152. else if (token=_FINALIZATION) then
  153. begin
  154. if (current_module.flags and uf_finalize)<>0 then
  155. block:=statement_block(_FINALIZATION)
  156. else
  157. begin
  158. { can we allow no INITIALIZATION for DLL ??
  159. I think it should work PM }
  160. block:=nil;
  161. exit;
  162. end;
  163. end
  164. else
  165. begin
  166. { The library init code is already called and does not
  167. need to be in the initfinal table (PFV) }
  168. if not islibrary then
  169. current_module.flags:=current_module.flags or uf_init;
  170. block:=statement_block(_BEGIN);
  171. end;
  172. end;
  173. end
  174. else
  175. begin
  176. block:=statement_block(_BEGIN);
  177. if symtablestack.symtabletype=localsymtable then
  178. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}initializevars,block);
  179. end;
  180. if (current_procinfo.procdef.localst.symtablelevel=main_program_level) and
  181. (not current_module.is_unit) then
  182. begin
  183. { there's always a call to FPC_DO_EXIT in the main program }
  184. include(current_procinfo.flags,pi_do_call);
  185. end;
  186. if ([cs_check_range,cs_check_overflow] * aktlocalswitches <> []) then
  187. include(current_procinfo.flags,pi_do_call);
  188. end;
  189. {****************************************************************************
  190. PROCEDURE/FUNCTION COMPILING
  191. ****************************************************************************}
  192. procedure printnode_reset;
  193. begin
  194. assign(printnodefile,treelogfilename);
  195. {$I-}
  196. rewrite(printnodefile);
  197. {$I+}
  198. if ioresult<>0 then
  199. begin
  200. Comment(V_Error,'Error creating '+treelogfilename);
  201. exit;
  202. end;
  203. close(printnodefile);
  204. end;
  205. procedure printnode_procdef(pd:tprocdef);
  206. begin
  207. assign(printnodefile,treelogfilename);
  208. {$I-}
  209. append(printnodefile);
  210. if ioresult<>0 then
  211. rewrite(printnodefile);
  212. {$I+}
  213. if ioresult<>0 then
  214. begin
  215. Comment(V_Error,'Error creating '+treelogfilename);
  216. exit;
  217. end;
  218. writeln(printnodefile);
  219. writeln(printnodefile,'*******************************************************************************');
  220. writeln(printnodefile,current_procinfo.procdef.fullprocname(false));
  221. writeln(printnodefile,'*******************************************************************************');
  222. printnode(printnodefile,pd.inlininginfo^.code);
  223. close(printnodefile);
  224. end;
  225. function generate_bodyentry_block:tnode;
  226. var
  227. srsym : tsym;
  228. para : tcallparanode;
  229. newstatement : tstatementnode;
  230. htype : ttype;
  231. begin
  232. result:=internalstatements(newstatement);
  233. if assigned(current_procinfo.procdef._class) then
  234. begin
  235. { a constructor needs a help procedure }
  236. if (current_procinfo.procdef.proctypeoption=potype_constructor) then
  237. begin
  238. if is_class(current_procinfo.procdef._class) then
  239. begin
  240. if (cs_implicit_exceptions in aktmoduleswitches) then
  241. include(current_procinfo.flags,pi_needs_implicit_finally);
  242. srsym:=search_class_member(current_procinfo.procdef._class,'NEWINSTANCE');
  243. if assigned(srsym) and
  244. (srsym.typ=procsym) then
  245. begin
  246. { if vmt<>0 then newinstance }
  247. addstatement(newstatement,cifnode.create(
  248. caddnode.create(unequaln,
  249. load_vmt_pointer_node,
  250. cnilnode.create),
  251. cassignmentnode.create(
  252. ctypeconvnode.create_explicit(
  253. load_self_pointer_node,
  254. voidpointertype),
  255. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_vmt_pointer_node)),
  256. nil));
  257. end
  258. else
  259. internalerror(200305108);
  260. end
  261. else
  262. if is_object(current_procinfo.procdef._class) then
  263. begin
  264. htype.setdef(current_procinfo.procdef._class);
  265. htype.setdef(tpointerdef.create(htype));
  266. { parameter 3 : vmt_offset }
  267. { parameter 2 : address of pointer to vmt,
  268. this is required to allow setting the vmt to -1 to indicate
  269. that memory was allocated }
  270. { parameter 1 : self pointer }
  271. para:=ccallparanode.create(
  272. cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32bittype,false),
  273. ccallparanode.create(
  274. ctypeconvnode.create_explicit(
  275. load_vmt_pointer_node,
  276. voidpointertype),
  277. ccallparanode.create(
  278. ctypeconvnode.create_explicit(
  279. load_self_pointer_node,
  280. voidpointertype),
  281. nil)));
  282. addstatement(newstatement,cassignmentnode.create(
  283. ctypeconvnode.create_explicit(
  284. load_self_pointer_node,
  285. voidpointertype),
  286. ccallnode.createintern('fpc_help_constructor',para)));
  287. end
  288. else
  289. internalerror(200305103);
  290. { if self=nil then exit
  291. calling fail instead of exit is useless because
  292. there is nothing to dispose (PFV) }
  293. addstatement(newstatement,cifnode.create(
  294. caddnode.create(equaln,
  295. load_self_pointer_node,
  296. cnilnode.create),
  297. cexitnode.create(nil),
  298. nil));
  299. end;
  300. { maybe call BeforeDestruction for classes }
  301. if (current_procinfo.procdef.proctypeoption=potype_destructor) and
  302. is_class(current_procinfo.procdef._class) then
  303. begin
  304. srsym:=search_class_member(current_procinfo.procdef._class,'BEFOREDESTRUCTION');
  305. if assigned(srsym) and
  306. (srsym.typ=procsym) then
  307. begin
  308. { if vmt<>0 then beforedestruction }
  309. addstatement(newstatement,cifnode.create(
  310. caddnode.create(unequaln,
  311. load_vmt_pointer_node,
  312. cnilnode.create),
  313. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  314. nil));
  315. end
  316. else
  317. internalerror(200305104);
  318. end;
  319. end;
  320. end;
  321. function generate_bodyexit_block:tnode;
  322. var
  323. srsym : tsym;
  324. para : tcallparanode;
  325. newstatement : tstatementnode;
  326. begin
  327. result:=internalstatements(newstatement);
  328. if assigned(current_procinfo.procdef._class) then
  329. begin
  330. { maybe call AfterConstruction for classes }
  331. if (current_procinfo.procdef.proctypeoption=potype_constructor) and
  332. is_class(current_procinfo.procdef._class) then
  333. begin
  334. srsym:=search_class_member(current_procinfo.procdef._class,'AFTERCONSTRUCTION');
  335. if assigned(srsym) and
  336. (srsym.typ=procsym) then
  337. begin
  338. { Self can be nil when fail is called }
  339. { if self<>nil and vmt<>nil then afterconstruction }
  340. addstatement(newstatement,cifnode.create(
  341. caddnode.create(andn,
  342. caddnode.create(unequaln,
  343. load_self_pointer_node,
  344. cnilnode.create),
  345. caddnode.create(unequaln,
  346. load_vmt_pointer_node,
  347. cnilnode.create)),
  348. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  349. nil));
  350. end
  351. else
  352. internalerror(200305106);
  353. end;
  354. { a destructor needs a help procedure }
  355. if (current_procinfo.procdef.proctypeoption=potype_destructor) then
  356. begin
  357. if is_class(current_procinfo.procdef._class) then
  358. begin
  359. srsym:=search_class_member(current_procinfo.procdef._class,'FREEINSTANCE');
  360. if assigned(srsym) and
  361. (srsym.typ=procsym) then
  362. begin
  363. { if self<>0 and vmt=1 then freeinstance }
  364. addstatement(newstatement,cifnode.create(
  365. caddnode.create(andn,
  366. caddnode.create(unequaln,
  367. load_self_pointer_node,
  368. cnilnode.create),
  369. caddnode.create(equaln,
  370. ctypeconvnode.create(
  371. load_vmt_pointer_node,
  372. voidpointertype),
  373. cpointerconstnode.create(1,voidpointertype))),
  374. ccallnode.create(nil,tprocsym(srsym),srsym.owner,load_self_node),
  375. nil));
  376. end
  377. else
  378. internalerror(200305108);
  379. end
  380. else
  381. if is_object(current_procinfo.procdef._class) then
  382. begin
  383. { finalize object data }
  384. if current_procinfo.procdef._class.needs_inittable then
  385. addstatement(newstatement,finalize_data_node(load_self_node));
  386. { parameter 3 : vmt_offset }
  387. { parameter 2 : pointer to vmt }
  388. { parameter 1 : self pointer }
  389. para:=ccallparanode.create(
  390. cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32bittype,false),
  391. ccallparanode.create(
  392. ctypeconvnode.create_explicit(
  393. load_vmt_pointer_node,
  394. voidpointertype),
  395. ccallparanode.create(
  396. ctypeconvnode.create_explicit(
  397. load_self_pointer_node,
  398. voidpointertype),
  399. nil)));
  400. addstatement(newstatement,
  401. ccallnode.createintern('fpc_help_destructor',para));
  402. end
  403. else
  404. internalerror(200305105);
  405. end;
  406. end;
  407. end;
  408. function generate_except_block:tnode;
  409. var
  410. pd : tprocdef;
  411. newstatement : tstatementnode;
  412. begin
  413. generate_except_block:=internalstatements(newstatement);
  414. { a constructor needs call destructor (if available) when it
  415. is not inherited }
  416. if assigned(current_procinfo.procdef._class) and
  417. (current_procinfo.procdef.proctypeoption=potype_constructor) then
  418. begin
  419. pd:=current_procinfo.procdef._class.searchdestructor;
  420. if assigned(pd) then
  421. begin
  422. { if vmt<>0 then call destructor }
  423. addstatement(newstatement,cifnode.create(
  424. caddnode.create(unequaln,
  425. load_vmt_pointer_node,
  426. cnilnode.create),
  427. ccallnode.create(nil,tprocsym(pd.procsym),pd.procsym.owner,load_self_node),
  428. nil));
  429. end;
  430. end
  431. else
  432. begin
  433. { no constructor }
  434. { must be the return value finalized before reraising the exception? }
  435. if (not is_void(current_procinfo.procdef.rettype.def)) and
  436. (current_procinfo.procdef.rettype.def.needs_inittable) and
  437. (not is_class(current_procinfo.procdef.rettype.def)) then
  438. addstatement(newstatement,finalize_data_node(load_result_node));
  439. end;
  440. end;
  441. {****************************************************************************
  442. TCGProcInfo
  443. ****************************************************************************}
  444. constructor tcgprocinfo.create(aparent:tprocinfo);
  445. begin
  446. inherited Create(aparent);
  447. nestedprocs:=tlinkedlist.create;
  448. end;
  449. destructor tcgprocinfo.destroy;
  450. begin
  451. nestedprocs.free;
  452. if assigned(code) then
  453. code.free;
  454. inherited destroy;
  455. end;
  456. procedure tcgprocinfo.add_entry_exit_code;
  457. var
  458. finalcode,
  459. bodyentrycode,
  460. bodyexitcode,
  461. exceptcode : tnode;
  462. newblock : tblocknode;
  463. codestatement,
  464. newstatement : tstatementnode;
  465. oldfilepos : tfileposinfo;
  466. begin
  467. oldfilepos:=aktfilepos;
  468. { Generate code/locations used at start of proc }
  469. aktfilepos:=entrypos;
  470. entry_asmnode:=casmnode.create_get_position;
  471. loadpara_asmnode:=casmnode.create_get_position;
  472. init_asmnode:=casmnode.create_get_position;
  473. bodyentrycode:=generate_bodyentry_block;
  474. { Generate code/locations used at end of proc }
  475. aktfilepos:=exitpos;
  476. exitlabel_asmnode:=casmnode.create_get_position;
  477. final_asmnode:=casmnode.create_get_position;
  478. bodyexitcode:=generate_bodyexit_block;
  479. { Generate procedure by combining init+body+final,
  480. depending on the implicit finally we need to add
  481. an try...finally...end wrapper }
  482. newblock:=internalstatements(newstatement);
  483. if (pi_needs_implicit_finally in flags) and
  484. { but it's useless in init/final code of units }
  485. not(procdef.proctypeoption in [potype_unitfinalize,potype_unitinit]) then
  486. begin
  487. { Generate special exception block only needed when
  488. implicit finaly is used }
  489. aktfilepos:=exitpos;
  490. exceptcode:=generate_except_block;
  491. { Generate code that will be in the try...finally }
  492. finalcode:=internalstatements(codestatement);
  493. addstatement(codestatement,bodyexitcode);
  494. addstatement(codestatement,final_asmnode);
  495. { Initialize before try...finally...end frame }
  496. addstatement(newstatement,entry_asmnode);
  497. addstatement(newstatement,loadpara_asmnode);
  498. addstatement(newstatement,init_asmnode);
  499. addstatement(newstatement,bodyentrycode);
  500. aktfilepos:=entrypos;
  501. addstatement(newstatement,ctryfinallynode.create_implicit(
  502. code,
  503. finalcode,
  504. exceptcode));
  505. addstatement(newstatement,exitlabel_asmnode);
  506. end
  507. else
  508. begin
  509. addstatement(newstatement,entry_asmnode);
  510. addstatement(newstatement,loadpara_asmnode);
  511. addstatement(newstatement,init_asmnode);
  512. addstatement(newstatement,bodyentrycode);
  513. addstatement(newstatement,code);
  514. addstatement(newstatement,exitlabel_asmnode);
  515. addstatement(newstatement,bodyexitcode);
  516. addstatement(newstatement,final_asmnode);
  517. end;
  518. resulttypepass(newblock);
  519. code:=newblock;
  520. aktfilepos:=oldfilepos;
  521. end;
  522. procedure clearrefs(p : tnamedindexitem;arg:pointer);
  523. begin
  524. if (tsym(p).typ=varsym) then
  525. if tvarsym(p).refs>1 then
  526. tvarsym(p).refs:=1;
  527. end;
  528. procedure tcgprocinfo.generate_code;
  529. var
  530. oldprocinfo : tprocinfo;
  531. oldaktmaxfpuregisters : longint;
  532. oldfilepos : tfileposinfo;
  533. templist : Taasmoutput;
  534. headertai : tai;
  535. usesacc,
  536. usesfpu,
  537. usesacchi : boolean;
  538. begin
  539. { the initialization procedure can be empty, then we
  540. don't need to generate anything. When it was an empty
  541. procedure there would be at least a blocknode }
  542. if not assigned(code) then
  543. exit;
  544. { We need valid code }
  545. if Errorcount<>0 then
  546. exit;
  547. { The RA and Tempgen shall not be available yet }
  548. if assigned(tg) then
  549. internalerror(200309201);
  550. oldprocinfo:=current_procinfo;
  551. oldfilepos:=aktfilepos;
  552. oldaktmaxfpuregisters:=aktmaxfpuregisters;
  553. current_procinfo:=self;
  554. aktfilepos:=entrypos;
  555. { get new labels }
  556. aktbreaklabel:=nil;
  557. aktcontinuelabel:=nil;
  558. templist:=Taasmoutput.create;
  559. { add parast/localst to symtablestack }
  560. add_to_symtablestack;
  561. { when size optimization only count occurrence }
  562. if cs_littlesize in aktglobalswitches then
  563. cg.t_times:=1
  564. else
  565. { reference for repetition is 100 }
  566. cg.t_times:=100;
  567. { clear register count }
  568. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
  569. symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
  570. { firstpass everything }
  571. flowcontrol:=[];
  572. do_firstpass(code);
  573. if code.registersfpu>0 then
  574. include(current_procinfo.flags,pi_uses_fpu);
  575. { only do secondpass if there are no errors }
  576. if ErrorCount=0 then
  577. begin
  578. { set the start offset to the start of the temp area in the stack }
  579. tg:=ttgobj.create;
  580. { Create register allocator }
  581. cg.init_register_allocators;
  582. set_first_temp_offset;
  583. generate_parameter_info;
  584. { Allocate space in temp/registers for parast and localst }
  585. aktfilepos:=entrypos;
  586. gen_alloc_parast(aktproccode,tparasymtable(procdef.parast));
  587. if procdef.localst.symtabletype=localsymtable then
  588. gen_alloc_localst(aktproccode,tlocalsymtable(procdef.localst));
  589. { Store temp offset for information about 'real' temps }
  590. tempstart:=tg.lasttemp;
  591. { Generate code to load register parameters in temps and insert local
  592. copies for values parameters. This must be done before the code for the
  593. body is generated because the localloc is updated.
  594. Note: The generated code will be inserted after the code generation of
  595. the body is finished, because only then the position is known }
  596. aktfilepos:=entrypos;
  597. gen_load_para_value(templist);
  598. { caller paraloc info is also necessary in the stackframe_entry
  599. code of the ppc (and possibly other processors) }
  600. if not procdef.has_paraloc_info then
  601. begin
  602. paramanager.create_paraloc_info(procdef,callerside);
  603. procdef.has_paraloc_info:=true;
  604. end;
  605. { generate code for the node tree }
  606. do_secondpass(code);
  607. aktproccode.concatlist(exprasmlist);
  608. {$ifdef i386}
  609. procdef.fpu_used:=code.registersfpu;
  610. {$endif i386}
  611. { The position of the loadpara_asmnode is now known }
  612. aktproccode.insertlistafter(loadpara_asmnode.currenttai,templist);
  613. { first generate entry and initialize code with the correct
  614. position and switches }
  615. aktfilepos:=entrypos;
  616. aktlocalswitches:=entryswitches;
  617. gen_entry_code(templist);
  618. aktproccode.insertlistafter(entry_asmnode.currenttai,templist);
  619. gen_initialize_code(templist,false);
  620. aktproccode.insertlistafter(init_asmnode.currenttai,templist);
  621. { now generate finalize and exit code with the correct position
  622. and switches }
  623. aktfilepos:=exitpos;
  624. aktlocalswitches:=exitswitches;
  625. gen_finalize_code(templist,false);
  626. { the finalcode must be concated if there was no position available,
  627. using insertlistafter will result in an insert at the start
  628. when currentai=nil }
  629. if assigned(final_asmnode.currenttai) then
  630. aktproccode.insertlistafter(final_asmnode.currenttai,templist)
  631. else
  632. aktproccode.concatlist(templist);
  633. { insert exit label at the correct position }
  634. cg.a_label(templist,aktexitlabel);
  635. if assigned(exitlabel_asmnode.currenttai) then
  636. aktproccode.insertlistafter(exitlabel_asmnode.currenttai,templist)
  637. else
  638. aktproccode.concatlist(templist);
  639. { exit code }
  640. gen_exit_code(templist);
  641. aktproccode.concatlist(templist);
  642. {$ifdef OLDREGVARS}
  643. { note: this must be done only after as much code as possible has }
  644. { been generated. The result is that when you ungetregister() a }
  645. { regvar, it will actually free the regvar (and alse free the }
  646. { the regvars at the same time). Doing this too early will }
  647. { confuse the register allocator, as the regvars will still be }
  648. { used. It should be done before loading the result regs (so }
  649. { they don't conflict with the regvars) and before }
  650. { gen_entry_code (that one has to be able to allocate the }
  651. { regvars again) (JM) }
  652. free_regvars(aktproccode);
  653. {$endif OLDREGVARS}
  654. { add code that will load the return value, this is not done
  655. for assembler routines when they didn't reference the result
  656. variable }
  657. usesacc:=false;
  658. usesfpu:=false;
  659. usesacchi:=false;
  660. gen_load_return_value(templist,usesacc,usesacchi,usesfpu);
  661. aktproccode.concatlist(templist);
  662. { generate symbol and save end of header position }
  663. aktfilepos:=entrypos;
  664. gen_proc_symbol(templist);
  665. headertai:=tai(templist.last);
  666. { insert symbol }
  667. aktproccode.insertlist(templist);
  668. { Free space in temp/registers for parast and localst, must be
  669. done after gen_entry_code }
  670. aktfilepos:=exitpos;
  671. if procdef.localst.symtabletype=localsymtable then
  672. gen_free_localst(aktproccode,tlocalsymtable(procdef.localst));
  673. gen_free_parast(aktproccode,tparasymtable(procdef.parast));
  674. { The procedure body is finished, we can now
  675. allocate the registers }
  676. cg.do_register_allocation(aktproccode,headertai);
  677. { Add save and restore of used registers }
  678. aktfilepos:=entrypos;
  679. gen_save_used_regs(templist);
  680. aktproccode.insertlistafter(headertai,templist);
  681. aktfilepos:=exitpos;
  682. gen_restore_used_regs(aktproccode,usesacc,usesacchi,usesfpu);
  683. { Add stack allocation code after header }
  684. aktfilepos:=entrypos;
  685. gen_stackalloc_code(templist);
  686. aktproccode.insertlistafter(headertai,templist);
  687. { Add exit code at the end }
  688. aktfilepos:=exitpos;
  689. gen_stackfree_code(templist,usesacc,usesacchi);
  690. aktproccode.concatlist(templist);
  691. {$ifndef NoOpt}
  692. if not(cs_no_regalloc in aktglobalswitches) then
  693. begin
  694. if (cs_optimize in aktglobalswitches) and
  695. { do not optimize pure assembler procedures }
  696. not(pi_is_assembler in flags) then
  697. optimize(aktproccode);
  698. end;
  699. {$endif NoOpt}
  700. { Add end symbol and debug info }
  701. aktfilepos:=exitpos;
  702. gen_proc_symbol_end(templist);
  703. aktproccode.concatlist(templist);
  704. { save local data (casetable) also in the same file }
  705. if assigned(aktlocaldata) and
  706. (not aktlocaldata.empty) then
  707. begin
  708. { because of the limited constant size of the arm, all data access is done pc relative }
  709. if target_info.cpu=cpu_arm then
  710. aktproccode.concatlist(aktlocaldata)
  711. else
  712. begin
  713. aktproccode.concat(Tai_section.Create(sec_data));
  714. aktproccode.concatlist(aktlocaldata);
  715. aktproccode.concat(Tai_section.Create(sec_code));
  716. end;
  717. end;
  718. { add the procedure to the codesegment }
  719. if (cs_create_smart in aktmoduleswitches) then
  720. codesegment.concat(Tai_cut.Create);
  721. codesegment.concatlist(aktproccode);
  722. { only now we can remove the temps }
  723. tg.resettempgen;
  724. { stop tempgen and ra }
  725. tg.free;
  726. cg.done_register_allocators;
  727. tg:=nil;
  728. end;
  729. { restore symtablestack }
  730. remove_from_symtablestack;
  731. { restore }
  732. templist.free;
  733. aktmaxfpuregisters:=oldaktmaxfpuregisters;
  734. aktfilepos:=oldfilepos;
  735. current_procinfo:=oldprocinfo;
  736. end;
  737. procedure tcgprocinfo.add_to_symtablestack;
  738. var
  739. _class,hp : tobjectdef;
  740. begin
  741. { insert symtables for the class, but only if it is no nested function }
  742. if assigned(procdef._class) and
  743. not(assigned(parent) and
  744. assigned(parent.procdef) and
  745. assigned(parent.procdef._class)) then
  746. begin
  747. { insert them in the reverse order }
  748. hp:=nil;
  749. repeat
  750. _class:=procdef._class;
  751. while _class.childof<>hp do
  752. _class:=_class.childof;
  753. hp:=_class;
  754. _class.symtable.next:=symtablestack;
  755. symtablestack:=_class.symtable;
  756. until hp=procdef._class;
  757. end;
  758. { insert parasymtable in symtablestack when parsing
  759. a function }
  760. if procdef.parast.symtablelevel>=normal_function_level then
  761. begin
  762. procdef.parast.next:=symtablestack;
  763. symtablestack:=procdef.parast;
  764. end;
  765. procdef.localst.next:=symtablestack;
  766. symtablestack:=procdef.localst;
  767. end;
  768. procedure tcgprocinfo.remove_from_symtablestack;
  769. begin
  770. { remove localst/parast }
  771. if procdef.parast.symtablelevel>=normal_function_level then
  772. symtablestack:=symtablestack.next.next
  773. else
  774. symtablestack:=symtablestack.next;
  775. { remove class member symbol tables }
  776. while symtablestack.symtabletype=objectsymtable do
  777. symtablestack:=symtablestack.next;
  778. end;
  779. procedure tcgprocinfo.resetprocdef;
  780. begin
  781. { the local symtables can be deleted, but the parast }
  782. { doesn't, (checking definitons when calling a }
  783. { function }
  784. { not for a inline procedure !! (PM) }
  785. { at lexlevel = 1 localst is the staticsymtable itself }
  786. { so no dispose here !! }
  787. if assigned(code) and
  788. not(cs_browser in aktmoduleswitches) and
  789. (procdef.proccalloption<>pocall_inline) then
  790. begin
  791. if procdef.parast.symtablelevel>=normal_function_level then
  792. procdef.localst.free;
  793. procdef.localst:=nil;
  794. end;
  795. { remove code tree, if not inline procedure }
  796. if assigned(code) then
  797. begin
  798. { the inline procedure has already got a copy of the tree
  799. stored in current_procinfo.procdef.code }
  800. code.free;
  801. code:=nil;
  802. if (procdef.proccalloption<>pocall_inline) then
  803. procdef.inlininginfo^.code:=nil;
  804. end;
  805. end;
  806. procedure tcgprocinfo.parse_body;
  807. var
  808. oldprocinfo : tprocinfo;
  809. oldblock_type : tblock_type;
  810. begin
  811. oldprocinfo:=current_procinfo;
  812. oldblock_type:=block_type;
  813. { reset break and continue labels }
  814. block_type:=bt_body;
  815. current_procinfo:=self;
  816. { calculate the lexical level }
  817. if procdef.parast.symtablelevel>maxnesting then
  818. Message(parser_e_too_much_lexlevel);
  819. { static is also important for local procedures !! }
  820. if (po_staticmethod in procdef.procoptions) then
  821. allow_only_static:=true
  822. else if (procdef.parast.symtablelevel=normal_function_level) then
  823. allow_only_static:=false;
  824. {$ifdef state_tracking}
  825. { aktstate:=Tstate_storage.create;}
  826. {$endif state_tracking}
  827. { create a local symbol table for this routine }
  828. if not assigned(procdef.localst) then
  829. procdef.insert_localst;
  830. { add parast/localst to symtablestack }
  831. add_to_symtablestack;
  832. { constant symbols are inserted in this symboltable }
  833. constsymtable:=symtablestack;
  834. { save entry info }
  835. entrypos:=aktfilepos;
  836. entryswitches:=aktlocalswitches;
  837. { parse the code ... }
  838. code:=block(current_module.islibrary);
  839. { save exit info }
  840. exitswitches:=aktlocalswitches;
  841. exitpos:=last_endtoken_filepos;
  842. if assigned(code) then
  843. begin
  844. { get a better entry point }
  845. entrypos:=code.fileinfo;
  846. { the procedure is now defined }
  847. procdef.forwarddef:=false;
  848. if (Errorcount=0) then
  849. begin
  850. { add implicit entry and exit code }
  851. add_entry_exit_code;
  852. { check if forwards are resolved }
  853. tstoredsymtable(procdef.localst).check_forwards;
  854. { check if all labels are used }
  855. tstoredsymtable(procdef.localst).checklabels;
  856. { remove cross unit overloads }
  857. tstoredsymtable(procdef.localst).unchain_overloaded;
  858. end;
  859. { check for unused symbols, but only if there is no asm block }
  860. if not(pi_uses_asm in flags) then
  861. begin
  862. { not for unit init, becuase the var can be used in finalize,
  863. it will be done in proc_unit }
  864. if not(procdef.proctypeoption in [potype_proginit,potype_unitinit,potype_unitfinalize]) then
  865. tstoredsymtable(procdef.localst).allsymbolsused;
  866. tstoredsymtable(procdef.parast).allsymbolsused;
  867. end;
  868. { Finish type checking pass }
  869. do_resulttypepass(code);
  870. { Print the node to tree.log }
  871. if paraprintnodetree=1 then
  872. printnode_procdef(procdef);
  873. end;
  874. new(procdef.inlininginfo);
  875. { store a copy of the original tree for inline, for
  876. normal procedures only store a reference to the
  877. current tree }
  878. if (procdef.proccalloption=pocall_inline) then
  879. begin
  880. procdef.inlininginfo^.code:=code.getcopy;
  881. procdef.inlininginfo^.flags:=current_procinfo.flags;
  882. end
  883. else
  884. procdef.inlininginfo^.code:=code;
  885. { ... remove symbol tables }
  886. remove_from_symtablestack;
  887. {$ifdef state_tracking}
  888. { aktstate.destroy;}
  889. {$endif state_tracking}
  890. { reset to normal non static function }
  891. if (procdef.parast.symtablelevel=normal_function_level) then
  892. allow_only_static:=false;
  893. current_procinfo:=oldprocinfo;
  894. block_type:=oldblock_type;
  895. end;
  896. {****************************************************************************
  897. PROCEDURE/FUNCTION PARSING
  898. ****************************************************************************}
  899. procedure check_init_paras(p:tnamedindexitem;arg:pointer);
  900. begin
  901. if tsym(p).typ<>varsym then
  902. exit;
  903. with tvarsym(p) do
  904. if (not is_class(vartype.def) and
  905. vartype.def.needs_inittable and
  906. (varspez in [vs_value,vs_out])) then
  907. include(current_procinfo.flags,pi_do_call);
  908. end;
  909. procedure read_proc;
  910. {
  911. Parses the procedure directives, then parses the procedure body, then
  912. generates the code for it
  913. }
  914. procedure do_generate_code(pi:tcgprocinfo);
  915. var
  916. hpi : tcgprocinfo;
  917. begin
  918. { generate code for this procedure }
  919. pi.generate_code;
  920. { process nested procs }
  921. hpi:=tcgprocinfo(pi.nestedprocs.first);
  922. while assigned(hpi) do
  923. begin
  924. do_generate_code(hpi);
  925. hpi:=tcgprocinfo(hpi.next);
  926. end;
  927. pi.resetprocdef;
  928. end;
  929. var
  930. old_current_procinfo : tprocinfo;
  931. oldconstsymtable : tsymtable;
  932. oldfailtokenmode : tmodeswitch;
  933. pdflags : tpdflags;
  934. pd : tprocdef;
  935. isnestedproc : boolean;
  936. begin
  937. { save old state }
  938. oldconstsymtable:=constsymtable;
  939. old_current_procinfo:=current_procinfo;
  940. { reset current_procinfo.procdef to nil to be sure that nothing is writing
  941. to an other procdef }
  942. current_procinfo:=nil;
  943. { parse procedure declaration }
  944. if assigned(old_current_procinfo) and
  945. assigned(old_current_procinfo.procdef) then
  946. pd:=parse_proc_dec(old_current_procinfo.procdef._class)
  947. else
  948. pd:=parse_proc_dec(nil);
  949. { set the default function options }
  950. if parse_only then
  951. begin
  952. pd.forwarddef:=true;
  953. { set also the interface flag, for better error message when the
  954. implementation doesn't much this header }
  955. pd.interfacedef:=true;
  956. include(pd.procoptions,po_public);
  957. pdflags:=[pd_interface];
  958. end
  959. else
  960. begin
  961. pdflags:=[pd_body];
  962. if (not current_module.in_interface) then
  963. include(pdflags,pd_implemen);
  964. if (not current_module.is_unit) or
  965. (cs_create_smart in aktmoduleswitches) then
  966. include(pd.procoptions,po_public);
  967. pd.forwarddef:=false;
  968. end;
  969. { parse the directives that may follow }
  970. parse_proc_directives(pd,pdflags);
  971. { hint directives, these can be separated by semicolons here,
  972. that needs to be handled here with a loop (PFV) }
  973. while try_consume_hintdirective(pd.symoptions) do
  974. Consume(_SEMICOLON);
  975. { Set calling convention }
  976. handle_calling_convention(pd);
  977. { everything of the proc definition is known, we can now
  978. calculate the parameters }
  979. calc_parast(pd);
  980. { search for forward declarations }
  981. if not proc_add_definition(pd) then
  982. begin
  983. { A method must be forward defined (in the object declaration) }
  984. if assigned(pd._class) and
  985. (not assigned(old_current_procinfo.procdef._class)) then
  986. begin
  987. MessagePos1(pd.fileinfo,parser_e_header_dont_match_any_member,pd.fullprocname(false));
  988. tprocsym(pd.procsym).write_parameter_lists(pd);
  989. end
  990. else
  991. begin
  992. { Give a better error if there is a forward def in the interface and only
  993. a single implementation }
  994. if (not pd.forwarddef) and
  995. (not pd.interfacedef) and
  996. (tprocsym(pd.procsym).procdef_count>1) and
  997. tprocsym(pd.procsym).first_procdef.forwarddef and
  998. tprocsym(pd.procsym).first_procdef.interfacedef and
  999. not(tprocsym(pd.procsym).procdef_count>2) then
  1000. begin
  1001. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,pd.fullprocname(false));
  1002. tprocsym(pd.procsym).write_parameter_lists(pd);
  1003. end;
  1004. end;
  1005. end;
  1006. { compile procedure when a body is needed }
  1007. if (pd_body in pdflags) then
  1008. begin
  1009. Message1(parser_d_procedure_start,pd.fullprocname(false));
  1010. { create a new procedure }
  1011. current_procinfo:=cprocinfo.create(old_current_procinfo);
  1012. current_module.procinfo:=current_procinfo;
  1013. current_procinfo.procdef:=pd;
  1014. isnestedproc:=(current_procinfo.procdef.parast.symtablelevel>normal_function_level);
  1015. { Insert mangledname }
  1016. pd.aliasnames.insert(pd.mangledname);
  1017. { Insert result variables in the localst }
  1018. insert_funcret_local(pd);
  1019. { check if there are para's which require initing -> set }
  1020. { pi_do_call (if not yet set) }
  1021. if not(pi_do_call in current_procinfo.flags) then
  1022. pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_init_paras,nil);
  1023. { set _FAIL as keyword if constructor }
  1024. if (pd.proctypeoption=potype_constructor) then
  1025. begin
  1026. oldfailtokenmode:=tokeninfo^[_FAIL].keyword;
  1027. tokeninfo^[_FAIL].keyword:=m_all;
  1028. end;
  1029. tcgprocinfo(current_procinfo).parse_body;
  1030. { When it's a nested procedure then defer the code generation,
  1031. when back at normal function level then generate the code
  1032. for all defered nested procedures and the current procedure }
  1033. if isnestedproc then
  1034. tcgprocinfo(current_procinfo.parent).nestedprocs.insert(current_procinfo)
  1035. else
  1036. begin
  1037. { We can't support inlining for procedures that have nested
  1038. procedures because the nested procedures use a fixed offset
  1039. for accessing locals in the parent procedure (PFV) }
  1040. if (current_procinfo.procdef.proccalloption=pocall_inline) and
  1041. (tcgprocinfo(current_procinfo).nestedprocs.count>0) then
  1042. begin
  1043. Message1(parser_w_not_supported_for_inline,'nested procedures');
  1044. Message(parser_w_inlining_disabled);
  1045. current_procinfo.procdef.proccalloption:=pocall_default;
  1046. end;
  1047. do_generate_code(tcgprocinfo(current_procinfo));
  1048. end;
  1049. { reset _FAIL as _SELF normal }
  1050. if (pd.proctypeoption=potype_constructor) then
  1051. tokeninfo^[_FAIL].keyword:=oldfailtokenmode;
  1052. { release procinfo }
  1053. if tprocinfo(current_module.procinfo)<>current_procinfo then
  1054. internalerror(200304274);
  1055. current_module.procinfo:=current_procinfo.parent;
  1056. if not isnestedproc then
  1057. current_procinfo.free;
  1058. consume(_SEMICOLON);
  1059. end;
  1060. { Restore old state }
  1061. constsymtable:=oldconstsymtable;
  1062. current_procinfo:=old_current_procinfo;
  1063. end;
  1064. {****************************************************************************
  1065. DECLARATION PARSING
  1066. ****************************************************************************}
  1067. { search in symtablestack for not complete classes }
  1068. procedure check_forward_class(p : tnamedindexitem;arg:pointer);
  1069. begin
  1070. if (tsym(p).typ=typesym) and
  1071. (ttypesym(p).restype.def.deftype=objectdef) and
  1072. (oo_is_forward in tobjectdef(ttypesym(p).restype.def).objectoptions) then
  1073. MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
  1074. end;
  1075. procedure read_declarations(islibrary : boolean);
  1076. begin
  1077. repeat
  1078. if not assigned(current_procinfo) then
  1079. internalerror(200304251);
  1080. case token of
  1081. _LABEL:
  1082. label_dec;
  1083. _CONST:
  1084. const_dec;
  1085. _TYPE:
  1086. type_dec;
  1087. _VAR:
  1088. var_dec;
  1089. _THREADVAR:
  1090. threadvar_dec;
  1091. _CONSTRUCTOR,
  1092. _DESTRUCTOR,
  1093. _FUNCTION,
  1094. _PROCEDURE,
  1095. _OPERATOR,
  1096. _CLASS:
  1097. read_proc;
  1098. _EXPORTS:
  1099. begin
  1100. if not(assigned(current_procinfo.procdef.localst)) or
  1101. (current_procinfo.procdef.localst.symtablelevel>main_program_level) or
  1102. (current_module.is_unit) then
  1103. begin
  1104. Message(parser_e_syntax_error);
  1105. consume_all_until(_SEMICOLON);
  1106. end
  1107. else if islibrary or
  1108. (target_info.system in [system_i386_WIN32,system_i386_wdosx,system_i386_Netware]) then
  1109. read_exports
  1110. else
  1111. begin
  1112. Message(parser_w_unsupported_feature);
  1113. consume(_BEGIN);
  1114. end;
  1115. end
  1116. else
  1117. begin
  1118. case idtoken of
  1119. _RESOURCESTRING :
  1120. resourcestring_dec;
  1121. _PROPERTY:
  1122. begin
  1123. if (m_fpc in aktmodeswitches) then
  1124. property_dec
  1125. else
  1126. break;
  1127. end;
  1128. else
  1129. break;
  1130. end;
  1131. end;
  1132. end;
  1133. until false;
  1134. { check for incomplete class definitions, this is only required
  1135. for fpc modes }
  1136. if (m_fpc in aktmodeswitches) then
  1137. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  1138. end;
  1139. procedure read_interface_declarations;
  1140. begin
  1141. repeat
  1142. case token of
  1143. _CONST :
  1144. const_dec;
  1145. _TYPE :
  1146. type_dec;
  1147. _VAR :
  1148. var_dec;
  1149. _THREADVAR :
  1150. threadvar_dec;
  1151. _FUNCTION,
  1152. _PROCEDURE,
  1153. _OPERATOR :
  1154. read_proc;
  1155. else
  1156. begin
  1157. case idtoken of
  1158. _RESOURCESTRING :
  1159. resourcestring_dec;
  1160. _PROPERTY:
  1161. begin
  1162. if (m_fpc in aktmodeswitches) then
  1163. property_dec
  1164. else
  1165. break;
  1166. end;
  1167. else
  1168. break;
  1169. end;
  1170. end;
  1171. end;
  1172. until false;
  1173. { check for incomplete class definitions, this is only required
  1174. for fpc modes }
  1175. if (m_fpc in aktmodeswitches) then
  1176. symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_forward_class,nil);
  1177. end;
  1178. end.
  1179. {
  1180. $Log$
  1181. Revision 1.180 2003-12-19 22:08:44 daniel
  1182. * Some work to restore the MMX capabilities
  1183. Revision 1.179 2003/12/16 22:36:19 florian
  1184. * forgot a commit
  1185. Revision 1.178 2003/12/16 21:29:24 florian
  1186. + inlined procedures inherit procinfo flags
  1187. Revision 1.177 2003/12/15 21:25:48 peter
  1188. * reg allocations for imaginary register are now inserted just
  1189. before reg allocation
  1190. * tregister changed to enum to allow compile time check
  1191. * fixed several tregister-tsuperregister errors
  1192. Revision 1.176 2003/12/10 16:37:01 peter
  1193. * global property support for fpc modes
  1194. Revision 1.175 2003/12/03 23:13:20 peter
  1195. * delayed paraloc allocation, a_param_*() gets extra parameter
  1196. if it needs to allocate temp or real paralocation
  1197. * optimized/simplified int-real loading
  1198. Revision 1.174 2003/11/27 09:08:01 florian
  1199. * resourcestring is allowed in the interface
  1200. Revision 1.173 2003/11/23 17:05:16 peter
  1201. * register calling is left-right
  1202. * parameter ordering
  1203. * left-right calling inserts result parameter last
  1204. Revision 1.172 2003/11/22 00:40:19 jonas
  1205. * fixed optimiser so it compiles again
  1206. * fixed several bugs which were in there already for a long time, but
  1207. which only popped up now :) -O2/-O3 will now optimise less than in
  1208. the past (and correctly so), but -O2u/-O3u will optimise a bit more
  1209. * some more small improvements for -O3 are still possible
  1210. Revision 1.171 2003/11/10 22:02:52 peter
  1211. * cross unit inlining fixed
  1212. Revision 1.170 2003/11/07 15:58:32 florian
  1213. * Florian's culmutative nr. 1; contains:
  1214. - invalid calling conventions for a certain cpu are rejected
  1215. - arm softfloat calling conventions
  1216. - -Sp for cpu dependend code generation
  1217. - several arm fixes
  1218. - remaining code for value open array paras on heap
  1219. Revision 1.169 2003/10/31 15:52:18 peter
  1220. * fix crash with fail in constructor
  1221. Revision 1.168 2003/10/30 16:22:40 peter
  1222. * call firstpass before allocation and codegeneration is started
  1223. * move leftover code from pass_2.generatecode() to psub
  1224. Revision 1.167 2003/10/24 17:40:23 peter
  1225. * cleanup of the entry and exit code insertion
  1226. Revision 1.166 2003/10/21 15:14:33 peter
  1227. * fixed memleak for initfinalcode
  1228. * exit from generatecode when there are already errors
  1229. Revision 1.165 2003/10/20 19:28:51 peter
  1230. * disable inlining when nested procedures are found
  1231. Revision 1.164 2003/10/19 01:34:30 florian
  1232. * some ppc stuff fixed
  1233. * memory leak fixed
  1234. Revision 1.163 2003/10/17 14:38:32 peter
  1235. * 64k registers supported
  1236. * fixed some memory leaks
  1237. Revision 1.162 2003/10/10 17:48:13 peter
  1238. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1239. * tregisteralloctor renamed to trgobj
  1240. * removed rgobj from a lot of units
  1241. * moved location_* and reference_* to cgobj
  1242. * first things for mmx register allocation
  1243. Revision 1.161 2003/10/09 21:31:37 daniel
  1244. * Register allocator splitted, ans abstract now
  1245. Revision 1.160 2003/10/09 15:20:56 peter
  1246. * self is not a token anymore. It is handled special when found
  1247. in a code block and when parsing an method
  1248. Revision 1.159 2003/10/07 15:17:07 peter
  1249. * inline supported again, LOC_REFERENCEs are used to pass the
  1250. parameters
  1251. * inlineparasymtable,inlinelocalsymtable removed
  1252. * exitlabel inserting fixed
  1253. Revision 1.158 2003/10/06 22:23:41 florian
  1254. + added basic olevariant support
  1255. Revision 1.157 2003/10/03 14:45:09 peter
  1256. * more proc directive for procvar fixes
  1257. Revision 1.156 2003/10/02 21:20:32 peter
  1258. * handle_calling_convention removed from parse_proc_directive to
  1259. separate call
  1260. Revision 1.155 2003/10/01 20:34:49 peter
  1261. * procinfo unit contains tprocinfo
  1262. * cginfo renamed to cgbase
  1263. * moved cgmessage to verbose
  1264. * fixed ppc and sparc compiles
  1265. Revision 1.154 2003/09/29 20:58:56 peter
  1266. * optimized releasing of registers
  1267. Revision 1.153 2003/09/28 17:55:04 peter
  1268. * parent framepointer changed to hidden parameter
  1269. * tloadparentfpnode added
  1270. Revision 1.152 2003/09/27 13:29:43 peter
  1271. * fix reported file position for not matched forwards
  1272. Revision 1.151 2003/09/25 21:25:13 peter
  1273. * remove allocate_intterupt_parameter, allocation is platform
  1274. dependent and needs to be done in create_paraloc_info
  1275. Revision 1.150 2003/09/25 16:19:32 peter
  1276. * fix filepositions
  1277. * insert spill temp allocations at the start of the proc
  1278. Revision 1.149 2003/09/23 17:56:06 peter
  1279. * locals and paras are allocated in the code generation
  1280. * tvarsym.localloc contains the location of para/local when
  1281. generating code for the current procedure
  1282. Revision 1.148 2003/09/14 19:18:10 peter
  1283. * remove obsolete code already in comments
  1284. Revision 1.147 2003/09/14 12:58:00 peter
  1285. * support mulitple overloads in implementation, this is delphi
  1286. compatible
  1287. * procsym only stores the overloads available in the interface
  1288. Revision 1.146 2003/09/12 19:07:42 daniel
  1289. * Fixed fast spilling functionality by re-adding the code that initializes
  1290. precoloured nodes to degree 255. I would like to play hangman on the one
  1291. who removed that code.
  1292. Revision 1.145 2003/09/10 19:14:31 daniel
  1293. * Failed attempt to restore broken fastspill functionality
  1294. Revision 1.144 2003/09/09 20:59:27 daniel
  1295. * Adding register allocation order
  1296. Revision 1.143 2003/09/09 15:55:44 peter
  1297. * use register with least interferences in spillregister
  1298. Revision 1.142 2003/09/07 22:09:35 peter
  1299. * preparations for different default calling conventions
  1300. * various RA fixes
  1301. Revision 1.141 2003/09/04 14:46:12 peter
  1302. * abort with IE when spilling requires > 20 loops
  1303. Revision 1.140 2003/09/03 15:55:01 peter
  1304. * NEWRA branch merged
  1305. Revision 1.139 2003/09/03 11:18:37 florian
  1306. * fixed arm concatcopy
  1307. + arm support in the common compiler sources added
  1308. * moved some generic cg code around
  1309. + tfputype added
  1310. * ...
  1311. Revision 1.138.2.1 2003/08/31 13:50:16 daniel
  1312. * Remove sorting and use pregenerated indexes
  1313. * Some work on making things compile
  1314. Revision 1.138 2003/08/20 17:48:49 peter
  1315. * fixed stackalloc to not allocate localst.datasize twice
  1316. * order of stackalloc code fixed for implicit init/final
  1317. Revision 1.137 2003/08/20 15:50:35 peter
  1318. * define NOOPT until optimizer is fixed
  1319. Revision 1.136 2003/08/20 09:07:00 daniel
  1320. * New register coding now mandatory, some more convert_registers calls
  1321. removed.
  1322. Revision 1.135 2003/08/20 07:48:03 daniel
  1323. * Made internal assembler use new register coding
  1324. Revision 1.134 2003/08/17 16:59:20 jonas
  1325. * fixed regvars so they work with newra (at least for ppc)
  1326. * fixed some volatile register bugs
  1327. + -dnotranslation option for -dnewra, which causes the registers not to
  1328. be translated from virtual to normal registers. Requires support in
  1329. the assembler writer as well, which is only implemented in aggas/
  1330. agppcgas currently
  1331. Revision 1.133 2003/07/23 11:04:15 jonas
  1332. * split en_exit_code into a part that may allocate a register and a part
  1333. that doesn't, so the former can be done before the register colouring
  1334. has been performed
  1335. Revision 1.132 2003/07/06 17:58:22 peter
  1336. * framepointer fixes for sparc
  1337. * parent framepointer code more generic
  1338. Revision 1.131 2003/07/06 15:31:21 daniel
  1339. * Fixed register allocator. *Lots* of fixes.
  1340. Revision 1.130 2003/07/05 20:15:24 jonas
  1341. * set pi_do_call if range/overflow checking is on
  1342. Revision 1.129 2003/06/17 16:34:44 jonas
  1343. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  1344. * renamed all_intregisters to paramanager.get_volatile_registers_int(pocall_default) and made it
  1345. processor dependent
  1346. Revision 1.128 2003/06/14 14:53:50 jonas
  1347. * fixed newra cycle for x86
  1348. * added constants for indicating source and destination operands of the
  1349. "move reg,reg" instruction to aasmcpu (and use those in rgobj)
  1350. Revision 1.127 2003/06/13 21:19:31 peter
  1351. * current_procdef removed, use current_procinfo.procdef instead
  1352. Revision 1.126 2003/06/12 16:43:07 peter
  1353. * newra compiles for sparc
  1354. Revision 1.125 2003/06/09 12:23:30 peter
  1355. * init/final of procedure data splitted from genentrycode
  1356. * use asmnode getposition to insert final at the correct position
  1357. als for the implicit try...finally
  1358. Revision 1.124 2003/06/07 19:37:43 jonas
  1359. * pi_do_call must always be set for the main program, since it always
  1360. ends with a call to FPC_DO_EXIT
  1361. Revision 1.123 2003/06/07 18:57:04 jonas
  1362. + added freeintparaloc
  1363. * ppc get/freeintparaloc now check whether the parameter regs are
  1364. properly allocated/deallocated (and get an extra list para)
  1365. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1366. * fixed lot of missing pi_do_call's
  1367. Revision 1.122 2003/06/03 13:01:59 daniel
  1368. * Register allocator finished
  1369. Revision 1.121 2003/05/31 20:23:39 jonas
  1370. * added pi_do_call if a procedure has a value shortstring parameter
  1371. (it's copied to the local stackframe with a helper)
  1372. Revision 1.120 2003/05/30 23:57:08 peter
  1373. * more sparc cleanup
  1374. * accumulator removed, splitted in function_return_reg (called) and
  1375. function_result_reg (caller)
  1376. Revision 1.119 2003/05/28 23:58:18 jonas
  1377. * added missing initialization of rg.usedintin,byproc
  1378. * ppc now also saves/restores used fpu registers
  1379. * ncgcal doesn't add used registers to usedby/inproc anymore, except for
  1380. i386
  1381. Revision 1.118 2003/05/26 21:17:18 peter
  1382. * procinlinenode removed
  1383. * aktexit2label removed, fast exit removed
  1384. + tcallnode.inlined_pass_2 added
  1385. Revision 1.117 2003/05/25 08:59:47 peter
  1386. * do not generate code when there was an error
  1387. Revision 1.116 2003/05/23 18:49:55 jonas
  1388. * generate code for parent procedure before that of nested procedures as
  1389. well (I only need pass_1 to be done for the ppc, but pass_1 and pass_2
  1390. are grouped and it doesn't hurt that pass_2 is done as well)
  1391. Revision 1.115 2003/05/22 21:31:35 peter
  1392. * defer codegeneration for nested procedures
  1393. Revision 1.114 2003/05/16 20:00:39 jonas
  1394. * powerpc nested procedure fixes, should work completely now if all
  1395. local variables of the parent procedure are declared before the
  1396. nested procedures are declared
  1397. Revision 1.113 2003/05/16 14:33:31 peter
  1398. * regvar fixes
  1399. Revision 1.112 2003/05/13 21:26:38 peter
  1400. * only call destructor in except block when there is a destructor
  1401. available
  1402. Revision 1.111 2003/05/13 19:14:41 peter
  1403. * failn removed
  1404. * inherited result code check moven to pexpr
  1405. Revision 1.110 2003/05/13 15:18:49 peter
  1406. * fixed various crashes
  1407. Revision 1.109 2003/05/11 21:37:03 peter
  1408. * moved implicit exception frame from ncgutil to psub
  1409. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1410. Revision 1.108 2003/05/09 17:47:03 peter
  1411. * self moved to hidden parameter
  1412. * removed hdisposen,hnewn,selfn
  1413. Revision 1.107 2003/04/27 11:21:34 peter
  1414. * aktprocdef renamed to current_procinfo.procdef
  1415. * procinfo renamed to current_procinfo
  1416. * procinfo will now be stored in current_module so it can be
  1417. cleaned up properly
  1418. * gen_main_procsym changed to create_main_proc and release_main_proc
  1419. to also generate a tprocinfo structure
  1420. * fixed unit implicit initfinal
  1421. Revision 1.106 2003/04/27 07:29:50 peter
  1422. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  1423. a new procdef declaration
  1424. * aktprocsym removed
  1425. * lexlevel removed, use symtable.symtablelevel instead
  1426. * implicit init/final code uses the normal genentry/genexit
  1427. * funcret state checking updated for new funcret handling
  1428. Revision 1.105 2003/04/26 00:31:42 peter
  1429. * set return_offset moved to after_header
  1430. Revision 1.104 2003/04/25 20:59:34 peter
  1431. * removed funcretn,funcretsym, function result is now in varsym
  1432. and aliases for result and function name are added using absolutesym
  1433. * vs_hidden parameter for funcret passed in parameter
  1434. * vs_hidden fixes
  1435. * writenode changed to printnode and released from extdebug
  1436. * -vp option added to generate a tree.log with the nodetree
  1437. * nicer printnode for statements, callnode
  1438. Revision 1.103 2003/04/24 13:03:01 florian
  1439. * comp is now written with its bit pattern to the ppu instead as an extended
  1440. Revision 1.102 2003/04/23 12:35:34 florian
  1441. * fixed several issues with powerpc
  1442. + applied a patch from Jonas for nested function calls (PowerPC only)
  1443. * ...
  1444. Revision 1.101 2003/04/22 14:33:38 peter
  1445. * removed some notes/hints
  1446. Revision 1.100 2003/04/22 13:47:08 peter
  1447. * fixed C style array of const
  1448. * fixed C array passing
  1449. * fixed left to right with high parameters
  1450. Revision 1.99 2003/04/22 10:09:35 daniel
  1451. + Implemented the actual register allocator
  1452. + Scratch registers unavailable when new register allocator used
  1453. + maybe_save/maybe_restore unavailable when new register allocator used
  1454. Revision 1.98 2003/04/17 07:50:24 daniel
  1455. * Some work on interference graph construction
  1456. Revision 1.97 2003/04/16 09:26:55 jonas
  1457. * assembler procedures now again get a stackframe if they have local
  1458. variables. No space is reserved for a function result however.
  1459. Also, the register parameters aren't automatically saved on the stack
  1460. anymore in assembler procedures.
  1461. Revision 1.96 2003/04/05 21:09:31 jonas
  1462. * several ppc/generic result offset related fixes. The "normal" result
  1463. offset seems now to be calculated correctly and a lot of duplicate
  1464. calculations have been removed. Nested functions accessing the parent's
  1465. function result don't work at all though :(
  1466. Revision 1.95 2003/04/02 16:11:34 peter
  1467. * give error when exports is not supported
  1468. Revision 1.94 2003/03/12 22:43:38 jonas
  1469. * more powerpc and generic fixes related to the new register allocator
  1470. Revision 1.93 2003/03/08 08:59:07 daniel
  1471. + $define newra will enable new register allocator
  1472. + getregisterint will return imaginary registers with $newra
  1473. + -sr switch added, will skip register allocation so you can see
  1474. the direct output of the code generator before register allocation
  1475. Revision 1.92 2003/02/19 22:00:14 daniel
  1476. * Code generator converted to new register notation
  1477. - Horribily outdated todo.txt removed
  1478. Revision 1.91 2003/01/09 21:52:37 peter
  1479. * merged some verbosity options.
  1480. * V_LineInfo is a verbosity flag to include line info
  1481. Revision 1.90 2003/01/09 20:40:59 daniel
  1482. * Converted some code in cgx86.pas to new register numbering
  1483. Revision 1.89 2003/01/09 15:49:56 daniel
  1484. * Added register conversion
  1485. Revision 1.88 2003/01/08 18:43:56 daniel
  1486. * Tregister changed into a record
  1487. Revision 1.87 2003/01/03 20:35:08 peter
  1488. * check also interfacedef when checking for matching forwarddef
  1489. Revision 1.86 2003/01/02 11:14:02 michael
  1490. + Patch from peter to support initial values for local variables
  1491. Revision 1.85 2002/12/29 18:59:34 peter
  1492. * fixed parsing of declarations before asm statement
  1493. Revision 1.84 2002/12/29 18:25:18 peter
  1494. * parse declarations before check _ASM token
  1495. Revision 1.83 2002/12/29 14:57:50 peter
  1496. * unit loading changed to first register units and load them
  1497. afterwards. This is needed to support uses xxx in yyy correctly
  1498. * unit dependency check fixed
  1499. Revision 1.82 2002/12/25 01:26:56 peter
  1500. * duplicate procsym-unitsym fix
  1501. Revision 1.81 2002/12/15 13:37:15 peter
  1502. * don't include uf_init for library. The code is already called and
  1503. does not need to be in the initfinal table
  1504. Revision 1.80 2002/12/07 14:27:09 carl
  1505. * 3% memory optimization
  1506. * changed some types
  1507. + added type checking with different size for call node and for
  1508. parameters
  1509. Revision 1.79 2002/11/25 18:43:32 carl
  1510. - removed the invalid if <> checking (Delphi is strange on this)
  1511. + implemented abstract warning on instance creation of class with
  1512. abstract methods.
  1513. * some error message cleanups
  1514. Revision 1.78 2002/11/25 17:43:23 peter
  1515. * splitted defbase in defutil,symutil,defcmp
  1516. * merged isconvertable and is_equal into compare_defs(_ext)
  1517. * made operator search faster by walking the list only once
  1518. Revision 1.77 2002/11/23 22:50:06 carl
  1519. * some small speed optimizations
  1520. + added several new warnings/hints
  1521. Revision 1.76 2002/11/18 17:31:58 peter
  1522. * pass proccalloption to ret_in_xxx and push_xxx functions
  1523. Revision 1.75 2002/11/17 16:31:57 carl
  1524. * memory optimization (3-4%) : cleanup of tai fields,
  1525. cleanup of tdef and tsym fields.
  1526. * make it work for m68k
  1527. Revision 1.74 2002/11/15 01:58:53 peter
  1528. * merged changes from 1.0.7 up to 04-11
  1529. - -V option for generating bug report tracing
  1530. - more tracing for option parsing
  1531. - errors for cdecl and high()
  1532. - win32 import stabs
  1533. - win32 records<=8 are returned in eax:edx (turned off by default)
  1534. - heaptrc update
  1535. - more info for temp management in .s file with EXTDEBUG
  1536. Revision 1.73 2002/11/09 15:32:30 carl
  1537. * noopt for non-i386 targets
  1538. Revision 1.72 2002/09/10 20:31:48 florian
  1539. * call to current_procinfo.after_header added
  1540. Revision 1.71 2002/09/07 15:25:07 peter
  1541. * old logs removed and tabs fixed
  1542. Revision 1.70 2002/09/03 16:26:27 daniel
  1543. * Make Tprocdef.defs protected
  1544. Revision 1.69 2002/08/25 19:25:20 peter
  1545. * sym.insert_in_data removed
  1546. * symtable.insertvardata/insertconstdata added
  1547. * removed insert_in_data call from symtable.insert, it needs to be
  1548. called separatly. This allows to deref the address calculation
  1549. * procedures now calculate the parast addresses after the procedure
  1550. directives are parsed. This fixes the cdecl parast problem
  1551. * push_addr_param has an extra argument that specifies if cdecl is used
  1552. or not
  1553. Revision 1.68 2002/08/17 09:23:41 florian
  1554. * first part of procinfo rewrite
  1555. Revision 1.67 2002/08/16 14:24:59 carl
  1556. * issameref() to test if two references are the same (then emit no opcodes)
  1557. + ret_in_reg to replace ret_in_acc
  1558. (fix some register allocation bugs at the same time)
  1559. + save_std_register now has an extra parameter which is the
  1560. usedinproc registers
  1561. Revision 1.66 2002/08/11 14:32:27 peter
  1562. * renamed current_library to objectlibrary
  1563. Revision 1.65 2002/08/11 13:24:13 peter
  1564. * saving of asmsymbols in ppu supported
  1565. * asmsymbollist global is removed and moved into a new class
  1566. tasmlibrarydata that will hold the info of a .a file which
  1567. corresponds with a single module. Added librarydata to tmodule
  1568. to keep the library info stored for the module. In the future the
  1569. objectfiles will also be stored to the tasmlibrarydata class
  1570. * all getlabel/newasmsymbol and friends are moved to the new class
  1571. Revision 1.64 2002/08/09 19:14:28 carl
  1572. * fixed stackframe parameter (should only contain local size),
  1573. set to zero currently
  1574. Revision 1.63 2002/08/06 20:55:22 florian
  1575. * first part of ppc calling conventions fix
  1576. Revision 1.62 2002/07/26 21:15:41 florian
  1577. * rewrote the system handling
  1578. Revision 1.61 2002/07/20 11:57:56 florian
  1579. * types.pas renamed to defbase.pas because D6 contains a types
  1580. unit so this would conflicts if D6 programms are compiled
  1581. + Willamette/SSE2 instructions to assembler added
  1582. Revision 1.60 2002/07/19 11:41:36 daniel
  1583. * State tracker work
  1584. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1585. allows the state tracker to change while nodes automatically into
  1586. repeat nodes.
  1587. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1588. 'not(a>b)' is optimized into 'a<=b'.
  1589. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1590. by removing the notn and later switchting the true and falselabels. The
  1591. same is done with 'repeat until not a'.
  1592. Revision 1.59 2002/07/15 18:03:15 florian
  1593. * readded removed changes
  1594. Revision 1.57 2002/07/11 14:41:28 florian
  1595. * start of the new generic parameter handling
  1596. Revision 1.58 2002/07/14 18:00:44 daniel
  1597. + Added the beginning of a state tracker. This will track the values of
  1598. variables through procedures and optimize things away.
  1599. Revision 1.56 2002/07/07 09:52:32 florian
  1600. * powerpc target fixed, very simple units can be compiled
  1601. * some basic stuff for better callparanode handling, far from being finished
  1602. Revision 1.55 2002/07/04 20:43:01 florian
  1603. * first x86-64 patches
  1604. Revision 1.54 2002/07/01 18:46:25 peter
  1605. * internal linker
  1606. * reorganized aasm layer
  1607. Revision 1.53 2002/05/18 13:34:14 peter
  1608. * readded missing revisions
  1609. Revision 1.52 2002/05/16 19:46:44 carl
  1610. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1611. + try to fix temp allocation (still in ifdef)
  1612. + generic constructor calls
  1613. + start of tassembler / tmodulebase class cleanup
  1614. Revision 1.51 2002/05/14 19:34:49 peter
  1615. * removed old logs and updated copyright year
  1616. }