nld.pas 28 KB

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