nld.pas 53 KB

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