node.pas 25 KB

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