ncnv.pas 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468
  1. {
  2. $Id$
  3. Copyright (c) 2000 by Florian Klaempfl
  4. Type checking and register allocation for type converting 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 ncnv;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. node,
  23. symtype,types,
  24. nld;
  25. type
  26. ttypeconvnode = class(tunarynode)
  27. totype : ttype;
  28. convtype : tconverttype;
  29. constructor create(node : tnode;const t : ttype);virtual;
  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. private
  35. function resulttype_cord_to_pointer : tnode;
  36. function resulttype_string_to_string : tnode;
  37. function resulttype_char_to_string : tnode;
  38. function resulttype_int_to_real : tnode;
  39. function resulttype_real_to_real : tnode;
  40. function resulttype_cchar_to_pchar : tnode;
  41. function resulttype_char_to_char : tnode;
  42. function resulttype_arrayconstructor_to_set : tnode;
  43. function resulttype_call_helper(c : tconverttype) : tnode;
  44. protected
  45. function first_int_to_int : tnode;virtual;
  46. function first_cstring_to_pchar : tnode;virtual;
  47. function first_string_to_chararray : tnode;virtual;
  48. function first_string_to_string : tnode;virtual;
  49. function first_char_to_string : tnode;virtual;
  50. function first_nothing : tnode;virtual;
  51. function first_array_to_pointer : tnode;virtual;
  52. function first_int_to_real : tnode;virtual;
  53. function first_real_to_real : tnode;virtual;
  54. function first_pointer_to_array : tnode;virtual;
  55. function first_chararray_to_string : tnode;virtual;
  56. function first_cchar_to_pchar : tnode;virtual;
  57. function first_bool_to_int : tnode;virtual;
  58. function first_int_to_bool : tnode;virtual;
  59. function first_bool_to_bool : tnode;virtual;
  60. function first_proc_to_procvar : tnode;virtual;
  61. function first_load_smallset : tnode;virtual;
  62. function first_cord_to_pointer : tnode;virtual;
  63. function first_pchar_to_string : tnode;virtual;
  64. function first_ansistring_to_pchar : tnode;virtual;
  65. function first_arrayconstructor_to_set : tnode;virtual;
  66. function first_class_to_intf : tnode;virtual;
  67. function first_char_to_char : tnode;virtual;
  68. function first_call_helper(c : tconverttype) : tnode;
  69. end;
  70. tasnode = class(tbinarynode)
  71. constructor create(l,r : tnode);virtual;
  72. function pass_1 : tnode;override;
  73. function det_resulttype:tnode;override;
  74. end;
  75. tisnode = class(tbinarynode)
  76. constructor create(l,r : tnode);virtual;
  77. function pass_1 : tnode;override;
  78. function det_resulttype:tnode;override;
  79. end;
  80. var
  81. ctypeconvnode : class of ttypeconvnode;
  82. casnode : class of tasnode;
  83. cisnode : class of tisnode;
  84. procedure inserttypeconv(var p:tnode;const t:ttype);
  85. procedure arrayconstructor_to_set(var p : tarrayconstructornode);
  86. implementation
  87. uses
  88. globtype,systems,tokens,
  89. cutils,verbose,globals,widestr,
  90. symconst,symdef,symsym,symtable,
  91. ncon,ncal,nset,nadd,
  92. {$ifdef newcg}
  93. cgbase,
  94. {$else newcg}
  95. hcodegen,
  96. {$endif newcg}
  97. htypechk,pass_1,cpubase,cpuinfo;
  98. {*****************************************************************************
  99. Helpers
  100. *****************************************************************************}
  101. procedure inserttypeconv(var p:tnode;const t:ttype);
  102. begin
  103. if not assigned(p.resulttype.def) then
  104. begin
  105. resulttypepass(p);
  106. if codegenerror then
  107. exit;
  108. end;
  109. { don't insert obsolete type conversions }
  110. if is_equal(p.resulttype.def,t.def) then
  111. begin
  112. p.resulttype:=t;
  113. end
  114. else
  115. begin
  116. p:=ctypeconvnode.create(p,t);
  117. resulttypepass(p);
  118. end;
  119. end;
  120. {*****************************************************************************
  121. Array constructor to Set Conversion
  122. *****************************************************************************}
  123. procedure arrayconstructor_to_set(var p : tarrayconstructornode);
  124. var
  125. constp : tsetconstnode;
  126. buildp,
  127. p2,p3,p4 : tnode;
  128. htype : ttype;
  129. constset : pconstset;
  130. constsetlo,
  131. constsethi : longint;
  132. procedure update_constsethi(t:ttype);
  133. begin
  134. if ((t.def.deftype=orddef) and
  135. (torddef(t.def).high>=constsethi)) then
  136. begin
  137. constsethi:=torddef(t.def).high;
  138. if htype.def=nil then
  139. begin
  140. if (constsethi>255) or
  141. (torddef(t.def).low<0) then
  142. htype:=u8bittype
  143. else
  144. htype:=t;
  145. end;
  146. if constsethi>255 then
  147. constsethi:=255;
  148. end
  149. else if ((t.def.deftype=enumdef) and
  150. (tenumdef(t.def).max>=constsethi)) then
  151. begin
  152. if htype.def=nil then
  153. htype:=t;
  154. constsethi:=tenumdef(t.def).max;
  155. end;
  156. end;
  157. procedure do_set(pos : longint);
  158. var
  159. mask,l : longint;
  160. begin
  161. if (pos>255) or (pos<0) then
  162. Message(parser_e_illegal_set_expr);
  163. if pos>constsethi then
  164. constsethi:=pos;
  165. if pos<constsetlo then
  166. constsetlo:=pos;
  167. l:=pos shr 3;
  168. mask:=1 shl (pos mod 8);
  169. { do we allow the same twice }
  170. if (constset^[l] and mask)<>0 then
  171. Message(parser_e_illegal_set_expr);
  172. constset^[l]:=constset^[l] or mask;
  173. end;
  174. var
  175. l : longint;
  176. lr,hr : longint;
  177. begin
  178. new(constset);
  179. FillChar(constset^,sizeof(constset^),0);
  180. htype.reset;
  181. constsetlo:=0;
  182. constsethi:=0;
  183. constp:=csetconstnode.create(nil,htype);
  184. constp.value_set:=constset;
  185. buildp:=constp;
  186. if assigned(p.left) then
  187. begin
  188. while assigned(p) do
  189. begin
  190. p4:=nil; { will contain the tree to create the set }
  191. {split a range into p2 and p3 }
  192. if p.left.nodetype=arrayconstructorrangen then
  193. begin
  194. p2:=tarrayconstructorrangenode(p.left).left;
  195. p3:=tarrayconstructorrangenode(p.left).right;
  196. tarrayconstructorrangenode(p.left).left:=nil;
  197. tarrayconstructorrangenode(p.left).right:=nil;
  198. end
  199. else
  200. begin
  201. p2:=p.left;
  202. p.left:=nil;
  203. p3:=nil;
  204. end;
  205. resulttypepass(p2);
  206. if assigned(p3) then
  207. resulttypepass(p3);
  208. if codegenerror then
  209. break;
  210. case p2.resulttype.def.deftype of
  211. enumdef,
  212. orddef:
  213. begin
  214. getrange(p2.resulttype.def,lr,hr);
  215. if assigned(p3) then
  216. begin
  217. { this isn't good, you'll get problems with
  218. type t010 = 0..10;
  219. ts = set of t010;
  220. var s : ts;b : t010
  221. begin s:=[1,2,b]; end.
  222. if is_integer(p3^.resulttype.def) then
  223. begin
  224. inserttypeconv(p3,u8bitdef);
  225. end;
  226. }
  227. if assigned(htype.def) and not(is_equal(htype.def,p3.resulttype.def)) then
  228. begin
  229. aktfilepos:=p3.fileinfo;
  230. CGMessage(type_e_typeconflict_in_set);
  231. end
  232. else
  233. begin
  234. if (p2.nodetype=ordconstn) and (p3.nodetype=ordconstn) then
  235. begin
  236. if not(is_integer(p3.resulttype.def)) then
  237. htype:=p3.resulttype
  238. else
  239. begin
  240. inserttypeconv(p3,u8bittype);
  241. inserttypeconv(p2,u8bittype);
  242. end;
  243. for l:=tordconstnode(p2).value to tordconstnode(p3).value do
  244. do_set(l);
  245. p2.free;
  246. p3.free;
  247. end
  248. else
  249. begin
  250. update_constsethi(p2.resulttype);
  251. inserttypeconv(p2,htype);
  252. update_constsethi(p3.resulttype);
  253. inserttypeconv(p3,htype);
  254. if assigned(htype.def) then
  255. inserttypeconv(p3,htype)
  256. else
  257. inserttypeconv(p3,u8bittype);
  258. p4:=csetelementnode.create(p2,p3);
  259. end;
  260. end;
  261. end
  262. else
  263. begin
  264. { Single value }
  265. if p2.nodetype=ordconstn then
  266. begin
  267. if not(is_integer(p2.resulttype.def)) then
  268. update_constsethi(p2.resulttype)
  269. else
  270. inserttypeconv(p2,u8bittype);
  271. do_set(tordconstnode(p2).value);
  272. p2.free;
  273. end
  274. else
  275. begin
  276. update_constsethi(p2.resulttype);
  277. if assigned(htype.def) then
  278. inserttypeconv(p2,htype)
  279. else
  280. inserttypeconv(p2,u8bittype);
  281. p4:=csetelementnode.create(p2,nil);
  282. end;
  283. end;
  284. end;
  285. stringdef :
  286. begin
  287. { if we've already set elements which are constants }
  288. { throw an error }
  289. if ((htype.def=nil) and assigned(buildp)) or
  290. not(is_char(htype.def)) then
  291. CGMessage(type_e_typeconflict_in_set)
  292. else
  293. for l:=1 to length(pstring(tstringconstnode(p2).value_str)^) do
  294. do_set(ord(pstring(tstringconstnode(p2).value_str)^[l]));
  295. if htype.def=nil then
  296. htype:=cchartype;
  297. p2.free;
  298. end;
  299. else
  300. CGMessage(type_e_ordinal_expr_expected);
  301. end;
  302. { insert the set creation tree }
  303. if assigned(p4) then
  304. buildp:=caddnode.create(addn,buildp,p4);
  305. { load next and dispose current node }
  306. p2:=p;
  307. p:=tarrayconstructornode(tarrayconstructornode(p2).right);
  308. tarrayconstructornode(p2).right:=nil;
  309. p2.free;
  310. end;
  311. if (htype.def=nil) then
  312. begin
  313. htype:=u8bittype;
  314. constsethi:=255;
  315. end;
  316. end
  317. else
  318. begin
  319. { empty set [], only remove node }
  320. p.free;
  321. end;
  322. { set the initial set type }
  323. constp.resulttype.setdef(tsetdef.create(htype,constsethi));
  324. { determine the resulttype for the tree }
  325. resulttypepass(buildp);
  326. { set the new tree }
  327. p:=tarrayconstructornode(buildp);
  328. end;
  329. {*****************************************************************************
  330. TTYPECONVNODE
  331. *****************************************************************************}
  332. constructor ttypeconvnode.create(node : tnode;const t:ttype);
  333. begin
  334. inherited create(typeconvn,node);
  335. convtype:=tc_not_possible;
  336. totype:=t;
  337. if t.def=nil then
  338. internalerror(200103281);
  339. set_file_line(node);
  340. end;
  341. function ttypeconvnode.getcopy : tnode;
  342. var
  343. n : ttypeconvnode;
  344. begin
  345. n:=ttypeconvnode(inherited getcopy);
  346. n.convtype:=convtype;
  347. getcopy:=n;
  348. end;
  349. function ttypeconvnode.resulttype_cord_to_pointer : tnode;
  350. var
  351. t : tnode;
  352. begin
  353. result:=nil;
  354. if left.nodetype=ordconstn then
  355. begin
  356. { check if we have a valid pointer constant (JM) }
  357. if (sizeof(tordconstnode) > sizeof(tpointerord)) then
  358. if (sizeof(tpointerord) = 4) then
  359. begin
  360. if (tordconstnode(left).value < low(longint)) or
  361. (tordconstnode(left).value > high(cardinal)) then
  362. CGMessage(parser_e_range_check_error);
  363. end
  364. else if (sizeof(tpointerord) = 8) then
  365. begin
  366. if (tordconstnode(left).value < low(int64)) or
  367. (tordconstnode(left).value > high(qword)) then
  368. CGMessage(parser_e_range_check_error);
  369. end
  370. else
  371. internalerror(2001020801);
  372. t:=cpointerconstnode.create(tpointerord(tordconstnode(left).value),resulttype);
  373. resulttypepass(t);
  374. result:=t;
  375. end
  376. else
  377. internalerror(200104023);
  378. end;
  379. function ttypeconvnode.resulttype_string_to_string : tnode;
  380. begin
  381. result:=nil;
  382. if left.nodetype=stringconstn then
  383. begin
  384. tstringconstnode(left).st_type:=tstringdef(resulttype.def).string_typ;
  385. tstringconstnode(left).resulttype:=resulttype;
  386. result:=left;
  387. left:=nil;
  388. end;
  389. end;
  390. function ttypeconvnode.resulttype_char_to_string : tnode;
  391. var
  392. hp : tstringconstnode;
  393. begin
  394. result:=nil;
  395. if left.nodetype=ordconstn then
  396. begin
  397. hp:=cstringconstnode.createstr(chr(tordconstnode(left).value),st_default);
  398. hp.st_type:=tstringdef(resulttype.def).string_typ;
  399. resulttypepass(hp);
  400. result:=hp;
  401. end;
  402. end;
  403. function ttypeconvnode.resulttype_char_to_char : tnode;
  404. var
  405. hp : tordconstnode;
  406. begin
  407. result:=nil;
  408. if torddef(resulttype.def).typ=uchar then
  409. begin
  410. hp:=cordconstnode.create(
  411. ord(unicode2asciichar(tcompilerwidechar(tordconstnode(left).value))),cchartype);
  412. resulttypepass(hp);
  413. result:=hp;
  414. end
  415. else
  416. begin
  417. hp:=cordconstnode.create(
  418. asciichar2unicode(chr(tordconstnode(left).value)),cwidechartype);
  419. resulttypepass(hp);
  420. result:=hp;
  421. end;
  422. end;
  423. function ttypeconvnode.resulttype_int_to_real : tnode;
  424. var
  425. t : trealconstnode;
  426. begin
  427. result:=nil;
  428. if left.nodetype=ordconstn then
  429. begin
  430. t:=crealconstnode.create(tordconstnode(left).value,resulttype);
  431. resulttypepass(t);
  432. result:=t;
  433. exit;
  434. end;
  435. end;
  436. function ttypeconvnode.resulttype_real_to_real : tnode;
  437. var
  438. t : tnode;
  439. begin
  440. result:=nil;
  441. if left.nodetype=realconstn then
  442. begin
  443. t:=crealconstnode.create(trealconstnode(left).value_real,resulttype);
  444. resulttypepass(t);
  445. result:=t;
  446. end;
  447. end;
  448. function ttypeconvnode.resulttype_cchar_to_pchar : tnode;
  449. begin
  450. result:=nil;
  451. inserttypeconv(left,cshortstringtype);
  452. { evaluate again, reset resulttype so the convert_typ
  453. will be calculated again }
  454. result:=det_resulttype;
  455. end;
  456. function ttypeconvnode.resulttype_arrayconstructor_to_set : tnode;
  457. var
  458. hp : tnode;
  459. begin
  460. result:=nil;
  461. if left.nodetype<>arrayconstructorn then
  462. internalerror(5546);
  463. { remove typeconv node }
  464. hp:=left;
  465. left:=nil;
  466. { create a set constructor tree }
  467. arrayconstructor_to_set(tarrayconstructornode(hp));
  468. { now resulttypepass the set }
  469. resulttypepass(hp);
  470. result:=hp;
  471. end;
  472. function ttypeconvnode.resulttype_call_helper(c : tconverttype) : tnode;
  473. const
  474. resulttypeconvert : array[tconverttype] of pointer = (
  475. {equal} nil,
  476. {not_possible} nil,
  477. { string_2_string } @ttypeconvnode.resulttype_string_to_string,
  478. { char_2_string } @ttypeconvnode.resulttype_char_to_string,
  479. { pchar_2_string } nil,
  480. { cchar_2_pchar } @ttypeconvnode.resulttype_cchar_to_pchar,
  481. { cstring_2_pchar } nil,
  482. { ansistring_2_pchar } nil,
  483. { string_2_chararray } nil,
  484. { chararray_2_string } nil,
  485. { array_2_pointer } nil,
  486. { pointer_2_array } nil,
  487. { int_2_int } nil,
  488. { int_2_bool } nil,
  489. { bool_2_bool } nil,
  490. { bool_2_int } nil,
  491. { real_2_real } @ttypeconvnode.resulttype_real_to_real,
  492. { int_2_real } @ttypeconvnode.resulttype_int_to_real,
  493. { proc_2_procvar } nil,
  494. { arrayconstructor_2_set } @ttypeconvnode.resulttype_arrayconstructor_to_set,
  495. { load_smallset } nil,
  496. { cord_2_pointer } @ttypeconvnode.resulttype_cord_to_pointer,
  497. { intf_2_string } nil,
  498. { intf_2_guid } nil,
  499. { class_2_intf } nil,
  500. { char_2_char } @ttypeconvnode.resulttype_char_to_char
  501. );
  502. type
  503. tprocedureofobject = function : tnode of object;
  504. var
  505. r : packed record
  506. proc : pointer;
  507. obj : pointer;
  508. end;
  509. begin
  510. result:=nil;
  511. { this is a little bit dirty but it works }
  512. { and should be quite portable too }
  513. r.proc:=resulttypeconvert[c];
  514. r.obj:=self;
  515. if assigned(r.proc) then
  516. result:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  517. end;
  518. function ttypeconvnode.det_resulttype:tnode;
  519. var
  520. hp : tnode;
  521. aprocdef : tprocdef;
  522. begin
  523. result:=nil;
  524. resulttype:=totype;
  525. resulttypepass(left);
  526. if codegenerror then
  527. exit;
  528. { remove obsolete type conversions }
  529. if is_equal(left.resulttype.def,resulttype.def) then
  530. begin
  531. { becuase is_equal only checks the basetype for sets we need to
  532. check here if we are loading a smallset into a normalset }
  533. if (resulttype.def.deftype=setdef) and
  534. (left.resulttype.def.deftype=setdef) and
  535. (tsetdef(resulttype.def).settype<>smallset) and
  536. (tsetdef(left.resulttype.def).settype=smallset) then
  537. begin
  538. { try to define the set as a normalset if it's a constant set }
  539. if left.nodetype=setconstn then
  540. begin
  541. resulttype:=left.resulttype;
  542. tsetdef(resulttype.def).settype:=normset
  543. end
  544. else
  545. convtype:=tc_load_smallset;
  546. exit;
  547. end
  548. else
  549. begin
  550. left.resulttype:=resulttype;
  551. result:=left;
  552. left:=nil;
  553. exit;
  554. end;
  555. end;
  556. aprocdef:=assignment_overloaded(left.resulttype.def,resulttype.def);
  557. if assigned(aprocdef) then
  558. begin
  559. procinfo^.flags:=procinfo^.flags or pi_do_call;
  560. hp:=ccallnode.create(ccallparanode.create(left,nil),
  561. overloaded_operators[_assignment],nil,nil);
  562. { tell explicitly which def we must use !! (PM) }
  563. tcallnode(hp).procdefinition:=aprocdef;
  564. left:=nil;
  565. resulttypepass(hp);
  566. result:=hp;
  567. exit;
  568. end;
  569. if isconvertable(left.resulttype.def,resulttype.def,convtype,left.nodetype,nf_explizit in flags)=0 then
  570. begin
  571. {Procedures have a resulttype.def of voiddef and functions of their
  572. own resulttype.def. They will therefore always be incompatible with
  573. a procvar. Because isconvertable cannot check for procedures we
  574. use an extra check for them.}
  575. if (m_tp_procvar in aktmodeswitches) then
  576. begin
  577. if (resulttype.def.deftype=procvardef) and
  578. (is_procsym_load(left) or is_procsym_call(left)) then
  579. begin
  580. if is_procsym_call(left) then
  581. begin
  582. hp:=cloadnode.create(tprocsym(tcallnode(left).symtableprocentry),
  583. tcallnode(left).symtableproc);
  584. if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
  585. assigned(tcallnode(left).methodpointer) then
  586. tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
  587. resulttypepass(hp);
  588. left.free;
  589. left:=hp;
  590. aprocdef:=tprocdef(left.resulttype.def);
  591. end
  592. else
  593. begin
  594. if (left.nodetype<>addrn) then
  595. aprocdef:=tprocsym(tloadnode(left).symtableentry).definition;
  596. end;
  597. convtype:=tc_proc_2_procvar;
  598. { Now check if the procedure we are going to assign to
  599. the procvar, is compatible with the procvar's type }
  600. if assigned(aprocdef) then
  601. begin
  602. if not proc_to_procvar_equal(aprocdef,tprocvardef(resulttype.def)) then
  603. CGMessage2(type_e_incompatible_types,aprocdef.typename,resulttype.def.typename);
  604. end
  605. else
  606. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  607. exit;
  608. end;
  609. end;
  610. if nf_explizit in flags then
  611. begin
  612. { check if the result could be in a register }
  613. if not(tstoreddef(resulttype.def).is_intregable) and
  614. not(tstoreddef(resulttype.def).is_fpuregable) then
  615. make_not_regable(left);
  616. { boolean to byte are special because the
  617. location can be different }
  618. if is_integer(resulttype.def) and
  619. is_boolean(left.resulttype.def) then
  620. begin
  621. convtype:=tc_bool_2_int;
  622. exit;
  623. end;
  624. { ansistring to pchar }
  625. if is_pchar(resulttype.def) and
  626. is_ansistring(left.resulttype.def) then
  627. begin
  628. convtype:=tc_ansistring_2_pchar;
  629. exit;
  630. end;
  631. { do common tc_equal cast }
  632. convtype:=tc_equal;
  633. { enum to ordinal will always be s32bit }
  634. if (left.resulttype.def.deftype=enumdef) and
  635. is_ordinal(resulttype.def) then
  636. begin
  637. if left.nodetype=ordconstn then
  638. begin
  639. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  640. resulttypepass(hp);
  641. result:=hp;
  642. exit;
  643. end
  644. else
  645. begin
  646. if isconvertable(s32bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  647. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  648. end;
  649. end
  650. { ordinal to enumeration }
  651. else
  652. if (resulttype.def.deftype=enumdef) and
  653. is_ordinal(left.resulttype.def) then
  654. begin
  655. if left.nodetype=ordconstn then
  656. begin
  657. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  658. resulttypepass(hp);
  659. result:=hp;
  660. exit;
  661. end
  662. else
  663. begin
  664. if IsConvertable(left.resulttype.def,s32bittype.def,convtype,ordconstn,false)=0 then
  665. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  666. end;
  667. end
  668. { nil to ordinal node }
  669. else if (left.nodetype=niln) and is_ordinal(resulttype.def) then
  670. begin
  671. hp:=cordconstnode.create(0,resulttype);
  672. resulttypepass(hp);
  673. result:=hp;
  674. exit;
  675. end
  676. { constant pointer to ordinal }
  677. else if is_ordinal(resulttype.def) and
  678. (left.nodetype=pointerconstn) then
  679. begin
  680. hp:=cordconstnode.create(tpointerconstnode(left).value,resulttype);
  681. resulttypepass(hp);
  682. result:=hp;
  683. exit;
  684. end
  685. {Are we typecasting an ordconst to a char?}
  686. else
  687. if is_char(resulttype.def) and
  688. is_ordinal(left.resulttype.def) then
  689. begin
  690. if left.nodetype=ordconstn then
  691. begin
  692. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  693. resulttypepass(hp);
  694. result:=hp;
  695. exit;
  696. end
  697. else
  698. begin
  699. if IsConvertable(left.resulttype.def,u8bittype.def,convtype,ordconstn,false)=0 then
  700. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  701. end;
  702. end
  703. {Are we typecasting an ordconst to a wchar?}
  704. else
  705. if is_widechar(resulttype.def) and
  706. is_ordinal(left.resulttype.def) then
  707. begin
  708. if left.nodetype=ordconstn then
  709. begin
  710. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  711. resulttypepass(hp);
  712. result:=hp;
  713. exit;
  714. end
  715. else
  716. begin
  717. if IsConvertable(left.resulttype.def,u16bittype.def,convtype,ordconstn,false)=0 then
  718. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  719. end;
  720. end
  721. { char to ordinal }
  722. else
  723. if is_char(left.resulttype.def) and
  724. is_ordinal(resulttype.def) then
  725. begin
  726. if left.nodetype=ordconstn then
  727. begin
  728. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  729. resulttypepass(hp);
  730. result:=hp;
  731. exit;
  732. end
  733. else
  734. begin
  735. if IsConvertable(u8bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  736. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  737. end;
  738. end
  739. { widechar to ordinal }
  740. else
  741. if is_widechar(left.resulttype.def) and
  742. is_ordinal(resulttype.def) then
  743. begin
  744. if left.nodetype=ordconstn then
  745. begin
  746. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  747. resulttypepass(hp);
  748. result:=hp;
  749. exit;
  750. end
  751. else
  752. begin
  753. if IsConvertable(u16bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  754. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  755. end;
  756. end
  757. { only if the same size or formal def }
  758. { why do we allow typecasting of voiddef ?? (PM) }
  759. else
  760. begin
  761. if not(
  762. (left.resulttype.def.deftype=formaldef) or
  763. (left.resulttype.def.size=resulttype.def.size) or
  764. (is_void(left.resulttype.def) and
  765. (left.nodetype=derefn))
  766. ) then
  767. CGMessage(cg_e_illegal_type_conversion);
  768. if ((left.resulttype.def.deftype=orddef) and
  769. (resulttype.def.deftype=pointerdef)) or
  770. ((resulttype.def.deftype=orddef) and
  771. (left.resulttype.def.deftype=pointerdef)) then
  772. CGMessage(cg_d_pointer_to_longint_conv_not_portable);
  773. end;
  774. { the conversion into a strutured type is only }
  775. { possible, if the source is not a register }
  776. if ((resulttype.def.deftype in [recorddef,stringdef,arraydef]) or
  777. ((resulttype.def.deftype=objectdef) and not(is_class(resulttype.def)))
  778. ) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) { and
  779. it also works if the assignment is overloaded
  780. YES but this code is not executed if assignment is overloaded (PM)
  781. not assigned(assignment_overloaded(left.resulttype.def,resulttype.def))} then
  782. CGMessage(cg_e_illegal_type_conversion);
  783. end
  784. else
  785. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  786. end;
  787. { tp7 procvar support, when right is not a procvardef and we got a
  788. loadn of a procvar then convert to a calln, the check for the
  789. result is already done in is_convertible, also no conflict with
  790. @procvar is here because that has an extra addrn }
  791. if (m_tp_procvar in aktmodeswitches) and
  792. (resulttype.def.deftype<>procvardef) and
  793. (left.resulttype.def.deftype=procvardef) and
  794. (left.nodetype=loadn) then
  795. begin
  796. hp:=ccallnode.create(nil,nil,nil,nil);
  797. tcallnode(hp).set_procvar(left);
  798. resulttypepass(hp);
  799. left:=hp;
  800. end;
  801. { ordinal contants can be directly converted }
  802. if (left.nodetype=ordconstn) and is_ordinal(resulttype.def) then
  803. begin
  804. { replace the resulttype and recheck the range }
  805. left.resulttype:=resulttype;
  806. testrange(left.resulttype.def,tordconstnode(left).value,(nf_explizit in flags));
  807. result:=left;
  808. left:=nil;
  809. exit;
  810. end;
  811. { fold nil to any pointer type }
  812. if (left.nodetype=niln) and (resulttype.def.deftype=pointerdef) then
  813. begin
  814. hp:=cnilnode.create;
  815. hp.resulttype:=resulttype;
  816. resulttypepass(hp);
  817. result:=hp;
  818. exit;
  819. end;
  820. { further, pointerconstn to any pointer is folded too }
  821. if (left.nodetype=pointerconstn) and (resulttype.def.deftype=pointerdef) then
  822. begin
  823. left.resulttype:=resulttype;
  824. result:=left;
  825. left:=nil;
  826. exit;
  827. end;
  828. { now call the resulttype helper to do constant folding }
  829. result:=resulttype_call_helper(convtype);
  830. end;
  831. function ttypeconvnode.first_cord_to_pointer : tnode;
  832. begin
  833. result:=nil;
  834. internalerror(200104043);
  835. end;
  836. function ttypeconvnode.first_int_to_int : tnode;
  837. begin
  838. first_int_to_int:=nil;
  839. if (left.location.loc<>LOC_REGISTER) and
  840. (resulttype.def.size>left.resulttype.def.size) then
  841. location.loc:=LOC_REGISTER;
  842. if is_64bitint(resulttype.def) then
  843. registers32:=max(registers32,2)
  844. else
  845. registers32:=max(registers32,1);
  846. end;
  847. function ttypeconvnode.first_cstring_to_pchar : tnode;
  848. begin
  849. first_cstring_to_pchar:=nil;
  850. registers32:=1;
  851. location.loc:=LOC_REGISTER;
  852. end;
  853. function ttypeconvnode.first_string_to_chararray : tnode;
  854. begin
  855. first_string_to_chararray:=nil;
  856. registers32:=1;
  857. location.loc:=LOC_REGISTER;
  858. end;
  859. function ttypeconvnode.first_string_to_string : tnode;
  860. begin
  861. first_string_to_string:=nil;
  862. if tstringdef(resulttype.def).string_typ<>
  863. tstringdef(left.resulttype.def).string_typ then
  864. begin
  865. procinfo^.flags:=procinfo^.flags or pi_do_call;
  866. end;
  867. { for simplicity lets first keep all ansistrings
  868. as LOC_MEM, could also become LOC_REGISTER }
  869. if tstringdef(resulttype.def).string_typ in [st_ansistring,st_widestring] then
  870. { we may use ansistrings so no fast exit here }
  871. procinfo^.no_fast_exit:=true;
  872. location.loc:=LOC_MEM;
  873. end;
  874. function ttypeconvnode.first_char_to_string : tnode;
  875. begin
  876. first_char_to_string:=nil;
  877. location.loc:=LOC_MEM;
  878. end;
  879. function ttypeconvnode.first_nothing : tnode;
  880. begin
  881. first_nothing:=nil;
  882. location.loc:=LOC_MEM;
  883. end;
  884. function ttypeconvnode.first_array_to_pointer : tnode;
  885. begin
  886. first_array_to_pointer:=nil;
  887. if registers32<1 then
  888. registers32:=1;
  889. location.loc:=LOC_REGISTER;
  890. end;
  891. function ttypeconvnode.first_int_to_real : tnode;
  892. begin
  893. first_int_to_real:=nil;
  894. if registersfpu<1 then
  895. registersfpu:=1;
  896. location.loc:=LOC_FPU;
  897. end;
  898. function ttypeconvnode.first_real_to_real : tnode;
  899. begin
  900. first_real_to_real:=nil;
  901. { comp isn't a floating type }
  902. {$ifdef i386}
  903. if (tfloatdef(resulttype.def).typ=s64comp) and
  904. (tfloatdef(left.resulttype.def).typ<>s64comp) and
  905. not (nf_explizit in flags) then
  906. CGMessage(type_w_convert_real_2_comp);
  907. {$endif}
  908. if registersfpu<1 then
  909. registersfpu:=1;
  910. location.loc:=LOC_FPU;
  911. end;
  912. function ttypeconvnode.first_pointer_to_array : tnode;
  913. begin
  914. first_pointer_to_array:=nil;
  915. if registers32<1 then
  916. registers32:=1;
  917. location.loc:=LOC_REFERENCE;
  918. end;
  919. function ttypeconvnode.first_chararray_to_string : tnode;
  920. begin
  921. first_chararray_to_string:=nil;
  922. { the only important information is the location of the }
  923. { result }
  924. { other stuff is done by firsttypeconv }
  925. location.loc:=LOC_MEM;
  926. end;
  927. function ttypeconvnode.first_cchar_to_pchar : tnode;
  928. begin
  929. first_cchar_to_pchar:=nil;
  930. internalerror(200104021);
  931. end;
  932. function ttypeconvnode.first_bool_to_int : tnode;
  933. begin
  934. first_bool_to_int:=nil;
  935. { byte(boolean) or word(wordbool) or longint(longbool) must
  936. be accepted for var parameters }
  937. if (nf_explizit in flags) and
  938. (left.resulttype.def.size=resulttype.def.size) and
  939. (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
  940. exit;
  941. location.loc:=LOC_REGISTER;
  942. if registers32<1 then
  943. registers32:=1;
  944. end;
  945. function ttypeconvnode.first_int_to_bool : tnode;
  946. begin
  947. first_int_to_bool:=nil;
  948. { byte(boolean) or word(wordbool) or longint(longbool) must
  949. be accepted for var parameters }
  950. if (nf_explizit in flags) and
  951. (left.resulttype.def.size=resulttype.def.size) and
  952. (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
  953. exit;
  954. location.loc:=LOC_REGISTER;
  955. { need if bool to bool !!
  956. not very nice !!
  957. insertypeconv(left,s32bittype);
  958. left.explizit:=true;
  959. firstpass(left); }
  960. if registers32<1 then
  961. registers32:=1;
  962. end;
  963. function ttypeconvnode.first_bool_to_bool : tnode;
  964. begin
  965. first_bool_to_bool:=nil;
  966. location.loc:=LOC_REGISTER;
  967. if registers32<1 then
  968. registers32:=1;
  969. end;
  970. function ttypeconvnode.first_char_to_char : tnode;
  971. begin
  972. first_char_to_char:=nil;
  973. location.loc:=LOC_REGISTER;
  974. if registers32<1 then
  975. registers32:=1;
  976. end;
  977. function ttypeconvnode.first_proc_to_procvar : tnode;
  978. begin
  979. first_proc_to_procvar:=nil;
  980. if (left.location.loc<>LOC_REFERENCE) then
  981. CGMessage(cg_e_illegal_expression);
  982. registers32:=left.registers32;
  983. if registers32<1 then
  984. registers32:=1;
  985. location.loc:=LOC_REGISTER;
  986. end;
  987. function ttypeconvnode.first_load_smallset : tnode;
  988. begin
  989. first_load_smallset:=nil;
  990. end;
  991. function ttypeconvnode.first_pchar_to_string : tnode;
  992. begin
  993. first_pchar_to_string:=nil;
  994. location.loc:=LOC_REFERENCE;
  995. end;
  996. function ttypeconvnode.first_ansistring_to_pchar : tnode;
  997. begin
  998. first_ansistring_to_pchar:=nil;
  999. location.loc:=LOC_REGISTER;
  1000. if registers32<1 then
  1001. registers32:=1;
  1002. end;
  1003. function ttypeconvnode.first_arrayconstructor_to_set : tnode;
  1004. begin
  1005. first_arrayconstructor_to_set:=nil;
  1006. internalerror(200104022);
  1007. end;
  1008. function ttypeconvnode.first_class_to_intf : tnode;
  1009. begin
  1010. first_class_to_intf:=nil;
  1011. location.loc:=LOC_REFERENCE;
  1012. if registers32<1 then
  1013. registers32:=1;
  1014. end;
  1015. function ttypeconvnode.first_call_helper(c : tconverttype) : tnode;
  1016. const
  1017. firstconvert : array[tconverttype] of pointer = (
  1018. @ttypeconvnode.first_nothing, {equal}
  1019. @ttypeconvnode.first_nothing, {not_possible}
  1020. @ttypeconvnode.first_string_to_string,
  1021. @ttypeconvnode.first_char_to_string,
  1022. @ttypeconvnode.first_pchar_to_string,
  1023. @ttypeconvnode.first_cchar_to_pchar,
  1024. @ttypeconvnode.first_cstring_to_pchar,
  1025. @ttypeconvnode.first_ansistring_to_pchar,
  1026. @ttypeconvnode.first_string_to_chararray,
  1027. @ttypeconvnode.first_chararray_to_string,
  1028. @ttypeconvnode.first_array_to_pointer,
  1029. @ttypeconvnode.first_pointer_to_array,
  1030. @ttypeconvnode.first_int_to_int,
  1031. @ttypeconvnode.first_int_to_bool,
  1032. @ttypeconvnode.first_bool_to_bool,
  1033. @ttypeconvnode.first_bool_to_int,
  1034. @ttypeconvnode.first_real_to_real,
  1035. @ttypeconvnode.first_int_to_real,
  1036. @ttypeconvnode.first_proc_to_procvar,
  1037. @ttypeconvnode.first_arrayconstructor_to_set,
  1038. @ttypeconvnode.first_load_smallset,
  1039. @ttypeconvnode.first_cord_to_pointer,
  1040. @ttypeconvnode.first_nothing,
  1041. @ttypeconvnode.first_nothing,
  1042. @ttypeconvnode.first_class_to_intf,
  1043. @ttypeconvnode.first_char_to_char
  1044. );
  1045. type
  1046. tprocedureofobject = function : tnode of object;
  1047. var
  1048. r : packed record
  1049. proc : pointer;
  1050. obj : pointer;
  1051. end;
  1052. begin
  1053. { this is a little bit dirty but it works }
  1054. { and should be quite portable too }
  1055. r.proc:=firstconvert[c];
  1056. r.obj:=self;
  1057. first_call_helper:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  1058. end;
  1059. function ttypeconvnode.pass_1 : tnode;
  1060. begin
  1061. result:=nil;
  1062. firstpass(left);
  1063. if codegenerror then
  1064. exit;
  1065. { load the value_str from the left part }
  1066. registers32:=left.registers32;
  1067. registersfpu:=left.registersfpu;
  1068. {$ifdef SUPPORT_MMX}
  1069. registersmmx:=left.registersmmx;
  1070. {$endif}
  1071. set_location(location,left.location);
  1072. if nf_explizit in flags then
  1073. begin
  1074. { check if the result could be in a register }
  1075. if not(tstoreddef(resulttype.def).is_intregable) and
  1076. not(tstoreddef(resulttype.def).is_fpuregable) then
  1077. make_not_regable(left);
  1078. end;
  1079. if convtype=tc_equal then
  1080. begin
  1081. { remove typeconv node if left is a const. For other nodes we can't
  1082. remove it because the secondpass can still depend on the old type (PFV) }
  1083. if is_constnode(left) then
  1084. begin
  1085. left.resulttype:=resulttype;
  1086. result:=left;
  1087. left:=nil;
  1088. end;
  1089. end
  1090. else
  1091. begin
  1092. result:=first_call_helper(convtype);
  1093. end;
  1094. end;
  1095. {*****************************************************************************
  1096. TISNODE
  1097. *****************************************************************************}
  1098. constructor tisnode.create(l,r : tnode);
  1099. begin
  1100. inherited create(isn,l,r);
  1101. end;
  1102. function tisnode.det_resulttype:tnode;
  1103. begin
  1104. result:=nil;
  1105. resulttypepass(left);
  1106. resulttypepass(right);
  1107. set_varstate(left,true);
  1108. set_varstate(right,true);
  1109. if codegenerror then
  1110. exit;
  1111. if (right.resulttype.def.deftype=classrefdef) then
  1112. begin
  1113. { left must be a class }
  1114. if is_class(left.resulttype.def) then
  1115. begin
  1116. { the operands must be related }
  1117. if (not(tobjectdef(left.resulttype.def).is_related(
  1118. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1119. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1120. tobjectdef(left.resulttype.def)))) then
  1121. CGMessage(type_e_mismatch);
  1122. end
  1123. else
  1124. CGMessage(type_e_mismatch);
  1125. end
  1126. else
  1127. CGMessage(type_e_mismatch);
  1128. resulttype:=booltype;
  1129. end;
  1130. function tisnode.pass_1 : tnode;
  1131. begin
  1132. result:=nil;
  1133. firstpass(left);
  1134. firstpass(right);
  1135. if codegenerror then
  1136. exit;
  1137. left_right_max;
  1138. location.loc:=LOC_FLAGS;
  1139. end;
  1140. {*****************************************************************************
  1141. TASNODE
  1142. *****************************************************************************}
  1143. constructor tasnode.create(l,r : tnode);
  1144. begin
  1145. inherited create(asn,l,r);
  1146. end;
  1147. function tasnode.det_resulttype:tnode;
  1148. begin
  1149. result:=nil;
  1150. resulttypepass(right);
  1151. resulttypepass(left);
  1152. set_varstate(right,true);
  1153. set_varstate(left,true);
  1154. if codegenerror then
  1155. exit;
  1156. if (right.resulttype.def.deftype=classrefdef) then
  1157. begin
  1158. { left must be a class }
  1159. if is_class(left.resulttype.def) then
  1160. begin
  1161. { the operands must be related }
  1162. if (not(tobjectdef(left.resulttype.def).is_related(
  1163. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1164. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1165. tobjectdef(left.resulttype.def)))) then
  1166. CGMessage(type_e_mismatch);
  1167. end
  1168. else
  1169. CGMessage(type_e_mismatch);
  1170. resulttype:=tclassrefdef(right.resulttype.def).pointertype;
  1171. end
  1172. else
  1173. CGMessage(type_e_mismatch);
  1174. end;
  1175. function tasnode.pass_1 : tnode;
  1176. begin
  1177. result:=nil;
  1178. firstpass(right);
  1179. firstpass(left);
  1180. if codegenerror then
  1181. exit;
  1182. left_right_max;
  1183. set_location(location,left.location);
  1184. end;
  1185. function ttypeconvnode.docompare(p: tnode) : boolean;
  1186. begin
  1187. docompare :=
  1188. inherited docompare(p) and
  1189. (convtype = ttypeconvnode(p).convtype);
  1190. end;
  1191. begin
  1192. ctypeconvnode:=ttypeconvnode;
  1193. casnode:=tasnode;
  1194. cisnode:=tisnode;
  1195. end.
  1196. {
  1197. $Log$
  1198. Revision 1.27 2001-05-08 21:06:30 florian
  1199. * some more support for widechars commited especially
  1200. regarding type casting and constants
  1201. Revision 1.26 2001/05/04 15:52:03 florian
  1202. * some Delphi incompatibilities fixed:
  1203. - out, dispose and new can be used as idenfiers now
  1204. - const p = apointerype(nil); is supported now
  1205. + support for const p = apointertype(pointer(1234)); added
  1206. Revision 1.25 2001/04/13 22:20:58 peter
  1207. * remove wrongly placed first_call_helper
  1208. Revision 1.24 2001/04/13 01:22:08 peter
  1209. * symtable change to classes
  1210. * range check generation and errors fixed, make cycle DEBUG=1 works
  1211. * memory leaks fixed
  1212. Revision 1.23 2001/04/04 22:42:39 peter
  1213. * move constant folding into det_resulttype
  1214. Revision 1.22 2001/04/02 21:20:30 peter
  1215. * resulttype rewrite
  1216. Revision 1.21 2001/03/08 17:44:47 jonas
  1217. * fixed web bug 1430
  1218. Revision 1.20 2001/02/21 11:49:50 jonas
  1219. * evaluate typecasts of const pointers to ordinals inline ('merged')
  1220. Revision 1.19 2001/02/20 18:37:10 peter
  1221. * removed unused code
  1222. Revision 1.18 2001/02/20 13:14:18 marco
  1223. * Fix from Peter for passing a procedure of method to a other method in a method
  1224. Revision 1.17 2001/02/08 13:09:03 jonas
  1225. * fixed web bug 1396: tpointerord is now a cardinal instead of a longint,
  1226. but added a hack in ncnv so that pointer(-1) still works
  1227. Revision 1.16 2000/12/31 11:14:10 jonas
  1228. + implemented/fixed docompare() mathods for all nodes (not tested)
  1229. + nopt.pas, nadd.pas, i386/n386opt.pas: optimized nodes for adding strings
  1230. and constant strings/chars together
  1231. * n386add.pas: don't copy temp strings (of size 256) to another temp string
  1232. when adding
  1233. Revision 1.15 2000/12/08 12:41:01 jonas
  1234. * fixed bug in sign extension patch
  1235. Revision 1.14 2000/12/07 17:19:42 jonas
  1236. * new constant handling: from now on, hex constants >$7fffffff are
  1237. parsed as unsigned constants (otherwise, $80000000 got sign extended
  1238. and became $ffffffff80000000), all constants in the longint range
  1239. become longints, all constants >$7fffffff and <=cardinal($ffffffff)
  1240. are cardinals and the rest are int64's.
  1241. * added lots of longint typecast to prevent range check errors in the
  1242. compiler and rtl
  1243. * type casts of symbolic ordinal constants are now preserved
  1244. * fixed bug where the original resulttype.def wasn't restored correctly
  1245. after doing a 64bit rangecheck
  1246. Revision 1.13 2000/11/29 00:30:32 florian
  1247. * unused units removed from uses clause
  1248. * some changes for widestrings
  1249. Revision 1.12 2000/11/20 16:06:04 jonas
  1250. + allow evaluation of 64bit constant expressions at compile time
  1251. * disable range checking for explicit typecasts of constant expressions
  1252. Revision 1.11 2000/11/12 23:24:11 florian
  1253. * interfaces are basically running
  1254. Revision 1.10 2000/11/04 14:25:20 florian
  1255. + merged Attila's changes for interfaces, not tested yet
  1256. Revision 1.9 2000/10/31 22:02:48 peter
  1257. * symtable splitted, no real code changes
  1258. Revision 1.8 2000/10/14 21:52:55 peter
  1259. * fixed memory leaks
  1260. Revision 1.7 2000/10/14 10:14:50 peter
  1261. * moehrendorf oct 2000 rewrite
  1262. Revision 1.6 2000/10/01 19:48:24 peter
  1263. * lot of compile updates for cg11
  1264. Revision 1.5 2000/09/28 19:49:52 florian
  1265. *** empty log message ***
  1266. Revision 1.4 2000/09/27 18:14:31 florian
  1267. * fixed a lot of syntax errors in the n*.pas stuff
  1268. Revision 1.3 2000/09/26 20:06:13 florian
  1269. * hmm, still a lot of work to get things compilable
  1270. Revision 1.2 2000/09/26 14:59:34 florian
  1271. * more conversion work done
  1272. Revision 1.1 2000/09/25 15:37:14 florian
  1273. * more fixes
  1274. }