ncnv.pas 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 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 fpcdefs.inc}
  20. interface
  21. uses
  22. node,
  23. symtype,symppu,
  24. defutil,defcmp,
  25. nld
  26. {$ifdef Delphi}
  27. ,dmisc
  28. {$endif}
  29. ;
  30. type
  31. ttypeconvnode = class(tunarynode)
  32. totype : ttype;
  33. convtype : tconverttype;
  34. constructor create(node : tnode;const t : ttype);virtual;
  35. constructor create_explicit(node : tnode;const t : ttype);
  36. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  37. procedure ppuwrite(ppufile:tcompilerppufile);override;
  38. procedure derefimpl;override;
  39. function getcopy : tnode;override;
  40. function pass_1 : tnode;override;
  41. function det_resulttype:tnode;override;
  42. {$ifdef var_notification}
  43. procedure mark_write;override;
  44. {$endif}
  45. function docompare(p: tnode) : boolean; override;
  46. private
  47. function resulttype_cord_to_pointer : tnode;
  48. function resulttype_chararray_to_string : tnode;
  49. function resulttype_string_to_chararray : tnode;
  50. function resulttype_string_to_string : tnode;
  51. function resulttype_char_to_string : tnode;
  52. function resulttype_char_to_chararray : tnode;
  53. function resulttype_int_to_real : tnode;
  54. function resulttype_real_to_real : tnode;
  55. function resulttype_cchar_to_pchar : tnode;
  56. function resulttype_cstring_to_pchar : tnode;
  57. function resulttype_char_to_char : tnode;
  58. function resulttype_arrayconstructor_to_set : tnode;
  59. function resulttype_pchar_to_string : tnode;
  60. function resulttype_interface_to_guid : tnode;
  61. function resulttype_dynarray_to_openarray : tnode;
  62. function resulttype_pwchar_to_string : tnode;
  63. function resulttype_call_helper(c : tconverttype) : tnode;
  64. protected
  65. function first_int_to_int : tnode;virtual;
  66. function first_cstring_to_pchar : tnode;virtual;
  67. function first_string_to_chararray : tnode;virtual;
  68. function first_char_to_string : tnode;virtual;
  69. function first_nothing : tnode;virtual;
  70. function first_array_to_pointer : tnode;virtual;
  71. function first_int_to_real : tnode;virtual;
  72. function first_real_to_real : tnode;virtual;
  73. function first_pointer_to_array : tnode;virtual;
  74. function first_cchar_to_pchar : tnode;virtual;
  75. function first_bool_to_int : tnode;virtual;
  76. function first_int_to_bool : tnode;virtual;
  77. function first_bool_to_bool : tnode;virtual;
  78. function first_proc_to_procvar : tnode;virtual;
  79. function first_load_smallset : tnode;virtual;
  80. function first_cord_to_pointer : tnode;virtual;
  81. function first_ansistring_to_pchar : tnode;virtual;
  82. function first_arrayconstructor_to_set : tnode;virtual;
  83. function first_class_to_intf : tnode;virtual;
  84. function first_char_to_char : tnode;virtual;
  85. function first_call_helper(c : tconverttype) : tnode;
  86. { these wrapper are necessary, because the first_* stuff is called }
  87. { through a table. Without the wrappers override wouldn't have }
  88. { any effect }
  89. function _first_int_to_int : tnode;
  90. function _first_cstring_to_pchar : tnode;
  91. function _first_string_to_chararray : tnode;
  92. function _first_char_to_string : tnode;
  93. function _first_nothing : tnode;
  94. function _first_array_to_pointer : tnode;
  95. function _first_int_to_real : tnode;
  96. function _first_real_to_real : tnode;
  97. function _first_pointer_to_array : tnode;
  98. function _first_cchar_to_pchar : tnode;
  99. function _first_bool_to_int : tnode;
  100. function _first_int_to_bool : tnode;
  101. function _first_bool_to_bool : tnode;
  102. function _first_proc_to_procvar : tnode;
  103. function _first_load_smallset : tnode;
  104. function _first_cord_to_pointer : tnode;
  105. function _first_ansistring_to_pchar : tnode;
  106. function _first_arrayconstructor_to_set : tnode;
  107. function _first_class_to_intf : tnode;
  108. function _first_char_to_char : tnode;
  109. procedure second_int_to_int;virtual;abstract;
  110. procedure second_string_to_string;virtual;abstract;
  111. procedure second_cstring_to_pchar;virtual;abstract;
  112. procedure second_string_to_chararray;virtual;abstract;
  113. procedure second_array_to_pointer;virtual;abstract;
  114. procedure second_pointer_to_array;virtual;abstract;
  115. procedure second_chararray_to_string;virtual;abstract;
  116. procedure second_char_to_string;virtual;abstract;
  117. procedure second_int_to_real;virtual;abstract;
  118. procedure second_real_to_real;virtual;abstract;
  119. procedure second_cord_to_pointer;virtual;abstract;
  120. procedure second_proc_to_procvar;virtual;abstract;
  121. procedure second_bool_to_int;virtual;abstract;
  122. procedure second_int_to_bool;virtual;abstract;
  123. procedure second_bool_to_bool;virtual;abstract;
  124. procedure second_load_smallset;virtual;abstract;
  125. procedure second_ansistring_to_pchar;virtual;abstract;
  126. procedure second_class_to_intf;virtual;abstract;
  127. procedure second_char_to_char;virtual;abstract;
  128. procedure second_nothing; virtual;abstract;
  129. end;
  130. ttypeconvnodeclass = class of ttypeconvnode;
  131. tasnode = class(tbinarynode)
  132. constructor create(l,r : tnode);virtual;
  133. function pass_1 : tnode;override;
  134. function det_resulttype:tnode;override;
  135. function getcopy: tnode;override;
  136. destructor destroy; override;
  137. protected
  138. call: tnode;
  139. end;
  140. tasnodeclass = class of tasnode;
  141. tisnode = class(tbinarynode)
  142. constructor create(l,r : tnode);virtual;
  143. function pass_1 : tnode;override;
  144. function det_resulttype:tnode;override;
  145. procedure pass_2;override;
  146. end;
  147. tisnodeclass = class of tisnode;
  148. var
  149. ctypeconvnode : ttypeconvnodeclass;
  150. casnode : tasnodeclass;
  151. cisnode : tisnodeclass;
  152. procedure inserttypeconv(var p:tnode;const t:ttype);
  153. procedure inserttypeconv_explicit(var p:tnode;const t:ttype);
  154. procedure arrayconstructor_to_set(var p : tnode);
  155. implementation
  156. uses
  157. globtype,systems,tokens,
  158. cutils,verbose,globals,widestr,
  159. symconst,symdef,symsym,symtable,
  160. ncon,ncal,nset,nadd,ninl,nmem,nmat,
  161. cgbase,
  162. htypechk,pass_1,cpubase,cpuinfo;
  163. {*****************************************************************************
  164. Helpers
  165. *****************************************************************************}
  166. procedure inserttypeconv(var p:tnode;const t:ttype);
  167. begin
  168. if not assigned(p.resulttype.def) then
  169. begin
  170. resulttypepass(p);
  171. if codegenerror then
  172. exit;
  173. end;
  174. { don't insert obsolete type conversions }
  175. if equal_defs(p.resulttype.def,t.def) and
  176. not ((p.resulttype.def.deftype=setdef) and
  177. (tsetdef(p.resulttype.def).settype <>
  178. tsetdef(t.def).settype)) then
  179. begin
  180. p.resulttype:=t;
  181. end
  182. else
  183. begin
  184. p:=ctypeconvnode.create(p,t);
  185. resulttypepass(p);
  186. end;
  187. end;
  188. procedure inserttypeconv_explicit(var p:tnode;const t:ttype);
  189. begin
  190. if not assigned(p.resulttype.def) then
  191. begin
  192. resulttypepass(p);
  193. if codegenerror then
  194. exit;
  195. end;
  196. { don't insert obsolete type conversions }
  197. if equal_defs(p.resulttype.def,t.def) and
  198. not ((p.resulttype.def.deftype=setdef) and
  199. (tsetdef(p.resulttype.def).settype <>
  200. tsetdef(t.def).settype)) then
  201. begin
  202. p.resulttype:=t;
  203. end
  204. else
  205. begin
  206. p:=ctypeconvnode.create_explicit(p,t);
  207. resulttypepass(p);
  208. end;
  209. end;
  210. {*****************************************************************************
  211. Array constructor to Set Conversion
  212. *****************************************************************************}
  213. procedure arrayconstructor_to_set(var p : tnode);
  214. var
  215. constp : tsetconstnode;
  216. buildp,
  217. p2,p3,p4 : tnode;
  218. htype : ttype;
  219. constset : Pconstset;
  220. constsetlo,
  221. constsethi : longint;
  222. procedure update_constsethi(t:ttype);
  223. begin
  224. if ((t.def.deftype=orddef) and
  225. (torddef(t.def).high>=constsethi)) then
  226. begin
  227. constsethi:=torddef(t.def).high;
  228. if htype.def=nil then
  229. begin
  230. if (constsethi>255) or
  231. (torddef(t.def).low<0) then
  232. htype:=u8bittype
  233. else
  234. htype:=t;
  235. end;
  236. if constsethi>255 then
  237. constsethi:=255;
  238. end
  239. else if ((t.def.deftype=enumdef) and
  240. (tenumdef(t.def).max>=constsethi)) then
  241. begin
  242. if htype.def=nil then
  243. htype:=t;
  244. constsethi:=tenumdef(t.def).max;
  245. end;
  246. end;
  247. procedure do_set(pos : longint);
  248. {$ifdef oldset}
  249. var
  250. mask,l : longint;
  251. {$endif}
  252. begin
  253. if (pos and not $ff)<>0 then
  254. Message(parser_e_illegal_set_expr);
  255. if pos>constsethi then
  256. constsethi:=pos;
  257. if pos<constsetlo then
  258. constsetlo:=pos;
  259. {$ifdef oldset}
  260. { to do this correctly we use the 32bit array }
  261. l:=pos shr 5;
  262. mask:=1 shl (pos mod 32);
  263. { do we allow the same twice }
  264. if (pconst32bitset(constset)^[l] and mask)<>0 then
  265. Message(parser_e_illegal_set_expr);
  266. pconst32bitset(constset)^[l]:=pconst32bitset(constset)^[l] or mask;
  267. {$else}
  268. include(constset^,pos);
  269. {$endif}
  270. end;
  271. var
  272. l : Longint;
  273. lr,hr : TConstExprInt;
  274. hp : tarrayconstructornode;
  275. begin
  276. if p.nodetype<>arrayconstructorn then
  277. internalerror(200205105);
  278. new(constset);
  279. {$ifdef oldset}
  280. FillChar(constset^,sizeof(constset^),0);
  281. {$else}
  282. constset^:=[];
  283. {$endif}
  284. htype.reset;
  285. constsetlo:=0;
  286. constsethi:=0;
  287. constp:=csetconstnode.create(nil,htype);
  288. constp.value_set:=constset;
  289. buildp:=constp;
  290. hp:=tarrayconstructornode(p);
  291. if assigned(hp.left) then
  292. begin
  293. while assigned(hp) do
  294. begin
  295. p4:=nil; { will contain the tree to create the set }
  296. {split a range into p2 and p3 }
  297. if hp.left.nodetype=arrayconstructorrangen then
  298. begin
  299. p2:=tarrayconstructorrangenode(hp.left).left;
  300. p3:=tarrayconstructorrangenode(hp.left).right;
  301. tarrayconstructorrangenode(hp.left).left:=nil;
  302. tarrayconstructorrangenode(hp.left).right:=nil;
  303. end
  304. else
  305. begin
  306. p2:=hp.left;
  307. hp.left:=nil;
  308. p3:=nil;
  309. end;
  310. resulttypepass(p2);
  311. if assigned(p3) then
  312. resulttypepass(p3);
  313. if codegenerror then
  314. break;
  315. case p2.resulttype.def.deftype of
  316. enumdef,
  317. orddef:
  318. begin
  319. getrange(p2.resulttype.def,lr,hr);
  320. if assigned(p3) then
  321. begin
  322. { this isn't good, you'll get problems with
  323. type t010 = 0..10;
  324. ts = set of t010;
  325. var s : ts;b : t010
  326. begin s:=[1,2,b]; end.
  327. if is_integer(p3^.resulttype.def) then
  328. begin
  329. inserttypeconv(p3,u8bitdef);
  330. end;
  331. }
  332. if assigned(htype.def) and not(equal_defs(htype.def,p3.resulttype.def)) then
  333. begin
  334. aktfilepos:=p3.fileinfo;
  335. CGMessage(type_e_typeconflict_in_set);
  336. end
  337. else
  338. begin
  339. if (p2.nodetype=ordconstn) and (p3.nodetype=ordconstn) then
  340. begin
  341. if not(is_integer(p3.resulttype.def)) then
  342. htype:=p3.resulttype
  343. else
  344. begin
  345. inserttypeconv(p3,u8bittype);
  346. inserttypeconv(p2,u8bittype);
  347. end;
  348. for l:=tordconstnode(p2).value to tordconstnode(p3).value do
  349. do_set(l);
  350. p2.free;
  351. p3.free;
  352. end
  353. else
  354. begin
  355. update_constsethi(p2.resulttype);
  356. inserttypeconv(p2,htype);
  357. update_constsethi(p3.resulttype);
  358. inserttypeconv(p3,htype);
  359. if assigned(htype.def) then
  360. inserttypeconv(p3,htype)
  361. else
  362. inserttypeconv(p3,u8bittype);
  363. p4:=csetelementnode.create(p2,p3);
  364. end;
  365. end;
  366. end
  367. else
  368. begin
  369. { Single value }
  370. if p2.nodetype=ordconstn then
  371. begin
  372. if not(is_integer(p2.resulttype.def)) then
  373. update_constsethi(p2.resulttype)
  374. else
  375. inserttypeconv(p2,u8bittype);
  376. do_set(tordconstnode(p2).value);
  377. p2.free;
  378. end
  379. else
  380. begin
  381. update_constsethi(p2.resulttype);
  382. if assigned(htype.def) then
  383. inserttypeconv(p2,htype)
  384. else
  385. inserttypeconv(p2,u8bittype);
  386. p4:=csetelementnode.create(p2,nil);
  387. end;
  388. end;
  389. end;
  390. stringdef :
  391. begin
  392. { if we've already set elements which are constants }
  393. { throw an error }
  394. if ((htype.def=nil) and assigned(buildp)) or
  395. not(is_char(htype.def)) then
  396. CGMessage(type_e_typeconflict_in_set)
  397. else
  398. for l:=1 to length(pstring(tstringconstnode(p2).value_str)^) do
  399. do_set(ord(pstring(tstringconstnode(p2).value_str)^[l]));
  400. if htype.def=nil then
  401. htype:=cchartype;
  402. p2.free;
  403. end;
  404. else
  405. CGMessage(type_e_ordinal_expr_expected);
  406. end;
  407. { insert the set creation tree }
  408. if assigned(p4) then
  409. buildp:=caddnode.create(addn,buildp,p4);
  410. { load next and dispose current node }
  411. p2:=hp;
  412. hp:=tarrayconstructornode(tarrayconstructornode(p2).right);
  413. tarrayconstructornode(p2).right:=nil;
  414. p2.free;
  415. end;
  416. if (htype.def=nil) then
  417. htype:=u8bittype;
  418. end
  419. else
  420. begin
  421. { empty set [], only remove node }
  422. p.free;
  423. end;
  424. { set the initial set type }
  425. constp.resulttype.setdef(tsetdef.create(htype,constsethi));
  426. { determine the resulttype for the tree }
  427. resulttypepass(buildp);
  428. { set the new tree }
  429. p:=buildp;
  430. end;
  431. {*****************************************************************************
  432. TTYPECONVNODE
  433. *****************************************************************************}
  434. constructor ttypeconvnode.create(node : tnode;const t:ttype);
  435. begin
  436. inherited create(typeconvn,node);
  437. convtype:=tc_not_possible;
  438. totype:=t;
  439. if t.def=nil then
  440. internalerror(200103281);
  441. set_file_line(node);
  442. end;
  443. constructor ttypeconvnode.create_explicit(node : tnode;const t:ttype);
  444. begin
  445. self.create(node,t);
  446. toggleflag(nf_explizit);
  447. end;
  448. constructor ttypeconvnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  449. begin
  450. inherited ppuload(t,ppufile);
  451. ppufile.gettype(totype);
  452. convtype:=tconverttype(ppufile.getbyte);
  453. end;
  454. procedure ttypeconvnode.ppuwrite(ppufile:tcompilerppufile);
  455. begin
  456. inherited ppuwrite(ppufile);
  457. ppufile.puttype(totype);
  458. ppufile.putbyte(byte(convtype));
  459. end;
  460. procedure ttypeconvnode.derefimpl;
  461. begin
  462. inherited derefimpl;
  463. totype.resolve;
  464. end;
  465. function ttypeconvnode.getcopy : tnode;
  466. var
  467. n : ttypeconvnode;
  468. begin
  469. n:=ttypeconvnode(inherited getcopy);
  470. n.convtype:=convtype;
  471. getcopy:=n;
  472. end;
  473. function ttypeconvnode.resulttype_cord_to_pointer : tnode;
  474. var
  475. t : tnode;
  476. begin
  477. result:=nil;
  478. if left.nodetype=ordconstn then
  479. begin
  480. { check if we have a valid pointer constant (JM) }
  481. if (sizeof(pointer) > sizeof(TConstPtrUInt)) then
  482. if (sizeof(TConstPtrUInt) = 4) then
  483. begin
  484. if (tordconstnode(left).value < low(longint)) or
  485. (tordconstnode(left).value > high(cardinal)) then
  486. CGMessage(parser_e_range_check_error);
  487. end
  488. else if (sizeof(TConstPtrUInt) = 8) then
  489. begin
  490. if (tordconstnode(left).value < low(int64)) or
  491. (tordconstnode(left).value > high(qword)) then
  492. CGMessage(parser_e_range_check_error);
  493. end
  494. else
  495. internalerror(2001020801);
  496. t:=cpointerconstnode.create(TConstPtrUInt(tordconstnode(left).value),resulttype);
  497. result:=t;
  498. end
  499. else
  500. internalerror(200104023);
  501. end;
  502. function ttypeconvnode.resulttype_chararray_to_string : tnode;
  503. begin
  504. result := ccallnode.createinternres(
  505. 'fpc_chararray_to_'+tstringdef(resulttype.def).stringtypname,
  506. ccallparanode.create(left,nil),resulttype);
  507. left := nil;
  508. end;
  509. function ttypeconvnode.resulttype_string_to_chararray : tnode;
  510. var
  511. arrsize: longint;
  512. begin
  513. with tarraydef(resulttype.def) do
  514. begin
  515. if highrange<lowrange then
  516. internalerror(75432653);
  517. arrsize := highrange-lowrange+1;
  518. end;
  519. if (left.nodetype = stringconstn) and
  520. { left.length+1 since there's always a terminating #0 character (JM) }
  521. (tstringconstnode(left).len+1 >= arrsize) and
  522. (tstringdef(left.resulttype.def).string_typ=st_shortstring) then
  523. begin
  524. { handled separately }
  525. result := nil;
  526. exit;
  527. end;
  528. result := ccallnode.createinternres(
  529. 'fpc_'+tstringdef(left.resulttype.def).stringtypname+
  530. '_to_chararray',ccallparanode.create(left,ccallparanode.create(
  531. cordconstnode.create(arrsize,s32bittype,true),nil)),resulttype);
  532. left := nil;
  533. end;
  534. function ttypeconvnode.resulttype_string_to_string : tnode;
  535. var
  536. procname: string[31];
  537. stringpara : tcallparanode;
  538. pw : pcompilerwidestring;
  539. pc : pchar;
  540. begin
  541. result:=nil;
  542. if left.nodetype=stringconstn then
  543. begin
  544. { convert ascii 2 unicode }
  545. if (tstringdef(resulttype.def).string_typ=st_widestring) and
  546. (tstringconstnode(left).st_type in [st_ansistring,st_shortstring,st_longstring]) then
  547. begin
  548. initwidestring(pw);
  549. ascii2unicode(tstringconstnode(left).value_str,tstringconstnode(left).len,pw);
  550. ansistringdispose(tstringconstnode(left).value_str,tstringconstnode(left).len);
  551. pcompilerwidestring(tstringconstnode(left).value_str):=pw;
  552. end
  553. else
  554. { convert unicode 2 ascii }
  555. if (tstringconstnode(left).st_type=st_widestring) and
  556. (tstringdef(resulttype.def).string_typ in [st_ansistring,st_shortstring,st_longstring]) then
  557. begin
  558. pw:=pcompilerwidestring(tstringconstnode(left).value_str);
  559. getmem(pc,getlengthwidestring(pw)+1);
  560. unicode2ascii(pw,pc);
  561. donewidestring(pw);
  562. tstringconstnode(left).value_str:=pc;
  563. end;
  564. tstringconstnode(left).st_type:=tstringdef(resulttype.def).string_typ;
  565. tstringconstnode(left).resulttype:=resulttype;
  566. result:=left;
  567. left:=nil;
  568. end
  569. else
  570. begin
  571. { get the correct procedure name }
  572. procname := 'fpc_'+tstringdef(left.resulttype.def).stringtypname+
  573. '_to_'+tstringdef(resulttype.def).stringtypname;
  574. { create parameter (and remove left node from typeconvnode }
  575. { since it's reused as parameter) }
  576. stringpara := ccallparanode.create(left,nil);
  577. left := nil;
  578. { when converting to shortstrings, we have to pass high(destination) too }
  579. if (tstringdef(resulttype.def).string_typ = st_shortstring) then
  580. stringpara.right := ccallparanode.create(cinlinenode.create(
  581. in_high_x,false,self.getcopy),nil);
  582. { and create the callnode }
  583. result := ccallnode.createinternres(procname,stringpara,resulttype);
  584. end;
  585. end;
  586. function ttypeconvnode.resulttype_char_to_string : tnode;
  587. var
  588. procname: string[31];
  589. para : tcallparanode;
  590. hp : tstringconstnode;
  591. ws : pcompilerwidestring;
  592. begin
  593. result:=nil;
  594. if left.nodetype=ordconstn then
  595. begin
  596. if tstringdef(resulttype.def).string_typ=st_widestring then
  597. begin
  598. initwidestring(ws);
  599. concatwidestringchar(ws,tcompilerwidechar(chr(tordconstnode(left).value)));
  600. hp:=cstringconstnode.createwstr(ws);
  601. donewidestring(ws);
  602. end
  603. else
  604. hp:=cstringconstnode.createstr(chr(tordconstnode(left).value),tstringdef(resulttype.def).string_typ);
  605. result:=hp;
  606. end
  607. else
  608. { shortstrings are handled 'inline' }
  609. if tstringdef(resulttype.def).string_typ <> st_shortstring then
  610. begin
  611. { create the parameter }
  612. para := ccallparanode.create(left,nil);
  613. left := nil;
  614. { and the procname }
  615. procname := 'fpc_char_to_' +tstringdef(resulttype.def).stringtypname;
  616. { and finally the call }
  617. result := ccallnode.createinternres(procname,para,resulttype);
  618. end
  619. else
  620. begin
  621. { create word(byte(char) shl 8 or 1) for litte endian machines }
  622. { and word(byte(char) or 256) for big endian machines }
  623. left := ctypeconvnode.create(left,u8bittype);
  624. left.toggleflag(nf_explizit);
  625. if (target_info.endian = endian_little) then
  626. left := caddnode.create(orn,
  627. cshlshrnode.create(shln,left,cordconstnode.create(8,s32bittype,false)),
  628. cordconstnode.create(1,s32bittype,false))
  629. else
  630. left := caddnode.create(orn,left,
  631. cordconstnode.create(1 shl 8,s32bittype,false));
  632. left := ctypeconvnode.create(left,u16bittype);
  633. left.toggleflag(nf_explizit);
  634. resulttypepass(left);
  635. end;
  636. end;
  637. function ttypeconvnode.resulttype_char_to_chararray : tnode;
  638. begin
  639. if resulttype.def.size <> 1 then
  640. begin
  641. { convert first to string, then to chararray }
  642. inserttypeconv(left,cshortstringtype);
  643. inserttypeconv(left,resulttype);
  644. result:=left;
  645. left := nil;
  646. exit;
  647. end;
  648. result := nil;
  649. end;
  650. function ttypeconvnode.resulttype_char_to_char : tnode;
  651. var
  652. hp : tordconstnode;
  653. begin
  654. result:=nil;
  655. if left.nodetype=ordconstn then
  656. begin
  657. if (torddef(resulttype.def).typ=uchar) and
  658. (torddef(left.resulttype.def).typ=uwidechar) then
  659. begin
  660. hp:=cordconstnode.create(
  661. ord(unicode2asciichar(tcompilerwidechar(tordconstnode(left).value))),
  662. cchartype,true);
  663. result:=hp;
  664. end
  665. else if (torddef(resulttype.def).typ=uwidechar) and
  666. (torddef(left.resulttype.def).typ=uchar) then
  667. begin
  668. hp:=cordconstnode.create(
  669. asciichar2unicode(chr(tordconstnode(left).value)),
  670. cwidechartype,true);
  671. result:=hp;
  672. end
  673. else
  674. internalerror(200105131);
  675. exit;
  676. end;
  677. end;
  678. function ttypeconvnode.resulttype_int_to_real : tnode;
  679. var
  680. t : trealconstnode;
  681. begin
  682. result:=nil;
  683. if left.nodetype=ordconstn then
  684. begin
  685. t:=crealconstnode.create(tordconstnode(left).value,resulttype);
  686. result:=t;
  687. end;
  688. end;
  689. function ttypeconvnode.resulttype_real_to_real : tnode;
  690. var
  691. t : tnode;
  692. begin
  693. result:=nil;
  694. if is_currency(left.resulttype.def) and not(is_currency(resulttype.def)) then
  695. begin
  696. end
  697. else
  698. if is_currency(resulttype.def) then
  699. begin
  700. end;
  701. if left.nodetype=realconstn then
  702. begin
  703. t:=crealconstnode.create(trealconstnode(left).value_real,resulttype);
  704. result:=t;
  705. end;
  706. end;
  707. function ttypeconvnode.resulttype_cchar_to_pchar : tnode;
  708. begin
  709. result:=nil;
  710. if is_pwidechar(resulttype.def) then
  711. inserttypeconv(left,cwidestringtype)
  712. else
  713. inserttypeconv(left,cshortstringtype);
  714. { evaluate again, reset resulttype so the convert_typ
  715. will be calculated again and cstring_to_pchar will
  716. be used for futher conversion }
  717. result:=det_resulttype;
  718. end;
  719. function ttypeconvnode.resulttype_cstring_to_pchar : tnode;
  720. begin
  721. result:=nil;
  722. if is_pwidechar(resulttype.def) then
  723. inserttypeconv(left,cwidestringtype);
  724. end;
  725. function ttypeconvnode.resulttype_arrayconstructor_to_set : tnode;
  726. var
  727. hp : tnode;
  728. begin
  729. result:=nil;
  730. if left.nodetype<>arrayconstructorn then
  731. internalerror(5546);
  732. { remove typeconv node }
  733. hp:=left;
  734. left:=nil;
  735. { create a set constructor tree }
  736. arrayconstructor_to_set(hp);
  737. result:=hp;
  738. end;
  739. function ttypeconvnode.resulttype_pchar_to_string : tnode;
  740. begin
  741. result := ccallnode.createinternres(
  742. 'fpc_pchar_to_'+tstringdef(resulttype.def).stringtypname,
  743. ccallparanode.create(left,nil),resulttype);
  744. left := nil;
  745. end;
  746. function ttypeconvnode.resulttype_interface_to_guid : tnode;
  747. begin
  748. if assigned(tobjectdef(left.resulttype.def).iidguid) then
  749. result:=cguidconstnode.create(tobjectdef(left.resulttype.def).iidguid^);
  750. end;
  751. function ttypeconvnode.resulttype_dynarray_to_openarray : tnode;
  752. begin
  753. { a dynamic array is a pointer to an array, so to convert it to }
  754. { an open array, we have to dereference it (JM) }
  755. result := ctypeconvnode.create(left,voidpointertype);
  756. { left is reused }
  757. left := nil;
  758. result.toggleflag(nf_explizit);
  759. result := cderefnode.create(result);
  760. result.resulttype := resulttype;
  761. end;
  762. function ttypeconvnode.resulttype_pwchar_to_string : tnode;
  763. begin
  764. result := ccallnode.createinternres(
  765. 'fpc_pwidechar_to_'+tstringdef(resulttype.def).stringtypname,
  766. ccallparanode.create(left,nil),resulttype);
  767. left := nil;
  768. end;
  769. function ttypeconvnode.resulttype_call_helper(c : tconverttype) : tnode;
  770. {$ifdef fpc}
  771. const
  772. resulttypeconvert : array[tconverttype] of pointer = (
  773. {equal} nil,
  774. {not_possible} nil,
  775. { string_2_string } @ttypeconvnode.resulttype_string_to_string,
  776. { char_2_string } @ttypeconvnode.resulttype_char_to_string,
  777. { char_2_chararray } @ttypeconvnode.resulttype_char_to_chararray,
  778. { pchar_2_string } @ttypeconvnode.resulttype_pchar_to_string,
  779. { cchar_2_pchar } @ttypeconvnode.resulttype_cchar_to_pchar,
  780. { cstring_2_pchar } @ttypeconvnode.resulttype_cstring_to_pchar,
  781. { ansistring_2_pchar } nil,
  782. { string_2_chararray } @ttypeconvnode.resulttype_string_to_chararray,
  783. { chararray_2_string } @ttypeconvnode.resulttype_chararray_to_string,
  784. { array_2_pointer } nil,
  785. { pointer_2_array } nil,
  786. { int_2_int } nil,
  787. { int_2_bool } nil,
  788. { bool_2_bool } nil,
  789. { bool_2_int } nil,
  790. { real_2_real } @ttypeconvnode.resulttype_real_to_real,
  791. { int_2_real } @ttypeconvnode.resulttype_int_to_real,
  792. { proc_2_procvar } nil,
  793. { arrayconstructor_2_set } @ttypeconvnode.resulttype_arrayconstructor_to_set,
  794. { load_smallset } nil,
  795. { cord_2_pointer } @ttypeconvnode.resulttype_cord_to_pointer,
  796. { intf_2_string } nil,
  797. { intf_2_guid } @ttypeconvnode.resulttype_interface_to_guid,
  798. { class_2_intf } nil,
  799. { char_2_char } @ttypeconvnode.resulttype_char_to_char,
  800. { normal_2_smallset} nil,
  801. { dynarray_2_openarray} @resulttype_dynarray_to_openarray,
  802. { pwchar_2_string} @resulttype_pwchar_to_string
  803. );
  804. type
  805. tprocedureofobject = function : tnode of object;
  806. var
  807. r : packed record
  808. proc : pointer;
  809. obj : pointer;
  810. end;
  811. begin
  812. result:=nil;
  813. { this is a little bit dirty but it works }
  814. { and should be quite portable too }
  815. r.proc:=resulttypeconvert[c];
  816. r.obj:=self;
  817. if assigned(r.proc) then
  818. result:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  819. end;
  820. {$else}
  821. begin
  822. case c of
  823. tc_string_2_string: resulttype_string_to_string;
  824. tc_char_2_string : resulttype_char_to_string;
  825. tc_char_2_chararray: resulttype_char_to_chararray;
  826. tc_pchar_2_string : resulttype_pchar_to_string;
  827. tc_cchar_2_pchar : resulttype_cchar_to_pchar;
  828. tc_cstring_2_pchar : resulttype_cstring_to_pchar;
  829. tc_string_2_chararray : resulttype_string_to_chararray;
  830. tc_chararray_2_string : resulttype_chararray_to_string;
  831. tc_real_2_real : resulttype_real_to_real;
  832. tc_int_2_real : resulttype_int_to_real;
  833. tc_arrayconstructor_2_set : resulttype_arrayconstructor_to_set;
  834. tc_cord_2_pointer : resulttype_cord_to_pointer;
  835. tc_intf_2_guid : resulttype_interface_to_guid;
  836. tc_char_2_char : resulttype_char_to_char;
  837. tc_dynarray_2_openarray : resulttype_dynarray_to_openarray;
  838. tc_pwchar_2_string : resulttype_pwchar_to_string;
  839. end;
  840. end;
  841. {$Endif fpc}
  842. function ttypeconvnode.det_resulttype:tnode;
  843. var
  844. hp : tnode;
  845. currprocdef,
  846. aprocdef : tprocdef;
  847. eq : tequaltype;
  848. begin
  849. result:=nil;
  850. resulttype:=totype;
  851. resulttypepass(left);
  852. if codegenerror then
  853. exit;
  854. eq:=compare_defs_ext(left.resulttype.def,resulttype.def,left.nodetype,
  855. nf_explizit in flags,true,convtype,aprocdef);
  856. case eq of
  857. te_exact,
  858. te_equal :
  859. begin
  860. { because is_equal only checks the basetype for sets we need to
  861. check here if we are loading a smallset into a normalset }
  862. if (resulttype.def.deftype=setdef) and
  863. (left.resulttype.def.deftype=setdef) and
  864. ((tsetdef(resulttype.def).settype = smallset) xor
  865. (tsetdef(left.resulttype.def).settype = smallset)) then
  866. begin
  867. { constant sets can be converted by changing the type only }
  868. if (left.nodetype=setconstn) then
  869. begin
  870. tsetdef(left.resulttype.def).changesettype(tsetdef(resulttype.def).settype);
  871. result:=left;
  872. left:=nil;
  873. exit;
  874. end;
  875. if (tsetdef(resulttype.def).settype <> smallset) then
  876. convtype:=tc_load_smallset
  877. else
  878. convtype := tc_normal_2_smallset;
  879. exit;
  880. end
  881. else
  882. begin
  883. left.resulttype:=resulttype;
  884. result:=left;
  885. left:=nil;
  886. exit;
  887. end;
  888. end;
  889. te_convert_l1,
  890. te_convert_l2 :
  891. begin
  892. { nothing to do }
  893. end;
  894. te_convert_operator :
  895. begin
  896. procinfo.flags:=procinfo.flags or pi_do_call;
  897. hp:=ccallnode.create(ccallparanode.create(left,nil),
  898. overloaded_operators[_assignment],nil,nil);
  899. { tell explicitly which def we must use !! (PM) }
  900. tcallnode(hp).procdefinition:=aprocdef;
  901. left:=nil;
  902. result:=hp;
  903. exit;
  904. end;
  905. te_incompatible :
  906. begin
  907. { Procedures have a resulttype.def of voiddef and functions of their
  908. own resulttype.def. They will therefore always be incompatible with
  909. a procvar. Because isconvertable cannot check for procedures we
  910. use an extra check for them.}
  911. if (m_tp_procvar in aktmodeswitches) then
  912. begin
  913. if (resulttype.def.deftype=procvardef) and
  914. (is_procsym_load(left) or is_procsym_call(left)) then
  915. begin
  916. if is_procsym_call(left) then
  917. begin
  918. currprocdef:=Tprocsym(Tcallnode(left).symtableprocentry).search_procdef_byprocvardef(Tprocvardef(resulttype.def));
  919. hp:=cloadnode.create_procvar(tprocsym(tcallnode(left).symtableprocentry),
  920. currprocdef,tcallnode(left).symtableproc);
  921. if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
  922. assigned(tcallnode(left).methodpointer) then
  923. tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
  924. resulttypepass(hp);
  925. left.free;
  926. left:=hp;
  927. aprocdef:=tprocdef(left.resulttype.def);
  928. end
  929. else
  930. begin
  931. if (left.nodetype<>addrn) then
  932. aprocdef:=tprocsym(tloadnode(left).symtableentry).first_procdef;
  933. end;
  934. convtype:=tc_proc_2_procvar;
  935. { Now check if the procedure we are going to assign to
  936. the procvar, is compatible with the procvar's type }
  937. if assigned(aprocdef) then
  938. begin
  939. if proc_to_procvar_equal(aprocdef,tprocvardef(resulttype.def))=te_incompatible then
  940. CGMessage2(type_e_incompatible_types,aprocdef.typename,resulttype.def.typename);
  941. end
  942. else
  943. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  944. exit;
  945. end;
  946. end;
  947. { Handle explicit type conversions }
  948. if nf_explizit in flags then
  949. begin
  950. { do common tc_equal cast }
  951. convtype:=tc_equal;
  952. { check if the result could be in a register }
  953. if not(tstoreddef(resulttype.def).is_intregable) and
  954. not(tstoreddef(resulttype.def).is_fpuregable) then
  955. make_not_regable(left);
  956. { class to class or object to object, with checkobject support }
  957. if (resulttype.def.deftype=objectdef) and
  958. (left.resulttype.def.deftype=objectdef) then
  959. begin
  960. if (cs_check_object in aktlocalswitches) then
  961. begin
  962. if is_class_or_interface(resulttype.def) then
  963. begin
  964. { we can translate the typeconvnode to 'as' when
  965. typecasting to a class or interface }
  966. hp:=casnode.create(left,cloadvmtnode.create(ctypenode.create(resulttype)));
  967. left:=nil;
  968. result:=hp;
  969. exit;
  970. end;
  971. end
  972. else
  973. begin
  974. { check if the types are related }
  975. if (not(tobjectdef(left.resulttype.def).is_related(tobjectdef(resulttype.def)))) and
  976. (not(tobjectdef(resulttype.def).is_related(tobjectdef(left.resulttype.def)))) then
  977. CGMessage2(type_w_classes_not_related,left.resulttype.def.typename,resulttype.def.typename);
  978. end;
  979. end
  980. { only if the same size or formal def }
  981. { why do we allow typecasting of voiddef ?? (PM) }
  982. else
  983. begin
  984. if not(
  985. (left.resulttype.def.deftype=formaldef) or
  986. (not(is_open_array(left.resulttype.def)) and
  987. (left.resulttype.def.size=resulttype.def.size)) or
  988. (is_void(left.resulttype.def) and
  989. (left.nodetype=derefn))
  990. ) then
  991. CGMessage(cg_e_illegal_type_conversion);
  992. if ((left.resulttype.def.deftype=orddef) and
  993. (resulttype.def.deftype=pointerdef)) or
  994. ((resulttype.def.deftype=orddef) and
  995. (left.resulttype.def.deftype=pointerdef)) then
  996. CGMessage(cg_d_pointer_to_longint_conv_not_portable);
  997. end;
  998. { the conversion into a strutured type is only }
  999. { possible, if the source is not a register }
  1000. if (
  1001. (resulttype.def.deftype in [recorddef,stringdef,arraydef]) or
  1002. ((resulttype.def.deftype=objectdef) and
  1003. not(is_class(resulttype.def)))
  1004. ) and
  1005. (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  1006. CGMessage(cg_e_illegal_type_conversion);
  1007. end
  1008. else
  1009. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  1010. end;
  1011. else
  1012. internalerror(200211231);
  1013. end;
  1014. { Constant folding and other node transitions to
  1015. remove the typeconv node }
  1016. case left.nodetype of
  1017. loadn :
  1018. begin
  1019. { tp7 procvar support, when right is not a procvardef and we got a
  1020. loadn of a procvar then convert to a calln, the check for the
  1021. result is already done in is_convertible, also no conflict with
  1022. @procvar is here because that has an extra addrn }
  1023. if (m_tp_procvar in aktmodeswitches) and
  1024. (resulttype.def.deftype<>procvardef) and
  1025. (left.resulttype.def.deftype=procvardef) then
  1026. begin
  1027. hp:=ccallnode.create(nil,nil,nil,nil);
  1028. tcallnode(hp).set_procvar(left);
  1029. resulttypepass(hp);
  1030. left:=hp;
  1031. end;
  1032. end;
  1033. niln :
  1034. begin
  1035. { nil to ordinal node }
  1036. if (resulttype.def.deftype=orddef) then
  1037. begin
  1038. hp:=cordconstnode.create(0,resulttype,true);
  1039. result:=hp;
  1040. exit;
  1041. end
  1042. else
  1043. { fold nil to any pointer type }
  1044. if (resulttype.def.deftype=pointerdef) then
  1045. begin
  1046. hp:=cnilnode.create;
  1047. hp.resulttype:=resulttype;
  1048. result:=hp;
  1049. exit;
  1050. end
  1051. else
  1052. { remove typeconv after niln, but not when the result is a
  1053. methodpointer. The typeconv of the methodpointer will then
  1054. take care of updateing size of niln to OS_64 }
  1055. if not((resulttype.def.deftype=procvardef) and
  1056. (po_methodpointer in tprocvardef(resulttype.def).procoptions)) then
  1057. begin
  1058. left.resulttype:=resulttype;
  1059. result:=left;
  1060. left:=nil;
  1061. exit;
  1062. end;
  1063. end;
  1064. ordconstn :
  1065. begin
  1066. { ordinal contants can be directly converted }
  1067. { but not char to char because it is a widechar to char or via versa }
  1068. { which needs extra code to do the code page transistion }
  1069. if is_ordinal(resulttype.def) and
  1070. not(convtype=tc_char_2_char) then
  1071. begin
  1072. { replace the resulttype and recheck the range }
  1073. left.resulttype:=resulttype;
  1074. testrange(left.resulttype.def,tordconstnode(left).value,(nf_explizit in flags));
  1075. result:=left;
  1076. left:=nil;
  1077. exit;
  1078. end;
  1079. end;
  1080. pointerconstn :
  1081. begin
  1082. { pointerconstn to any pointer is folded too }
  1083. if (resulttype.def.deftype=pointerdef) then
  1084. begin
  1085. left.resulttype:=resulttype;
  1086. result:=left;
  1087. left:=nil;
  1088. exit;
  1089. end
  1090. { constant pointer to ordinal }
  1091. else if is_ordinal(resulttype.def) then
  1092. begin
  1093. hp:=cordconstnode.create(tpointerconstnode(left).value,
  1094. resulttype,true);
  1095. result:=hp;
  1096. exit;
  1097. end;
  1098. end;
  1099. end;
  1100. { now call the resulttype helper to do constant folding }
  1101. result:=resulttype_call_helper(convtype);
  1102. end;
  1103. {$ifdef var_notification}
  1104. procedure Ttypeconvnode.mark_write;
  1105. begin
  1106. left.mark_write;
  1107. end;
  1108. {$endif}
  1109. function ttypeconvnode.first_cord_to_pointer : tnode;
  1110. begin
  1111. result:=nil;
  1112. internalerror(200104043);
  1113. end;
  1114. function ttypeconvnode.first_int_to_int : tnode;
  1115. begin
  1116. first_int_to_int:=nil;
  1117. if (left.location.loc<>LOC_REGISTER) and
  1118. (resulttype.def.size>left.resulttype.def.size) then
  1119. location.loc:=LOC_REGISTER;
  1120. if is_64bitint(resulttype.def) then
  1121. registers32:=max(registers32,2)
  1122. else
  1123. registers32:=max(registers32,1);
  1124. end;
  1125. function ttypeconvnode.first_cstring_to_pchar : tnode;
  1126. begin
  1127. first_cstring_to_pchar:=nil;
  1128. registers32:=1;
  1129. location.loc:=LOC_REGISTER;
  1130. end;
  1131. function ttypeconvnode.first_string_to_chararray : tnode;
  1132. begin
  1133. first_string_to_chararray:=nil;
  1134. registers32:=1;
  1135. location.loc:=LOC_REGISTER;
  1136. end;
  1137. function ttypeconvnode.first_char_to_string : tnode;
  1138. begin
  1139. first_char_to_string:=nil;
  1140. location.loc:=LOC_CREFERENCE;
  1141. end;
  1142. function ttypeconvnode.first_nothing : tnode;
  1143. begin
  1144. first_nothing:=nil;
  1145. end;
  1146. function ttypeconvnode.first_array_to_pointer : tnode;
  1147. begin
  1148. first_array_to_pointer:=nil;
  1149. if registers32<1 then
  1150. registers32:=1;
  1151. location.loc:=LOC_REGISTER;
  1152. end;
  1153. function ttypeconvnode.first_int_to_real: tnode;
  1154. var
  1155. fname: string[19];
  1156. typname : string[12];
  1157. begin
  1158. { Get the type name }
  1159. { Normally the typename should be one of the following:
  1160. single, double - carl
  1161. }
  1162. typname := lower(pbestrealtype^.def.gettypename);
  1163. { converting a 64bit integer to a float requires a helper }
  1164. if is_64bitint(left.resulttype.def) then
  1165. begin
  1166. if is_signed(left.resulttype.def) then
  1167. fname := 'fpc_int64_to_'+typname
  1168. else
  1169. fname := 'fpc_qword_to_'+typname;
  1170. result := ccallnode.createintern(fname,ccallparanode.create(
  1171. left,nil));
  1172. left:=nil;
  1173. firstpass(result);
  1174. exit;
  1175. end
  1176. else
  1177. { other integers are supposed to be 32 bit }
  1178. begin
  1179. if is_signed(left.resulttype.def) then
  1180. fname := 'fpc_longint_to_'+typname
  1181. else
  1182. fname := 'fpc_longword_to_'+typname;
  1183. result := ccallnode.createintern(fname,ccallparanode.create(
  1184. left,nil));
  1185. left:=nil;
  1186. firstpass(result);
  1187. exit;
  1188. end;
  1189. end;
  1190. function ttypeconvnode.first_real_to_real : tnode;
  1191. begin
  1192. first_real_to_real:=nil;
  1193. { comp isn't a floating type }
  1194. {$ifdef i386}
  1195. if (tfloatdef(resulttype.def).typ=s64comp) and
  1196. (tfloatdef(left.resulttype.def).typ<>s64comp) and
  1197. not (nf_explizit in flags) then
  1198. CGMessage(type_w_convert_real_2_comp);
  1199. {$endif}
  1200. if registersfpu<1 then
  1201. registersfpu:=1;
  1202. location.loc:=LOC_FPUREGISTER;
  1203. end;
  1204. function ttypeconvnode.first_pointer_to_array : tnode;
  1205. begin
  1206. first_pointer_to_array:=nil;
  1207. if registers32<1 then
  1208. registers32:=1;
  1209. location.loc:=LOC_REFERENCE;
  1210. end;
  1211. function ttypeconvnode.first_cchar_to_pchar : tnode;
  1212. begin
  1213. first_cchar_to_pchar:=nil;
  1214. internalerror(200104021);
  1215. end;
  1216. function ttypeconvnode.first_bool_to_int : tnode;
  1217. begin
  1218. first_bool_to_int:=nil;
  1219. { byte(boolean) or word(wordbool) or longint(longbool) must
  1220. be accepted for var parameters }
  1221. if (nf_explizit in flags) and
  1222. (left.resulttype.def.size=resulttype.def.size) and
  1223. (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
  1224. exit;
  1225. { when converting to 64bit, first convert to a 32bit int and then }
  1226. { convert to a 64bit int (only necessary for 32bit processors) (JM) }
  1227. if resulttype.def.size > sizeof(aword) then
  1228. begin
  1229. result := ctypeconvnode.create(left,u32bittype);
  1230. result.toggleflag(nf_explizit);
  1231. result := ctypeconvnode.create(result,resulttype);
  1232. left := nil;
  1233. firstpass(result);
  1234. exit;
  1235. end;
  1236. location.loc:=LOC_REGISTER;
  1237. if registers32<1 then
  1238. registers32:=1;
  1239. end;
  1240. function ttypeconvnode.first_int_to_bool : tnode;
  1241. begin
  1242. first_int_to_bool:=nil;
  1243. { byte(boolean) or word(wordbool) or longint(longbool) must
  1244. be accepted for var parameters }
  1245. if (nf_explizit in flags) and
  1246. (left.resulttype.def.size=resulttype.def.size) and
  1247. (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
  1248. exit;
  1249. location.loc:=LOC_REGISTER;
  1250. { need if bool to bool !!
  1251. not very nice !!
  1252. insertypeconv(left,s32bittype);
  1253. left.explizit:=true;
  1254. firstpass(left); }
  1255. if registers32<1 then
  1256. registers32:=1;
  1257. end;
  1258. function ttypeconvnode.first_bool_to_bool : tnode;
  1259. begin
  1260. first_bool_to_bool:=nil;
  1261. location.loc:=LOC_REGISTER;
  1262. if registers32<1 then
  1263. registers32:=1;
  1264. end;
  1265. function ttypeconvnode.first_char_to_char : tnode;
  1266. begin
  1267. first_char_to_char:=nil;
  1268. location.loc:=LOC_REGISTER;
  1269. if registers32<1 then
  1270. registers32:=1;
  1271. end;
  1272. function ttypeconvnode.first_proc_to_procvar : tnode;
  1273. begin
  1274. first_proc_to_procvar:=nil;
  1275. if (left.location.loc<>LOC_REFERENCE) then
  1276. CGMessage(cg_e_illegal_expression);
  1277. registers32:=left.registers32;
  1278. if registers32<1 then
  1279. registers32:=1;
  1280. location.loc:=LOC_REGISTER;
  1281. end;
  1282. function ttypeconvnode.first_load_smallset : tnode;
  1283. var
  1284. srsym: ttypesym;
  1285. p: tcallparanode;
  1286. begin
  1287. if not searchsystype('FPC_SMALL_SET',srsym) then
  1288. internalerror(200108313);
  1289. p := ccallparanode.create(left,nil);
  1290. { reused }
  1291. left := nil;
  1292. { convert parameter explicitely to fpc_small_set }
  1293. p.left := ctypeconvnode.create(p.left,srsym.restype);
  1294. p.left.toggleflag(nf_explizit);
  1295. { create call, adjust resulttype }
  1296. result :=
  1297. ccallnode.createinternres('fpc_set_load_small',p,resulttype);
  1298. firstpass(result);
  1299. end;
  1300. function ttypeconvnode.first_ansistring_to_pchar : tnode;
  1301. begin
  1302. first_ansistring_to_pchar:=nil;
  1303. location.loc:=LOC_REGISTER;
  1304. if registers32<1 then
  1305. registers32:=1;
  1306. end;
  1307. function ttypeconvnode.first_arrayconstructor_to_set : tnode;
  1308. begin
  1309. first_arrayconstructor_to_set:=nil;
  1310. internalerror(200104022);
  1311. end;
  1312. function ttypeconvnode.first_class_to_intf : tnode;
  1313. begin
  1314. first_class_to_intf:=nil;
  1315. location.loc:=LOC_REFERENCE;
  1316. if registers32<1 then
  1317. registers32:=1;
  1318. end;
  1319. function ttypeconvnode._first_int_to_int : tnode;
  1320. begin
  1321. result:=first_int_to_int;
  1322. end;
  1323. function ttypeconvnode._first_cstring_to_pchar : tnode;
  1324. begin
  1325. result:=first_cstring_to_pchar;
  1326. end;
  1327. function ttypeconvnode._first_string_to_chararray : tnode;
  1328. begin
  1329. result:=first_string_to_chararray;
  1330. end;
  1331. function ttypeconvnode._first_char_to_string : tnode;
  1332. begin
  1333. result:=first_char_to_string;
  1334. end;
  1335. function ttypeconvnode._first_nothing : tnode;
  1336. begin
  1337. result:=first_nothing;
  1338. end;
  1339. function ttypeconvnode._first_array_to_pointer : tnode;
  1340. begin
  1341. result:=first_array_to_pointer;
  1342. end;
  1343. function ttypeconvnode._first_int_to_real : tnode;
  1344. begin
  1345. result:=first_int_to_real;
  1346. end;
  1347. function ttypeconvnode._first_real_to_real : tnode;
  1348. begin
  1349. result:=first_real_to_real;
  1350. end;
  1351. function ttypeconvnode._first_pointer_to_array : tnode;
  1352. begin
  1353. result:=first_pointer_to_array;
  1354. end;
  1355. function ttypeconvnode._first_cchar_to_pchar : tnode;
  1356. begin
  1357. result:=first_cchar_to_pchar;
  1358. end;
  1359. function ttypeconvnode._first_bool_to_int : tnode;
  1360. begin
  1361. result:=first_bool_to_int;
  1362. end;
  1363. function ttypeconvnode._first_int_to_bool : tnode;
  1364. begin
  1365. result:=first_int_to_bool;
  1366. end;
  1367. function ttypeconvnode._first_bool_to_bool : tnode;
  1368. begin
  1369. result:=first_bool_to_bool;
  1370. end;
  1371. function ttypeconvnode._first_proc_to_procvar : tnode;
  1372. begin
  1373. result:=first_proc_to_procvar;
  1374. end;
  1375. function ttypeconvnode._first_load_smallset : tnode;
  1376. begin
  1377. result:=first_load_smallset;
  1378. end;
  1379. function ttypeconvnode._first_cord_to_pointer : tnode;
  1380. begin
  1381. result:=first_cord_to_pointer;
  1382. end;
  1383. function ttypeconvnode._first_ansistring_to_pchar : tnode;
  1384. begin
  1385. result:=first_ansistring_to_pchar;
  1386. end;
  1387. function ttypeconvnode._first_arrayconstructor_to_set : tnode;
  1388. begin
  1389. result:=first_arrayconstructor_to_set;
  1390. end;
  1391. function ttypeconvnode._first_class_to_intf : tnode;
  1392. begin
  1393. result:=first_class_to_intf;
  1394. end;
  1395. function ttypeconvnode._first_char_to_char : tnode;
  1396. begin
  1397. result:=first_char_to_char;
  1398. end;
  1399. function ttypeconvnode.first_call_helper(c : tconverttype) : tnode;
  1400. const
  1401. firstconvert : array[tconverttype] of pointer = (
  1402. @ttypeconvnode._first_nothing, {equal}
  1403. @ttypeconvnode._first_nothing, {not_possible}
  1404. nil, { removed in resulttype_string_to_string }
  1405. @ttypeconvnode._first_char_to_string,
  1406. @ttypeconvnode._first_nothing, { char_2_chararray, needs nothing extra }
  1407. nil, { removed in resulttype_chararray_to_string }
  1408. @ttypeconvnode._first_cchar_to_pchar,
  1409. @ttypeconvnode._first_cstring_to_pchar,
  1410. @ttypeconvnode._first_ansistring_to_pchar,
  1411. @ttypeconvnode._first_string_to_chararray,
  1412. nil, { removed in resulttype_chararray_to_string }
  1413. @ttypeconvnode._first_array_to_pointer,
  1414. @ttypeconvnode._first_pointer_to_array,
  1415. @ttypeconvnode._first_int_to_int,
  1416. @ttypeconvnode._first_int_to_bool,
  1417. @ttypeconvnode._first_bool_to_bool,
  1418. @ttypeconvnode._first_bool_to_int,
  1419. @ttypeconvnode._first_real_to_real,
  1420. @ttypeconvnode._first_int_to_real,
  1421. @ttypeconvnode._first_proc_to_procvar,
  1422. @ttypeconvnode._first_arrayconstructor_to_set,
  1423. @ttypeconvnode._first_load_smallset,
  1424. @ttypeconvnode._first_cord_to_pointer,
  1425. @ttypeconvnode._first_nothing,
  1426. @ttypeconvnode._first_nothing,
  1427. @ttypeconvnode._first_class_to_intf,
  1428. @ttypeconvnode._first_char_to_char,
  1429. @ttypeconvnode._first_nothing,
  1430. @ttypeconvnode._first_nothing,
  1431. nil
  1432. );
  1433. type
  1434. tprocedureofobject = function : tnode of object;
  1435. var
  1436. r : packed record
  1437. proc : pointer;
  1438. obj : pointer;
  1439. end;
  1440. begin
  1441. { this is a little bit dirty but it works }
  1442. { and should be quite portable too }
  1443. r.proc:=firstconvert[c];
  1444. r.obj:=self;
  1445. first_call_helper:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  1446. end;
  1447. function ttypeconvnode.pass_1 : tnode;
  1448. begin
  1449. result:=nil;
  1450. firstpass(left);
  1451. if codegenerror then
  1452. exit;
  1453. { load the value_str from the left part }
  1454. registers32:=left.registers32;
  1455. registersfpu:=left.registersfpu;
  1456. {$ifdef SUPPORT_MMX}
  1457. registersmmx:=left.registersmmx;
  1458. {$endif}
  1459. location.loc:=left.location.loc;
  1460. if nf_explizit in flags then
  1461. begin
  1462. { check if the result could be in a register }
  1463. if not(tstoreddef(resulttype.def).is_intregable) and
  1464. not(tstoreddef(resulttype.def).is_fpuregable) then
  1465. make_not_regable(left);
  1466. end;
  1467. result:=first_call_helper(convtype);
  1468. end;
  1469. function ttypeconvnode.docompare(p: tnode) : boolean;
  1470. begin
  1471. docompare :=
  1472. inherited docompare(p) and
  1473. (convtype = ttypeconvnode(p).convtype);
  1474. end;
  1475. {*****************************************************************************
  1476. TISNODE
  1477. *****************************************************************************}
  1478. constructor tisnode.create(l,r : tnode);
  1479. begin
  1480. inherited create(isn,l,r);
  1481. end;
  1482. function tisnode.det_resulttype:tnode;
  1483. var
  1484. paras: tcallparanode;
  1485. begin
  1486. result:=nil;
  1487. resulttypepass(left);
  1488. resulttypepass(right);
  1489. set_varstate(left,true);
  1490. set_varstate(right,true);
  1491. if codegenerror then
  1492. exit;
  1493. if (right.resulttype.def.deftype=classrefdef) then
  1494. begin
  1495. { left must be a class }
  1496. if is_class(left.resulttype.def) then
  1497. begin
  1498. { the operands must be related }
  1499. if (not(tobjectdef(left.resulttype.def).is_related(
  1500. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1501. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1502. tobjectdef(left.resulttype.def)))) then
  1503. CGMessage2(type_e_classes_not_related,left.resulttype.def.typename,
  1504. tclassrefdef(right.resulttype.def).pointertype.def.typename);
  1505. end
  1506. else
  1507. CGMessage1(type_e_class_type_expected,left.resulttype.def.typename);
  1508. { call fpc_do_is helper }
  1509. paras := ccallparanode.create(
  1510. left,
  1511. ccallparanode.create(
  1512. right,nil));
  1513. result := ccallnode.createintern('fpc_do_is',paras);
  1514. left := nil;
  1515. right := nil;
  1516. end
  1517. else if is_interface(right.resulttype.def) then
  1518. begin
  1519. { left is a class }
  1520. if is_class(left.resulttype.def) then
  1521. begin
  1522. { the operands must be related }
  1523. if not(assigned(tobjectdef(left.resulttype.def).implementedinterfaces) and
  1524. (tobjectdef(left.resulttype.def).implementedinterfaces.searchintf(right.resulttype.def)<>-1)) then
  1525. CGMessage2(type_e_classes_not_related,left.resulttype.def.typename,right.resulttype.def.typename);
  1526. end
  1527. { left is an interface }
  1528. else if is_interface(left.resulttype.def) then
  1529. begin
  1530. { the operands must be related }
  1531. if (not(tobjectdef(left.resulttype.def).is_related(tobjectdef(right.resulttype.def)))) and
  1532. (not(tobjectdef(right.resulttype.def).is_related(tobjectdef(left.resulttype.def)))) then
  1533. CGMessage(type_e_mismatch);
  1534. end
  1535. else
  1536. CGMessage1(type_e_class_type_expected,left.resulttype.def.typename);
  1537. { call fpc_do_is helper }
  1538. paras := ccallparanode.create(
  1539. left,
  1540. ccallparanode.create(
  1541. right,nil));
  1542. result := ccallnode.createintern('fpc_do_is',paras);
  1543. left := nil;
  1544. right := nil;
  1545. end
  1546. else
  1547. CGMessage1(type_e_class_or_interface_type_expected,right.resulttype.def.typename);
  1548. resulttype:=booltype;
  1549. end;
  1550. function tisnode.pass_1 : tnode;
  1551. begin
  1552. internalerror(200204254);
  1553. result:=nil;
  1554. end;
  1555. { dummy pass_2, it will never be called, but we need one since }
  1556. { you can't instantiate an abstract class }
  1557. procedure tisnode.pass_2;
  1558. begin
  1559. end;
  1560. {*****************************************************************************
  1561. TASNODE
  1562. *****************************************************************************}
  1563. constructor tasnode.create(l,r : tnode);
  1564. begin
  1565. inherited create(asn,l,r);
  1566. call := nil;
  1567. end;
  1568. destructor tasnode.destroy;
  1569. begin
  1570. call.free;
  1571. inherited destroy;
  1572. end;
  1573. function tasnode.det_resulttype:tnode;
  1574. var
  1575. hp : tnode;
  1576. b : boolean;
  1577. o : tobjectdef;
  1578. begin
  1579. result:=nil;
  1580. resulttypepass(right);
  1581. resulttypepass(left);
  1582. set_varstate(right,true);
  1583. set_varstate(left,true);
  1584. if codegenerror then
  1585. exit;
  1586. if (right.resulttype.def.deftype=classrefdef) then
  1587. begin
  1588. { left must be a class }
  1589. if is_class(left.resulttype.def) then
  1590. begin
  1591. { the operands must be related }
  1592. if (not(tobjectdef(left.resulttype.def).is_related(
  1593. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1594. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1595. tobjectdef(left.resulttype.def)))) then
  1596. CGMessage2(type_e_classes_not_related,left.resulttype.def.typename,
  1597. tclassrefdef(right.resulttype.def).pointertype.def.typename);
  1598. end
  1599. else
  1600. CGMessage1(type_e_class_type_expected,left.resulttype.def.typename);
  1601. resulttype:=tclassrefdef(right.resulttype.def).pointertype;
  1602. end
  1603. else if is_interface(right.resulttype.def) then
  1604. begin
  1605. { left is a class }
  1606. if is_class(left.resulttype.def) then
  1607. begin
  1608. { the operands must be related
  1609. no, because the class instance could be a child class of the current one which
  1610. implements additional interfaces (FK)
  1611. b:=false;
  1612. o:=tobjectdef(left.resulttype.def);
  1613. while assigned(o) do
  1614. begin
  1615. if assigned(o.implementedinterfaces) and
  1616. (o.implementedinterfaces.searchintf(right.resulttype.def)<>-1) then
  1617. begin
  1618. b:=true;
  1619. break;
  1620. end;
  1621. o:=o.childof;
  1622. end;
  1623. if not(b) then
  1624. CGMessage2(type_e_classes_not_related,left.resulttype.def.typename,right.resulttype.def.typename);
  1625. }
  1626. end
  1627. { left is an interface }
  1628. else if is_interface(left.resulttype.def) then
  1629. begin
  1630. { the operands must be related
  1631. we don't necessarily know how the both interfaces are implemented, so we can't do this check (FK)
  1632. if (not(tobjectdef(left.resulttype.def).is_related(tobjectdef(right.resulttype.def)))) and
  1633. (not(tobjectdef(right.resulttype.def).is_related(tobjectdef(left.resulttype.def)))) then
  1634. CGMessage2(type_e_classes_not_related,left.resulttype.def.typename,right.resulttype.def.typename);
  1635. }
  1636. end
  1637. else
  1638. CGMessage1(type_e_class_type_expected,left.resulttype.def.typename);
  1639. resulttype:=right.resulttype;
  1640. { load the GUID of the interface }
  1641. if (right.nodetype=typen) then
  1642. begin
  1643. if assigned(tobjectdef(right.resulttype.def).iidguid) then
  1644. begin
  1645. hp:=cguidconstnode.create(tobjectdef(right.resulttype.def).iidguid^);
  1646. right.free;
  1647. right:=hp;
  1648. end
  1649. else
  1650. internalerror(200206282);
  1651. resulttypepass(right);
  1652. end;
  1653. end
  1654. else
  1655. CGMessage1(type_e_class_or_interface_type_expected,right.resulttype.def.typename);
  1656. end;
  1657. function tasnode.getcopy: tnode;
  1658. begin
  1659. result := inherited getcopy;
  1660. if assigned(call) then
  1661. tasnode(result).call := call.getcopy
  1662. else
  1663. tasnode(result).call := nil;
  1664. end;
  1665. function tasnode.pass_1 : tnode;
  1666. var
  1667. procname: string;
  1668. begin
  1669. result:=nil;
  1670. if not assigned(call) then
  1671. begin
  1672. if is_class(left.resulttype.def) and
  1673. (right.resulttype.def.deftype=classrefdef) then
  1674. call := ccallnode.createinternres('fpc_do_as',
  1675. ccallparanode.create(left,ccallparanode.create(right,nil)),
  1676. resulttype)
  1677. else
  1678. begin
  1679. if is_class(left.resulttype.def) then
  1680. procname := 'fpc_class_as_intf'
  1681. else
  1682. procname := 'fpc_intf_as';
  1683. call := ccallnode.createinternres(procname,
  1684. ccallparanode.create(right,ccallparanode.create(left,nil)),
  1685. resulttype);
  1686. end;
  1687. left := nil;
  1688. right := nil;
  1689. firstpass(call);
  1690. if codegenerror then
  1691. exit;
  1692. location.loc:=call.location.loc;
  1693. registers32:=call.registers32;
  1694. registersfpu:=call.registersfpu;
  1695. {$ifdef SUPPORT_MMX}
  1696. registersmmx:=call.registersmmx;
  1697. {$endif SUPPORT_MMX}
  1698. end;
  1699. end;
  1700. begin
  1701. ctypeconvnode:=ttypeconvnode;
  1702. casnode:=tasnode;
  1703. cisnode:=tisnode;
  1704. end.
  1705. {
  1706. $Log$
  1707. Revision 1.89 2002-11-25 17:43:18 peter
  1708. * splitted defbase in defutil,symutil,defcmp
  1709. * merged isconvertable and is_equal into compare_defs(_ext)
  1710. * made operator search faster by walking the list only once
  1711. Revision 1.88 2002/11/17 16:31:56 carl
  1712. * memory optimization (3-4%) : cleanup of tai fields,
  1713. cleanup of tdef and tsym fields.
  1714. * make it work for m68k
  1715. Revision 1.87 2002/10/10 16:07:57 florian
  1716. + several widestring/pwidechar related stuff added
  1717. Revision 1.86 2002/10/06 16:10:23 florian
  1718. * when compiling <interface> as <interface> we can't assume
  1719. anything about relation
  1720. Revision 1.85 2002/10/05 12:43:25 carl
  1721. * fixes for Delphi 6 compilation
  1722. (warning : Some features do not work under Delphi)
  1723. Revision 1.84 2002/10/02 20:23:50 florian
  1724. - removed the relation check for <class> as <interface> because we don't
  1725. know the runtime type of <class>! It could be a child class of the given type
  1726. which implements additional interfaces
  1727. Revision 1.83 2002/10/02 20:17:14 florian
  1728. + the as operator for <class> as <interface> has to check the parent classes as well
  1729. Revision 1.82 2002/09/30 07:00:47 florian
  1730. * fixes to common code to get the alpha compiler compiled applied
  1731. Revision 1.81 2002/09/16 14:11:13 peter
  1732. * add argument to equal_paras() to support default values or not
  1733. Revision 1.80 2002/09/07 20:40:23 carl
  1734. * cardinal -> longword
  1735. Revision 1.79 2002/09/07 15:25:03 peter
  1736. * old logs removed and tabs fixed
  1737. Revision 1.78 2002/09/07 12:16:04 carl
  1738. * second part bug report 1996 fix, testrange in cordconstnode
  1739. only called if option is set (also make parsing a tiny faster)
  1740. Revision 1.77 2002/09/05 05:56:07 jonas
  1741. - reverted my last commit, it was completely bogus :(
  1742. Revision 1.75 2002/09/02 19:24:42 peter
  1743. * array of char support for Str()
  1744. Revision 1.74 2002/09/01 08:01:16 daniel
  1745. * Removed sets from Tcallnode.det_resulttype
  1746. + Added read/write notifications of variables. These will be usefull
  1747. for providing information for several optimizations. For example
  1748. the value of the loop variable of a for loop does matter is the
  1749. variable is read after the for loop, but if it's no longer used
  1750. or written, it doesn't matter and this can be used to optimize
  1751. the loop code generation.
  1752. Revision 1.73 2002/08/23 16:14:49 peter
  1753. * tempgen cleanup
  1754. * tt_noreuse temp type added that will be used in genentrycode
  1755. Revision 1.72 2002/08/20 18:23:33 jonas
  1756. * the as node again uses a compilerproc
  1757. + (untested) support for interface "as" statements
  1758. Revision 1.71 2002/08/19 19:36:43 peter
  1759. * More fixes for cross unit inlining, all tnodes are now implemented
  1760. * Moved pocall_internconst to po_internconst because it is not a
  1761. calling type at all and it conflicted when inlining of these small
  1762. functions was requested
  1763. Revision 1.70 2002/08/17 09:23:36 florian
  1764. * first part of procinfo rewrite
  1765. Revision 1.69 2002/08/14 19:26:55 carl
  1766. + generic int_to_real type conversion
  1767. + generic unaryminus node
  1768. Revision 1.68 2002/08/11 16:08:55 florian
  1769. + support of explicit type case boolean->char
  1770. Revision 1.67 2002/08/11 15:28:00 florian
  1771. + support of explicit type case <any ordinal type>->pointer
  1772. (delphi mode only)
  1773. Revision 1.66 2002/08/09 07:33:01 florian
  1774. * a couple of interface related fixes
  1775. Revision 1.65 2002/07/29 21:23:42 florian
  1776. * more fixes for the ppc
  1777. + wrappers for the tcnvnode.first_* stuff introduced
  1778. Revision 1.64 2002/07/23 12:34:30 daniel
  1779. * Readded old set code. To use it define 'oldset'. Activated by default
  1780. for ppc.
  1781. Revision 1.63 2002/07/23 09:51:22 daniel
  1782. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  1783. are worth comitting.
  1784. Revision 1.62 2002/07/22 11:48:04 daniel
  1785. * Sets are now internally sets.
  1786. Revision 1.61 2002/07/20 17:16:02 florian
  1787. + source code page support
  1788. Revision 1.60 2002/07/20 11:57:54 florian
  1789. * types.pas renamed to defbase.pas because D6 contains a types
  1790. unit so this would conflicts if D6 programms are compiled
  1791. + Willamette/SSE2 instructions to assembler added
  1792. Revision 1.59 2002/07/01 16:23:53 peter
  1793. * cg64 patch
  1794. * basics for currency
  1795. * asnode updates for class and interface (not finished)
  1796. Revision 1.58 2002/05/18 13:34:09 peter
  1797. * readded missing revisions
  1798. }