node.pas 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  1. {
  2. Copyright (c) 2000-2002 by Florian Klaempfl
  3. Basic node handling
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit node;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. globtype,globals,cgbase,cgutils,
  23. symtype,
  24. optbase;
  25. type
  26. tnodetype = (
  27. emptynode, {No node (returns nil when loading from ppu)}
  28. addn, {Represents the + operator}
  29. muln, {Represents the * operator}
  30. subn, {Represents the - operator}
  31. divn, {Represents the div operator}
  32. symdifn, {Represents the >< operator}
  33. modn, {Represents the mod operator}
  34. assignn, {Represents an assignment}
  35. loadn, {Represents the use of a variabele}
  36. rangen, {Represents a range (i.e. 0..9)}
  37. ltn, {Represents the < operator}
  38. lten, {Represents the <= operator}
  39. gtn, {Represents the > operator}
  40. gten, {Represents the >= operator}
  41. equaln, {Represents the = operator}
  42. unequaln, {Represents the <> operator}
  43. inn, {Represents the in operator}
  44. orn, {Represents the or operator}
  45. xorn, {Represents the xor operator}
  46. shrn, {Represents the shr operator}
  47. shln, {Represents the shl operator}
  48. slashn, {Represents the / operator}
  49. andn, {Represents the and operator}
  50. subscriptn, {Field in a record/object}
  51. derefn, {Dereferences a pointer}
  52. addrn, {Represents the @ operator}
  53. ordconstn, {Represents an ordinal value}
  54. typeconvn, {Represents type-conversion/typecast}
  55. calln, {Represents a call node}
  56. callparan, {Represents a parameter}
  57. realconstn, {Represents a real value}
  58. unaryminusn, {Represents a sign change (i.e. -2)}
  59. unaryplusn, {Represents a check for +Value}
  60. asmn, {Represents an assembler node }
  61. vecn, {Represents array indexing}
  62. pointerconstn, {Represents a pointer constant}
  63. stringconstn, {Represents a string constant}
  64. notn, {Represents the not operator}
  65. inlinen, {Internal procedures (i.e. writeln)}
  66. niln, {Represents the nil pointer}
  67. errorn, {This part of the tree could not be
  68. parsed because of a compiler error}
  69. typen, {A type name. Used for i.e. typeof(obj)}
  70. setelementn, {A set element(s) (i.e. [a,b] and also [a..b])}
  71. setconstn, {A set constant (i.e. [1,2])}
  72. blockn, {A block of statements}
  73. statementn, {One statement in a block of nodes}
  74. ifn, {An if statement}
  75. breakn, {A break statement}
  76. continuen, {A continue statement}
  77. whilerepeatn, {A while or repeat statement}
  78. forn, {A for loop}
  79. exitn, {An exit statement}
  80. casen, {A case statement}
  81. labeln, {A label}
  82. goton, {A goto statement}
  83. tryexceptn, {A try except block}
  84. raisen, {A raise statement}
  85. tryfinallyn, {A try finally statement}
  86. onn, {For an on statement in exception code}
  87. isn, {Represents the is operator}
  88. asn, {Represents the as typecast}
  89. starstarn, {Represents the ** operator exponentiation }
  90. arrayconstructorn, {Construction node for [...] parsing}
  91. arrayconstructorrangen, {Range element to allow sets in array construction tree}
  92. tempcreaten, { for temps in the result/firstpass }
  93. temprefn, { references to temps }
  94. tempdeleten, { for temps in the result/firstpass }
  95. addoptn, { added for optimizations where we cannot suppress }
  96. nothingn, { NOP, Do nothing}
  97. loadvmtaddrn, { Load the address of the VMT of a class/object}
  98. guidconstn, { A GUID COM Interface constant }
  99. rttin, { Rtti information so they can be accessed in result/firstpass}
  100. loadparentfpn, { Load the framepointer of the parent for nested procedures }
  101. objcselectorn, { node for an Objective-C message selector }
  102. objcprotocoln, { node for an Objective-C @protocol() expression (returns metaclass associated with protocol) }
  103. specializen, { parser-only node to handle Delphi-mode inline specializations }
  104. finalizetempsn { Internal node used to clean up code generator temps (warning: must NOT create additional tepms that may need to be finalised!) }
  105. );
  106. tnodetypeset = set of tnodetype;
  107. pnodetypeset = ^tnodetypeset;
  108. const
  109. nodetype2str : array[tnodetype] of string[24] = (
  110. '<emptynode>',
  111. 'addn',
  112. 'muln',
  113. 'subn',
  114. 'divn',
  115. 'symdifn',
  116. 'modn',
  117. 'assignn',
  118. 'loadn',
  119. 'rangen',
  120. 'ltn',
  121. 'lten',
  122. 'gtn',
  123. 'gten',
  124. 'equaln',
  125. 'unequaln',
  126. 'inn',
  127. 'orn',
  128. 'xorn',
  129. 'shrn',
  130. 'shln',
  131. 'slashn',
  132. 'andn',
  133. 'subscriptn',
  134. 'derefn',
  135. 'addrn',
  136. 'ordconstn',
  137. 'typeconvn',
  138. 'calln',
  139. 'callparan',
  140. 'realconstn',
  141. 'unaryminusn',
  142. 'unaryplusn',
  143. 'asmn',
  144. 'vecn',
  145. 'pointerconstn',
  146. 'stringconstn',
  147. 'notn',
  148. 'inlinen',
  149. 'niln',
  150. 'errorn',
  151. 'typen',
  152. 'setelementn',
  153. 'setconstn',
  154. 'blockn',
  155. 'statementn',
  156. 'ifn',
  157. 'breakn',
  158. 'continuen',
  159. 'whilerepeatn',
  160. 'forn',
  161. 'exitn',
  162. 'casen',
  163. 'labeln',
  164. 'goton',
  165. 'tryexceptn',
  166. 'raisen',
  167. 'tryfinallyn',
  168. 'onn',
  169. 'isn',
  170. 'asn',
  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. 'objcselectorn',
  184. 'objcprotocoln',
  185. 'specializen',
  186. 'finalizetempsn');
  187. { a set containing all const nodes }
  188. nodetype_const = [niln,
  189. ordconstn,
  190. pointerconstn,
  191. stringconstn,
  192. guidconstn,
  193. realconstn,
  194. setconstn];
  195. type
  196. { all boolean field of ttree are now collected in flags }
  197. tnodeflag = (
  198. { tbinop operands can be swaped }
  199. nf_swapable,
  200. { tbinop operands are swaped }
  201. nf_swapped,
  202. nf_error,
  203. { general }
  204. nf_pass1_done,
  205. { Node is written to }
  206. nf_write,
  207. { Node is modified }
  208. nf_modify,
  209. { address of node is taken }
  210. nf_address_taken,
  211. nf_is_funcret,
  212. nf_isproperty,
  213. nf_processing,
  214. { Node cannot be assigned to }
  215. nf_no_lvalue,
  216. { this node is the user code entry, if a node with this flag is removed
  217. during simplify, the flag must be moved to another node }
  218. nf_usercode_entry,
  219. { tderefnode }
  220. nf_no_checkpointer,
  221. { tvecnode }
  222. nf_memindex,
  223. nf_memseg,
  224. nf_callunique,
  225. { tloadnode/ttypeconvnode }
  226. nf_absolute,
  227. { taddnode }
  228. { if the result type of a node is currency, then this flag denotes, that the value is already mulitplied by 10000 }
  229. nf_is_currency,
  230. nf_has_pointerdiv,
  231. { the node shall be short boolean evaluated, this flag has priority over localswitches }
  232. nf_short_bool,
  233. { tmoddivnode }
  234. nf_isomod,
  235. { tassignmentnode }
  236. nf_assign_done_in_right,
  237. { tarrayconstructnode }
  238. nf_forcevaria,
  239. nf_novariaallowed,
  240. { ttypeconvnode, and the first one also treal/ord/pointerconstn }
  241. { second one also for subtractions of u32-u32 implicitly upcasted to s64 }
  242. { last one also used on addnode to inhibit procvar calling }
  243. nf_explicit,
  244. nf_internal, { no warnings/hints generated }
  245. nf_load_procvar,
  246. { tinlinenode }
  247. nf_inlineconst,
  248. { tasmnode }
  249. nf_get_asm_position,
  250. { tblocknode }
  251. nf_block_with_exit,
  252. { tloadvmtaddrnode }
  253. nf_ignore_for_wpo, { we know that this loadvmtaddrnode cannot be used to construct a class instance }
  254. { node is derived from generic parameter }
  255. nf_generic_para
  256. { WARNING: there are now 32 elements in this type, and a set of this
  257. type is written to the PPU. So before adding more elements,
  258. either move some flags to specific nodes, or stream a normalset
  259. to the ppu
  260. }
  261. );
  262. tnodeflags = set of tnodeflag;
  263. const
  264. { contains the flags which must be equal for the equality }
  265. { of nodes }
  266. flagsequal : tnodeflags = [nf_error];
  267. type
  268. tnodelist = class
  269. end;
  270. pnode = ^tnode;
  271. { basic class for the intermediated representation fpc uses }
  272. tnode = class
  273. private
  274. fppuidx : longint;
  275. function getppuidx:longint;
  276. public
  277. { type of this node }
  278. nodetype : tnodetype;
  279. { type of the current code block, general/const/type }
  280. blocktype : tblock_type;
  281. { expected location of the result of this node (pass1) }
  282. expectloc : tcgloc;
  283. { the location of the result of this node (pass2) }
  284. location : tlocation;
  285. { next node in control flow on the same block level, i.e.
  286. for loop nodes, this is the next node after the end of the loop,
  287. same for if and case, if this field is nil, the next node is the procedure exit,
  288. for the last node in a loop this is set to the loop header
  289. this field is set only for control flow nodes }
  290. successor : tnode;
  291. { there are some properties about the node stored }
  292. flags : tnodeflags;
  293. resultdef : tdef;
  294. resultdefderef : tderef;
  295. fileinfo : tfileposinfo;
  296. localswitches : tlocalswitches;
  297. verbosity : longint;
  298. optinfo : poptinfo;
  299. constructor create(t:tnodetype);
  300. { this constructor is only for creating copies of class }
  301. { the fields are copied by getcopy }
  302. constructor createforcopy;
  303. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);virtual;
  304. destructor destroy;override;
  305. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  306. procedure buildderefimpl;virtual;
  307. procedure derefimpl;virtual;
  308. procedure resolveppuidx;virtual;
  309. { toggles the flag }
  310. procedure toggleflag(f : tnodeflag);
  311. { the 1.1 code generator may override pass_1 }
  312. { and it need not to implement det_* then }
  313. { 1.1: pass_1 returns a value<>0 if the node has been transformed }
  314. { 2.0: runs pass_typecheck and det_temp }
  315. function pass_1 : tnode;virtual;abstract;
  316. { dermines the resultdef of the node }
  317. function pass_typecheck : tnode;virtual;abstract;
  318. { tries to simplify the node, returns a value <>nil if a simplified
  319. node has been created }
  320. function simplify(forinline : boolean) : tnode;virtual;
  321. {$ifdef state_tracking}
  322. { Does optimizations by keeping track of the variable states
  323. in a procedure }
  324. function track_state_pass(exec_known:boolean):boolean;virtual;
  325. {$endif}
  326. { For a t1:=t2 tree, mark the part of the tree t1 that gets
  327. written to (normally the loadnode) as write access. }
  328. procedure mark_write;virtual;
  329. { dermines the number of necessary temp. locations to evaluate
  330. the node }
  331. procedure det_temp;virtual;abstract;
  332. procedure pass_generate_code;virtual;abstract;
  333. { comparing of nodes }
  334. function isequal(p : tnode) : boolean;
  335. { to implement comparisation, override this method }
  336. function docompare(p : tnode) : boolean;virtual;
  337. { wrapper for getcopy }
  338. function getcopy : tnode;
  339. { does the real copying of a node }
  340. function dogetcopy : tnode;virtual;
  341. procedure insertintolist(l : tnodelist);virtual;
  342. { writes a node for debugging purpose, shouldn't be called }
  343. { direct, because there is no test for nil, use printnode }
  344. { to write a complete tree }
  345. procedure printnodeinfo(var t:text);virtual;
  346. procedure printnodedata(var t:text);virtual;
  347. procedure printnodetree(var t:text);virtual;
  348. {$ifdef DEBUG_NODE_XML}
  349. { For writing nodes to XML files - do not call directly, but
  350. instead call XMLPrintNode to write a complete tree }
  351. procedure XMLPrintNodeInfo(var T: Text); dynamic;
  352. procedure XMLPrintNodeData(var T: Text); virtual;
  353. procedure XMLPrintNodeTree(var T: Text); virtual;
  354. {$endif DEBUG_NODE_XML}
  355. function ischild(p : tnode) : boolean;virtual;
  356. { ensures that the optimizer info record is allocated }
  357. function allocoptinfo : poptinfo;inline;
  358. property ppuidx:longint read getppuidx;
  359. end;
  360. tnodeclass = class of tnode;
  361. tnodeclassarray = array[tnodetype] of tnodeclass;
  362. { this node is the anchestor for all nodes with at least }
  363. { one child, you have to use it if you want to use }
  364. { true- and current_procinfo.CurrFalseLabel }
  365. //punarynode = ^tunarynode;
  366. tunarynode = class(tnode)
  367. left : tnode;
  368. constructor create(t:tnodetype;l : tnode);
  369. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  370. destructor destroy;override;
  371. procedure ppuwrite(ppufile:tcompilerppufile);override;
  372. procedure buildderefimpl;override;
  373. procedure derefimpl;override;
  374. function ischild(p : tnode) : boolean;override;
  375. function docompare(p : tnode) : boolean;override;
  376. function dogetcopy : tnode;override;
  377. procedure insertintolist(l : tnodelist);override;
  378. procedure printnodedata(var t:text);override;
  379. {$ifdef DEBUG_NODE_XML}
  380. procedure XMLPrintNodeData(var T: Text); override;
  381. {$endif DEBUG_NODE_XML}
  382. end;
  383. //pbinarynode = ^tbinarynode;
  384. tbinarynode = class(tunarynode)
  385. right : tnode;
  386. constructor create(t:tnodetype;l,r : tnode);
  387. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  388. destructor destroy;override;
  389. procedure ppuwrite(ppufile:tcompilerppufile);override;
  390. procedure buildderefimpl;override;
  391. procedure derefimpl;override;
  392. function ischild(p : tnode) : boolean;override;
  393. function docompare(p : tnode) : boolean;override;
  394. procedure swapleftright;
  395. function dogetcopy : tnode;override;
  396. procedure insertintolist(l : tnodelist);override;
  397. procedure printnodedata(var t:text);override;
  398. {$ifdef DEBUG_NODE_XML}
  399. procedure XMLPrintNodeTree(var T: Text); override;
  400. procedure XMLPrintNodeData(var T: Text); override;
  401. {$endif DEBUG_NODE_XML}
  402. procedure printnodelist(var t:text);
  403. end;
  404. //ptertiarynode = ^ttertiarynode;
  405. ttertiarynode = class(tbinarynode)
  406. third : tnode;
  407. constructor create(_t:tnodetype;l,r,t : tnode);
  408. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  409. destructor destroy;override;
  410. procedure ppuwrite(ppufile:tcompilerppufile);override;
  411. procedure buildderefimpl;override;
  412. procedure derefimpl;override;
  413. function ischild(p : tnode) : boolean;override;
  414. function docompare(p : tnode) : boolean;override;
  415. function dogetcopy : tnode;override;
  416. procedure insertintolist(l : tnodelist);override;
  417. procedure printnodedata(var t:text);override;
  418. {$ifdef DEBUG_NODE_XML}
  419. procedure XMLPrintNodeData(var T: Text); override;
  420. {$endif DEBUG_NODE_XML}
  421. end;
  422. tbinopnode = class(tbinarynode)
  423. constructor create(t:tnodetype;l,r : tnode);virtual;
  424. function docompare(p : tnode) : boolean;override;
  425. {$ifdef DEBUG_NODE_XML}
  426. procedure XMLPrintNodeData(var T: Text); override;
  427. {$endif DEBUG_NODE_XML}
  428. end;
  429. var
  430. { array with all class types for tnodes }
  431. nodeclass : tnodeclassarray;
  432. function nodeppuidxget(i:longint):tnode;
  433. function ppuloadnode(ppufile:tcompilerppufile):tnode;
  434. procedure ppuwritenode(ppufile:tcompilerppufile;n:tnode);
  435. function ppuloadnodetree(ppufile:tcompilerppufile):tnode;
  436. procedure ppuwritenodetree(ppufile:tcompilerppufile;n:tnode);
  437. procedure printnode(var t:text;n:tnode);
  438. procedure printnode(n:tnode);
  439. {$ifdef DEBUG_NODE_XML}
  440. procedure XMLPrintNode(var T: Text; N: TNode);
  441. {$endif DEBUG_NODE_XML}
  442. function is_constnode(p : tnode) : boolean;
  443. function is_constintnode(p : tnode) : boolean;
  444. function is_constcharnode(p : tnode) : boolean;
  445. function is_constrealnode(p : tnode) : boolean;
  446. function is_constboolnode(p : tnode) : boolean;
  447. function is_constenumnode(p : tnode) : boolean;
  448. function is_constwidecharnode(p : tnode) : boolean;
  449. function is_constpointernode(p : tnode) : boolean;
  450. function is_conststringnode(p : tnode) : boolean;
  451. function is_constwidestringnode(p : tnode) : boolean;
  452. function is_conststring_or_constcharnode(p : tnode) : boolean;
  453. implementation
  454. uses
  455. verbose,entfile,comphook,
  456. {$ifdef DEBUG_NODE_XML}
  457. cutils,
  458. {$endif DEBUG_NODE_XML}
  459. ppu,
  460. symconst,
  461. nutils,nflw,
  462. defutil;
  463. const
  464. ppunodemarker = 255;
  465. {****************************************************************************
  466. Helpers
  467. ****************************************************************************}
  468. var
  469. nodeppulist : TFPObjectList;
  470. nodeppuidx : longint;
  471. procedure nodeppuidxcreate;
  472. begin
  473. nodeppulist:=TFPObjectList.Create(false);
  474. nodeppuidx:=0;
  475. end;
  476. procedure nodeppuidxresolve;
  477. var
  478. i : longint;
  479. n : tnode;
  480. begin
  481. for i:=0 to nodeppulist.count-1 do
  482. begin
  483. n:=tnode(nodeppulist[i]);
  484. if assigned(n) then
  485. n.resolveppuidx;
  486. end;
  487. end;
  488. procedure nodeppuidxfree;
  489. begin
  490. nodeppulist.free;
  491. nodeppulist:=nil;
  492. nodeppuidx:=0;
  493. end;
  494. procedure nodeppuidxadd(n:tnode);
  495. var
  496. i : longint;
  497. begin
  498. i:=n.ppuidx;
  499. if i<=0 then
  500. internalerror(200311072);
  501. if i>=nodeppulist.capacity then
  502. nodeppulist.capacity:=((i div 1024)+1)*1024;
  503. if i>=nodeppulist.count then
  504. nodeppulist.count:=i+1;
  505. nodeppulist[i]:=n;
  506. end;
  507. function nodeppuidxget(i:longint):tnode;
  508. begin
  509. if i<=0 then
  510. internalerror(200311073);
  511. result:=tnode(nodeppulist[i]);
  512. end;
  513. function ppuloadnode(ppufile:tcompilerppufile):tnode;
  514. var
  515. b : byte;
  516. t : tnodetype;
  517. hppuidx : longint;
  518. begin
  519. { marker }
  520. b:=ppufile.getbyte;
  521. if b<>ppunodemarker then
  522. internalerror(200208151);
  523. { load nodetype }
  524. t:=tnodetype(ppufile.getbyte);
  525. if t>high(tnodetype) then
  526. internalerror(200208152);
  527. if t<>emptynode then
  528. begin
  529. if not assigned(nodeclass[t]) then
  530. internalerror(200208153);
  531. hppuidx:=ppufile.getlongint;
  532. //writeln('load: ',nodetype2str[t]);
  533. { generate node of the correct class }
  534. result:=nodeclass[t].ppuload(t,ppufile);
  535. result.fppuidx:=hppuidx;
  536. nodeppuidxadd(result);
  537. end
  538. else
  539. result:=nil;
  540. end;
  541. procedure ppuwritenode(ppufile:tcompilerppufile;n:tnode);
  542. begin
  543. { marker, read by ppuloadnode }
  544. ppufile.putbyte(ppunodemarker);
  545. { type, read by ppuloadnode }
  546. if assigned(n) then
  547. begin
  548. ppufile.putbyte(byte(n.nodetype));
  549. ppufile.putlongint(n.ppuidx);
  550. //writeln('write: ',nodetype2str[n.nodetype]);
  551. n.ppuwrite(ppufile);
  552. end
  553. else
  554. ppufile.putbyte(byte(emptynode));
  555. end;
  556. function ppuloadnodetree(ppufile:tcompilerppufile):tnode;
  557. begin
  558. if ppufile.readentry<>ibnodetree then
  559. Message(unit_f_ppu_read_error);
  560. nodeppuidxcreate;
  561. result:=ppuloadnode(ppufile);
  562. nodeppuidxresolve;
  563. nodeppuidxfree;
  564. end;
  565. procedure ppuwritenodetree(ppufile:tcompilerppufile;n:tnode);
  566. begin
  567. nodeppuidxcreate;
  568. ppuwritenode(ppufile,n);
  569. ppufile.writeentry(ibnodetree);
  570. nodeppuidxfree;
  571. end;
  572. procedure printnode(var t:text;n:tnode);
  573. begin
  574. if assigned(n) then
  575. n.printnodetree(t)
  576. else
  577. writeln(t,printnodeindention,'nil');
  578. end;
  579. procedure printnode(n:tnode);
  580. begin
  581. printnode(output,n);
  582. end;
  583. {$ifdef DEBUG_NODE_XML}
  584. procedure XMLPrintNode(var T: Text; N: TNode);
  585. begin
  586. if Assigned(N) then
  587. N.XMLPrintNodeTree(T);
  588. end;
  589. {$endif DEBUG_NODE_XML}
  590. function is_constnode(p : tnode) : boolean;
  591. begin
  592. is_constnode:=(p.nodetype in nodetype_const);
  593. end;
  594. function is_constintnode(p : tnode) : boolean;
  595. begin
  596. is_constintnode:=(p.nodetype=ordconstn) and is_integer(p.resultdef);
  597. end;
  598. function is_constcharnode(p : tnode) : boolean;
  599. begin
  600. is_constcharnode:=(p.nodetype=ordconstn) and is_char(p.resultdef);
  601. end;
  602. function is_constwidecharnode(p : tnode) : boolean;
  603. begin
  604. is_constwidecharnode:=(p.nodetype=ordconstn) and is_widechar(p.resultdef);
  605. end;
  606. function is_constrealnode(p : tnode) : boolean;
  607. begin
  608. is_constrealnode:=(p.nodetype=realconstn);
  609. end;
  610. function is_constboolnode(p : tnode) : boolean;
  611. begin
  612. is_constboolnode:=(p.nodetype=ordconstn) and is_boolean(p.resultdef);
  613. end;
  614. function is_constenumnode(p : tnode) : boolean;
  615. begin
  616. is_constenumnode:=(p.nodetype=ordconstn) and (p.resultdef.typ=enumdef);
  617. end;
  618. function is_constpointernode(p : tnode) : boolean;
  619. begin
  620. is_constpointernode:=(p.nodetype in [pointerconstn,niln]);
  621. end;
  622. function is_conststringnode(p : tnode) : boolean;
  623. begin
  624. is_conststringnode :=
  625. (p.nodetype = stringconstn) and
  626. (is_chararray(p.resultdef) or
  627. is_shortstring(p.resultdef) or
  628. is_ansistring(p.resultdef));
  629. end;
  630. function is_constwidestringnode(p : tnode) : boolean;
  631. begin
  632. is_constwidestringnode :=
  633. (p.nodetype = stringconstn) and
  634. (is_widechararray(p.resultdef) or
  635. is_wide_or_unicode_string(p.resultdef));
  636. end;
  637. function is_conststring_or_constcharnode(p : tnode) : boolean;
  638. begin
  639. is_conststring_or_constcharnode :=
  640. is_conststringnode(p) or is_constcharnode(p) or
  641. is_constwidestringnode(p) or is_constwidecharnode(p);
  642. end;
  643. {****************************************************************************
  644. TNODE
  645. ****************************************************************************}
  646. constructor tnode.create(t:tnodetype);
  647. begin
  648. inherited create;
  649. nodetype:=t;
  650. blocktype:=block_type;
  651. { updated by firstpass }
  652. expectloc:=LOC_INVALID;
  653. { updated by secondpass }
  654. location.loc:=LOC_INVALID;
  655. { save local info }
  656. fileinfo:=current_filepos;
  657. localswitches:=current_settings.localswitches;
  658. verbosity:=status.verbosity;
  659. resultdef:=nil;
  660. flags:=[];
  661. end;
  662. constructor tnode.createforcopy;
  663. begin
  664. end;
  665. constructor tnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  666. begin
  667. nodetype:=t;
  668. { tnode fields }
  669. blocktype:=tblock_type(ppufile.getbyte);
  670. ppufile.getposinfo(fileinfo);
  671. ppufile.getset(tppuset5(localswitches));
  672. verbosity:=ppufile.getlongint;
  673. ppufile.getderef(resultdefderef);
  674. ppufile.getset(tppuset4(flags));
  675. { updated by firstpass }
  676. expectloc:=LOC_INVALID;
  677. { updated by secondpass }
  678. location.loc:=LOC_INVALID;
  679. end;
  680. procedure tnode.ppuwrite(ppufile:tcompilerppufile);
  681. begin
  682. ppufile.putbyte(byte(block_type));
  683. ppufile.putposinfo(fileinfo);
  684. ppufile.putset(tppuset5(localswitches));
  685. ppufile.putlongint(verbosity);
  686. ppufile.putderef(resultdefderef);
  687. ppufile.putset(tppuset4(flags));
  688. end;
  689. function tnode.getppuidx:longint;
  690. begin
  691. if fppuidx=0 then
  692. begin
  693. inc(nodeppuidx);
  694. fppuidx:=nodeppuidx;
  695. end;
  696. result:=fppuidx;
  697. end;
  698. procedure tnode.resolveppuidx;
  699. begin
  700. end;
  701. procedure tnode.buildderefimpl;
  702. begin
  703. resultdefderef.build(resultdef);
  704. end;
  705. procedure tnode.derefimpl;
  706. begin
  707. resultdef:=tdef(resultdefderef.resolve);
  708. end;
  709. procedure tnode.toggleflag(f : tnodeflag);
  710. begin
  711. if f in flags then
  712. exclude(flags,f)
  713. else
  714. include(flags,f);
  715. end;
  716. function tnode.simplify(forinline : boolean) : tnode;
  717. begin
  718. result:=nil;
  719. end;
  720. destructor tnode.destroy;
  721. begin
  722. if assigned(optinfo) then
  723. dispose(optinfo);
  724. end;
  725. function tnode.ischild(p : tnode) : boolean;
  726. begin
  727. ischild:=false;
  728. end;
  729. procedure tnode.mark_write;
  730. begin
  731. {$ifdef EXTDEBUG}
  732. Comment(V_Warning,'mark_write not implemented for '+nodetype2str[nodetype]);
  733. {$endif EXTDEBUG}
  734. end;
  735. procedure tnode.printnodeinfo(var t:text);
  736. var
  737. i : tnodeflag;
  738. first : boolean;
  739. begin
  740. write(t,nodetype2str[nodetype]);
  741. if assigned(resultdef) then
  742. write(t,', resultdef = ',resultdef.typesymbolprettyname,' = "',resultdef.GetTypeName,'"')
  743. else
  744. write(t,', resultdef = <nil>');
  745. write(t,', pos = (',fileinfo.line,',',fileinfo.column,')',
  746. ', loc = ',tcgloc2str[location.loc],
  747. ', expectloc = ',tcgloc2str[expectloc],
  748. ', flags = [');
  749. first:=true;
  750. for i:=low(tnodeflag) to high(tnodeflag) do
  751. if i in flags then
  752. begin
  753. if not(first) then
  754. write(t,',')
  755. else
  756. first:=false;
  757. write(t, i);
  758. end;
  759. write(t,']');
  760. if (nf_pass1_done in flags) then
  761. write(t,', cmplx = ',node_complexity(self));
  762. end;
  763. procedure tnode.printnodedata(var t:text);
  764. begin
  765. end;
  766. procedure tnode.printnodetree(var t:text);
  767. begin
  768. write(t,printnodeindention,'(');
  769. printnodeinfo(t);
  770. writeln(t);
  771. printnodeindent;
  772. printnodedata(t);
  773. printnodeunindent;
  774. writeln(t,printnodeindention,')');
  775. end;
  776. {$ifdef DEBUG_NODE_XML}
  777. { For writing nodes to XML files - do not call directly, but
  778. instead call XMLPrintNode to write a complete tree }
  779. procedure tnode.XMLPrintNodeInfo(var T: Text);
  780. var
  781. i: TNodeFlag;
  782. first: Boolean;
  783. begin
  784. if Assigned(resultdef) then
  785. Write(T,' resultdef="', SanitiseXMLString(resultdef.typesymbolprettyname), '"');
  786. Write(T,' pos="',fileinfo.line,',',fileinfo.column);
  787. First := True;
  788. for i := Low(TNodeFlag) to High(TNodeFlag) do
  789. if i in flags then
  790. begin
  791. if First then
  792. begin
  793. Write(T, '" flags="', i);
  794. First := False;
  795. end
  796. else
  797. Write(T, ',', i)
  798. end;
  799. write(t,'"');
  800. if (nf_pass1_done in flags) then
  801. write(t,' complexity="',node_complexity(self),'"');
  802. end;
  803. procedure tnode.XMLPrintNodeData(var T: Text);
  804. begin
  805. { Nothing by default }
  806. end;
  807. procedure tnode.XMLPrintNodeTree(var T: Text);
  808. begin
  809. Write(T, PrintNodeIndention, '<', nodetype2str[nodetype]);
  810. XMLPrintNodeInfo(T);
  811. WriteLn(T, '>');
  812. PrintNodeIndent;
  813. XMLPrintNodeData(T);
  814. PrintNodeUnindent;
  815. WriteLn(T, PrintNodeIndention, '</', nodetype2str[nodetype], '>');
  816. end;
  817. {$endif DEBUG_NODE_XML}
  818. function tnode.isequal(p : tnode) : boolean;
  819. begin
  820. isequal:=
  821. (not assigned(self) and not assigned(p)) or
  822. (assigned(self) and assigned(p) and
  823. { optimized subclasses have the same nodetype as their }
  824. { superclass (for compatibility), so also check the classtype (JM) }
  825. (p.classtype=classtype) and
  826. (p.nodetype=nodetype) and
  827. (flags*flagsequal=p.flags*flagsequal) and
  828. docompare(p));
  829. end;
  830. {$ifdef state_tracking}
  831. function Tnode.track_state_pass(exec_known:boolean):boolean;
  832. begin
  833. track_state_pass:=false;
  834. end;
  835. {$endif state_tracking}
  836. function tnode.docompare(p : tnode) : boolean;
  837. begin
  838. docompare:=true;
  839. end;
  840. function cleanupcopiedto(var n : tnode;arg : pointer) : foreachnoderesult;
  841. begin
  842. result:=fen_true;
  843. if n.nodetype=labeln then
  844. tlabelnode(n).copiedto:=nil;
  845. end;
  846. function setuplabelnode(var n : tnode;arg : pointer) : foreachnoderesult;
  847. begin
  848. result:=fen_true;
  849. if (n.nodetype=goton) and assigned(tgotonode(n).labelnode) and
  850. assigned(tgotonode(n).labelnode.copiedto) then
  851. tgotonode(n).labelnode:=tgotonode(n).labelnode.copiedto;
  852. end;
  853. function tnode.getcopy : tnode;
  854. begin
  855. result:=dogetcopy;
  856. foreachnodestatic(pm_postprocess,result,@setuplabelnode,nil);
  857. foreachnodestatic(pm_postprocess,self,@cleanupcopiedto,nil);
  858. end;
  859. function tnode.dogetcopy : tnode;
  860. var
  861. p : tnode;
  862. begin
  863. { this is quite tricky because we need a node of the current }
  864. { node type and not one of tnode! }
  865. p:=tnodeclass(classtype).createforcopy;
  866. p.nodetype:=nodetype;
  867. p.expectloc:=expectloc;
  868. p.location:=location;
  869. p.flags:=flags;
  870. p.resultdef:=resultdef;
  871. p.fileinfo:=fileinfo;
  872. p.localswitches:=localswitches;
  873. p.verbosity:=verbosity;
  874. { p.list:=list; }
  875. result:=p;
  876. end;
  877. procedure tnode.insertintolist(l : tnodelist);
  878. begin
  879. end;
  880. { ensures that the optimizer info record is allocated }
  881. function tnode.allocoptinfo : poptinfo;inline;
  882. begin
  883. if not(assigned(optinfo)) then
  884. begin
  885. new(optinfo);
  886. fillchar(optinfo^,sizeof(optinfo^),0);
  887. end;
  888. result:=optinfo;
  889. end;
  890. {****************************************************************************
  891. TUNARYNODE
  892. ****************************************************************************}
  893. constructor tunarynode.create(t:tnodetype;l : tnode);
  894. begin
  895. inherited create(t);
  896. { transfer generic paramater flag }
  897. if assigned(l) and (nf_generic_para in l.flags) then
  898. include(flags,nf_generic_para);
  899. left:=l;
  900. end;
  901. constructor tunarynode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  902. begin
  903. inherited ppuload(t,ppufile);
  904. left:=ppuloadnode(ppufile);
  905. end;
  906. destructor tunarynode.destroy;
  907. begin
  908. left.free;
  909. inherited destroy;
  910. end;
  911. procedure tunarynode.ppuwrite(ppufile:tcompilerppufile);
  912. begin
  913. inherited ppuwrite(ppufile);
  914. ppuwritenode(ppufile,left);
  915. end;
  916. procedure tunarynode.buildderefimpl;
  917. begin
  918. inherited buildderefimpl;
  919. if assigned(left) then
  920. left.buildderefimpl;
  921. end;
  922. procedure tunarynode.derefimpl;
  923. begin
  924. inherited derefimpl;
  925. if assigned(left) then
  926. left.derefimpl;
  927. end;
  928. function tunarynode.docompare(p : tnode) : boolean;
  929. begin
  930. docompare:=(inherited docompare(p) and
  931. ((left=nil) or left.isequal(tunarynode(p).left))
  932. );
  933. end;
  934. function tunarynode.dogetcopy : tnode;
  935. var
  936. p : tunarynode;
  937. begin
  938. p:=tunarynode(inherited dogetcopy);
  939. if assigned(left) then
  940. p.left:=left.dogetcopy
  941. else
  942. p.left:=nil;
  943. result:=p;
  944. end;
  945. procedure tunarynode.insertintolist(l : tnodelist);
  946. begin
  947. end;
  948. procedure tunarynode.printnodedata(var t:text);
  949. begin
  950. inherited printnodedata(t);
  951. printnode(t,left);
  952. end;
  953. {$ifdef DEBUG_NODE_XML}
  954. procedure TUnaryNode.XMLPrintNodeData(var T: Text);
  955. begin
  956. inherited XMLPrintNodeData(T);
  957. XMLPrintNode(T, Left);
  958. end;
  959. {$endif DEBUG_NODE_XML}
  960. function tunarynode.ischild(p : tnode) : boolean;
  961. begin
  962. ischild:=p=left;
  963. end;
  964. {****************************************************************************
  965. TBINARYNODE
  966. ****************************************************************************}
  967. constructor tbinarynode.create(t:tnodetype;l,r : tnode);
  968. begin
  969. inherited create(t,l);
  970. { transfer generic paramater flag }
  971. if assigned(r) and (nf_generic_para in r.flags) then
  972. include(flags,nf_generic_para);
  973. right:=r;
  974. end;
  975. constructor tbinarynode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  976. begin
  977. inherited ppuload(t,ppufile);
  978. right:=ppuloadnode(ppufile);
  979. end;
  980. destructor tbinarynode.destroy;
  981. begin
  982. right.free;
  983. inherited destroy;
  984. end;
  985. procedure tbinarynode.ppuwrite(ppufile:tcompilerppufile);
  986. begin
  987. inherited ppuwrite(ppufile);
  988. ppuwritenode(ppufile,right);
  989. end;
  990. procedure tbinarynode.buildderefimpl;
  991. begin
  992. inherited buildderefimpl;
  993. if assigned(right) then
  994. right.buildderefimpl;
  995. end;
  996. procedure tbinarynode.derefimpl;
  997. begin
  998. inherited derefimpl;
  999. if assigned(right) then
  1000. right.derefimpl;
  1001. end;
  1002. function tbinarynode.ischild(p : tnode) : boolean;
  1003. begin
  1004. ischild:=(p=right);
  1005. end;
  1006. function tbinarynode.docompare(p : tnode) : boolean;
  1007. begin
  1008. docompare:=(inherited docompare(p) and
  1009. ((right=nil) or right.isequal(tbinarynode(p).right))
  1010. );
  1011. end;
  1012. function tbinarynode.dogetcopy : tnode;
  1013. var
  1014. p : tbinarynode;
  1015. begin
  1016. p:=tbinarynode(inherited dogetcopy);
  1017. if assigned(right) then
  1018. p.right:=right.dogetcopy
  1019. else
  1020. p.right:=nil;
  1021. result:=p;
  1022. end;
  1023. procedure tbinarynode.insertintolist(l : tnodelist);
  1024. begin
  1025. end;
  1026. procedure tbinarynode.swapleftright;
  1027. var
  1028. swapp : tnode;
  1029. begin
  1030. swapp:=right;
  1031. right:=left;
  1032. left:=swapp;
  1033. if nf_swapped in flags then
  1034. exclude(flags,nf_swapped)
  1035. else
  1036. include(flags,nf_swapped);
  1037. end;
  1038. procedure tbinarynode.printnodedata(var t:text);
  1039. begin
  1040. inherited printnodedata(t);
  1041. printnode(t,right);
  1042. end;
  1043. {$ifdef DEBUG_NODE_XML}
  1044. procedure TBinaryNode.XMLPrintNodeTree(var T: Text);
  1045. begin
  1046. Write(T, PrintNodeIndention, '<', nodetype2str[nodetype]);
  1047. XMLPrintNodeInfo(T);
  1048. WriteLn(T, '>');
  1049. PrintNodeIndent;
  1050. XMLPrintNodeData(T);
  1051. end;
  1052. procedure TBinaryNode.XMLPrintNodeData(var T: Text);
  1053. begin
  1054. inherited XMLPrintNodeData(T);
  1055. PrintNodeUnindent;
  1056. WriteLn(T, PrintNodeIndention, '</', nodetype2str[nodetype], '>');
  1057. { Right nodes are on the same indentation level }
  1058. XMLPrintNode(T, Right);
  1059. end;
  1060. {$endif DEBUG_NODE_XML}
  1061. procedure tbinarynode.printnodelist(var t:text);
  1062. var
  1063. hp : tbinarynode;
  1064. begin
  1065. hp:=self;
  1066. while assigned(hp) do
  1067. begin
  1068. write(t,printnodeindention,'(');
  1069. printnodeindent;
  1070. hp.printnodeinfo(t);
  1071. writeln(t);
  1072. printnode(t,hp.left);
  1073. writeln(t);
  1074. printnodeunindent;
  1075. writeln(t,printnodeindention,')');
  1076. hp:=tbinarynode(hp.right);
  1077. end;
  1078. end;
  1079. {****************************************************************************
  1080. TTERTIARYNODE
  1081. ****************************************************************************}
  1082. constructor ttertiarynode.create(_t:tnodetype;l,r,t : tnode);
  1083. begin
  1084. inherited create(_t,l,r);
  1085. { transfer generic parameter flag }
  1086. if assigned(t) and (nf_generic_para in t.flags) then
  1087. include(flags,nf_generic_para);
  1088. third:=t;
  1089. end;
  1090. constructor ttertiarynode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1091. begin
  1092. inherited ppuload(t,ppufile);
  1093. third:=ppuloadnode(ppufile);
  1094. end;
  1095. destructor ttertiarynode.destroy;
  1096. begin
  1097. third.free;
  1098. inherited destroy;
  1099. end;
  1100. procedure ttertiarynode.ppuwrite(ppufile:tcompilerppufile);
  1101. begin
  1102. inherited ppuwrite(ppufile);
  1103. ppuwritenode(ppufile,third);
  1104. end;
  1105. procedure ttertiarynode.buildderefimpl;
  1106. begin
  1107. inherited buildderefimpl;
  1108. if assigned(third) then
  1109. third.buildderefimpl;
  1110. end;
  1111. procedure ttertiarynode.derefimpl;
  1112. begin
  1113. inherited derefimpl;
  1114. if assigned(third) then
  1115. third.derefimpl;
  1116. end;
  1117. function ttertiarynode.docompare(p : tnode) : boolean;
  1118. begin
  1119. docompare:=(inherited docompare(p) and
  1120. ((third=nil) or third.isequal(ttertiarynode(p).third))
  1121. );
  1122. end;
  1123. function ttertiarynode.dogetcopy : tnode;
  1124. var
  1125. p : ttertiarynode;
  1126. begin
  1127. p:=ttertiarynode(inherited dogetcopy);
  1128. if assigned(third) then
  1129. p.third:=third.dogetcopy
  1130. else
  1131. p.third:=nil;
  1132. result:=p;
  1133. end;
  1134. procedure ttertiarynode.insertintolist(l : tnodelist);
  1135. begin
  1136. end;
  1137. procedure ttertiarynode.printnodedata(var t:text);
  1138. begin
  1139. inherited printnodedata(t);
  1140. printnode(t,third);
  1141. end;
  1142. {$ifdef DEBUG_NODE_XML}
  1143. procedure TTertiaryNode.XMLPrintNodeData(var T: Text);
  1144. begin
  1145. if Assigned(Third) then
  1146. begin
  1147. WriteLn(T, PrintNodeIndention, '<third-branch>');
  1148. PrintNodeIndent;
  1149. XMLPrintNode(T, Third);
  1150. PrintNodeUnindent;
  1151. WriteLn(T, PrintNodeIndention, '</third-branch>');
  1152. end;
  1153. inherited XMLPrintNodeData(T);
  1154. end;
  1155. {$endif DEBUG_NODE_XML}
  1156. function ttertiarynode.ischild(p : tnode) : boolean;
  1157. begin
  1158. ischild:=p=third;
  1159. end;
  1160. {****************************************************************************
  1161. TBINOPNODE
  1162. ****************************************************************************}
  1163. constructor tbinopnode.create(t:tnodetype;l,r : tnode);
  1164. begin
  1165. inherited create(t,l,r);
  1166. end;
  1167. function tbinopnode.docompare(p : tnode) : boolean;
  1168. begin
  1169. docompare:=(inherited docompare(p)) or
  1170. { if that's in the flags, is p then always a tbinopnode (?) (JM) }
  1171. ((nf_swapable in flags) and
  1172. left.isequal(tbinopnode(p).right) and
  1173. right.isequal(tbinopnode(p).left));
  1174. end;
  1175. {$ifdef DEBUG_NODE_XML}
  1176. procedure TBinOpNode.XMLPrintNodeData(var T: Text);
  1177. begin
  1178. { For binary operations, put the left and right branches on the same level for clarity }
  1179. XMLPrintNode(T, Left);
  1180. XMLPrintNode(T, Right);
  1181. PrintNodeUnindent;
  1182. WriteLn(T, PrintNodeIndention, '</', nodetype2str[nodetype], '>');
  1183. end;
  1184. {$endif DEBUG_NODE_XML}
  1185. begin
  1186. {$push}{$warnings off}
  1187. { tvaroption must fit into a 4 byte set for speed reasons }
  1188. if ord(high(tvaroption))>31 then
  1189. internalerror(201110301);
  1190. { tnodeflags must fit into a 4 byte set for speed reasons }
  1191. if ord(high(tnodeflags))>31 then
  1192. internalerror(2014020701);
  1193. {$pop}
  1194. end.