nld.pas 50 KB

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