node.pas 27 KB

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