nflw.pas 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Type checking and register allocation for nodes that influence
  4. the flow
  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 nflw;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,
  23. node,cpubase,
  24. symnot,
  25. symtype,symbase,symdef,symsym,
  26. optunrol;
  27. type
  28. { flags used by loop nodes }
  29. tloopflag = (
  30. { set if it is a for ... downto ... do loop }
  31. lnf_backward,
  32. { Do we need to parse childs to set var state? }
  33. lnf_varstate,
  34. { Do a test at the begin of the loop?}
  35. lnf_testatbegin,
  36. { Negate the loop test? }
  37. lnf_checknegate,
  38. { Should the value of the loop variable on exit be correct. }
  39. lnf_dont_mind_loopvar_on_exit);
  40. tloopflags = set of tloopflag;
  41. const
  42. { loop flags which must match to consider loop nodes equal regarding the flags }
  43. loopflagsequal = [lnf_backward];
  44. type
  45. tlabelnode = class;
  46. tloopnode = class(tbinarynode)
  47. t1,t2 : tnode;
  48. loopflags : tloopflags;
  49. constructor create(tt : tnodetype;l,r,_t1,_t2 : tnode);virtual;
  50. destructor destroy;override;
  51. function dogetcopy : tnode;override;
  52. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  53. procedure ppuwrite(ppufile:tcompilerppufile);override;
  54. procedure buildderefimpl;override;
  55. procedure derefimpl;override;
  56. procedure insertintolist(l : tnodelist);override;
  57. procedure printnodetree(var t:text);override;
  58. function docompare(p: tnode): boolean; override;
  59. end;
  60. twhilerepeatnode = class(tloopnode)
  61. constructor create(l,r:Tnode;tab,cn:boolean);virtual;reintroduce;
  62. function pass_typecheck:tnode;override;
  63. function pass_1 : tnode;override;
  64. {$ifdef state_tracking}
  65. function track_state_pass(exec_known:boolean):boolean;override;
  66. {$endif}
  67. end;
  68. twhilerepeatnodeclass = class of twhilerepeatnode;
  69. tifnode = class(tloopnode)
  70. constructor create(l,r,_t1 : tnode);virtual;reintroduce;
  71. function pass_typecheck:tnode;override;
  72. function pass_1 : tnode;override;
  73. end;
  74. tifnodeclass = class of tifnode;
  75. tfornode = class(tloopnode)
  76. { if count isn divisable by unrolls then
  77. the for loop must jump to this label to get the correct
  78. number of executions }
  79. entrylabel : tnode;
  80. loopvar_notid:cardinal;
  81. constructor create(l,r,_t1,_t2 : tnode;back : boolean);virtual;reintroduce;
  82. procedure loop_var_access(not_type:Tnotification_flag;symbol:Tsym);
  83. function pass_typecheck:tnode;override;
  84. function pass_1 : tnode;override;
  85. end;
  86. tfornodeclass = class of tfornode;
  87. texitnode = class(tunarynode)
  88. constructor create(l:tnode);virtual;
  89. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  90. procedure ppuwrite(ppufile:tcompilerppufile);override;
  91. function pass_typecheck:tnode;override;
  92. function pass_1 : tnode;override;
  93. end;
  94. texitnodeclass = class of texitnode;
  95. tbreaknode = class(tnode)
  96. constructor create;virtual;
  97. function pass_typecheck:tnode;override;
  98. function pass_1 : tnode;override;
  99. end;
  100. tbreaknodeclass = class of tbreaknode;
  101. tcontinuenode = class(tnode)
  102. constructor create;virtual;
  103. function pass_typecheck:tnode;override;
  104. function pass_1 : tnode;override;
  105. end;
  106. tcontinuenodeclass = class of tcontinuenode;
  107. tgotonode = class(tnode)
  108. labelsym : tlabelsym;
  109. labelnode : tlabelnode;
  110. exceptionblock : integer;
  111. constructor create(p : tlabelsym);virtual;
  112. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  113. procedure ppuwrite(ppufile:tcompilerppufile);override;
  114. procedure buildderefimpl;override;
  115. procedure derefimpl;override;
  116. function dogetcopy : tnode;override;
  117. function pass_typecheck:tnode;override;
  118. function pass_1 : tnode;override;
  119. function docompare(p: tnode): boolean; override;
  120. end;
  121. tgotonodeclass = class of tgotonode;
  122. tlabelnode = class(tunarynode)
  123. exceptionblock : integer;
  124. { when copying trees, this points to the newly created copy of a label }
  125. copiedto : tlabelnode;
  126. labsym : tlabelsym;
  127. constructor create(l:tnode;alabsym:tlabelsym);virtual;
  128. destructor destroy;override;
  129. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  130. procedure ppuwrite(ppufile:tcompilerppufile);override;
  131. procedure buildderefimpl;override;
  132. procedure derefimpl;override;
  133. function dogetcopy : tnode;override;
  134. function pass_typecheck:tnode;override;
  135. function pass_1 : tnode;override;
  136. function docompare(p: tnode): boolean; override;
  137. end;
  138. tlabelnodeclass = class of tlabelnode;
  139. traisenode = class(ttertiarynode)
  140. constructor create(l,taddr,tframe:tnode);virtual;
  141. function pass_typecheck:tnode;override;
  142. function pass_1 : tnode;override;
  143. property frametree : tnode read third write third;
  144. end;
  145. traisenodeclass = class of traisenode;
  146. ttryexceptnode = class(tloopnode)
  147. constructor create(l,r,_t1 : tnode);virtual;reintroduce;
  148. function pass_typecheck:tnode;override;
  149. function pass_1 : tnode;override;
  150. end;
  151. ttryexceptnodeclass = class of ttryexceptnode;
  152. ttryfinallynode = class(tloopnode)
  153. implicitframe : boolean;
  154. constructor create(l,r:tnode);virtual;reintroduce;
  155. constructor create_implicit(l,r,_t1:tnode);virtual;
  156. function pass_typecheck:tnode;override;
  157. function pass_1 : tnode;override;
  158. end;
  159. ttryfinallynodeclass = class of ttryfinallynode;
  160. tonnode = class(tbinarynode)
  161. excepTSymtable : TSymtable;
  162. excepttype : tobjectdef;
  163. constructor create(l,r:tnode);virtual;
  164. destructor destroy;override;
  165. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  166. function pass_typecheck:tnode;override;
  167. function pass_1 : tnode;override;
  168. function dogetcopy : tnode;override;
  169. function docompare(p: tnode): boolean; override;
  170. end;
  171. tonnodeclass = class of tonnode;
  172. var
  173. cwhilerepeatnode : twhilerepeatnodeclass;
  174. cifnode : tifnodeclass;
  175. cfornode : tfornodeclass;
  176. cexitnode : texitnodeclass;
  177. cbreaknode : tbreaknodeclass;
  178. ccontinuenode : tcontinuenodeclass;
  179. cgotonode : tgotonodeclass;
  180. clabelnode : tlabelnodeclass;
  181. craisenode : traisenodeclass;
  182. ctryexceptnode : ttryexceptnodeclass;
  183. ctryfinallynode : ttryfinallynodeclass;
  184. connode : tonnodeclass;
  185. implementation
  186. uses
  187. globtype,systems,
  188. cutils,verbose,globals,
  189. symconst,paramgr,defcmp,defutil,htypechk,pass_1,
  190. ncal,nadd,ncon,nmem,nld,ncnv,nbas,cgobj,nutils,
  191. {$ifdef prefetchnext}
  192. ninl,
  193. {$endif prefetchnext}
  194. {$ifdef state_tracking}
  195. nstate,
  196. {$endif}
  197. cgbase,procinfo
  198. ;
  199. {****************************************************************************
  200. TLOOPNODE
  201. *****************************************************************************}
  202. constructor tloopnode.create(tt : tnodetype;l,r,_t1,_t2 : tnode);
  203. begin
  204. inherited create(tt,l,r);
  205. t1:=_t1;
  206. t2:=_t2;
  207. fileinfo:=l.fileinfo;
  208. end;
  209. destructor tloopnode.destroy;
  210. begin
  211. t1.free;
  212. t2.free;
  213. inherited destroy;
  214. end;
  215. constructor tloopnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  216. begin
  217. inherited ppuload(t,ppufile);
  218. t1:=ppuloadnode(ppufile);
  219. t2:=ppuloadnode(ppufile);
  220. end;
  221. procedure tloopnode.ppuwrite(ppufile:tcompilerppufile);
  222. begin
  223. inherited ppuwrite(ppufile);
  224. ppuwritenode(ppufile,t1);
  225. ppuwritenode(ppufile,t2);
  226. end;
  227. procedure tloopnode.buildderefimpl;
  228. begin
  229. inherited buildderefimpl;
  230. if assigned(t1) then
  231. t1.buildderefimpl;
  232. if assigned(t2) then
  233. t2.buildderefimpl;
  234. end;
  235. procedure tloopnode.derefimpl;
  236. begin
  237. inherited derefimpl;
  238. if assigned(t1) then
  239. t1.derefimpl;
  240. if assigned(t2) then
  241. t2.derefimpl;
  242. end;
  243. function tloopnode.dogetcopy : tnode;
  244. var
  245. p : tloopnode;
  246. begin
  247. p:=tloopnode(inherited dogetcopy);
  248. if assigned(t1) then
  249. p.t1:=t1.dogetcopy
  250. else
  251. p.t1:=nil;
  252. if assigned(t2) then
  253. p.t2:=t2.dogetcopy
  254. else
  255. p.t2:=nil;
  256. p.loopflags:=loopflags;
  257. dogetcopy:=p;
  258. end;
  259. procedure tloopnode.insertintolist(l : tnodelist);
  260. begin
  261. end;
  262. procedure tloopnode.printnodetree(var t:text);
  263. begin
  264. write(t,printnodeindention,'(');
  265. printnodeindent;
  266. printnodeinfo(t);
  267. writeln(t);
  268. printnode(t,left);
  269. printnode(t,right);
  270. printnode(t,t1);
  271. printnode(t,t2);
  272. printnodeunindent;
  273. writeln(t,printnodeindention,')');
  274. end;
  275. function tloopnode.docompare(p: tnode): boolean;
  276. begin
  277. docompare :=
  278. inherited docompare(p) and
  279. (loopflags*loopflagsequal=tloopnode(p).loopflags*loopflagsequal) and
  280. t1.isequal(tloopnode(p).t1) and
  281. t2.isequal(tloopnode(p).t2);
  282. end;
  283. {****************************************************************************
  284. TWHILEREPEATNODE
  285. *****************************************************************************}
  286. constructor Twhilerepeatnode.create(l,r:Tnode;tab,cn:boolean);
  287. begin
  288. inherited create(whilerepeatn,l,r,nil,nil);
  289. if tab then
  290. include(loopflags, lnf_testatbegin);
  291. if cn then
  292. include(loopflags,lnf_checknegate);
  293. end;
  294. function twhilerepeatnode.pass_typecheck:tnode;
  295. var
  296. t:Tunarynode;
  297. begin
  298. result:=nil;
  299. resultdef:=voidtype;
  300. typecheckpass(left);
  301. { tp procvar support }
  302. maybe_call_procvar(left,true);
  303. {A not node can be removed.}
  304. if left.nodetype=notn then
  305. begin
  306. t:=Tunarynode(left);
  307. left:=Tunarynode(left).left;
  308. t.left:=nil;
  309. t.destroy;
  310. {Symdif operator, in case you are wondering:}
  311. loopflags:=loopflags >< [lnf_checknegate];
  312. end;
  313. { loop instruction }
  314. if assigned(right) then
  315. typecheckpass(right);
  316. set_varstate(left,vs_read,[vsf_must_be_valid]);
  317. if codegenerror then
  318. exit;
  319. if not is_boolean(left.resultdef) then
  320. begin
  321. if left.resultdef.typ=variantdef then
  322. inserttypeconv(left,booltype)
  323. else
  324. CGMessage1(type_e_boolean_expr_expected,left.resultdef.typename);
  325. end;
  326. { Give warnings for code that will never be executed for
  327. while false do }
  328. if (lnf_testatbegin in loopflags) and
  329. (left.nodetype=ordconstn) and
  330. (tordconstnode(left).value=0) and
  331. assigned(right) then
  332. CGMessagePos(right.fileinfo,cg_w_unreachable_code);
  333. end;
  334. {$ifdef prefetchnext}
  335. type
  336. passignmentquery = ^tassignmentquery;
  337. tassignmentquery = record
  338. towhat: tnode;
  339. source: tassignmentnode;
  340. statementcount: cardinal;
  341. end;
  342. function checkassignment(var n: tnode; arg: pointer): foreachnoderesult;
  343. var
  344. query: passignmentquery absolute arg;
  345. temp, prederef: tnode;
  346. begin
  347. result := fen_norecurse_false;
  348. if (n.nodetype in [assignn,inlinen,forn,calln,whilerepeatn,casen,ifn]) then
  349. inc(query^.statementcount);
  350. { make sure there's something else in the loop besides going to the }
  351. { next item }
  352. if (query^.statementcount > 1) and
  353. (n.nodetype = assignn) then
  354. begin
  355. { skip type conversions of assignment target }
  356. temp := tassignmentnode(n).left;
  357. while (temp.nodetype = typeconvn) do
  358. temp := ttypeconvnode(temp).left;
  359. { assignment to x of the while assigned(x) check? }
  360. if not(temp.isequal(query^.towhat)) then
  361. exit;
  362. { right hand side of assignment dereferenced field of }
  363. { x? (no derefn in case of class) }
  364. temp := tassignmentnode(n).right;
  365. while (temp.nodetype = typeconvn) do
  366. temp := ttypeconvnode(temp).left;
  367. if (temp.nodetype <> subscriptn) then
  368. exit;
  369. prederef := tsubscriptnode(temp).left;
  370. temp := prederef;
  371. while (temp.nodetype = typeconvn) do
  372. temp := ttypeconvnode(temp).left;
  373. { see tests/test/prefetch1.pp }
  374. if (temp.nodetype = derefn) then
  375. temp := tderefnode(temp).left
  376. else
  377. temp := prederef;
  378. if temp.isequal(query^.towhat) then
  379. begin
  380. query^.source := tassignmentnode(n);
  381. result := fen_norecurse_true;
  382. end
  383. end
  384. { don't check nodes which can't contain an assignment or whose }
  385. { final assignment can vary a lot }
  386. else if not(n.nodetype in [calln,inlinen,casen,whilerepeatn,forn]) then
  387. result := fen_false;
  388. end;
  389. function findassignment(where: tnode; towhat: tnode): tassignmentnode;
  390. var
  391. query: tassignmentquery;
  392. begin
  393. query.towhat := towhat;
  394. query.source := nil;
  395. query.statementcount := 0;
  396. if foreachnodestatic(where,@checkassignment,@query) then
  397. result := query.source
  398. else
  399. result := nil;
  400. end;
  401. {$endif prefetchnext}
  402. function twhilerepeatnode.pass_1 : tnode;
  403. var
  404. {$ifdef prefetchnext}
  405. runnernode, prefetchcode: tnode;
  406. assignmentnode: tassignmentnode;
  407. prefetchstatements: tstatementnode;
  408. {$endif prefetchnext}
  409. old_t_times : longint;
  410. begin
  411. result:=nil;
  412. expectloc:=LOC_VOID;
  413. old_t_times:=cg.t_times;
  414. { calc register weight }
  415. if not(cs_opt_size in current_settings.optimizerswitches) then
  416. cg.t_times:=cg.t_times*8;
  417. firstpass(left);
  418. if codegenerror then
  419. exit;
  420. registersint:=left.registersint;
  421. registersfpu:=left.registersfpu;
  422. {$ifdef SUPPORT_MMX}
  423. registersmmx:=left.registersmmx;
  424. {$endif SUPPORT_MMX}
  425. { loop instruction }
  426. if assigned(right) then
  427. begin
  428. firstpass(right);
  429. if codegenerror then
  430. exit;
  431. if registersint<right.registersint then
  432. registersint:=right.registersint;
  433. if registersfpu<right.registersfpu then
  434. registersfpu:=right.registersfpu;
  435. {$ifdef SUPPORT_MMX}
  436. if registersmmx<right.registersmmx then
  437. registersmmx:=right.registersmmx;
  438. {$endif SUPPORT_MMX}
  439. end;
  440. cg.t_times:=old_t_times;
  441. {$ifdef prefetchnext}
  442. { do at the end so all complex typeconversions are already }
  443. { converted to calln's }
  444. if (cs_opt_level1 in current_settings.optimizerswitches) and
  445. (lnf_testatbegin in loopflags) then
  446. begin
  447. { get first component of the while check }
  448. runnernode := left;
  449. while (runnernode.nodetype in [andn,orn,notn,xorn,typeconvn]) do
  450. runnernode := tunarynode(runnernode).left;
  451. { is it an assigned(x) check? }
  452. if ((runnernode.nodetype = inlinen) and
  453. (tinlinenode(runnernode).inlinenumber = in_assigned_x)) or
  454. ((runnernode.nodetype = unequaln) and
  455. (taddnode(runnernode).right.nodetype = niln)) then
  456. begin
  457. runnernode := tunarynode(runnernode).left;
  458. { in case of in_assigned_x, there's a callparan in between }
  459. if (runnernode.nodetype = callparan) then
  460. runnernode := tcallparanode(runnernode).left;
  461. while (runnernode.nodetype = typeconvn) do
  462. runnernode := ttypeconvnode(runnernode).left;
  463. { is there an "x := x(^).somefield"? }
  464. assignmentnode := findassignment(right,runnernode);
  465. if assigned(assignmentnode) then
  466. begin
  467. prefetchcode := internalstatements(prefetchstatements);
  468. addstatement(prefetchstatements,geninlinenode(in_prefetch_var,false,
  469. cderefnode.create(ctypeconvnode.create(assignmentnode.right.getcopy,voidpointertype))));
  470. addstatement(prefetchstatements,right);
  471. right := prefetchcode;
  472. typecheckpass(right);
  473. end;
  474. end;
  475. end;
  476. {$endif prefetchnext}
  477. end;
  478. {$ifdef state_tracking}
  479. function Twhilerepeatnode.track_state_pass(exec_known:boolean):boolean;
  480. var condition:Tnode;
  481. code:Tnode;
  482. done:boolean;
  483. value:boolean;
  484. change:boolean;
  485. firsttest:boolean;
  486. factval:Tnode;
  487. begin
  488. track_state_pass:=false;
  489. done:=false;
  490. firsttest:=true;
  491. {For repeat until statements, first do a pass through the code.}
  492. if not(lnf_testatbegin in flags) then
  493. begin
  494. code:=right.getcopy;
  495. if code.track_state_pass(exec_known) then
  496. track_state_pass:=true;
  497. code.destroy;
  498. end;
  499. repeat
  500. condition:=left.getcopy;
  501. code:=right.getcopy;
  502. change:=condition.track_state_pass(exec_known);
  503. factval:=aktstate.find_fact(left);
  504. if factval<>nil then
  505. begin
  506. condition.destroy;
  507. condition:=factval.getcopy;
  508. change:=true;
  509. end;
  510. if change then
  511. begin
  512. track_state_pass:=true;
  513. {Force new resultdef pass.}
  514. condition.resultdef:=nil;
  515. do_typecheckpass(condition);
  516. end;
  517. if is_constboolnode(condition) then
  518. begin
  519. {Try to turn a while loop into a repeat loop.}
  520. if firsttest then
  521. exclude(flags,testatbegin);
  522. value:=(Tordconstnode(condition).value<>0) xor checknegate;
  523. if value then
  524. begin
  525. if code.track_state_pass(exec_known) then
  526. track_state_pass:=true;
  527. end
  528. else
  529. done:=true;
  530. end
  531. else
  532. begin
  533. {Remove any modified variables from the state.}
  534. code.track_state_pass(false);
  535. done:=true;
  536. end;
  537. code.destroy;
  538. condition.destroy;
  539. firsttest:=false;
  540. until done;
  541. {The loop condition is also known, for example:
  542. while i<10 do
  543. begin
  544. ...
  545. end;
  546. When the loop is done, we do know that i<10 = false.
  547. }
  548. condition:=left.getcopy;
  549. if condition.track_state_pass(exec_known) then
  550. begin
  551. track_state_pass:=true;
  552. {Force new resultdef pass.}
  553. condition.resultdef:=nil;
  554. do_typecheckpass(condition);
  555. end;
  556. if not is_constboolnode(condition) then
  557. aktstate.store_fact(condition,
  558. cordconstnode.create(byte(checknegate),booltype,true))
  559. else
  560. condition.destroy;
  561. end;
  562. {$endif}
  563. {*****************************************************************************
  564. TIFNODE
  565. *****************************************************************************}
  566. constructor tifnode.create(l,r,_t1 : tnode);
  567. begin
  568. inherited create(ifn,l,r,_t1,nil);
  569. end;
  570. function tifnode.pass_typecheck:tnode;
  571. begin
  572. result:=nil;
  573. resultdef:=voidtype;
  574. typecheckpass(left);
  575. { tp procvar support }
  576. maybe_call_procvar(left,true);
  577. { if path }
  578. if assigned(right) then
  579. typecheckpass(right);
  580. { else path }
  581. if assigned(t1) then
  582. typecheckpass(t1);
  583. set_varstate(left,vs_read,[vsf_must_be_valid]);
  584. if codegenerror then
  585. exit;
  586. if not is_boolean(left.resultdef) then
  587. begin
  588. if left.resultdef.typ=variantdef then
  589. inserttypeconv(left,booltype)
  590. else
  591. Message1(type_e_boolean_expr_expected,left.resultdef.typename);
  592. end;
  593. { optimize constant expressions }
  594. if left.nodetype=ordconstn then
  595. begin
  596. if tordconstnode(left).value=1 then
  597. begin
  598. if assigned(right) then
  599. result:=right
  600. else
  601. result:=cnothingnode.create;
  602. right:=nil;
  603. if assigned(t1) then
  604. CGMessagePos(t1.fileinfo,cg_w_unreachable_code);
  605. end
  606. else
  607. begin
  608. if assigned(t1) then
  609. result:=t1
  610. else
  611. result:=cnothingnode.create;
  612. t1:=nil;
  613. if assigned(right) then
  614. CGMessagePos(right.fileinfo,cg_w_unreachable_code);
  615. end;
  616. end;
  617. end;
  618. function tifnode.pass_1 : tnode;
  619. var
  620. old_t_times : longint;
  621. begin
  622. result:=nil;
  623. expectloc:=LOC_VOID;
  624. old_t_times:=cg.t_times;
  625. firstpass(left);
  626. registersint:=left.registersint;
  627. registersfpu:=left.registersfpu;
  628. {$ifdef SUPPORT_MMX}
  629. registersmmx:=left.registersmmx;
  630. {$endif SUPPORT_MMX}
  631. { determines registers weigths }
  632. if not(cs_opt_size in current_settings.optimizerswitches) then
  633. cg.t_times:=cg.t_times div 2;
  634. if cg.t_times=0 then
  635. cg.t_times:=1;
  636. { if path }
  637. if assigned(right) then
  638. begin
  639. firstpass(right);
  640. if registersint<right.registersint then
  641. registersint:=right.registersint;
  642. if registersfpu<right.registersfpu then
  643. registersfpu:=right.registersfpu;
  644. {$ifdef SUPPORT_MMX}
  645. if registersmmx<right.registersmmx then
  646. registersmmx:=right.registersmmx;
  647. {$endif SUPPORT_MMX}
  648. end;
  649. { else path }
  650. if assigned(t1) then
  651. begin
  652. firstpass(t1);
  653. if registersint<t1.registersint then
  654. registersint:=t1.registersint;
  655. if registersfpu<t1.registersfpu then
  656. registersfpu:=t1.registersfpu;
  657. {$ifdef SUPPORT_MMX}
  658. if registersmmx<t1.registersmmx then
  659. registersmmx:=t1.registersmmx;
  660. {$endif SUPPORT_MMX}
  661. end;
  662. { leave if we've got an error in one of the paths }
  663. if codegenerror then
  664. exit;
  665. cg.t_times:=old_t_times;
  666. end;
  667. {*****************************************************************************
  668. TFORNODE
  669. *****************************************************************************}
  670. constructor tfornode.create(l,r,_t1,_t2 : tnode;back : boolean);
  671. begin
  672. inherited create(forn,l,r,_t1,_t2);
  673. if back then
  674. include(loopflags,lnf_backward);
  675. include(loopflags,lnf_testatbegin);
  676. end;
  677. procedure Tfornode.loop_var_access(not_type:Tnotification_flag;
  678. symbol:Tsym);
  679. begin
  680. {If there is a read access, the value of the loop counter is important;
  681. at the end of the loop the loop variable should contain the value it
  682. had in the last iteration.}
  683. if not_type=vn_onwrite then
  684. begin
  685. writeln('Loopvar does not matter on exit');
  686. end
  687. else
  688. begin
  689. exclude(loopflags,lnf_dont_mind_loopvar_on_exit);
  690. writeln('Loopvar does matter on exit');
  691. end;
  692. Tabstractvarsym(symbol).unregister_notification(loopvar_notid);
  693. end;
  694. function tfornode.pass_typecheck:tnode;
  695. var
  696. unrollres : tnode;
  697. begin
  698. result:=nil;
  699. resultdef:=voidtype;
  700. { loop unrolling }
  701. if cs_opt_loopunroll in current_settings.optimizerswitches then
  702. begin
  703. unrollres:=unroll_loop(self);
  704. if assigned(unrollres) then
  705. begin
  706. typecheckpass(unrollres);
  707. result:=unrollres;
  708. exit;
  709. end;
  710. end;
  711. { process the loopvar, from and to, varstates are already set }
  712. typecheckpass(left);
  713. typecheckpass(right);
  714. typecheckpass(t1);
  715. {Can we spare the first comparision?}
  716. if (t1.nodetype=ordconstn) and
  717. (right.nodetype=ordconstn) and
  718. (
  719. (
  720. (lnf_backward in loopflags) and
  721. (Tordconstnode(right).value>=Tordconstnode(t1).value)
  722. ) or
  723. (
  724. not(lnf_backward in loopflags) and
  725. (Tordconstnode(right).value<=Tordconstnode(t1).value)
  726. )
  727. ) then
  728. exclude(loopflags,lnf_testatbegin);
  729. { Make sure that the loop var and the
  730. from and to values are compatible types }
  731. check_ranges(right.fileinfo,right,left.resultdef);
  732. inserttypeconv(right,left.resultdef);
  733. check_ranges(t1.fileinfo,t1,left.resultdef);
  734. inserttypeconv(t1,left.resultdef);
  735. if assigned(t2) then
  736. typecheckpass(t2);
  737. end;
  738. function tfornode.pass_1 : tnode;
  739. var
  740. old_t_times : longint;
  741. begin
  742. result:=nil;
  743. expectloc:=LOC_VOID;
  744. firstpass(left);
  745. if left.registersint>registersint then
  746. registersint:=left.registersint;
  747. if left.registersfpu>registersfpu then
  748. registersfpu:=left.registersfpu;
  749. {$ifdef SUPPORT_MMX}
  750. if left.registersmmx>registersmmx then
  751. registersmmx:=left.registersmmx;
  752. {$endif SUPPORT_MMX}
  753. firstpass(right);
  754. if right.registersint>registersint then
  755. registersint:=right.registersint;
  756. if right.registersfpu>registersfpu then
  757. registersfpu:=right.registersfpu;
  758. {$ifdef SUPPORT_MMX}
  759. if right.registersmmx>registersmmx then
  760. registersmmx:=right.registersmmx;
  761. {$endif SUPPORT_MMX}
  762. firstpass(t1);
  763. if t1.registersint>registersint then
  764. registersint:=t1.registersint;
  765. if t1.registersfpu>registersfpu then
  766. registersfpu:=t1.registersfpu;
  767. {$ifdef SUPPORT_MMX}
  768. if t1.registersmmx>registersmmx then
  769. registersmmx:=t1.registersmmx;
  770. {$endif SUPPORT_MMX}
  771. if assigned(t2) then
  772. begin
  773. { Calc register weight }
  774. old_t_times:=cg.t_times;
  775. if not(cs_opt_size in current_settings.optimizerswitches) then
  776. cg.t_times:=cg.t_times*8;
  777. firstpass(t2);
  778. if codegenerror then
  779. exit;
  780. if t2.registersint>registersint then
  781. registersint:=t2.registersint;
  782. if t2.registersfpu>registersfpu then
  783. registersfpu:=t2.registersfpu;
  784. {$ifdef SUPPORT_MMX}
  785. if t2.registersmmx>registersmmx then
  786. registersmmx:=t2.registersmmx;
  787. {$endif SUPPORT_MMX}
  788. cg.t_times:=old_t_times;
  789. end;
  790. { we need at least one register for comparisons PM }
  791. if registersint=0 then
  792. inc(registersint);
  793. end;
  794. {*****************************************************************************
  795. TEXITNODE
  796. *****************************************************************************}
  797. constructor texitnode.create(l:tnode);
  798. begin
  799. inherited create(exitn,l);
  800. end;
  801. constructor texitnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  802. begin
  803. inherited ppuload(t,ppufile);
  804. end;
  805. procedure texitnode.ppuwrite(ppufile:tcompilerppufile);
  806. begin
  807. inherited ppuwrite(ppufile);
  808. end;
  809. function texitnode.pass_typecheck:tnode;
  810. begin
  811. result:=nil;
  812. if assigned(left) then
  813. begin
  814. { add assignment to funcretsym }
  815. inserttypeconv(left,current_procinfo.procdef.returndef);
  816. left:=cassignmentnode.create(
  817. cloadnode.create(current_procinfo.procdef.funcretsym,current_procinfo.procdef.funcretsym.owner),
  818. left);
  819. typecheckpass(left);
  820. set_varstate(left,vs_read,[vsf_must_be_valid]);
  821. end;
  822. resultdef:=voidtype;
  823. end;
  824. function texitnode.pass_1 : tnode;
  825. begin
  826. result:=nil;
  827. expectloc:=LOC_VOID;
  828. if assigned(left) then
  829. begin
  830. firstpass(left);
  831. if codegenerror then
  832. exit;
  833. registersint:=left.registersint;
  834. registersfpu:=left.registersfpu;
  835. {$ifdef SUPPORT_MMX}
  836. registersmmx:=left.registersmmx;
  837. {$endif SUPPORT_MMX}
  838. end;
  839. end;
  840. {*****************************************************************************
  841. TBREAKNODE
  842. *****************************************************************************}
  843. constructor tbreaknode.create;
  844. begin
  845. inherited create(breakn);
  846. end;
  847. function tbreaknode.pass_typecheck:tnode;
  848. begin
  849. result:=nil;
  850. resultdef:=voidtype;
  851. end;
  852. function tbreaknode.pass_1 : tnode;
  853. begin
  854. result:=nil;
  855. expectloc:=LOC_VOID;
  856. end;
  857. {*****************************************************************************
  858. TCONTINUENODE
  859. *****************************************************************************}
  860. constructor tcontinuenode.create;
  861. begin
  862. inherited create(continuen);
  863. end;
  864. function tcontinuenode.pass_typecheck:tnode;
  865. begin
  866. result:=nil;
  867. resultdef:=voidtype;
  868. end;
  869. function tcontinuenode.pass_1 : tnode;
  870. begin
  871. result:=nil;
  872. expectloc:=LOC_VOID;
  873. end;
  874. {*****************************************************************************
  875. TGOTONODE
  876. *****************************************************************************}
  877. constructor tgotonode.create(p : tlabelsym);
  878. begin
  879. inherited create(goton);
  880. exceptionblock:=aktexceptblock;
  881. labelnode:=nil;
  882. labelsym:=p;
  883. end;
  884. constructor tgotonode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  885. begin
  886. inherited ppuload(t,ppufile);
  887. labelnode:=tlabelnode(ppuloadnoderef(ppufile));
  888. exceptionblock:=ppufile.getbyte;
  889. end;
  890. procedure tgotonode.ppuwrite(ppufile:tcompilerppufile);
  891. begin
  892. inherited ppuwrite(ppufile);
  893. ppuwritenoderef(ppufile,labelnode);
  894. ppufile.putbyte(exceptionblock);
  895. end;
  896. procedure tgotonode.buildderefimpl;
  897. begin
  898. inherited buildderefimpl;
  899. //!!! deref(labelnode);
  900. end;
  901. procedure tgotonode.derefimpl;
  902. begin
  903. inherited derefimpl;
  904. //!!! deref(labelnode);
  905. end;
  906. function tgotonode.pass_typecheck:tnode;
  907. begin
  908. result:=nil;
  909. resultdef:=voidtype;
  910. end;
  911. function tgotonode.pass_1 : tnode;
  912. begin
  913. result:=nil;
  914. expectloc:=LOC_VOID;
  915. include(current_procinfo.flags,pi_has_goto);
  916. { The labelnode can already be set when
  917. this node was copied }
  918. if not assigned(labelnode) then
  919. begin
  920. if assigned(labelsym.code) then
  921. labelnode:=tlabelnode(labelsym.code)
  922. else
  923. CGMessage1(cg_e_goto_label_not_found,labelsym.realname);
  924. end;
  925. { check if we don't mess with exception blocks }
  926. if assigned(labelnode) and
  927. (exceptionblock<>labelnode.exceptionblock) then
  928. CGMessage(cg_e_goto_inout_of_exception_block);
  929. end;
  930. function tgotonode.dogetcopy : tnode;
  931. var
  932. p : tgotonode;
  933. begin
  934. p:=tgotonode(inherited dogetcopy);
  935. p.exceptionblock:=exceptionblock;
  936. { force a valid labelnode }
  937. if not(assigned(labelnode)) then
  938. begin
  939. if assigned(labelsym) and assigned(labelsym.code) then
  940. labelnode:=tlabelnode(labelsym.code)
  941. else
  942. internalerror(200610291);
  943. end;
  944. p.labelsym:=labelsym;
  945. p.labelnode:=tlabelnode(labelnode.dogetcopy);
  946. result:=p;
  947. end;
  948. function tgotonode.docompare(p: tnode): boolean;
  949. begin
  950. docompare := false;
  951. end;
  952. {*****************************************************************************
  953. TLABELNODE
  954. *****************************************************************************}
  955. constructor tlabelnode.create(l:tnode;alabsym:tlabelsym);
  956. begin
  957. inherited create(labeln,l);
  958. exceptionblock:=aktexceptblock;
  959. labsym:=alabsym;
  960. { Register labelnode in labelsym }
  961. labsym.code:=self;
  962. end;
  963. constructor tlabelnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  964. begin
  965. inherited ppuload(t,ppufile);
  966. exceptionblock:=ppufile.getbyte;
  967. end;
  968. destructor tlabelnode.destroy;
  969. begin
  970. { Remove reference in labelsym, this is to prevent
  971. goto's to this label }
  972. if assigned(labsym) and (labsym.code=pointer(self)) then
  973. labsym.code:=nil;
  974. inherited destroy;
  975. end;
  976. procedure tlabelnode.ppuwrite(ppufile:tcompilerppufile);
  977. begin
  978. inherited ppuwrite(ppufile);
  979. ppufile.putbyte(exceptionblock);
  980. end;
  981. procedure tlabelnode.buildderefimpl;
  982. begin
  983. inherited buildderefimpl;
  984. end;
  985. procedure tlabelnode.derefimpl;
  986. begin
  987. inherited derefimpl;
  988. end;
  989. function tlabelnode.pass_typecheck:tnode;
  990. begin
  991. result:=nil;
  992. { left could still be unassigned }
  993. if assigned(left) then
  994. typecheckpass(left);
  995. resultdef:=voidtype;
  996. end;
  997. function tlabelnode.pass_1 : tnode;
  998. begin
  999. result:=nil;
  1000. expectloc:=LOC_VOID;
  1001. if assigned(left) then
  1002. begin
  1003. firstpass(left);
  1004. registersint:=left.registersint;
  1005. registersfpu:=left.registersfpu;
  1006. {$ifdef SUPPORT_MMX}
  1007. registersmmx:=left.registersmmx;
  1008. {$endif SUPPORT_MMX}
  1009. end;
  1010. end;
  1011. function tlabelnode.dogetcopy : tnode;
  1012. begin
  1013. if not(assigned(copiedto)) then
  1014. copiedto:=tlabelnode(inherited dogetcopy);
  1015. copiedto.exceptionblock:=exceptionblock;
  1016. result:=copiedto;
  1017. end;
  1018. function tlabelnode.docompare(p: tnode): boolean;
  1019. begin
  1020. docompare := false;
  1021. end;
  1022. {*****************************************************************************
  1023. TRAISENODE
  1024. *****************************************************************************}
  1025. constructor traisenode.create(l,taddr,tframe:tnode);
  1026. begin
  1027. inherited create(raisen,l,taddr,tframe);
  1028. end;
  1029. function traisenode.pass_typecheck:tnode;
  1030. begin
  1031. result:=nil;
  1032. resultdef:=voidtype;
  1033. if assigned(left) then
  1034. begin
  1035. { first para must be a _class_ }
  1036. typecheckpass(left);
  1037. set_varstate(left,vs_read,[vsf_must_be_valid]);
  1038. if codegenerror then
  1039. exit;
  1040. if not(is_class(left.resultdef)) then
  1041. CGMessage1(type_e_class_type_expected,left.resultdef.typename);
  1042. { insert needed typeconvs for addr,frame }
  1043. if assigned(right) then
  1044. begin
  1045. { addr }
  1046. typecheckpass(right);
  1047. inserttypeconv(right,voidpointertype);
  1048. { frame }
  1049. if assigned(frametree) then
  1050. begin
  1051. typecheckpass(frametree);
  1052. inserttypeconv(frametree,voidpointertype);
  1053. end;
  1054. end;
  1055. end;
  1056. end;
  1057. function traisenode.pass_1 : tnode;
  1058. begin
  1059. result:=nil;
  1060. include(current_procinfo.flags,pi_do_call);
  1061. expectloc:=LOC_VOID;
  1062. if assigned(left) then
  1063. begin
  1064. { first para must be a _class_ }
  1065. firstpass(left);
  1066. { insert needed typeconvs for addr,frame }
  1067. if assigned(right) then
  1068. begin
  1069. { addr }
  1070. firstpass(right);
  1071. { frame }
  1072. if assigned(frametree) then
  1073. firstpass(frametree);
  1074. end;
  1075. left_right_max;
  1076. end;
  1077. end;
  1078. {*****************************************************************************
  1079. TTRYEXCEPTNODE
  1080. *****************************************************************************}
  1081. constructor ttryexceptnode.create(l,r,_t1 : tnode);
  1082. begin
  1083. inherited create(tryexceptn,l,r,_t1,nil);
  1084. end;
  1085. function ttryexceptnode.pass_typecheck:tnode;
  1086. begin
  1087. result:=nil;
  1088. typecheckpass(left);
  1089. { on statements }
  1090. if assigned(right) then
  1091. typecheckpass(right);
  1092. { else block }
  1093. if assigned(t1) then
  1094. typecheckpass(t1);
  1095. resultdef:=voidtype;
  1096. end;
  1097. function ttryexceptnode.pass_1 : tnode;
  1098. begin
  1099. result:=nil;
  1100. include(current_procinfo.flags,pi_do_call);
  1101. expectloc:=LOC_VOID;
  1102. firstpass(left);
  1103. { on statements }
  1104. if assigned(right) then
  1105. begin
  1106. firstpass(right);
  1107. registersint:=max(registersint,right.registersint);
  1108. registersfpu:=max(registersfpu,right.registersfpu);
  1109. {$ifdef SUPPORT_MMX}
  1110. registersmmx:=max(registersmmx,right.registersmmx);
  1111. {$endif SUPPORT_MMX}
  1112. end;
  1113. { else block }
  1114. if assigned(t1) then
  1115. begin
  1116. firstpass(t1);
  1117. registersint:=max(registersint,t1.registersint);
  1118. registersfpu:=max(registersfpu,t1.registersfpu);
  1119. {$ifdef SUPPORT_MMX}
  1120. registersmmx:=max(registersmmx,t1.registersmmx);
  1121. {$endif SUPPORT_MMX}
  1122. end;
  1123. end;
  1124. {*****************************************************************************
  1125. TTRYFINALLYNODE
  1126. *****************************************************************************}
  1127. constructor ttryfinallynode.create(l,r:tnode);
  1128. begin
  1129. inherited create(tryfinallyn,l,r,nil,nil);
  1130. implicitframe:=false;
  1131. end;
  1132. constructor ttryfinallynode.create_implicit(l,r,_t1:tnode);
  1133. begin
  1134. inherited create(tryfinallyn,l,r,_t1,nil);
  1135. implicitframe:=true;
  1136. end;
  1137. function ttryfinallynode.pass_typecheck:tnode;
  1138. begin
  1139. result:=nil;
  1140. include(current_procinfo.flags,pi_do_call);
  1141. resultdef:=voidtype;
  1142. typecheckpass(left);
  1143. // "try block" is "used"? (JM)
  1144. set_varstate(left,vs_readwritten,[vsf_must_be_valid]);
  1145. typecheckpass(right);
  1146. // "except block" is "used"? (JM)
  1147. set_varstate(right,vs_readwritten,[vsf_must_be_valid]);
  1148. { special finally block only executed when there was an exception }
  1149. if assigned(t1) then
  1150. begin
  1151. typecheckpass(t1);
  1152. // "finally block" is "used"? (JM)
  1153. set_varstate(t1,vs_readwritten,[vsf_must_be_valid]);
  1154. end;
  1155. end;
  1156. function ttryfinallynode.pass_1 : tnode;
  1157. begin
  1158. result:=nil;
  1159. expectloc:=LOC_VOID;
  1160. firstpass(left);
  1161. firstpass(right);
  1162. left_right_max;
  1163. if assigned(t1) then
  1164. begin
  1165. firstpass(t1);
  1166. registersint:=max(registersint,t1.registersint);
  1167. registersfpu:=max(registersfpu,t1.registersfpu);
  1168. {$ifdef SUPPORT_MMX}
  1169. registersmmx:=max(registersmmx,t1.registersmmx);
  1170. {$endif SUPPORT_MMX}
  1171. end;
  1172. end;
  1173. {*****************************************************************************
  1174. TONNODE
  1175. *****************************************************************************}
  1176. constructor tonnode.create(l,r:tnode);
  1177. begin
  1178. inherited create(onn,l,r);
  1179. excepTSymtable:=nil;
  1180. excepttype:=nil;
  1181. end;
  1182. destructor tonnode.destroy;
  1183. begin
  1184. { copied nodes don't need to release the symtable }
  1185. if assigned(excepTSymtable) then
  1186. excepTSymtable.free;
  1187. inherited destroy;
  1188. end;
  1189. constructor tonnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1190. begin
  1191. inherited ppuload(t,ppufile);
  1192. excepTSymtable:=nil;
  1193. excepttype:=nil;
  1194. end;
  1195. function tonnode.dogetcopy : tnode;
  1196. var
  1197. n : tonnode;
  1198. begin
  1199. n:=tonnode(inherited dogetcopy);
  1200. if assigned(exceptsymtable) then
  1201. n.exceptsymtable:=exceptsymtable.getcopy
  1202. else
  1203. n.exceptsymtable:=nil;
  1204. n.excepttype:=excepttype;
  1205. result:=n;
  1206. end;
  1207. function tonnode.pass_typecheck:tnode;
  1208. begin
  1209. result:=nil;
  1210. resultdef:=voidtype;
  1211. if not(is_class(excepttype)) then
  1212. CGMessage1(type_e_class_type_expected,excepttype.typename);
  1213. if assigned(left) then
  1214. typecheckpass(left);
  1215. if assigned(right) then
  1216. typecheckpass(right);
  1217. end;
  1218. function tonnode.pass_1 : tnode;
  1219. begin
  1220. result:=nil;
  1221. include(current_procinfo.flags,pi_do_call);
  1222. expectloc:=LOC_VOID;
  1223. registersint:=0;
  1224. registersfpu:=0;
  1225. {$ifdef SUPPORT_MMX}
  1226. registersmmx:=0;
  1227. {$endif SUPPORT_MMX}
  1228. if assigned(left) then
  1229. begin
  1230. firstpass(left);
  1231. registersint:=left.registersint;
  1232. registersfpu:=left.registersfpu;
  1233. {$ifdef SUPPORT_MMX}
  1234. registersmmx:=left.registersmmx;
  1235. {$endif SUPPORT_MMX}
  1236. end;
  1237. if assigned(right) then
  1238. begin
  1239. firstpass(right);
  1240. registersint:=max(registersint,right.registersint);
  1241. registersfpu:=max(registersfpu,right.registersfpu);
  1242. {$ifdef SUPPORT_MMX}
  1243. registersmmx:=max(registersmmx,right.registersmmx);
  1244. {$endif SUPPORT_MMX}
  1245. end;
  1246. end;
  1247. function tonnode.docompare(p: tnode): boolean;
  1248. begin
  1249. docompare := false;
  1250. end;
  1251. begin
  1252. cwhilerepeatnode:=twhilerepeatnode;
  1253. cifnode:=tifnode;
  1254. cfornode:=tfornode;
  1255. cexitnode:=texitnode;
  1256. cgotonode:=tgotonode;
  1257. clabelnode:=tlabelnode;
  1258. craisenode:=traisenode;
  1259. ctryexceptnode:=ttryexceptnode;
  1260. ctryfinallynode:=ttryfinallynode;
  1261. connode:=tonnode;
  1262. end.