node.pas 24 KB

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