2
0

nflw.pas 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Type checking and register allocation for nodes that influence
  5. the flow
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit nflw;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. node,cpubase,
  24. aasmbase,aasmtai,aasmcpu,symnot,
  25. symppu,symtype,symbase,symdef,symsym;
  26. type
  27. { flags used by loop nodes }
  28. tloopflags = (
  29. { set if it is a for ... downto ... do loop }
  30. lnf_backward,
  31. { Do we need to parse childs to set var state? }
  32. lnf_varstate,
  33. { Do a test at the begin of the loop?}
  34. lnf_testatbegin,
  35. { Negate the loop test? }
  36. lnf_checknegate,
  37. { Should the value of the loop variable on exit be correct. }
  38. lnf_dont_mind_loopvar_on_exit);
  39. const
  40. { loop flags which must match to consider loop nodes equal regarding the flags }
  41. loopflagsequal = [lnf_backward];
  42. type
  43. tloopnode = class(tbinarynode)
  44. t1,t2 : tnode;
  45. loopflags : set of tloopflags;
  46. constructor create(tt : tnodetype;l,r,_t1,_t2 : tnode);virtual;
  47. destructor destroy;override;
  48. function getcopy : tnode;override;
  49. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  50. procedure ppuwrite(ppufile:tcompilerppufile);override;
  51. procedure derefimpl;override;
  52. procedure insertintolist(l : tnodelist);override;
  53. procedure printnodetree(var t:text);override;
  54. function docompare(p: tnode): boolean; override;
  55. end;
  56. twhilerepeatnode = class(tloopnode)
  57. constructor create(l,r,_t1:Tnode;tab,cn:boolean);virtual;
  58. function det_resulttype:tnode;override;
  59. function pass_1 : tnode;override;
  60. {$ifdef state_tracking}
  61. function track_state_pass(exec_known:boolean):boolean;override;
  62. {$endif}
  63. end;
  64. twhilerepeatnodeclass = class of twhilerepeatnode;
  65. tifnode = class(tloopnode)
  66. constructor create(l,r,_t1 : tnode);virtual;
  67. function det_resulttype:tnode;override;
  68. function pass_1 : tnode;override;
  69. end;
  70. tifnodeclass = class of tifnode;
  71. tfornode = class(tloopnode)
  72. loopvar_notid:cardinal;
  73. constructor create(l,r,_t1,_t2 : tnode;back : boolean);virtual;
  74. procedure loop_var_access(not_type:Tnotification_flag;symbol:Tsym);
  75. function det_resulttype:tnode;override;
  76. function pass_1 : tnode;override;
  77. end;
  78. tfornodeclass = class of tfornode;
  79. texitnode = class(tunarynode)
  80. onlyassign : boolean;
  81. constructor create(l:tnode);virtual;
  82. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  83. procedure ppuwrite(ppufile:tcompilerppufile);override;
  84. function det_resulttype:tnode;override;
  85. function pass_1 : tnode;override;
  86. end;
  87. texitnodeclass = class of texitnode;
  88. tbreaknode = class(tnode)
  89. constructor create;virtual;
  90. function det_resulttype:tnode;override;
  91. function pass_1 : tnode;override;
  92. end;
  93. tbreaknodeclass = class of tbreaknode;
  94. tcontinuenode = class(tnode)
  95. constructor create;virtual;
  96. function det_resulttype:tnode;override;
  97. function pass_1 : tnode;override;
  98. end;
  99. tcontinuenodeclass = class of tcontinuenode;
  100. tgotonode = class(tnode)
  101. labsym : tlabelsym;
  102. exceptionblock : integer;
  103. constructor create(p : tlabelsym);virtual;
  104. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  105. procedure ppuwrite(ppufile:tcompilerppufile);override;
  106. procedure derefimpl;override;
  107. function getcopy : tnode;override;
  108. function det_resulttype:tnode;override;
  109. function pass_1 : tnode;override;
  110. function docompare(p: tnode): boolean; override;
  111. end;
  112. tgotonodeclass = class of tgotonode;
  113. tlabelnode = class(tunarynode)
  114. labelnr : tasmlabel;
  115. labsym : tlabelsym;
  116. exceptionblock : integer;
  117. constructor createcase(p : tasmlabel;l:tnode);virtual;
  118. constructor create(p : tlabelsym;l:tnode);virtual;
  119. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  120. procedure ppuwrite(ppufile:tcompilerppufile);override;
  121. procedure derefimpl;override;
  122. function getcopy : tnode;override;
  123. function det_resulttype:tnode;override;
  124. function pass_1 : tnode;override;
  125. function docompare(p: tnode): boolean; override;
  126. end;
  127. tlabelnodeclass = class of tlabelnode;
  128. traisenode = class(tbinarynode)
  129. frametree : tnode;
  130. constructor create(l,taddr,tframe:tnode);virtual;
  131. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  132. procedure ppuwrite(ppufile:tcompilerppufile);override;
  133. procedure derefimpl;override;
  134. function getcopy : tnode;override;
  135. procedure insertintolist(l : tnodelist);override;
  136. function det_resulttype:tnode;override;
  137. function pass_1 : tnode;override;
  138. function docompare(p: tnode): boolean; override;
  139. end;
  140. traisenodeclass = class of traisenode;
  141. ttryexceptnode = class(tloopnode)
  142. constructor create(l,r,_t1 : tnode);virtual;
  143. function det_resulttype:tnode;override;
  144. function pass_1 : tnode;override;
  145. end;
  146. ttryexceptnodeclass = class of ttryexceptnode;
  147. ttryfinallynode = class(tbinarynode)
  148. constructor create(l,r:tnode);virtual;
  149. function det_resulttype:tnode;override;
  150. function pass_1 : tnode;override;
  151. end;
  152. ttryfinallynodeclass = class of ttryfinallynode;
  153. tonnode = class(tbinarynode)
  154. exceptsymtable : tsymtable;
  155. excepttype : tobjectdef;
  156. constructor create(l,r:tnode);virtual;
  157. destructor destroy;override;
  158. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  159. function det_resulttype:tnode;override;
  160. function pass_1 : tnode;override;
  161. function getcopy : tnode;override;
  162. function docompare(p: tnode): boolean; override;
  163. end;
  164. tonnodeclass = class of tonnode;
  165. tfailnode = class(tnode)
  166. constructor create;virtual;
  167. function det_resulttype:tnode;override;
  168. function pass_1: tnode;override;
  169. function docompare(p: tnode): boolean; override;
  170. end;
  171. tfailnodeclass = class of tfailnode;
  172. { for compatibilty }
  173. function genloopnode(t : tnodetype;l,r,n1 : tnode;back : boolean) : tnode;
  174. var
  175. cwhilerepeatnode : twhilerepeatnodeclass;
  176. cifnode : tifnodeclass;
  177. cfornode : tfornodeclass;
  178. cexitnode : texitnodeclass;
  179. cbreaknode : tbreaknodeclass;
  180. ccontinuenode : tcontinuenodeclass;
  181. cgotonode : tgotonodeclass;
  182. clabelnode : tlabelnodeclass;
  183. craisenode : traisenodeclass;
  184. ctryexceptnode : ttryexceptnodeclass;
  185. ctryfinallynode : ttryfinallynodeclass;
  186. connode : tonnodeclass;
  187. cfailnode : tfailnodeclass;
  188. implementation
  189. uses
  190. globtype,systems,
  191. cutils,verbose,globals,
  192. symconst,symtable,paramgr,defutil,htypechk,pass_1,
  193. ncon,nmem,nld,ncnv,nbas,rgobj,
  194. {$ifdef state_tracking}
  195. nstate,
  196. {$endif}
  197. cginfo,cgbase
  198. ;
  199. function genloopnode(t : tnodetype;l,r,n1 : tnode;back : boolean) : tnode;
  200. var
  201. p : tnode;
  202. begin
  203. case t of
  204. ifn:
  205. p:=cifnode.create(l,r,n1);
  206. whilerepeatn:
  207. if back then
  208. {Repeat until.}
  209. p:=cwhilerepeatnode.create(l,r,n1,false,true)
  210. else
  211. {While do.}
  212. p:=cwhilerepeatnode.create(l,r,n1,true,false);
  213. forn:
  214. p:=cfornode.create(l,r,n1,nil,back);
  215. end;
  216. genloopnode:=p;
  217. end;
  218. {****************************************************************************
  219. TLOOPNODE
  220. *****************************************************************************}
  221. constructor tloopnode.create(tt : tnodetype;l,r,_t1,_t2 : tnode);
  222. begin
  223. inherited create(tt,l,r);
  224. t1:=_t1;
  225. t2:=_t2;
  226. set_file_line(l);
  227. end;
  228. destructor tloopnode.destroy;
  229. begin
  230. t1.free;
  231. t2.free;
  232. inherited destroy;
  233. end;
  234. constructor tloopnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  235. begin
  236. inherited ppuload(t,ppufile);
  237. t1:=ppuloadnode(ppufile);
  238. t2:=ppuloadnode(ppufile);
  239. end;
  240. procedure tloopnode.ppuwrite(ppufile:tcompilerppufile);
  241. begin
  242. inherited ppuwrite(ppufile);
  243. ppuwritenode(ppufile,t1);
  244. ppuwritenode(ppufile,t2);
  245. end;
  246. procedure tloopnode.derefimpl;
  247. begin
  248. inherited derefimpl;
  249. if assigned(t1) then
  250. t1.derefimpl;
  251. if assigned(t2) then
  252. t2.derefimpl;
  253. end;
  254. function tloopnode.getcopy : tnode;
  255. var
  256. p : tloopnode;
  257. begin
  258. p:=tloopnode(inherited getcopy);
  259. if assigned(t1) then
  260. p.t1:=t1.getcopy
  261. else
  262. p.t1:=nil;
  263. if assigned(t2) then
  264. p.t2:=t2.getcopy
  265. else
  266. p.t2:=nil;
  267. getcopy:=p;
  268. end;
  269. procedure tloopnode.insertintolist(l : tnodelist);
  270. begin
  271. end;
  272. procedure tloopnode.printnodetree(var t:text);
  273. begin
  274. printnodeinfo(t);
  275. printnodeindent;
  276. printnode(t,left);
  277. printnode(t,right);
  278. printnode(t,t1);
  279. printnode(t,t2);
  280. printnodeunindent;
  281. end;
  282. function tloopnode.docompare(p: tnode): boolean;
  283. begin
  284. docompare :=
  285. inherited docompare(p) and
  286. (loopflags*loopflagsequal=tloopnode(p).loopflags*loopflagsequal) and
  287. t1.isequal(tloopnode(p).t1) and
  288. t2.isequal(tloopnode(p).t2);
  289. end;
  290. {****************************************************************************
  291. TWHILEREPEATNODE
  292. *****************************************************************************}
  293. constructor Twhilerepeatnode.create(l,r,_t1:Tnode;tab,cn:boolean);
  294. begin
  295. inherited create(whilerepeatn,l,r,_t1,nil);
  296. if tab then
  297. include(loopflags, lnf_testatbegin);
  298. if cn then
  299. include(loopflags,lnf_checknegate);
  300. end;
  301. function twhilerepeatnode.det_resulttype:tnode;
  302. var
  303. t:Tunarynode;
  304. begin
  305. result:=nil;
  306. resulttype:=voidtype;
  307. resulttypepass(left);
  308. {A not node can be removed.}
  309. if left.nodetype=notn then
  310. begin
  311. t:=Tunarynode(left);
  312. left:=Tunarynode(left).left;
  313. t.left:=nil;
  314. t.destroy;
  315. {$ifdef Delphi}
  316. { How can this be handled in Delphi ? }
  317. RunError(255);
  318. {$else}
  319. {Symdif operator, in case you are wondering:}
  320. loopflags:=loopflags >< [lnf_checknegate];
  321. {$endif}
  322. end;
  323. { loop instruction }
  324. if assigned(right) then
  325. resulttypepass(right);
  326. set_varstate(left,true);
  327. if codegenerror then
  328. exit;
  329. if not is_boolean(left.resulttype.def) then
  330. begin
  331. CGMessage(type_e_mismatch);
  332. exit;
  333. end;
  334. end;
  335. function twhilerepeatnode.pass_1 : tnode;
  336. var
  337. old_t_times : longint;
  338. begin
  339. result:=nil;
  340. expectloc:=LOC_VOID;
  341. old_t_times:=rg.t_times;
  342. { calc register weight }
  343. if not(cs_littlesize in aktglobalswitches ) then
  344. rg.t_times:=rg.t_times*8;
  345. {$ifndef newra}
  346. rg.cleartempgen;
  347. {$endif}
  348. firstpass(left);
  349. if codegenerror then
  350. exit;
  351. registers32:=left.registers32;
  352. registersfpu:=left.registersfpu;
  353. {$ifdef SUPPORT_MMX}
  354. registersmmx:=left.registersmmx;
  355. {$endif SUPPORT_MMX}
  356. { loop instruction }
  357. if assigned(right) then
  358. begin
  359. {$ifndef newra}
  360. rg.cleartempgen;
  361. {$endif}
  362. firstpass(right);
  363. if codegenerror then
  364. exit;
  365. if registers32<right.registers32 then
  366. registers32:=right.registers32;
  367. if registersfpu<right.registersfpu then
  368. registersfpu:=right.registersfpu;
  369. {$ifdef SUPPORT_MMX}
  370. if registersmmx<right.registersmmx then
  371. registersmmx:=right.registersmmx;
  372. {$endif SUPPORT_MMX}
  373. end;
  374. rg.t_times:=old_t_times;
  375. end;
  376. {$ifdef state_tracking}
  377. function Twhilerepeatnode.track_state_pass(exec_known:boolean):boolean;
  378. var condition:Tnode;
  379. code:Tnode;
  380. done:boolean;
  381. value:boolean;
  382. change:boolean;
  383. firsttest:boolean;
  384. factval:Tnode;
  385. begin
  386. track_state_pass:=false;
  387. done:=false;
  388. firsttest:=true;
  389. {For repeat until statements, first do a pass through the code.}
  390. if not(lnf_testatbegin in flags) then
  391. begin
  392. code:=right.getcopy;
  393. if code.track_state_pass(exec_known) then
  394. track_state_pass:=true;
  395. code.destroy;
  396. end;
  397. repeat
  398. condition:=left.getcopy;
  399. code:=right.getcopy;
  400. change:=condition.track_state_pass(exec_known);
  401. factval:=aktstate.find_fact(left);
  402. if factval<>nil then
  403. begin
  404. condition.destroy;
  405. condition:=factval.getcopy;
  406. change:=true;
  407. end;
  408. if change then
  409. begin
  410. track_state_pass:=true;
  411. {Force new resulttype pass.}
  412. condition.resulttype.def:=nil;
  413. do_resulttypepass(condition);
  414. end;
  415. if is_constboolnode(condition) then
  416. begin
  417. {Try to turn a while loop into a repeat loop.}
  418. if firsttest then
  419. exclude(flags,testatbegin);
  420. value:=(Tordconstnode(condition).value<>0) xor checknegate;
  421. if value then
  422. begin
  423. if code.track_state_pass(exec_known) then
  424. track_state_pass:=true;
  425. end
  426. else
  427. done:=true;
  428. end
  429. else
  430. begin
  431. {Remove any modified variables from the state.}
  432. code.track_state_pass(false);
  433. done:=true;
  434. end;
  435. code.destroy;
  436. condition.destroy;
  437. firsttest:=false;
  438. until done;
  439. {The loop condition is also known, for example:
  440. while i<10 do
  441. begin
  442. ...
  443. end;
  444. When the loop is done, we do know that i<10 = false.
  445. }
  446. condition:=left.getcopy;
  447. if condition.track_state_pass(exec_known) then
  448. begin
  449. track_state_pass:=true;
  450. {Force new resulttype pass.}
  451. condition.resulttype.def:=nil;
  452. do_resulttypepass(condition);
  453. end;
  454. if not is_constboolnode(condition) then
  455. aktstate.store_fact(condition,
  456. cordconstnode.create(byte(checknegate),booltype,true))
  457. else
  458. condition.destroy;
  459. end;
  460. {$endif}
  461. {*****************************************************************************
  462. TIFNODE
  463. *****************************************************************************}
  464. constructor tifnode.create(l,r,_t1 : tnode);
  465. begin
  466. inherited create(ifn,l,r,_t1,nil);
  467. end;
  468. function tifnode.det_resulttype:tnode;
  469. begin
  470. result:=nil;
  471. resulttype:=voidtype;
  472. resulttypepass(left);
  473. { if path }
  474. if assigned(right) then
  475. resulttypepass(right);
  476. { else path }
  477. if assigned(t1) then
  478. resulttypepass(t1);
  479. set_varstate(left,true);
  480. if codegenerror then
  481. exit;
  482. if not is_boolean(left.resulttype.def) then
  483. Message1(type_e_boolean_expr_expected,left.resulttype.def.typename);
  484. end;
  485. function tifnode.pass_1 : tnode;
  486. var
  487. old_t_times : longint;
  488. hp : tnode;
  489. begin
  490. result:=nil;
  491. expectloc:=LOC_VOID;
  492. old_t_times:=rg.t_times;
  493. {$ifndef newra}
  494. rg.cleartempgen;
  495. {$endif}
  496. firstpass(left);
  497. registers32:=left.registers32;
  498. registersfpu:=left.registersfpu;
  499. {$ifdef SUPPORT_MMX}
  500. registersmmx:=left.registersmmx;
  501. {$endif SUPPORT_MMX}
  502. { determines registers weigths }
  503. if not(cs_littlesize in aktglobalswitches) then
  504. rg.t_times:=rg.t_times div 2;
  505. if rg.t_times=0 then
  506. rg.t_times:=1;
  507. { if path }
  508. if assigned(right) then
  509. begin
  510. {$ifndef newra}
  511. rg.cleartempgen;
  512. {$endif}
  513. firstpass(right);
  514. if registers32<right.registers32 then
  515. registers32:=right.registers32;
  516. if registersfpu<right.registersfpu then
  517. registersfpu:=right.registersfpu;
  518. {$ifdef SUPPORT_MMX}
  519. if registersmmx<right.registersmmx then
  520. registersmmx:=right.registersmmx;
  521. {$endif SUPPORT_MMX}
  522. end;
  523. { else path }
  524. if assigned(t1) then
  525. begin
  526. {$ifndef newra}
  527. rg.cleartempgen;
  528. {$endif}
  529. firstpass(t1);
  530. if registers32<t1.registers32 then
  531. registers32:=t1.registers32;
  532. if registersfpu<t1.registersfpu then
  533. registersfpu:=t1.registersfpu;
  534. {$ifdef SUPPORT_MMX}
  535. if registersmmx<t1.registersmmx then
  536. registersmmx:=t1.registersmmx;
  537. {$endif SUPPORT_MMX}
  538. end;
  539. { leave if we've got an error in one of the paths }
  540. if codegenerror then
  541. exit;
  542. if left.nodetype=ordconstn then
  543. begin
  544. { optimize }
  545. if tordconstnode(left).value=1 then
  546. begin
  547. hp:=right;
  548. right:=nil;
  549. { we cannot set p to nil !!! }
  550. if assigned(hp) then
  551. result:=hp
  552. else
  553. result:=cnothingnode.create;
  554. end
  555. else
  556. begin
  557. hp:=t1;
  558. t1:=nil;
  559. { we cannot set p to nil !!! }
  560. if assigned(hp) then
  561. result:=hp
  562. else
  563. result:=cnothingnode.create;
  564. end;
  565. end;
  566. rg.t_times:=old_t_times;
  567. end;
  568. {*****************************************************************************
  569. TFORNODE
  570. *****************************************************************************}
  571. constructor tfornode.create(l,r,_t1,_t2 : tnode;back : boolean);
  572. begin
  573. inherited create(forn,l,r,_t1,_t2);
  574. if back then
  575. include(loopflags,lnf_backward);
  576. include(loopflags,lnf_testatbegin);
  577. end;
  578. procedure Tfornode.loop_var_access(not_type:Tnotification_flag;
  579. symbol:Tsym);
  580. begin
  581. {If there is a read access, the value of the loop counter is important;
  582. at the end of the loop the loop variable should contain the value it
  583. had in the last iteration.}
  584. if not_type=vn_onwrite then
  585. begin
  586. writeln('Loopvar does not matter on exit');
  587. end
  588. else
  589. begin
  590. exclude(loopflags,lnf_dont_mind_loopvar_on_exit);
  591. writeln('Loopvar does matter on exit');
  592. end;
  593. Tvarsym(symbol).unregister_notification(loopvar_notid);
  594. end;
  595. function tfornode.det_resulttype:tnode;
  596. var
  597. hp : tnode;
  598. begin
  599. result:=nil;
  600. resulttype:=voidtype;
  601. if left.nodetype<>assignn then
  602. begin
  603. CGMessage(cg_e_illegal_expression);
  604. exit;
  605. end;
  606. {Can we spare the first comparision?}
  607. if (right.nodetype=ordconstn) and (Tassignmentnode(left).right.nodetype=ordconstn) then
  608. if (
  609. (lnf_backward in loopflags) and
  610. (Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value)
  611. )
  612. or not(
  613. (lnf_backward in loopflags) and
  614. (Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value)
  615. ) then
  616. exclude(loopflags,lnf_testatbegin);
  617. { save counter var }
  618. t2:=tassignmentnode(left).left.getcopy;
  619. resulttypepass(left);
  620. set_varstate(left,false);
  621. if assigned(t1) then
  622. begin
  623. resulttypepass(t1);
  624. if codegenerror then
  625. exit;
  626. end;
  627. { process count var }
  628. resulttypepass(t2);
  629. set_varstate(t2,true);
  630. if codegenerror then
  631. exit;
  632. { Check count var, record fields are also allowed in tp7 }
  633. hp:=t2;
  634. while (hp.nodetype=subscriptn) or
  635. ((hp.nodetype=vecn) and
  636. is_constintnode(tvecnode(hp).right)) do
  637. hp:=tunarynode(hp).left;
  638. { we need a simple loadn, but the load must be in a global symtable or
  639. in the same level as the para of the current proc }
  640. if (
  641. (hp.nodetype=loadn) and
  642. (
  643. (tloadnode(hp).symtable.symtablelevel=main_program_level) or
  644. (tloadnode(hp).symtable.symtablelevel=current_procdef.parast.symtablelevel)
  645. ) and
  646. not(
  647. (tloadnode(hp).symtableentry.typ=varsym) and
  648. ((tvarsym(tloadnode(hp).symtableentry).varspez in [vs_var,vs_out]) or
  649. (vo_is_thread_var in tvarsym(tloadnode(hp).symtableentry).varoptions))
  650. )
  651. ) then
  652. begin
  653. if (hp.nodetype=loadn) and
  654. (tloadnode(hp).symtableentry.typ=varsym) then
  655. tvarsym(tloadnode(hp).symtableentry).varstate:=vs_used;
  656. if (not(is_ordinal(t2.resulttype.def)) or is_64bitint(t2.resulttype.def)) then
  657. CGMessagePos(hp.fileinfo,type_e_ordinal_expr_expected);
  658. end
  659. else
  660. CGMessagePos(hp.fileinfo,cg_e_illegal_count_var);
  661. resulttypepass(right);
  662. set_varstate(right,true);
  663. inserttypeconv(right,t2.resulttype);
  664. end;
  665. function tfornode.pass_1 : tnode;
  666. var
  667. old_t_times : longint;
  668. {$ifdef loopvar_dont_mind}
  669. hp : Tnode;
  670. {$endif loopvar_dont_mind}
  671. begin
  672. result:=nil;
  673. expectloc:=LOC_VOID;
  674. { Calc register weight }
  675. old_t_times:=rg.t_times;
  676. if not(cs_littlesize in aktglobalswitches) then
  677. rg.t_times:=rg.t_times*8;
  678. {$ifndef newra}
  679. rg.cleartempgen;
  680. {$endif}
  681. firstpass(left);
  682. {$ifndef newra}
  683. rg.cleartempgen;
  684. {$endif}
  685. if assigned(t1) then
  686. begin
  687. firstpass(t1);
  688. if codegenerror then
  689. exit;
  690. end;
  691. registers32:=t1.registers32;
  692. registersfpu:=t1.registersfpu;
  693. {$ifdef SUPPORT_MMX}
  694. registersmmx:=left.registersmmx;
  695. {$endif SUPPORT_MMX}
  696. if left.registers32>registers32 then
  697. registers32:=left.registers32;
  698. if left.registersfpu>registersfpu then
  699. registersfpu:=left.registersfpu;
  700. {$ifdef SUPPORT_MMX}
  701. if left.registersmmx>registersmmx then
  702. registersmmx:=left.registersmmx;
  703. {$endif SUPPORT_MMX}
  704. { process count var }
  705. {$ifndef newra}
  706. rg.cleartempgen;
  707. {$endif}
  708. firstpass(t2);
  709. if codegenerror then
  710. exit;
  711. if t2.registers32>registers32 then
  712. registers32:=t2.registers32;
  713. if t2.registersfpu>registersfpu then
  714. registersfpu:=t2.registersfpu;
  715. {$ifdef SUPPORT_MMX}
  716. if t2.registersmmx>registersmmx then
  717. registersmmx:=t2.registersmmx;
  718. {$endif SUPPORT_MMX}
  719. {$ifndef newra}
  720. rg.cleartempgen;
  721. {$endif}
  722. firstpass(right);
  723. {$ifdef loopvar_dont_mind}
  724. { Check count var, record fields are also allowed in tp7 }
  725. include(loopflags,lnf_dont_mind_loopvar_on_exit);
  726. hp:=t2;
  727. while (hp.nodetype=subscriptn) or
  728. ((hp.nodetype=vecn) and
  729. is_constintnode(tvecnode(hp).right)) do
  730. hp:=tunarynode(hp).left;
  731. if (hp.nodetype=loadn) and (Tloadnode(hp).symtableentry.typ=varsym) then
  732. loopvar_notid:=Tvarsym(Tloadnode(hp).symtableentry).
  733. register_notification([vn_onread,vn_onwrite],@loop_var_access);
  734. {$endif}
  735. if right.registers32>registers32 then
  736. registers32:=right.registers32;
  737. if right.registersfpu>registersfpu then
  738. registersfpu:=right.registersfpu;
  739. {$ifdef SUPPORT_MMX}
  740. if right.registersmmx>registersmmx then
  741. registersmmx:=right.registersmmx;
  742. {$endif SUPPORT_MMX}
  743. { we need at least one register for comparisons PM }
  744. if registers32=0 then
  745. inc(registers32);
  746. rg.t_times:=old_t_times;
  747. end;
  748. {*****************************************************************************
  749. TEXITNODE
  750. *****************************************************************************}
  751. constructor texitnode.create(l:tnode);
  752. begin
  753. inherited create(exitn,l);
  754. onlyassign:=false;
  755. end;
  756. constructor texitnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  757. begin
  758. inherited ppuload(t,ppufile);
  759. onlyassign:=boolean(ppufile.getbyte);
  760. end;
  761. procedure texitnode.ppuwrite(ppufile:tcompilerppufile);
  762. begin
  763. inherited ppuwrite(ppufile);
  764. ppufile.putbyte(byte(onlyassign));
  765. end;
  766. function texitnode.det_resulttype:tnode;
  767. begin
  768. result:=nil;
  769. { Check the 2 types }
  770. if not inlining_procedure then
  771. begin
  772. if assigned(left) then
  773. begin
  774. inserttypeconv(left,current_procdef.rettype);
  775. if paramanager.ret_in_param(current_procdef.rettype.def,current_procdef.proccalloption) or
  776. (current_procdef.proctypeoption=potype_constructor) or
  777. (pi_needs_implicit_finally in current_procinfo.flags) or
  778. (pi_uses_exceptions in current_procinfo.flags) then
  779. begin
  780. left:=cassignmentnode.create(
  781. cloadnode.create(current_procdef.funcretsym,current_procdef.funcretsym.owner),
  782. left);
  783. onlyassign:=true;
  784. end
  785. else
  786. begin
  787. { mark funcretsym as assigned }
  788. inc(tvarsym(current_procdef.funcretsym).refs);
  789. tvarsym(current_procdef.funcretsym).varstate:=vs_assigned;
  790. end;
  791. end;
  792. end;
  793. if assigned(left) then
  794. begin
  795. resulttypepass(left);
  796. set_varstate(left,true);
  797. end;
  798. resulttype:=voidtype;
  799. end;
  800. function texitnode.pass_1 : tnode;
  801. begin
  802. result:=nil;
  803. expectloc:=LOC_VOID;
  804. if assigned(left) then
  805. begin
  806. firstpass(left);
  807. if codegenerror then
  808. exit;
  809. registers32:=left.registers32;
  810. registersfpu:=left.registersfpu;
  811. {$ifdef SUPPORT_MMX}
  812. registersmmx:=left.registersmmx;
  813. {$endif SUPPORT_MMX}
  814. end;
  815. end;
  816. {*****************************************************************************
  817. TBREAKNODE
  818. *****************************************************************************}
  819. constructor tbreaknode.create;
  820. begin
  821. inherited create(breakn);
  822. end;
  823. function tbreaknode.det_resulttype:tnode;
  824. begin
  825. result:=nil;
  826. resulttype:=voidtype;
  827. end;
  828. function tbreaknode.pass_1 : tnode;
  829. begin
  830. result:=nil;
  831. expectloc:=LOC_VOID;
  832. end;
  833. {*****************************************************************************
  834. TCONTINUENODE
  835. *****************************************************************************}
  836. constructor tcontinuenode.create;
  837. begin
  838. inherited create(continuen);
  839. end;
  840. function tcontinuenode.det_resulttype:tnode;
  841. begin
  842. result:=nil;
  843. resulttype:=voidtype;
  844. end;
  845. function tcontinuenode.pass_1 : tnode;
  846. begin
  847. result:=nil;
  848. expectloc:=LOC_VOID;
  849. end;
  850. {*****************************************************************************
  851. TGOTONODE
  852. *****************************************************************************}
  853. constructor tgotonode.create(p : tlabelsym);
  854. begin
  855. inherited create(goton);
  856. exceptionblock:=aktexceptblock;
  857. labsym:=p;
  858. end;
  859. constructor tgotonode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  860. begin
  861. inherited ppuload(t,ppufile);
  862. labsym:=tlabelsym(ppufile.getderef);
  863. exceptionblock:=ppufile.getbyte;
  864. end;
  865. procedure tgotonode.ppuwrite(ppufile:tcompilerppufile);
  866. begin
  867. inherited ppuwrite(ppufile);
  868. ppufile.putderef(labsym);
  869. ppufile.putbyte(exceptionblock);
  870. end;
  871. procedure tgotonode.derefimpl;
  872. begin
  873. inherited derefimpl;
  874. resolvesym(pointer(labsym));
  875. end;
  876. function tgotonode.det_resulttype:tnode;
  877. begin
  878. result:=nil;
  879. resulttype:=voidtype;
  880. end;
  881. function tgotonode.pass_1 : tnode;
  882. begin
  883. result:=nil;
  884. expectloc:=LOC_VOID;
  885. { check if }
  886. if assigned(labsym) and
  887. assigned(labsym.code) and
  888. (exceptionblock<>tlabelnode(labsym.code).exceptionblock) then
  889. begin
  890. writeln('goto exceptblock: ',exceptionblock);
  891. writeln('label exceptblock: ',tlabelnode(labsym.code).exceptionblock);
  892. CGMessage(cg_e_goto_inout_of_exception_block);
  893. end;
  894. end;
  895. function tgotonode.getcopy : tnode;
  896. var
  897. p : tgotonode;
  898. begin
  899. p:=tgotonode(inherited getcopy);
  900. p.labsym:=labsym;
  901. p.exceptionblock:=exceptionblock;
  902. result:=p;
  903. end;
  904. function tgotonode.docompare(p: tnode): boolean;
  905. begin
  906. docompare := false;
  907. end;
  908. {*****************************************************************************
  909. TLABELNODE
  910. *****************************************************************************}
  911. constructor tlabelnode.createcase(p : tasmlabel;l:tnode);
  912. begin
  913. inherited create(labeln,l);
  914. { it shouldn't be possible to jump to case labels using goto }
  915. exceptionblock:=-1;
  916. labsym:=nil;
  917. labelnr:=p;
  918. end;
  919. constructor tlabelnode.create(p : tlabelsym;l:tnode);
  920. begin
  921. inherited create(labeln,l);
  922. exceptionblock:=aktexceptblock;
  923. labsym:=p;
  924. labelnr:=p.lab;
  925. { save the current labelnode in the labelsym }
  926. p.code:=self;
  927. end;
  928. constructor tlabelnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  929. begin
  930. inherited ppuload(t,ppufile);
  931. labsym:=tlabelsym(ppufile.getderef);
  932. labelnr:=tasmlabel(ppufile.getasmsymbol);
  933. exceptionblock:=ppufile.getbyte;
  934. end;
  935. procedure tlabelnode.ppuwrite(ppufile:tcompilerppufile);
  936. begin
  937. inherited ppuwrite(ppufile);
  938. ppufile.putderef(labsym);
  939. ppufile.putasmsymbol(labelnr);
  940. ppufile.putbyte(exceptionblock);
  941. end;
  942. procedure tlabelnode.derefimpl;
  943. begin
  944. inherited derefimpl;
  945. resolvesym(pointer(labsym));
  946. objectlibrary.derefasmsymbol(tasmsymbol(labelnr));
  947. end;
  948. function tlabelnode.det_resulttype:tnode;
  949. begin
  950. result:=nil;
  951. { left could still be unassigned }
  952. if assigned(left) then
  953. resulttypepass(left);
  954. resulttype:=voidtype;
  955. end;
  956. function tlabelnode.pass_1 : tnode;
  957. begin
  958. result:=nil;
  959. expectloc:=LOC_VOID;
  960. if assigned(left) then
  961. begin
  962. {$ifndef newra}
  963. rg.cleartempgen;
  964. {$endif}
  965. firstpass(left);
  966. registers32:=left.registers32;
  967. registersfpu:=left.registersfpu;
  968. {$ifdef SUPPORT_MMX}
  969. registersmmx:=left.registersmmx;
  970. {$endif SUPPORT_MMX}
  971. end;
  972. end;
  973. function tlabelnode.getcopy : tnode;
  974. var
  975. p : tlabelnode;
  976. begin
  977. p:=tlabelnode(inherited getcopy);
  978. p.labelnr:=labelnr;
  979. p.exceptionblock:=exceptionblock;
  980. p.labsym:=labsym;
  981. result:=p;
  982. end;
  983. function tlabelnode.docompare(p: tnode): boolean;
  984. begin
  985. docompare := false;
  986. end;
  987. {*****************************************************************************
  988. TRAISENODE
  989. *****************************************************************************}
  990. constructor traisenode.create(l,taddr,tframe:tnode);
  991. begin
  992. inherited create(raisen,l,taddr);
  993. frametree:=tframe;
  994. end;
  995. constructor traisenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  996. begin
  997. inherited ppuload(t,ppufile);
  998. frametree:=ppuloadnode(ppufile);
  999. end;
  1000. procedure traisenode.ppuwrite(ppufile:tcompilerppufile);
  1001. begin
  1002. inherited ppuwrite(ppufile);
  1003. ppuwritenode(ppufile,frametree);
  1004. end;
  1005. procedure traisenode.derefimpl;
  1006. begin
  1007. inherited derefimpl;
  1008. if assigned(frametree) then
  1009. frametree.derefimpl;
  1010. end;
  1011. function traisenode.getcopy : tnode;
  1012. var
  1013. n : traisenode;
  1014. begin
  1015. n:=traisenode(inherited getcopy);
  1016. if assigned(frametree) then
  1017. n.frametree:=frametree.getcopy
  1018. else
  1019. n.frametree:=nil;
  1020. getcopy:=n;
  1021. end;
  1022. procedure traisenode.insertintolist(l : tnodelist);
  1023. begin
  1024. end;
  1025. function traisenode.det_resulttype:tnode;
  1026. begin
  1027. result:=nil;
  1028. resulttype:=voidtype;
  1029. if assigned(left) then
  1030. begin
  1031. { first para must be a _class_ }
  1032. resulttypepass(left);
  1033. set_varstate(left,true);
  1034. if codegenerror then
  1035. exit;
  1036. if not(is_class(left.resulttype.def)) then
  1037. CGMessage(type_e_mismatch);
  1038. { insert needed typeconvs for addr,frame }
  1039. if assigned(right) then
  1040. begin
  1041. { addr }
  1042. resulttypepass(right);
  1043. inserttypeconv(right,voidpointertype);
  1044. { frame }
  1045. if assigned(frametree) then
  1046. begin
  1047. resulttypepass(frametree);
  1048. inserttypeconv(frametree,voidpointertype);
  1049. end;
  1050. end;
  1051. end;
  1052. end;
  1053. function traisenode.pass_1 : tnode;
  1054. begin
  1055. result:=nil;
  1056. expectloc:=LOC_VOID;
  1057. if assigned(left) then
  1058. begin
  1059. { first para must be a _class_ }
  1060. firstpass(left);
  1061. { insert needed typeconvs for addr,frame }
  1062. if assigned(right) then
  1063. begin
  1064. { addr }
  1065. firstpass(right);
  1066. { frame }
  1067. if assigned(frametree) then
  1068. firstpass(frametree);
  1069. end;
  1070. left_right_max;
  1071. end;
  1072. end;
  1073. function traisenode.docompare(p: tnode): boolean;
  1074. begin
  1075. docompare := false;
  1076. end;
  1077. {*****************************************************************************
  1078. TTRYEXCEPTNODE
  1079. *****************************************************************************}
  1080. constructor ttryexceptnode.create(l,r,_t1 : tnode);
  1081. begin
  1082. inherited create(tryexceptn,l,r,_t1,nil);
  1083. end;
  1084. function ttryexceptnode.det_resulttype:tnode;
  1085. begin
  1086. result:=nil;
  1087. resulttypepass(left);
  1088. { on statements }
  1089. if assigned(right) then
  1090. resulttypepass(right);
  1091. { else block }
  1092. if assigned(t1) then
  1093. resulttypepass(t1);
  1094. resulttype:=voidtype;
  1095. end;
  1096. function ttryexceptnode.pass_1 : tnode;
  1097. begin
  1098. result:=nil;
  1099. expectloc:=LOC_VOID;
  1100. {$ifndef newra}
  1101. rg.cleartempgen;
  1102. {$endif}
  1103. firstpass(left);
  1104. { on statements }
  1105. if assigned(right) then
  1106. begin
  1107. {$ifndef newra}
  1108. rg.cleartempgen;
  1109. {$endif}
  1110. firstpass(right);
  1111. registers32:=max(registers32,right.registers32);
  1112. registersfpu:=max(registersfpu,right.registersfpu);
  1113. {$ifdef SUPPORT_MMX}
  1114. registersmmx:=max(registersmmx,right.registersmmx);
  1115. {$endif SUPPORT_MMX}
  1116. end;
  1117. { else block }
  1118. if assigned(t1) then
  1119. begin
  1120. firstpass(t1);
  1121. registers32:=max(registers32,t1.registers32);
  1122. registersfpu:=max(registersfpu,t1.registersfpu);
  1123. {$ifdef SUPPORT_MMX}
  1124. registersmmx:=max(registersmmx,t1.registersmmx);
  1125. {$endif SUPPORT_MMX}
  1126. end;
  1127. end;
  1128. {*****************************************************************************
  1129. TTRYFINALLYNODE
  1130. *****************************************************************************}
  1131. constructor ttryfinallynode.create(l,r:tnode);
  1132. begin
  1133. inherited create(tryfinallyn,l,r);
  1134. end;
  1135. function ttryfinallynode.det_resulttype:tnode;
  1136. begin
  1137. result:=nil;
  1138. resulttype:=voidtype;
  1139. resulttypepass(left);
  1140. set_varstate(left,true);
  1141. resulttypepass(right);
  1142. set_varstate(right,true);
  1143. end;
  1144. function ttryfinallynode.pass_1 : tnode;
  1145. begin
  1146. result:=nil;
  1147. expectloc:=LOC_VOID;
  1148. {$ifndef newra}
  1149. rg.cleartempgen;
  1150. {$endif}
  1151. firstpass(left);
  1152. {$ifndef newra}
  1153. rg.cleartempgen;
  1154. {$endif}
  1155. firstpass(right);
  1156. left_right_max;
  1157. end;
  1158. {*****************************************************************************
  1159. TONNODE
  1160. *****************************************************************************}
  1161. constructor tonnode.create(l,r:tnode);
  1162. begin
  1163. inherited create(onn,l,r);
  1164. exceptsymtable:=nil;
  1165. excepttype:=nil;
  1166. end;
  1167. destructor tonnode.destroy;
  1168. begin
  1169. if assigned(exceptsymtable) then
  1170. exceptsymtable.free;
  1171. inherited destroy;
  1172. end;
  1173. constructor tonnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1174. begin
  1175. inherited ppuload(t,ppufile);
  1176. exceptsymtable:=nil;
  1177. excepttype:=nil;
  1178. end;
  1179. function tonnode.getcopy : tnode;
  1180. var
  1181. n : tonnode;
  1182. begin
  1183. n:=tonnode(inherited getcopy);
  1184. n.exceptsymtable:=exceptsymtable;
  1185. n.excepttype:=excepttype;
  1186. result:=n;
  1187. end;
  1188. function tonnode.det_resulttype:tnode;
  1189. begin
  1190. result:=nil;
  1191. resulttype:=voidtype;
  1192. if not(is_class(excepttype)) then
  1193. CGMessage(type_e_mismatch);
  1194. if assigned(left) then
  1195. resulttypepass(left);
  1196. if assigned(right) then
  1197. resulttypepass(right);
  1198. end;
  1199. function tonnode.pass_1 : tnode;
  1200. begin
  1201. result:=nil;
  1202. expectloc:=LOC_VOID;
  1203. rg.cleartempgen;
  1204. registers32:=0;
  1205. registersfpu:=0;
  1206. {$ifdef SUPPORT_MMX}
  1207. registersmmx:=0;
  1208. {$endif SUPPORT_MMX}
  1209. if assigned(left) then
  1210. begin
  1211. firstpass(left);
  1212. registers32:=left.registers32;
  1213. registersfpu:=left.registersfpu;
  1214. {$ifdef SUPPORT_MMX}
  1215. registersmmx:=left.registersmmx;
  1216. {$endif SUPPORT_MMX}
  1217. end;
  1218. rg.cleartempgen;
  1219. if assigned(right) then
  1220. begin
  1221. firstpass(right);
  1222. registers32:=max(registers32,right.registers32);
  1223. registersfpu:=max(registersfpu,right.registersfpu);
  1224. {$ifdef SUPPORT_MMX}
  1225. registersmmx:=max(registersmmx,right.registersmmx);
  1226. {$endif SUPPORT_MMX}
  1227. end;
  1228. end;
  1229. function tonnode.docompare(p: tnode): boolean;
  1230. begin
  1231. docompare := false;
  1232. end;
  1233. {*****************************************************************************
  1234. TFAILNODE
  1235. *****************************************************************************}
  1236. constructor tfailnode.create;
  1237. begin
  1238. inherited create(failn);
  1239. end;
  1240. function tfailnode.det_resulttype:tnode;
  1241. begin
  1242. result:=nil;
  1243. resulttype:=voidtype;
  1244. end;
  1245. function tfailnode.pass_1 : tnode;
  1246. begin
  1247. result:=nil;
  1248. expectloc:=LOC_VOID;
  1249. end;
  1250. function tfailnode.docompare(p: tnode): boolean;
  1251. begin
  1252. docompare := false;
  1253. end;
  1254. begin
  1255. cwhilerepeatnode:=twhilerepeatnode;
  1256. cifnode:=tifnode;
  1257. cfornode:=tfornode;
  1258. cexitnode:=texitnode;
  1259. cgotonode:=tgotonode;
  1260. clabelnode:=tlabelnode;
  1261. craisenode:=traisenode;
  1262. ctryexceptnode:=ttryexceptnode;
  1263. ctryfinallynode:=ttryfinallynode;
  1264. connode:=tonnode;
  1265. cfailnode:=tfailnode;
  1266. end.
  1267. {
  1268. $Log$
  1269. Revision 1.71 2003-04-27 11:21:33 peter
  1270. * aktprocdef renamed to current_procdef
  1271. * procinfo renamed to current_procinfo
  1272. * procinfo will now be stored in current_module so it can be
  1273. cleaned up properly
  1274. * gen_main_procsym changed to create_main_proc and release_main_proc
  1275. to also generate a tprocinfo structure
  1276. * fixed unit implicit initfinal
  1277. Revision 1.70 2003/04/27 07:29:50 peter
  1278. * current_procdef cleanup, current_procdef is now always nil when parsing
  1279. a new procdef declaration
  1280. * aktprocsym removed
  1281. * lexlevel removed, use symtable.symtablelevel instead
  1282. * implicit init/final code uses the normal genentry/genexit
  1283. * funcret state checking updated for new funcret handling
  1284. Revision 1.69 2003/04/26 00:28:41 peter
  1285. * removed load_funcret
  1286. Revision 1.68 2003/04/25 20:59:33 peter
  1287. * removed funcretn,funcretsym, function result is now in varsym
  1288. and aliases for result and function name are added using absolutesym
  1289. * vs_hidden parameter for funcret passed in parameter
  1290. * vs_hidden fixes
  1291. * writenode changed to printnode and released from extdebug
  1292. * -vp option added to generate a tree.log with the nodetree
  1293. * nicer printnode for statements, callnode
  1294. Revision 1.67 2003/04/25 08:25:26 daniel
  1295. * Ifdefs around a lot of calls to cleartempgen
  1296. * Fixed registers that are allocated but not freed in several nodes
  1297. * Tweak to register allocator to cause less spills
  1298. * 8-bit registers now interfere with esi,edi and ebp
  1299. Compiler can now compile rtl successfully when using new register
  1300. allocator
  1301. Revision 1.66 2003/04/22 23:50:23 peter
  1302. * firstpass uses expectloc
  1303. * checks if there are differences between the expectloc and
  1304. location.loc from secondpass in EXTDEBUG
  1305. Revision 1.65 2003/03/20 15:54:46 peter
  1306. * don't allow var and out parameters as for loop counter
  1307. Revision 1.64 2003/01/09 21:52:37 peter
  1308. * merged some verbosity options.
  1309. * V_LineInfo is a verbosity flag to include line info
  1310. Revision 1.63 2003/01/04 08:08:47 daniel
  1311. * Readded missing variable
  1312. Revision 1.62 2003/01/03 17:16:57 peter
  1313. * fixed warning about unset funcret
  1314. Revision 1.61 2003/01/03 12:15:56 daniel
  1315. * Removed ifdefs around notifications
  1316. ifdefs around for loop optimizations remain
  1317. Revision 1.60 2002/12/31 09:55:58 daniel
  1318. + Notification implementation complete
  1319. + Add for loop code optimization using notifications
  1320. results in 1.5-1.9% speed improvement in nestloop benchmark
  1321. Optimization incomplete, compiler does not cycle yet with
  1322. notifications enabled.
  1323. Revision 1.59 2002/12/30 22:44:53 daniel
  1324. * Some work on notifications
  1325. Revision 1.58 2002/12/27 15:25:40 peter
  1326. * do not allow threadvar as loop counter
  1327. Revision 1.57 2002/11/28 11:17:02 florian
  1328. * loop node flags from node flags splitted
  1329. Revision 1.56 2002/11/25 17:43:18 peter
  1330. * splitted defbase in defutil,symutil,defcmp
  1331. * merged isconvertable and is_equal into compare_defs(_ext)
  1332. * made operator search faster by walking the list only once
  1333. Revision 1.55 2002/11/18 17:31:56 peter
  1334. * pass proccalloption to ret_in_xxx and push_xxx functions
  1335. Revision 1.54 2002/10/20 15:31:49 peter
  1336. * set funcret state for exit(0)
  1337. Revision 1.53 2002/10/05 12:43:25 carl
  1338. * fixes for Delphi 6 compilation
  1339. (warning : Some features do not work under Delphi)
  1340. Revision 1.52 2002/09/07 15:25:03 peter
  1341. * old logs removed and tabs fixed
  1342. Revision 1.51 2002/09/07 12:16:04 carl
  1343. * second part bug report 1996 fix, testrange in cordconstnode
  1344. only called if option is set (also make parsing a tiny faster)
  1345. Revision 1.50 2002/09/01 18:47:00 peter
  1346. * assignn check in exitnode changed to use a separate boolean as the
  1347. assignn can be changed to a calln
  1348. Revision 1.49 2002/09/01 08:01:16 daniel
  1349. * Removed sets from Tcallnode.det_resulttype
  1350. + Added read/write notifications of variables. These will be usefull
  1351. for providing information for several optimizations. For example
  1352. the value of the loop variable of a for loop does matter is the
  1353. variable is read after the for loop, but if it's no longer used
  1354. or written, it doesn't matter and this can be used to optimize
  1355. the loop code generation.
  1356. Revision 1.48 2002/08/22 15:15:20 daniel
  1357. * Fixed the detection wether the first check of a for loop can be skipped
  1358. Revision 1.47 2002/08/19 19:36:43 peter
  1359. * More fixes for cross unit inlining, all tnodes are now implemented
  1360. * Moved pocall_internconst to po_internconst because it is not a
  1361. calling type at all and it conflicted when inlining of these small
  1362. functions was requested
  1363. Revision 1.46 2002/08/17 22:09:46 florian
  1364. * result type handling in tcgcal.pass_2 overhauled
  1365. * better tnode.dowrite
  1366. * some ppc stuff fixed
  1367. Revision 1.45 2002/08/17 09:23:37 florian
  1368. * first part of current_procinfo rewrite
  1369. Revision 1.44 2002/07/21 06:58:49 daniel
  1370. * Changed booleans into flags
  1371. Revision 1.43 2002/07/20 11:57:54 florian
  1372. * types.pas renamed to defbase.pas because D6 contains a types
  1373. unit so this would conflicts if D6 programms are compiled
  1374. + Willamette/SSE2 instructions to assembler added
  1375. Revision 1.42 2002/07/20 11:18:18 daniel
  1376. * Small mistake fixed; the skip test was done before we know the for node
  1377. is correct.
  1378. Revision 1.40 2002/07/20 08:19:31 daniel
  1379. * State tracker automatically changes while loops into repeat loops
  1380. Revision 1.39 2002/07/19 12:55:27 daniel
  1381. * Further developed state tracking in whilerepeatn
  1382. Revision 1.38 2002/07/19 11:41:35 daniel
  1383. * State tracker work
  1384. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1385. allows the state tracker to change while nodes automatically into
  1386. repeat nodes.
  1387. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1388. 'not(a>b)' is optimized into 'a<=b'.
  1389. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1390. by removing the notn and later switchting the true and falselabels. The
  1391. same is done with 'repeat until not a'.
  1392. Revision 1.37 2002/07/16 13:57:02 florian
  1393. * raise takes now a void pointer as at and frame address
  1394. instead of a longint
  1395. Revision 1.36 2002/07/15 18:03:15 florian
  1396. * readded removed changes
  1397. Revision 1.35 2002/07/14 18:00:44 daniel
  1398. + Added the beginning of a state tracker. This will track the values of
  1399. variables through procedures and optimize things away.
  1400. Revision 1.34 2002/07/11 14:41:28 florian
  1401. * start of the new generic parameter handling
  1402. Revision 1.33 2002/07/01 18:46:23 peter
  1403. * internal linker
  1404. * reorganized aasm layer
  1405. Revision 1.32 2002/05/18 13:34:10 peter
  1406. * readded missing revisions
  1407. Revision 1.31 2002/05/16 19:46:38 carl
  1408. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1409. + try to fix temp allocation (still in ifdef)
  1410. + generic constructor calls
  1411. + start of tassembler / tmodulebase class cleanup
  1412. }