2
0

nld.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. {
  2. $Id$
  3. Copyright (c) 2000 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 defines.inc}
  20. interface
  21. uses
  22. node,
  23. symbase,symtype,symsym;
  24. type
  25. tloadnode = class(tunarynode)
  26. symtableentry : psym;
  27. symtable : psymtable;
  28. constructor create(v : psym;st : psymtable);virtual;
  29. procedure set_mp(p:tnode);
  30. function getcopy : tnode;override;
  31. function pass_1 : tnode;override;
  32. function det_resulttype:tnode;override;
  33. function docompare(p: tnode): boolean; override;
  34. end;
  35. { different assignment types }
  36. tassigntype = (at_normal,at_plus,at_minus,at_star,at_slash);
  37. tassignmentnode = class(tbinarynode)
  38. assigntype : tassigntype;
  39. constructor create(l,r : tnode);virtual;
  40. function getcopy : tnode;override;
  41. function pass_1 : tnode;override;
  42. function det_resulttype:tnode;override;
  43. function docompare(p: tnode): boolean; override;
  44. end;
  45. tfuncretnode = class(tnode)
  46. funcretprocinfo : pointer;
  47. constructor create(p:pointer);virtual;
  48. function getcopy : tnode;override;
  49. function pass_1 : tnode;override;
  50. function det_resulttype:tnode;override;
  51. function docompare(p: tnode): boolean; override;
  52. end;
  53. tarrayconstructorrangenode = class(tbinarynode)
  54. constructor create(l,r : tnode);virtual;
  55. function pass_1 : tnode;override;
  56. function det_resulttype:tnode;override;
  57. end;
  58. tarrayconstructornode = class(tbinarynode)
  59. constructortype : ttype;
  60. constructor create(l,r : tnode);virtual;
  61. function getcopy : tnode;override;
  62. function pass_1 : tnode;override;
  63. function det_resulttype:tnode;override;
  64. function docompare(p: tnode): boolean; override;
  65. end;
  66. ttypenode = class(tnode)
  67. restype : ttype;
  68. constructor create(t : ttype);virtual;
  69. function pass_1 : tnode;override;
  70. function det_resulttype:tnode;override;
  71. function docompare(p: tnode): boolean; override;
  72. end;
  73. var
  74. cloadnode : class of tloadnode;
  75. cassignmentnode : class of tassignmentnode;
  76. cfuncretnode : class of tfuncretnode;
  77. carrayconstructorrangenode : class of tarrayconstructorrangenode;
  78. carrayconstructornode : class of tarrayconstructornode;
  79. ctypenode : class of ttypenode;
  80. implementation
  81. uses
  82. cutils,verbose,globtype,globals,systems,
  83. symconst,symdef,symtable,types,
  84. htypechk,pass_1,
  85. ncnv,nmem,cpubase,tgcpu,hcodegen
  86. {$ifdef newcg}
  87. ,cgbase
  88. ,tgobj
  89. {$endif newcg}
  90. ;
  91. {*****************************************************************************
  92. TLOADNODE
  93. *****************************************************************************}
  94. constructor tloadnode.create(v : psym;st : psymtable);
  95. begin
  96. inherited create(loadn,nil);
  97. symtableentry:=v;
  98. symtable:=st;
  99. end;
  100. procedure tloadnode.set_mp(p:tnode);
  101. begin
  102. left:=p;
  103. end;
  104. function tloadnode.getcopy : tnode;
  105. var
  106. n : tloadnode;
  107. begin
  108. n:=tloadnode(inherited getcopy);
  109. n.symtable:=symtable;
  110. n.symtableentry:=symtableentry;
  111. result:=n;
  112. end;
  113. function tloadnode.det_resulttype:tnode;
  114. begin
  115. result:=nil;
  116. case symtableentry^.typ of
  117. absolutesym,
  118. varsym :
  119. resulttype:=pvarsym(symtableentry)^.vartype;
  120. constsym :
  121. resulttype:=pconstsym(symtableentry)^.consttype;
  122. typedconstsym :
  123. resulttype:=ptypedconstsym(symtableentry)^.typedconsttype;
  124. procsym :
  125. resulttype.setdef(pprocsym(symtableentry)^.definition);
  126. else
  127. internalerror(534785349);
  128. end;
  129. end;
  130. function tloadnode.pass_1 : tnode;
  131. var
  132. p1 : tnode;
  133. begin
  134. result:=nil;
  135. if (symtable^.symtabletype=withsymtable) and
  136. (pwithsymtable(symtable)^.direct_with) and
  137. (symtableentry^.typ=varsym) then
  138. begin
  139. p1:=tnode(pwithsymtable(symtable)^.withrefnode).getcopy;
  140. p1:=csubscriptnode.create(pvarsym(symtableentry),p1);
  141. left:=nil;
  142. firstpass(p1);
  143. result:=p1;
  144. exit;
  145. end;
  146. location.loc:=LOC_REFERENCE;
  147. registers32:=0;
  148. registersfpu:=0;
  149. {$ifdef SUPPORT_MMX}
  150. registersmmx:=0;
  151. {$endif SUPPORT_MMX}
  152. { handle first absolute as it will replace the symtableentry }
  153. if symtableentry^.typ=absolutesym then
  154. begin
  155. { replace the symtableentry when it points to a var, else
  156. we are finished }
  157. if pabsolutesym(symtableentry)^.abstyp=tovar then
  158. begin
  159. symtableentry:=pabsolutesym(symtableentry)^.ref;
  160. symtable:=symtableentry^.owner;
  161. include(flags,nf_absolute);
  162. end
  163. else
  164. exit;
  165. end;
  166. case symtableentry^.typ of
  167. funcretsym :
  168. begin
  169. p1:=cfuncretnode.create(pfuncretsym(symtableentry)^.funcretprocinfo);
  170. firstpass(p1);
  171. { if it's refered as absolute then we need to have the
  172. type of the absolute instead of the function return,
  173. the function return is then also assigned }
  174. if nf_absolute in flags then
  175. begin
  176. pprocinfo(tfuncretnode(p1).funcretprocinfo)^.funcret_state:=vs_assigned;
  177. p1.resulttype:=resulttype;
  178. end;
  179. left:=nil;
  180. result:=p1;
  181. end;
  182. constsym:
  183. begin
  184. if pconstsym(symtableentry)^.consttyp=constresourcestring then
  185. begin
  186. resulttype:=cansistringtype;
  187. { we use ansistrings so no fast exit here }
  188. if assigned(procinfo) then
  189. procinfo^.no_fast_exit:=true;
  190. location.loc:=LOC_MEM;
  191. end
  192. else
  193. internalerror(22799);
  194. end;
  195. varsym :
  196. begin
  197. { if it's refered by absolute then it's used }
  198. if nf_absolute in flags then
  199. pvarsym(symtableentry)^.varstate:=vs_used;
  200. if (symtable^.symtabletype in [parasymtable,localsymtable]) and
  201. (lexlevel>symtable^.symtablelevel) then
  202. begin
  203. { if the variable is in an other stackframe then we need
  204. a register to dereference }
  205. if (symtable^.symtablelevel)>0 then
  206. begin
  207. registers32:=1;
  208. { further, the variable can't be put into a register }
  209. pvarsym(symtableentry)^.varoptions:=
  210. pvarsym(symtableentry)^.varoptions-[vo_fpuregable,vo_regable];
  211. end;
  212. end;
  213. if (pvarsym(symtableentry)^.varspez=vs_const) then
  214. location.loc:=LOC_MEM;
  215. { we need a register for call by reference parameters }
  216. if (pvarsym(symtableentry)^.varspez in [vs_var,vs_out]) or
  217. ((pvarsym(symtableentry)^.varspez=vs_const) and
  218. push_addr_param(pvarsym(symtableentry)^.vartype.def)) or
  219. { call by value open arrays are also indirect addressed }
  220. is_open_array(pvarsym(symtableentry)^.vartype.def) then
  221. registers32:=1;
  222. if symtable^.symtabletype=withsymtable then
  223. inc(registers32);
  224. if ([vo_is_thread_var,vo_is_dll_var]*pvarsym(symtableentry)^.varoptions)<>[] then
  225. registers32:=1;
  226. { count variable references }
  227. { this will create problem with local var set by
  228. under_procedures
  229. if (assigned(pvarsym(symtableentry)^.owner) and assigned(aktprocsym)
  230. and ((pvarsym(symtableentry)^.owner = aktprocsym^.definition^.localst)
  231. or (pvarsym(symtableentry)^.owner = aktprocsym^.definition^.localst))) then }
  232. if t_times<1 then
  233. inc(pvarsym(symtableentry)^.refs)
  234. else
  235. inc(pvarsym(symtableentry)^.refs,t_times);
  236. end;
  237. typedconstsym :
  238. if not(nf_absolute in flags) then
  239. resulttype:=ptypedconstsym(symtableentry)^.typedconsttype;
  240. procsym :
  241. begin
  242. if assigned(pprocsym(symtableentry)^.definition^.nextoverloaded) then
  243. CGMessage(parser_e_no_overloaded_procvars);
  244. resulttype.setdef(pprocsym(symtableentry)^.definition);
  245. { if the owner of the procsym is a object, }
  246. { left must be set, if left isn't set }
  247. { it can be only self }
  248. { this code is only used in TP procvar mode }
  249. if (m_tp_procvar in aktmodeswitches) and
  250. not(assigned(left)) and
  251. (pprocsym(symtableentry)^.owner^.symtabletype=objectsymtable) then
  252. begin
  253. left:=cselfnode.create(pobjectdef(symtableentry^.owner^.defowner));
  254. end;
  255. { method pointer ? }
  256. if assigned(left) then
  257. begin
  258. firstpass(left);
  259. registers32:=max(registers32,left.registers32);
  260. registersfpu:=max(registersfpu,left.registersfpu);
  261. {$ifdef SUPPORT_MMX}
  262. registersmmx:=max(registersmmx,left.registersmmx);
  263. {$endif SUPPORT_MMX}
  264. end;
  265. end;
  266. else
  267. internalerror(3);
  268. end;
  269. end;
  270. function tloadnode.docompare(p: tnode): boolean;
  271. begin
  272. docompare :=
  273. inherited docompare(p) and
  274. (symtableentry = tloadnode(p).symtableentry) and
  275. (symtable = tloadnode(p).symtable);
  276. end;
  277. {*****************************************************************************
  278. TASSIGNMENTNODE
  279. *****************************************************************************}
  280. constructor tassignmentnode.create(l,r : tnode);
  281. begin
  282. inherited create(assignn,l,r);
  283. assigntype:=at_normal;
  284. end;
  285. function tassignmentnode.getcopy : tnode;
  286. var
  287. n : tassignmentnode;
  288. begin
  289. n:=tassignmentnode(inherited getcopy);
  290. n.assigntype:=assigntype;
  291. getcopy:=n;
  292. end;
  293. function tassignmentnode.det_resulttype:tnode;
  294. begin
  295. result:=nil;
  296. resulttype:=voidtype;
  297. { must be made unique }
  298. if assigned(left) then
  299. begin
  300. set_unique(left);
  301. { set we the function result? }
  302. set_funcret_is_valid(left);
  303. end;
  304. resulttypepass(left);
  305. resulttypepass(right);
  306. set_varstate(left,false);
  307. set_varstate(right,true);
  308. if codegenerror then
  309. exit;
  310. { assignments to open arrays aren't allowed }
  311. if is_open_array(left.resulttype.def) then
  312. CGMessage(type_e_mismatch);
  313. { some string functions don't need conversion, so treat them separatly }
  314. if not (
  315. is_shortstring(left.resulttype.def) and
  316. (
  317. is_shortstring(right.resulttype.def) or
  318. is_ansistring(right.resulttype.def) or
  319. is_char(right.resulttype.def)
  320. )
  321. ) then
  322. inserttypeconv(right,left.resulttype);
  323. { test if node can be assigned, properties are allowed }
  324. valid_for_assign(left,true);
  325. { check if local proc/func is assigned to procvar }
  326. if right.resulttype.def^.deftype=procvardef then
  327. test_local_to_procvar(pprocvardef(right.resulttype.def),left.resulttype.def);
  328. end;
  329. function tassignmentnode.pass_1 : tnode;
  330. begin
  331. result:=nil;
  332. firstpass(left);
  333. firstpass(right);
  334. if codegenerror then
  335. exit;
  336. { some string functions don't need conversion, so treat them separatly }
  337. if is_shortstring(left.resulttype.def) and
  338. (
  339. is_shortstring(right.resulttype.def) or
  340. is_ansistring(right.resulttype.def) or
  341. is_char(right.resulttype.def)
  342. ) then
  343. begin
  344. { we call STRCOPY }
  345. procinfo^.flags:=procinfo^.flags or pi_do_call;
  346. { test for s:=s+anything ... }
  347. { the problem is for
  348. s:=s+s+s;
  349. this is broken here !! }
  350. {$ifdef newoptimizations2}
  351. { the above is fixed now, but still problem with s := s + f(); if }
  352. { f modifies s (bad programming, so only enable if uncertain }
  353. { optimizations are on) (JM) }
  354. if (cs_UncertainOpts in aktglobalswitches) then
  355. begin
  356. hp := right;
  357. while hp.treetype=addn do hp:=hp.left;
  358. if equal_trees(left,hp) and
  359. not multiple_uses(left,right) then
  360. begin
  361. concat_string:=true;
  362. hp:=right;
  363. while hp.treetype=addn do
  364. begin
  365. hp.use_strconcat:=true;
  366. hp:=hp.left;
  367. end;
  368. end;
  369. end;
  370. {$endif newoptimizations2}
  371. end;
  372. registers32:=left.registers32+right.registers32;
  373. registersfpu:=max(left.registersfpu,right.registersfpu);
  374. {$ifdef SUPPORT_MMX}
  375. registersmmx:=max(left.registersmmx,right.registersmmx);
  376. {$endif SUPPORT_MMX}
  377. end;
  378. function tassignmentnode.docompare(p: tnode): boolean;
  379. begin
  380. docompare :=
  381. inherited docompare(p) and
  382. (assigntype = tassignmentnode(p).assigntype);
  383. end;
  384. {*****************************************************************************
  385. TFUNCRETNODE
  386. *****************************************************************************}
  387. constructor tfuncretnode.create(p:pointer);
  388. begin
  389. inherited create(funcretn);
  390. funcretprocinfo:=p;
  391. end;
  392. function tfuncretnode.getcopy : tnode;
  393. var
  394. n : tfuncretnode;
  395. begin
  396. n:=tfuncretnode(inherited getcopy);
  397. n.funcretprocinfo:=funcretprocinfo;
  398. getcopy:=n;
  399. end;
  400. function tfuncretnode.det_resulttype:tnode;
  401. begin
  402. result:=nil;
  403. resulttype:=pprocinfo(funcretprocinfo)^.returntype;
  404. end;
  405. function tfuncretnode.pass_1 : tnode;
  406. begin
  407. result:=nil;
  408. location.loc:=LOC_REFERENCE;
  409. if ret_in_param(resulttype.def) or
  410. (procinfo<>pprocinfo(funcretprocinfo)) then
  411. registers32:=1;
  412. end;
  413. function tfuncretnode.docompare(p: tnode): boolean;
  414. begin
  415. docompare :=
  416. inherited docompare(p) and
  417. (funcretprocinfo = tfuncretnode(p).funcretprocinfo);
  418. end;
  419. {*****************************************************************************
  420. TARRAYCONSTRUCTORRANGENODE
  421. *****************************************************************************}
  422. constructor tarrayconstructorrangenode.create(l,r : tnode);
  423. begin
  424. inherited create(arrayconstructorrangen,l,r);
  425. end;
  426. function tarrayconstructorrangenode.det_resulttype:tnode;
  427. begin
  428. result:=nil;
  429. resulttypepass(left);
  430. resulttypepass(right);
  431. set_varstate(left,true);
  432. set_varstate(right,true);
  433. if codegenerror then
  434. exit;
  435. resulttype:=left.resulttype;
  436. end;
  437. function tarrayconstructorrangenode.pass_1 : tnode;
  438. begin
  439. firstpass(left);
  440. firstpass(right);
  441. calcregisters(self,0,0,0);
  442. result:=nil;
  443. end;
  444. {****************************************************************************
  445. TARRAYCONSTRUCTORNODE
  446. *****************************************************************************}
  447. constructor tarrayconstructornode.create(l,r : tnode);
  448. begin
  449. inherited create(arrayconstructorn,l,r);
  450. constructortype.reset;
  451. end;
  452. function tarrayconstructornode.getcopy : tnode;
  453. var
  454. n : tarrayconstructornode;
  455. begin
  456. n:=tarrayconstructornode(inherited getcopy);
  457. n.constructortype:=constructortype;
  458. result:=n;
  459. end;
  460. function tarrayconstructornode.det_resulttype:tnode;
  461. var
  462. htype : ttype;
  463. hp : tarrayconstructornode;
  464. len : longint;
  465. varia : boolean;
  466. begin
  467. result:=nil;
  468. { are we allowing array constructor? Then convert it to a set }
  469. if not allow_array_constructor then
  470. begin
  471. hp:=tarrayconstructornode(getcopy);
  472. arrayconstructor_to_set(hp);
  473. resulttypepass(hp);
  474. result:=hp;
  475. exit;
  476. end;
  477. { only pass left tree, right tree contains next construct if any }
  478. htype:=constructortype;
  479. len:=0;
  480. varia:=false;
  481. if assigned(left) then
  482. begin
  483. hp:=self;
  484. while assigned(hp) do
  485. begin
  486. resulttypepass(hp.left);
  487. set_varstate(hp.left,true);
  488. if (htype.def=nil) then
  489. htype:=hp.left.resulttype
  490. else
  491. begin
  492. if ((nf_novariaallowed in flags) or (not varia)) and
  493. (not is_equal(htype.def,hp.left.resulttype.def)) then
  494. begin
  495. varia:=true;
  496. end;
  497. end;
  498. inc(len);
  499. hp:=tarrayconstructornode(hp.right);
  500. end;
  501. end;
  502. if not assigned(htype.def) then
  503. htype:=voidtype;
  504. resulttype.setdef(new(parraydef,init(0,len-1,s32bittype)));
  505. parraydef(resulttype.def)^.elementtype:=htype;
  506. parraydef(resulttype.def)^.IsConstructor:=true;
  507. parraydef(resulttype.def)^.IsVariant:=varia;
  508. end;
  509. function tarrayconstructornode.pass_1 : tnode;
  510. var
  511. htype : ttype;
  512. thp,
  513. chp,
  514. hp : tarrayconstructornode;
  515. len : longint;
  516. varia : boolean;
  517. procedure postprocess(t : tnode);
  518. begin
  519. calcregisters(tbinarynode(t),0,0,0);
  520. { looks a little bit dangerous to me }
  521. { len-1 gives problems with is_open_array if len=0, }
  522. { is_open_array checks now for isconstructor (FK) }
  523. { if no type is set then we set the type to voiddef to overcome a
  524. 0 addressing }
  525. if not assigned(htype.def) then
  526. htype:=voidtype;
  527. { skip if already done ! (PM) }
  528. if not assigned(t.resulttype.def) or
  529. (t.resulttype.def^.deftype<>arraydef) or
  530. not parraydef(t.resulttype.def)^.IsConstructor or
  531. (parraydef(t.resulttype.def)^.lowrange<>0) or
  532. (parraydef(t.resulttype.def)^.highrange<>len-1) then
  533. t.resulttype.setdef(new(parraydef,init(0,len-1,s32bittype)));
  534. parraydef(t.resulttype.def)^.elementtype:=htype;
  535. parraydef(t.resulttype.def)^.IsConstructor:=true;
  536. parraydef(t.resulttype.def)^.IsVariant:=varia;
  537. t.location.loc:=LOC_MEM;
  538. end;
  539. begin
  540. result:=nil;
  541. { only pass left tree, right tree contains next construct if any }
  542. htype:=constructortype;
  543. len:=0;
  544. varia:=false;
  545. if assigned(left) then
  546. begin
  547. hp:=self;
  548. while assigned(hp) do
  549. begin
  550. firstpass(hp.left);
  551. set_varstate(hp.left,true);
  552. if (not get_para_resulttype) and
  553. (not(nf_novariaallowed in flags)) then
  554. begin
  555. case hp.left.resulttype.def^.deftype of
  556. enumdef :
  557. begin
  558. hp.left:=ctypeconvnode.create(hp.left,s32bittype);
  559. firstpass(hp.left);
  560. end;
  561. orddef :
  562. begin
  563. if is_integer(hp.left.resulttype.def) and
  564. not(is_64bitint(hp.left.resulttype.def)) then
  565. begin
  566. hp.left:=ctypeconvnode.create(hp.left,s32bittype);
  567. firstpass(hp.left);
  568. end;
  569. end;
  570. floatdef :
  571. begin
  572. hp.left:=ctypeconvnode.create(hp.left,pbestrealtype^);
  573. firstpass(hp.left);
  574. end;
  575. stringdef :
  576. begin
  577. if nf_cargs in flags then
  578. begin
  579. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  580. firstpass(hp.left);
  581. end;
  582. end;
  583. procvardef :
  584. begin
  585. hp.left:=ctypeconvnode.create(hp.left,voidpointertype);
  586. firstpass(hp.left);
  587. end;
  588. pointerdef,
  589. classrefdef,
  590. objectdef : ;
  591. else
  592. CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def^.typename);
  593. end;
  594. end;
  595. if (htype.def=nil) then
  596. htype:=hp.left.resulttype
  597. else
  598. begin
  599. if ((nf_novariaallowed in flags) or (not varia)) and
  600. (not is_equal(htype.def,hp.left.resulttype.def)) then
  601. begin
  602. { if both should be equal try inserting a conversion }
  603. if nf_novariaallowed in flags then
  604. begin
  605. hp.left:=ctypeconvnode.create(hp.left,htype);
  606. firstpass(hp.left);
  607. end;
  608. varia:=true;
  609. end;
  610. end;
  611. inc(len);
  612. hp:=tarrayconstructornode(hp.right);
  613. end;
  614. { swap the tree for cargs }
  615. if (nf_cargs in flags) and (not(nf_cargswap in flags)) then
  616. begin
  617. chp:=nil;
  618. { we need a copy here, because self is destroyed }
  619. { by firstpass later }
  620. hp:=tarrayconstructornode(getcopy);
  621. while assigned(hp) do
  622. begin
  623. thp:=tarrayconstructornode(hp.right);
  624. hp.right:=chp;
  625. chp:=hp;
  626. hp:=thp;
  627. end;
  628. include(chp.flags,nf_cargs);
  629. include(chp.flags,nf_cargswap);
  630. postprocess(chp);
  631. result:=chp;
  632. exit;
  633. end;
  634. end;
  635. postprocess(self);
  636. end;
  637. function tarrayconstructornode.docompare(p: tnode): boolean;
  638. begin
  639. docompare :=
  640. inherited docompare(p) and
  641. (constructortype.def = tarrayconstructornode(p).constructortype.def);
  642. end;
  643. {*****************************************************************************
  644. TTYPENODE
  645. *****************************************************************************}
  646. constructor ttypenode.create(t : ttype);
  647. begin
  648. inherited create(typen);
  649. restype:=t;
  650. end;
  651. function ttypenode.det_resulttype:tnode;
  652. begin
  653. result:=nil;
  654. resulttype:=restype;
  655. end;
  656. function ttypenode.pass_1 : tnode;
  657. begin
  658. result:=nil;
  659. end;
  660. function ttypenode.docompare(p: tnode): boolean;
  661. begin
  662. docompare :=
  663. inherited docompare(p);
  664. end;
  665. begin
  666. cloadnode:=tloadnode;
  667. cassignmentnode:=tassignmentnode;
  668. cfuncretnode:=tfuncretnode;
  669. carrayconstructorrangenode:=tarrayconstructorrangenode;
  670. carrayconstructornode:=tarrayconstructornode;
  671. ctypenode:=ttypenode;
  672. end.
  673. {
  674. $Log$
  675. Revision 1.11 2001-04-02 21:20:31 peter
  676. * resulttype rewrite
  677. Revision 1.10 2000/12/31 11:14:10 jonas
  678. + implemented/fixed docompare() mathods for all nodes (not tested)
  679. + nopt.pas, nadd.pas, i386/n386opt.pas: optimized nodes for adding strings
  680. and constant strings/chars together
  681. * n386add.pas: don't copy temp strings (of size 256) to another temp string
  682. when adding
  683. Revision 1.9 2000/11/29 00:30:33 florian
  684. * unused units removed from uses clause
  685. * some changes for widestrings
  686. Revision 1.8 2000/11/04 14:25:20 florian
  687. + merged Attila's changes for interfaces, not tested yet
  688. Revision 1.7 2000/10/31 22:02:49 peter
  689. * symtable splitted, no real code changes
  690. Revision 1.6 2000/10/14 10:14:50 peter
  691. * moehrendorf oct 2000 rewrite
  692. Revision 1.5 2000/10/01 19:48:24 peter
  693. * lot of compile updates for cg11
  694. Revision 1.4 2000/09/28 19:49:52 florian
  695. *** empty log message ***
  696. Revision 1.3 2000/09/27 18:14:31 florian
  697. * fixed a lot of syntax errors in the n*.pas stuff
  698. Revision 1.2 2000/09/25 15:37:14 florian
  699. * more fixes
  700. Revision 1.1 2000/09/25 14:55:05 florian
  701. * initial revision
  702. }