nbas.pas 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. {
  2. Copyright (c) 2000-2002 by Florian Klaempfl
  3. This unit implements some basic nodes
  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 nbas;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. cgbase,cgutils,
  23. aasmtai,aasmdata,aasmcpu,
  24. node,
  25. symtype;
  26. type
  27. tnothingnode = class(tnode)
  28. constructor create;virtual;
  29. function pass_1 : tnode;override;
  30. function pass_typecheck:tnode;override;
  31. end;
  32. tnothingnodeclass = class of tnothingnode;
  33. terrornode = class(tnode)
  34. constructor create;virtual;
  35. function pass_1 : tnode;override;
  36. function pass_typecheck:tnode;override;
  37. procedure mark_write;override;
  38. end;
  39. terrornodeclass = class of terrornode;
  40. tspecializenode = class(tunarynode)
  41. sym:tsym;
  42. getaddr:boolean;
  43. constructor create(l:tnode;g:boolean;s:tsym);virtual;
  44. function pass_1:tnode;override;
  45. function pass_typecheck:tnode;override;
  46. end;
  47. tspecializenodeclass = class of tspecializenode;
  48. tasmnode = class(tnode)
  49. p_asm : TAsmList;
  50. currenttai : tai;
  51. { Used registers in assembler block }
  52. has_registerlist : boolean;
  53. constructor create(p : TAsmList);virtual;
  54. constructor create_get_position;
  55. destructor destroy;override;
  56. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  57. procedure ppuwrite(ppufile:tcompilerppufile);override;
  58. procedure buildderefimpl;override;
  59. procedure derefimpl;override;
  60. function dogetcopy : tnode;override;
  61. function pass_1 : tnode;override;
  62. function pass_typecheck:tnode;override;
  63. function docompare(p: tnode): boolean; override;
  64. end;
  65. tasmnodeclass = class of tasmnode;
  66. tstatementnode = class(tbinarynode)
  67. constructor create(l,r : tnode);virtual;
  68. function simplify(forinline : boolean) : tnode; override;
  69. function pass_1 : tnode;override;
  70. function pass_typecheck:tnode;override;
  71. procedure printnodetree(var t:text);override;
  72. property statement : tnode read left write left;
  73. property next : tnode read right write right;
  74. end;
  75. tstatementnodeclass = class of tstatementnode;
  76. tblocknode = class(tunarynode)
  77. constructor create(l : tnode);virtual;
  78. destructor destroy; override;
  79. function simplify(forinline : boolean) : tnode; override;
  80. function pass_1 : tnode;override;
  81. function pass_typecheck:tnode;override;
  82. {$ifdef state_tracking}
  83. function track_state_pass(exec_known:boolean):boolean;override;
  84. {$endif state_tracking}
  85. property statements : tnode read left write left;
  86. end;
  87. tblocknodeclass = class of tblocknode;
  88. ttempcreatenode = class;
  89. ttempinfoflag = (
  90. { temp can be kept in a register as far as the original creator is
  91. concerned }
  92. ti_may_be_in_reg,
  93. { the ttempcreatenode has been process and the temp's location is
  94. valid (-> the ttempdeletenode has not yet been processed, or
  95. in case it's a "create_to_normal()" one, the final ttemprefnode
  96. has not yet been processed) }
  97. ti_valid,
  98. { when performing a getcopy of a nodetree, we have to hook up the
  99. copies of ttemprefnodes and ttempdestroynode to the copied
  100. ttempinfo. this is done by setting hookoncopy in the original
  101. ttempinfo to point to the new one. if the temp is deleted via a
  102. regular ttempdeletenode, the hookoncopy is simply set to nil once
  103. it's processed. otherwise, it sets the ti_nextref_set_hookoncopy_nil
  104. and after processing the final ttemprefnode, hookoncopy is set to nil
  105. }
  106. ti_nextref_set_hookoncopy_nil,
  107. { the address of this temp is taken (-> cannot be kept in a register,
  108. even if the creator didn't mind)
  109. }
  110. ti_addr_taken,
  111. { temps can get an extra node tree that contains the value to which
  112. they should be initialised when they are created. this initialisation
  113. has to be performed right before the first reference to the temp.
  114. this flag indicates that the ttempcreatenode has been
  115. processed by pass_generate_code, but that the first ttemprefnode
  116. hasn't yet and hence will have to perform the initialisation
  117. }
  118. ti_executeinitialisation,
  119. { in case an expression like "inc(x[func()],1)" is translated into
  120. a regular addition, you have to create a temp to hold the address
  121. representing x[func()], since otherwise func() will be called twice
  122. and that can spell trouble in case it has side effects. on platforms
  123. without pointers, we cannot just take the address though. this flag
  124. has to be combined with ti_executeinitialisation above and will,
  125. rather than loading the value at the calculated location and store
  126. it in the temp, keep a copy of the calculated location if possible
  127. and required (not possible for regvars, because SSA may change their
  128. register, but not required for them either since calculating their
  129. location has no side-effects
  130. }
  131. ti_reference,
  132. { this temp only allows reading (makes it possible to safely use as
  133. reference under more circumstances)
  134. }
  135. ti_readonly,
  136. { if this is a managed temp, it doesn't have to be finalised before use
  137. }
  138. ti_nofini,
  139. { the value described by this temp. node is const/immutable, this is important for
  140. managed types like ansistrings where temp. refs are pointers to the actual value
  141. -- in this case, assignments to the temp do not increase the
  142. reference count, and if the assigned value was a temp itself then
  143. that temp is not deallocated until this temp is deleted (since
  144. otherwise the assigned value may be freed before the last use of
  145. the temp) }
  146. ti_const,
  147. { the temp. needs no final sync instruction if it is located in a register,
  148. so there are no loops involved in the usage of the temp.
  149. }
  150. ti_no_final_regsync
  151. );
  152. ttempinfoflags = set of ttempinfoflag;
  153. const
  154. tempinfostoreflags = [ti_may_be_in_reg,ti_addr_taken,ti_reference,ti_readonly,ti_no_final_regsync];
  155. type
  156. { to allow access to the location by temp references even after the temp has }
  157. { already been disposed and to make sure the coherency between temps and }
  158. { temp references is kept after a getcopy }
  159. ptempinfo = ^ttempinfo;
  160. ttempinfo = object
  161. private
  162. flags : ttempinfoflags;
  163. public
  164. { set to the copy of a tempcreate pnode (if it gets copied) so that the }
  165. { refs and deletenode can hook to this copy once they get copied too }
  166. hookoncopy : ptempinfo;
  167. typedef : tdef;
  168. typedefderef : tderef;
  169. temptype : ttemptype;
  170. owner : ttempcreatenode;
  171. withnode : tnode;
  172. location : tlocation;
  173. tempinitcode : tnode;
  174. end;
  175. ttempinfoaccessor = class
  176. class procedure settempinfoflags(tempinfo: ptempinfo; const flags: ttempinfoflags); virtual;
  177. class function gettempinfoflags(tempinfo: ptempinfo): ttempinfoflags; static; inline;
  178. end;
  179. ttempinfoaccessorclass = class of ttempinfoaccessor;
  180. ttempbasenode = class(tnode)
  181. protected
  182. class var tempinfoaccessor: ttempinfoaccessorclass;
  183. protected
  184. procedure settempinfoflags(const tempflags: ttempinfoflags); inline;
  185. function gettempinfoflags: ttempinfoflags; inline;
  186. public
  187. tempinfo: ptempinfo;
  188. procedure includetempflag(flag: ttempinfoflag); inline;
  189. procedure excludetempflag(flag: ttempinfoflag); inline;
  190. property tempflags: ttempinfoflags read gettempinfoflags write settempinfoflags;
  191. end;
  192. { a node which will create a (non)persistent temp of a given type with a given }
  193. { size (the size is separate to allow creating "void" temps with a custom size) }
  194. ttempcreatenode = class(ttempbasenode)
  195. size: tcgint;
  196. ftemplvalue : tnode;
  197. { * persistent temps are used in manually written code where the temp }
  198. { be usable among different statements and where you can manually say }
  199. { when the temp has to be freed (using a ttempdeletenode) }
  200. { * non-persistent temps are mostly used in typeconversion helpers, }
  201. { where the node that receives the temp becomes responsible for }
  202. { freeing it. In this last case, you must use only one reference }
  203. { to it and *not* generate a ttempdeletenode }
  204. constructor create(_typedef: tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean); virtual;
  205. constructor create_withnode(_typedef: tdef; _size: tcgint; _temptype: ttemptype; allowreg:boolean; withnode: tnode); virtual;
  206. constructor create_value(_typedef:tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean; templvalue: tnode);
  207. constructor create_reference(_typedef:tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean; templvalue: tnode; readonly: boolean);
  208. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  209. procedure ppuwrite(ppufile:tcompilerppufile);override;
  210. procedure buildderefimpl;override;
  211. procedure derefimpl;override;
  212. function dogetcopy: tnode; override;
  213. function pass_1 : tnode; override;
  214. function pass_typecheck: tnode; override;
  215. function docompare(p: tnode): boolean; override;
  216. procedure printnodedata(var t:text);override;
  217. end;
  218. ttempcreatenodeclass = class of ttempcreatenode;
  219. { a node which is a reference to a certain temp }
  220. ttemprefnode = class(ttempbasenode)
  221. constructor create(const temp: ttempcreatenode); virtual;
  222. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  223. procedure ppuwrite(ppufile:tcompilerppufile);override;
  224. procedure resolveppuidx;override;
  225. function dogetcopy: tnode; override;
  226. function pass_1 : tnode; override;
  227. function pass_typecheck : tnode; override;
  228. procedure mark_write;override;
  229. function docompare(p: tnode): boolean; override;
  230. procedure printnodedata(var t:text);override;
  231. private
  232. tempidx : longint;
  233. end;
  234. ttemprefnodeclass = class of ttemprefnode;
  235. { a node which removes a temp }
  236. ttempdeletenode = class(ttempbasenode)
  237. constructor create(const temp: ttempcreatenode); virtual;
  238. { this will convert the persistant temp to a normal temp
  239. for returning to the other nodes }
  240. constructor create_normal_temp(const temp: ttempcreatenode);
  241. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  242. procedure ppuwrite(ppufile:tcompilerppufile);override;
  243. procedure resolveppuidx;override;
  244. function dogetcopy: tnode; override;
  245. function pass_1: tnode; override;
  246. function pass_typecheck: tnode; override;
  247. function docompare(p: tnode): boolean; override;
  248. destructor destroy; override;
  249. procedure printnodedata(var t:text);override;
  250. protected
  251. release_to_normal : boolean;
  252. private
  253. tempidx : longint;
  254. end;
  255. ttempdeletenodeclass = class of ttempdeletenode;
  256. var
  257. cnothingnode : tnothingnodeclass = tnothingnode;
  258. cerrornode : terrornodeclass = terrornode;
  259. cspecializenode : tspecializenodeclass = tspecializenode;
  260. casmnode : tasmnodeclass = tasmnode;
  261. cstatementnode : tstatementnodeclass = tstatementnode;
  262. cblocknode : tblocknodeclass = tblocknode;
  263. ctempinfoaccessor : ttempinfoaccessorclass = ttempinfoaccessor;
  264. ctempcreatenode : ttempcreatenodeclass = ttempcreatenode;
  265. ctemprefnode : ttemprefnodeclass = ttemprefnode;
  266. ctempdeletenode : ttempdeletenodeclass = ttempdeletenode;
  267. { Create a blocknode and statement node for multiple statements
  268. generated internally by the parser }
  269. function internalstatements(out laststatement:tstatementnode):tblocknode;
  270. function laststatement(block:tblocknode):tstatementnode;
  271. procedure addstatement(var laststatement:tstatementnode;n:tnode);
  272. { if the complexity of n is "high", creates a reference temp to n's
  273. location and replace n with a ttemprefnode referring to that location }
  274. function maybereplacewithtempref(var n: tnode; var block: tblocknode; var stat: tstatementnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
  275. implementation
  276. uses
  277. verbose,globals,systems,
  278. symconst,symdef,defutil,defcmp,
  279. pass_1,
  280. nutils,nld,
  281. procinfo
  282. ;
  283. {*****************************************************************************
  284. Helpers
  285. *****************************************************************************}
  286. function internalstatements(out laststatement:tstatementnode):tblocknode;
  287. begin
  288. { create dummy initial statement }
  289. laststatement := cstatementnode.create(cnothingnode.create,nil);
  290. internalstatements := cblocknode.create(laststatement);
  291. end;
  292. function laststatement(block:tblocknode):tstatementnode;
  293. begin
  294. result:=tstatementnode(block.left);
  295. while assigned(result) and assigned(result.right) do
  296. result:=tstatementnode(result.right);
  297. end;
  298. procedure addstatement(var laststatement:tstatementnode;n:tnode);
  299. begin
  300. if assigned(laststatement.right) then
  301. internalerror(200204201);
  302. laststatement.right:=cstatementnode.create(n,nil);
  303. laststatement:=tstatementnode(laststatement.right);
  304. end;
  305. function maybereplacewithtempref(var n: tnode; var block: tblocknode; var stat: tstatementnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
  306. begin
  307. result:=nil;
  308. if node_complexity(n) > 4 then
  309. begin
  310. result:=ctempcreatenode.create_reference(n.resultdef,size,tt_persistent,true,n,readonly);
  311. typecheckpass(tnode(result));
  312. n:=ctemprefnode.create(result);
  313. typecheckpass(n);
  314. if not assigned(stat) then
  315. block:=internalstatements(stat);
  316. addstatement(stat,result)
  317. end;
  318. end;
  319. {*****************************************************************************
  320. TFIRSTNOTHING
  321. *****************************************************************************}
  322. constructor tnothingnode.create;
  323. begin
  324. inherited create(nothingn);
  325. end;
  326. function tnothingnode.pass_typecheck:tnode;
  327. begin
  328. result:=nil;
  329. resultdef:=voidtype;
  330. end;
  331. function tnothingnode.pass_1 : tnode;
  332. begin
  333. result:=nil;
  334. expectloc:=LOC_VOID;
  335. end;
  336. {*****************************************************************************
  337. TFIRSTERROR
  338. *****************************************************************************}
  339. constructor terrornode.create;
  340. begin
  341. inherited create(errorn);
  342. end;
  343. function terrornode.pass_typecheck:tnode;
  344. begin
  345. result:=nil;
  346. include(flags,nf_error);
  347. codegenerror:=true;
  348. resultdef:=generrordef;
  349. end;
  350. function terrornode.pass_1 : tnode;
  351. begin
  352. result:=nil;
  353. expectloc:=LOC_VOID;
  354. codegenerror:=true;
  355. end;
  356. procedure terrornode.mark_write;
  357. begin
  358. end;
  359. {*****************************************************************************
  360. TSPECIALIZENODE
  361. *****************************************************************************}
  362. constructor tspecializenode.create(l:tnode;g:boolean;s:tsym);
  363. begin
  364. inherited create(specializen,l);
  365. sym:=s;
  366. getaddr:=g;
  367. end;
  368. function tspecializenode.pass_typecheck:tnode;
  369. begin
  370. result:=nil;
  371. resultdef:=cundefinedtype;
  372. end;
  373. function tspecializenode.pass_1:tnode;
  374. begin
  375. { such a node should not reach pass_1 }
  376. internalerror(2015071704);
  377. result:=nil;
  378. expectloc:=LOC_VOID;
  379. codegenerror:=true;
  380. end;
  381. {*****************************************************************************
  382. TSTATEMENTNODE
  383. *****************************************************************************}
  384. constructor tstatementnode.create(l,r : tnode);
  385. begin
  386. inherited create(statementn,l,r);
  387. end;
  388. function is_exit_statement(var n: tnode; arg: pointer): foreachnoderesult;
  389. begin
  390. if (n.nodetype<>exitn) then
  391. result:=fen_false
  392. else
  393. result:=fen_norecurse_true;
  394. end;
  395. function no_exit_statement_in_block(n: tnode): boolean;
  396. begin
  397. result:=not foreachnodestatic(n,@is_exit_statement,nil);
  398. end;
  399. function tstatementnode.simplify(forinline: boolean) : tnode;
  400. begin
  401. result:=nil;
  402. { these "optimizations" are only to make it more easy to recognise }
  403. { blocknodes which at the end of inlining only contain one single }
  404. { statement. Simplifying inside blocknode.simplify could be dangerous }
  405. { because if the main blocknode which makes up a procedure/function }
  406. { body were replaced with a statementn/nothingn, this could cause }
  407. { problems elsewhere in the compiler which expects a blocknode }
  408. { remove next statement if it's a nothing-statement (since if it's }
  409. { the last, it won't remove itself -- see next simplification) }
  410. while assigned(right) and
  411. (tstatementnode(right).left.nodetype = nothingn) do
  412. begin
  413. result:=tstatementnode(right).right;
  414. tstatementnode(right).right:=nil;
  415. right.free;
  416. right:=result;
  417. result:=nil;
  418. end;
  419. { Remove initial nothingn if there are other statements. If there }
  420. { are no other statements, returning nil doesn't help (will be }
  421. { interpreted as "can't be simplified") and replacing the }
  422. { statementnode with a nothingnode cannot be done (because it's }
  423. { possible this statementnode is a child of a blocknode, and }
  424. { blocknodes are expected to only contain statementnodes) }
  425. if (left.nodetype = nothingn) and
  426. assigned(right) then
  427. begin
  428. result:=right;
  429. right:=nil;
  430. exit;
  431. end;
  432. { if the current statement contains a block with one statement,
  433. replace the current statement with that block's statement
  434. (but only if the block does not have nf_block_with_exit set
  435. or has no exit statement, because otherwise it needs an own
  436. exit label, see tests/test/tinline10)
  437. Further, it might not be the user code entry
  438. }
  439. if (left.nodetype = blockn) and
  440. ((left.flags*[nf_block_with_exit,nf_usercode_entry]=[]) or
  441. ((left.flags*[nf_block_with_exit,nf_usercode_entry]=[nf_block_with_exit]) and no_exit_statement_in_block(left))) and
  442. assigned(tblocknode(left).left) and
  443. not assigned(tstatementnode(tblocknode(left).left).right) then
  444. begin
  445. result:=tblocknode(left).left;
  446. tstatementnode(result).right:=right;
  447. right:=nil;
  448. tblocknode(left).left:=nil;
  449. exit;
  450. end;
  451. end;
  452. function tstatementnode.pass_typecheck:tnode;
  453. begin
  454. result:=nil;
  455. resultdef:=voidtype;
  456. { left is the statement itself calln assignn or a complex one }
  457. typecheckpass(left);
  458. if codegenerror then
  459. exit;
  460. { right is the next statement in the list }
  461. if assigned(right) then
  462. typecheckpass(right);
  463. if codegenerror then
  464. exit;
  465. end;
  466. function tstatementnode.pass_1 : tnode;
  467. begin
  468. result:=nil;
  469. { left is the statement itself calln assignn or a complex one }
  470. firstpass(left);
  471. if codegenerror then
  472. exit;
  473. expectloc:=left.expectloc;
  474. { right is the next in the list }
  475. if assigned(right) then
  476. firstpass(right);
  477. if codegenerror then
  478. exit;
  479. end;
  480. procedure tstatementnode.printnodetree(var t:text);
  481. begin
  482. printnodelist(t);
  483. end;
  484. {*****************************************************************************
  485. TBLOCKNODE
  486. *****************************************************************************}
  487. constructor tblocknode.create(l : tnode);
  488. begin
  489. inherited create(blockn,l);
  490. end;
  491. destructor tblocknode.destroy;
  492. var
  493. hp, next: tstatementnode;
  494. begin
  495. hp := tstatementnode(left);
  496. left := nil;
  497. while assigned(hp) do
  498. begin
  499. next := tstatementnode(hp.right);
  500. hp.right := nil;
  501. hp.free;
  502. hp := next;
  503. end;
  504. inherited destroy;
  505. end;
  506. function tblocknode.simplify(forinline : boolean): tnode;
  507. begin
  508. result := nil;
  509. { Warning: never replace a blocknode with another node type, }
  510. { since the block may be the main block of a procedure/function/ }
  511. { main program body, and those nodes should always be blocknodes }
  512. { since that's what the compiler expects elsewhere. }
  513. if assigned(left) and
  514. not assigned(tstatementnode(left).right) then
  515. begin
  516. case tstatementnode(left).left.nodetype of
  517. blockn:
  518. begin
  519. { if the current block contains only one statement, and
  520. this one statement only contains another block, replace
  521. this block with that other block. }
  522. result:=tstatementnode(left).left;
  523. tstatementnode(left).left:=nil;
  524. { make sure the nf_block_with_exit flag is safeguarded }
  525. result.flags:=result.flags+(flags*[nf_block_with_exit,nf_usercode_entry]);
  526. exit;
  527. end;
  528. nothingn:
  529. begin
  530. { if the block contains only a statement with a nothing node,
  531. get rid of the statement }
  532. left.Free;
  533. left:=nil;
  534. exit;
  535. end;
  536. end;
  537. end;
  538. end;
  539. function tblocknode.pass_typecheck:tnode;
  540. var
  541. hp : tstatementnode;
  542. begin
  543. result:=nil;
  544. resultdef:=voidtype;
  545. hp:=tstatementnode(left);
  546. while assigned(hp) do
  547. begin
  548. if assigned(hp.left) then
  549. begin
  550. codegenerror:=false;
  551. typecheckpass(hp.left);
  552. { the resultdef of the block is the last type that is
  553. returned. Normally this is a voidtype. But when the
  554. compiler inserts a block of multiple statements then the
  555. last entry can return a value }
  556. resultdef:=hp.left.resultdef;
  557. end;
  558. hp:=tstatementnode(hp.right);
  559. end;
  560. end;
  561. function tblocknode.pass_1 : tnode;
  562. var
  563. hp : tstatementnode;
  564. //count : longint;
  565. begin
  566. result:=nil;
  567. expectloc:=LOC_VOID;
  568. //count:=0;
  569. hp:=tstatementnode(left);
  570. while assigned(hp) do
  571. begin
  572. if assigned(hp.left) then
  573. begin
  574. codegenerror:=false;
  575. firstpass(hp.left);
  576. hp.expectloc:=hp.left.expectloc;
  577. end;
  578. expectloc:=hp.expectloc;
  579. //inc(count);
  580. hp:=tstatementnode(hp.right);
  581. end;
  582. end;
  583. {$ifdef state_tracking}
  584. function Tblocknode.track_state_pass(exec_known:boolean):boolean;
  585. var hp:Tstatementnode;
  586. begin
  587. track_state_pass:=false;
  588. hp:=Tstatementnode(left);
  589. while assigned(hp) do
  590. begin
  591. if hp.left.track_state_pass(exec_known) then
  592. track_state_pass:=true;
  593. hp:=Tstatementnode(hp.right);
  594. end;
  595. end;
  596. {$endif state_tracking}
  597. {*****************************************************************************
  598. TASMNODE
  599. *****************************************************************************}
  600. constructor tasmnode.create(p : TAsmList);
  601. begin
  602. inherited create(asmn);
  603. p_asm:=p;
  604. currenttai:=nil;
  605. end;
  606. constructor tasmnode.create_get_position;
  607. begin
  608. inherited create(asmn);
  609. p_asm:=nil;
  610. include(flags,nf_get_asm_position);
  611. currenttai:=nil;
  612. end;
  613. destructor tasmnode.destroy;
  614. begin
  615. if assigned(p_asm) then
  616. p_asm.free;
  617. inherited destroy;
  618. end;
  619. constructor tasmnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  620. var
  621. hp : tai;
  622. begin
  623. inherited ppuload(t,ppufile);
  624. if not(nf_get_asm_position in flags) then
  625. begin
  626. p_asm:=TAsmList.create;
  627. repeat
  628. hp:=ppuloadai(ppufile);
  629. if hp=nil then
  630. break;
  631. p_asm.concat(hp);
  632. if hp.typ=ait_section then
  633. inc(p_asm.section_count);
  634. until false;
  635. end
  636. else
  637. p_asm:=nil;
  638. currenttai:=nil;
  639. end;
  640. procedure tasmnode.ppuwrite(ppufile:tcompilerppufile);
  641. var
  642. hp : tai;
  643. begin
  644. inherited ppuwrite(ppufile);
  645. { TODO: FIXME Add saving of register sets}
  646. if not(nf_get_asm_position in flags) then
  647. begin
  648. hp:=tai(p_asm.first);
  649. while assigned(hp) do
  650. begin
  651. ppuwriteai(ppufile,hp);
  652. hp:=tai(hp.next);
  653. end;
  654. { end is marked by a nil }
  655. ppuwriteai(ppufile,nil);
  656. end;
  657. end;
  658. procedure tasmnode.buildderefimpl;
  659. var
  660. hp : tai;
  661. begin
  662. inherited buildderefimpl;
  663. if not(nf_get_asm_position in flags) then
  664. begin
  665. hp:=tai(p_asm.first);
  666. while assigned(hp) do
  667. begin
  668. hp.buildderefimpl;
  669. hp:=tai(hp.next);
  670. end;
  671. end;
  672. end;
  673. procedure tasmnode.derefimpl;
  674. var
  675. hp : tai;
  676. begin
  677. inherited derefimpl;
  678. if not(nf_get_asm_position in flags) then
  679. begin
  680. hp:=tai(p_asm.first);
  681. while assigned(hp) do
  682. begin
  683. hp.derefimpl;
  684. hp:=tai(hp.next);
  685. end;
  686. end;
  687. end;
  688. function tasmnode.dogetcopy: tnode;
  689. var
  690. n: tasmnode;
  691. begin
  692. n := tasmnode(inherited dogetcopy);
  693. if assigned(p_asm) then
  694. begin
  695. n.p_asm:=TAsmList.create;
  696. n.p_asm.concatlistcopy(p_asm);
  697. n.p_asm.section_count:=p_asm.section_count;
  698. end
  699. else n.p_asm := nil;
  700. n.currenttai:=currenttai;
  701. n.has_registerlist:=has_registerlist;
  702. result:=n;
  703. end;
  704. function tasmnode.pass_typecheck:tnode;
  705. begin
  706. result:=nil;
  707. resultdef:=voidtype;
  708. if not(nf_get_asm_position in flags) then
  709. include(current_procinfo.flags,pi_has_assembler_block);
  710. end;
  711. function tasmnode.pass_1 : tnode;
  712. begin
  713. result:=nil;
  714. expectloc:=LOC_VOID;
  715. end;
  716. function tasmnode.docompare(p: tnode): boolean;
  717. begin
  718. { comparing of asmlists is not implemented (JM) }
  719. docompare := false;
  720. end;
  721. {*****************************************************************************
  722. TEMPBASENODE
  723. *****************************************************************************}
  724. class procedure ttempinfoaccessor.settempinfoflags(tempinfo: ptempinfo; const flags: ttempinfoflags);
  725. begin
  726. tempinfo^.flags:=flags;
  727. end;
  728. class function ttempinfoaccessor.gettempinfoflags(tempinfo: ptempinfo): ttempinfoflags;
  729. begin
  730. result:=tempinfo^.flags;
  731. end;
  732. {*****************************************************************************
  733. TEMPBASENODE
  734. *****************************************************************************}
  735. procedure ttempbasenode.settempinfoflags(const tempflags: ttempinfoflags);
  736. begin
  737. ctempinfoaccessor.settempinfoflags(tempinfo,tempflags);
  738. end;
  739. function ttempbasenode.gettempinfoflags: ttempinfoflags;
  740. begin
  741. result:=ctempinfoaccessor.gettempinfoflags(tempinfo);
  742. end;
  743. procedure ttempbasenode.includetempflag(flag: ttempinfoflag);
  744. begin
  745. { go through settempinfoflags() so it can filter out unsupported tempflags }
  746. settempinfoflags(gettempinfoflags+[flag])
  747. end;
  748. procedure ttempbasenode.excludetempflag(flag: ttempinfoflag);
  749. begin
  750. { go through settempinfoflags() so it can prevent required tempflags from
  751. being removed (if any) }
  752. settempinfoflags(gettempinfoflags-[flag])
  753. end;
  754. {*****************************************************************************
  755. TEMPCREATENODE
  756. *****************************************************************************}
  757. constructor ttempcreatenode.create(_typedef:tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean);
  758. begin
  759. inherited create(tempcreaten);
  760. size := _size;
  761. new(tempinfo);
  762. fillchar(tempinfo^,sizeof(tempinfo^),0);
  763. tempinfo^.typedef := _typedef;
  764. tempinfo^.temptype := _temptype;
  765. tempinfo^.owner := self;
  766. tempinfo^.withnode := nil;
  767. if allowreg and
  768. { temp must fit a single register }
  769. (tstoreddef(_typedef).is_fpuregable or
  770. (tstoreddef(_typedef).is_intregable and
  771. (_size<=TCGSize2Size[OS_64]))) and
  772. { size of register operations must be known }
  773. (def_cgsize(_typedef)<>OS_NO) and
  774. { no init/final needed }
  775. not is_managed_type(_typedef) then
  776. includetempflag(ti_may_be_in_reg);
  777. end;
  778. constructor ttempcreatenode.create_withnode(_typedef: tdef; _size: tcgint; _temptype: ttemptype; allowreg:boolean; withnode: tnode);
  779. begin
  780. self.create(_typedef,_size,_temptype,allowreg);
  781. tempinfo^.withnode:=withnode.getcopy;
  782. end;
  783. constructor ttempcreatenode.create_value(_typedef:tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean; templvalue: tnode);
  784. begin
  785. self.create(_typedef,_size,_temptype,allowreg);
  786. // store in ppuwrite
  787. ftemplvalue:=templvalue;
  788. // create from stored ftemplvalue in ppuload
  789. tempinfo^.tempinitcode:=cassignmentnode.create(ctemprefnode.create(self),ftemplvalue);
  790. end;
  791. constructor ttempcreatenode.create_reference(_typedef: tdef; _size: tcgint; _temptype: ttemptype; allowreg: boolean; templvalue: tnode; readonly: boolean);
  792. begin
  793. // store in ppuwrite
  794. self.create(_typedef,_size,_temptype,allowreg);
  795. ftemplvalue:=templvalue;
  796. // no assignment node, just the tempvalue
  797. tempinfo^.tempinitcode:=ftemplvalue;
  798. includetempflag(ti_reference);
  799. if readonly then
  800. includetempflag(ti_readonly);
  801. end;
  802. function ttempcreatenode.dogetcopy: tnode;
  803. var
  804. n: ttempcreatenode;
  805. begin
  806. n := ttempcreatenode(inherited dogetcopy);
  807. n.size := size;
  808. new(n.tempinfo);
  809. fillchar(n.tempinfo^,sizeof(n.tempinfo^),0);
  810. n.tempinfo^.owner:=n;
  811. n.tempinfo^.typedef := tempinfo^.typedef;
  812. n.tempinfo^.temptype := tempinfo^.temptype;
  813. n.tempflags := tempflags * tempinfostoreflags;
  814. { when the tempinfo has already a hookoncopy then it is not
  815. reset by a tempdeletenode }
  816. if assigned(tempinfo^.hookoncopy) then
  817. internalerror(200211262);
  818. { signal the temprefs that the temp they point to has been copied, }
  819. { so that if the refs get copied as well, they can hook themselves }
  820. { to the copy of the temp }
  821. tempinfo^.hookoncopy := n.tempinfo;
  822. excludetempflag(ti_nextref_set_hookoncopy_nil);
  823. if assigned(tempinfo^.withnode) then
  824. n.tempinfo^.withnode := tempinfo^.withnode.getcopy
  825. else
  826. n.tempinfo^.withnode := nil;
  827. if assigned(tempinfo^.tempinitcode) then
  828. n.tempinfo^.tempinitcode := tempinfo^.tempinitcode.getcopy
  829. else
  830. n.tempinfo^.tempinitcode := nil;
  831. result := n;
  832. end;
  833. constructor ttempcreatenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  834. begin
  835. inherited ppuload(t,ppufile);
  836. size:=ppufile.getlongint;
  837. new(tempinfo);
  838. fillchar(tempinfo^,sizeof(tempinfo^),0);
  839. ppufile.getsmallset(tempinfo^.flags);
  840. ppufile.getderef(tempinfo^.typedefderef);
  841. tempinfo^.temptype := ttemptype(ppufile.getbyte);
  842. tempinfo^.owner:=self;
  843. tempinfo^.withnode:=ppuloadnode(ppufile);
  844. ftemplvalue:=ppuloadnode(ppufile);
  845. end;
  846. procedure ttempcreatenode.ppuwrite(ppufile:tcompilerppufile);
  847. begin
  848. inherited ppuwrite(ppufile);
  849. ppufile.putlongint(size);
  850. ppufile.putsmallset(tempinfo^.flags);
  851. ppufile.putderef(tempinfo^.typedefderef);
  852. ppufile.putbyte(byte(tempinfo^.temptype));
  853. ppuwritenode(ppufile,tempinfo^.withnode);
  854. ppuwritenode(ppufile,ftemplvalue);
  855. end;
  856. procedure ttempcreatenode.buildderefimpl;
  857. begin
  858. inherited buildderefimpl;
  859. tempinfo^.typedefderef.build(tempinfo^.typedef);
  860. if assigned(tempinfo^.withnode) then
  861. tempinfo^.withnode.buildderefimpl;
  862. if assigned(ftemplvalue) then
  863. ftemplvalue.buildderefimpl;
  864. end;
  865. procedure ttempcreatenode.derefimpl;
  866. begin
  867. inherited derefimpl;
  868. tempinfo^.typedef:=tdef(tempinfo^.typedefderef.resolve);
  869. if assigned(tempinfo^.withnode) then
  870. tempinfo^.withnode.derefimpl;
  871. if assigned(ftemplvalue) then
  872. begin
  873. ftemplvalue.derefimpl;
  874. tempinfo^.tempinitcode:=cassignmentnode.create(ctemprefnode.create(self),ftemplvalue);
  875. end;
  876. end;
  877. function ttempcreatenode.pass_1 : tnode;
  878. begin
  879. result := nil;
  880. expectloc:=LOC_VOID;
  881. { temps which are immutable do not need to be initialized/finalized }
  882. if (tempinfo^.typedef.needs_inittable) and not(ti_const in tempflags) then
  883. include(current_procinfo.flags,pi_needs_implicit_finally);
  884. if (cs_create_pic in current_settings.moduleswitches) and
  885. (tf_pic_uses_got in target_info.flags) and
  886. is_rtti_managed_type(tempinfo^.typedef) then
  887. include(current_procinfo.flags,pi_needs_got);
  888. if assigned(tempinfo^.withnode) then
  889. firstpass(tempinfo^.withnode);
  890. if assigned(tempinfo^.tempinitcode) then
  891. firstpass(tempinfo^.tempinitcode);
  892. inc(current_procinfo.estimatedtempsize,size);;
  893. end;
  894. function ttempcreatenode.pass_typecheck: tnode;
  895. begin
  896. result := nil;
  897. { a tempcreatenode doesn't have a resultdef, only temprefnodes do }
  898. resultdef := voidtype;
  899. if assigned(tempinfo^.withnode) then
  900. typecheckpass(tempinfo^.withnode);
  901. if assigned(tempinfo^.tempinitcode) then
  902. typecheckpass(tempinfo^.tempinitcode);
  903. end;
  904. function ttempcreatenode.docompare(p: tnode): boolean;
  905. begin
  906. result :=
  907. inherited docompare(p) and
  908. (ttempcreatenode(p).size = size) and
  909. (ttempcreatenode(p).tempflags*tempinfostoreflags=tempflags*tempinfostoreflags) and
  910. equal_defs(ttempcreatenode(p).tempinfo^.typedef,tempinfo^.typedef) and
  911. (ttempcreatenode(p).tempinfo^.withnode.isequal(tempinfo^.withnode)) and
  912. (ttempcreatenode(p).tempinfo^.tempinitcode.isequal(tempinfo^.tempinitcode));
  913. end;
  914. procedure ttempcreatenode.printnodedata(var t:text);
  915. begin
  916. inherited printnodedata(t);
  917. writeln(t,printnodeindention,'size = ',size,', temptypedef = ',tempinfo^.typedef.typesymbolprettyname,' = "',
  918. tempinfo^.typedef.GetTypeName,'", tempinfo = $',hexstr(ptrint(tempinfo),sizeof(ptrint)*2));
  919. writeln(t,printnodeindention,'tempinit =');
  920. printnode(t,tempinfo^.tempinitcode);
  921. end;
  922. {*****************************************************************************
  923. TEMPREFNODE
  924. *****************************************************************************}
  925. constructor ttemprefnode.create(const temp: ttempcreatenode);
  926. begin
  927. inherited create(temprefn);
  928. tempinfo := temp.tempinfo;
  929. end;
  930. function ttemprefnode.dogetcopy: tnode;
  931. var
  932. n: ttemprefnode;
  933. begin
  934. n := ttemprefnode(inherited dogetcopy);
  935. if assigned(tempinfo^.hookoncopy) then
  936. { if the temp has been copied, assume it becomes a new }
  937. { temp which has to be hooked by the copied reference }
  938. begin
  939. { hook the ref to the copied temp }
  940. n.tempinfo := tempinfo^.hookoncopy;
  941. { if we passed a ttempdeletenode that changed the temp }
  942. { from a persistent one into a normal one, we must be }
  943. { the last reference (since our parent should free the }
  944. { temp (JM) }
  945. if (ti_nextref_set_hookoncopy_nil in tempflags) then
  946. tempinfo^.hookoncopy := nil;
  947. end
  948. else
  949. { if the temp we refer to hasn't been copied, assume }
  950. { we're just a new reference to that temp }
  951. begin
  952. n.tempinfo := tempinfo;
  953. end;
  954. if not assigned(n.tempinfo) then
  955. internalerror(2005071901);
  956. result := n;
  957. end;
  958. constructor ttemprefnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  959. begin
  960. inherited ppuload(t,ppufile);
  961. tempidx:=ppufile.getlongint;
  962. end;
  963. procedure ttemprefnode.ppuwrite(ppufile:tcompilerppufile);
  964. begin
  965. inherited ppuwrite(ppufile);
  966. ppufile.putlongint(tempinfo^.owner.ppuidx);
  967. end;
  968. procedure ttemprefnode.resolveppuidx;
  969. var
  970. temp : ttempcreatenode;
  971. begin
  972. temp:=ttempcreatenode(nodeppuidxget(tempidx));
  973. if temp.nodetype<>tempcreaten then
  974. internalerror(200311075);
  975. tempinfo:=temp.tempinfo;
  976. end;
  977. function ttemprefnode.pass_1 : tnode;
  978. begin
  979. expectloc := LOC_REFERENCE;
  980. if not tempinfo^.typedef.needs_inittable and
  981. (ti_may_be_in_reg in tempflags) then
  982. begin
  983. if tempinfo^.typedef.typ=floatdef then
  984. begin
  985. if not use_vectorfpu(tempinfo^.typedef) then
  986. if (tempinfo^.temptype = tt_persistent) then
  987. expectloc := LOC_CFPUREGISTER
  988. else
  989. expectloc := LOC_FPUREGISTER
  990. else
  991. if (tempinfo^.temptype = tt_persistent) then
  992. expectloc := LOC_CMMREGISTER
  993. else
  994. expectloc := LOC_MMREGISTER
  995. end
  996. else
  997. begin
  998. if (tempinfo^.temptype = tt_persistent) then
  999. expectloc := LOC_CREGISTER
  1000. else
  1001. expectloc := LOC_REGISTER;
  1002. end;
  1003. end;
  1004. result := nil;
  1005. end;
  1006. function ttemprefnode.pass_typecheck: tnode;
  1007. begin
  1008. { check if the temp is already resultdef passed }
  1009. if not assigned(tempinfo^.typedef) then
  1010. internalerror(200108233);
  1011. result := nil;
  1012. resultdef := tempinfo^.typedef;
  1013. end;
  1014. function ttemprefnode.docompare(p: tnode): boolean;
  1015. begin
  1016. result :=
  1017. inherited docompare(p) and
  1018. (ttemprefnode(p).tempinfo = tempinfo);
  1019. end;
  1020. procedure ttemprefnode.mark_write;
  1021. begin
  1022. include(flags,nf_write);
  1023. end;
  1024. procedure ttemprefnode.printnodedata(var t:text);
  1025. var
  1026. f : ttempinfoflag;
  1027. notfirst : Boolean;
  1028. begin
  1029. inherited printnodedata(t);
  1030. write(t,printnodeindention,'temptypedef = ',tempinfo^.typedef.typesymbolprettyname,' = "',
  1031. tempinfo^.typedef.GetTypeName,'", (tempinfo = $',hexstr(ptrint(tempinfo),sizeof(ptrint)*2),' flags = [');
  1032. notfirst:=false;
  1033. for f in tempinfo^.flags do
  1034. begin
  1035. if notfirst then
  1036. write(t,',');
  1037. write(t,f);
  1038. notfirst:=true;
  1039. end;
  1040. writeln(t,'])');
  1041. end;
  1042. {*****************************************************************************
  1043. TEMPDELETENODE
  1044. *****************************************************************************}
  1045. constructor ttempdeletenode.create(const temp: ttempcreatenode);
  1046. begin
  1047. inherited create(tempdeleten);
  1048. tempinfo := temp.tempinfo;
  1049. release_to_normal := false;
  1050. end;
  1051. constructor ttempdeletenode.create_normal_temp(const temp: ttempcreatenode);
  1052. begin
  1053. inherited create(tempdeleten);
  1054. tempinfo := temp.tempinfo;
  1055. release_to_normal := true;
  1056. if tempinfo^.temptype <> tt_persistent then
  1057. internalerror(200204211);
  1058. end;
  1059. function ttempdeletenode.dogetcopy: tnode;
  1060. var
  1061. n: ttempdeletenode;
  1062. begin
  1063. n:=ttempdeletenode(inherited dogetcopy);
  1064. n.release_to_normal:=release_to_normal;
  1065. if assigned(tempinfo^.hookoncopy) then
  1066. { if the temp has been copied, assume it becomes a new }
  1067. { temp which has to be hooked by the copied deletenode }
  1068. begin
  1069. { hook the tempdeletenode to the copied temp }
  1070. n.tempinfo:=tempinfo^.hookoncopy;
  1071. { the temp shall not be used, reset hookoncopy }
  1072. { Only if release_to_normal is false, otherwise }
  1073. { the temp can still be referenced once more (JM) }
  1074. if (not release_to_normal) then
  1075. tempinfo^.hookoncopy:=nil
  1076. else
  1077. includetempflag(ti_nextref_set_hookoncopy_nil);
  1078. end
  1079. else
  1080. { if the temp we refer to hasn't been copied, we have a }
  1081. { problem since that means we now have two delete nodes }
  1082. { for one temp }
  1083. internalerror(200108234);
  1084. result:=n;
  1085. end;
  1086. constructor ttempdeletenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1087. begin
  1088. inherited ppuload(t,ppufile);
  1089. tempidx:=ppufile.getlongint;
  1090. release_to_normal:=(ppufile.getbyte<>0);
  1091. end;
  1092. procedure ttempdeletenode.ppuwrite(ppufile:tcompilerppufile);
  1093. begin
  1094. inherited ppuwrite(ppufile);
  1095. ppufile.putlongint(tempinfo^.owner.ppuidx);
  1096. ppufile.putbyte(byte(release_to_normal));
  1097. end;
  1098. procedure ttempdeletenode.resolveppuidx;
  1099. var
  1100. temp : ttempcreatenode;
  1101. begin
  1102. temp:=ttempcreatenode(nodeppuidxget(tempidx));
  1103. if temp.nodetype<>tempcreaten then
  1104. internalerror(200311075);
  1105. tempinfo:=temp.tempinfo;
  1106. end;
  1107. function ttempdeletenode.pass_1 : tnode;
  1108. begin
  1109. expectloc:=LOC_VOID;
  1110. result := nil;
  1111. end;
  1112. function ttempdeletenode.pass_typecheck: tnode;
  1113. begin
  1114. result := nil;
  1115. resultdef := voidtype;
  1116. end;
  1117. function ttempdeletenode.docompare(p: tnode): boolean;
  1118. begin
  1119. result :=
  1120. inherited docompare(p) and
  1121. (ttemprefnode(p).tempinfo = tempinfo);
  1122. end;
  1123. destructor ttempdeletenode.destroy;
  1124. begin
  1125. tempinfo^.withnode.free;
  1126. tempinfo^.tempinitcode.free;
  1127. dispose(tempinfo);
  1128. end;
  1129. procedure ttempdeletenode.printnodedata(var t:text);
  1130. begin
  1131. inherited printnodedata(t);
  1132. writeln(t,printnodeindention,'release_to_normal: ',release_to_normal,', temptypedef = ',tempinfo^.typedef.typesymbolprettyname,' = "',
  1133. tempinfo^.typedef.GetTypeName,'", temptype = ',tempinfo^.temptype,', tempinfo = $',hexstr(ptrint(tempinfo),sizeof(ptrint)*2));
  1134. end;
  1135. end.