nld.pas 26 KB

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