nbas.pas 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349
  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. cpuinfo,cpubase,cgbase,cgutils,
  23. aasmbase,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. cutils,
  278. verbose,globals,systems,
  279. symconst,symdef,defutil,defcmp,
  280. pass_1,
  281. nutils,nld,ncal,nflw,
  282. procinfo
  283. ;
  284. {*****************************************************************************
  285. Helpers
  286. *****************************************************************************}
  287. function internalstatements(out laststatement:tstatementnode):tblocknode;
  288. begin
  289. { create dummy initial statement }
  290. laststatement := cstatementnode.create(cnothingnode.create,nil);
  291. internalstatements := cblocknode.create(laststatement);
  292. end;
  293. function laststatement(block:tblocknode):tstatementnode;
  294. begin
  295. result:=tstatementnode(block.left);
  296. while assigned(result) and assigned(result.right) do
  297. result:=tstatementnode(result.right);
  298. end;
  299. procedure addstatement(var laststatement:tstatementnode;n:tnode);
  300. begin
  301. if assigned(laststatement.right) then
  302. internalerror(200204201);
  303. laststatement.right:=cstatementnode.create(n,nil);
  304. laststatement:=tstatementnode(laststatement.right);
  305. end;
  306. function maybereplacewithtempref(var n: tnode; var block: tblocknode; var stat: tstatementnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
  307. begin
  308. result:=nil;
  309. if node_complexity(n) > 4 then
  310. begin
  311. result:=ctempcreatenode.create_reference(n.resultdef,size,tt_persistent,true,n,readonly);
  312. typecheckpass(tnode(result));
  313. n:=ctemprefnode.create(result);
  314. typecheckpass(n);
  315. if not assigned(stat) then
  316. block:=internalstatements(stat);
  317. addstatement(stat,result)
  318. end;
  319. end;
  320. {*****************************************************************************
  321. TFIRSTNOTHING
  322. *****************************************************************************}
  323. constructor tnothingnode.create;
  324. begin
  325. inherited create(nothingn);
  326. end;
  327. function tnothingnode.pass_typecheck:tnode;
  328. begin
  329. result:=nil;
  330. resultdef:=voidtype;
  331. end;
  332. function tnothingnode.pass_1 : tnode;
  333. begin
  334. result:=nil;
  335. expectloc:=LOC_VOID;
  336. end;
  337. {*****************************************************************************
  338. TFIRSTERROR
  339. *****************************************************************************}
  340. constructor terrornode.create;
  341. begin
  342. inherited create(errorn);
  343. end;
  344. function terrornode.pass_typecheck:tnode;
  345. begin
  346. result:=nil;
  347. include(flags,nf_error);
  348. codegenerror:=true;
  349. resultdef:=generrordef;
  350. end;
  351. function terrornode.pass_1 : tnode;
  352. begin
  353. result:=nil;
  354. expectloc:=LOC_VOID;
  355. codegenerror:=true;
  356. end;
  357. procedure terrornode.mark_write;
  358. begin
  359. end;
  360. {*****************************************************************************
  361. TSPECIALIZENODE
  362. *****************************************************************************}
  363. constructor tspecializenode.create(l:tnode;g:boolean;s:tsym);
  364. begin
  365. inherited create(specializen,l);
  366. sym:=s;
  367. getaddr:=g;
  368. end;
  369. function tspecializenode.pass_typecheck:tnode;
  370. begin
  371. result:=nil;
  372. resultdef:=cundefinedtype;
  373. end;
  374. function tspecializenode.pass_1:tnode;
  375. begin
  376. { such a node should not reach pass_1 }
  377. internalerror(2015071704);
  378. result:=nil;
  379. expectloc:=LOC_VOID;
  380. codegenerror:=true;
  381. end;
  382. {*****************************************************************************
  383. TSTATEMENTNODE
  384. *****************************************************************************}
  385. constructor tstatementnode.create(l,r : tnode);
  386. begin
  387. inherited create(statementn,l,r);
  388. end;
  389. function is_exit_statement(var n: tnode; arg: pointer): foreachnoderesult;
  390. begin
  391. if (n.nodetype<>exitn) then
  392. result:=fen_false
  393. else
  394. result:=fen_norecurse_true;
  395. end;
  396. function no_exit_statement_in_block(n: tnode): boolean;
  397. begin
  398. result:=not foreachnodestatic(n,@is_exit_statement,nil);
  399. end;
  400. function tstatementnode.simplify(forinline: boolean) : tnode;
  401. begin
  402. result:=nil;
  403. { these "optimizations" are only to make it more easy to recognise }
  404. { blocknodes which at the end of inlining only contain one single }
  405. { statement. Simplifying inside blocknode.simplify could be dangerous }
  406. { because if the main blocknode which makes up a procedure/function }
  407. { body were replaced with a statementn/nothingn, this could cause }
  408. { problems elsewhere in the compiler which expects a blocknode }
  409. { remove next statement if it's a nothing-statement (since if it's }
  410. { the last, it won't remove itself -- see next simplification) }
  411. while assigned(right) and
  412. (tstatementnode(right).left.nodetype = nothingn) do
  413. begin
  414. result:=tstatementnode(right).right;
  415. tstatementnode(right).right:=nil;
  416. right.free;
  417. right:=result;
  418. result:=nil;
  419. end;
  420. { Remove initial nothingn if there are other statements. If there }
  421. { are no other statements, returning nil doesn't help (will be }
  422. { interpreted as "can't be simplified") and replacing the }
  423. { statementnode with a nothingnode cannot be done (because it's }
  424. { possible this statementnode is a child of a blocknode, and }
  425. { blocknodes are expected to only contain statementnodes) }
  426. if (left.nodetype = nothingn) and
  427. assigned(right) then
  428. begin
  429. result:=right;
  430. right:=nil;
  431. exit;
  432. end;
  433. { if the current statement contains a block with one statement,
  434. replace the current statement with that block's statement
  435. (but only if the block does not have nf_block_with_exit set
  436. or has no exit statement, because otherwise it needs an own
  437. exit label, see tests/test/tinline10)
  438. Further, it might not be the user code entry
  439. }
  440. if (left.nodetype = blockn) and
  441. ((left.flags*[nf_block_with_exit,nf_usercode_entry]=[]) or
  442. ((left.flags*[nf_block_with_exit,nf_usercode_entry]=[nf_block_with_exit]) and no_exit_statement_in_block(left))) and
  443. assigned(tblocknode(left).left) and
  444. not assigned(tstatementnode(tblocknode(left).left).right) then
  445. begin
  446. result:=tblocknode(left).left;
  447. tstatementnode(result).right:=right;
  448. right:=nil;
  449. tblocknode(left).left:=nil;
  450. exit;
  451. end;
  452. end;
  453. function tstatementnode.pass_typecheck:tnode;
  454. begin
  455. result:=nil;
  456. resultdef:=voidtype;
  457. { left is the statement itself calln assignn or a complex one }
  458. typecheckpass(left);
  459. if codegenerror then
  460. exit;
  461. { right is the next statement in the list }
  462. if assigned(right) then
  463. typecheckpass(right);
  464. if codegenerror then
  465. exit;
  466. end;
  467. function tstatementnode.pass_1 : tnode;
  468. begin
  469. result:=nil;
  470. { left is the statement itself calln assignn or a complex one }
  471. firstpass(left);
  472. if codegenerror then
  473. exit;
  474. expectloc:=left.expectloc;
  475. { right is the next in the list }
  476. if assigned(right) then
  477. firstpass(right);
  478. if codegenerror then
  479. exit;
  480. end;
  481. procedure tstatementnode.printnodetree(var t:text);
  482. begin
  483. printnodelist(t);
  484. end;
  485. {*****************************************************************************
  486. TBLOCKNODE
  487. *****************************************************************************}
  488. constructor tblocknode.create(l : tnode);
  489. begin
  490. inherited create(blockn,l);
  491. end;
  492. destructor tblocknode.destroy;
  493. var
  494. hp, next: tstatementnode;
  495. begin
  496. hp := tstatementnode(left);
  497. left := nil;
  498. while assigned(hp) do
  499. begin
  500. next := tstatementnode(hp.right);
  501. hp.right := nil;
  502. hp.free;
  503. hp := next;
  504. end;
  505. inherited destroy;
  506. end;
  507. function tblocknode.simplify(forinline : boolean): tnode;
  508. begin
  509. result := nil;
  510. { Warning: never replace a blocknode with another node type, }
  511. { since the block may be the main block of a procedure/function/ }
  512. { main program body, and those nodes should always be blocknodes }
  513. { since that's what the compiler expects elsewhere. }
  514. if assigned(left) and
  515. not assigned(tstatementnode(left).right) then
  516. begin
  517. case tstatementnode(left).left.nodetype of
  518. blockn:
  519. begin
  520. { if the current block contains only one statement, and
  521. this one statement only contains another block, replace
  522. this block with that other block. }
  523. result:=tstatementnode(left).left;
  524. tstatementnode(left).left:=nil;
  525. { make sure the nf_block_with_exit flag is safeguarded }
  526. result.flags:=result.flags+(flags*[nf_block_with_exit,nf_usercode_entry]);
  527. exit;
  528. end;
  529. nothingn:
  530. begin
  531. { if the block contains only a statement with a nothing node,
  532. get rid of the statement }
  533. left.Free;
  534. left:=nil;
  535. exit;
  536. end;
  537. end;
  538. end;
  539. end;
  540. function tblocknode.pass_typecheck:tnode;
  541. var
  542. hp : tstatementnode;
  543. begin
  544. result:=nil;
  545. resultdef:=voidtype;
  546. hp:=tstatementnode(left);
  547. while assigned(hp) do
  548. begin
  549. if assigned(hp.left) then
  550. begin
  551. codegenerror:=false;
  552. typecheckpass(hp.left);
  553. { the resultdef of the block is the last type that is
  554. returned. Normally this is a voidtype. But when the
  555. compiler inserts a block of multiple statements then the
  556. last entry can return a value }
  557. resultdef:=hp.left.resultdef;
  558. end;
  559. hp:=tstatementnode(hp.right);
  560. end;
  561. end;
  562. function tblocknode.pass_1 : tnode;
  563. var
  564. hp : tstatementnode;
  565. //count : longint;
  566. begin
  567. result:=nil;
  568. expectloc:=LOC_VOID;
  569. //count:=0;
  570. hp:=tstatementnode(left);
  571. while assigned(hp) do
  572. begin
  573. if assigned(hp.left) then
  574. begin
  575. codegenerror:=false;
  576. firstpass(hp.left);
  577. hp.expectloc:=hp.left.expectloc;
  578. end;
  579. expectloc:=hp.expectloc;
  580. //inc(count);
  581. hp:=tstatementnode(hp.right);
  582. end;
  583. end;
  584. {$ifdef state_tracking}
  585. function Tblocknode.track_state_pass(exec_known:boolean):boolean;
  586. var hp:Tstatementnode;
  587. begin
  588. track_state_pass:=false;
  589. hp:=Tstatementnode(left);
  590. while assigned(hp) do
  591. begin
  592. if hp.left.track_state_pass(exec_known) then
  593. track_state_pass:=true;
  594. hp:=Tstatementnode(hp.right);
  595. end;
  596. end;
  597. {$endif state_tracking}
  598. {*****************************************************************************
  599. TASMNODE
  600. *****************************************************************************}
  601. constructor tasmnode.create(p : TAsmList);
  602. begin
  603. inherited create(asmn);
  604. p_asm:=p;
  605. currenttai:=nil;
  606. end;
  607. constructor tasmnode.create_get_position;
  608. begin
  609. inherited create(asmn);
  610. p_asm:=nil;
  611. include(flags,nf_get_asm_position);
  612. currenttai:=nil;
  613. end;
  614. destructor tasmnode.destroy;
  615. begin
  616. if assigned(p_asm) then
  617. p_asm.free;
  618. inherited destroy;
  619. end;
  620. constructor tasmnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  621. var
  622. hp : tai;
  623. begin
  624. inherited ppuload(t,ppufile);
  625. if not(nf_get_asm_position in flags) then
  626. begin
  627. p_asm:=TAsmList.create;
  628. repeat
  629. hp:=ppuloadai(ppufile);
  630. if hp=nil then
  631. break;
  632. p_asm.concat(hp);
  633. if hp.typ=ait_section then
  634. inc(p_asm.section_count);
  635. until false;
  636. end
  637. else
  638. p_asm:=nil;
  639. currenttai:=nil;
  640. end;
  641. procedure tasmnode.ppuwrite(ppufile:tcompilerppufile);
  642. var
  643. hp : tai;
  644. begin
  645. inherited ppuwrite(ppufile);
  646. { TODO: FIXME Add saving of register sets}
  647. if not(nf_get_asm_position in flags) then
  648. begin
  649. hp:=tai(p_asm.first);
  650. while assigned(hp) do
  651. begin
  652. ppuwriteai(ppufile,hp);
  653. hp:=tai(hp.next);
  654. end;
  655. { end is marked by a nil }
  656. ppuwriteai(ppufile,nil);
  657. end;
  658. end;
  659. procedure tasmnode.buildderefimpl;
  660. var
  661. hp : tai;
  662. begin
  663. inherited buildderefimpl;
  664. if not(nf_get_asm_position in flags) then
  665. begin
  666. hp:=tai(p_asm.first);
  667. while assigned(hp) do
  668. begin
  669. hp.buildderefimpl;
  670. hp:=tai(hp.next);
  671. end;
  672. end;
  673. end;
  674. procedure tasmnode.derefimpl;
  675. var
  676. hp : tai;
  677. begin
  678. inherited derefimpl;
  679. if not(nf_get_asm_position in flags) then
  680. begin
  681. hp:=tai(p_asm.first);
  682. while assigned(hp) do
  683. begin
  684. hp.derefimpl;
  685. hp:=tai(hp.next);
  686. end;
  687. end;
  688. end;
  689. function tasmnode.dogetcopy: tnode;
  690. var
  691. n: tasmnode;
  692. begin
  693. n := tasmnode(inherited dogetcopy);
  694. if assigned(p_asm) then
  695. begin
  696. n.p_asm:=TAsmList.create;
  697. n.p_asm.concatlistcopy(p_asm);
  698. n.p_asm.section_count:=p_asm.section_count;
  699. end
  700. else n.p_asm := nil;
  701. n.currenttai:=currenttai;
  702. n.has_registerlist:=has_registerlist;
  703. result:=n;
  704. end;
  705. function tasmnode.pass_typecheck:tnode;
  706. begin
  707. result:=nil;
  708. resultdef:=voidtype;
  709. if not(nf_get_asm_position in flags) then
  710. include(current_procinfo.flags,pi_has_assembler_block);
  711. end;
  712. function tasmnode.pass_1 : tnode;
  713. begin
  714. result:=nil;
  715. expectloc:=LOC_VOID;
  716. end;
  717. function tasmnode.docompare(p: tnode): boolean;
  718. begin
  719. { comparing of asmlists is not implemented (JM) }
  720. docompare := false;
  721. end;
  722. {*****************************************************************************
  723. TEMPBASENODE
  724. *****************************************************************************}
  725. class procedure ttempinfoaccessor.settempinfoflags(tempinfo: ptempinfo; const flags: ttempinfoflags);
  726. begin
  727. tempinfo^.flags:=flags;
  728. end;
  729. class function ttempinfoaccessor.gettempinfoflags(tempinfo: ptempinfo): ttempinfoflags;
  730. begin
  731. result:=tempinfo^.flags;
  732. end;
  733. {*****************************************************************************
  734. TEMPBASENODE
  735. *****************************************************************************}
  736. procedure ttempbasenode.settempinfoflags(const tempflags: ttempinfoflags);
  737. begin
  738. ctempinfoaccessor.settempinfoflags(tempinfo,tempflags);
  739. end;
  740. function ttempbasenode.gettempinfoflags: ttempinfoflags;
  741. begin
  742. result:=ctempinfoaccessor.gettempinfoflags(tempinfo);
  743. end;
  744. procedure ttempbasenode.includetempflag(flag: ttempinfoflag);
  745. begin
  746. { go through settempinfoflags() so it can filter out unsupported tempflags }
  747. settempinfoflags(gettempinfoflags+[flag])
  748. end;
  749. procedure ttempbasenode.excludetempflag(flag: ttempinfoflag);
  750. begin
  751. { go through settempinfoflags() so it can prevent required tempflags from
  752. being removed (if any) }
  753. settempinfoflags(gettempinfoflags-[flag])
  754. end;
  755. {*****************************************************************************
  756. TEMPCREATENODE
  757. *****************************************************************************}
  758. constructor ttempcreatenode.create(_typedef:tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean);
  759. begin
  760. inherited create(tempcreaten);
  761. size := _size;
  762. new(tempinfo);
  763. fillchar(tempinfo^,sizeof(tempinfo^),0);
  764. tempinfo^.typedef := _typedef;
  765. tempinfo^.temptype := _temptype;
  766. tempinfo^.owner := self;
  767. tempinfo^.withnode := nil;
  768. if allowreg and
  769. { temp must fit a single register }
  770. (tstoreddef(_typedef).is_fpuregable or
  771. (tstoreddef(_typedef).is_intregable and
  772. (_size<=TCGSize2Size[OS_64]))) and
  773. { size of register operations must be known }
  774. (def_cgsize(_typedef)<>OS_NO) and
  775. { no init/final needed }
  776. not is_managed_type(_typedef) then
  777. includetempflag(ti_may_be_in_reg);
  778. end;
  779. constructor ttempcreatenode.create_withnode(_typedef: tdef; _size: tcgint; _temptype: ttemptype; allowreg:boolean; withnode: tnode);
  780. begin
  781. self.create(_typedef,_size,_temptype,allowreg);
  782. tempinfo^.withnode:=withnode.getcopy;
  783. end;
  784. constructor ttempcreatenode.create_value(_typedef:tdef; _size: tcgint; _temptype: ttemptype;allowreg:boolean; templvalue: tnode);
  785. begin
  786. self.create(_typedef,_size,_temptype,allowreg);
  787. // store in ppuwrite
  788. ftemplvalue:=templvalue;
  789. // create from stored ftemplvalue in ppuload
  790. tempinfo^.tempinitcode:=cassignmentnode.create(ctemprefnode.create(self),ftemplvalue);
  791. end;
  792. constructor ttempcreatenode.create_reference(_typedef: tdef; _size: tcgint; _temptype: ttemptype; allowreg: boolean; templvalue: tnode; readonly: boolean);
  793. begin
  794. // store in ppuwrite
  795. self.create(_typedef,_size,_temptype,allowreg);
  796. ftemplvalue:=templvalue;
  797. // no assignment node, just the tempvalue
  798. tempinfo^.tempinitcode:=ftemplvalue;
  799. includetempflag(ti_reference);
  800. if readonly then
  801. includetempflag(ti_readonly);
  802. end;
  803. function ttempcreatenode.dogetcopy: tnode;
  804. var
  805. n: ttempcreatenode;
  806. begin
  807. n := ttempcreatenode(inherited dogetcopy);
  808. n.size := size;
  809. new(n.tempinfo);
  810. fillchar(n.tempinfo^,sizeof(n.tempinfo^),0);
  811. n.tempinfo^.owner:=n;
  812. n.tempinfo^.typedef := tempinfo^.typedef;
  813. n.tempinfo^.temptype := tempinfo^.temptype;
  814. n.tempflags := tempflags * tempinfostoreflags;
  815. { when the tempinfo has already a hookoncopy then it is not
  816. reset by a tempdeletenode }
  817. if assigned(tempinfo^.hookoncopy) then
  818. internalerror(200211262);
  819. { signal the temprefs that the temp they point to has been copied, }
  820. { so that if the refs get copied as well, they can hook themselves }
  821. { to the copy of the temp }
  822. tempinfo^.hookoncopy := n.tempinfo;
  823. excludetempflag(ti_nextref_set_hookoncopy_nil);
  824. if assigned(tempinfo^.withnode) then
  825. n.tempinfo^.withnode := tempinfo^.withnode.getcopy
  826. else
  827. n.tempinfo^.withnode := nil;
  828. if assigned(tempinfo^.tempinitcode) then
  829. n.tempinfo^.tempinitcode := tempinfo^.tempinitcode.getcopy
  830. else
  831. n.tempinfo^.tempinitcode := nil;
  832. result := n;
  833. end;
  834. constructor ttempcreatenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  835. begin
  836. inherited ppuload(t,ppufile);
  837. size:=ppufile.getlongint;
  838. new(tempinfo);
  839. fillchar(tempinfo^,sizeof(tempinfo^),0);
  840. ppufile.getsmallset(tempinfo^.flags);
  841. ppufile.getderef(tempinfo^.typedefderef);
  842. tempinfo^.temptype := ttemptype(ppufile.getbyte);
  843. tempinfo^.owner:=self;
  844. tempinfo^.withnode:=ppuloadnode(ppufile);
  845. ftemplvalue:=ppuloadnode(ppufile);
  846. end;
  847. procedure ttempcreatenode.ppuwrite(ppufile:tcompilerppufile);
  848. begin
  849. inherited ppuwrite(ppufile);
  850. ppufile.putlongint(size);
  851. ppufile.putsmallset(tempinfo^.flags);
  852. ppufile.putderef(tempinfo^.typedefderef);
  853. ppufile.putbyte(byte(tempinfo^.temptype));
  854. ppuwritenode(ppufile,tempinfo^.withnode);
  855. ppuwritenode(ppufile,ftemplvalue);
  856. end;
  857. procedure ttempcreatenode.buildderefimpl;
  858. begin
  859. inherited buildderefimpl;
  860. tempinfo^.typedefderef.build(tempinfo^.typedef);
  861. if assigned(tempinfo^.withnode) then
  862. tempinfo^.withnode.buildderefimpl;
  863. if assigned(ftemplvalue) then
  864. ftemplvalue.buildderefimpl;
  865. end;
  866. procedure ttempcreatenode.derefimpl;
  867. begin
  868. inherited derefimpl;
  869. tempinfo^.typedef:=tdef(tempinfo^.typedefderef.resolve);
  870. if assigned(tempinfo^.withnode) then
  871. tempinfo^.withnode.derefimpl;
  872. if assigned(ftemplvalue) then
  873. begin
  874. ftemplvalue.derefimpl;
  875. tempinfo^.tempinitcode:=cassignmentnode.create(ctemprefnode.create(self),ftemplvalue);
  876. end;
  877. end;
  878. function ttempcreatenode.pass_1 : tnode;
  879. begin
  880. result := nil;
  881. expectloc:=LOC_VOID;
  882. { temps which are immutable do not need to be initialized/finalized }
  883. if (tempinfo^.typedef.needs_inittable) and not(ti_const in tempflags) then
  884. include(current_procinfo.flags,pi_needs_implicit_finally);
  885. if (cs_create_pic in current_settings.moduleswitches) and
  886. (tf_pic_uses_got in target_info.flags) and
  887. is_rtti_managed_type(tempinfo^.typedef) then
  888. include(current_procinfo.flags,pi_needs_got);
  889. if assigned(tempinfo^.withnode) then
  890. firstpass(tempinfo^.withnode);
  891. if assigned(tempinfo^.tempinitcode) then
  892. firstpass(tempinfo^.tempinitcode);
  893. inc(current_procinfo.estimatedtempsize,size);;
  894. end;
  895. function ttempcreatenode.pass_typecheck: tnode;
  896. begin
  897. result := nil;
  898. { a tempcreatenode doesn't have a resultdef, only temprefnodes do }
  899. resultdef := voidtype;
  900. if assigned(tempinfo^.withnode) then
  901. typecheckpass(tempinfo^.withnode);
  902. if assigned(tempinfo^.tempinitcode) then
  903. typecheckpass(tempinfo^.tempinitcode);
  904. end;
  905. function ttempcreatenode.docompare(p: tnode): boolean;
  906. begin
  907. result :=
  908. inherited docompare(p) and
  909. (ttempcreatenode(p).size = size) and
  910. (ttempcreatenode(p).tempflags*tempinfostoreflags=tempflags*tempinfostoreflags) and
  911. equal_defs(ttempcreatenode(p).tempinfo^.typedef,tempinfo^.typedef) and
  912. (ttempcreatenode(p).tempinfo^.withnode.isequal(tempinfo^.withnode)) and
  913. (ttempcreatenode(p).tempinfo^.tempinitcode.isequal(tempinfo^.tempinitcode));
  914. end;
  915. procedure ttempcreatenode.printnodedata(var t:text);
  916. begin
  917. inherited printnodedata(t);
  918. writeln(t,printnodeindention,'size = ',size,', temptypedef = ',tempinfo^.typedef.typesymbolprettyname,' = "',
  919. tempinfo^.typedef.GetTypeName,'", tempinfo = $',hexstr(ptrint(tempinfo),sizeof(ptrint)*2));
  920. writeln(t,printnodeindention,'tempinit =');
  921. printnode(t,tempinfo^.tempinitcode);
  922. end;
  923. {*****************************************************************************
  924. TEMPREFNODE
  925. *****************************************************************************}
  926. constructor ttemprefnode.create(const temp: ttempcreatenode);
  927. begin
  928. inherited create(temprefn);
  929. tempinfo := temp.tempinfo;
  930. end;
  931. function ttemprefnode.dogetcopy: tnode;
  932. var
  933. n: ttemprefnode;
  934. begin
  935. n := ttemprefnode(inherited dogetcopy);
  936. if assigned(tempinfo^.hookoncopy) then
  937. { if the temp has been copied, assume it becomes a new }
  938. { temp which has to be hooked by the copied reference }
  939. begin
  940. { hook the ref to the copied temp }
  941. n.tempinfo := tempinfo^.hookoncopy;
  942. { if we passed a ttempdeletenode that changed the temp }
  943. { from a persistent one into a normal one, we must be }
  944. { the last reference (since our parent should free the }
  945. { temp (JM) }
  946. if (ti_nextref_set_hookoncopy_nil in tempflags) then
  947. tempinfo^.hookoncopy := nil;
  948. end
  949. else
  950. { if the temp we refer to hasn't been copied, assume }
  951. { we're just a new reference to that temp }
  952. begin
  953. n.tempinfo := tempinfo;
  954. end;
  955. if not assigned(n.tempinfo) then
  956. internalerror(2005071901);
  957. result := n;
  958. end;
  959. constructor ttemprefnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  960. begin
  961. inherited ppuload(t,ppufile);
  962. tempidx:=ppufile.getlongint;
  963. end;
  964. procedure ttemprefnode.ppuwrite(ppufile:tcompilerppufile);
  965. begin
  966. inherited ppuwrite(ppufile);
  967. ppufile.putlongint(tempinfo^.owner.ppuidx);
  968. end;
  969. procedure ttemprefnode.resolveppuidx;
  970. var
  971. temp : ttempcreatenode;
  972. begin
  973. temp:=ttempcreatenode(nodeppuidxget(tempidx));
  974. if temp.nodetype<>tempcreaten then
  975. internalerror(200311075);
  976. tempinfo:=temp.tempinfo;
  977. end;
  978. function ttemprefnode.pass_1 : tnode;
  979. begin
  980. expectloc := LOC_REFERENCE;
  981. if not tempinfo^.typedef.needs_inittable and
  982. (ti_may_be_in_reg in tempflags) then
  983. begin
  984. if tempinfo^.typedef.typ=floatdef then
  985. begin
  986. if not use_vectorfpu(tempinfo^.typedef) then
  987. if (tempinfo^.temptype = tt_persistent) then
  988. expectloc := LOC_CFPUREGISTER
  989. else
  990. expectloc := LOC_FPUREGISTER
  991. else
  992. if (tempinfo^.temptype = tt_persistent) then
  993. expectloc := LOC_CMMREGISTER
  994. else
  995. expectloc := LOC_MMREGISTER
  996. end
  997. else
  998. begin
  999. if (tempinfo^.temptype = tt_persistent) then
  1000. expectloc := LOC_CREGISTER
  1001. else
  1002. expectloc := LOC_REGISTER;
  1003. end;
  1004. end;
  1005. result := nil;
  1006. end;
  1007. function ttemprefnode.pass_typecheck: tnode;
  1008. begin
  1009. { check if the temp is already resultdef passed }
  1010. if not assigned(tempinfo^.typedef) then
  1011. internalerror(200108233);
  1012. result := nil;
  1013. resultdef := tempinfo^.typedef;
  1014. end;
  1015. function ttemprefnode.docompare(p: tnode): boolean;
  1016. begin
  1017. result :=
  1018. inherited docompare(p) and
  1019. (ttemprefnode(p).tempinfo = tempinfo);
  1020. end;
  1021. procedure ttemprefnode.mark_write;
  1022. begin
  1023. include(flags,nf_write);
  1024. end;
  1025. procedure ttemprefnode.printnodedata(var t:text);
  1026. var
  1027. f : ttempinfoflag;
  1028. notfirst : Boolean;
  1029. begin
  1030. inherited printnodedata(t);
  1031. write(t,printnodeindention,'temptypedef = ',tempinfo^.typedef.typesymbolprettyname,' = "',
  1032. tempinfo^.typedef.GetTypeName,'", (tempinfo = $',hexstr(ptrint(tempinfo),sizeof(ptrint)*2),' flags = [');
  1033. notfirst:=false;
  1034. for f in tempinfo^.flags do
  1035. begin
  1036. if notfirst then
  1037. write(t,',');
  1038. write(t,f);
  1039. notfirst:=true;
  1040. end;
  1041. writeln(t,'])');
  1042. end;
  1043. {*****************************************************************************
  1044. TEMPDELETENODE
  1045. *****************************************************************************}
  1046. constructor ttempdeletenode.create(const temp: ttempcreatenode);
  1047. begin
  1048. inherited create(tempdeleten);
  1049. tempinfo := temp.tempinfo;
  1050. release_to_normal := false;
  1051. end;
  1052. constructor ttempdeletenode.create_normal_temp(const temp: ttempcreatenode);
  1053. begin
  1054. inherited create(tempdeleten);
  1055. tempinfo := temp.tempinfo;
  1056. release_to_normal := true;
  1057. if tempinfo^.temptype <> tt_persistent then
  1058. internalerror(200204211);
  1059. end;
  1060. function ttempdeletenode.dogetcopy: tnode;
  1061. var
  1062. n: ttempdeletenode;
  1063. begin
  1064. n:=ttempdeletenode(inherited dogetcopy);
  1065. n.release_to_normal:=release_to_normal;
  1066. if assigned(tempinfo^.hookoncopy) then
  1067. { if the temp has been copied, assume it becomes a new }
  1068. { temp which has to be hooked by the copied deletenode }
  1069. begin
  1070. { hook the tempdeletenode to the copied temp }
  1071. n.tempinfo:=tempinfo^.hookoncopy;
  1072. { the temp shall not be used, reset hookoncopy }
  1073. { Only if release_to_normal is false, otherwise }
  1074. { the temp can still be referenced once more (JM) }
  1075. if (not release_to_normal) then
  1076. tempinfo^.hookoncopy:=nil
  1077. else
  1078. includetempflag(ti_nextref_set_hookoncopy_nil);
  1079. end
  1080. else
  1081. { if the temp we refer to hasn't been copied, we have a }
  1082. { problem since that means we now have two delete nodes }
  1083. { for one temp }
  1084. internalerror(200108234);
  1085. result:=n;
  1086. end;
  1087. constructor ttempdeletenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1088. begin
  1089. inherited ppuload(t,ppufile);
  1090. tempidx:=ppufile.getlongint;
  1091. release_to_normal:=(ppufile.getbyte<>0);
  1092. end;
  1093. procedure ttempdeletenode.ppuwrite(ppufile:tcompilerppufile);
  1094. begin
  1095. inherited ppuwrite(ppufile);
  1096. ppufile.putlongint(tempinfo^.owner.ppuidx);
  1097. ppufile.putbyte(byte(release_to_normal));
  1098. end;
  1099. procedure ttempdeletenode.resolveppuidx;
  1100. var
  1101. temp : ttempcreatenode;
  1102. begin
  1103. temp:=ttempcreatenode(nodeppuidxget(tempidx));
  1104. if temp.nodetype<>tempcreaten then
  1105. internalerror(200311075);
  1106. tempinfo:=temp.tempinfo;
  1107. end;
  1108. function ttempdeletenode.pass_1 : tnode;
  1109. begin
  1110. expectloc:=LOC_VOID;
  1111. result := nil;
  1112. end;
  1113. function ttempdeletenode.pass_typecheck: tnode;
  1114. begin
  1115. result := nil;
  1116. resultdef := voidtype;
  1117. end;
  1118. function ttempdeletenode.docompare(p: tnode): boolean;
  1119. begin
  1120. result :=
  1121. inherited docompare(p) and
  1122. (ttemprefnode(p).tempinfo = tempinfo);
  1123. end;
  1124. destructor ttempdeletenode.destroy;
  1125. begin
  1126. tempinfo^.withnode.free;
  1127. tempinfo^.tempinitcode.free;
  1128. dispose(tempinfo);
  1129. end;
  1130. procedure ttempdeletenode.printnodedata(var t:text);
  1131. begin
  1132. inherited printnodedata(t);
  1133. writeln(t,printnodeindention,'release_to_normal: ',release_to_normal,', temptypedef = ',tempinfo^.typedef.typesymbolprettyname,' = "',
  1134. tempinfo^.typedef.GetTypeName,'", temptype = ',tempinfo^.temptype,', tempinfo = $',hexstr(ptrint(tempinfo),sizeof(ptrint)*2));
  1135. end;
  1136. end.