defcmp.pas 55 KB

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