node.pas 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 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,cgbase,
  25. aasmbase,
  26. symtype;
  27. type
  28. pconstset = ^tconstset;
  29. tconstset = set of 0..255;
  30. tnodetype = (
  31. emptynode, {No node (returns nil when loading from ppu)}
  32. addn, {Represents the + operator}
  33. muln, {Represents the * operator}
  34. subn, {Represents the - operator}
  35. divn, {Represents the div operator}
  36. symdifn, {Represents the >< operator}
  37. modn, {Represents the mod operator}
  38. assignn, {Represents an assignment}
  39. loadn, {Represents the use of a variabele}
  40. rangen, {Represents a range (i.e. 0..9)}
  41. ltn, {Represents the < operator}
  42. lten, {Represents the <= operator}
  43. gtn, {Represents the > operator}
  44. gten, {Represents the >= operator}
  45. equaln, {Represents the = operator}
  46. unequaln, {Represents the <> operator}
  47. inn, {Represents the in operator}
  48. orn, {Represents the or operator}
  49. xorn, {Represents the xor operator}
  50. shrn, {Represents the shr operator}
  51. shln, {Represents the shl operator}
  52. slashn, {Represents the / operator}
  53. andn, {Represents the and operator}
  54. subscriptn, {Field in a record/object}
  55. derefn, {Dereferences a pointer}
  56. addrn, {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. unaryminusn, {Represents a sign change (i.e. -2)}
  63. asmn, {Represents an assembler node }
  64. vecn, {Represents array indexing}
  65. pointerconstn, {Represents a pointer constant}
  66. stringconstn, {Represents a string constant}
  67. notn, {Represents the not operator}
  68. inlinen, {Internal procedures (i.e. writeln)}
  69. niln, {Represents the nil pointer}
  70. errorn, {This part of the tree could not be
  71. parsed because of a compiler error}
  72. typen, {A type name. Used for i.e. typeof(obj)}
  73. setelementn, {A set element(s) (i.e. [a,b] and also [a..b])}
  74. setconstn, {A set constant (i.e. [1,2])}
  75. blockn, {A block of statements}
  76. statementn, {One statement in a block of nodes}
  77. ifn, {An if statement}
  78. breakn, {A break statement}
  79. continuen, {A continue statement}
  80. whilerepeatn, {A while or repeat statement}
  81. forn, {A for loop}
  82. exitn, {An exit statement}
  83. withn, {A with statement}
  84. casen, {A case statement}
  85. labeln, {A label}
  86. goton, {A goto statement}
  87. tryexceptn, {A try except block}
  88. raisen, {A raise statement}
  89. tryfinallyn, {A try finally statement}
  90. onn, {For an on statement in exception code}
  91. isn, {Represents the is operator}
  92. asn, {Represents the as typecast}
  93. caretn, {Represents the ^ operator}
  94. starstarn, {Represents the ** operator exponentiation }
  95. arrayconstructorn, {Construction node for [...] parsing}
  96. arrayconstructorrangen, {Range element to allow sets in array construction tree}
  97. tempcreaten, { for temps in the result/firstpass }
  98. temprefn, { references to temps }
  99. tempdeleten, { for temps in the result/firstpass }
  100. addoptn, { added for optimizations where we cannot suppress }
  101. nothingn, {NOP, Do nothing}
  102. loadvmtaddrn, {Load the address of the VMT of a class/object}
  103. guidconstn, {A GUID COM Interface constant }
  104. rttin, {Rtti information so they can be accessed in result/firstpass}
  105. loadparentfpn { Load the framepointer of the parent for nested procedures }
  106. );
  107. const
  108. nodetype2str : array[tnodetype] of string[24] = (
  109. '<emptynode>',
  110. 'addn',
  111. 'muln',
  112. 'subn',
  113. 'divn',
  114. 'symdifn',
  115. 'modn',
  116. 'assignn',
  117. 'loadn',
  118. 'rangen',
  119. 'ltn',
  120. 'lten',
  121. 'gtn',
  122. 'gten',
  123. 'equaln',
  124. 'unequaln',
  125. 'inn',
  126. 'orn',
  127. 'xorn',
  128. 'shrn',
  129. 'shln',
  130. 'slashn',
  131. 'andn',
  132. 'subscriptn',
  133. 'derefn',
  134. 'addrn',
  135. 'ordconstn',
  136. 'typeconvn',
  137. 'calln',
  138. 'callparan',
  139. 'realconstn',
  140. 'unaryminusn',
  141. 'asmn',
  142. 'vecn',
  143. 'pointerconstn',
  144. 'stringconstn',
  145. 'notn',
  146. 'inlinen',
  147. 'niln',
  148. 'errorn',
  149. 'typen',
  150. 'setelementn',
  151. 'setconstn',
  152. 'blockn',
  153. 'statementn',
  154. 'ifn',
  155. 'breakn',
  156. 'continuen',
  157. 'whilerepeatn',
  158. 'forn',
  159. 'exitn',
  160. 'withn',
  161. 'casen',
  162. 'labeln',
  163. 'goton',
  164. 'tryexceptn',
  165. 'raisen',
  166. 'tryfinallyn',
  167. 'onn',
  168. 'isn',
  169. 'asn',
  170. 'caretn',
  171. 'starstarn',
  172. 'arrayconstructn',
  173. 'arrayconstructrangen',
  174. 'tempcreaten',
  175. 'temprefn',
  176. 'tempdeleten',
  177. 'addoptn',
  178. 'nothingn',
  179. 'loadvmtaddrn',
  180. 'guidconstn',
  181. 'rttin',
  182. 'loadparentfpn');
  183. type
  184. { all boolean field of ttree are now collected in flags }
  185. tnodeflag = (
  186. nf_swapable, { tbinop operands can be swaped }
  187. nf_swaped, { tbinop operands are swaped }
  188. nf_error,
  189. { general }
  190. nf_pass1_done,
  191. nf_write, { Node is written to }
  192. nf_isproperty,
  193. { taddrnode }
  194. nf_procvarload,
  195. nf_typedaddr,
  196. { tvecnode }
  197. nf_memindex,
  198. nf_memseg,
  199. nf_callunique,
  200. { tloadnode }
  201. nf_absolute,
  202. nf_load_self_pointer,
  203. { taddnode }
  204. nf_is_currency,
  205. nf_has_pointerdiv,
  206. { tassignmentnode }
  207. nf_concat_string,
  208. nf_use_strconcat,
  209. { tarrayconstructnode }
  210. nf_forcevaria,
  211. nf_novariaallowed,
  212. { ttypeconvnode }
  213. nf_explicit,
  214. { tinlinenode }
  215. nf_inlineconst,
  216. { tasmnode }
  217. nf_get_asm_position
  218. );
  219. tnodeflags = set of tnodeflag;
  220. const
  221. { contains the flags which must be equal for the equality }
  222. { of nodes }
  223. flagsequal : tnodeflags = [nf_error];
  224. type
  225. tnodelist = class
  226. end;
  227. { later (for the newcg) tnode will inherit from tlinkedlist_item }
  228. tnode = class
  229. public
  230. { type of this node }
  231. nodetype : tnodetype;
  232. { type of the current code block, general/const/type }
  233. blocktype : tblock_type;
  234. { expected location of the result of this node (pass1) }
  235. expectloc : tcgloc;
  236. { the location of the result of this node (pass2) }
  237. location : tlocation;
  238. { the parent node of this is node }
  239. { this field is set by concattolist }
  240. parent : tnode;
  241. { there are some properties about the node stored }
  242. flags : tnodeflags;
  243. ppuidx : longint;
  244. { the number of registers needed to evalute the node }
  245. registersint,registersfpu,registersmm : longint; { must be longint !!!! }
  246. {$ifdef SUPPORT_MMX}
  247. registersmmx : longint;
  248. {$endif SUPPORT_MMX}
  249. resulttype : ttype;
  250. fileinfo : tfileposinfo;
  251. localswitches : tlocalswitches;
  252. {$ifdef extdebug}
  253. maxfirstpasscount,
  254. firstpasscount : longint;
  255. {$endif extdebug}
  256. constructor create(t:tnodetype);
  257. { this constructor is only for creating copies of class }
  258. { the fields are copied by getcopy }
  259. constructor createforcopy;
  260. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);virtual;
  261. destructor destroy;override;
  262. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  263. procedure buildderefimpl;virtual;
  264. procedure derefimpl;virtual;
  265. procedure derefnode;virtual;
  266. { toggles the flag }
  267. procedure toggleflag(f : tnodeflag);
  268. { the 1.1 code generator may override pass_1 }
  269. { and it need not to implement det_* then }
  270. { 1.1: pass_1 returns a value<>0 if the node has been transformed }
  271. { 2.0: runs det_resulttype and det_temp }
  272. function pass_1 : tnode;virtual;abstract;
  273. { dermines the resulttype of the node }
  274. function det_resulttype : tnode;virtual;abstract;
  275. { dermines the number of necessary temp. locations to evaluate
  276. the node }
  277. {$ifdef state_tracking}
  278. { Does optimizations by keeping track of the variable states
  279. in a procedure }
  280. function track_state_pass(exec_known:boolean):boolean;virtual;
  281. {$endif}
  282. { For a t1:=t2 tree, mark the part of the tree t1 that gets
  283. written to (normally the loadnode) as write access. }
  284. procedure mark_write;virtual;
  285. procedure det_temp;virtual;abstract;
  286. procedure pass_2;virtual;abstract;
  287. { comparing of nodes }
  288. function isequal(p : tnode) : boolean;
  289. { to implement comparisation, override this method }
  290. function docompare(p : tnode) : boolean;virtual;
  291. { gets a copy of the node }
  292. function getcopy : tnode;virtual;
  293. procedure insertintolist(l : tnodelist);virtual;
  294. { writes a node for debugging purpose, shouldn't be called }
  295. { direct, because there is no test for nil, use printnode }
  296. { to write a complete tree }
  297. procedure printnodeinfo(var t:text);
  298. procedure printnodedata(var t:text);virtual;
  299. procedure printnodetree(var t:text);virtual;
  300. procedure concattolist(l : tlinkedlist);virtual;
  301. function ischild(p : tnode) : boolean;virtual;
  302. procedure set_file_line(from : tnode);
  303. procedure set_tree_filepos(const filepos : tfileposinfo);
  304. end;
  305. tnodeclass = class of tnode;
  306. tnodeclassarray = array[tnodetype] of tnodeclass;
  307. { this node is the anchestor for all nodes with at least }
  308. { one child, you have to use it if you want to use }
  309. { true- and falselabel }
  310. punarynode = ^tunarynode;
  311. tunarynode = class(tnode)
  312. left : tnode;
  313. constructor create(t:tnodetype;l : tnode);
  314. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  315. destructor destroy;override;
  316. procedure ppuwrite(ppufile:tcompilerppufile);override;
  317. procedure buildderefimpl;override;
  318. procedure derefimpl;override;
  319. procedure derefnode;override;
  320. procedure concattolist(l : tlinkedlist);override;
  321. function ischild(p : tnode) : boolean;override;
  322. function docompare(p : tnode) : boolean;override;
  323. function getcopy : tnode;override;
  324. procedure insertintolist(l : tnodelist);override;
  325. procedure left_max;
  326. procedure printnodedata(var t:text);override;
  327. end;
  328. pbinarynode = ^tbinarynode;
  329. tbinarynode = class(tunarynode)
  330. right : tnode;
  331. constructor create(t:tnodetype;l,r : tnode);
  332. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  333. destructor destroy;override;
  334. procedure ppuwrite(ppufile:tcompilerppufile);override;
  335. procedure buildderefimpl;override;
  336. procedure derefimpl;override;
  337. procedure derefnode;override;
  338. procedure concattolist(l : tlinkedlist);override;
  339. function ischild(p : tnode) : boolean;override;
  340. function docompare(p : tnode) : boolean;override;
  341. procedure swapleftright;
  342. function getcopy : tnode;override;
  343. procedure insertintolist(l : tnodelist);override;
  344. procedure left_right_max;
  345. procedure printnodedata(var t:text);override;
  346. procedure printnodelist(var t:text);
  347. end;
  348. tbinopnode = class(tbinarynode)
  349. constructor create(t:tnodetype;l,r : tnode);virtual;
  350. function docompare(p : tnode) : boolean;override;
  351. end;
  352. var
  353. { array with all class types for tnodes }
  354. nodeclass : tnodeclassarray;
  355. function nodeppuidxget(i:longint):tnode;
  356. function ppuloadnode(ppufile:tcompilerppufile):tnode;
  357. procedure ppuwritenode(ppufile:tcompilerppufile;n:tnode);
  358. function ppuloadnodetree(ppufile:tcompilerppufile):tnode;
  359. procedure ppuwritenodetree(ppufile:tcompilerppufile;n:tnode);
  360. const
  361. printnodespacing = ' ';
  362. var
  363. { indention used when writing the tree to the screen }
  364. printnodeindention : string;
  365. procedure printnodeindent;
  366. procedure printnodeunindent;
  367. procedure printnode(var t:text;n:tnode);
  368. function is_constnode(p : tnode) : boolean;
  369. function is_constintnode(p : tnode) : boolean;
  370. function is_constcharnode(p : tnode) : boolean;
  371. function is_constrealnode(p : tnode) : boolean;
  372. function is_constboolnode(p : tnode) : boolean;
  373. function is_constenumnode(p : tnode) : boolean;
  374. function is_constwidecharnode(p : tnode) : boolean;
  375. implementation
  376. uses
  377. cutils,verbose,ppu,
  378. symconst,
  379. defutil;
  380. const
  381. ppunodemarker = 255;
  382. {****************************************************************************
  383. Helpers
  384. ****************************************************************************}
  385. var
  386. nodeppudata : tdynamicarray;
  387. nodeppuidx : longint;
  388. procedure nodeppuidxcreate;
  389. begin
  390. nodeppudata:=tdynamicarray.create(1024);
  391. nodeppuidx:=0;
  392. end;
  393. procedure nodeppuidxfree;
  394. begin
  395. nodeppudata.free;
  396. nodeppudata:=nil;
  397. end;
  398. procedure nodeppuidxadd(n:tnode);
  399. begin
  400. if n.ppuidx<0 then
  401. internalerror(200311072);
  402. nodeppudata.seek(n.ppuidx*sizeof(pointer));
  403. nodeppudata.write(n,sizeof(pointer));
  404. end;
  405. function nodeppuidxget(i:longint):tnode;
  406. var
  407. l : longint;
  408. begin
  409. if i<0 then
  410. internalerror(200311072);
  411. nodeppudata.seek(i*sizeof(pointer));
  412. if nodeppudata.read(result,sizeof(pointer))<>sizeof(pointer) then
  413. internalerror(200311073);
  414. end;
  415. function ppuloadnode(ppufile:tcompilerppufile):tnode;
  416. var
  417. b : byte;
  418. t : tnodetype;
  419. hppuidx : longint;
  420. begin
  421. { marker }
  422. b:=ppufile.getbyte;
  423. if b<>ppunodemarker then
  424. internalerror(200208151);
  425. { load nodetype }
  426. t:=tnodetype(ppufile.getbyte);
  427. if t>high(tnodetype) then
  428. internalerror(200208152);
  429. if t<>emptynode then
  430. begin
  431. if not assigned(nodeclass[t]) then
  432. internalerror(200208153);
  433. hppuidx:=ppufile.getlongint;
  434. //writeln('load: ',nodetype2str[t]);
  435. { generate node of the correct class }
  436. result:=nodeclass[t].ppuload(t,ppufile);
  437. result.ppuidx:=hppuidx;
  438. nodeppuidxadd(result);
  439. end
  440. else
  441. result:=nil;
  442. end;
  443. procedure ppuwritenode(ppufile:tcompilerppufile;n:tnode);
  444. begin
  445. { marker, read by ppuloadnode }
  446. ppufile.putbyte(ppunodemarker);
  447. { type, read by ppuloadnode }
  448. if assigned(n) then
  449. begin
  450. if n.ppuidx=-1 then
  451. internalerror(200311071);
  452. n.ppuidx:=nodeppuidx;
  453. inc(nodeppuidx);
  454. ppufile.putbyte(byte(n.nodetype));
  455. ppufile.putlongint(n.ppuidx);
  456. //writeln('write: ',nodetype2str[n.nodetype]);
  457. n.ppuwrite(ppufile);
  458. end
  459. else
  460. ppufile.putbyte(byte(emptynode));
  461. end;
  462. function ppuloadnodetree(ppufile:tcompilerppufile):tnode;
  463. begin
  464. if ppufile.readentry<>ibnodetree then
  465. Message(unit_f_ppu_read_error);
  466. nodeppuidxcreate;
  467. result:=ppuloadnode(ppufile);
  468. result.derefnode;
  469. nodeppuidxfree;
  470. end;
  471. procedure ppuwritenodetree(ppufile:tcompilerppufile;n:tnode);
  472. begin
  473. nodeppuidx:=0;
  474. ppuwritenode(ppufile,n);
  475. ppufile.writeentry(ibnodetree);
  476. end;
  477. procedure printnodeindent;
  478. begin
  479. printnodeindention:=printnodeindention+printnodespacing;
  480. end;
  481. procedure printnodeunindent;
  482. begin
  483. delete(printnodeindention,1,length(printnodespacing));
  484. end;
  485. procedure printnode(var t:text;n:tnode);
  486. begin
  487. if assigned(n) then
  488. n.printnodetree(t)
  489. else
  490. writeln(t,printnodeindention,'nil');
  491. end;
  492. function is_constnode(p : tnode) : boolean;
  493. begin
  494. is_constnode:=(p.nodetype in [niln,ordconstn,realconstn,stringconstn,setconstn,guidconstn]);
  495. end;
  496. function is_constintnode(p : tnode) : boolean;
  497. begin
  498. is_constintnode:=(p.nodetype=ordconstn) and is_integer(p.resulttype.def);
  499. end;
  500. function is_constcharnode(p : tnode) : boolean;
  501. begin
  502. is_constcharnode:=(p.nodetype=ordconstn) and is_char(p.resulttype.def);
  503. end;
  504. function is_constwidecharnode(p : tnode) : boolean;
  505. begin
  506. is_constwidecharnode:=(p.nodetype=ordconstn) and is_widechar(p.resulttype.def);
  507. end;
  508. function is_constrealnode(p : tnode) : boolean;
  509. begin
  510. is_constrealnode:=(p.nodetype=realconstn);
  511. end;
  512. function is_constboolnode(p : tnode) : boolean;
  513. begin
  514. is_constboolnode:=(p.nodetype=ordconstn) and is_boolean(p.resulttype.def);
  515. end;
  516. function is_constenumnode(p : tnode) : boolean;
  517. begin
  518. is_constenumnode:=(p.nodetype=ordconstn) and (p.resulttype.def.deftype=enumdef);
  519. end;
  520. {****************************************************************************
  521. TNODE
  522. ****************************************************************************}
  523. constructor tnode.create(t:tnodetype);
  524. begin
  525. inherited create;
  526. nodetype:=t;
  527. blocktype:=block_type;
  528. { updated by firstpass }
  529. expectloc:=LOC_INVALID;
  530. { updated by secondpass }
  531. location.loc:=LOC_INVALID;
  532. { save local info }
  533. fileinfo:=aktfilepos;
  534. localswitches:=aktlocalswitches;
  535. resulttype.reset;
  536. registersint:=0;
  537. registersfpu:=0;
  538. {$ifdef SUPPORT_MMX}
  539. registersmmx:=0;
  540. {$endif SUPPORT_MMX}
  541. {$ifdef EXTDEBUG}
  542. maxfirstpasscount:=0;
  543. firstpasscount:=0;
  544. {$endif EXTDEBUG}
  545. flags:=[];
  546. ppuidx:=-1;
  547. end;
  548. constructor tnode.createforcopy;
  549. begin
  550. end;
  551. constructor tnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  552. begin
  553. nodetype:=t;
  554. { tnode fields }
  555. blocktype:=tblock_type(ppufile.getbyte);
  556. ppufile.getposinfo(fileinfo);
  557. ppufile.getsmallset(localswitches);
  558. ppufile.gettype(resulttype);
  559. ppufile.getsmallset(flags);
  560. { updated by firstpass }
  561. expectloc:=LOC_INVALID;
  562. { updated by secondpass }
  563. location.loc:=LOC_INVALID;
  564. registersint:=0;
  565. registersfpu:=0;
  566. {$ifdef SUPPORT_MMX}
  567. registersmmx:=0;
  568. {$endif SUPPORT_MMX}
  569. {$ifdef EXTDEBUG}
  570. maxfirstpasscount:=0;
  571. firstpasscount:=0;
  572. {$endif EXTDEBUG}
  573. ppuidx:=-1;
  574. end;
  575. procedure tnode.ppuwrite(ppufile:tcompilerppufile);
  576. begin
  577. ppufile.putbyte(byte(block_type));
  578. ppufile.putposinfo(fileinfo);
  579. ppufile.putsmallset(localswitches);
  580. ppufile.puttype(resulttype);
  581. ppufile.putsmallset(flags);
  582. end;
  583. procedure tnode.buildderefimpl;
  584. begin
  585. resulttype.buildderef;
  586. end;
  587. procedure tnode.derefimpl;
  588. begin
  589. resulttype.resolve;
  590. end;
  591. procedure tnode.derefnode;
  592. begin
  593. end;
  594. procedure tnode.toggleflag(f : tnodeflag);
  595. begin
  596. if f in flags then
  597. exclude(flags,f)
  598. else
  599. include(flags,f);
  600. end;
  601. destructor tnode.destroy;
  602. begin
  603. {$ifdef EXTDEBUG}
  604. if firstpasscount>maxfirstpasscount then
  605. maxfirstpasscount:=firstpasscount;
  606. {$endif EXTDEBUG}
  607. end;
  608. procedure tnode.concattolist(l : tlinkedlist);
  609. begin
  610. end;
  611. function tnode.ischild(p : tnode) : boolean;
  612. begin
  613. ischild:=false;
  614. end;
  615. procedure tnode.mark_write;
  616. begin
  617. {$ifdef EXTDEBUG}
  618. Comment(V_Warning,'mark_write not implemented for '+nodetype2str[nodetype]);
  619. {$endif EXTDEBUG}
  620. end;
  621. procedure tnode.printnodeinfo(var t:text);
  622. begin
  623. write(t,nodetype2str[nodetype]);
  624. if assigned(resulttype.def) then
  625. write(t,', resulttype = "',resulttype.def.gettypename,'"')
  626. else
  627. write(t,', resulttype = <nil>');
  628. writeln(t,', pos = (',fileinfo.line,',',fileinfo.column,')',
  629. ', loc = ',tcgloc2str[location.loc],
  630. ', expectloc = ',tcgloc2str[expectloc],
  631. ', intregs = ',registersint,
  632. ', fpuregs = ',registersfpu);
  633. end;
  634. procedure tnode.printnodedata(var t:text);
  635. begin
  636. end;
  637. procedure tnode.printnodetree(var t:text);
  638. begin
  639. write(t,printnodeindention,'(');
  640. printnodeinfo(t);
  641. printnodeindent;
  642. printnodedata(t);
  643. printnodeunindent;
  644. writeln(t,printnodeindention,')');
  645. end;
  646. function tnode.isequal(p : tnode) : boolean;
  647. begin
  648. isequal:=
  649. (not assigned(self) and not assigned(p)) or
  650. (assigned(self) and assigned(p) and
  651. { optimized subclasses have the same nodetype as their }
  652. { superclass (for compatibility), so also check the classtype (JM) }
  653. (p.classtype=classtype) and
  654. (p.nodetype=nodetype) and
  655. (flags*flagsequal=p.flags*flagsequal) and
  656. docompare(p));
  657. end;
  658. {$ifdef state_tracking}
  659. function Tnode.track_state_pass(exec_known:boolean):boolean;
  660. begin
  661. track_state_pass:=false;
  662. end;
  663. {$endif state_tracking}
  664. function tnode.docompare(p : tnode) : boolean;
  665. begin
  666. docompare:=true;
  667. end;
  668. function tnode.getcopy : tnode;
  669. var
  670. p : tnode;
  671. begin
  672. { this is quite tricky because we need a node of the current }
  673. { node type and not one of tnode! }
  674. p:=tnodeclass(classtype).createforcopy;
  675. p.nodetype:=nodetype;
  676. p.expectloc:=expectloc;
  677. p.location:=location;
  678. p.parent:=parent;
  679. p.flags:=flags;
  680. p.registersint:=registersint;
  681. p.registersfpu:=registersfpu;
  682. {$ifdef SUPPORT_MMX}
  683. p.registersmmx:=registersmmx;
  684. p.registerskni:=registerskni;
  685. {$endif SUPPORT_MMX}
  686. p.resulttype:=resulttype;
  687. p.fileinfo:=fileinfo;
  688. p.localswitches:=localswitches;
  689. {$ifdef extdebug}
  690. p.firstpasscount:=firstpasscount;
  691. {$endif extdebug}
  692. { p.list:=list; }
  693. getcopy:=p;
  694. end;
  695. procedure tnode.insertintolist(l : tnodelist);
  696. begin
  697. end;
  698. procedure tnode.set_file_line(from : tnode);
  699. begin
  700. if assigned(from) then
  701. fileinfo:=from.fileinfo;
  702. end;
  703. procedure tnode.set_tree_filepos(const filepos : tfileposinfo);
  704. begin
  705. fileinfo:=filepos;
  706. end;
  707. {****************************************************************************
  708. TUNARYNODE
  709. ****************************************************************************}
  710. constructor tunarynode.create(t:tnodetype;l : tnode);
  711. begin
  712. inherited create(t);
  713. left:=l;
  714. end;
  715. constructor tunarynode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  716. begin
  717. inherited ppuload(t,ppufile);
  718. left:=ppuloadnode(ppufile);
  719. end;
  720. destructor tunarynode.destroy;
  721. begin
  722. left.free;
  723. inherited destroy;
  724. end;
  725. procedure tunarynode.ppuwrite(ppufile:tcompilerppufile);
  726. begin
  727. inherited ppuwrite(ppufile);
  728. ppuwritenode(ppufile,left);
  729. end;
  730. procedure tunarynode.buildderefimpl;
  731. begin
  732. inherited buildderefimpl;
  733. if assigned(left) then
  734. left.buildderefimpl;
  735. end;
  736. procedure tunarynode.derefimpl;
  737. begin
  738. inherited derefimpl;
  739. if assigned(left) then
  740. left.derefimpl;
  741. end;
  742. procedure tunarynode.derefnode;
  743. begin
  744. inherited derefnode;
  745. if assigned(left) then
  746. left.derefnode;
  747. end;
  748. function tunarynode.docompare(p : tnode) : boolean;
  749. begin
  750. docompare:=(inherited docompare(p) and
  751. ((left=nil) or left.isequal(tunarynode(p).left))
  752. );
  753. end;
  754. function tunarynode.getcopy : tnode;
  755. var
  756. p : tunarynode;
  757. begin
  758. p:=tunarynode(inherited getcopy);
  759. if assigned(left) then
  760. p.left:=left.getcopy
  761. else
  762. p.left:=nil;
  763. getcopy:=p;
  764. end;
  765. procedure tunarynode.insertintolist(l : tnodelist);
  766. begin
  767. end;
  768. procedure tunarynode.printnodedata(var t:text);
  769. begin
  770. inherited printnodedata(t);
  771. printnode(t,left);
  772. end;
  773. procedure tunarynode.left_max;
  774. begin
  775. registersint:=left.registersint;
  776. registersfpu:=left.registersfpu;
  777. {$ifdef SUPPORT_MMX}
  778. registersmmx:=left.registersmmx;
  779. {$endif SUPPORT_MMX}
  780. end;
  781. procedure tunarynode.concattolist(l : tlinkedlist);
  782. begin
  783. left.parent:=self;
  784. left.concattolist(l);
  785. inherited concattolist(l);
  786. end;
  787. function tunarynode.ischild(p : tnode) : boolean;
  788. begin
  789. ischild:=p=left;
  790. end;
  791. {****************************************************************************
  792. TBINARYNODE
  793. ****************************************************************************}
  794. constructor tbinarynode.create(t:tnodetype;l,r : tnode);
  795. begin
  796. inherited create(t,l);
  797. right:=r
  798. end;
  799. constructor tbinarynode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  800. begin
  801. inherited ppuload(t,ppufile);
  802. right:=ppuloadnode(ppufile);
  803. end;
  804. destructor tbinarynode.destroy;
  805. begin
  806. right.free;
  807. inherited destroy;
  808. end;
  809. procedure tbinarynode.ppuwrite(ppufile:tcompilerppufile);
  810. begin
  811. inherited ppuwrite(ppufile);
  812. ppuwritenode(ppufile,right);
  813. end;
  814. procedure tbinarynode.buildderefimpl;
  815. begin
  816. inherited buildderefimpl;
  817. if assigned(right) then
  818. right.buildderefimpl;
  819. end;
  820. procedure tbinarynode.derefimpl;
  821. begin
  822. inherited derefimpl;
  823. if assigned(right) then
  824. right.derefimpl;
  825. end;
  826. procedure tbinarynode.derefnode;
  827. begin
  828. inherited derefnode;
  829. if assigned(right) then
  830. right.derefnode;
  831. end;
  832. procedure tbinarynode.concattolist(l : tlinkedlist);
  833. begin
  834. { we could change that depending on the number of }
  835. { required registers }
  836. left.parent:=self;
  837. left.concattolist(l);
  838. left.parent:=self;
  839. left.concattolist(l);
  840. inherited concattolist(l);
  841. end;
  842. function tbinarynode.ischild(p : tnode) : boolean;
  843. begin
  844. ischild:=(p=right);
  845. end;
  846. function tbinarynode.docompare(p : tnode) : boolean;
  847. begin
  848. docompare:=(inherited docompare(p) and
  849. ((right=nil) or right.isequal(tbinarynode(p).right))
  850. );
  851. end;
  852. function tbinarynode.getcopy : tnode;
  853. var
  854. p : tbinarynode;
  855. begin
  856. p:=tbinarynode(inherited getcopy);
  857. if assigned(right) then
  858. p.right:=right.getcopy
  859. else
  860. p.right:=nil;
  861. getcopy:=p;
  862. end;
  863. procedure tbinarynode.insertintolist(l : tnodelist);
  864. begin
  865. end;
  866. procedure tbinarynode.swapleftright;
  867. var
  868. swapp : tnode;
  869. begin
  870. swapp:=right;
  871. right:=left;
  872. left:=swapp;
  873. if nf_swaped in flags then
  874. exclude(flags,nf_swaped)
  875. else
  876. include(flags,nf_swaped);
  877. end;
  878. procedure tbinarynode.left_right_max;
  879. begin
  880. if assigned(left) then
  881. begin
  882. if assigned(right) then
  883. begin
  884. registersint:=max(left.registersint,right.registersint);
  885. registersfpu:=max(left.registersfpu,right.registersfpu);
  886. {$ifdef SUPPORT_MMX}
  887. registersmmx:=max(left.registersmmx,right.registersmmx);
  888. {$endif SUPPORT_MMX}
  889. end
  890. else
  891. begin
  892. registersint:=left.registersint;
  893. registersfpu:=left.registersfpu;
  894. {$ifdef SUPPORT_MMX}
  895. registersmmx:=left.registersmmx;
  896. {$endif SUPPORT_MMX}
  897. end;
  898. end;
  899. end;
  900. procedure tbinarynode.printnodedata(var t:text);
  901. begin
  902. inherited printnodedata(t);
  903. printnode(t,right);
  904. end;
  905. procedure tbinarynode.printnodelist(var t:text);
  906. var
  907. hp : tbinarynode;
  908. begin
  909. hp:=self;
  910. while assigned(hp) do
  911. begin
  912. write(t,printnodeindention,'(');
  913. printnodeindent;
  914. hp.printnodeinfo(t);
  915. printnode(t,hp.left);
  916. printnodeunindent;
  917. writeln(t,printnodeindention,')');
  918. hp:=tbinarynode(hp.right);
  919. end;
  920. end;
  921. {****************************************************************************
  922. TBINOPYNODE
  923. ****************************************************************************}
  924. constructor tbinopnode.create(t:tnodetype;l,r : tnode);
  925. begin
  926. inherited create(t,l,r);
  927. end;
  928. function tbinopnode.docompare(p : tnode) : boolean;
  929. begin
  930. docompare:=(inherited docompare(p)) or
  931. { if that's in the flags, is p then always a tbinopnode (?) (JM) }
  932. ((nf_swapable in flags) and
  933. left.isequal(tbinopnode(p).right) and
  934. right.isequal(tbinopnode(p).left));
  935. end;
  936. end.
  937. {
  938. $Log$
  939. Revision 1.85 2004-05-24 20:39:41 florian
  940. * stricter handling of formal const parameters and IE fixed
  941. Revision 1.84 2004/05/23 18:28:41 peter
  942. * methodpointer is loaded into a temp when it was a calln
  943. Revision 1.83 2004/05/23 15:06:21 peter
  944. * implicit_finally flag must be set in pass1
  945. * add check whether the implicit frame is generated when expected
  946. Revision 1.82 2004/05/20 21:54:33 florian
  947. + <pointer> - <pointer> result is divided by the pointer element size now
  948. this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
  949. Revision 1.81 2004/02/03 22:32:54 peter
  950. * renamed xNNbittype to xNNinttype
  951. * renamed registers32 to registersint
  952. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  953. Revision 1.80 2004/01/26 16:12:28 daniel
  954. * reginfo now also only allocated during register allocation
  955. * third round of gdb cleanups: kick out most of concatstabto
  956. Revision 1.79 2003/12/26 00:32:22 florian
  957. + fpu<->mm register conversion
  958. Revision 1.78 2003/12/01 18:44:15 peter
  959. * fixed some crashes
  960. * fixed varargs and register calling probs
  961. Revision 1.77 2003/11/29 14:33:13 peter
  962. * typed address only used for @ and addr() that are parsed
  963. Revision 1.76 2003/11/23 17:38:48 peter
  964. * mark nodes that are copies
  965. Revision 1.75 2003/11/12 15:48:27 peter
  966. * fix set_varstate in for loops
  967. * fix set_varstate from case statements
  968. Revision 1.74 2003/11/10 22:02:52 peter
  969. * cross unit inlining fixed
  970. Revision 1.73 2003/10/23 14:44:07 peter
  971. * splitted buildderef and buildderefimpl to fix interface crc
  972. calculation
  973. Revision 1.72 2003/10/22 20:40:00 peter
  974. * write derefdata in a separate ppu entry
  975. Revision 1.71 2003/10/18 15:41:26 peter
  976. * made worklists dynamic in size
  977. Revision 1.70 2003/10/17 01:22:08 florian
  978. * compilation of the powerpc compiler fixed
  979. Revision 1.69 2003/10/08 19:19:45 peter
  980. * set_varstate cleanup
  981. Revision 1.68 2003/10/01 20:34:49 peter
  982. * procinfo unit contains tprocinfo
  983. * cginfo renamed to cgbase
  984. * moved cgmessage to verbose
  985. * fixed ppc and sparc compiles
  986. Revision 1.67 2003/09/28 17:55:04 peter
  987. * parent framepointer changed to hidden parameter
  988. * tloadparentfpnode added
  989. Revision 1.66 2003/09/06 22:27:08 florian
  990. * fixed web bug 2669
  991. * cosmetic fix in printnode
  992. * tobjectdef.gettypename implemented
  993. Revision 1.65 2003/09/03 15:55:01 peter
  994. * NEWRA branch merged
  995. Revision 1.64 2003/09/03 11:18:37 florian
  996. * fixed arm concatcopy
  997. + arm support in the common compiler sources added
  998. * moved some generic cg code around
  999. + tfputype added
  1000. * ...
  1001. Revision 1.63 2003/08/10 17:25:23 peter
  1002. * fixed some reported bugs
  1003. Revision 1.62 2003/05/26 21:17:17 peter
  1004. * procinlinenode removed
  1005. * aktexit2label removed, fast exit removed
  1006. + tcallnode.inlined_pass_2 added
  1007. Revision 1.61 2003/05/13 19:14:41 peter
  1008. * failn removed
  1009. * inherited result code check moven to pexpr
  1010. Revision 1.60 2003/05/11 21:37:03 peter
  1011. * moved implicit exception frame from ncgutil to psub
  1012. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1013. Revision 1.59 2003/05/09 17:47:02 peter
  1014. * self moved to hidden parameter
  1015. * removed hdisposen,hnewn,selfn
  1016. Revision 1.58 2003/04/25 20:59:33 peter
  1017. * removed funcretn,funcretsym, function result is now in varsym
  1018. and aliases for result and function name are added using absolutesym
  1019. * vs_hidden parameter for funcret passed in parameter
  1020. * vs_hidden fixes
  1021. * writenode changed to printnode and released from extdebug
  1022. * -vp option added to generate a tree.log with the nodetree
  1023. * nicer printnode for statements, callnode
  1024. Revision 1.57 2002/04/25 20:15:39 florian
  1025. * block nodes within expressions shouldn't release the used registers,
  1026. fixed using a flag till the new rg is ready
  1027. Revision 1.56 2003/04/24 22:29:58 florian
  1028. * fixed a lot of PowerPC related stuff
  1029. Revision 1.55 2003/04/23 10:12:14 peter
  1030. * allow multi pass2 changed to global boolean instead of node flag
  1031. Revision 1.54 2003/04/22 23:50:23 peter
  1032. * firstpass uses expectloc
  1033. * checks if there are differences between the expectloc and
  1034. location.loc from secondpass in EXTDEBUG
  1035. Revision 1.53 2003/04/22 09:52:00 peter
  1036. * mark_write implemented for default with a warning in EXTDEBUG, this
  1037. is required for error recovery where the left node can be also a non
  1038. writable node
  1039. Revision 1.52 2003/04/10 17:57:52 peter
  1040. * vs_hidden released
  1041. Revision 1.51 2003/03/28 19:16:56 peter
  1042. * generic constructor working for i386
  1043. * remove fixed self register
  1044. * esi added as address register for i386
  1045. Revision 1.50 2003/03/17 16:54:41 peter
  1046. * support DefaultHandler and anonymous inheritance fixed
  1047. for message methods
  1048. Revision 1.49 2003/01/04 15:54:03 daniel
  1049. * Fixed mark_write for @ operator
  1050. (can happen when compiling @procvar:=nil (Delphi mode construction))
  1051. Revision 1.48 2003/01/03 21:03:02 peter
  1052. * made mark_write dummy instead of abstract
  1053. Revision 1.47 2003/01/03 12:15:56 daniel
  1054. * Removed ifdefs around notifications
  1055. ifdefs around for loop optimizations remain
  1056. Revision 1.46 2002/12/26 18:24:33 jonas
  1057. * fixed check for whether or not a high parameter was already generated
  1058. * no type checking/conversions for invisible parameters
  1059. Revision 1.45 2002/11/28 11:17:04 florian
  1060. * loop node flags from node flags splitted
  1061. Revision 1.44 2002/10/05 00:48:57 peter
  1062. * support inherited; support for overload as it is handled by
  1063. delphi. This is only for delphi mode as it is working is
  1064. undocumented and hard to predict what is done
  1065. Revision 1.43 2002/09/07 15:25:03 peter
  1066. * old logs removed and tabs fixed
  1067. Revision 1.42 2002/09/03 16:26:26 daniel
  1068. * Make Tprocdef.defs protected
  1069. Revision 1.41 2002/09/01 13:28:38 daniel
  1070. - write_access fields removed in favor of a flag
  1071. Revision 1.40 2002/09/01 08:01:16 daniel
  1072. * Removed sets from Tcallnode.det_resulttype
  1073. + Added read/write notifications of variables. These will be usefull
  1074. for providing information for several optimizations. For example
  1075. the value of the loop variable of a for loop does matter is the
  1076. variable is read after the for loop, but if it's no longer used
  1077. or written, it doesn't matter and this can be used to optimize
  1078. the loop code generation.
  1079. Revision 1.39 2002/08/22 11:21:45 florian
  1080. + register32 is now written by tnode.dowrite
  1081. * fixed write of value of tconstnode
  1082. Revision 1.38 2002/08/19 19:36:44 peter
  1083. * More fixes for cross unit inlining, all tnodes are now implemented
  1084. * Moved pocall_internconst to po_internconst because it is not a
  1085. calling type at all and it conflicted when inlining of these small
  1086. functions was requested
  1087. Revision 1.37 2002/08/18 20:06:24 peter
  1088. * inlining is now also allowed in interface
  1089. * renamed write/load to ppuwrite/ppuload
  1090. * tnode storing in ppu
  1091. * nld,ncon,nbas are already updated for storing in ppu
  1092. Revision 1.36 2002/08/17 22:09:46 florian
  1093. * result type handling in tcgcal.pass_2 overhauled
  1094. * better tnode.dowrite
  1095. * some ppc stuff fixed
  1096. Revision 1.35 2002/08/15 19:10:35 peter
  1097. * first things tai,tnode storing in ppu
  1098. Revision 1.34 2002/08/09 19:15:41 carl
  1099. - removed newcg define
  1100. Revision 1.33 2002/07/23 12:34:30 daniel
  1101. * Readded old set code. To use it define 'oldset'. Activated by default
  1102. for ppc.
  1103. Revision 1.32 2002/07/22 11:48:04 daniel
  1104. * Sets are now internally sets.
  1105. Revision 1.31 2002/07/21 06:58:49 daniel
  1106. * Changed booleans into flags
  1107. Revision 1.30 2002/07/19 11:41:36 daniel
  1108. * State tracker work
  1109. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1110. allows the state tracker to change while nodes automatically into
  1111. repeat nodes.
  1112. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1113. 'not(a>b)' is optimized into 'a<=b'.
  1114. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1115. by removing the notn and later switchting the true and falselabels. The
  1116. same is done with 'repeat until not a'.
  1117. Revision 1.29 2002/07/14 18:00:44 daniel
  1118. + Added the beginning of a state tracker. This will track the values of
  1119. variables through procedures and optimize things away.
  1120. Revision 1.28 2002/07/01 18:46:24 peter
  1121. * internal linker
  1122. * reorganized aasm layer
  1123. Revision 1.27 2002/05/18 13:34:10 peter
  1124. * readded missing revisions
  1125. Revision 1.26 2002/05/16 19:46:39 carl
  1126. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1127. + try to fix temp allocation (still in ifdef)
  1128. + generic constructor calls
  1129. + start of tassembler / tmodulebase class cleanup
  1130. Revision 1.24 2002/04/21 19:02:04 peter
  1131. * removed newn and disposen nodes, the code is now directly
  1132. inlined from pexpr
  1133. * -an option that will write the secondpass nodes to the .s file, this
  1134. requires EXTDEBUG define to actually write the info
  1135. * fixed various internal errors and crashes due recent code changes
  1136. Revision 1.23 2002/04/06 18:13:01 jonas
  1137. * several powerpc-related additions and fixes
  1138. Revision 1.22 2002/03/31 20:26:35 jonas
  1139. + a_loadfpu_* and a_loadmm_* methods in tcg
  1140. * register allocation is now handled by a class and is mostly processor
  1141. independent (+rgobj.pas and i386/rgcpu.pas)
  1142. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  1143. * some small improvements and fixes to the optimizer
  1144. * some register allocation fixes
  1145. * some fpuvaroffset fixes in the unary minus node
  1146. * push/popusedregisters is now called rg.save/restoreusedregisters and
  1147. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  1148. also better optimizable)
  1149. * fixed and optimized register saving/restoring for new/dispose nodes
  1150. * LOC_FPU locations now also require their "register" field to be set to
  1151. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  1152. - list field removed of the tnode class because it's not used currently
  1153. and can cause hard-to-find bugs
  1154. }