nld.pas 53 KB

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