nld.pas 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by Florian Klaempfl
  4. Type checking and register allocation for load/assignment nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit nld;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,
  23. {$ifdef state_tracking}
  24. nstate,
  25. {$endif}
  26. symconst,symppu,symbase,symtype,symsym,symdef;
  27. type
  28. tloadnode = class(tunarynode)
  29. symtableentry : tsym;
  30. symtable : tsymtable;
  31. procdef : tprocdef;
  32. constructor create(v : tsym;st : tsymtable);virtual;
  33. constructor create_procvar(v : tsym;d:tprocdef;st : tsymtable);virtual;
  34. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  35. procedure ppuwrite(ppufile:tcompilerppufile);override;
  36. procedure derefimpl;override;
  37. procedure set_mp(p:tnode);
  38. function getcopy : tnode;override;
  39. function pass_1 : tnode;override;
  40. function det_resulttype:tnode;override;
  41. procedure mark_write;override;
  42. function docompare(p: tnode): boolean; override;
  43. procedure printnodedata(var t:text);override;
  44. end;
  45. tloadnodeclass = class of tloadnode;
  46. { different assignment types }
  47. tassigntype = (at_normal,at_plus,at_minus,at_star,at_slash);
  48. tassignmentnode = class(tbinarynode)
  49. assigntype : tassigntype;
  50. constructor create(l,r : tnode);virtual;
  51. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  52. procedure ppuwrite(ppufile:tcompilerppufile);override;
  53. function getcopy : tnode;override;
  54. function pass_1 : tnode;override;
  55. function det_resulttype:tnode;override;
  56. {$ifdef state_tracking}
  57. function track_state_pass(exec_known:boolean):boolean;override;
  58. {$endif state_tracking}
  59. function docompare(p: tnode): boolean; override;
  60. end;
  61. tassignmentnodeclass = class of tassignmentnode;
  62. tarrayconstructorrangenode = class(tbinarynode)
  63. constructor create(l,r : tnode);virtual;
  64. function pass_1 : tnode;override;
  65. function det_resulttype:tnode;override;
  66. end;
  67. tarrayconstructorrangenodeclass = class of tarrayconstructorrangenode;
  68. tarrayconstructornode = class(tbinarynode)
  69. constructor create(l,r : tnode);virtual;
  70. function getcopy : tnode;override;
  71. function pass_1 : tnode;override;
  72. function det_resulttype:tnode;override;
  73. function docompare(p: tnode): boolean; override;
  74. procedure force_type(tt:ttype);
  75. end;
  76. tarrayconstructornodeclass = class of tarrayconstructornode;
  77. ttypenode = class(tnode)
  78. allowed : boolean;
  79. restype : ttype;
  80. constructor create(t : ttype);virtual;
  81. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  82. procedure ppuwrite(ppufile:tcompilerppufile);override;
  83. procedure derefimpl;override;
  84. function pass_1 : tnode;override;
  85. function det_resulttype:tnode;override;
  86. function docompare(p: tnode): boolean; override;
  87. end;
  88. ttypenodeclass = class of ttypenode;
  89. trttinode = class(tnode)
  90. l1,l2 : longint;
  91. rttitype : trttitype;
  92. rttidef : tstoreddef;
  93. constructor create(def:tstoreddef;rt:trttitype);virtual;
  94. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  95. procedure ppuwrite(ppufile:tcompilerppufile);override;
  96. procedure derefimpl;override;
  97. function getcopy : tnode;override;
  98. function pass_1 : tnode;override;
  99. procedure pass_2;override;
  100. function det_resulttype:tnode;override;
  101. function docompare(p: tnode): boolean; override;
  102. end;
  103. trttinodeclass = class of trttinode;
  104. var
  105. cloadnode : tloadnodeclass;
  106. cassignmentnode : tassignmentnodeclass;
  107. carrayconstructorrangenode : tarrayconstructorrangenodeclass;
  108. carrayconstructornode : tarrayconstructornodeclass;
  109. ctypenode : ttypenodeclass;
  110. crttinode : trttinodeclass;
  111. procedure load_procvar_from_calln(var p1:tnode);
  112. function load_high_value(vs:tvarsym):tnode;
  113. implementation
  114. uses
  115. cutils,verbose,globtype,globals,systems,
  116. symtable,paramgr,defutil,defcmp,
  117. htypechk,pass_1,
  118. ncon,ninl,ncnv,nmem,ncal,cpubase,rgobj,cginfo,cgbase
  119. ,symnot
  120. ;
  121. {*****************************************************************************
  122. Helpers
  123. *****************************************************************************}
  124. procedure load_procvar_from_calln(var p1:tnode);
  125. var
  126. p2 : tnode;
  127. begin
  128. if p1.nodetype<>calln then
  129. internalerror(200212251);
  130. { was it a procvar, then we simply remove the calln and
  131. reuse the right }
  132. if assigned(tcallnode(p1).right) then
  133. begin
  134. p2:=tcallnode(p1).right;
  135. tcallnode(p1).right:=nil;
  136. end
  137. else
  138. begin
  139. p2:=cloadnode.create_procvar(tcallnode(p1).symtableprocentry,
  140. tprocdef(tcallnode(p1).procdefinition),tcallnode(p1).symtableproc);
  141. { when the methodpointer is typen we've something like:
  142. tobject.create. Then only the address is needed of the
  143. method without a self pointer }
  144. if assigned(tcallnode(p1).methodpointer) and
  145. (tcallnode(p1).methodpointer.nodetype<>typen) then
  146. begin
  147. tloadnode(p2).set_mp(tcallnode(p1).methodpointer);
  148. tcallnode(p1).methodpointer:=nil;
  149. end;
  150. end;
  151. resulttypepass(p2);
  152. p1.free;
  153. p1:=p2;
  154. end;
  155. function load_high_value(vs:tvarsym):tnode;
  156. var
  157. srsym : tsym;
  158. srsymtable : tsymtable;
  159. begin
  160. result:=nil;
  161. srsymtable:=vs.owner;
  162. if vo_is_local_copy in vs.varoptions then
  163. begin
  164. { next symtable is always the para symtable }
  165. srsymtable:=srsymtable.next;
  166. if not(srsymtable.symtabletype in [parasymtable,inlineparasymtable]) then
  167. internalerror(200212171);
  168. end;
  169. srsym:=searchsymonlyin(srsymtable,'high'+vs.name);
  170. if assigned(srsym) then
  171. result:=cloadnode.create(srsym,srsymtable)
  172. else
  173. CGMessage(cg_e_illegal_expression);
  174. end;
  175. {*****************************************************************************
  176. TLOADNODE
  177. *****************************************************************************}
  178. constructor tloadnode.create(v : tsym;st : tsymtable);
  179. begin
  180. inherited create(loadn,nil);
  181. if not assigned(v) then
  182. internalerror(200108121);
  183. symtableentry:=v;
  184. symtable:=st;
  185. procdef:=nil;
  186. end;
  187. constructor tloadnode.create_procvar(v : tsym;d:tprocdef;st : tsymtable);
  188. begin
  189. inherited create(loadn,nil);
  190. if not assigned(v) then
  191. internalerror(200108121);
  192. symtableentry:=v;
  193. symtable:=st;
  194. procdef:=d;
  195. end;
  196. constructor tloadnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  197. begin
  198. inherited ppuload(t,ppufile);
  199. symtableentry:=tsym(ppufile.getderef);
  200. {$ifdef fpc}
  201. {$warning FIXME: No withsymtable support}
  202. {$endif}
  203. symtable:=nil;
  204. procdef:=tprocdef(ppufile.getderef);
  205. end;
  206. procedure tloadnode.ppuwrite(ppufile:tcompilerppufile);
  207. begin
  208. inherited ppuwrite(ppufile);
  209. ppufile.putderef(symtableentry);
  210. ppufile.putderef(procdef);
  211. end;
  212. procedure tloadnode.derefimpl;
  213. begin
  214. inherited derefimpl;
  215. resolvesym(pointer(symtableentry));
  216. symtable:=symtableentry.owner;
  217. resolvedef(pointer(procdef));
  218. end;
  219. procedure tloadnode.set_mp(p:tnode);
  220. begin
  221. { typen nodes should not be set }
  222. if p.nodetype=typen then
  223. internalerror(200301042);
  224. left:=p;
  225. end;
  226. function tloadnode.getcopy : tnode;
  227. var
  228. n : tloadnode;
  229. begin
  230. n:=tloadnode(inherited getcopy);
  231. n.symtable:=symtable;
  232. n.symtableentry:=symtableentry;
  233. result:=n;
  234. end;
  235. function tloadnode.det_resulttype:tnode;
  236. var
  237. p1 : tnode;
  238. begin
  239. result:=nil;
  240. { optimize simple with loadings }
  241. if (symtable.symtabletype=withsymtable) and
  242. (twithsymtable(symtable).direct_with) and
  243. (symtableentry.typ=varsym) then
  244. begin
  245. p1:=tnode(twithsymtable(symtable).withrefnode).getcopy;
  246. p1:=csubscriptnode.create(tvarsym(symtableentry),p1);
  247. left:=nil;
  248. result:=p1;
  249. exit;
  250. end;
  251. { handle first absolute as it will replace the symtableentry }
  252. if symtableentry.typ=absolutesym then
  253. begin
  254. { force the resulttype to the type of the absolute }
  255. resulttype:=tabsolutesym(symtableentry).vartype;
  256. { replace the symtableentry when it points to a var, else
  257. we are finished }
  258. if (tabsolutesym(symtableentry).abstyp=tovar) then
  259. begin
  260. symtableentry:=tabsolutesym(symtableentry).ref;
  261. symtable:=symtableentry.owner;
  262. include(flags,nf_absolute);
  263. end
  264. else
  265. exit;
  266. end;
  267. case symtableentry.typ of
  268. constsym:
  269. begin
  270. if tconstsym(symtableentry).consttyp=constresourcestring then
  271. resulttype:=cansistringtype
  272. else
  273. internalerror(22799);
  274. end;
  275. varsym :
  276. begin
  277. { if it's refered by absolute then it's used }
  278. if nf_absolute in flags then
  279. tvarsym(symtableentry).varstate:=vs_used
  280. else
  281. resulttype:=tvarsym(symtableentry).vartype;
  282. end;
  283. typedconstsym :
  284. if not(nf_absolute in flags) then
  285. resulttype:=ttypedconstsym(symtableentry).typedconsttype;
  286. procsym :
  287. begin
  288. if not assigned(procdef) then
  289. begin
  290. if Tprocsym(symtableentry).procdef_count>1 then
  291. CGMessage(parser_e_no_overloaded_procvars);
  292. procdef:=tprocsym(symtableentry).first_procdef;
  293. end;
  294. { Delphi returns Pointer as type }
  295. if not(m_tp_procvar in aktmodeswitches) then
  296. resulttype.setdef(procdef)
  297. else
  298. resulttype:=voidpointertype;
  299. { process methodpointer }
  300. if assigned(left) then
  301. resulttypepass(left);
  302. end;
  303. else
  304. internalerror(200104141);
  305. end;
  306. end;
  307. procedure Tloadnode.mark_write;
  308. begin
  309. include(flags,nf_write);
  310. end;
  311. function tloadnode.pass_1 : tnode;
  312. begin
  313. result:=nil;
  314. expectloc:=LOC_REFERENCE;
  315. registers32:=0;
  316. registersfpu:=0;
  317. {$ifdef SUPPORT_MMX}
  318. registersmmx:=0;
  319. {$endif SUPPORT_MMX}
  320. case symtableentry.typ of
  321. absolutesym :
  322. ;
  323. constsym:
  324. begin
  325. if tconstsym(symtableentry).consttyp=constresourcestring then
  326. begin
  327. include(current_procinfo.flags,pi_needs_implicit_finally);
  328. expectloc:=LOC_CREFERENCE;
  329. end;
  330. end;
  331. varsym :
  332. begin
  333. if (symtable.symtabletype in [parasymtable,localsymtable]) and
  334. (current_procdef.parast.symtablelevel>symtable.symtablelevel) then
  335. begin
  336. { if the variable is in an other stackframe then we need
  337. a register to dereference }
  338. if symtable.symtablelevel>normal_function_level then
  339. begin
  340. registers32:=1;
  341. { further, the variable can't be put into a register }
  342. tvarsym(symtableentry).varoptions:=
  343. tvarsym(symtableentry).varoptions-[vo_fpuregable,vo_regable];
  344. end;
  345. end;
  346. if (tvarsym(symtableentry).varspez=vs_const) then
  347. expectloc:=LOC_CREFERENCE;
  348. { we need a register for call by reference parameters }
  349. if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
  350. ((tvarsym(symtableentry).varspez=vs_const) and
  351. paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,pocall_none)) or
  352. { call by value open arrays are also indirect addressed }
  353. is_open_array(tvarsym(symtableentry).vartype.def) then
  354. registers32:=1;
  355. if symtable.symtabletype in [withsymtable,objectsymtable] then
  356. inc(registers32);
  357. if ([vo_is_thread_var,vo_is_dll_var]*tvarsym(symtableentry).varoptions)<>[] then
  358. registers32:=1;
  359. if nf_write in flags then
  360. Tvarsym(symtableentry).trigger_notifications(vn_onwrite)
  361. else
  362. Tvarsym(symtableentry).trigger_notifications(vn_onread);
  363. { count variable references }
  364. if rg.t_times<1 then
  365. inc(tvarsym(symtableentry).refs)
  366. else
  367. inc(tvarsym(symtableentry).refs,rg.t_times);
  368. end;
  369. typedconstsym :
  370. ;
  371. procsym :
  372. begin
  373. { method pointer ? }
  374. if assigned(left) then
  375. begin
  376. expectloc:=LOC_CREFERENCE;
  377. firstpass(left);
  378. registers32:=max(registers32,left.registers32);
  379. registersfpu:=max(registersfpu,left.registersfpu);
  380. {$ifdef SUPPORT_MMX}
  381. registersmmx:=max(registersmmx,left.registersmmx);
  382. {$endif SUPPORT_MMX}
  383. end;
  384. end;
  385. else
  386. internalerror(200104143);
  387. end;
  388. end;
  389. function tloadnode.docompare(p: tnode): boolean;
  390. begin
  391. docompare :=
  392. inherited docompare(p) and
  393. (symtableentry = tloadnode(p).symtableentry) and
  394. (symtable = tloadnode(p).symtable);
  395. end;
  396. procedure Tloadnode.printnodedata(var t:text);
  397. begin
  398. inherited printnodedata(t);
  399. writeln(t,printnodeindention,'symbol = ',symtableentry.name);
  400. end;
  401. {*****************************************************************************
  402. TASSIGNMENTNODE
  403. *****************************************************************************}
  404. constructor tassignmentnode.create(l,r : tnode);
  405. begin
  406. inherited create(assignn,l,r);
  407. l.mark_write;
  408. assigntype:=at_normal;
  409. end;
  410. constructor tassignmentnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  411. begin
  412. inherited ppuload(t,ppufile);
  413. assigntype:=tassigntype(ppufile.getbyte);
  414. end;
  415. procedure tassignmentnode.ppuwrite(ppufile:tcompilerppufile);
  416. begin
  417. inherited ppuwrite(ppufile);
  418. ppufile.putbyte(byte(assigntype));
  419. end;
  420. function tassignmentnode.getcopy : tnode;
  421. var
  422. n : tassignmentnode;
  423. begin
  424. n:=tassignmentnode(inherited getcopy);
  425. n.assigntype:=assigntype;
  426. getcopy:=n;
  427. end;
  428. function tassignmentnode.det_resulttype:tnode;
  429. var
  430. hp : tnode;
  431. useshelper : boolean;
  432. original_size : longint;
  433. begin
  434. result:=nil;
  435. resulttype:=voidtype;
  436. original_size := 0;
  437. { must be made unique }
  438. set_unique(left);
  439. resulttypepass(left);
  440. if is_ansistring(left.resulttype.def) then
  441. begin
  442. { fold <ansistring>:=<ansistring>+<char|shortstring|ansistring> }
  443. if (right.nodetype=addn) and
  444. left.isequal(tbinarynode(right).left) and
  445. { don't fold multiple concatenations else we could get trouble
  446. with multiple uses of s
  447. }
  448. (tbinarynode(right).left.nodetype<>addn) and
  449. (tbinarynode(right).right.nodetype<>addn) then
  450. begin
  451. { don't do a resulttypepass(right), since then the addnode }
  452. { may insert typeconversions that make this optimization }
  453. { opportunity quite difficult to detect (JM) }
  454. resulttypepass(tbinarynode(right).left);
  455. resulttypepass(tbinarynode(right).right);
  456. if (is_char(tbinarynode(right).right.resulttype.def) or
  457. is_shortstring(tbinarynode(right).right.resulttype.def) or
  458. is_ansistring(tbinarynode(right).right.resulttype.def)) then
  459. begin
  460. { remove property flag so it'll not trigger an error }
  461. exclude(left.flags,nf_isproperty);
  462. { generate call to helper }
  463. hp:=ccallparanode.create(tbinarynode(right).right,
  464. ccallparanode.create(left,nil));
  465. if is_char(tbinarynode(right).right.resulttype.def) then
  466. result:=ccallnode.createintern('fpc_ansistr_append_char',hp)
  467. else if is_shortstring(tbinarynode(right).right.resulttype.def) then
  468. result:=ccallnode.createintern('fpc_ansistr_append_shortstring',hp)
  469. else
  470. result:=ccallnode.createintern('fpc_ansistr_append_ansistring',hp);
  471. tbinarynode(right).right:=nil;
  472. left:=nil;
  473. exit;
  474. end;
  475. end;
  476. end;
  477. resulttypepass(right);
  478. set_varstate(left,false);
  479. set_varstate(right,true);
  480. { set_funcret_is_valid(left); }
  481. if codegenerror then
  482. exit;
  483. { assignments to open arrays aren't allowed }
  484. if is_open_array(left.resulttype.def) then
  485. CGMessage(type_e_mismatch);
  486. { test if node can be assigned, properties are allowed }
  487. valid_for_assignment(left);
  488. { assigning nil to a dynamic array clears the array }
  489. if is_dynamic_array(left.resulttype.def) and
  490. (right.nodetype=niln) then
  491. begin
  492. hp:=ccallparanode.create(caddrnode.create
  493. (crttinode.create(tstoreddef(left.resulttype.def),initrtti)),
  494. ccallparanode.create(ctypeconvnode.create_explicit(left,voidpointertype),nil));
  495. result := ccallnode.createintern('fpc_dynarray_clear',hp);
  496. left:=nil;
  497. exit;
  498. end;
  499. { shortstring helpers can do the conversion directly,
  500. so treat them separatly }
  501. if (is_shortstring(left.resulttype.def)) then
  502. begin
  503. { test for s:=s+anything ... }
  504. { the problem is for
  505. s:=s+s+s;
  506. this is broken here !! }
  507. {$ifdef newoptimizations2}
  508. { the above is fixed now, but still problem with s := s + f(); if }
  509. { f modifies s (bad programming, so only enable if uncertain }
  510. { optimizations are on) (JM) }
  511. if (cs_UncertainOpts in aktglobalswitches) then
  512. begin
  513. hp := right;
  514. while hp.treetype=addn do
  515. hp:=hp.left;
  516. if left.docompare(hp) then
  517. begin
  518. concat_string:=true;
  519. hp:=right;
  520. while hp.treetype=addn do
  521. begin
  522. hp.use_strconcat:=true;
  523. hp:=hp.left;
  524. end;
  525. end;
  526. end;
  527. {$endif newoptimizations2}
  528. { insert typeconv, except for chars that are handled in
  529. secondpass and except for ansi/wide string that can
  530. be converted immediatly }
  531. if not(is_char(right.resulttype.def) or
  532. (right.resulttype.def.deftype=stringdef)) then
  533. inserttypeconv(right,left.resulttype);
  534. if right.resulttype.def.deftype=stringdef then
  535. begin
  536. useshelper:=true;
  537. { convert constant strings to shortstrings. But
  538. skip empty constant strings, that will be handled
  539. in secondpass }
  540. if (right.nodetype=stringconstn) then
  541. begin
  542. { verify if range fits within shortstring }
  543. { just emit a warning, delphi gives an }
  544. { error, only if the type definition of }
  545. { of the string is less < 255 characters }
  546. if not is_open_string(left.resulttype.def) and
  547. (tstringconstnode(right).len > tstringdef(left.resulttype.def).len) then
  548. cgmessage(type_w_string_too_long);
  549. inserttypeconv(right,left.resulttype);
  550. if (tstringconstnode(right).len=0) then
  551. useshelper:=false;
  552. end;
  553. if useshelper then
  554. begin
  555. hp:=ccallparanode.create
  556. (right,
  557. ccallparanode.create(cinlinenode.create
  558. (in_high_x,false,left.getcopy),nil));
  559. result:=ccallnode.createinternreturn('fpc_'+tstringdef(right.resulttype.def).stringtypname+'_to_shortstr',hp,left);
  560. left:=nil;
  561. right:=nil;
  562. exit;
  563. end;
  564. end;
  565. end
  566. else
  567. begin
  568. { get the size before the type conversion - check for all nodes }
  569. if assigned(right.resulttype.def) and (right.nodetype in [loadn,vecn,calln]) then
  570. original_size := right.resulttype.def.size;
  571. inserttypeconv(right,left.resulttype);
  572. end;
  573. { check if the assignment may cause a range check error }
  574. { if its not explicit, and only if the values are }
  575. { ordinals, enumdef and floatdef }
  576. if (right.nodetype = typeconvn) and
  577. not (nf_explicit in ttypeconvnode(right).flags) then
  578. begin
  579. if assigned(left.resulttype.def) and
  580. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) then
  581. begin
  582. if (original_size <> 0) and (left.resulttype.def.size < original_size) then
  583. begin
  584. if (cs_check_range in aktlocalswitches) then
  585. Message(type_w_smaller_possible_range_check)
  586. else
  587. Message(type_h_smaller_possible_range_check);
  588. end;
  589. end;
  590. end;
  591. { call helpers for interface }
  592. if is_interfacecom(left.resulttype.def) then
  593. begin
  594. hp:=ccallparanode.create(ctypeconvnode.create_explicit
  595. (right,voidpointertype),
  596. ccallparanode.create(ctypeconvnode.create_explicit
  597. (left,voidpointertype),nil));
  598. result:=ccallnode.createintern('fpc_intf_assign',hp);
  599. left:=nil;
  600. right:=nil;
  601. exit;
  602. end;
  603. { check if local proc/func is assigned to procvar }
  604. if right.resulttype.def.deftype=procvardef then
  605. test_local_to_procvar(tprocvardef(right.resulttype.def),left.resulttype.def);
  606. end;
  607. function tassignmentnode.pass_1 : tnode;
  608. begin
  609. result:=nil;
  610. expectloc:=LOC_VOID;
  611. firstpass(left);
  612. firstpass(right);
  613. if codegenerror then
  614. exit;
  615. registers32:=left.registers32+right.registers32;
  616. registersfpu:=max(left.registersfpu,right.registersfpu);
  617. {$ifdef SUPPORT_MMX}
  618. registersmmx:=max(left.registersmmx,right.registersmmx);
  619. {$endif SUPPORT_MMX}
  620. end;
  621. function tassignmentnode.docompare(p: tnode): boolean;
  622. begin
  623. docompare :=
  624. inherited docompare(p) and
  625. (assigntype = tassignmentnode(p).assigntype);
  626. end;
  627. {$ifdef state_tracking}
  628. function Tassignmentnode.track_state_pass(exec_known:boolean):boolean;
  629. var se:Tstate_entry;
  630. begin
  631. track_state_pass:=false;
  632. if exec_known then
  633. begin
  634. track_state_pass:=right.track_state_pass(exec_known);
  635. {Force a new resulttype pass.}
  636. right.resulttype.def:=nil;
  637. do_resulttypepass(right);
  638. resulttypepass(right);
  639. aktstate.store_fact(left.getcopy,right.getcopy);
  640. end
  641. else
  642. aktstate.delete_fact(left);
  643. end;
  644. {$endif}
  645. {*****************************************************************************
  646. TARRAYCONSTRUCTORRANGENODE
  647. *****************************************************************************}
  648. constructor tarrayconstructorrangenode.create(l,r : tnode);
  649. begin
  650. inherited create(arrayconstructorrangen,l,r);
  651. end;
  652. function tarrayconstructorrangenode.det_resulttype:tnode;
  653. begin
  654. result:=nil;
  655. resulttypepass(left);
  656. resulttypepass(right);
  657. set_varstate(left,true);
  658. set_varstate(right,true);
  659. if codegenerror then
  660. exit;
  661. resulttype:=left.resulttype;
  662. end;
  663. function tarrayconstructorrangenode.pass_1 : tnode;
  664. begin
  665. firstpass(left);
  666. firstpass(right);
  667. expectloc:=LOC_CREFERENCE;
  668. calcregisters(self,0,0,0);
  669. result:=nil;
  670. end;
  671. {****************************************************************************
  672. TARRAYCONSTRUCTORNODE
  673. *****************************************************************************}
  674. constructor tarrayconstructornode.create(l,r : tnode);
  675. begin
  676. inherited create(arrayconstructorn,l,r);
  677. end;
  678. function tarrayconstructornode.getcopy : tnode;
  679. var
  680. n : tarrayconstructornode;
  681. begin
  682. n:=tarrayconstructornode(inherited getcopy);
  683. result:=n;
  684. end;
  685. function tarrayconstructornode.det_resulttype:tnode;
  686. var
  687. htype : ttype;
  688. hp : tarrayconstructornode;
  689. len : longint;
  690. varia : boolean;
  691. begin
  692. result:=nil;
  693. { are we allowing array constructor? Then convert it to a set }
  694. if not allow_array_constructor then
  695. begin
  696. hp:=tarrayconstructornode(getcopy);
  697. arrayconstructor_to_set(tnode(hp));
  698. result:=hp;
  699. exit;
  700. end;
  701. { only pass left tree, right tree contains next construct if any }
  702. htype.reset;
  703. len:=0;
  704. varia:=false;
  705. if assigned(left) then
  706. begin
  707. hp:=self;
  708. while assigned(hp) do
  709. begin
  710. resulttypepass(hp.left);
  711. set_varstate(hp.left,true);
  712. if (htype.def=nil) then
  713. htype:=hp.left.resulttype
  714. else
  715. begin
  716. if ((nf_novariaallowed in flags) or (not varia)) and
  717. (not equal_defs(htype.def,hp.left.resulttype.def)) then
  718. begin
  719. varia:=true;
  720. end;
  721. end;
  722. inc(len);
  723. hp:=tarrayconstructornode(hp.right);
  724. end;
  725. end;
  726. if not assigned(htype.def) then
  727. htype:=voidtype;
  728. resulttype.setdef(tarraydef.create(0,len-1,s32bittype));
  729. tarraydef(resulttype.def).setelementtype(htype);
  730. tarraydef(resulttype.def).IsConstructor:=true;
  731. tarraydef(resulttype.def).IsVariant:=varia;
  732. end;
  733. procedure tarrayconstructornode.force_type(tt:ttype);
  734. var
  735. hp : tarrayconstructornode;
  736. begin
  737. tarraydef(resulttype.def).setelementtype(tt);
  738. tarraydef(resulttype.def).IsConstructor:=true;
  739. tarraydef(resulttype.def).IsVariant:=false;
  740. if assigned(left) then
  741. begin
  742. hp:=self;
  743. while assigned(hp) do
  744. begin
  745. inserttypeconv(hp.left,tt);
  746. hp:=tarrayconstructornode(hp.right);
  747. end;
  748. end;
  749. end;
  750. function tarrayconstructornode.pass_1 : tnode;
  751. var
  752. thp,
  753. chp,
  754. hp : tarrayconstructornode;
  755. dovariant : boolean;
  756. htype : ttype;
  757. orgflags : tnodeflagset;
  758. begin
  759. dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
  760. result:=nil;
  761. { only pass left tree, right tree contains next construct if any }
  762. if assigned(left) then
  763. begin
  764. hp:=self;
  765. while assigned(hp) do
  766. begin
  767. firstpass(hp.left);
  768. { Insert typeconvs for array of const }
  769. if dovariant then
  770. begin
  771. case hp.left.resulttype.def.deftype of
  772. enumdef :
  773. begin
  774. hp.left:=ctypeconvnode.create_explicit(hp.left,s32bittype);
  775. firstpass(hp.left);
  776. end;
  777. arraydef :
  778. begin
  779. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  780. firstpass(hp.left);
  781. end;
  782. orddef :
  783. begin
  784. if is_integer(hp.left.resulttype.def) and
  785. not(is_64bitint(hp.left.resulttype.def)) then
  786. begin
  787. hp.left:=ctypeconvnode.create(hp.left,s32bittype);
  788. firstpass(hp.left);
  789. end;
  790. end;
  791. floatdef :
  792. begin
  793. { C uses 64bit floats }
  794. if nf_cargs in flags then
  795. hp.left:=ctypeconvnode.create(hp.left,s64floattype)
  796. else
  797. hp.left:=ctypeconvnode.create(hp.left,pbestrealtype^);
  798. firstpass(hp.left);
  799. end;
  800. stringdef :
  801. begin
  802. if nf_cargs in flags then
  803. begin
  804. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  805. firstpass(hp.left);
  806. end;
  807. end;
  808. procvardef :
  809. begin
  810. hp.left:=ctypeconvnode.create(hp.left,voidpointertype);
  811. firstpass(hp.left);
  812. end;
  813. variantdef,
  814. pointerdef,
  815. classrefdef,
  816. objectdef : ;
  817. else
  818. CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
  819. end;
  820. end;
  821. hp:=tarrayconstructornode(hp.right);
  822. end;
  823. { swap the tree for cargs }
  824. if (nf_cargs in flags) and (not(nf_cargswap in flags)) then
  825. begin
  826. chp:=nil;
  827. { save resulttype }
  828. htype:=resulttype;
  829. { we need a copy here, because self is destroyed }
  830. { by firstpass later }
  831. hp:=tarrayconstructornode(getcopy);
  832. { we also need a copy of the nf_ forcevaria flag to restore }
  833. { later) (JM) }
  834. orgflags := flags * [nf_forcevaria];
  835. while assigned(hp) do
  836. begin
  837. thp:=tarrayconstructornode(hp.right);
  838. hp.right:=chp;
  839. chp:=hp;
  840. hp:=thp;
  841. end;
  842. chp.flags := chp.flags+orgflags;
  843. include(chp.flags,nf_cargs);
  844. include(chp.flags,nf_cargswap);
  845. chp.expectloc:=LOC_CREFERENCE;
  846. calcregisters(chp,0,0,0);
  847. chp.resulttype:=htype;
  848. result:=chp;
  849. exit;
  850. end;
  851. end;
  852. { C style has pushed everything on the stack, so
  853. there is no return value }
  854. if (nf_cargs in flags) then
  855. expectloc:=LOC_VOID
  856. else
  857. expectloc:=LOC_CREFERENCE;
  858. { Calculate registers }
  859. calcregisters(self,0,0,0);
  860. end;
  861. function tarrayconstructornode.docompare(p: tnode): boolean;
  862. begin
  863. docompare :=
  864. inherited docompare(p);
  865. end;
  866. {*****************************************************************************
  867. TTYPENODE
  868. *****************************************************************************}
  869. constructor ttypenode.create(t : ttype);
  870. begin
  871. inherited create(typen);
  872. restype:=t;
  873. allowed:=false;
  874. end;
  875. constructor ttypenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  876. begin
  877. inherited ppuload(t,ppufile);
  878. ppufile.gettype(restype);
  879. allowed:=boolean(ppufile.getbyte);
  880. end;
  881. procedure ttypenode.ppuwrite(ppufile:tcompilerppufile);
  882. begin
  883. inherited ppuwrite(ppufile);
  884. ppufile.puttype(restype);
  885. ppufile.putbyte(byte(allowed));
  886. end;
  887. procedure ttypenode.derefimpl;
  888. begin
  889. inherited derefimpl;
  890. restype.resolve;
  891. end;
  892. function ttypenode.det_resulttype:tnode;
  893. begin
  894. result:=nil;
  895. resulttype:=restype;
  896. { check if it's valid }
  897. if restype.def.deftype = errordef then
  898. CGMessage(cg_e_illegal_expression);
  899. end;
  900. function ttypenode.pass_1 : tnode;
  901. begin
  902. result:=nil;
  903. expectloc:=LOC_VOID;
  904. { a typenode can't generate code, so we give here
  905. an error. Else it'll be an abstract error in pass_2.
  906. Only when the allowed flag is set we don't generate
  907. an error }
  908. if not allowed then
  909. Message(parser_e_no_type_not_allowed_here);
  910. end;
  911. function ttypenode.docompare(p: tnode): boolean;
  912. begin
  913. docompare :=
  914. inherited docompare(p);
  915. end;
  916. {*****************************************************************************
  917. TRTTINODE
  918. *****************************************************************************}
  919. constructor trttinode.create(def:tstoreddef;rt:trttitype);
  920. begin
  921. inherited create(rttin);
  922. rttidef:=def;
  923. rttitype:=rt;
  924. end;
  925. constructor trttinode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  926. begin
  927. inherited ppuload(t,ppufile);
  928. rttidef:=tstoreddef(ppufile.getderef);
  929. rttitype:=trttitype(ppufile.getbyte);
  930. end;
  931. procedure trttinode.ppuwrite(ppufile:tcompilerppufile);
  932. begin
  933. inherited ppuwrite(ppufile);
  934. ppufile.putderef(rttidef);
  935. ppufile.putbyte(byte(rttitype));
  936. end;
  937. procedure trttinode.derefimpl;
  938. begin
  939. inherited derefimpl;
  940. resolvedef(pointer(rttidef));
  941. end;
  942. function trttinode.getcopy : tnode;
  943. var
  944. n : trttinode;
  945. begin
  946. n:=trttinode(inherited getcopy);
  947. n.rttidef:=rttidef;
  948. n.rttitype:=rttitype;
  949. result:=n;
  950. end;
  951. function trttinode.det_resulttype:tnode;
  952. begin
  953. { rtti information will be returned as a void pointer }
  954. result:=nil;
  955. resulttype:=voidpointertype;
  956. end;
  957. function trttinode.pass_1 : tnode;
  958. begin
  959. result:=nil;
  960. expectloc:=LOC_CREFERENCE;
  961. end;
  962. function trttinode.docompare(p: tnode): boolean;
  963. begin
  964. docompare :=
  965. inherited docompare(p) and
  966. (rttidef = trttinode(p).rttidef) and
  967. (rttitype = trttinode(p).rttitype);
  968. end;
  969. procedure trttinode.pass_2;
  970. begin
  971. location_reset(location,LOC_CREFERENCE,OS_NO);
  972. location.reference.symbol:=rttidef.get_rtti_label(rttitype);
  973. end;
  974. begin
  975. cloadnode:=tloadnode;
  976. cassignmentnode:=tassignmentnode;
  977. carrayconstructorrangenode:=tarrayconstructorrangenode;
  978. carrayconstructornode:=tarrayconstructornode;
  979. ctypenode:=ttypenode;
  980. crttinode:=trttinode;
  981. end.
  982. {
  983. $Log$
  984. Revision 1.90 2003-04-27 11:21:33 peter
  985. * aktprocdef renamed to current_procdef
  986. * procinfo renamed to current_procinfo
  987. * procinfo will now be stored in current_module so it can be
  988. cleaned up properly
  989. * gen_main_procsym changed to create_main_proc and release_main_proc
  990. to also generate a tprocinfo structure
  991. * fixed unit implicit initfinal
  992. Revision 1.89 2003/04/27 07:29:50 peter
  993. * current_procdef cleanup, current_procdef is now always nil when parsing
  994. a new procdef declaration
  995. * aktprocsym removed
  996. * lexlevel removed, use symtable.symtablelevel instead
  997. * implicit init/final code uses the normal genentry/genexit
  998. * funcret state checking updated for new funcret handling
  999. Revision 1.88 2003/04/26 00:28:42 peter
  1000. * removed load_funcret
  1001. Revision 1.87 2003/04/25 20:59:33 peter
  1002. * removed funcretn,funcretsym, function result is now in varsym
  1003. and aliases for result and function name are added using absolutesym
  1004. * vs_hidden parameter for funcret passed in parameter
  1005. * vs_hidden fixes
  1006. * writenode changed to printnode and released from extdebug
  1007. * -vp option added to generate a tree.log with the nodetree
  1008. * nicer printnode for statements, callnode
  1009. Revision 1.86 2003/04/23 20:16:04 peter
  1010. + added currency support based on int64
  1011. + is_64bit for use in cg units instead of is_64bitint
  1012. * removed cgmessage from n386add, replace with internalerrors
  1013. Revision 1.85 2003/04/23 10:10:54 peter
  1014. * procvar is not compared in addrn
  1015. Revision 1.84 2003/04/22 23:50:23 peter
  1016. * firstpass uses expectloc
  1017. * checks if there are differences between the expectloc and
  1018. location.loc from secondpass in EXTDEBUG
  1019. Revision 1.83 2003/04/11 15:01:23 peter
  1020. * fix bug 2438
  1021. Revision 1.82 2003/03/28 19:16:56 peter
  1022. * generic constructor working for i386
  1023. * remove fixed self register
  1024. * esi added as address register for i386
  1025. Revision 1.81 2003/03/11 21:46:24 jonas
  1026. * lots of new regallocator fixes, both in generic and ppc-specific code
  1027. (ppc compiler still can't compile the linux system unit though)
  1028. Revision 1.80 2003/01/07 16:52:58 jonas
  1029. * fixed ansistring+char and ansistring+shortstring optimizations (those
  1030. cases were always handled as ansistring+ansistring due to
  1031. typeconversions inserted by the add-node)
  1032. Revision 1.79 2003/01/05 22:44:14 peter
  1033. * remove a lot of code to support typen in loadn-procsym
  1034. Revision 1.78 2003/01/03 12:15:56 daniel
  1035. * Removed ifdefs around notifications
  1036. ifdefs around for loop optimizations remain
  1037. Revision 1.77 2002/12/31 09:55:58 daniel
  1038. + Notification implementation complete
  1039. + Add for loop code optimization using notifications
  1040. results in 1.5-1.9% speed improvement in nestloop benchmark
  1041. Optimization incomplete, compiler does not cycle yet with
  1042. notifications enabled.
  1043. Revision 1.76 2002/12/30 22:44:53 daniel
  1044. * Some work on notifications
  1045. Revision 1.75 2002/12/27 15:27:25 peter
  1046. * remove property indicator when calling internal helpers
  1047. Revision 1.74 2002/12/24 16:53:19 peter
  1048. * fix for tb0438
  1049. Revision 1.73 2002/12/20 18:14:53 peter
  1050. * fix result of high_tree when high was not available
  1051. Revision 1.72 2002/12/17 22:19:33 peter
  1052. * fixed pushing of records>8 bytes with stdcall
  1053. * simplified hightree loading
  1054. Revision 1.71 2002/12/07 14:27:07 carl
  1055. * 3% memory optimization
  1056. * changed some types
  1057. + added type checking with different size for call node and for
  1058. parameters
  1059. Revision 1.70 2002/12/02 19:38:06 carl
  1060. * fix some errors
  1061. Revision 1.69 2002/11/29 20:02:44 carl
  1062. * warning / hint for possible loss of data in assignment
  1063. Revision 1.68 2002/11/27 20:04:39 peter
  1064. * cdecl array of const fixes
  1065. Revision 1.67 2002/11/27 15:33:47 peter
  1066. * the never ending story of tp procvar hacks
  1067. Revision 1.66 2002/11/25 17:43:20 peter
  1068. * splitted defbase in defutil,symutil,defcmp
  1069. * merged isconvertable and is_equal into compare_defs(_ext)
  1070. * made operator search faster by walking the list only once
  1071. Revision 1.65 2002/11/18 17:31:57 peter
  1072. * pass proccalloption to ret_in_xxx and push_xxx functions
  1073. Revision 1.64 2002/11/15 01:58:52 peter
  1074. * merged changes from 1.0.7 up to 04-11
  1075. - -V option for generating bug report tracing
  1076. - more tracing for option parsing
  1077. - errors for cdecl and high()
  1078. - win32 import stabs
  1079. - win32 records<=8 are returned in eax:edx (turned off by default)
  1080. - heaptrc update
  1081. - more info for temp management in .s file with EXTDEBUG
  1082. Revision 1.63 2002/10/17 12:44:09 florian
  1083. + s:=s+<string type> where s is an ansistring is done via calls to append_ansistring_*
  1084. Revision 1.62 2002/10/05 12:43:25 carl
  1085. * fixes for Delphi 6 compilation
  1086. (warning : Some features do not work under Delphi)
  1087. Revision 1.61 2002/10/03 21:26:08 carl
  1088. + compile-time range checking for strings
  1089. Revision 1.60 2002/09/27 21:13:28 carl
  1090. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  1091. Revision 1.59 2002/09/26 15:02:05 florian
  1092. + support of passing variants to "array of const"
  1093. Revision 1.58 2002/09/07 15:25:03 peter
  1094. * old logs removed and tabs fixed
  1095. Revision 1.57 2002/09/03 16:26:26 daniel
  1096. * Make Tprocdef.defs protected
  1097. Revision 1.56 2002/09/01 13:28:37 daniel
  1098. - write_access fields removed in favor of a flag
  1099. Revision 1.55 2002/09/01 08:01:16 daniel
  1100. * Removed sets from Tcallnode.det_resulttype
  1101. + Added read/write notifications of variables. These will be usefull
  1102. for providing information for several optimizations. For example
  1103. the value of the loop variable of a for loop does matter is the
  1104. variable is read after the for loop, but if it's no longer used
  1105. or written, it doesn't matter and this can be used to optimize
  1106. the loop code generation.
  1107. Revision 1.54 2002/08/25 19:25:19 peter
  1108. * sym.insert_in_data removed
  1109. * symtable.insertvardata/insertconstdata added
  1110. * removed insert_in_data call from symtable.insert, it needs to be
  1111. called separatly. This allows to deref the address calculation
  1112. * procedures now calculate the parast addresses after the procedure
  1113. directives are parsed. This fixes the cdecl parast problem
  1114. * push_addr_param has an extra argument that specifies if cdecl is used
  1115. or not
  1116. Revision 1.53 2002/08/19 19:36:43 peter
  1117. * More fixes for cross unit inlining, all tnodes are now implemented
  1118. * Moved pocall_internconst to po_internconst because it is not a
  1119. calling type at all and it conflicted when inlining of these small
  1120. functions was requested
  1121. Revision 1.52 2002/08/18 20:06:23 peter
  1122. * inlining is now also allowed in interface
  1123. * renamed write/load to ppuwrite/ppuload
  1124. * tnode storing in ppu
  1125. * nld,ncon,nbas are already updated for storing in ppu
  1126. Revision 1.51 2002/08/17 22:09:46 florian
  1127. * result type handling in tcgcal.pass_2 overhauled
  1128. * better tnode.dowrite
  1129. * some ppc stuff fixed
  1130. Revision 1.50 2002/08/17 09:23:37 florian
  1131. * first part of procinfo rewrite
  1132. Revision 1.49 2002/07/20 11:57:54 florian
  1133. * types.pas renamed to defbase.pas because D6 contains a types
  1134. unit so this would conflicts if D6 programms are compiled
  1135. + Willamette/SSE2 instructions to assembler added
  1136. Revision 1.48 2002/07/20 07:44:37 daniel
  1137. * Forgot to add a $ifdef extdebug
  1138. Revision 1.47 2002/07/19 12:55:27 daniel
  1139. * Further developed state tracking in whilerepeatn
  1140. Revision 1.46 2002/07/19 11:41:36 daniel
  1141. * State tracker work
  1142. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1143. allows the state tracker to change while nodes automatically into
  1144. repeat nodes.
  1145. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1146. 'not(a>b)' is optimized into 'a<=b'.
  1147. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1148. by removing the notn and later switchting the true and falselabels. The
  1149. same is done with 'repeat until not a'.
  1150. Revision 1.45 2002/07/15 18:03:15 florian
  1151. * readded removed changes
  1152. Revision 1.43 2002/07/11 14:41:28 florian
  1153. * start of the new generic parameter handling
  1154. Revision 1.44 2002/07/14 18:00:44 daniel
  1155. + Added the beginning of a state tracker. This will track the values of
  1156. variables through procedures and optimize things away.
  1157. Revision 1.42 2002/05/18 13:34:10 peter
  1158. * readded missing revisions
  1159. Revision 1.41 2002/05/16 19:46:38 carl
  1160. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1161. + try to fix temp allocation (still in ifdef)
  1162. + generic constructor calls
  1163. + start of tassembler / tmodulebase class cleanup
  1164. Revision 1.39 2002/05/12 16:53:07 peter
  1165. * moved entry and exitcode to ncgutil and cgobj
  1166. * foreach gets extra argument for passing local data to the
  1167. iterator function
  1168. * -CR checks also class typecasts at runtime by changing them
  1169. into as
  1170. * fixed compiler to cycle with the -CR option
  1171. * fixed stabs with elf writer, finally the global variables can
  1172. be watched
  1173. * removed a lot of routines from cga unit and replaced them by
  1174. calls to cgobj
  1175. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1176. u32bit then the other is typecasted also to u32bit without giving
  1177. a rangecheck warning/error.
  1178. * fixed pascal calling method with reversing also the high tree in
  1179. the parast, detected by tcalcst3 test
  1180. Revision 1.38 2002/04/25 20:16:39 peter
  1181. * moved more routines from cga/n386util
  1182. Revision 1.37 2002/04/23 19:16:34 peter
  1183. * add pinline unit that inserts compiler supported functions using
  1184. one or more statements
  1185. * moved finalize and setlength from ninl to pinline
  1186. }