defcmp.pas 58 KB

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