nld.pas 52 KB

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