node.pas 24 KB

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