nld.pas 50 KB

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