nld.pas 49 KB

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