nld.pas 50 KB

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