defcmp.pas 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Compare definitions and parameter lists
  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 defcmp;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,
  23. cpuinfo,
  24. globtype,globals,tokens,
  25. node,
  26. symconst,symbase,symtype,symdef;
  27. type
  28. { if acp is cp_all the var const or nothing are considered equal }
  29. tcompare_paras_type = ( cp_none, cp_value_equal_const, cp_all,cp_procvar);
  30. tcompare_paras_option = (cpo_allowdefaults,cpo_ignorehidden,cpo_allowconvert,cpo_comparedefaultvalue);
  31. tcompare_paras_options = set of tcompare_paras_option;
  32. tconverttype = (
  33. tc_equal,
  34. tc_not_possible,
  35. tc_string_2_string,
  36. tc_char_2_string,
  37. tc_char_2_chararray,
  38. tc_pchar_2_string,
  39. tc_cchar_2_pchar,
  40. tc_cstring_2_pchar,
  41. tc_ansistring_2_pchar,
  42. tc_string_2_chararray,
  43. tc_chararray_2_string,
  44. tc_array_2_pointer,
  45. tc_pointer_2_array,
  46. tc_int_2_int,
  47. tc_int_2_bool,
  48. tc_bool_2_bool,
  49. tc_bool_2_int,
  50. tc_real_2_real,
  51. tc_int_2_real,
  52. tc_real_2_currency,
  53. tc_proc_2_procvar,
  54. tc_arrayconstructor_2_set,
  55. tc_load_smallset,
  56. tc_cord_2_pointer,
  57. tc_intf_2_string,
  58. tc_intf_2_guid,
  59. tc_class_2_intf,
  60. tc_char_2_char,
  61. tc_normal_2_smallset,
  62. tc_dynarray_2_openarray,
  63. tc_pwchar_2_string,
  64. tc_variant_2_dynarray,
  65. tc_dynarray_2_variant,
  66. tc_variant_2_enum,
  67. tc_enum_2_variant
  68. );
  69. function compare_defs_ext(def_from,def_to : tdef;
  70. fromtreetype : tnodetype;
  71. explicit : boolean;
  72. check_operator : boolean;
  73. var doconv : tconverttype;
  74. var operatorpd : tprocdef):tequaltype;
  75. { Returns if the type def_from can be converted to def_to or if both types are equal }
  76. function compare_defs(def_from,def_to:tdef;fromtreetype:tnodetype):tequaltype;
  77. { Returns true, if def1 and def2 are semantically the same }
  78. function equal_defs(def_from,def_to:tdef):boolean;
  79. { Checks for type compatibility (subgroups of type)
  80. used for case statements... probably missing stuff
  81. to use on other types }
  82. function is_subequal(def1, def2: tdef): boolean;
  83. function assignment_overloaded(from_def,to_def : tdef) : tprocdef;
  84. {# true, if two parameter lists are equal
  85. if acp is cp_none, all have to match exactly
  86. if acp is cp_value_equal_const call by value
  87. and call by const parameter are assumed as
  88. equal
  89. allowdefaults indicates if default value parameters
  90. are allowed (in this case, the search order will first
  91. search for a routine with default parameters, before
  92. searching for the same definition with no parameters)
  93. }
  94. function compare_paras(paralist1,paralist2 : TLinkedList; acp : tcompare_paras_type; cpoptions: tcompare_paras_options):tequaltype;
  95. { True if a function can be assigned to a procvar }
  96. { changed first argument type to pabstractprocdef so that it can also be }
  97. { used to test compatibility between two pprocvardefs (JM) }
  98. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;methoderr:boolean):tequaltype;
  99. implementation
  100. uses
  101. verbose,systems,
  102. symtable,symsym,
  103. defutil,symutil;
  104. function assignment_overloaded(from_def,to_def:tdef):tprocdef;
  105. begin
  106. if assigned(overloaded_operators[_ASSIGNMENT]) then
  107. assignment_overloaded:=overloaded_operators[_ASSIGNMENT].search_procdef_assignment_operator(from_def,to_def)
  108. else
  109. assignment_overloaded:=nil;
  110. end;
  111. function compare_defs_ext(def_from,def_to : tdef;
  112. fromtreetype : tnodetype;
  113. explicit : boolean;
  114. check_operator : boolean;
  115. var doconv : tconverttype;
  116. var operatorpd : tprocdef):tequaltype;
  117. { Tbasetype:
  118. uvoid,
  119. u8bit,u16bit,u32bit,u64bit,
  120. s8bit,s16bit,s32bit,s64bit,
  121. bool8bit,bool16bit,bool32bit,
  122. uchar,uwidechar }
  123. type
  124. tbasedef=(bvoid,bchar,bint,bbool);
  125. const
  126. basedeftbl:array[tbasetype] of tbasedef =
  127. (bvoid,
  128. bint,bint,bint,bint,
  129. bint,bint,bint,bint,
  130. bbool,bbool,bbool,
  131. bchar,bchar,bint);
  132. basedefconvertsimplicit : array[tbasedef,tbasedef] of tconverttype =
  133. { void, char, int, bool }
  134. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  135. (tc_not_possible,tc_char_2_char,tc_not_possible,tc_not_possible),
  136. (tc_not_possible,tc_not_possible,tc_int_2_int,tc_not_possible),
  137. (tc_not_possible,tc_not_possible,tc_not_possible,tc_bool_2_bool));
  138. basedefconvertsexplicit : array[tbasedef,tbasedef] of tconverttype =
  139. { void, char, int, bool }
  140. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  141. (tc_not_possible,tc_char_2_char,tc_int_2_int,tc_int_2_bool),
  142. (tc_not_possible,tc_int_2_int,tc_int_2_int,tc_int_2_bool),
  143. (tc_not_possible,tc_bool_2_int,tc_bool_2_int,tc_bool_2_bool));
  144. var
  145. subeq,eq : tequaltype;
  146. hd1,hd2 : tdef;
  147. hct : tconverttype;
  148. hd3 : tobjectdef;
  149. hpd : tprocdef;
  150. begin
  151. { safety check }
  152. if not(assigned(def_from) and assigned(def_to)) then
  153. begin
  154. compare_defs_ext:=te_incompatible;
  155. exit;
  156. end;
  157. { same def? then we've an exact match }
  158. if def_from=def_to then
  159. begin
  160. compare_defs_ext:=te_exact;
  161. exit;
  162. end;
  163. { we walk the wanted (def_to) types and check then the def_from
  164. types if there is a conversion possible }
  165. eq:=te_incompatible;
  166. doconv:=tc_not_possible;
  167. case def_to.deftype of
  168. orddef :
  169. begin
  170. case def_from.deftype of
  171. orddef :
  172. begin
  173. if (torddef(def_from).typ=torddef(def_to).typ) then
  174. begin
  175. case torddef(def_from).typ of
  176. uchar,uwidechar,
  177. u8bit,u16bit,u32bit,u64bit,
  178. s8bit,s16bit,s32bit,s64bit:
  179. begin
  180. if (torddef(def_from).low=torddef(def_to).low) and
  181. (torddef(def_from).high=torddef(def_to).high) then
  182. eq:=te_equal
  183. else
  184. begin
  185. doconv:=tc_int_2_int;
  186. eq:=te_convert_l1;
  187. end;
  188. end;
  189. uvoid,
  190. bool8bit,bool16bit,bool32bit:
  191. eq:=te_equal;
  192. else
  193. internalerror(200210061);
  194. end;
  195. end
  196. else
  197. begin
  198. if explicit then
  199. doconv:=basedefconvertsexplicit[basedeftbl[torddef(def_from).typ],basedeftbl[torddef(def_to).typ]]
  200. else
  201. doconv:=basedefconvertsimplicit[basedeftbl[torddef(def_from).typ],basedeftbl[torddef(def_to).typ]];
  202. if (doconv=tc_not_possible) then
  203. eq:=te_incompatible
  204. else
  205. { "punish" bad type conversions :) (JM) }
  206. if (not is_in_limit(def_from,def_to)) and
  207. (def_from.size > def_to.size) then
  208. eq:=te_convert_l3
  209. else
  210. eq:=te_convert_l1;
  211. end;
  212. end;
  213. enumdef :
  214. begin
  215. { needed for char(enum) }
  216. if explicit then
  217. begin
  218. doconv:=tc_int_2_int;
  219. eq:=te_convert_l1;
  220. end;
  221. end;
  222. floatdef :
  223. begin
  224. if is_currency(def_to) then
  225. begin
  226. doconv:=tc_real_2_currency;
  227. eq:=te_convert_l2;
  228. end;
  229. end;
  230. classrefdef,
  231. procvardef,
  232. pointerdef :
  233. begin
  234. if explicit then
  235. begin
  236. eq:=te_convert_l1;
  237. if (fromtreetype=niln) then
  238. begin
  239. { will be handled by the constant folding }
  240. doconv:=tc_equal;
  241. end
  242. else
  243. doconv:=tc_int_2_int;
  244. end;
  245. end;
  246. end;
  247. end;
  248. stringdef :
  249. begin
  250. case def_from.deftype of
  251. stringdef :
  252. begin
  253. { Constant string }
  254. if (fromtreetype=stringconstn) then
  255. begin
  256. if (tstringdef(def_from).string_typ=tstringdef(def_to).string_typ) then
  257. eq:=te_equal
  258. else
  259. begin
  260. doconv:=tc_string_2_string;
  261. { Don't prefer conversions from widestring to a
  262. normal string as we can loose information }
  263. if tstringdef(def_from).string_typ=st_widestring then
  264. eq:=te_convert_l1
  265. else
  266. begin
  267. if tstringdef(def_to).string_typ=st_widestring then
  268. eq:=te_convert_l1
  269. else
  270. eq:=te_equal; { we can change the stringconst node }
  271. end;
  272. end;
  273. end
  274. else
  275. { Same string type, for shortstrings also the length must match }
  276. if (tstringdef(def_from).string_typ=tstringdef(def_to).string_typ) and
  277. ((tstringdef(def_from).string_typ<>st_shortstring) or
  278. (tstringdef(def_from).len=tstringdef(def_to).len)) then
  279. eq:=te_equal
  280. else
  281. begin
  282. doconv:=tc_string_2_string;
  283. { Prefer conversions to shortstring over other
  284. conversions. This is compatible with Delphi (PFV) }
  285. if tstringdef(def_to).string_typ=st_shortstring then
  286. eq:=te_convert_l2
  287. else
  288. eq:=te_convert_l3;
  289. end;
  290. end;
  291. orddef :
  292. begin
  293. { char to string}
  294. if is_char(def_from) or
  295. is_widechar(def_from) then
  296. begin
  297. doconv:=tc_char_2_string;
  298. eq:=te_convert_l1;
  299. end;
  300. end;
  301. arraydef :
  302. begin
  303. { array of char to string, the length check is done by the firstpass of this node }
  304. if is_chararray(def_from) or
  305. (is_char(tarraydef(def_from).elementtype.def) and
  306. is_open_array(def_from)) then
  307. begin
  308. doconv:=tc_chararray_2_string;
  309. if is_open_array(def_from) or
  310. (is_shortstring(def_to) and
  311. (def_from.size <= 255)) or
  312. (is_ansistring(def_to) and
  313. (def_from.size > 255)) then
  314. eq:=te_convert_l1
  315. else
  316. eq:=te_convert_l2;
  317. end;
  318. end;
  319. pointerdef :
  320. begin
  321. { pchar can be assigned to short/ansistrings,
  322. but not in tp7 compatible mode }
  323. if not(m_tp7 in aktmodeswitches) then
  324. begin
  325. if is_pchar(def_from) then
  326. begin
  327. doconv:=tc_pchar_2_string;
  328. { prefer ansistrings because pchars can overflow shortstrings, }
  329. { but only if ansistrings are the default (JM) }
  330. if (is_shortstring(def_to) and
  331. not(cs_ansistrings in aktlocalswitches)) or
  332. (is_ansistring(def_to) and
  333. (cs_ansistrings in aktlocalswitches)) then
  334. eq:=te_convert_l1
  335. else
  336. eq:=te_convert_l2;
  337. end
  338. else if is_pwidechar(def_from) then
  339. begin
  340. doconv:=tc_pwchar_2_string;
  341. { prefer ansistrings because pchars can overflow shortstrings, }
  342. { but only if ansistrings are the default (JM) }
  343. if is_widestring(def_to) then
  344. eq:=te_convert_l1
  345. else
  346. eq:=te_convert_l3;
  347. end;
  348. end;
  349. end;
  350. end;
  351. end;
  352. floatdef :
  353. begin
  354. case def_from.deftype of
  355. orddef :
  356. begin { ordinal to real }
  357. if is_integer(def_from) or
  358. (is_currency(def_from) and
  359. (s64currencytype.def.deftype = floatdef)) then
  360. begin
  361. doconv:=tc_int_2_real;
  362. eq:=te_convert_l1;
  363. end
  364. else if is_currency(def_from)
  365. { and (s64currencytype.def.deftype = orddef)) } then
  366. begin
  367. { prefer conversion to orddef in this case, unless }
  368. { the orddef < currency (then it will get convert l3, }
  369. { and conversion to float is favoured) }
  370. doconv:=tc_int_2_real;
  371. eq:=te_convert_l2;
  372. end;
  373. end;
  374. floatdef :
  375. begin
  376. if tfloatdef(def_from).typ=tfloatdef(def_to).typ then
  377. eq:=te_equal
  378. else
  379. begin
  380. if not(explicit) or
  381. not(m_delphi in aktmodeswitches) then
  382. begin
  383. doconv:=tc_real_2_real;
  384. { do we loose precision? }
  385. if def_to.size<def_from.size then
  386. eq:=te_convert_l2
  387. else
  388. eq:=te_convert_l1;
  389. end;
  390. end;
  391. end;
  392. end;
  393. end;
  394. enumdef :
  395. begin
  396. case def_from.deftype of
  397. enumdef :
  398. begin
  399. if explicit then
  400. begin
  401. eq:=te_convert_l1;
  402. doconv:=tc_int_2_int;
  403. end
  404. else
  405. begin
  406. hd1:=def_from;
  407. while assigned(tenumdef(hd1).basedef) do
  408. hd1:=tenumdef(hd1).basedef;
  409. hd2:=def_to;
  410. while assigned(tenumdef(hd2).basedef) do
  411. hd2:=tenumdef(hd2).basedef;
  412. if (hd1=hd2) then
  413. begin
  414. eq:=te_convert_l1;
  415. { because of packenum they can have different sizes! (JM) }
  416. doconv:=tc_int_2_int;
  417. end;
  418. end;
  419. end;
  420. orddef :
  421. begin
  422. if explicit then
  423. begin
  424. eq:=te_convert_l1;
  425. doconv:=tc_int_2_int;
  426. end;
  427. end;
  428. variantdef :
  429. begin
  430. eq:=te_convert_l1;
  431. doconv:=tc_variant_2_enum;
  432. end;
  433. end;
  434. end;
  435. arraydef :
  436. begin
  437. { open array is also compatible with a single element of its base type }
  438. if is_open_array(def_to) and
  439. equal_defs(def_from,tarraydef(def_to).elementtype.def) then
  440. begin
  441. doconv:=tc_equal;
  442. eq:=te_convert_l1;
  443. end
  444. else
  445. begin
  446. case def_from.deftype of
  447. arraydef :
  448. begin
  449. { to dynamic array }
  450. if is_dynamic_array(def_to) then
  451. begin
  452. { dynamic array -> dynamic array }
  453. if is_dynamic_array(def_from) and
  454. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  455. eq:=te_equal;
  456. end
  457. else
  458. { to open array }
  459. if is_open_array(def_to) then
  460. begin
  461. { array constructor -> open array }
  462. if is_array_constructor(def_from) then
  463. begin
  464. if is_void(tarraydef(def_from).elementtype.def) then
  465. begin
  466. doconv:=tc_equal;
  467. eq:=te_convert_l1;
  468. end
  469. else
  470. begin
  471. subeq:=compare_defs_ext(tarraydef(def_from).elementtype.def,
  472. tarraydef(def_to).elementtype.def,
  473. arrayconstructorn,false,true,hct,hpd);
  474. if (subeq>=te_equal) then
  475. begin
  476. doconv:=tc_equal;
  477. eq:=te_convert_l1;
  478. end
  479. else
  480. if (subeq>te_incompatible) then
  481. begin
  482. doconv:=hct;
  483. eq:=te_convert_l2;
  484. end;
  485. end;
  486. end
  487. else
  488. { dynamic array -> open array }
  489. if is_dynamic_array(def_from) and
  490. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  491. begin
  492. doconv:=tc_dynarray_2_openarray;
  493. eq:=te_convert_l2;
  494. end
  495. else
  496. { array -> open array }
  497. if equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  498. eq:=te_equal;
  499. end
  500. else
  501. { to array of const }
  502. if is_array_of_const(def_to) then
  503. begin
  504. if is_array_of_const(def_from) or
  505. is_array_constructor(def_from) then
  506. begin
  507. eq:=te_equal;
  508. end
  509. else
  510. { array of tvarrec -> array of const }
  511. if equal_defs(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  512. begin
  513. doconv:=tc_equal;
  514. eq:=te_convert_l1;
  515. end;
  516. end
  517. else
  518. { other arrays }
  519. begin
  520. { open array -> array }
  521. if is_open_array(def_from) and
  522. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  523. begin
  524. eq:=te_equal
  525. end
  526. else
  527. { array -> array }
  528. if not(m_tp7 in aktmodeswitches) and
  529. not(m_delphi in aktmodeswitches) and
  530. (tarraydef(def_from).lowrange=tarraydef(def_to).lowrange) and
  531. (tarraydef(def_from).highrange=tarraydef(def_to).highrange) and
  532. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) and
  533. equal_defs(tarraydef(def_from).rangetype.def,tarraydef(def_to).rangetype.def) then
  534. begin
  535. eq:=te_equal
  536. end;
  537. end;
  538. end;
  539. pointerdef :
  540. begin
  541. { nil is compatible with dyn. arrays }
  542. if is_dynamic_array(def_to) and
  543. (fromtreetype=niln) then
  544. begin
  545. doconv:=tc_equal;
  546. eq:=te_convert_l1;
  547. end
  548. else
  549. if is_zero_based_array(def_to) and
  550. equal_defs(tpointerdef(def_from).pointertype.def,tarraydef(def_to).elementtype.def) then
  551. begin
  552. doconv:=tc_pointer_2_array;
  553. eq:=te_convert_l1;
  554. end;
  555. end;
  556. stringdef :
  557. begin
  558. { string to char array }
  559. if (not is_special_array(def_to)) and
  560. is_char(tarraydef(def_to).elementtype.def) then
  561. begin
  562. doconv:=tc_string_2_chararray;
  563. eq:=te_convert_l1;
  564. end;
  565. end;
  566. orddef:
  567. begin
  568. if is_chararray(def_to) and
  569. is_char(def_from) then
  570. begin
  571. doconv:=tc_char_2_chararray;
  572. eq:=te_convert_l2;
  573. end;
  574. end;
  575. recorddef :
  576. begin
  577. { tvarrec -> array of const }
  578. if is_array_of_const(def_to) and
  579. equal_defs(def_from,tarraydef(def_to).elementtype.def) then
  580. begin
  581. doconv:=tc_equal;
  582. eq:=te_convert_l1;
  583. end;
  584. end;
  585. variantdef :
  586. begin
  587. if is_dynamic_array(def_to) then
  588. begin
  589. doconv:=tc_variant_2_dynarray;
  590. eq:=te_convert_l1;
  591. end;
  592. end;
  593. end;
  594. end;
  595. end;
  596. variantdef :
  597. begin
  598. case def_from.deftype of
  599. enumdef :
  600. begin
  601. doconv:=tc_enum_2_variant;
  602. eq:=te_convert_l1;
  603. end;
  604. arraydef :
  605. begin
  606. if is_dynamic_array(def_from) then
  607. begin
  608. doconv:=tc_dynarray_2_variant;
  609. eq:=te_convert_l1;
  610. end;
  611. end;
  612. end;
  613. end;
  614. pointerdef :
  615. begin
  616. case def_from.deftype of
  617. stringdef :
  618. begin
  619. { string constant (which can be part of array constructor)
  620. to zero terminated string constant }
  621. if (fromtreetype in [arrayconstructorn,stringconstn]) and
  622. (is_pchar(def_to) or is_pwidechar(def_to)) then
  623. begin
  624. doconv:=tc_cstring_2_pchar;
  625. eq:=te_convert_l1;
  626. end
  627. else
  628. if explicit then
  629. begin
  630. { pchar(ansistring) }
  631. if is_pchar(def_to) and
  632. is_ansistring(def_from) then
  633. begin
  634. doconv:=tc_ansistring_2_pchar;
  635. eq:=te_convert_l1;
  636. end
  637. else
  638. { pwidechar(ansistring) }
  639. if is_pwidechar(def_to) and
  640. is_widestring(def_from) then
  641. begin
  642. doconv:=tc_ansistring_2_pchar;
  643. eq:=te_convert_l1;
  644. end;
  645. end;
  646. end;
  647. orddef :
  648. begin
  649. { char constant to zero terminated string constant }
  650. if (fromtreetype=ordconstn) then
  651. begin
  652. if is_char(def_from) and
  653. is_pchar(def_to) then
  654. begin
  655. doconv:=tc_cchar_2_pchar;
  656. eq:=te_convert_l1;
  657. end
  658. else
  659. if (m_delphi in aktmodeswitches) and is_integer(def_from) then
  660. begin
  661. doconv:=tc_cord_2_pointer;
  662. eq:=te_convert_l1;
  663. end;
  664. end;
  665. if (eq=te_incompatible) and explicit then
  666. begin
  667. doconv:=tc_int_2_int;
  668. eq:=te_convert_l1;
  669. end;
  670. end;
  671. arraydef :
  672. begin
  673. { chararray to pointer }
  674. if is_zero_based_array(def_from) and
  675. equal_defs(tarraydef(def_from).elementtype.def,tpointerdef(def_to).pointertype.def) then
  676. begin
  677. doconv:=tc_array_2_pointer;
  678. eq:=te_convert_l1;
  679. end;
  680. end;
  681. pointerdef :
  682. begin
  683. { check for far pointers }
  684. if (tpointerdef(def_from).is_far<>tpointerdef(def_to).is_far) then
  685. begin
  686. eq:=te_incompatible;
  687. end
  688. else
  689. { the types can be forward type, handle before normal type check !! }
  690. if assigned(def_to.typesym) and
  691. (tpointerdef(def_to).pointertype.def.deftype=forwarddef) then
  692. begin
  693. if (def_from.typesym=def_to.typesym) then
  694. eq:=te_equal
  695. end
  696. else
  697. { same types }
  698. if (tpointerdef(def_from).pointertype.def=tpointerdef(def_to).pointertype.def) then
  699. begin
  700. eq:=te_equal
  701. end
  702. else
  703. { child class pointer can be assigned to anchestor pointers }
  704. if (
  705. (tpointerdef(def_from).pointertype.def.deftype=objectdef) and
  706. (tpointerdef(def_to).pointertype.def.deftype=objectdef) and
  707. tobjectdef(tpointerdef(def_from).pointertype.def).is_related(
  708. tobjectdef(tpointerdef(def_to).pointertype.def))
  709. ) or
  710. { all pointers can be assigned to/from void-pointer }
  711. is_void(tpointerdef(def_to).pointertype.def) or
  712. is_void(tpointerdef(def_from).pointertype.def) then
  713. begin
  714. doconv:=tc_equal;
  715. { give pwidechar a penalty }
  716. if is_pwidechar(def_to) then
  717. eq:=te_convert_l2
  718. else
  719. eq:=te_convert_l1;
  720. end;
  721. end;
  722. procvardef :
  723. begin
  724. { procedure variable can be assigned to an void pointer }
  725. { Not anymore. Use the @ operator now.}
  726. if not(m_tp_procvar in aktmodeswitches) and
  727. { method pointers can't be assigned to void pointers
  728. not(tprocvardef(def_from).is_methodpointer) and }
  729. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  730. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  731. begin
  732. doconv:=tc_equal;
  733. eq:=te_convert_l1;
  734. end;
  735. end;
  736. classrefdef,
  737. objectdef :
  738. begin
  739. { class types and class reference type
  740. can be assigned to void pointers }
  741. if (
  742. is_class_or_interface(def_from) or
  743. (def_from.deftype=classrefdef)
  744. ) and
  745. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  746. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  747. begin
  748. doconv:=tc_equal;
  749. eq:=te_convert_l1;
  750. end;
  751. end;
  752. end;
  753. end;
  754. setdef :
  755. begin
  756. case def_from.deftype of
  757. setdef :
  758. begin
  759. if assigned(tsetdef(def_from).elementtype.def) and
  760. assigned(tsetdef(def_to).elementtype.def) then
  761. begin
  762. { sets with the same element base type are equal }
  763. if is_subequal(tsetdef(def_from).elementtype.def,tsetdef(def_to).elementtype.def) then
  764. eq:=te_equal;
  765. end
  766. else
  767. { empty set is compatible with everything }
  768. eq:=te_equal;
  769. end;
  770. arraydef :
  771. begin
  772. { automatic arrayconstructor -> set conversion }
  773. if is_array_constructor(def_from) then
  774. begin
  775. doconv:=tc_arrayconstructor_2_set;
  776. eq:=te_convert_l1;
  777. end;
  778. end;
  779. end;
  780. end;
  781. procvardef :
  782. begin
  783. case def_from.deftype of
  784. procdef :
  785. begin
  786. { proc -> procvar }
  787. if (m_tp_procvar in aktmodeswitches) then
  788. begin
  789. subeq:=proc_to_procvar_equal(tprocdef(def_from),tprocvardef(def_to),true);
  790. if subeq>te_incompatible then
  791. begin
  792. doconv:=tc_proc_2_procvar;
  793. eq:=te_convert_l1;
  794. end;
  795. end;
  796. end;
  797. procvardef :
  798. begin
  799. { procvar -> procvar }
  800. eq:=proc_to_procvar_equal(tprocvardef(def_from),tprocvardef(def_to),false);
  801. end;
  802. pointerdef :
  803. begin
  804. { nil is compatible with procvars }
  805. if (fromtreetype=niln) then
  806. begin
  807. doconv:=tc_equal;
  808. eq:=te_convert_l1;
  809. end
  810. else
  811. { for example delphi allows the assignement from pointers }
  812. { to procedure variables }
  813. if (m_pointer_2_procedure in aktmodeswitches) and
  814. (tpointerdef(def_from).pointertype.def.deftype=orddef) and
  815. (torddef(tpointerdef(def_from).pointertype.def).typ=uvoid) then
  816. begin
  817. doconv:=tc_equal;
  818. eq:=te_convert_l1;
  819. end;
  820. end;
  821. end;
  822. end;
  823. objectdef :
  824. begin
  825. { object pascal objects }
  826. if (def_from.deftype=objectdef) and
  827. (tobjectdef(def_from).is_related(tobjectdef(def_to))) then
  828. begin
  829. doconv:=tc_equal;
  830. eq:=te_convert_l1;
  831. end
  832. else
  833. { Class/interface specific }
  834. if is_class_or_interface(def_to) then
  835. begin
  836. { void pointer also for delphi mode }
  837. if (m_delphi in aktmodeswitches) and
  838. is_voidpointer(def_from) then
  839. begin
  840. doconv:=tc_equal;
  841. { prefer pointer-pointer assignments }
  842. eq:=te_convert_l2;
  843. end
  844. else
  845. { nil is compatible with class instances and interfaces }
  846. if (fromtreetype=niln) then
  847. begin
  848. doconv:=tc_equal;
  849. eq:=te_convert_l1;
  850. end
  851. { classes can be assigned to interfaces }
  852. else if is_interface(def_to) and
  853. is_class(def_from) and
  854. assigned(tobjectdef(def_from).implementedinterfaces) then
  855. begin
  856. { we've to search in parent classes as well }
  857. hd3:=tobjectdef(def_from);
  858. while assigned(hd3) do
  859. begin
  860. if hd3.implementedinterfaces.searchintf(def_to)<>-1 then
  861. begin
  862. doconv:=tc_class_2_intf;
  863. eq:=te_convert_l1;
  864. break;
  865. end;
  866. hd3:=hd3.childof;
  867. end;
  868. end
  869. { Interface 2 GUID handling }
  870. else if (def_to=tdef(rec_tguid)) and
  871. (fromtreetype=typen) and
  872. is_interface(def_from) and
  873. assigned(tobjectdef(def_from).iidguid) then
  874. begin
  875. eq:=te_convert_l1;
  876. doconv:=tc_equal;
  877. end;
  878. end;
  879. end;
  880. classrefdef :
  881. begin
  882. { similar to pointerdef wrt forwards }
  883. if assigned(def_to.typesym) and
  884. (tclassrefdef(def_to).pointertype.def.deftype=forwarddef) then
  885. begin
  886. if (def_from.typesym=def_to.typesym) then
  887. eq:=te_equal;
  888. end
  889. else
  890. { class reference types }
  891. if (def_from.deftype=classrefdef) then
  892. begin
  893. if equal_defs(tclassrefdef(def_from).pointertype.def,tclassrefdef(def_to).pointertype.def) then
  894. begin
  895. eq:=te_equal;
  896. end
  897. else
  898. begin
  899. doconv:=tc_equal;
  900. if explicit or
  901. tobjectdef(tclassrefdef(def_from).pointertype.def).is_related(
  902. tobjectdef(tclassrefdef(def_to).pointertype.def)) then
  903. eq:=te_convert_l1;
  904. end;
  905. end
  906. else
  907. { nil is compatible with class references }
  908. if (fromtreetype=niln) then
  909. begin
  910. doconv:=tc_equal;
  911. eq:=te_convert_l1;
  912. end;
  913. end;
  914. filedef :
  915. begin
  916. { typed files are all equal to the abstract file type
  917. name TYPEDFILE in system.pp in is_equal in types.pas
  918. the problem is that it sholud be also compatible to FILE
  919. but this would leed to a problem for ASSIGN RESET and REWRITE
  920. when trying to find the good overloaded function !!
  921. so all file function are doubled in system.pp
  922. this is not very beautiful !!}
  923. if (def_from.deftype=filedef) then
  924. begin
  925. if (tfiledef(def_from).filetyp=tfiledef(def_to).filetyp) then
  926. begin
  927. if
  928. (
  929. (tfiledef(def_from).typedfiletype.def=nil) and
  930. (tfiledef(def_to).typedfiletype.def=nil)
  931. ) or
  932. (
  933. (tfiledef(def_from).typedfiletype.def<>nil) and
  934. (tfiledef(def_to).typedfiletype.def<>nil) and
  935. equal_defs(tfiledef(def_from).typedfiletype.def,tfiledef(def_to).typedfiletype.def)
  936. ) or
  937. (
  938. (tfiledef(def_from).filetyp = ft_typed) and
  939. (tfiledef(def_to).filetyp = ft_typed) and
  940. (
  941. (tfiledef(def_from).typedfiletype.def = tdef(voidtype.def)) or
  942. (tfiledef(def_to).typedfiletype.def = tdef(voidtype.def))
  943. )
  944. ) then
  945. begin
  946. eq:=te_equal;
  947. end;
  948. end
  949. else
  950. if ((tfiledef(def_from).filetyp = ft_untyped) and
  951. (tfiledef(def_to).filetyp = ft_typed)) or
  952. ((tfiledef(def_from).filetyp = ft_typed) and
  953. (tfiledef(def_to).filetyp = ft_untyped)) then
  954. begin
  955. doconv:=tc_equal;
  956. eq:=te_convert_l1;
  957. end;
  958. end;
  959. end;
  960. recorddef :
  961. begin
  962. { interface -> guid }
  963. if is_interface(def_from) and
  964. (def_to=rec_tguid) then
  965. begin
  966. doconv:=tc_intf_2_guid;
  967. eq:=te_convert_l1;
  968. end;
  969. end;
  970. formaldef :
  971. begin
  972. doconv:=tc_equal;
  973. if (def_from.deftype=formaldef) then
  974. eq:=te_equal
  975. else
  976. { Just about everything can be converted to a formaldef...}
  977. if not (def_from.deftype in [abstractdef,errordef]) then
  978. eq:=te_convert_l1;
  979. end;
  980. end;
  981. { if we didn't find an appropriate type conversion yet
  982. then we search also the := operator }
  983. if (eq=te_incompatible) and
  984. check_operator and
  985. ((def_from.deftype in [objectdef,recorddef,arraydef,stringdef,variantdef]) or
  986. (def_to.deftype in [objectdef,recorddef,arraydef,stringdef,variantdef])) then
  987. begin
  988. operatorpd:=assignment_overloaded(def_from,def_to);
  989. if assigned(operatorpd) then
  990. eq:=te_convert_operator;
  991. end;
  992. { update convtype for te_equal when it is not yet set }
  993. if (eq=te_equal) and
  994. (doconv=tc_not_possible) then
  995. doconv:=tc_equal;
  996. compare_defs_ext:=eq;
  997. end;
  998. function equal_defs(def_from,def_to:tdef):boolean;
  999. var
  1000. convtyp : tconverttype;
  1001. pd : tprocdef;
  1002. begin
  1003. { Compare defs with nothingn and no explicit typecasts and
  1004. searching for overloaded operators is not needed }
  1005. equal_defs:=(compare_defs_ext(def_from,def_to,nothingn,false,false,convtyp,pd)>=te_equal);
  1006. end;
  1007. function compare_defs(def_from,def_to:tdef;fromtreetype:tnodetype):tequaltype;
  1008. var
  1009. doconv : tconverttype;
  1010. pd : tprocdef;
  1011. begin
  1012. compare_defs:=compare_defs_ext(def_from,def_to,fromtreetype,false,true,doconv,pd);
  1013. end;
  1014. function is_subequal(def1, def2: tdef): boolean;
  1015. var
  1016. basedef1,basedef2 : tenumdef;
  1017. Begin
  1018. is_subequal := false;
  1019. if assigned(def1) and assigned(def2) then
  1020. Begin
  1021. if (def1.deftype = orddef) and (def2.deftype = orddef) then
  1022. Begin
  1023. { see p.47 of Turbo Pascal 7.01 manual for the separation of types }
  1024. { range checking for case statements is done with testrange }
  1025. case torddef(def1).typ of
  1026. u8bit,u16bit,u32bit,u64bit,
  1027. s8bit,s16bit,s32bit,s64bit :
  1028. is_subequal:=(torddef(def2).typ in [s64bit,u64bit,s32bit,u32bit,u8bit,s8bit,s16bit,u16bit]);
  1029. bool8bit,bool16bit,bool32bit :
  1030. is_subequal:=(torddef(def2).typ in [bool8bit,bool16bit,bool32bit]);
  1031. uchar :
  1032. is_subequal:=(torddef(def2).typ=uchar);
  1033. uwidechar :
  1034. is_subequal:=(torddef(def2).typ=uwidechar);
  1035. end;
  1036. end
  1037. else
  1038. Begin
  1039. { Check if both basedefs are equal }
  1040. if (def1.deftype=enumdef) and (def2.deftype=enumdef) then
  1041. Begin
  1042. { get both basedefs }
  1043. basedef1:=tenumdef(def1);
  1044. while assigned(basedef1.basedef) do
  1045. basedef1:=basedef1.basedef;
  1046. basedef2:=tenumdef(def2);
  1047. while assigned(basedef2.basedef) do
  1048. basedef2:=basedef2.basedef;
  1049. is_subequal:=(basedef1=basedef2);
  1050. end;
  1051. end;
  1052. end;
  1053. end;
  1054. function compare_paras(paralist1,paralist2 : TLinkedList; acp : tcompare_paras_type; cpoptions: tcompare_paras_options):tequaltype;
  1055. var
  1056. currpara1,
  1057. currpara2 : TParaItem;
  1058. eq,lowesteq : tequaltype;
  1059. hpd : tprocdef;
  1060. convtype : tconverttype;
  1061. begin
  1062. compare_paras:=te_incompatible;
  1063. { we need to parse the list from left-right so the
  1064. not-default parameters are checked first }
  1065. lowesteq:=high(tequaltype);
  1066. currpara1:=TParaItem(paralist1.first);
  1067. currpara2:=TParaItem(paralist2.first);
  1068. if cpo_ignorehidden in cpoptions then
  1069. begin
  1070. while assigned(currpara1) and currpara1.is_hidden do
  1071. currpara1:=tparaitem(currpara1.next);
  1072. while assigned(currpara2) and currpara2.is_hidden do
  1073. currpara2:=tparaitem(currpara2.next);
  1074. end;
  1075. while (assigned(currpara1)) and (assigned(currpara2)) do
  1076. begin
  1077. eq:=te_incompatible;
  1078. { Unique types must match exact }
  1079. if ((df_unique in currpara1.paratype.def.defoptions) or (df_unique in currpara2.paratype.def.defoptions)) and
  1080. (currpara1.paratype.def<>currpara2.paratype.def) then
  1081. exit;
  1082. { Handle hidden parameters separately, because self is
  1083. defined as voidpointer for methodpointers }
  1084. if (currpara1.is_hidden or
  1085. currpara2.is_hidden) then
  1086. begin
  1087. { both must be hidden }
  1088. if currpara1.is_hidden<>currpara2.is_hidden then
  1089. exit;
  1090. eq:=te_equal;
  1091. if not(vo_is_self in tvarsym(currpara1.parasym).varoptions) and
  1092. not(vo_is_self in tvarsym(currpara2.parasym).varoptions) then
  1093. begin
  1094. if (currpara1.paratyp<>currpara2.paratyp) then
  1095. exit;
  1096. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1097. end;
  1098. end
  1099. else
  1100. begin
  1101. case acp of
  1102. cp_value_equal_const :
  1103. begin
  1104. if (
  1105. (currpara1.paratyp<>currpara2.paratyp) and
  1106. ((currpara1.paratyp in [vs_var,vs_out]) or
  1107. (currpara2.paratyp in [vs_var,vs_out]))
  1108. ) then
  1109. exit;
  1110. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1111. end;
  1112. cp_all :
  1113. begin
  1114. if (currpara1.paratyp<>currpara2.paratyp) then
  1115. exit;
  1116. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1117. end;
  1118. cp_procvar :
  1119. begin
  1120. if (currpara1.paratyp<>currpara2.paratyp) then
  1121. exit;
  1122. eq:=compare_defs_ext(currpara1.paratype.def,currpara2.paratype.def,nothingn,
  1123. false,true,convtype,hpd);
  1124. if (eq>te_incompatible) and
  1125. (eq<te_equal) and
  1126. not(
  1127. (convtype in [tc_equal,tc_int_2_int]) and
  1128. (currpara1.paratype.def.size=currpara2.paratype.def.size)
  1129. ) then
  1130. begin
  1131. eq:=te_incompatible;
  1132. end;
  1133. end;
  1134. else
  1135. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1136. end;
  1137. end;
  1138. { check type }
  1139. if eq=te_incompatible then
  1140. exit;
  1141. if eq<lowesteq then
  1142. lowesteq:=eq;
  1143. { also check default value if both have it declared }
  1144. if (cpo_comparedefaultvalue in cpoptions) and
  1145. assigned(currpara1.defaultvalue) and
  1146. assigned(currpara2.defaultvalue) then
  1147. begin
  1148. if not equal_constsym(tconstsym(currpara1.defaultvalue),tconstsym(currpara2.defaultvalue)) then
  1149. exit;
  1150. end;
  1151. currpara1:=TParaItem(currpara1.next);
  1152. currpara2:=TParaItem(currpara2.next);
  1153. if cpo_ignorehidden in cpoptions then
  1154. begin
  1155. while assigned(currpara1) and currpara1.is_hidden do
  1156. currpara1:=tparaitem(currpara1.next);
  1157. while assigned(currpara2) and currpara2.is_hidden do
  1158. currpara2:=tparaitem(currpara2.next);
  1159. end;
  1160. end;
  1161. { when both lists are empty then the parameters are equal. Also
  1162. when one list is empty and the other has a parameter with default
  1163. value assigned then the parameters are also equal }
  1164. if ((currpara1=nil) and (currpara2=nil)) or
  1165. ((cpo_allowdefaults in cpoptions) and
  1166. ((assigned(currpara1) and assigned(currpara1.defaultvalue)) or
  1167. (assigned(currpara2) and assigned(currpara2.defaultvalue)))) then
  1168. compare_paras:=lowesteq;
  1169. end;
  1170. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;methoderr:boolean):tequaltype;
  1171. var
  1172. eq : tequaltype;
  1173. po_comp : tprocoptions;
  1174. begin
  1175. proc_to_procvar_equal:=te_incompatible;
  1176. if not(assigned(def1)) or not(assigned(def2)) then
  1177. exit;
  1178. { check for method pointer }
  1179. if (def1.is_methodpointer xor def2.is_methodpointer) or
  1180. (def1.is_addressonly xor def2.is_addressonly) then
  1181. begin
  1182. if methoderr then
  1183. Message(type_e_no_method_and_procedure_not_compatible);
  1184. exit;
  1185. end;
  1186. { check return value and options, methodpointer is already checked }
  1187. po_comp:=[po_staticmethod,po_interrupt,
  1188. po_iocheck,po_varargs];
  1189. if (m_delphi in aktmodeswitches) then
  1190. exclude(po_comp,po_varargs);
  1191. if ((po_comp * def1.procoptions)= (po_comp * def2.procoptions)) and
  1192. equal_defs(def1.rettype.def,def2.rettype.def) then
  1193. begin
  1194. { return equal type based on the parameters, but a proc->procvar
  1195. is never exact, so map an exact match of the parameters to
  1196. te_equal }
  1197. eq:=compare_paras(def1.para,def2.para,cp_procvar,[]);
  1198. if eq=te_exact then
  1199. eq:=te_equal;
  1200. proc_to_procvar_equal:=eq;
  1201. end;
  1202. end;
  1203. end.
  1204. {
  1205. $Log$
  1206. Revision 1.42 2004-01-14 21:44:16 peter
  1207. * give penalty in float-float conversion when precision is lost
  1208. Revision 1.41 2004/01/06 02:17:44 florian
  1209. * fixed webbug 2878
  1210. Revision 1.40 2004/01/02 17:19:04 jonas
  1211. * if currency = int64, FPC_CURRENCY_IS_INT64 is defined
  1212. + round and trunc for currency and comp if FPC_CURRENCY_IS_INT64 is
  1213. defined
  1214. * if currency = orddef, prefer currency -> int64/qword conversion over
  1215. currency -> float conversions
  1216. * optimized currency/currency if currency = orddef
  1217. * TODO: write FPC_DIV_CURRENCY and FPC_MUL_CURRENCY routines to prevent
  1218. precision loss if currency=int64 and bestreal = double
  1219. Revision 1.39 2003/12/16 09:41:44 daniel
  1220. * Automatic conversion from integer constants to pointer constants is no
  1221. longer done except in Delphi mode
  1222. Revision 1.38 2003/11/26 15:11:42 michael
  1223. + Patch to prefer getpropinfo(ptypeinfo,name) over getpropinfo(tobject,name) when called with getpropinfo(aclass.classinfo) from Peter
  1224. Revision 1.37 2003/11/10 19:09:29 peter
  1225. * procvar default value support
  1226. Revision 1.36 2003/11/04 22:30:15 florian
  1227. + type cast variant<->enum
  1228. * cnv. node second pass uses now as well helper wrappers
  1229. Revision 1.35 2003/10/30 16:23:13 peter
  1230. * don't search for overloads in parents for constructors
  1231. Revision 1.34 2003/10/26 14:11:35 florian
  1232. * fixed web bug 2129: explicit float casts in Delphi mode must be handled by the default code
  1233. Revision 1.33 2003/10/14 12:23:06 florian
  1234. * fixed 2729: overloading problem with methodvars and procvars
  1235. Revision 1.32 2003/10/10 17:48:13 peter
  1236. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1237. * tregisteralloctor renamed to trgobj
  1238. * removed rgobj from a lot of units
  1239. * moved location_* and reference_* to cgobj
  1240. * first things for mmx register allocation
  1241. Revision 1.31 2003/10/07 21:14:32 peter
  1242. * compare_paras() has a parameter to ignore hidden parameters
  1243. * cross unit overload searching ignores hidden parameters when
  1244. comparing parameter lists. Now function(string):string is
  1245. not overriden with procedure(string) which has the same visible
  1246. parameter list
  1247. Revision 1.30 2003/10/05 13:05:05 peter
  1248. * when comparing hidden parameters both must be hidden
  1249. Revision 1.29 2003/10/05 12:57:11 peter
  1250. * set correct conversion for subranges
  1251. Revision 1.28 2003/09/09 21:03:17 peter
  1252. * basics for x86 register calling
  1253. Revision 1.27 2003/06/03 21:02:08 peter
  1254. * allow pointer(int64) in all modes
  1255. Revision 1.26 2003/05/26 21:17:17 peter
  1256. * procinlinenode removed
  1257. * aktexit2label removed, fast exit removed
  1258. + tcallnode.inlined_pass_2 added
  1259. Revision 1.25 2003/05/15 18:58:53 peter
  1260. * removed selfpointer_offset, vmtpointer_offset
  1261. * tvarsym.adjusted_address
  1262. * address in localsymtable is now in the real direction
  1263. * removed some obsolete globals
  1264. Revision 1.24 2003/05/09 17:47:02 peter
  1265. * self moved to hidden parameter
  1266. * removed hdisposen,hnewn,selfn
  1267. Revision 1.23 2003/04/23 20:16:04 peter
  1268. + added currency support based on int64
  1269. + is_64bit for use in cg units instead of is_64bitint
  1270. * removed cgmessage from n386add, replace with internalerrors
  1271. Revision 1.22 2003/04/23 11:37:33 peter
  1272. * po_comp for proc to procvar fixed
  1273. Revision 1.21 2003/04/10 17:57:52 peter
  1274. * vs_hidden released
  1275. Revision 1.20 2003/03/20 17:52:18 peter
  1276. * fix compare for unique types, they are allowed when they match
  1277. exact
  1278. Revision 1.19 2003/01/16 22:13:51 peter
  1279. * convert_l3 convertlevel added. This level is used for conversions
  1280. where information can be lost like converting widestring->ansistring
  1281. or dword->byte
  1282. Revision 1.18 2003/01/15 01:44:32 peter
  1283. * merged methodpointer fixes from 1.0.x
  1284. Revision 1.17 2003/01/09 21:43:39 peter
  1285. * constant string conversion fixed, it's now equal to both
  1286. shortstring, ansistring and the typeconvnode will return
  1287. te_equal but still return convtype to change the constnode
  1288. Revision 1.16 2003/01/05 22:42:13 peter
  1289. * use int_to_int conversion for pointer/procvar/classref to int
  1290. Revision 1.15 2003/01/05 15:54:15 florian
  1291. + added proper support of type = type <type>; for simple types
  1292. Revision 1.14 2003/01/03 17:16:04 peter
  1293. * fixed assignment operator checking for typecast
  1294. Revision 1.13 2002/12/29 18:15:19 peter
  1295. * varargs is not checked in proc->procvar for delphi
  1296. Revision 1.12 2002/12/29 14:57:50 peter
  1297. * unit loading changed to first register units and load them
  1298. afterwards. This is needed to support uses xxx in yyy correctly
  1299. * unit dependency check fixed
  1300. Revision 1.11 2002/12/27 15:26:12 peter
  1301. * procvar compare with 2 ints did not check the integer size
  1302. Revision 1.10 2002/12/23 22:22:16 peter
  1303. * don't allow implicit bool->int conversion
  1304. Revision 1.9 2002/12/18 21:37:36 peter
  1305. * allow classref-classref always when explicit
  1306. Revision 1.8 2002/12/15 22:37:53 peter
  1307. * give conversions from pointer to pwidechar a penalty (=prefer pchar)
  1308. Revision 1.7 2002/12/11 22:40:12 peter
  1309. * proc->procvar is never an exact match, convert exact parameters
  1310. to equal for the whole proc to procvar conversion level
  1311. Revision 1.6 2002/12/06 17:49:44 peter
  1312. * prefer string-shortstring over other string-string conversions
  1313. Revision 1.5 2002/12/05 14:27:26 florian
  1314. * some variant <-> dyn. array stuff
  1315. Revision 1.4 2002/12/01 22:07:41 carl
  1316. * warning of portabilitiy problems with parasize / localsize
  1317. + some added documentation
  1318. Revision 1.3 2002/11/27 15:33:46 peter
  1319. * the never ending story of tp procvar hacks
  1320. Revision 1.2 2002/11/27 02:32:14 peter
  1321. * fix cp_procvar compare
  1322. Revision 1.1 2002/11/25 17:43:16 peter
  1323. * splitted defbase in defutil,symutil,defcmp
  1324. * merged isconvertable and is_equal into compare_defs(_ext)
  1325. * made operator search faster by walking the list only once
  1326. }