node.pas 25 KB

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