defcmp.pas 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  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. eq:=te_convert_l1;
  385. end;
  386. end;
  387. end;
  388. end;
  389. end;
  390. enumdef :
  391. begin
  392. case def_from.deftype of
  393. enumdef :
  394. begin
  395. if explicit then
  396. begin
  397. eq:=te_convert_l1;
  398. doconv:=tc_int_2_int;
  399. end
  400. else
  401. begin
  402. hd1:=def_from;
  403. while assigned(tenumdef(hd1).basedef) do
  404. hd1:=tenumdef(hd1).basedef;
  405. hd2:=def_to;
  406. while assigned(tenumdef(hd2).basedef) do
  407. hd2:=tenumdef(hd2).basedef;
  408. if (hd1=hd2) then
  409. begin
  410. eq:=te_convert_l1;
  411. { because of packenum they can have different sizes! (JM) }
  412. doconv:=tc_int_2_int;
  413. end;
  414. end;
  415. end;
  416. orddef :
  417. begin
  418. if explicit then
  419. begin
  420. eq:=te_convert_l1;
  421. doconv:=tc_int_2_int;
  422. end;
  423. end;
  424. variantdef :
  425. begin
  426. eq:=te_convert_l1;
  427. doconv:=tc_variant_2_enum;
  428. end;
  429. end;
  430. end;
  431. arraydef :
  432. begin
  433. { open array is also compatible with a single element of its base type }
  434. if is_open_array(def_to) and
  435. equal_defs(def_from,tarraydef(def_to).elementtype.def) then
  436. begin
  437. doconv:=tc_equal;
  438. eq:=te_convert_l1;
  439. end
  440. else
  441. begin
  442. case def_from.deftype of
  443. arraydef :
  444. begin
  445. { to dynamic array }
  446. if is_dynamic_array(def_to) then
  447. begin
  448. { dynamic array -> dynamic array }
  449. if is_dynamic_array(def_from) and
  450. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  451. eq:=te_equal;
  452. end
  453. else
  454. { to open array }
  455. if is_open_array(def_to) then
  456. begin
  457. { array constructor -> open array }
  458. if is_array_constructor(def_from) then
  459. begin
  460. if is_void(tarraydef(def_from).elementtype.def) then
  461. begin
  462. doconv:=tc_equal;
  463. eq:=te_convert_l1;
  464. end
  465. else
  466. begin
  467. subeq:=compare_defs_ext(tarraydef(def_from).elementtype.def,
  468. tarraydef(def_to).elementtype.def,
  469. arrayconstructorn,false,true,hct,hpd);
  470. if (subeq>=te_equal) then
  471. begin
  472. doconv:=tc_equal;
  473. eq:=te_convert_l1;
  474. end
  475. else
  476. if (subeq>te_incompatible) then
  477. begin
  478. doconv:=hct;
  479. eq:=te_convert_l2;
  480. end;
  481. end;
  482. end
  483. else
  484. { dynamic array -> open array }
  485. if is_dynamic_array(def_from) and
  486. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  487. begin
  488. doconv:=tc_dynarray_2_openarray;
  489. eq:=te_convert_l2;
  490. end
  491. else
  492. { array -> open array }
  493. if equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  494. eq:=te_equal;
  495. end
  496. else
  497. { to array of const }
  498. if is_array_of_const(def_to) then
  499. begin
  500. if is_array_of_const(def_from) or
  501. is_array_constructor(def_from) then
  502. begin
  503. eq:=te_equal;
  504. end
  505. else
  506. { array of tvarrec -> array of const }
  507. if equal_defs(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  508. begin
  509. doconv:=tc_equal;
  510. eq:=te_convert_l1;
  511. end;
  512. end
  513. else
  514. { other arrays }
  515. begin
  516. { open array -> array }
  517. if is_open_array(def_from) and
  518. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  519. begin
  520. eq:=te_equal
  521. end
  522. else
  523. { array -> array }
  524. if not(m_tp7 in aktmodeswitches) and
  525. not(m_delphi in aktmodeswitches) and
  526. (tarraydef(def_from).lowrange=tarraydef(def_to).lowrange) and
  527. (tarraydef(def_from).highrange=tarraydef(def_to).highrange) and
  528. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) and
  529. equal_defs(tarraydef(def_from).rangetype.def,tarraydef(def_to).rangetype.def) then
  530. begin
  531. eq:=te_equal
  532. end;
  533. end;
  534. end;
  535. pointerdef :
  536. begin
  537. { nil is compatible with dyn. arrays }
  538. if is_dynamic_array(def_to) and
  539. (fromtreetype=niln) then
  540. begin
  541. doconv:=tc_equal;
  542. eq:=te_convert_l1;
  543. end
  544. else
  545. if is_zero_based_array(def_to) and
  546. equal_defs(tpointerdef(def_from).pointertype.def,tarraydef(def_to).elementtype.def) then
  547. begin
  548. doconv:=tc_pointer_2_array;
  549. eq:=te_convert_l1;
  550. end;
  551. end;
  552. stringdef :
  553. begin
  554. { string to char array }
  555. if (not is_special_array(def_to)) and
  556. is_char(tarraydef(def_to).elementtype.def) then
  557. begin
  558. doconv:=tc_string_2_chararray;
  559. eq:=te_convert_l1;
  560. end;
  561. end;
  562. orddef:
  563. begin
  564. if is_chararray(def_to) and
  565. is_char(def_from) then
  566. begin
  567. doconv:=tc_char_2_chararray;
  568. eq:=te_convert_l2;
  569. end;
  570. end;
  571. recorddef :
  572. begin
  573. { tvarrec -> array of const }
  574. if is_array_of_const(def_to) and
  575. equal_defs(def_from,tarraydef(def_to).elementtype.def) then
  576. begin
  577. doconv:=tc_equal;
  578. eq:=te_convert_l1;
  579. end;
  580. end;
  581. variantdef :
  582. begin
  583. if is_dynamic_array(def_to) then
  584. begin
  585. doconv:=tc_variant_2_dynarray;
  586. eq:=te_convert_l1;
  587. end;
  588. end;
  589. end;
  590. end;
  591. end;
  592. variantdef :
  593. begin
  594. case def_from.deftype of
  595. enumdef :
  596. begin
  597. doconv:=tc_enum_2_variant;
  598. eq:=te_convert_l1;
  599. end;
  600. arraydef :
  601. begin
  602. if is_dynamic_array(def_from) then
  603. begin
  604. doconv:=tc_dynarray_2_variant;
  605. eq:=te_convert_l1;
  606. end;
  607. end;
  608. end;
  609. end;
  610. pointerdef :
  611. begin
  612. case def_from.deftype of
  613. stringdef :
  614. begin
  615. { string constant (which can be part of array constructor)
  616. to zero terminated string constant }
  617. if (fromtreetype in [arrayconstructorn,stringconstn]) and
  618. (is_pchar(def_to) or is_pwidechar(def_to)) then
  619. begin
  620. doconv:=tc_cstring_2_pchar;
  621. eq:=te_convert_l1;
  622. end
  623. else
  624. if explicit then
  625. begin
  626. { pchar(ansistring) }
  627. if is_pchar(def_to) and
  628. is_ansistring(def_from) then
  629. begin
  630. doconv:=tc_ansistring_2_pchar;
  631. eq:=te_convert_l1;
  632. end
  633. else
  634. { pwidechar(ansistring) }
  635. if is_pwidechar(def_to) and
  636. is_widestring(def_from) then
  637. begin
  638. doconv:=tc_ansistring_2_pchar;
  639. eq:=te_convert_l1;
  640. end;
  641. end;
  642. end;
  643. orddef :
  644. begin
  645. { char constant to zero terminated string constant }
  646. if (fromtreetype=ordconstn) then
  647. begin
  648. if is_char(def_from) and
  649. is_pchar(def_to) then
  650. begin
  651. doconv:=tc_cchar_2_pchar;
  652. eq:=te_convert_l1;
  653. end
  654. else
  655. if (m_delphi in aktmodeswitches) and is_integer(def_from) then
  656. begin
  657. doconv:=tc_cord_2_pointer;
  658. eq:=te_convert_l1;
  659. end;
  660. end;
  661. if (eq=te_incompatible) and explicit then
  662. begin
  663. doconv:=tc_int_2_int;
  664. eq:=te_convert_l1;
  665. end;
  666. end;
  667. arraydef :
  668. begin
  669. { chararray to pointer }
  670. if is_zero_based_array(def_from) and
  671. equal_defs(tarraydef(def_from).elementtype.def,tpointerdef(def_to).pointertype.def) then
  672. begin
  673. doconv:=tc_array_2_pointer;
  674. eq:=te_convert_l1;
  675. end;
  676. end;
  677. pointerdef :
  678. begin
  679. { check for far pointers }
  680. if (tpointerdef(def_from).is_far<>tpointerdef(def_to).is_far) then
  681. begin
  682. eq:=te_incompatible;
  683. end
  684. else
  685. { the types can be forward type, handle before normal type check !! }
  686. if assigned(def_to.typesym) and
  687. (tpointerdef(def_to).pointertype.def.deftype=forwarddef) then
  688. begin
  689. if (def_from.typesym=def_to.typesym) then
  690. eq:=te_equal
  691. end
  692. else
  693. { same types }
  694. if (tpointerdef(def_from).pointertype.def=tpointerdef(def_to).pointertype.def) then
  695. begin
  696. eq:=te_equal
  697. end
  698. else
  699. { child class pointer can be assigned to anchestor pointers }
  700. if (
  701. (tpointerdef(def_from).pointertype.def.deftype=objectdef) and
  702. (tpointerdef(def_to).pointertype.def.deftype=objectdef) and
  703. tobjectdef(tpointerdef(def_from).pointertype.def).is_related(
  704. tobjectdef(tpointerdef(def_to).pointertype.def))
  705. ) or
  706. { all pointers can be assigned to/from void-pointer }
  707. is_void(tpointerdef(def_to).pointertype.def) or
  708. is_void(tpointerdef(def_from).pointertype.def) then
  709. begin
  710. doconv:=tc_equal;
  711. { give pwidechar a penalty }
  712. if is_pwidechar(def_to) then
  713. eq:=te_convert_l2
  714. else
  715. eq:=te_convert_l1;
  716. end;
  717. end;
  718. procvardef :
  719. begin
  720. { procedure variable can be assigned to an void pointer }
  721. { Not anymore. Use the @ operator now.}
  722. if not(m_tp_procvar in aktmodeswitches) and
  723. { method pointers can't be assigned to void pointers
  724. not(tprocvardef(def_from).is_methodpointer) and }
  725. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  726. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  727. begin
  728. doconv:=tc_equal;
  729. eq:=te_convert_l1;
  730. end;
  731. end;
  732. classrefdef,
  733. objectdef :
  734. begin
  735. { class types and class reference type
  736. can be assigned to void pointers }
  737. if (
  738. is_class_or_interface(def_from) or
  739. (def_from.deftype=classrefdef)
  740. ) and
  741. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  742. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  743. begin
  744. doconv:=tc_equal;
  745. eq:=te_convert_l1;
  746. end;
  747. end;
  748. end;
  749. end;
  750. setdef :
  751. begin
  752. case def_from.deftype of
  753. setdef :
  754. begin
  755. if assigned(tsetdef(def_from).elementtype.def) and
  756. assigned(tsetdef(def_to).elementtype.def) then
  757. begin
  758. { sets with the same element base type are equal }
  759. if is_subequal(tsetdef(def_from).elementtype.def,tsetdef(def_to).elementtype.def) then
  760. eq:=te_equal;
  761. end
  762. else
  763. { empty set is compatible with everything }
  764. eq:=te_equal;
  765. end;
  766. arraydef :
  767. begin
  768. { automatic arrayconstructor -> set conversion }
  769. if is_array_constructor(def_from) then
  770. begin
  771. doconv:=tc_arrayconstructor_2_set;
  772. eq:=te_convert_l1;
  773. end;
  774. end;
  775. end;
  776. end;
  777. procvardef :
  778. begin
  779. case def_from.deftype of
  780. procdef :
  781. begin
  782. { proc -> procvar }
  783. if (m_tp_procvar in aktmodeswitches) then
  784. begin
  785. subeq:=proc_to_procvar_equal(tprocdef(def_from),tprocvardef(def_to),true);
  786. if subeq>te_incompatible then
  787. begin
  788. doconv:=tc_proc_2_procvar;
  789. eq:=te_convert_l1;
  790. end;
  791. end;
  792. end;
  793. procvardef :
  794. begin
  795. { procvar -> procvar }
  796. eq:=proc_to_procvar_equal(tprocvardef(def_from),tprocvardef(def_to),false);
  797. end;
  798. pointerdef :
  799. begin
  800. { nil is compatible with procvars }
  801. if (fromtreetype=niln) then
  802. begin
  803. doconv:=tc_equal;
  804. eq:=te_convert_l1;
  805. end
  806. else
  807. { for example delphi allows the assignement from pointers }
  808. { to procedure variables }
  809. if (m_pointer_2_procedure in aktmodeswitches) and
  810. (tpointerdef(def_from).pointertype.def.deftype=orddef) and
  811. (torddef(tpointerdef(def_from).pointertype.def).typ=uvoid) then
  812. begin
  813. doconv:=tc_equal;
  814. eq:=te_convert_l1;
  815. end;
  816. end;
  817. end;
  818. end;
  819. objectdef :
  820. begin
  821. { object pascal objects }
  822. if (def_from.deftype=objectdef) and
  823. (tobjectdef(def_from).is_related(tobjectdef(def_to))) then
  824. begin
  825. doconv:=tc_equal;
  826. eq:=te_convert_l1;
  827. end
  828. else
  829. { Class/interface specific }
  830. if is_class_or_interface(def_to) then
  831. begin
  832. { void pointer also for delphi mode }
  833. if (m_delphi in aktmodeswitches) and
  834. is_voidpointer(def_from) then
  835. begin
  836. doconv:=tc_equal;
  837. { prefer pointer-pointer assignments }
  838. eq:=te_convert_l2;
  839. end
  840. else
  841. { nil is compatible with class instances and interfaces }
  842. if (fromtreetype=niln) then
  843. begin
  844. doconv:=tc_equal;
  845. eq:=te_convert_l1;
  846. end
  847. { classes can be assigned to interfaces }
  848. else if is_interface(def_to) and
  849. is_class(def_from) and
  850. assigned(tobjectdef(def_from).implementedinterfaces) then
  851. begin
  852. { we've to search in parent classes as well }
  853. hd3:=tobjectdef(def_from);
  854. while assigned(hd3) do
  855. begin
  856. if hd3.implementedinterfaces.searchintf(def_to)<>-1 then
  857. begin
  858. doconv:=tc_class_2_intf;
  859. eq:=te_convert_l1;
  860. break;
  861. end;
  862. hd3:=hd3.childof;
  863. end;
  864. end
  865. { Interface 2 GUID handling }
  866. else if (def_to=tdef(rec_tguid)) and
  867. (fromtreetype=typen) and
  868. is_interface(def_from) and
  869. assigned(tobjectdef(def_from).iidguid) then
  870. begin
  871. eq:=te_convert_l1;
  872. doconv:=tc_equal;
  873. end;
  874. end;
  875. end;
  876. classrefdef :
  877. begin
  878. { similar to pointerdef wrt forwards }
  879. if assigned(def_to.typesym) and
  880. (tclassrefdef(def_to).pointertype.def.deftype=forwarddef) then
  881. begin
  882. if (def_from.typesym=def_to.typesym) then
  883. eq:=te_equal;
  884. end
  885. else
  886. { class reference types }
  887. if (def_from.deftype=classrefdef) then
  888. begin
  889. if equal_defs(tclassrefdef(def_from).pointertype.def,tclassrefdef(def_to).pointertype.def) then
  890. begin
  891. eq:=te_equal;
  892. end
  893. else
  894. begin
  895. doconv:=tc_equal;
  896. if explicit or
  897. tobjectdef(tclassrefdef(def_from).pointertype.def).is_related(
  898. tobjectdef(tclassrefdef(def_to).pointertype.def)) then
  899. eq:=te_convert_l1;
  900. end;
  901. end
  902. else
  903. { nil is compatible with class references }
  904. if (fromtreetype=niln) then
  905. begin
  906. doconv:=tc_equal;
  907. eq:=te_convert_l1;
  908. end;
  909. end;
  910. filedef :
  911. begin
  912. { typed files are all equal to the abstract file type
  913. name TYPEDFILE in system.pp in is_equal in types.pas
  914. the problem is that it sholud be also compatible to FILE
  915. but this would leed to a problem for ASSIGN RESET and REWRITE
  916. when trying to find the good overloaded function !!
  917. so all file function are doubled in system.pp
  918. this is not very beautiful !!}
  919. if (def_from.deftype=filedef) then
  920. begin
  921. if (tfiledef(def_from).filetyp=tfiledef(def_to).filetyp) then
  922. begin
  923. if
  924. (
  925. (tfiledef(def_from).typedfiletype.def=nil) and
  926. (tfiledef(def_to).typedfiletype.def=nil)
  927. ) or
  928. (
  929. (tfiledef(def_from).typedfiletype.def<>nil) and
  930. (tfiledef(def_to).typedfiletype.def<>nil) and
  931. equal_defs(tfiledef(def_from).typedfiletype.def,tfiledef(def_to).typedfiletype.def)
  932. ) or
  933. (
  934. (tfiledef(def_from).filetyp = ft_typed) and
  935. (tfiledef(def_to).filetyp = ft_typed) and
  936. (
  937. (tfiledef(def_from).typedfiletype.def = tdef(voidtype.def)) or
  938. (tfiledef(def_to).typedfiletype.def = tdef(voidtype.def))
  939. )
  940. ) then
  941. begin
  942. eq:=te_equal;
  943. end;
  944. end
  945. else
  946. if ((tfiledef(def_from).filetyp = ft_untyped) and
  947. (tfiledef(def_to).filetyp = ft_typed)) or
  948. ((tfiledef(def_from).filetyp = ft_typed) and
  949. (tfiledef(def_to).filetyp = ft_untyped)) then
  950. begin
  951. doconv:=tc_equal;
  952. eq:=te_convert_l1;
  953. end;
  954. end;
  955. end;
  956. recorddef :
  957. begin
  958. { interface -> guid }
  959. if is_interface(def_from) and
  960. (def_to=rec_tguid) then
  961. begin
  962. doconv:=tc_intf_2_guid;
  963. eq:=te_convert_l1;
  964. end;
  965. end;
  966. formaldef :
  967. begin
  968. doconv:=tc_equal;
  969. if (def_from.deftype=formaldef) then
  970. eq:=te_equal
  971. else
  972. { Just about everything can be converted to a formaldef...}
  973. if not (def_from.deftype in [abstractdef,errordef]) then
  974. eq:=te_convert_l1;
  975. end;
  976. end;
  977. { if we didn't find an appropriate type conversion yet
  978. then we search also the := operator }
  979. if (eq=te_incompatible) and
  980. check_operator and
  981. ((def_from.deftype in [objectdef,recorddef,arraydef,stringdef,variantdef]) or
  982. (def_to.deftype in [objectdef,recorddef,arraydef,stringdef,variantdef])) then
  983. begin
  984. operatorpd:=assignment_overloaded(def_from,def_to);
  985. if assigned(operatorpd) then
  986. eq:=te_convert_operator;
  987. end;
  988. { update convtype for te_equal when it is not yet set }
  989. if (eq=te_equal) and
  990. (doconv=tc_not_possible) then
  991. doconv:=tc_equal;
  992. compare_defs_ext:=eq;
  993. end;
  994. function equal_defs(def_from,def_to:tdef):boolean;
  995. var
  996. convtyp : tconverttype;
  997. pd : tprocdef;
  998. begin
  999. { Compare defs with nothingn and no explicit typecasts and
  1000. searching for overloaded operators is not needed }
  1001. equal_defs:=(compare_defs_ext(def_from,def_to,nothingn,false,false,convtyp,pd)>=te_equal);
  1002. end;
  1003. function compare_defs(def_from,def_to:tdef;fromtreetype:tnodetype):tequaltype;
  1004. var
  1005. doconv : tconverttype;
  1006. pd : tprocdef;
  1007. begin
  1008. compare_defs:=compare_defs_ext(def_from,def_to,fromtreetype,false,true,doconv,pd);
  1009. end;
  1010. function is_subequal(def1, def2: tdef): boolean;
  1011. var
  1012. basedef1,basedef2 : tenumdef;
  1013. Begin
  1014. is_subequal := false;
  1015. if assigned(def1) and assigned(def2) then
  1016. Begin
  1017. if (def1.deftype = orddef) and (def2.deftype = orddef) then
  1018. Begin
  1019. { see p.47 of Turbo Pascal 7.01 manual for the separation of types }
  1020. { range checking for case statements is done with testrange }
  1021. case torddef(def1).typ of
  1022. u8bit,u16bit,u32bit,u64bit,
  1023. s8bit,s16bit,s32bit,s64bit :
  1024. is_subequal:=(torddef(def2).typ in [s64bit,u64bit,s32bit,u32bit,u8bit,s8bit,s16bit,u16bit]);
  1025. bool8bit,bool16bit,bool32bit :
  1026. is_subequal:=(torddef(def2).typ in [bool8bit,bool16bit,bool32bit]);
  1027. uchar :
  1028. is_subequal:=(torddef(def2).typ=uchar);
  1029. uwidechar :
  1030. is_subequal:=(torddef(def2).typ=uwidechar);
  1031. end;
  1032. end
  1033. else
  1034. Begin
  1035. { Check if both basedefs are equal }
  1036. if (def1.deftype=enumdef) and (def2.deftype=enumdef) then
  1037. Begin
  1038. { get both basedefs }
  1039. basedef1:=tenumdef(def1);
  1040. while assigned(basedef1.basedef) do
  1041. basedef1:=basedef1.basedef;
  1042. basedef2:=tenumdef(def2);
  1043. while assigned(basedef2.basedef) do
  1044. basedef2:=basedef2.basedef;
  1045. is_subequal:=(basedef1=basedef2);
  1046. end;
  1047. end;
  1048. end;
  1049. end;
  1050. function compare_paras(paralist1,paralist2 : TLinkedList; acp : tcompare_paras_type; cpoptions: tcompare_paras_options):tequaltype;
  1051. var
  1052. currpara1,
  1053. currpara2 : TParaItem;
  1054. eq,lowesteq : tequaltype;
  1055. hpd : tprocdef;
  1056. convtype : tconverttype;
  1057. begin
  1058. compare_paras:=te_incompatible;
  1059. { we need to parse the list from left-right so the
  1060. not-default parameters are checked first }
  1061. lowesteq:=high(tequaltype);
  1062. currpara1:=TParaItem(paralist1.first);
  1063. currpara2:=TParaItem(paralist2.first);
  1064. if cpo_ignorehidden in cpoptions then
  1065. begin
  1066. while assigned(currpara1) and currpara1.is_hidden do
  1067. currpara1:=tparaitem(currpara1.next);
  1068. while assigned(currpara2) and currpara2.is_hidden do
  1069. currpara2:=tparaitem(currpara2.next);
  1070. end;
  1071. while (assigned(currpara1)) and (assigned(currpara2)) do
  1072. begin
  1073. eq:=te_incompatible;
  1074. { Unique types must match exact }
  1075. if ((df_unique in currpara1.paratype.def.defoptions) or (df_unique in currpara2.paratype.def.defoptions)) and
  1076. (currpara1.paratype.def<>currpara2.paratype.def) then
  1077. exit;
  1078. { Handle hidden parameters separately, because self is
  1079. defined as voidpointer for methodpointers }
  1080. if (currpara1.is_hidden or
  1081. currpara2.is_hidden) then
  1082. begin
  1083. { both must be hidden }
  1084. if currpara1.is_hidden<>currpara2.is_hidden then
  1085. exit;
  1086. eq:=te_equal;
  1087. if not(vo_is_self in tvarsym(currpara1.parasym).varoptions) and
  1088. not(vo_is_self in tvarsym(currpara2.parasym).varoptions) then
  1089. begin
  1090. if (currpara1.paratyp<>currpara2.paratyp) then
  1091. exit;
  1092. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1093. end;
  1094. end
  1095. else
  1096. begin
  1097. case acp of
  1098. cp_value_equal_const :
  1099. begin
  1100. if (
  1101. (currpara1.paratyp<>currpara2.paratyp) and
  1102. ((currpara1.paratyp in [vs_var,vs_out]) or
  1103. (currpara2.paratyp in [vs_var,vs_out]))
  1104. ) then
  1105. exit;
  1106. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1107. end;
  1108. cp_all :
  1109. begin
  1110. if (currpara1.paratyp<>currpara2.paratyp) then
  1111. exit;
  1112. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1113. end;
  1114. cp_procvar :
  1115. begin
  1116. if (currpara1.paratyp<>currpara2.paratyp) then
  1117. exit;
  1118. eq:=compare_defs_ext(currpara1.paratype.def,currpara2.paratype.def,nothingn,
  1119. false,true,convtype,hpd);
  1120. if (eq>te_incompatible) and
  1121. (eq<te_equal) and
  1122. not(
  1123. (convtype in [tc_equal,tc_int_2_int]) and
  1124. (currpara1.paratype.def.size=currpara2.paratype.def.size)
  1125. ) then
  1126. begin
  1127. eq:=te_incompatible;
  1128. end;
  1129. end;
  1130. else
  1131. eq:=compare_defs(currpara1.paratype.def,currpara2.paratype.def,nothingn);
  1132. end;
  1133. end;
  1134. { check type }
  1135. if eq=te_incompatible then
  1136. exit;
  1137. if eq<lowesteq then
  1138. lowesteq:=eq;
  1139. { also check default value if both have it declared }
  1140. if (cpo_comparedefaultvalue in cpoptions) and
  1141. assigned(currpara1.defaultvalue) and
  1142. assigned(currpara2.defaultvalue) then
  1143. begin
  1144. if not equal_constsym(tconstsym(currpara1.defaultvalue),tconstsym(currpara2.defaultvalue)) then
  1145. exit;
  1146. end;
  1147. currpara1:=TParaItem(currpara1.next);
  1148. currpara2:=TParaItem(currpara2.next);
  1149. if cpo_ignorehidden in cpoptions then
  1150. begin
  1151. while assigned(currpara1) and currpara1.is_hidden do
  1152. currpara1:=tparaitem(currpara1.next);
  1153. while assigned(currpara2) and currpara2.is_hidden do
  1154. currpara2:=tparaitem(currpara2.next);
  1155. end;
  1156. end;
  1157. { when both lists are empty then the parameters are equal. Also
  1158. when one list is empty and the other has a parameter with default
  1159. value assigned then the parameters are also equal }
  1160. if ((currpara1=nil) and (currpara2=nil)) or
  1161. ((cpo_allowdefaults in cpoptions) and
  1162. ((assigned(currpara1) and assigned(currpara1.defaultvalue)) or
  1163. (assigned(currpara2) and assigned(currpara2.defaultvalue)))) then
  1164. compare_paras:=lowesteq;
  1165. end;
  1166. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;methoderr:boolean):tequaltype;
  1167. var
  1168. eq : tequaltype;
  1169. po_comp : tprocoptions;
  1170. begin
  1171. proc_to_procvar_equal:=te_incompatible;
  1172. if not(assigned(def1)) or not(assigned(def2)) then
  1173. exit;
  1174. { check for method pointer }
  1175. if (def1.is_methodpointer xor def2.is_methodpointer) or
  1176. (def1.is_addressonly xor def2.is_addressonly) then
  1177. begin
  1178. if methoderr then
  1179. Message(type_e_no_method_and_procedure_not_compatible);
  1180. exit;
  1181. end;
  1182. { check return value and options, methodpointer is already checked }
  1183. po_comp:=[po_staticmethod,po_interrupt,
  1184. po_iocheck,po_varargs];
  1185. if (m_delphi in aktmodeswitches) then
  1186. exclude(po_comp,po_varargs);
  1187. if ((po_comp * def1.procoptions)= (po_comp * def2.procoptions)) and
  1188. equal_defs(def1.rettype.def,def2.rettype.def) then
  1189. begin
  1190. { return equal type based on the parameters, but a proc->procvar
  1191. is never exact, so map an exact match of the parameters to
  1192. te_equal }
  1193. eq:=compare_paras(def1.para,def2.para,cp_procvar,[]);
  1194. if eq=te_exact then
  1195. eq:=te_equal;
  1196. proc_to_procvar_equal:=eq;
  1197. end;
  1198. end;
  1199. end.
  1200. {
  1201. $Log$
  1202. Revision 1.41 2004-01-06 02:17:44 florian
  1203. * fixed webbug 2878
  1204. Revision 1.40 2004/01/02 17:19:04 jonas
  1205. * if currency = int64, FPC_CURRENCY_IS_INT64 is defined
  1206. + round and trunc for currency and comp if FPC_CURRENCY_IS_INT64 is
  1207. defined
  1208. * if currency = orddef, prefer currency -> int64/qword conversion over
  1209. currency -> float conversions
  1210. * optimized currency/currency if currency = orddef
  1211. * TODO: write FPC_DIV_CURRENCY and FPC_MUL_CURRENCY routines to prevent
  1212. precision loss if currency=int64 and bestreal = double
  1213. Revision 1.39 2003/12/16 09:41:44 daniel
  1214. * Automatic conversion from integer constants to pointer constants is no
  1215. longer done except in Delphi mode
  1216. Revision 1.38 2003/11/26 15:11:42 michael
  1217. + Patch to prefer getpropinfo(ptypeinfo,name) over getpropinfo(tobject,name) when called with getpropinfo(aclass.classinfo) from Peter
  1218. Revision 1.37 2003/11/10 19:09:29 peter
  1219. * procvar default value support
  1220. Revision 1.36 2003/11/04 22:30:15 florian
  1221. + type cast variant<->enum
  1222. * cnv. node second pass uses now as well helper wrappers
  1223. Revision 1.35 2003/10/30 16:23:13 peter
  1224. * don't search for overloads in parents for constructors
  1225. Revision 1.34 2003/10/26 14:11:35 florian
  1226. * fixed web bug 2129: explicit float casts in Delphi mode must be handled by the default code
  1227. Revision 1.33 2003/10/14 12:23:06 florian
  1228. * fixed 2729: overloading problem with methodvars and procvars
  1229. Revision 1.32 2003/10/10 17:48:13 peter
  1230. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1231. * tregisteralloctor renamed to trgobj
  1232. * removed rgobj from a lot of units
  1233. * moved location_* and reference_* to cgobj
  1234. * first things for mmx register allocation
  1235. Revision 1.31 2003/10/07 21:14:32 peter
  1236. * compare_paras() has a parameter to ignore hidden parameters
  1237. * cross unit overload searching ignores hidden parameters when
  1238. comparing parameter lists. Now function(string):string is
  1239. not overriden with procedure(string) which has the same visible
  1240. parameter list
  1241. Revision 1.30 2003/10/05 13:05:05 peter
  1242. * when comparing hidden parameters both must be hidden
  1243. Revision 1.29 2003/10/05 12:57:11 peter
  1244. * set correct conversion for subranges
  1245. Revision 1.28 2003/09/09 21:03:17 peter
  1246. * basics for x86 register calling
  1247. Revision 1.27 2003/06/03 21:02:08 peter
  1248. * allow pointer(int64) in all modes
  1249. Revision 1.26 2003/05/26 21:17:17 peter
  1250. * procinlinenode removed
  1251. * aktexit2label removed, fast exit removed
  1252. + tcallnode.inlined_pass_2 added
  1253. Revision 1.25 2003/05/15 18:58:53 peter
  1254. * removed selfpointer_offset, vmtpointer_offset
  1255. * tvarsym.adjusted_address
  1256. * address in localsymtable is now in the real direction
  1257. * removed some obsolete globals
  1258. Revision 1.24 2003/05/09 17:47:02 peter
  1259. * self moved to hidden parameter
  1260. * removed hdisposen,hnewn,selfn
  1261. Revision 1.23 2003/04/23 20:16:04 peter
  1262. + added currency support based on int64
  1263. + is_64bit for use in cg units instead of is_64bitint
  1264. * removed cgmessage from n386add, replace with internalerrors
  1265. Revision 1.22 2003/04/23 11:37:33 peter
  1266. * po_comp for proc to procvar fixed
  1267. Revision 1.21 2003/04/10 17:57:52 peter
  1268. * vs_hidden released
  1269. Revision 1.20 2003/03/20 17:52:18 peter
  1270. * fix compare for unique types, they are allowed when they match
  1271. exact
  1272. Revision 1.19 2003/01/16 22:13:51 peter
  1273. * convert_l3 convertlevel added. This level is used for conversions
  1274. where information can be lost like converting widestring->ansistring
  1275. or dword->byte
  1276. Revision 1.18 2003/01/15 01:44:32 peter
  1277. * merged methodpointer fixes from 1.0.x
  1278. Revision 1.17 2003/01/09 21:43:39 peter
  1279. * constant string conversion fixed, it's now equal to both
  1280. shortstring, ansistring and the typeconvnode will return
  1281. te_equal but still return convtype to change the constnode
  1282. Revision 1.16 2003/01/05 22:42:13 peter
  1283. * use int_to_int conversion for pointer/procvar/classref to int
  1284. Revision 1.15 2003/01/05 15:54:15 florian
  1285. + added proper support of type = type <type>; for simple types
  1286. Revision 1.14 2003/01/03 17:16:04 peter
  1287. * fixed assignment operator checking for typecast
  1288. Revision 1.13 2002/12/29 18:15:19 peter
  1289. * varargs is not checked in proc->procvar for delphi
  1290. Revision 1.12 2002/12/29 14:57:50 peter
  1291. * unit loading changed to first register units and load them
  1292. afterwards. This is needed to support uses xxx in yyy correctly
  1293. * unit dependency check fixed
  1294. Revision 1.11 2002/12/27 15:26:12 peter
  1295. * procvar compare with 2 ints did not check the integer size
  1296. Revision 1.10 2002/12/23 22:22:16 peter
  1297. * don't allow implicit bool->int conversion
  1298. Revision 1.9 2002/12/18 21:37:36 peter
  1299. * allow classref-classref always when explicit
  1300. Revision 1.8 2002/12/15 22:37:53 peter
  1301. * give conversions from pointer to pwidechar a penalty (=prefer pchar)
  1302. Revision 1.7 2002/12/11 22:40:12 peter
  1303. * proc->procvar is never an exact match, convert exact parameters
  1304. to equal for the whole proc to procvar conversion level
  1305. Revision 1.6 2002/12/06 17:49:44 peter
  1306. * prefer string-shortstring over other string-string conversions
  1307. Revision 1.5 2002/12/05 14:27:26 florian
  1308. * some variant <-> dyn. array stuff
  1309. Revision 1.4 2002/12/01 22:07:41 carl
  1310. * warning of portabilitiy problems with parasize / localsize
  1311. + some added documentation
  1312. Revision 1.3 2002/11/27 15:33:46 peter
  1313. * the never ending story of tp procvar hacks
  1314. Revision 1.2 2002/11/27 02:32:14 peter
  1315. * fix cp_procvar compare
  1316. Revision 1.1 2002/11/25 17:43:16 peter
  1317. * splitted defbase in defutil,symutil,defcmp
  1318. * merged isconvertable and is_equal into compare_defs(_ext)
  1319. * made operator search faster by walking the list only once
  1320. }