nld.pas 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491
  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. resulttypepass(right);
  553. set_varstate(left,false);
  554. set_varstate(right,true);
  555. { set_funcret_is_valid(left); }
  556. if codegenerror then
  557. exit;
  558. { assignments to open arrays aren't allowed }
  559. if is_open_array(left.resulttype.def) then
  560. CGMessage(type_e_mismatch);
  561. { test if node can be assigned, properties are allowed }
  562. valid_for_assignment(left);
  563. { assigning nil to a dynamic array clears the array }
  564. if is_dynamic_array(left.resulttype.def) and
  565. (right.nodetype=niln) then
  566. begin
  567. hp:=ccallparanode.create(caddrnode.create
  568. (crttinode.create(tstoreddef(left.resulttype.def),initrtti)),
  569. ccallparanode.create(ctypeconvnode.create_explicit(left,voidpointertype),nil));
  570. result := ccallnode.createintern('fpc_dynarray_clear',hp);
  571. left:=nil;
  572. exit;
  573. end;
  574. { shortstring helpers can do the conversion directly,
  575. so treat them separatly }
  576. if (is_shortstring(left.resulttype.def)) then
  577. begin
  578. { test for s:=s+anything ... }
  579. { the problem is for
  580. s:=s+s+s;
  581. this is broken here !! }
  582. {$ifdef newoptimizations2}
  583. { the above is fixed now, but still problem with s := s + f(); if }
  584. { f modifies s (bad programming, so only enable if uncertain }
  585. { optimizations are on) (JM) }
  586. if (cs_UncertainOpts in aktglobalswitches) then
  587. begin
  588. hp := right;
  589. while hp.treetype=addn do
  590. hp:=hp.left;
  591. if left.docompare(hp) then
  592. begin
  593. concat_string:=true;
  594. hp:=right;
  595. while hp.treetype=addn do
  596. begin
  597. hp.use_strconcat:=true;
  598. hp:=hp.left;
  599. end;
  600. end;
  601. end;
  602. {$endif newoptimizations2}
  603. { insert typeconv, except for chars that are handled in
  604. secondpass and except for ansi/wide string that can
  605. be converted immediatly }
  606. if not(is_char(right.resulttype.def) or
  607. (right.resulttype.def.deftype=stringdef)) then
  608. inserttypeconv(right,left.resulttype);
  609. if right.resulttype.def.deftype=stringdef then
  610. begin
  611. useshelper:=true;
  612. { convert constant strings to shortstrings. But
  613. skip empty constant strings, that will be handled
  614. in secondpass }
  615. if (right.nodetype=stringconstn) then
  616. begin
  617. { verify if range fits within shortstring }
  618. { just emit a warning, delphi gives an }
  619. { error, only if the type definition of }
  620. { of the string is less < 255 characters }
  621. if not is_open_string(left.resulttype.def) and
  622. (tstringconstnode(right).len > tstringdef(left.resulttype.def).len) then
  623. cgmessage(type_w_string_too_long);
  624. inserttypeconv(right,left.resulttype);
  625. if (tstringconstnode(right).len=0) then
  626. useshelper:=false;
  627. end;
  628. if useshelper then
  629. begin
  630. hp:=ccallparanode.create
  631. (right,
  632. ccallparanode.create(cinlinenode.create
  633. (in_high_x,false,left.getcopy),nil));
  634. result:=ccallnode.createinternreturn('fpc_'+tstringdef(right.resulttype.def).stringtypname+'_to_shortstr',hp,left);
  635. left:=nil;
  636. right:=nil;
  637. exit;
  638. end;
  639. end;
  640. end
  641. else
  642. begin
  643. { get the size before the type conversion - check for all nodes }
  644. if assigned(right.resulttype.def) and (right.nodetype in [loadn,vecn,calln]) then
  645. original_size := right.resulttype.def.size;
  646. inserttypeconv(right,left.resulttype);
  647. end;
  648. { check if the assignment may cause a range check error }
  649. { if its not explicit, and only if the values are }
  650. { ordinals, enumdef and floatdef }
  651. if (right.nodetype = typeconvn) and
  652. not (nf_explicit in ttypeconvnode(right).flags) then
  653. begin
  654. if assigned(left.resulttype.def) and
  655. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) then
  656. begin
  657. if (original_size <> 0) and (left.resulttype.def.size < original_size) then
  658. begin
  659. if (cs_check_range in aktlocalswitches) then
  660. Message(type_w_smaller_possible_range_check)
  661. else
  662. Message(type_h_smaller_possible_range_check);
  663. end;
  664. end;
  665. end;
  666. { call helpers for interface }
  667. if is_interfacecom(left.resulttype.def) then
  668. begin
  669. hp:=ccallparanode.create(ctypeconvnode.create_explicit
  670. (right,voidpointertype),
  671. ccallparanode.create(ctypeconvnode.create_explicit
  672. (left,voidpointertype),nil));
  673. result:=ccallnode.createintern('fpc_intf_assign',hp);
  674. left:=nil;
  675. right:=nil;
  676. exit;
  677. end;
  678. { check if local proc/func is assigned to procvar }
  679. if right.resulttype.def.deftype=procvardef then
  680. test_local_to_procvar(tprocvardef(right.resulttype.def),left.resulttype.def);
  681. end;
  682. function tassignmentnode.pass_1 : tnode;
  683. begin
  684. result:=nil;
  685. expectloc:=LOC_VOID;
  686. firstpass(left);
  687. firstpass(right);
  688. if codegenerror then
  689. exit;
  690. registers32:=left.registers32+right.registers32;
  691. registersfpu:=max(left.registersfpu,right.registersfpu);
  692. {$ifdef SUPPORT_MMX}
  693. registersmmx:=max(left.registersmmx,right.registersmmx);
  694. {$endif SUPPORT_MMX}
  695. end;
  696. function tassignmentnode.docompare(p: tnode): boolean;
  697. begin
  698. docompare :=
  699. inherited docompare(p) and
  700. (assigntype = tassignmentnode(p).assigntype);
  701. end;
  702. {$ifdef state_tracking}
  703. function Tassignmentnode.track_state_pass(exec_known:boolean):boolean;
  704. var se:Tstate_entry;
  705. begin
  706. track_state_pass:=false;
  707. if exec_known then
  708. begin
  709. track_state_pass:=right.track_state_pass(exec_known);
  710. {Force a new resulttype pass.}
  711. right.resulttype.def:=nil;
  712. do_resulttypepass(right);
  713. resulttypepass(right);
  714. aktstate.store_fact(left.getcopy,right.getcopy);
  715. end
  716. else
  717. aktstate.delete_fact(left);
  718. end;
  719. {$endif}
  720. {*****************************************************************************
  721. TARRAYCONSTRUCTORRANGENODE
  722. *****************************************************************************}
  723. constructor tarrayconstructorrangenode.create(l,r : tnode);
  724. begin
  725. inherited create(arrayconstructorrangen,l,r);
  726. end;
  727. function tarrayconstructorrangenode.det_resulttype:tnode;
  728. begin
  729. result:=nil;
  730. resulttypepass(left);
  731. resulttypepass(right);
  732. set_varstate(left,true);
  733. set_varstate(right,true);
  734. if codegenerror then
  735. exit;
  736. resulttype:=left.resulttype;
  737. end;
  738. function tarrayconstructorrangenode.pass_1 : tnode;
  739. begin
  740. firstpass(left);
  741. firstpass(right);
  742. expectloc:=LOC_CREFERENCE;
  743. calcregisters(self,0,0,0);
  744. result:=nil;
  745. end;
  746. {****************************************************************************
  747. TARRAYCONSTRUCTORNODE
  748. *****************************************************************************}
  749. constructor tarrayconstructornode.create(l,r : tnode);
  750. begin
  751. inherited create(arrayconstructorn,l,r);
  752. end;
  753. function tarrayconstructornode.getcopy : tnode;
  754. var
  755. n : tarrayconstructornode;
  756. begin
  757. n:=tarrayconstructornode(inherited getcopy);
  758. result:=n;
  759. end;
  760. function tarrayconstructornode.det_resulttype:tnode;
  761. var
  762. htype : ttype;
  763. hp : tarrayconstructornode;
  764. len : longint;
  765. varia : boolean;
  766. begin
  767. result:=nil;
  768. { are we allowing array constructor? Then convert it to a set }
  769. if not allow_array_constructor then
  770. begin
  771. hp:=tarrayconstructornode(getcopy);
  772. arrayconstructor_to_set(tnode(hp));
  773. result:=hp;
  774. exit;
  775. end;
  776. { only pass left tree, right tree contains next construct if any }
  777. htype.reset;
  778. len:=0;
  779. varia:=false;
  780. if assigned(left) then
  781. begin
  782. hp:=self;
  783. while assigned(hp) do
  784. begin
  785. resulttypepass(hp.left);
  786. set_varstate(hp.left,true);
  787. if (htype.def=nil) then
  788. htype:=hp.left.resulttype
  789. else
  790. begin
  791. if ((nf_novariaallowed in flags) or (not varia)) and
  792. (not equal_defs(htype.def,hp.left.resulttype.def)) then
  793. begin
  794. varia:=true;
  795. end;
  796. end;
  797. inc(len);
  798. hp:=tarrayconstructornode(hp.right);
  799. end;
  800. end;
  801. if not assigned(htype.def) then
  802. htype:=voidtype;
  803. resulttype.setdef(tarraydef.create(0,len-1,s32bittype));
  804. tarraydef(resulttype.def).setelementtype(htype);
  805. tarraydef(resulttype.def).IsConstructor:=true;
  806. tarraydef(resulttype.def).IsVariant:=varia;
  807. end;
  808. procedure tarrayconstructornode.force_type(tt:ttype);
  809. var
  810. hp : tarrayconstructornode;
  811. begin
  812. tarraydef(resulttype.def).setelementtype(tt);
  813. tarraydef(resulttype.def).IsConstructor:=true;
  814. tarraydef(resulttype.def).IsVariant:=false;
  815. if assigned(left) then
  816. begin
  817. hp:=self;
  818. while assigned(hp) do
  819. begin
  820. inserttypeconv(hp.left,tt);
  821. hp:=tarrayconstructornode(hp.right);
  822. end;
  823. end;
  824. end;
  825. function tarrayconstructornode.pass_1 : tnode;
  826. var
  827. thp,
  828. chp,
  829. hp : tarrayconstructornode;
  830. dovariant : boolean;
  831. htype : ttype;
  832. orgflags : tnodeflags;
  833. begin
  834. dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
  835. result:=nil;
  836. { only pass left tree, right tree contains next construct if any }
  837. if assigned(left) then
  838. begin
  839. hp:=self;
  840. while assigned(hp) do
  841. begin
  842. firstpass(hp.left);
  843. { Insert typeconvs for array of const }
  844. if dovariant then
  845. begin
  846. case hp.left.resulttype.def.deftype of
  847. enumdef :
  848. begin
  849. hp.left:=ctypeconvnode.create_explicit(hp.left,s32bittype);
  850. firstpass(hp.left);
  851. end;
  852. arraydef :
  853. begin
  854. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  855. firstpass(hp.left);
  856. end;
  857. orddef :
  858. begin
  859. if is_integer(hp.left.resulttype.def) and
  860. not(is_64bitint(hp.left.resulttype.def)) then
  861. begin
  862. hp.left:=ctypeconvnode.create(hp.left,s32bittype);
  863. firstpass(hp.left);
  864. end;
  865. end;
  866. floatdef :
  867. begin
  868. { C uses 64bit floats }
  869. if nf_cargs in flags then
  870. hp.left:=ctypeconvnode.create(hp.left,s64floattype)
  871. else
  872. hp.left:=ctypeconvnode.create(hp.left,pbestrealtype^);
  873. firstpass(hp.left);
  874. end;
  875. stringdef :
  876. begin
  877. if nf_cargs in flags then
  878. begin
  879. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  880. firstpass(hp.left);
  881. end;
  882. end;
  883. procvardef :
  884. begin
  885. hp.left:=ctypeconvnode.create(hp.left,voidpointertype);
  886. firstpass(hp.left);
  887. end;
  888. variantdef,
  889. pointerdef,
  890. classrefdef,
  891. objectdef : ;
  892. else
  893. CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
  894. end;
  895. end;
  896. hp:=tarrayconstructornode(hp.right);
  897. end;
  898. { swap the tree for cargs }
  899. if (nf_cargs in flags) and (not(nf_cargswap in flags)) then
  900. begin
  901. chp:=nil;
  902. { save resulttype }
  903. htype:=resulttype;
  904. { we need a copy here, because self is destroyed }
  905. { by firstpass later }
  906. hp:=tarrayconstructornode(getcopy);
  907. { we also need a copy of the nf_ forcevaria flag to restore }
  908. { later) (JM) }
  909. orgflags := flags * [nf_forcevaria];
  910. while assigned(hp) do
  911. begin
  912. thp:=tarrayconstructornode(hp.right);
  913. hp.right:=chp;
  914. chp:=hp;
  915. hp:=thp;
  916. end;
  917. chp.flags := chp.flags+orgflags;
  918. include(chp.flags,nf_cargs);
  919. include(chp.flags,nf_cargswap);
  920. chp.expectloc:=LOC_CREFERENCE;
  921. calcregisters(chp,0,0,0);
  922. chp.resulttype:=htype;
  923. result:=chp;
  924. exit;
  925. end;
  926. end;
  927. { C style has pushed everything on the stack, so
  928. there is no return value }
  929. if (nf_cargs in flags) then
  930. expectloc:=LOC_VOID
  931. else
  932. expectloc:=LOC_CREFERENCE;
  933. { Calculate registers }
  934. calcregisters(self,0,0,0);
  935. end;
  936. function tarrayconstructornode.docompare(p: tnode): boolean;
  937. begin
  938. docompare :=
  939. inherited docompare(p);
  940. end;
  941. {*****************************************************************************
  942. TTYPENODE
  943. *****************************************************************************}
  944. constructor ttypenode.create(t : ttype);
  945. begin
  946. inherited create(typen);
  947. restype:=t;
  948. allowed:=false;
  949. end;
  950. constructor ttypenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  951. begin
  952. inherited ppuload(t,ppufile);
  953. ppufile.gettype(restype);
  954. allowed:=boolean(ppufile.getbyte);
  955. end;
  956. procedure ttypenode.ppuwrite(ppufile:tcompilerppufile);
  957. begin
  958. inherited ppuwrite(ppufile);
  959. ppufile.puttype(restype);
  960. ppufile.putbyte(byte(allowed));
  961. end;
  962. procedure ttypenode.derefimpl;
  963. begin
  964. inherited derefimpl;
  965. restype.resolve;
  966. end;
  967. function ttypenode.det_resulttype:tnode;
  968. begin
  969. result:=nil;
  970. resulttype:=restype;
  971. { check if it's valid }
  972. if restype.def.deftype = errordef then
  973. CGMessage(cg_e_illegal_expression);
  974. end;
  975. function ttypenode.pass_1 : tnode;
  976. begin
  977. result:=nil;
  978. expectloc:=LOC_VOID;
  979. { a typenode can't generate code, so we give here
  980. an error. Else it'll be an abstract error in pass_2.
  981. Only when the allowed flag is set we don't generate
  982. an error }
  983. if not allowed then
  984. Message(parser_e_no_type_not_allowed_here);
  985. end;
  986. function ttypenode.docompare(p: tnode): boolean;
  987. begin
  988. docompare :=
  989. inherited docompare(p);
  990. end;
  991. {*****************************************************************************
  992. TRTTINODE
  993. *****************************************************************************}
  994. constructor trttinode.create(def:tstoreddef;rt:trttitype);
  995. begin
  996. inherited create(rttin);
  997. rttidef:=def;
  998. rttitype:=rt;
  999. end;
  1000. constructor trttinode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1001. begin
  1002. inherited ppuload(t,ppufile);
  1003. rttidef:=tstoreddef(ppufile.getderef);
  1004. rttitype:=trttitype(ppufile.getbyte);
  1005. end;
  1006. procedure trttinode.ppuwrite(ppufile:tcompilerppufile);
  1007. begin
  1008. inherited ppuwrite(ppufile);
  1009. ppufile.putderef(rttidef);
  1010. ppufile.putbyte(byte(rttitype));
  1011. end;
  1012. procedure trttinode.derefimpl;
  1013. begin
  1014. inherited derefimpl;
  1015. resolvedef(pointer(rttidef));
  1016. end;
  1017. function trttinode.getcopy : tnode;
  1018. var
  1019. n : trttinode;
  1020. begin
  1021. n:=trttinode(inherited getcopy);
  1022. n.rttidef:=rttidef;
  1023. n.rttitype:=rttitype;
  1024. result:=n;
  1025. end;
  1026. function trttinode.det_resulttype:tnode;
  1027. begin
  1028. { rtti information will be returned as a void pointer }
  1029. result:=nil;
  1030. resulttype:=voidpointertype;
  1031. end;
  1032. function trttinode.pass_1 : tnode;
  1033. begin
  1034. result:=nil;
  1035. expectloc:=LOC_CREFERENCE;
  1036. end;
  1037. function trttinode.docompare(p: tnode): boolean;
  1038. begin
  1039. docompare :=
  1040. inherited docompare(p) and
  1041. (rttidef = trttinode(p).rttidef) and
  1042. (rttitype = trttinode(p).rttitype);
  1043. end;
  1044. procedure trttinode.pass_2;
  1045. begin
  1046. location_reset(location,LOC_CREFERENCE,OS_NO);
  1047. location.reference.symbol:=rttidef.get_rtti_label(rttitype);
  1048. end;
  1049. begin
  1050. cloadnode:=tloadnode;
  1051. cassignmentnode:=tassignmentnode;
  1052. carrayconstructorrangenode:=tarrayconstructorrangenode;
  1053. carrayconstructornode:=tarrayconstructornode;
  1054. ctypenode:=ttypenode;
  1055. crttinode:=trttinode;
  1056. end.
  1057. {
  1058. $Log$
  1059. Revision 1.95 2003-05-23 17:05:13 peter
  1060. * loadn procsym need to return procdef
  1061. Revision 1.94 2003/05/23 14:27:35 peter
  1062. * remove some unit dependencies
  1063. * current_procinfo changes to store more info
  1064. Revision 1.93 2003/05/11 21:37:03 peter
  1065. * moved implicit exception frame from ncgutil to psub
  1066. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1067. Revision 1.92 2003/05/11 14:45:12 peter
  1068. * tloadnode does not support objectsymtable,withsymtable anymore
  1069. * withnode cleanup
  1070. * direct with rewritten to use temprefnode
  1071. Revision 1.91 2003/05/09 17:47:02 peter
  1072. * self moved to hidden parameter
  1073. * removed hdisposen,hnewn,selfn
  1074. Revision 1.90 2003/04/27 11:21:33 peter
  1075. * aktprocdef renamed to current_procdef
  1076. * procinfo renamed to current_procinfo
  1077. * procinfo will now be stored in current_module so it can be
  1078. cleaned up properly
  1079. * gen_main_procsym changed to create_main_proc and release_main_proc
  1080. to also generate a tprocinfo structure
  1081. * fixed unit implicit initfinal
  1082. Revision 1.89 2003/04/27 07:29:50 peter
  1083. * current_procdef cleanup, current_procdef is now always nil when parsing
  1084. a new procdef declaration
  1085. * aktprocsym removed
  1086. * lexlevel removed, use symtable.symtablelevel instead
  1087. * implicit init/final code uses the normal genentry/genexit
  1088. * funcret state checking updated for new funcret handling
  1089. Revision 1.88 2003/04/26 00:28:42 peter
  1090. * removed load_funcret
  1091. Revision 1.87 2003/04/25 20:59:33 peter
  1092. * removed funcretn,funcretsym, function result is now in varsym
  1093. and aliases for result and function name are added using absolutesym
  1094. * vs_hidden parameter for funcret passed in parameter
  1095. * vs_hidden fixes
  1096. * writenode changed to printnode and released from extdebug
  1097. * -vp option added to generate a tree.log with the nodetree
  1098. * nicer printnode for statements, callnode
  1099. Revision 1.86 2003/04/23 20:16:04 peter
  1100. + added currency support based on int64
  1101. + is_64bit for use in cg units instead of is_64bitint
  1102. * removed cgmessage from n386add, replace with internalerrors
  1103. Revision 1.85 2003/04/23 10:10:54 peter
  1104. * procvar is not compared in addrn
  1105. Revision 1.84 2003/04/22 23:50:23 peter
  1106. * firstpass uses expectloc
  1107. * checks if there are differences between the expectloc and
  1108. location.loc from secondpass in EXTDEBUG
  1109. Revision 1.83 2003/04/11 15:01:23 peter
  1110. * fix bug 2438
  1111. Revision 1.82 2003/03/28 19:16:56 peter
  1112. * generic constructor working for i386
  1113. * remove fixed self register
  1114. * esi added as address register for i386
  1115. Revision 1.81 2003/03/11 21:46:24 jonas
  1116. * lots of new regallocator fixes, both in generic and ppc-specific code
  1117. (ppc compiler still can't compile the linux system unit though)
  1118. Revision 1.80 2003/01/07 16:52:58 jonas
  1119. * fixed ansistring+char and ansistring+shortstring optimizations (those
  1120. cases were always handled as ansistring+ansistring due to
  1121. typeconversions inserted by the add-node)
  1122. Revision 1.79 2003/01/05 22:44:14 peter
  1123. * remove a lot of code to support typen in loadn-procsym
  1124. Revision 1.78 2003/01/03 12:15:56 daniel
  1125. * Removed ifdefs around notifications
  1126. ifdefs around for loop optimizations remain
  1127. Revision 1.77 2002/12/31 09:55:58 daniel
  1128. + Notification implementation complete
  1129. + Add for loop code optimization using notifications
  1130. results in 1.5-1.9% speed improvement in nestloop benchmark
  1131. Optimization incomplete, compiler does not cycle yet with
  1132. notifications enabled.
  1133. Revision 1.76 2002/12/30 22:44:53 daniel
  1134. * Some work on notifications
  1135. Revision 1.75 2002/12/27 15:27:25 peter
  1136. * remove property indicator when calling internal helpers
  1137. Revision 1.74 2002/12/24 16:53:19 peter
  1138. * fix for tb0438
  1139. Revision 1.73 2002/12/20 18:14:53 peter
  1140. * fix result of high_tree when high was not available
  1141. Revision 1.72 2002/12/17 22:19:33 peter
  1142. * fixed pushing of records>8 bytes with stdcall
  1143. * simplified hightree loading
  1144. Revision 1.71 2002/12/07 14:27:07 carl
  1145. * 3% memory optimization
  1146. * changed some types
  1147. + added type checking with different size for call node and for
  1148. parameters
  1149. Revision 1.70 2002/12/02 19:38:06 carl
  1150. * fix some errors
  1151. Revision 1.69 2002/11/29 20:02:44 carl
  1152. * warning / hint for possible loss of data in assignment
  1153. Revision 1.68 2002/11/27 20:04:39 peter
  1154. * cdecl array of const fixes
  1155. Revision 1.67 2002/11/27 15:33:47 peter
  1156. * the never ending story of tp procvar hacks
  1157. Revision 1.66 2002/11/25 17:43:20 peter
  1158. * splitted defbase in defutil,symutil,defcmp
  1159. * merged isconvertable and is_equal into compare_defs(_ext)
  1160. * made operator search faster by walking the list only once
  1161. Revision 1.65 2002/11/18 17:31:57 peter
  1162. * pass proccalloption to ret_in_xxx and push_xxx functions
  1163. Revision 1.64 2002/11/15 01:58:52 peter
  1164. * merged changes from 1.0.7 up to 04-11
  1165. - -V option for generating bug report tracing
  1166. - more tracing for option parsing
  1167. - errors for cdecl and high()
  1168. - win32 import stabs
  1169. - win32 records<=8 are returned in eax:edx (turned off by default)
  1170. - heaptrc update
  1171. - more info for temp management in .s file with EXTDEBUG
  1172. Revision 1.63 2002/10/17 12:44:09 florian
  1173. + s:=s+<string type> where s is an ansistring is done via calls to append_ansistring_*
  1174. Revision 1.62 2002/10/05 12:43:25 carl
  1175. * fixes for Delphi 6 compilation
  1176. (warning : Some features do not work under Delphi)
  1177. Revision 1.61 2002/10/03 21:26:08 carl
  1178. + compile-time range checking for strings
  1179. Revision 1.60 2002/09/27 21:13:28 carl
  1180. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  1181. Revision 1.59 2002/09/26 15:02:05 florian
  1182. + support of passing variants to "array of const"
  1183. Revision 1.58 2002/09/07 15:25:03 peter
  1184. * old logs removed and tabs fixed
  1185. Revision 1.57 2002/09/03 16:26:26 daniel
  1186. * Make Tprocdef.defs protected
  1187. Revision 1.56 2002/09/01 13:28:37 daniel
  1188. - write_access fields removed in favor of a flag
  1189. Revision 1.55 2002/09/01 08:01:16 daniel
  1190. * Removed sets from Tcallnode.det_resulttype
  1191. + Added read/write notifications of variables. These will be usefull
  1192. for providing information for several optimizations. For example
  1193. the value of the loop variable of a for loop does matter is the
  1194. variable is read after the for loop, but if it's no longer used
  1195. or written, it doesn't matter and this can be used to optimize
  1196. the loop code generation.
  1197. Revision 1.54 2002/08/25 19:25:19 peter
  1198. * sym.insert_in_data removed
  1199. * symtable.insertvardata/insertconstdata added
  1200. * removed insert_in_data call from symtable.insert, it needs to be
  1201. called separatly. This allows to deref the address calculation
  1202. * procedures now calculate the parast addresses after the procedure
  1203. directives are parsed. This fixes the cdecl parast problem
  1204. * push_addr_param has an extra argument that specifies if cdecl is used
  1205. or not
  1206. Revision 1.53 2002/08/19 19:36:43 peter
  1207. * More fixes for cross unit inlining, all tnodes are now implemented
  1208. * Moved pocall_internconst to po_internconst because it is not a
  1209. calling type at all and it conflicted when inlining of these small
  1210. functions was requested
  1211. Revision 1.52 2002/08/18 20:06:23 peter
  1212. * inlining is now also allowed in interface
  1213. * renamed write/load to ppuwrite/ppuload
  1214. * tnode storing in ppu
  1215. * nld,ncon,nbas are already updated for storing in ppu
  1216. Revision 1.51 2002/08/17 22:09:46 florian
  1217. * result type handling in tcgcal.pass_2 overhauled
  1218. * better tnode.dowrite
  1219. * some ppc stuff fixed
  1220. Revision 1.50 2002/08/17 09:23:37 florian
  1221. * first part of procinfo rewrite
  1222. Revision 1.49 2002/07/20 11:57:54 florian
  1223. * types.pas renamed to defbase.pas because D6 contains a types
  1224. unit so this would conflicts if D6 programms are compiled
  1225. + Willamette/SSE2 instructions to assembler added
  1226. Revision 1.48 2002/07/20 07:44:37 daniel
  1227. * Forgot to add a $ifdef extdebug
  1228. Revision 1.47 2002/07/19 12:55:27 daniel
  1229. * Further developed state tracking in whilerepeatn
  1230. Revision 1.46 2002/07/19 11:41:36 daniel
  1231. * State tracker work
  1232. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1233. allows the state tracker to change while nodes automatically into
  1234. repeat nodes.
  1235. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1236. 'not(a>b)' is optimized into 'a<=b'.
  1237. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1238. by removing the notn and later switchting the true and falselabels. The
  1239. same is done with 'repeat until not a'.
  1240. Revision 1.45 2002/07/15 18:03:15 florian
  1241. * readded removed changes
  1242. Revision 1.43 2002/07/11 14:41:28 florian
  1243. * start of the new generic parameter handling
  1244. Revision 1.44 2002/07/14 18:00:44 daniel
  1245. + Added the beginning of a state tracker. This will track the values of
  1246. variables through procedures and optimize things away.
  1247. Revision 1.42 2002/05/18 13:34:10 peter
  1248. * readded missing revisions
  1249. Revision 1.41 2002/05/16 19:46:38 carl
  1250. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1251. + try to fix temp allocation (still in ifdef)
  1252. + generic constructor calls
  1253. + start of tassembler / tmodulebase class cleanup
  1254. Revision 1.39 2002/05/12 16:53:07 peter
  1255. * moved entry and exitcode to ncgutil and cgobj
  1256. * foreach gets extra argument for passing local data to the
  1257. iterator function
  1258. * -CR checks also class typecasts at runtime by changing them
  1259. into as
  1260. * fixed compiler to cycle with the -CR option
  1261. * fixed stabs with elf writer, finally the global variables can
  1262. be watched
  1263. * removed a lot of routines from cga unit and replaced them by
  1264. calls to cgobj
  1265. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1266. u32bit then the other is typecasted also to u32bit without giving
  1267. a rangecheck warning/error.
  1268. * fixed pascal calling method with reversing also the high tree in
  1269. the parast, detected by tcalcst3 test
  1270. Revision 1.38 2002/04/25 20:16:39 peter
  1271. * moved more routines from cga/n386util
  1272. Revision 1.37 2002/04/23 19:16:34 peter
  1273. * add pinline unit that inserts compiler supported functions using
  1274. one or more statements
  1275. * moved finalize and setlength from ninl to pinline
  1276. }