ncnv.pas 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  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) and
  409. (torddef(left.resulttype.def).typ=uwidechar) then
  410. begin
  411. hp:=cordconstnode.create(
  412. ord(unicode2asciichar(tcompilerwidechar(tordconstnode(left).value))),cchartype);
  413. resulttypepass(hp);
  414. result:=hp;
  415. end
  416. else if (torddef(resulttype.def).typ=uwidechar) and
  417. (torddef(left.resulttype.def).typ=uchar) then
  418. begin
  419. hp:=cordconstnode.create(
  420. asciichar2unicode(chr(tordconstnode(left).value)),cwidechartype);
  421. resulttypepass(hp);
  422. result:=hp;
  423. end
  424. else
  425. internalerror(200105131);
  426. end;
  427. function ttypeconvnode.resulttype_int_to_real : tnode;
  428. var
  429. t : trealconstnode;
  430. begin
  431. result:=nil;
  432. if left.nodetype=ordconstn then
  433. begin
  434. t:=crealconstnode.create(tordconstnode(left).value,resulttype);
  435. resulttypepass(t);
  436. result:=t;
  437. exit;
  438. end;
  439. end;
  440. function ttypeconvnode.resulttype_real_to_real : tnode;
  441. var
  442. t : tnode;
  443. begin
  444. result:=nil;
  445. if left.nodetype=realconstn then
  446. begin
  447. t:=crealconstnode.create(trealconstnode(left).value_real,resulttype);
  448. resulttypepass(t);
  449. result:=t;
  450. end;
  451. end;
  452. function ttypeconvnode.resulttype_cchar_to_pchar : tnode;
  453. begin
  454. result:=nil;
  455. inserttypeconv(left,cshortstringtype);
  456. { evaluate again, reset resulttype so the convert_typ
  457. will be calculated again }
  458. result:=det_resulttype;
  459. end;
  460. function ttypeconvnode.resulttype_arrayconstructor_to_set : tnode;
  461. var
  462. hp : tnode;
  463. begin
  464. result:=nil;
  465. if left.nodetype<>arrayconstructorn then
  466. internalerror(5546);
  467. { remove typeconv node }
  468. hp:=left;
  469. left:=nil;
  470. { create a set constructor tree }
  471. arrayconstructor_to_set(tarrayconstructornode(hp));
  472. { now resulttypepass the set }
  473. resulttypepass(hp);
  474. result:=hp;
  475. end;
  476. function ttypeconvnode.resulttype_call_helper(c : tconverttype) : tnode;
  477. const
  478. resulttypeconvert : array[tconverttype] of pointer = (
  479. {equal} nil,
  480. {not_possible} nil,
  481. { string_2_string } @ttypeconvnode.resulttype_string_to_string,
  482. { char_2_string } @ttypeconvnode.resulttype_char_to_string,
  483. { pchar_2_string } nil,
  484. { cchar_2_pchar } @ttypeconvnode.resulttype_cchar_to_pchar,
  485. { cstring_2_pchar } nil,
  486. { ansistring_2_pchar } nil,
  487. { string_2_chararray } nil,
  488. { chararray_2_string } nil,
  489. { array_2_pointer } nil,
  490. { pointer_2_array } nil,
  491. { int_2_int } nil,
  492. { int_2_bool } nil,
  493. { bool_2_bool } nil,
  494. { bool_2_int } nil,
  495. { real_2_real } @ttypeconvnode.resulttype_real_to_real,
  496. { int_2_real } @ttypeconvnode.resulttype_int_to_real,
  497. { proc_2_procvar } nil,
  498. { arrayconstructor_2_set } @ttypeconvnode.resulttype_arrayconstructor_to_set,
  499. { load_smallset } nil,
  500. { cord_2_pointer } @ttypeconvnode.resulttype_cord_to_pointer,
  501. { intf_2_string } nil,
  502. { intf_2_guid } nil,
  503. { class_2_intf } nil,
  504. { char_2_char } @ttypeconvnode.resulttype_char_to_char
  505. );
  506. type
  507. tprocedureofobject = function : tnode of object;
  508. var
  509. r : packed record
  510. proc : pointer;
  511. obj : pointer;
  512. end;
  513. begin
  514. result:=nil;
  515. { this is a little bit dirty but it works }
  516. { and should be quite portable too }
  517. r.proc:=resulttypeconvert[c];
  518. r.obj:=self;
  519. if assigned(r.proc) then
  520. result:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  521. end;
  522. function ttypeconvnode.det_resulttype:tnode;
  523. var
  524. hp : tnode;
  525. aprocdef : tprocdef;
  526. begin
  527. result:=nil;
  528. resulttype:=totype;
  529. resulttypepass(left);
  530. if codegenerror then
  531. exit;
  532. { remove obsolete type conversions }
  533. if is_equal(left.resulttype.def,resulttype.def) then
  534. begin
  535. { becuase is_equal only checks the basetype for sets we need to
  536. check here if we are loading a smallset into a normalset }
  537. if (resulttype.def.deftype=setdef) and
  538. (left.resulttype.def.deftype=setdef) and
  539. (tsetdef(resulttype.def).settype<>smallset) and
  540. (tsetdef(left.resulttype.def).settype=smallset) then
  541. begin
  542. { try to define the set as a normalset if it's a constant set }
  543. if left.nodetype=setconstn then
  544. begin
  545. resulttype:=left.resulttype;
  546. tsetdef(resulttype.def).settype:=normset
  547. end
  548. else
  549. convtype:=tc_load_smallset;
  550. exit;
  551. end
  552. else
  553. begin
  554. left.resulttype:=resulttype;
  555. result:=left;
  556. left:=nil;
  557. exit;
  558. end;
  559. end;
  560. aprocdef:=assignment_overloaded(left.resulttype.def,resulttype.def);
  561. if assigned(aprocdef) then
  562. begin
  563. procinfo^.flags:=procinfo^.flags or pi_do_call;
  564. hp:=ccallnode.create(ccallparanode.create(left,nil),
  565. overloaded_operators[_assignment],nil,nil);
  566. { tell explicitly which def we must use !! (PM) }
  567. tcallnode(hp).procdefinition:=aprocdef;
  568. left:=nil;
  569. resulttypepass(hp);
  570. result:=hp;
  571. exit;
  572. end;
  573. if isconvertable(left.resulttype.def,resulttype.def,convtype,left.nodetype,nf_explizit in flags)=0 then
  574. begin
  575. {Procedures have a resulttype.def of voiddef and functions of their
  576. own resulttype.def. They will therefore always be incompatible with
  577. a procvar. Because isconvertable cannot check for procedures we
  578. use an extra check for them.}
  579. if (m_tp_procvar in aktmodeswitches) then
  580. begin
  581. if (resulttype.def.deftype=procvardef) and
  582. (is_procsym_load(left) or is_procsym_call(left)) then
  583. begin
  584. if is_procsym_call(left) then
  585. begin
  586. hp:=cloadnode.create(tprocsym(tcallnode(left).symtableprocentry),
  587. tcallnode(left).symtableproc);
  588. if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
  589. assigned(tcallnode(left).methodpointer) then
  590. tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
  591. resulttypepass(hp);
  592. left.free;
  593. left:=hp;
  594. aprocdef:=tprocdef(left.resulttype.def);
  595. end
  596. else
  597. begin
  598. if (left.nodetype<>addrn) then
  599. aprocdef:=tprocsym(tloadnode(left).symtableentry).definition;
  600. end;
  601. convtype:=tc_proc_2_procvar;
  602. { Now check if the procedure we are going to assign to
  603. the procvar, is compatible with the procvar's type }
  604. if assigned(aprocdef) then
  605. begin
  606. if not proc_to_procvar_equal(aprocdef,tprocvardef(resulttype.def)) then
  607. CGMessage2(type_e_incompatible_types,aprocdef.typename,resulttype.def.typename);
  608. end
  609. else
  610. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  611. exit;
  612. end;
  613. end;
  614. if nf_explizit in flags then
  615. begin
  616. { check if the result could be in a register }
  617. if not(tstoreddef(resulttype.def).is_intregable) and
  618. not(tstoreddef(resulttype.def).is_fpuregable) then
  619. make_not_regable(left);
  620. { boolean to byte are special because the
  621. location can be different }
  622. if is_integer(resulttype.def) and
  623. is_boolean(left.resulttype.def) then
  624. begin
  625. convtype:=tc_bool_2_int;
  626. exit;
  627. end;
  628. { ansistring to pchar }
  629. if is_pchar(resulttype.def) and
  630. is_ansistring(left.resulttype.def) then
  631. begin
  632. convtype:=tc_ansistring_2_pchar;
  633. exit;
  634. end;
  635. { do common tc_equal cast }
  636. convtype:=tc_equal;
  637. { enum to ordinal will always be s32bit }
  638. if (left.resulttype.def.deftype=enumdef) and
  639. is_ordinal(resulttype.def) then
  640. begin
  641. if left.nodetype=ordconstn then
  642. begin
  643. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  644. resulttypepass(hp);
  645. result:=hp;
  646. exit;
  647. end
  648. else
  649. begin
  650. if isconvertable(s32bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  651. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  652. end;
  653. end
  654. { ordinal to enumeration }
  655. else
  656. if (resulttype.def.deftype=enumdef) and
  657. is_ordinal(left.resulttype.def) then
  658. begin
  659. if left.nodetype=ordconstn then
  660. begin
  661. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  662. resulttypepass(hp);
  663. result:=hp;
  664. exit;
  665. end
  666. else
  667. begin
  668. if IsConvertable(left.resulttype.def,s32bittype.def,convtype,ordconstn,false)=0 then
  669. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  670. end;
  671. end
  672. { nil to ordinal node }
  673. else if (left.nodetype=niln) and is_ordinal(resulttype.def) then
  674. begin
  675. hp:=cordconstnode.create(0,resulttype);
  676. resulttypepass(hp);
  677. result:=hp;
  678. exit;
  679. end
  680. { constant pointer to ordinal }
  681. else if is_ordinal(resulttype.def) and
  682. (left.nodetype=pointerconstn) then
  683. begin
  684. hp:=cordconstnode.create(tpointerconstnode(left).value,resulttype);
  685. resulttypepass(hp);
  686. result:=hp;
  687. exit;
  688. end
  689. {Are we typecasting an ordconst to a char?}
  690. else
  691. if is_char(resulttype.def) and
  692. is_ordinal(left.resulttype.def) then
  693. begin
  694. if left.nodetype=ordconstn then
  695. begin
  696. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  697. resulttypepass(hp);
  698. result:=hp;
  699. exit;
  700. end
  701. else
  702. begin
  703. if IsConvertable(left.resulttype.def,u8bittype.def,convtype,ordconstn,false)=0 then
  704. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  705. end;
  706. end
  707. {Are we typecasting an ordconst to a wchar?}
  708. else
  709. if is_widechar(resulttype.def) and
  710. is_ordinal(left.resulttype.def) then
  711. begin
  712. if left.nodetype=ordconstn then
  713. begin
  714. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  715. resulttypepass(hp);
  716. result:=hp;
  717. exit;
  718. end
  719. else
  720. begin
  721. if IsConvertable(left.resulttype.def,u16bittype.def,convtype,ordconstn,false)=0 then
  722. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  723. end;
  724. end
  725. { char to ordinal }
  726. else
  727. if is_char(left.resulttype.def) and
  728. is_ordinal(resulttype.def) then
  729. begin
  730. if left.nodetype=ordconstn then
  731. begin
  732. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  733. resulttypepass(hp);
  734. result:=hp;
  735. exit;
  736. end
  737. else
  738. begin
  739. if IsConvertable(u8bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  740. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  741. end;
  742. end
  743. { widechar to ordinal }
  744. else
  745. if is_widechar(left.resulttype.def) and
  746. is_ordinal(resulttype.def) then
  747. begin
  748. if left.nodetype=ordconstn then
  749. begin
  750. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  751. resulttypepass(hp);
  752. result:=hp;
  753. exit;
  754. end
  755. else
  756. begin
  757. if IsConvertable(u16bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  758. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  759. end;
  760. end
  761. { only if the same size or formal def }
  762. { why do we allow typecasting of voiddef ?? (PM) }
  763. else
  764. begin
  765. if not(
  766. (left.resulttype.def.deftype=formaldef) or
  767. (left.resulttype.def.size=resulttype.def.size) or
  768. (is_void(left.resulttype.def) and
  769. (left.nodetype=derefn))
  770. ) then
  771. CGMessage(cg_e_illegal_type_conversion);
  772. if ((left.resulttype.def.deftype=orddef) and
  773. (resulttype.def.deftype=pointerdef)) or
  774. ((resulttype.def.deftype=orddef) and
  775. (left.resulttype.def.deftype=pointerdef)) then
  776. CGMessage(cg_d_pointer_to_longint_conv_not_portable);
  777. end;
  778. { the conversion into a strutured type is only }
  779. { possible, if the source is not a register }
  780. if ((resulttype.def.deftype in [recorddef,stringdef,arraydef]) or
  781. ((resulttype.def.deftype=objectdef) and not(is_class(resulttype.def)))
  782. ) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) { and
  783. it also works if the assignment is overloaded
  784. YES but this code is not executed if assignment is overloaded (PM)
  785. not assigned(assignment_overloaded(left.resulttype.def,resulttype.def))} then
  786. CGMessage(cg_e_illegal_type_conversion);
  787. end
  788. else
  789. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  790. end;
  791. { tp7 procvar support, when right is not a procvardef and we got a
  792. loadn of a procvar then convert to a calln, the check for the
  793. result is already done in is_convertible, also no conflict with
  794. @procvar is here because that has an extra addrn }
  795. if (m_tp_procvar in aktmodeswitches) and
  796. (resulttype.def.deftype<>procvardef) and
  797. (left.resulttype.def.deftype=procvardef) and
  798. (left.nodetype=loadn) then
  799. begin
  800. hp:=ccallnode.create(nil,nil,nil,nil);
  801. tcallnode(hp).set_procvar(left);
  802. resulttypepass(hp);
  803. left:=hp;
  804. end;
  805. { ordinal contants can be directly converted }
  806. if (left.nodetype=ordconstn) and is_ordinal(resulttype.def) then
  807. begin
  808. { replace the resulttype and recheck the range }
  809. left.resulttype:=resulttype;
  810. testrange(left.resulttype.def,tordconstnode(left).value,(nf_explizit in flags));
  811. result:=left;
  812. left:=nil;
  813. exit;
  814. end;
  815. { fold nil to any pointer type }
  816. if (left.nodetype=niln) and (resulttype.def.deftype=pointerdef) then
  817. begin
  818. hp:=cnilnode.create;
  819. hp.resulttype:=resulttype;
  820. resulttypepass(hp);
  821. result:=hp;
  822. exit;
  823. end;
  824. { further, pointerconstn to any pointer is folded too }
  825. if (left.nodetype=pointerconstn) and (resulttype.def.deftype=pointerdef) then
  826. begin
  827. left.resulttype:=resulttype;
  828. result:=left;
  829. left:=nil;
  830. exit;
  831. end;
  832. { now call the resulttype helper to do constant folding }
  833. result:=resulttype_call_helper(convtype);
  834. end;
  835. function ttypeconvnode.first_cord_to_pointer : tnode;
  836. begin
  837. result:=nil;
  838. internalerror(200104043);
  839. end;
  840. function ttypeconvnode.first_int_to_int : tnode;
  841. begin
  842. first_int_to_int:=nil;
  843. if (left.location.loc<>LOC_REGISTER) and
  844. (resulttype.def.size>left.resulttype.def.size) then
  845. location.loc:=LOC_REGISTER;
  846. if is_64bitint(resulttype.def) then
  847. registers32:=max(registers32,2)
  848. else
  849. registers32:=max(registers32,1);
  850. end;
  851. function ttypeconvnode.first_cstring_to_pchar : tnode;
  852. begin
  853. first_cstring_to_pchar:=nil;
  854. registers32:=1;
  855. location.loc:=LOC_REGISTER;
  856. end;
  857. function ttypeconvnode.first_string_to_chararray : tnode;
  858. begin
  859. first_string_to_chararray:=nil;
  860. registers32:=1;
  861. location.loc:=LOC_REGISTER;
  862. end;
  863. function ttypeconvnode.first_string_to_string : tnode;
  864. begin
  865. first_string_to_string:=nil;
  866. if tstringdef(resulttype.def).string_typ<>
  867. tstringdef(left.resulttype.def).string_typ then
  868. begin
  869. procinfo^.flags:=procinfo^.flags or pi_do_call;
  870. end;
  871. { for simplicity lets first keep all ansistrings
  872. as LOC_MEM, could also become LOC_REGISTER }
  873. if tstringdef(resulttype.def).string_typ in [st_ansistring,st_widestring] then
  874. { we may use ansistrings so no fast exit here }
  875. procinfo^.no_fast_exit:=true;
  876. location.loc:=LOC_MEM;
  877. end;
  878. function ttypeconvnode.first_char_to_string : tnode;
  879. begin
  880. first_char_to_string:=nil;
  881. location.loc:=LOC_MEM;
  882. end;
  883. function ttypeconvnode.first_nothing : tnode;
  884. begin
  885. first_nothing:=nil;
  886. location.loc:=LOC_MEM;
  887. end;
  888. function ttypeconvnode.first_array_to_pointer : tnode;
  889. begin
  890. first_array_to_pointer:=nil;
  891. if registers32<1 then
  892. registers32:=1;
  893. location.loc:=LOC_REGISTER;
  894. end;
  895. function ttypeconvnode.first_int_to_real : tnode;
  896. begin
  897. first_int_to_real:=nil;
  898. if registersfpu<1 then
  899. registersfpu:=1;
  900. location.loc:=LOC_FPU;
  901. end;
  902. function ttypeconvnode.first_real_to_real : tnode;
  903. begin
  904. first_real_to_real:=nil;
  905. { comp isn't a floating type }
  906. {$ifdef i386}
  907. if (tfloatdef(resulttype.def).typ=s64comp) and
  908. (tfloatdef(left.resulttype.def).typ<>s64comp) and
  909. not (nf_explizit in flags) then
  910. CGMessage(type_w_convert_real_2_comp);
  911. {$endif}
  912. if registersfpu<1 then
  913. registersfpu:=1;
  914. location.loc:=LOC_FPU;
  915. end;
  916. function ttypeconvnode.first_pointer_to_array : tnode;
  917. begin
  918. first_pointer_to_array:=nil;
  919. if registers32<1 then
  920. registers32:=1;
  921. location.loc:=LOC_REFERENCE;
  922. end;
  923. function ttypeconvnode.first_chararray_to_string : tnode;
  924. begin
  925. first_chararray_to_string:=nil;
  926. { the only important information is the location of the }
  927. { result }
  928. { other stuff is done by firsttypeconv }
  929. location.loc:=LOC_MEM;
  930. end;
  931. function ttypeconvnode.first_cchar_to_pchar : tnode;
  932. begin
  933. first_cchar_to_pchar:=nil;
  934. internalerror(200104021);
  935. end;
  936. function ttypeconvnode.first_bool_to_int : tnode;
  937. begin
  938. first_bool_to_int:=nil;
  939. { byte(boolean) or word(wordbool) or longint(longbool) must
  940. be accepted for var parameters }
  941. if (nf_explizit in flags) and
  942. (left.resulttype.def.size=resulttype.def.size) and
  943. (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
  944. exit;
  945. location.loc:=LOC_REGISTER;
  946. if registers32<1 then
  947. registers32:=1;
  948. end;
  949. function ttypeconvnode.first_int_to_bool : tnode;
  950. begin
  951. first_int_to_bool:=nil;
  952. { byte(boolean) or word(wordbool) or longint(longbool) must
  953. be accepted for var parameters }
  954. if (nf_explizit in flags) and
  955. (left.resulttype.def.size=resulttype.def.size) and
  956. (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
  957. exit;
  958. location.loc:=LOC_REGISTER;
  959. { need if bool to bool !!
  960. not very nice !!
  961. insertypeconv(left,s32bittype);
  962. left.explizit:=true;
  963. firstpass(left); }
  964. if registers32<1 then
  965. registers32:=1;
  966. end;
  967. function ttypeconvnode.first_bool_to_bool : tnode;
  968. begin
  969. first_bool_to_bool:=nil;
  970. location.loc:=LOC_REGISTER;
  971. if registers32<1 then
  972. registers32:=1;
  973. end;
  974. function ttypeconvnode.first_char_to_char : tnode;
  975. begin
  976. first_char_to_char:=nil;
  977. location.loc:=LOC_REGISTER;
  978. if registers32<1 then
  979. registers32:=1;
  980. end;
  981. function ttypeconvnode.first_proc_to_procvar : tnode;
  982. begin
  983. first_proc_to_procvar:=nil;
  984. if (left.location.loc<>LOC_REFERENCE) then
  985. CGMessage(cg_e_illegal_expression);
  986. registers32:=left.registers32;
  987. if registers32<1 then
  988. registers32:=1;
  989. location.loc:=LOC_REGISTER;
  990. end;
  991. function ttypeconvnode.first_load_smallset : tnode;
  992. begin
  993. first_load_smallset:=nil;
  994. end;
  995. function ttypeconvnode.first_pchar_to_string : tnode;
  996. begin
  997. first_pchar_to_string:=nil;
  998. location.loc:=LOC_REFERENCE;
  999. end;
  1000. function ttypeconvnode.first_ansistring_to_pchar : tnode;
  1001. begin
  1002. first_ansistring_to_pchar:=nil;
  1003. location.loc:=LOC_REGISTER;
  1004. if registers32<1 then
  1005. registers32:=1;
  1006. end;
  1007. function ttypeconvnode.first_arrayconstructor_to_set : tnode;
  1008. begin
  1009. first_arrayconstructor_to_set:=nil;
  1010. internalerror(200104022);
  1011. end;
  1012. function ttypeconvnode.first_class_to_intf : tnode;
  1013. begin
  1014. first_class_to_intf:=nil;
  1015. location.loc:=LOC_REFERENCE;
  1016. if registers32<1 then
  1017. registers32:=1;
  1018. end;
  1019. function ttypeconvnode.first_call_helper(c : tconverttype) : tnode;
  1020. const
  1021. firstconvert : array[tconverttype] of pointer = (
  1022. @ttypeconvnode.first_nothing, {equal}
  1023. @ttypeconvnode.first_nothing, {not_possible}
  1024. @ttypeconvnode.first_string_to_string,
  1025. @ttypeconvnode.first_char_to_string,
  1026. @ttypeconvnode.first_pchar_to_string,
  1027. @ttypeconvnode.first_cchar_to_pchar,
  1028. @ttypeconvnode.first_cstring_to_pchar,
  1029. @ttypeconvnode.first_ansistring_to_pchar,
  1030. @ttypeconvnode.first_string_to_chararray,
  1031. @ttypeconvnode.first_chararray_to_string,
  1032. @ttypeconvnode.first_array_to_pointer,
  1033. @ttypeconvnode.first_pointer_to_array,
  1034. @ttypeconvnode.first_int_to_int,
  1035. @ttypeconvnode.first_int_to_bool,
  1036. @ttypeconvnode.first_bool_to_bool,
  1037. @ttypeconvnode.first_bool_to_int,
  1038. @ttypeconvnode.first_real_to_real,
  1039. @ttypeconvnode.first_int_to_real,
  1040. @ttypeconvnode.first_proc_to_procvar,
  1041. @ttypeconvnode.first_arrayconstructor_to_set,
  1042. @ttypeconvnode.first_load_smallset,
  1043. @ttypeconvnode.first_cord_to_pointer,
  1044. @ttypeconvnode.first_nothing,
  1045. @ttypeconvnode.first_nothing,
  1046. @ttypeconvnode.first_class_to_intf,
  1047. @ttypeconvnode.first_char_to_char
  1048. );
  1049. type
  1050. tprocedureofobject = function : tnode of object;
  1051. var
  1052. r : packed record
  1053. proc : pointer;
  1054. obj : pointer;
  1055. end;
  1056. begin
  1057. { this is a little bit dirty but it works }
  1058. { and should be quite portable too }
  1059. r.proc:=firstconvert[c];
  1060. r.obj:=self;
  1061. first_call_helper:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  1062. end;
  1063. function ttypeconvnode.pass_1 : tnode;
  1064. begin
  1065. result:=nil;
  1066. firstpass(left);
  1067. if codegenerror then
  1068. exit;
  1069. { load the value_str from the left part }
  1070. registers32:=left.registers32;
  1071. registersfpu:=left.registersfpu;
  1072. {$ifdef SUPPORT_MMX}
  1073. registersmmx:=left.registersmmx;
  1074. {$endif}
  1075. set_location(location,left.location);
  1076. if nf_explizit in flags then
  1077. begin
  1078. { check if the result could be in a register }
  1079. if not(tstoreddef(resulttype.def).is_intregable) and
  1080. not(tstoreddef(resulttype.def).is_fpuregable) then
  1081. make_not_regable(left);
  1082. end;
  1083. if convtype=tc_equal then
  1084. begin
  1085. { remove typeconv node if left is a const. For other nodes we can't
  1086. remove it because the secondpass can still depend on the old type (PFV) }
  1087. if is_constnode(left) then
  1088. begin
  1089. left.resulttype:=resulttype;
  1090. result:=left;
  1091. left:=nil;
  1092. end;
  1093. end
  1094. else
  1095. begin
  1096. result:=first_call_helper(convtype);
  1097. end;
  1098. end;
  1099. {*****************************************************************************
  1100. TISNODE
  1101. *****************************************************************************}
  1102. constructor tisnode.create(l,r : tnode);
  1103. begin
  1104. inherited create(isn,l,r);
  1105. end;
  1106. function tisnode.det_resulttype:tnode;
  1107. begin
  1108. result:=nil;
  1109. resulttypepass(left);
  1110. resulttypepass(right);
  1111. set_varstate(left,true);
  1112. set_varstate(right,true);
  1113. if codegenerror then
  1114. exit;
  1115. if (right.resulttype.def.deftype=classrefdef) then
  1116. begin
  1117. { left must be a class }
  1118. if is_class(left.resulttype.def) then
  1119. begin
  1120. { the operands must be related }
  1121. if (not(tobjectdef(left.resulttype.def).is_related(
  1122. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1123. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1124. tobjectdef(left.resulttype.def)))) then
  1125. CGMessage(type_e_mismatch);
  1126. end
  1127. else
  1128. CGMessage(type_e_mismatch);
  1129. end
  1130. else
  1131. CGMessage(type_e_mismatch);
  1132. resulttype:=booltype;
  1133. end;
  1134. function tisnode.pass_1 : tnode;
  1135. begin
  1136. result:=nil;
  1137. firstpass(left);
  1138. firstpass(right);
  1139. if codegenerror then
  1140. exit;
  1141. left_right_max;
  1142. location.loc:=LOC_FLAGS;
  1143. end;
  1144. {*****************************************************************************
  1145. TASNODE
  1146. *****************************************************************************}
  1147. constructor tasnode.create(l,r : tnode);
  1148. begin
  1149. inherited create(asn,l,r);
  1150. end;
  1151. function tasnode.det_resulttype:tnode;
  1152. begin
  1153. result:=nil;
  1154. resulttypepass(right);
  1155. resulttypepass(left);
  1156. set_varstate(right,true);
  1157. set_varstate(left,true);
  1158. if codegenerror then
  1159. exit;
  1160. if (right.resulttype.def.deftype=classrefdef) then
  1161. begin
  1162. { left must be a class }
  1163. if is_class(left.resulttype.def) then
  1164. begin
  1165. { the operands must be related }
  1166. if (not(tobjectdef(left.resulttype.def).is_related(
  1167. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1168. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1169. tobjectdef(left.resulttype.def)))) then
  1170. CGMessage(type_e_mismatch);
  1171. end
  1172. else
  1173. CGMessage(type_e_mismatch);
  1174. resulttype:=tclassrefdef(right.resulttype.def).pointertype;
  1175. end
  1176. else
  1177. CGMessage(type_e_mismatch);
  1178. end;
  1179. function tasnode.pass_1 : tnode;
  1180. begin
  1181. result:=nil;
  1182. firstpass(right);
  1183. firstpass(left);
  1184. if codegenerror then
  1185. exit;
  1186. left_right_max;
  1187. set_location(location,left.location);
  1188. end;
  1189. function ttypeconvnode.docompare(p: tnode) : boolean;
  1190. begin
  1191. docompare :=
  1192. inherited docompare(p) and
  1193. (convtype = ttypeconvnode(p).convtype);
  1194. end;
  1195. begin
  1196. ctypeconvnode:=ttypeconvnode;
  1197. casnode:=tasnode;
  1198. cisnode:=tisnode;
  1199. end.
  1200. {
  1201. $Log$
  1202. Revision 1.28 2001-05-13 15:43:46 florian
  1203. * made resultype_char_to_char a little bit robuster
  1204. Revision 1.27 2001/05/08 21:06:30 florian
  1205. * some more support for widechars commited especially
  1206. regarding type casting and constants
  1207. Revision 1.26 2001/05/04 15:52:03 florian
  1208. * some Delphi incompatibilities fixed:
  1209. - out, dispose and new can be used as idenfiers now
  1210. - const p = apointerype(nil); is supported now
  1211. + support for const p = apointertype(pointer(1234)); added
  1212. Revision 1.25 2001/04/13 22:20:58 peter
  1213. * remove wrongly placed first_call_helper
  1214. Revision 1.24 2001/04/13 01:22:08 peter
  1215. * symtable change to classes
  1216. * range check generation and errors fixed, make cycle DEBUG=1 works
  1217. * memory leaks fixed
  1218. Revision 1.23 2001/04/04 22:42:39 peter
  1219. * move constant folding into det_resulttype
  1220. Revision 1.22 2001/04/02 21:20:30 peter
  1221. * resulttype rewrite
  1222. Revision 1.21 2001/03/08 17:44:47 jonas
  1223. * fixed web bug 1430
  1224. Revision 1.20 2001/02/21 11:49:50 jonas
  1225. * evaluate typecasts of const pointers to ordinals inline ('merged')
  1226. Revision 1.19 2001/02/20 18:37:10 peter
  1227. * removed unused code
  1228. Revision 1.18 2001/02/20 13:14:18 marco
  1229. * Fix from Peter for passing a procedure of method to a other method in a method
  1230. Revision 1.17 2001/02/08 13:09:03 jonas
  1231. * fixed web bug 1396: tpointerord is now a cardinal instead of a longint,
  1232. but added a hack in ncnv so that pointer(-1) still works
  1233. Revision 1.16 2000/12/31 11:14:10 jonas
  1234. + implemented/fixed docompare() mathods for all nodes (not tested)
  1235. + nopt.pas, nadd.pas, i386/n386opt.pas: optimized nodes for adding strings
  1236. and constant strings/chars together
  1237. * n386add.pas: don't copy temp strings (of size 256) to another temp string
  1238. when adding
  1239. Revision 1.15 2000/12/08 12:41:01 jonas
  1240. * fixed bug in sign extension patch
  1241. Revision 1.14 2000/12/07 17:19:42 jonas
  1242. * new constant handling: from now on, hex constants >$7fffffff are
  1243. parsed as unsigned constants (otherwise, $80000000 got sign extended
  1244. and became $ffffffff80000000), all constants in the longint range
  1245. become longints, all constants >$7fffffff and <=cardinal($ffffffff)
  1246. are cardinals and the rest are int64's.
  1247. * added lots of longint typecast to prevent range check errors in the
  1248. compiler and rtl
  1249. * type casts of symbolic ordinal constants are now preserved
  1250. * fixed bug where the original resulttype.def wasn't restored correctly
  1251. after doing a 64bit rangecheck
  1252. Revision 1.13 2000/11/29 00:30:32 florian
  1253. * unused units removed from uses clause
  1254. * some changes for widestrings
  1255. Revision 1.12 2000/11/20 16:06:04 jonas
  1256. + allow evaluation of 64bit constant expressions at compile time
  1257. * disable range checking for explicit typecasts of constant expressions
  1258. Revision 1.11 2000/11/12 23:24:11 florian
  1259. * interfaces are basically running
  1260. Revision 1.10 2000/11/04 14:25:20 florian
  1261. + merged Attila's changes for interfaces, not tested yet
  1262. Revision 1.9 2000/10/31 22:02:48 peter
  1263. * symtable splitted, no real code changes
  1264. Revision 1.8 2000/10/14 21:52:55 peter
  1265. * fixed memory leaks
  1266. Revision 1.7 2000/10/14 10:14:50 peter
  1267. * moehrendorf oct 2000 rewrite
  1268. Revision 1.6 2000/10/01 19:48:24 peter
  1269. * lot of compile updates for cg11
  1270. Revision 1.5 2000/09/28 19:49:52 florian
  1271. *** empty log message ***
  1272. Revision 1.4 2000/09/27 18:14:31 florian
  1273. * fixed a lot of syntax errors in the n*.pas stuff
  1274. Revision 1.3 2000/09/26 20:06:13 florian
  1275. * hmm, still a lot of work to get things compilable
  1276. Revision 1.2 2000/09/26 14:59:34 florian
  1277. * more conversion work done
  1278. Revision 1.1 2000/09/25 15:37:14 florian
  1279. * more fixes
  1280. }