node.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. {
  2. $Id$
  3. Copyright (c) 2000 by Florian Klaempfl
  4. Basic node handling
  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 node;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. cclasses,
  23. globtype,globals,
  24. cpubase,
  25. aasm,
  26. symtype;
  27. type
  28. pconstset = ^tconstset;
  29. tconstset = array[0..31] of byte;
  30. pconst32bitset = ^tconst32bitset;
  31. tconst32bitset = array[0..7] of longint;
  32. tnodetype = (
  33. addn, {Represents the + operator.}
  34. muln, {Represents the * operator.}
  35. subn, {Represents the - operator.}
  36. divn, {Represents the div operator.}
  37. symdifn, {Represents the >< operator.}
  38. modn, {Represents the mod operator.}
  39. assignn, {Represents an assignment.}
  40. loadn, {Represents the use of a variabele.}
  41. rangen, {Represents a range (i.e. 0..9).}
  42. ltn, {Represents the < operator.}
  43. lten, {Represents the <= operator.}
  44. gtn, {Represents the > operator.}
  45. gten, {Represents the >= operator.}
  46. equaln, {Represents the = operator.}
  47. unequaln, {Represents the <> operator.}
  48. inn, {Represents the in operator.}
  49. orn, {Represents the or operator.}
  50. xorn, {Represents the xor operator.}
  51. shrn, {Represents the shr operator.}
  52. shln, {Represents the shl operator.}
  53. slashn, {Represents the / operator.}
  54. andn, {Represents the and operator.}
  55. subscriptn, {??? Field in a record/object?}
  56. derefn, {Dereferences a pointer.}
  57. addrn, {Represents the @ operator.}
  58. doubleaddrn, {Represents the @@ operator.}
  59. ordconstn, {Represents an ordinal value.}
  60. typeconvn, {Represents type-conversion/typecast.}
  61. calln, {Represents a call node.}
  62. callparan, {Represents a parameter.}
  63. realconstn, {Represents a real value.}
  64. unaryminusn, {Represents a sign change (i.e. -2).}
  65. asmn, {Represents an assembler node }
  66. vecn, {Represents array indexing.}
  67. pointerconstn,
  68. stringconstn, {Represents a string constant.}
  69. funcretn, {Represents the function result var.}
  70. selfn, {Represents the self parameter.}
  71. notn, {Represents the not operator.}
  72. inlinen, {Internal procedures (i.e. writeln).}
  73. niln, {Represents the nil pointer.}
  74. errorn, {This part of the tree could not be
  75. parsed because of a compiler error.}
  76. typen, {A type name. Used for i.e. typeof(obj).}
  77. hnewn, {The new operation, constructor call.}
  78. hdisposen, {The dispose operation with destructor call.}
  79. newn, {The new operation, constructor call.}
  80. simpledisposen, {The dispose operation.}
  81. setelementn, {A set element(s) (i.e. [a,b] and also [a..b]).}
  82. setconstn, {A set constant (i.e. [1,2]).}
  83. blockn, {A block of statements.}
  84. statementn, {One statement in a block of nodes.}
  85. loopn, { used in genloopnode, must be converted }
  86. ifn, {An if statement.}
  87. breakn, {A break statement.}
  88. continuen, {A continue statement.}
  89. repeatn, {A repeat until block.}
  90. whilen, {A while do statement.}
  91. forn, {A for loop.}
  92. exitn, {An exit statement.}
  93. withn, {A with statement.}
  94. casen, {A case statement.}
  95. labeln, {A label.}
  96. goton, {A goto statement.}
  97. simplenewn, {The new operation.}
  98. tryexceptn, {A try except block.}
  99. raisen, {A raise statement.}
  100. switchesn, {??? Currently unused...}
  101. tryfinallyn, {A try finally statement.}
  102. onn, { for an on statement in exception code }
  103. isn, {Represents the is operator.}
  104. asn, {Represents the as typecast.}
  105. caretn, {Represents the ^ operator.}
  106. failn, {Represents the fail statement.}
  107. starstarn, {Represents the ** operator exponentiation }
  108. procinlinen, {Procedures that can be inlined }
  109. arrayconstructorn, {Construction node for [...] parsing}
  110. arrayconstructorrangen, {Range element to allow sets in array construction tree}
  111. tempn, { for temps in the result/firstpass }
  112. temprefn, { references to temps }
  113. { added for optimizations where we cannot suppress }
  114. addoptn,
  115. nothingn,
  116. loadvmtn,
  117. guidconstn,
  118. rttin { rtti information so they can be accessed in result/firstpass }
  119. );
  120. const
  121. nodetype2str : array[tnodetype] of string[20] = (
  122. 'addn',
  123. 'muln',
  124. 'subn',
  125. 'divn',
  126. 'symdifn',
  127. 'modn',
  128. 'assignn',
  129. 'loadn',
  130. 'rangen',
  131. 'ltn',
  132. 'lten',
  133. 'gtn',
  134. 'gten',
  135. 'equaln',
  136. 'unequaln',
  137. 'inn',
  138. 'orn',
  139. 'xorn',
  140. 'shrn',
  141. 'shln',
  142. 'slashn',
  143. 'andn',
  144. 'subscriptn',
  145. 'derefn',
  146. 'addrn',
  147. 'doubleaddrn',
  148. 'ordconstn',
  149. 'typeconvn',
  150. 'calln',
  151. 'callparan',
  152. 'realconstn',
  153. 'umminusn',
  154. 'asmn',
  155. 'vecn',
  156. 'pointerconstn',
  157. 'stringconstn',
  158. 'funcretn',
  159. 'selfn',
  160. 'notn',
  161. 'inlinen',
  162. 'niln',
  163. 'errorn',
  164. 'typen',
  165. 'hnewn',
  166. 'hdisposen',
  167. 'newn',
  168. 'simpledisposen',
  169. 'setelementn',
  170. 'setconstn',
  171. 'blockn',
  172. 'statementn',
  173. 'loopn',
  174. 'ifn',
  175. 'breakn',
  176. 'continuen',
  177. 'repeatn',
  178. 'whilen',
  179. 'forn',
  180. 'exitn',
  181. 'withn',
  182. 'casen',
  183. 'labeln',
  184. 'goton',
  185. 'simplenewn',
  186. 'tryexceptn',
  187. 'raisen',
  188. 'switchesn',
  189. 'tryfinallyn',
  190. 'onn',
  191. 'isn',
  192. 'asn',
  193. 'caretn',
  194. 'failn',
  195. 'starstarn',
  196. 'procinlinen',
  197. 'arrayconstructn',
  198. 'arrayconstructrangen',
  199. 'tempn',
  200. 'temprefn',
  201. 'addoptn',
  202. 'nothingn',
  203. 'loadvmtn',
  204. 'guidconstn',
  205. 'rttin');
  206. type
  207. { all boolean field of ttree are now collected in flags }
  208. tnodeflags = (
  209. nf_needs_truefalselabel,
  210. nf_swapable, { tbinop operands can be swaped }
  211. nf_swaped, { tbinop operands are swaped }
  212. nf_error,
  213. { flags used by tcallnode }
  214. nf_return_value_used,
  215. nf_static_call,
  216. { flags used by tcallparanode }
  217. nf_varargs_para, { belongs this para to varargs }
  218. { flags used by loop nodes }
  219. nf_backward, { set if it is a for ... downto ... do loop }
  220. nf_varstate, { do we need to parse childs to set var state }
  221. { taddrnode }
  222. nf_procvarload,
  223. { tvecnode }
  224. nf_memindex,
  225. nf_memseg,
  226. nf_callunique,
  227. { twithnode }
  228. nf_islocal,
  229. { tloadnode }
  230. nf_absolute,
  231. nf_first,
  232. { tassignmentnode }
  233. nf_concat_string,
  234. { tfuncretnode }
  235. nf_is_first_funcret, { 20th }
  236. { tarrayconstructnode }
  237. nf_cargs,
  238. nf_cargswap,
  239. nf_forcevaria,
  240. nf_novariaallowed,
  241. { ttypeconvnode }
  242. nf_explizit,
  243. { tinlinenode }
  244. nf_inlineconst,
  245. { general }
  246. nf_isproperty,
  247. nf_varstateset,
  248. { tasmnode }
  249. nf_object_preserved,
  250. { taddnode }
  251. nf_use_strconcat
  252. );
  253. tnodeflagset = set of tnodeflags;
  254. const
  255. { contains the flags which must be equal for the equality }
  256. { of nodes }
  257. flagsequal : tnodeflagset = [nf_error,nf_static_call,nf_backward];
  258. type
  259. tnodelist = class
  260. end;
  261. { later (for the newcg) tnode will inherit from tlinkedlist_item }
  262. tnode = class
  263. public
  264. { type of this node }
  265. nodetype : tnodetype;
  266. { type of the current code block, general/const/type }
  267. blocktype : tblock_type;
  268. { the location of the result of this node }
  269. location : tlocation;
  270. { the parent node of this is node }
  271. { this field is set by concattolist }
  272. parent : tnode;
  273. { there are some properties about the node stored }
  274. flags : tnodeflagset;
  275. { the number of registers needed to evalute the node }
  276. registers32,registersfpu : longint; { must be longint !!!! }
  277. {$ifdef SUPPORT_MMX}
  278. registersmmx,registerskni : longint;
  279. {$endif SUPPORT_MMX}
  280. resulttype : ttype;
  281. fileinfo : tfileposinfo;
  282. localswitches : tlocalswitches;
  283. {$ifdef extdebug}
  284. maxfirstpasscount,
  285. firstpasscount : longint;
  286. {$endif extdebug}
  287. { list : taasmoutput; }
  288. constructor create(tt : tnodetype);
  289. { this constructor is only for creating copies of class }
  290. { the fields are copied by getcopy }
  291. constructor createforcopy;
  292. destructor destroy;override;
  293. { toggles the flag }
  294. procedure toggleflag(f : tnodeflags);
  295. { the 1.1 code generator may override pass_1 }
  296. { and it need not to implement det_* then }
  297. { 1.1: pass_1 returns a value<>0 if the node has been transformed }
  298. { 2.0: runs det_resulttype and det_temp }
  299. function pass_1 : tnode;virtual;abstract;
  300. { dermines the resulttype of the node }
  301. function det_resulttype : tnode;virtual;abstract;
  302. { dermines the number of necessary temp. locations to evaluate
  303. the node }
  304. procedure det_temp;virtual;abstract;
  305. procedure pass_2;virtual;abstract;
  306. { comparing of nodes }
  307. function isequal(p : tnode) : boolean;
  308. { to implement comparisation, override this method }
  309. function docompare(p : tnode) : boolean;virtual;
  310. { gets a copy of the node }
  311. function getcopy : tnode;virtual;
  312. procedure insertintolist(l : tnodelist);virtual;
  313. {$ifdef EXTDEBUG}
  314. { writes a node for debugging purpose, shouldn't be called }
  315. { direct, because there is no test for nil, use writenode }
  316. { to write a complete tree }
  317. procedure dowrite;virtual;
  318. procedure dowritenodetype;virtual;
  319. {$endif EXTDEBUG}
  320. procedure concattolist(l : tlinkedlist);virtual;
  321. function ischild(p : tnode) : boolean;virtual;
  322. procedure set_file_line(from : tnode);
  323. procedure set_tree_filepos(const filepos : tfileposinfo);
  324. end;
  325. { this node is the anchestor for all nodes with at least }
  326. { one child, you have to use it if you want to use }
  327. { true- and falselabel }
  328. tparentnode = class(tnode)
  329. {$ifdef newcg}
  330. falselabel,truelabel : tasmlabel;
  331. {$endif newcg}
  332. end;
  333. tnodeclass = class of tnode;
  334. punarynode = ^tunarynode;
  335. tunarynode = class(tparentnode)
  336. left : tnode;
  337. constructor create(tt : tnodetype;l : tnode);
  338. destructor destroy;override;
  339. procedure concattolist(l : tlinkedlist);override;
  340. function ischild(p : tnode) : boolean;override;
  341. function docompare(p : tnode) : boolean;override;
  342. function getcopy : tnode;override;
  343. procedure insertintolist(l : tnodelist);override;
  344. procedure left_max;
  345. {$ifdef extdebug}
  346. procedure dowrite;override;
  347. {$endif extdebug}
  348. end;
  349. pbinarynode = ^tbinarynode;
  350. tbinarynode = class(tunarynode)
  351. right : tnode;
  352. constructor create(tt : tnodetype;l,r : tnode);
  353. destructor destroy;override;
  354. procedure concattolist(l : tlinkedlist);override;
  355. function ischild(p : tnode) : boolean;override;
  356. function docompare(p : tnode) : boolean;override;
  357. procedure swapleftright;
  358. function getcopy : tnode;override;
  359. procedure insertintolist(l : tnodelist);override;
  360. procedure left_right_max;
  361. {$ifdef extdebug}
  362. procedure dowrite;override;
  363. {$endif extdebug}
  364. end;
  365. pbinopnode = ^tbinopnode;
  366. tbinopnode = class(tbinarynode)
  367. constructor create(tt : tnodetype;l,r : tnode);virtual;
  368. function docompare(p : tnode) : boolean;override;
  369. end;
  370. {$ifdef EXTDEBUG}
  371. var
  372. writenodeindention : string;
  373. procedure writenode(t:tnode);
  374. {$endif EXTDEBUG}
  375. {$ifdef tempregdebug}
  376. type
  377. pptree = ^tnode;
  378. var
  379. curptree: pptree;
  380. {$endif tempregdebug}
  381. implementation
  382. uses
  383. cutils;
  384. {****************************************************************************
  385. TNODE
  386. ****************************************************************************}
  387. constructor tnode.create(tt : tnodetype);
  388. begin
  389. inherited create;
  390. nodetype:=tt;
  391. blocktype:=block_type;
  392. { this allows easier error tracing }
  393. location.loc:=LOC_INVALID;
  394. { save local info }
  395. fileinfo:=aktfilepos;
  396. localswitches:=aktlocalswitches;
  397. resulttype.reset;
  398. registers32:=0;
  399. registersfpu:=0;
  400. {$ifdef SUPPORT_MMX}
  401. registersmmx:=0;
  402. {$endif SUPPORT_MMX}
  403. {$ifdef EXTDEBUG}
  404. maxfirstpasscount:=0;
  405. firstpasscount:=0;
  406. {$endif EXTDEBUG}
  407. flags:=[];
  408. end;
  409. constructor tnode.createforcopy;
  410. begin
  411. end;
  412. procedure tnode.toggleflag(f : tnodeflags);
  413. begin
  414. if f in flags then
  415. exclude(flags,f)
  416. else
  417. include(flags,f);
  418. end;
  419. destructor tnode.destroy;
  420. begin
  421. {$ifdef EXTDEBUG}
  422. if firstpasscount>maxfirstpasscount then
  423. maxfirstpasscount:=firstpasscount;
  424. {$endif EXTDEBUG}
  425. end;
  426. procedure tnode.concattolist(l : tlinkedlist);
  427. begin
  428. {$ifdef newcg}
  429. //!!!!!!! l^.concat(self);
  430. {$warning fixme}
  431. {$endif newcg}
  432. end;
  433. function tnode.ischild(p : tnode) : boolean;
  434. begin
  435. ischild:=false;
  436. end;
  437. {$ifdef EXTDEBUG}
  438. procedure tnode.dowrite;
  439. begin
  440. dowritenodetype;
  441. end;
  442. procedure tnode.dowritenodetype;
  443. begin
  444. write(writenodeindention,'(',nodetype2str[nodetype]);
  445. end;
  446. {$endif EXTDEBUG}
  447. function tnode.isequal(p : tnode) : boolean;
  448. begin
  449. isequal:=
  450. (not assigned(self) and not assigned(p)) or
  451. (assigned(self) and assigned(p) and
  452. { optimized subclasses have the same nodetype as their }
  453. { superclass (for compatibility), so also check the classtype (JM) }
  454. (p.classtype=classtype) and
  455. (p.nodetype=nodetype) and
  456. (flags*flagsequal=p.flags*flagsequal) and
  457. docompare(p));
  458. end;
  459. function tnode.docompare(p : tnode) : boolean;
  460. begin
  461. docompare:=true;
  462. end;
  463. function tnode.getcopy : tnode;
  464. var
  465. p : tnode;
  466. begin
  467. { this is quite tricky because we need a node of the current }
  468. { node type and not one of tnode! }
  469. p:=tnodeclass(classtype).createforcopy;
  470. p.nodetype:=nodetype;
  471. p.location:=location;
  472. p.parent:=parent;
  473. p.flags:=flags;
  474. p.registers32:=registers32;
  475. p.registersfpu:=registersfpu;
  476. {$ifdef SUPPORT_MMX}
  477. p.registersmmx:=registersmmx;
  478. p.registerskni:=registerskni;
  479. {$endif SUPPORT_MMX}
  480. p.resulttype:=resulttype;
  481. p.fileinfo:=fileinfo;
  482. p.localswitches:=localswitches;
  483. {$ifdef extdebug}
  484. p.firstpasscount:=firstpasscount;
  485. {$endif extdebug}
  486. { p.list:=list; }
  487. getcopy:=p;
  488. end;
  489. procedure tnode.insertintolist(l : tnodelist);
  490. begin
  491. end;
  492. procedure tnode.set_file_line(from : tnode);
  493. begin
  494. if assigned(from) then
  495. fileinfo:=from.fileinfo;
  496. end;
  497. procedure tnode.set_tree_filepos(const filepos : tfileposinfo);
  498. begin
  499. fileinfo:=filepos;
  500. end;
  501. {****************************************************************************
  502. TUNARYNODE
  503. ****************************************************************************}
  504. constructor tunarynode.create(tt : tnodetype;l : tnode);
  505. begin
  506. inherited create(tt);
  507. left:=l;
  508. end;
  509. destructor tunarynode.destroy;
  510. begin
  511. left.free;
  512. inherited destroy;
  513. end;
  514. function tunarynode.docompare(p : tnode) : boolean;
  515. begin
  516. docompare:=(inherited docompare(p) and
  517. ((left=nil) or left.isequal(tunarynode(p).left))
  518. );
  519. end;
  520. function tunarynode.getcopy : tnode;
  521. var
  522. p : tunarynode;
  523. begin
  524. p:=tunarynode(inherited getcopy);
  525. if assigned(left) then
  526. p.left:=left.getcopy
  527. else
  528. p.left:=nil;
  529. getcopy:=p;
  530. end;
  531. procedure tunarynode.insertintolist(l : tnodelist);
  532. begin
  533. end;
  534. {$ifdef extdebug}
  535. procedure tunarynode.dowrite;
  536. begin
  537. inherited dowrite;
  538. writeln(',');
  539. writenodeindention:=writenodeindention+' ';
  540. writenode(left);
  541. write(')');
  542. delete(writenodeindention,1,4);
  543. end;
  544. {$endif}
  545. procedure tunarynode.left_max;
  546. begin
  547. registers32:=left.registers32;
  548. registersfpu:=left.registersfpu;
  549. {$ifdef SUPPORT_MMX}
  550. registersmmx:=left.registersmmx;
  551. {$endif SUPPORT_MMX}
  552. end;
  553. procedure tunarynode.concattolist(l : tlinkedlist);
  554. begin
  555. left.parent:=self;
  556. left.concattolist(l);
  557. inherited concattolist(l);
  558. end;
  559. function tunarynode.ischild(p : tnode) : boolean;
  560. begin
  561. ischild:=p=left;
  562. end;
  563. {****************************************************************************
  564. TBINARYNODE
  565. ****************************************************************************}
  566. constructor tbinarynode.create(tt : tnodetype;l,r : tnode);
  567. begin
  568. inherited create(tt,l);
  569. right:=r
  570. end;
  571. destructor tbinarynode.destroy;
  572. begin
  573. right.free;
  574. inherited destroy;
  575. end;
  576. procedure tbinarynode.concattolist(l : tlinkedlist);
  577. begin
  578. { we could change that depending on the number of }
  579. { required registers }
  580. left.parent:=self;
  581. left.concattolist(l);
  582. left.parent:=self;
  583. left.concattolist(l);
  584. inherited concattolist(l);
  585. end;
  586. function tbinarynode.ischild(p : tnode) : boolean;
  587. begin
  588. ischild:=(p=right);
  589. end;
  590. function tbinarynode.docompare(p : tnode) : boolean;
  591. begin
  592. docompare:=(inherited docompare(p) and
  593. ((right=nil) or right.isequal(tbinarynode(p).right))
  594. );
  595. end;
  596. function tbinarynode.getcopy : tnode;
  597. var
  598. p : tbinarynode;
  599. begin
  600. p:=tbinarynode(inherited getcopy);
  601. if assigned(right) then
  602. p.right:=right.getcopy
  603. else
  604. p.right:=nil;
  605. getcopy:=p;
  606. end;
  607. procedure tbinarynode.insertintolist(l : tnodelist);
  608. begin
  609. end;
  610. procedure tbinarynode.swapleftright;
  611. var
  612. swapp : tnode;
  613. begin
  614. swapp:=right;
  615. right:=left;
  616. left:=swapp;
  617. if nf_swaped in flags then
  618. exclude(flags,nf_swaped)
  619. else
  620. include(flags,nf_swaped);
  621. end;
  622. procedure tbinarynode.left_right_max;
  623. begin
  624. if assigned(left) then
  625. begin
  626. if assigned(right) then
  627. begin
  628. registers32:=max(left.registers32,right.registers32);
  629. registersfpu:=max(left.registersfpu,right.registersfpu);
  630. {$ifdef SUPPORT_MMX}
  631. registersmmx:=max(left.registersmmx,right.registersmmx);
  632. {$endif SUPPORT_MMX}
  633. end
  634. else
  635. begin
  636. registers32:=left.registers32;
  637. registersfpu:=left.registersfpu;
  638. {$ifdef SUPPORT_MMX}
  639. registersmmx:=left.registersmmx;
  640. {$endif SUPPORT_MMX}
  641. end;
  642. end;
  643. end;
  644. {$ifdef extdebug}
  645. procedure tbinarynode.dowrite;
  646. begin
  647. inherited dowrite;
  648. writeln(',');
  649. writenodeindention:=writenodeindention+' ';
  650. writenode(right);
  651. write(')');
  652. delete(writenodeindention,1,4);
  653. end;
  654. {$endif}
  655. {****************************************************************************
  656. TBINOPYNODE
  657. ****************************************************************************}
  658. constructor tbinopnode.create(tt : tnodetype;l,r : tnode);
  659. begin
  660. inherited create(tt,l,r);
  661. end;
  662. function tbinopnode.docompare(p : tnode) : boolean;
  663. begin
  664. docompare:=(inherited docompare(p)) or
  665. { if that's in the flags, is p then always a tbinopnode (?) (JM) }
  666. ((nf_swapable in flags) and
  667. left.isequal(tbinopnode(p).right) and
  668. right.isequal(tbinopnode(p).left));
  669. end;
  670. {****************************************************************************
  671. WRITENODE
  672. ****************************************************************************}
  673. {$ifdef EXTDEBUG}
  674. procedure writenode(t:tnode);
  675. begin
  676. if assigned(t) then
  677. t.dowrite
  678. else
  679. write(writenodeindention,'nil');
  680. if writenodeindention='' then
  681. writeln;
  682. end;
  683. {$endif EXTDEBUG}
  684. end.
  685. {
  686. $Log$
  687. Revision 1.22 2002-03-31 20:26:35 jonas
  688. + a_loadfpu_* and a_loadmm_* methods in tcg
  689. * register allocation is now handled by a class and is mostly processor
  690. independent (+rgobj.pas and i386/rgcpu.pas)
  691. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  692. * some small improvements and fixes to the optimizer
  693. * some register allocation fixes
  694. * some fpuvaroffset fixes in the unary minus node
  695. * push/popusedregisters is now called rg.save/restoreusedregisters and
  696. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  697. also better optimizable)
  698. * fixed and optimized register saving/restoring for new/dispose nodes
  699. * LOC_FPU locations now also require their "register" field to be set to
  700. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  701. - list field removed of the tnode class because it's not used currently
  702. and can cause hard-to-find bugs
  703. Revision 1.21 2002/01/19 11:52:32 peter
  704. * dynarr:=nil support added
  705. Revision 1.20 2001/10/20 19:28:38 peter
  706. * interface 2 guid support
  707. * guid constants support
  708. Revision 1.19 2001/08/23 14:28:36 jonas
  709. + tempcreate/ref/delete nodes (allows the use of temps in the
  710. resulttype and first pass)
  711. * made handling of read(ln)/write(ln) processor independent
  712. * moved processor independent handling for str and reset/rewrite-typed
  713. from firstpass to resulttype pass
  714. * changed names of helpers in text.inc to be generic for use as
  715. compilerprocs + added "iocheck" directive for most of them
  716. * reading of ordinals is done by procedures instead of functions
  717. because otherwise FPC_IOCHECK overwrote the result before it could
  718. be stored elsewhere (range checking still works)
  719. * compilerprocs can now be used in the system unit before they are
  720. implemented
  721. * added note to errore.msg that booleans can't be read using read/readln
  722. Revision 1.18 2001/07/30 20:59:27 peter
  723. * m68k updates from v10 merged
  724. Revision 1.17 2001/06/04 18:14:16 peter
  725. * store blocktype info in tnode
  726. Revision 1.16 2001/06/04 11:53:13 peter
  727. + varargs directive
  728. Revision 1.15 2001/04/13 01:22:10 peter
  729. * symtable change to classes
  730. * range check generation and errors fixed, make cycle DEBUG=1 works
  731. * memory leaks fixed
  732. Revision 1.14 2001/04/02 21:20:31 peter
  733. * resulttype rewrite
  734. Revision 1.13 2001/01/13 00:08:09 peter
  735. * added missing addoptn
  736. Revision 1.12 2001/01/01 11:38:45 peter
  737. * forgot to remove node.inc and nodeh.inc that were merged into node.pas
  738. already.
  739. Revision 1.11 2000/12/25 00:07:26 peter
  740. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  741. tlinkedlist objects)
  742. Revision 1.10 2000/11/29 00:30:34 florian
  743. * unused units removed from uses clause
  744. * some changes for widestrings
  745. Revision 1.9 2000/10/31 22:02:49 peter
  746. * symtable splitted, no real code changes
  747. Revision 1.8 2000/10/01 19:48:24 peter
  748. * lot of compile updates for cg11
  749. Revision 1.7 2000/09/30 16:08:45 peter
  750. * more cg11 updates
  751. Revision 1.6 2000/09/28 19:49:52 florian
  752. *** empty log message ***
  753. Revision 1.5 2000/09/27 18:14:31 florian
  754. * fixed a lot of syntax errors in the n*.pas stuff
  755. Revision 1.4 2000/09/24 15:06:19 peter
  756. * use defines.inc
  757. Revision 1.3 2000/09/22 21:45:35 florian
  758. * some updates e.g. getcopy added
  759. Revision 1.2 2000/09/20 21:52:38 florian
  760. * removed a lot of errors
  761. Revision 1.1 2000/08/26 12:27:35 florian
  762. * initial release
  763. }