defcmp.pas 56 KB

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