nld.pas 52 KB

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