defbase.pas 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit provides some help routines for type handling
  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 defbase;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,
  23. cpuinfo,
  24. globals,
  25. node,
  26. symconst,symbase,symtype,symdef,symsym;
  27. type
  28. tmmxtype = (mmxno,mmxu8bit,mmxs8bit,mmxu16bit,mmxs16bit,
  29. mmxu32bit,mmxs32bit,mmxfixed16,mmxsingle);
  30. const
  31. {# true if we must never copy this parameter }
  32. never_copy_const_param : boolean = false;
  33. {*****************************************************************************
  34. Basic type functions
  35. *****************************************************************************}
  36. {# Returns true, if def defines an ordinal type }
  37. function is_ordinal(def : tdef) : boolean;
  38. {# Returns the min. value of the type }
  39. function get_min_value(def : tdef) : TConstExprInt;
  40. {# Returns basetype of the specified range }
  41. function range_to_basetype(low,high:TConstExprInt):tbasetype;
  42. {# Returns true, if def defines an ordinal type }
  43. function is_integer(def : tdef) : boolean;
  44. {# Returns true if p is a boolean }
  45. function is_boolean(def : tdef) : boolean;
  46. {# Returns true if p is a char }
  47. function is_char(def : tdef) : boolean;
  48. {# Returns true if p is a widechar }
  49. function is_widechar(def : tdef) : boolean;
  50. {# Returns true if p is a void}
  51. function is_void(def : tdef) : boolean;
  52. {# Returns true if p is a smallset def }
  53. function is_smallset(p : tdef) : boolean;
  54. {# Returns true, if def defines a signed data type (only for ordinal types) }
  55. function is_signed(def : tdef) : boolean;
  56. {# Returns true whether def_from's range is comprised in def_to's if both are
  57. orddefs, false otherwise }
  58. function is_in_limit(def_from,def_to : tdef) : boolean;
  59. {*****************************************************************************
  60. Array helper functions
  61. *****************************************************************************}
  62. {# Returns true, if p points to a zero based (non special like open or
  63. dynamic array def).
  64. This is mainly used to see if the array
  65. is convertable to a pointer
  66. }
  67. function is_zero_based_array(p : tdef) : boolean;
  68. {# Returns true if p points to an open array def }
  69. function is_open_array(p : tdef) : boolean;
  70. {# Returns true if p points to a dynamic array def }
  71. function is_dynamic_array(p : tdef) : boolean;
  72. {# Returns true, if p points to an array of const def }
  73. function is_array_constructor(p : tdef) : boolean;
  74. {# Returns true, if p points to a variant array }
  75. function is_variant_array(p : tdef) : boolean;
  76. {# Returns true, if p points to an array of const }
  77. function is_array_of_const(p : tdef) : boolean;
  78. {# Returns true, if p points any kind of special array
  79. That is if the array is an open array, a variant
  80. array, an array constants constructor, or an
  81. array of const.
  82. }
  83. function is_special_array(p : tdef) : boolean;
  84. {# Returns true if p is a char array def }
  85. function is_chararray(p : tdef) : boolean;
  86. {# Returns true if p is a wide char array def }
  87. function is_widechararray(p : tdef) : boolean;
  88. {*****************************************************************************
  89. String helper functions
  90. *****************************************************************************}
  91. {# Returns true if p points to an open string def }
  92. function is_open_string(p : tdef) : boolean;
  93. {# Returns true if p is an ansi string def }
  94. function is_ansistring(p : tdef) : boolean;
  95. {# Returns true if p is a long string def }
  96. function is_longstring(p : tdef) : boolean;
  97. {# returns true if p is a wide string def }
  98. function is_widestring(p : tdef) : boolean;
  99. {# Returns true if p is a short string def }
  100. function is_shortstring(p : tdef) : boolean;
  101. {# Returns true if p is a pchar def }
  102. function is_pchar(p : tdef) : boolean;
  103. {# Returns true if p is a pwidechar def }
  104. function is_pwidechar(p : tdef) : boolean;
  105. {# Returns true if p is a voidpointer def }
  106. function is_voidpointer(p : tdef) : boolean;
  107. {# Returns true, if definition is float }
  108. function is_fpu(def : tdef) : boolean;
  109. {# Returns true, if def is a currency type }
  110. function is_currency(def : tdef) : boolean;
  111. {# Returns true, if def is a 64 bit integer type }
  112. function is_64bitint(def : tdef) : boolean;
  113. {# Returns true, if def1 and def2 are semantically the same }
  114. function is_equal(def1,def2 : tdef) : boolean;
  115. {# Checks for type compatibility (subgroups of type)
  116. used for case statements... probably missing stuff
  117. to use on other types
  118. }
  119. function is_subequal(def1, def2: tdef): boolean;
  120. type
  121. tconverttype = (
  122. tc_equal,
  123. tc_not_possible,
  124. tc_string_2_string,
  125. tc_char_2_string,
  126. tc_char_2_chararray,
  127. tc_pchar_2_string,
  128. tc_cchar_2_pchar,
  129. tc_cstring_2_pchar,
  130. tc_ansistring_2_pchar,
  131. tc_string_2_chararray,
  132. tc_chararray_2_string,
  133. tc_array_2_pointer,
  134. tc_pointer_2_array,
  135. tc_int_2_int,
  136. tc_int_2_bool,
  137. tc_bool_2_bool,
  138. tc_bool_2_int,
  139. tc_real_2_real,
  140. tc_int_2_real,
  141. tc_proc_2_procvar,
  142. tc_arrayconstructor_2_set,
  143. tc_load_smallset,
  144. tc_cord_2_pointer,
  145. tc_intf_2_string,
  146. tc_intf_2_guid,
  147. tc_class_2_intf,
  148. tc_char_2_char,
  149. tc_normal_2_smallset,
  150. tc_dynarray_2_openarray
  151. );
  152. function assignment_overloaded(from_def,to_def : tdef) : tprocdef;
  153. { Returns:
  154. 0 - Not convertable
  155. 1 - Convertable
  156. 2 - Convertable, but not first choice }
  157. function isconvertable(def_from,def_to : tdef;
  158. var doconv : tconverttype;
  159. fromtreetype : tnodetype;
  160. explicit : boolean) : byte;
  161. { Same as is_equal, but with error message if failed }
  162. function CheckTypes(def1,def2 : tdef) : boolean;
  163. function equal_constsym(sym1,sym2:tconstsym):boolean;
  164. {# true, if two parameter lists are equal
  165. if acp is cp_none, all have to match exactly
  166. if acp is cp_value_equal_const call by value
  167. and call by const parameter are assumed as
  168. equal
  169. }
  170. { if acp is cp_all the var const or nothing are considered equal }
  171. type
  172. compare_type = ( cp_none, cp_value_equal_const, cp_all);
  173. function equal_paras(paralist1,paralist2 : tlinkedlist; acp : compare_type) : boolean;
  174. { True if a type can be allowed for another one
  175. in a func var }
  176. function convertable_paras(paralist1,paralist2 : tlinkedlist; acp : compare_type) : boolean;
  177. { True if a function can be assigned to a procvar }
  178. { changed first argument type to pabstractprocdef so that it can also be }
  179. { used to test compatibility between two pprocvardefs (JM) }
  180. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;exact:boolean) : boolean;
  181. { function get_proc_2_procvar_def(p:tprocsym;d:tprocvardef):tprocdef;}
  182. {# If @var(l) isn't in the range of def a range check error (if not explicit) is generated and
  183. the value is placed within the range
  184. }
  185. procedure testrange(def : tdef;var l : tconstexprint;explicit:boolean);
  186. {# Returns the range of def, where @var(l) is the low-range and @var(h) is
  187. the high-range.
  188. }
  189. procedure getrange(def : tdef;var l : TConstExprInt;var h : TConstExprInt);
  190. { some type helper routines for MMX support }
  191. function is_mmx_able_array(p : tdef) : boolean;
  192. {# returns the mmx type }
  193. function mmx_type(p : tdef) : tmmxtype;
  194. {# returns true, if sym needs an entry in the proplist of a class rtti }
  195. function needs_prop_entry(sym : tsym) : boolean;
  196. implementation
  197. uses
  198. globtype,tokens,verbose,
  199. symtable;
  200. function needs_prop_entry(sym : tsym) : boolean;
  201. begin
  202. needs_prop_entry:=(sp_published in tsym(sym).symoptions) and
  203. (sym.typ in [propertysym,varsym]);
  204. end;
  205. function equal_constsym(sym1,sym2:tconstsym):boolean;
  206. var
  207. p1,p2,pend : pchar;
  208. begin
  209. equal_constsym:=false;
  210. if sym1.consttyp<>sym2.consttyp then
  211. exit;
  212. case sym1.consttyp of
  213. constint,
  214. constbool,
  215. constchar,
  216. constord :
  217. equal_constsym:=(sym1.valueord=sym2.valueord);
  218. constpointer :
  219. equal_constsym:=(sym1.valueordptr=sym2.valueordptr);
  220. conststring,constresourcestring :
  221. begin
  222. if sym1.len=sym2.len then
  223. begin
  224. p1:=pchar(sym1.valueptr);
  225. p2:=pchar(sym2.valueptr);
  226. pend:=p1+sym1.len;
  227. while (p1<pend) do
  228. begin
  229. if p1^<>p2^ then
  230. break;
  231. inc(p1);
  232. inc(p2);
  233. end;
  234. if (p1=pend) then
  235. equal_constsym:=true;
  236. end;
  237. end;
  238. constreal :
  239. equal_constsym:=(pbestreal(sym1.valueptr)^=pbestreal(sym2.valueptr)^);
  240. constset :
  241. equal_constsym:=(pnormalset(sym1.valueptr)^=pnormalset(sym2.valueptr)^);
  242. constnil :
  243. equal_constsym:=true;
  244. end;
  245. end;
  246. { compare_type = ( cp_none, cp_value_equal_const, cp_all); }
  247. function equal_paras(paralist1,paralist2 : TLinkedList; acp : compare_type) : boolean;
  248. var
  249. def1,def2 : TParaItem;
  250. begin
  251. def1:=TParaItem(paralist1.first);
  252. def2:=TParaItem(paralist2.first);
  253. while (assigned(def1)) and (assigned(def2)) do
  254. begin
  255. case acp of
  256. cp_value_equal_const :
  257. begin
  258. if not(is_equal(def1.paratype.def,def2.paratype.def)) or
  259. ((def1.paratyp<>def2.paratyp) and
  260. ((def1.paratyp in [vs_var,vs_out]) or
  261. (def2.paratyp in [vs_var,vs_out])
  262. )
  263. ) then
  264. begin
  265. equal_paras:=false;
  266. exit;
  267. end;
  268. end;
  269. cp_all :
  270. begin
  271. if not(is_equal(def1.paratype.def,def2.paratype.def)) or
  272. (def1.paratyp<>def2.paratyp) then
  273. begin
  274. equal_paras:=false;
  275. exit;
  276. end;
  277. end;
  278. cp_none :
  279. begin
  280. if not(is_equal(def1.paratype.def,def2.paratype.def)) then
  281. begin
  282. equal_paras:=false;
  283. exit;
  284. end;
  285. { also check default value if both have it declared }
  286. if assigned(def1.defaultvalue) and
  287. assigned(def2.defaultvalue) then
  288. begin
  289. if not equal_constsym(tconstsym(def1.defaultvalue),tconstsym(def2.defaultvalue)) then
  290. begin
  291. equal_paras:=false;
  292. exit;
  293. end;
  294. end;
  295. end;
  296. end;
  297. def1:=TParaItem(def1.next);
  298. def2:=TParaItem(def2.next);
  299. end;
  300. if (def1=nil) and (def2=nil) then
  301. equal_paras:=true
  302. else
  303. equal_paras:=false;
  304. end;
  305. function convertable_paras(paralist1,paralist2 : TLinkedList;acp : compare_type) : boolean;
  306. var
  307. def1,def2 : TParaItem;
  308. doconv : tconverttype;
  309. begin
  310. def1:=TParaItem(paralist1.first);
  311. def2:=TParaItem(paralist2.first);
  312. while (assigned(def1)) and (assigned(def2)) do
  313. begin
  314. case acp of
  315. cp_value_equal_const :
  316. begin
  317. if (isconvertable(def1.paratype.def,def2.paratype.def,doconv,callparan,false)=0) or
  318. ((def1.paratyp<>def2.paratyp) and
  319. ((def1.paratyp in [vs_out,vs_var]) or
  320. (def2.paratyp in [vs_out,vs_var])
  321. )
  322. ) then
  323. begin
  324. convertable_paras:=false;
  325. exit;
  326. end;
  327. end;
  328. cp_all :
  329. begin
  330. if (isconvertable(def1.paratype.def,def2.paratype.def,doconv,callparan,false)=0) or
  331. (def1.paratyp<>def2.paratyp) then
  332. begin
  333. convertable_paras:=false;
  334. exit;
  335. end;
  336. end;
  337. cp_none :
  338. begin
  339. if (isconvertable(def1.paratype.def,def2.paratype.def,doconv,callparan,false)=0) then
  340. begin
  341. convertable_paras:=false;
  342. exit;
  343. end;
  344. end;
  345. end;
  346. def1:=TParaItem(def1.next);
  347. def2:=TParaItem(def2.next);
  348. end;
  349. if (def1=nil) and (def2=nil) then
  350. convertable_paras:=true
  351. else
  352. convertable_paras:=false;
  353. end;
  354. { true if a function can be assigned to a procvar }
  355. { changed first argument type to pabstractprocdef so that it can also be }
  356. { used to test compatibility between two pprocvardefs (JM) }
  357. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;exact:boolean) : boolean;
  358. const
  359. po_comp = po_compatibility_options-[po_methodpointer,po_classmethod];
  360. var
  361. ismethod : boolean;
  362. begin
  363. proc_to_procvar_equal:=false;
  364. if not(assigned(def1)) or not(assigned(def2)) then
  365. exit;
  366. { check for method pointer }
  367. if def1.deftype=procvardef then
  368. begin
  369. ismethod:=(po_methodpointer in def1.procoptions);
  370. end
  371. else
  372. begin
  373. ismethod:=assigned(def1.owner) and
  374. (def1.owner.symtabletype=objectsymtable);
  375. end;
  376. if (ismethod and not (po_methodpointer in def2.procoptions)) or
  377. (not(ismethod) and (po_methodpointer in def2.procoptions)) then
  378. begin
  379. Message(type_e_no_method_and_procedure_not_compatible);
  380. exit;
  381. end;
  382. { check return value and para's and options, methodpointer is already checked
  383. parameters may also be convertable }
  384. if is_equal(def1.rettype.def,def2.rettype.def) and
  385. (equal_paras(def1.para,def2.para,cp_all) or
  386. ((not exact) and convertable_paras(def1.para,def2.para,cp_all))) and
  387. ((po_comp * def1.procoptions)= (po_comp * def2.procoptions)) then
  388. proc_to_procvar_equal:=true
  389. else
  390. proc_to_procvar_equal:=false;
  391. end;
  392. { returns true, if def uses FPU }
  393. function is_fpu(def : tdef) : boolean;
  394. begin
  395. is_fpu:=(def.deftype=floatdef);
  396. end;
  397. { returns true, if def is a currency type }
  398. function is_currency(def : tdef) : boolean;
  399. begin
  400. is_currency:=(def.deftype=floatdef) and (tfloatdef(def).typ=s64currency);
  401. end;
  402. function range_to_basetype(low,high:TConstExprInt):tbasetype;
  403. begin
  404. { generate a unsigned range if high<0 and low>=0 }
  405. if (low>=0) and (high<0) then
  406. range_to_basetype:=u32bit
  407. else if (low>=0) and (high<=255) then
  408. range_to_basetype:=u8bit
  409. else if (low>=-128) and (high<=127) then
  410. range_to_basetype:=s8bit
  411. else if (low>=0) and (high<=65536) then
  412. range_to_basetype:=u16bit
  413. else if (low>=-32768) and (high<=32767) then
  414. range_to_basetype:=s16bit
  415. else
  416. range_to_basetype:=s32bit;
  417. end;
  418. { true if p is an ordinal }
  419. function is_ordinal(def : tdef) : boolean;
  420. var
  421. dt : tbasetype;
  422. begin
  423. case def.deftype of
  424. orddef :
  425. begin
  426. dt:=torddef(def).typ;
  427. is_ordinal:=dt in [uchar,uwidechar,
  428. u8bit,u16bit,u32bit,u64bit,
  429. s8bit,s16bit,s32bit,s64bit,
  430. bool8bit,bool16bit,bool32bit];
  431. end;
  432. enumdef :
  433. is_ordinal:=true;
  434. else
  435. is_ordinal:=false;
  436. end;
  437. end;
  438. { returns the min. value of the type }
  439. function get_min_value(def : tdef) : TConstExprInt;
  440. begin
  441. case def.deftype of
  442. orddef:
  443. get_min_value:=torddef(def).low;
  444. enumdef:
  445. get_min_value:=tenumdef(def).min;
  446. else
  447. get_min_value:=0;
  448. end;
  449. end;
  450. { true if p is an integer }
  451. function is_integer(def : tdef) : boolean;
  452. begin
  453. is_integer:=(def.deftype=orddef) and
  454. (torddef(def).typ in [u8bit,u16bit,u32bit,u64bit,
  455. s8bit,s16bit,s32bit,s64bit]);
  456. end;
  457. { true if p is a boolean }
  458. function is_boolean(def : tdef) : boolean;
  459. begin
  460. is_boolean:=(def.deftype=orddef) and
  461. (torddef(def).typ in [bool8bit,bool16bit,bool32bit]);
  462. end;
  463. { true if p is a void }
  464. function is_void(def : tdef) : boolean;
  465. begin
  466. is_void:=(def.deftype=orddef) and
  467. (torddef(def).typ=uvoid);
  468. end;
  469. { true if p is a char }
  470. function is_char(def : tdef) : boolean;
  471. begin
  472. is_char:=(def.deftype=orddef) and
  473. (torddef(def).typ=uchar);
  474. end;
  475. { true if p is a wchar }
  476. function is_widechar(def : tdef) : boolean;
  477. begin
  478. is_widechar:=(def.deftype=orddef) and
  479. (torddef(def).typ=uwidechar);
  480. end;
  481. { true if p is signed (integer) }
  482. function is_signed(def : tdef) : boolean;
  483. var
  484. dt : tbasetype;
  485. begin
  486. case def.deftype of
  487. orddef :
  488. begin
  489. dt:=torddef(def).typ;
  490. is_signed:=(dt in [s8bit,s16bit,s32bit,s64bit]);
  491. end;
  492. enumdef :
  493. is_signed:=tenumdef(def).min < 0;
  494. arraydef :
  495. is_signed:=is_signed(tarraydef(def).rangetype.def);
  496. else
  497. is_signed:=false;
  498. end;
  499. end;
  500. function is_in_limit(def_from,def_to : tdef) : boolean;
  501. var
  502. fromqword, toqword: boolean;
  503. begin
  504. if (def_from.deftype <> orddef) or
  505. (def_to.deftype <> orddef) then
  506. begin
  507. is_in_limit := false;
  508. exit;
  509. end;
  510. fromqword := torddef(def_from).typ = u64bit;
  511. toqword := torddef(def_to).typ = u64bit;
  512. is_in_limit:=((not(fromqword xor toqword) and
  513. (torddef(def_from).low>=torddef(def_to).low) and
  514. (torddef(def_from).high<=torddef(def_to).high)) or
  515. (toqword and not is_signed(def_from)));
  516. end;
  517. { true, if p points to an open array def }
  518. function is_open_string(p : tdef) : boolean;
  519. begin
  520. is_open_string:=(p.deftype=stringdef) and
  521. (tstringdef(p).string_typ=st_shortstring) and
  522. (tstringdef(p).len=0);
  523. end;
  524. { true, if p points to a zero based array def }
  525. function is_zero_based_array(p : tdef) : boolean;
  526. begin
  527. is_zero_based_array:=(p.deftype=arraydef) and
  528. (tarraydef(p).lowrange=0) and
  529. not(is_special_array(p));
  530. end;
  531. { true if p points to a dynamic array def }
  532. function is_dynamic_array(p : tdef) : boolean;
  533. begin
  534. is_dynamic_array:=(p.deftype=arraydef) and
  535. tarraydef(p).IsDynamicArray;
  536. end;
  537. { true, if p points to an open array def }
  538. function is_open_array(p : tdef) : boolean;
  539. begin
  540. { check for s32bittype is needed, because for u32bit the high
  541. range is also -1 ! (PFV) }
  542. is_open_array:=(p.deftype=arraydef) and
  543. (tarraydef(p).rangetype.def=s32bittype.def) and
  544. (tarraydef(p).lowrange=0) and
  545. (tarraydef(p).highrange=-1) and
  546. not(tarraydef(p).IsConstructor) and
  547. not(tarraydef(p).IsVariant) and
  548. not(tarraydef(p).IsArrayOfConst) and
  549. not(tarraydef(p).IsDynamicArray);
  550. end;
  551. { true, if p points to an array of const def }
  552. function is_array_constructor(p : tdef) : boolean;
  553. begin
  554. is_array_constructor:=(p.deftype=arraydef) and
  555. (tarraydef(p).IsConstructor);
  556. end;
  557. { true, if p points to a variant array }
  558. function is_variant_array(p : tdef) : boolean;
  559. begin
  560. is_variant_array:=(p.deftype=arraydef) and
  561. (tarraydef(p).IsVariant);
  562. end;
  563. { true, if p points to an array of const }
  564. function is_array_of_const(p : tdef) : boolean;
  565. begin
  566. is_array_of_const:=(p.deftype=arraydef) and
  567. (tarraydef(p).IsArrayOfConst);
  568. end;
  569. { true, if p points to a special array }
  570. function is_special_array(p : tdef) : boolean;
  571. begin
  572. is_special_array:=(p.deftype=arraydef) and
  573. ((tarraydef(p).IsVariant) or
  574. (tarraydef(p).IsArrayOfConst) or
  575. (tarraydef(p).IsConstructor) or
  576. is_open_array(p)
  577. );
  578. end;
  579. { true if p is an ansi string def }
  580. function is_ansistring(p : tdef) : boolean;
  581. begin
  582. is_ansistring:=(p.deftype=stringdef) and
  583. (tstringdef(p).string_typ=st_ansistring);
  584. end;
  585. { true if p is an long string def }
  586. function is_longstring(p : tdef) : boolean;
  587. begin
  588. is_longstring:=(p.deftype=stringdef) and
  589. (tstringdef(p).string_typ=st_longstring);
  590. end;
  591. { true if p is an wide string def }
  592. function is_widestring(p : tdef) : boolean;
  593. begin
  594. is_widestring:=(p.deftype=stringdef) and
  595. (tstringdef(p).string_typ=st_widestring);
  596. end;
  597. { true if p is an short string def }
  598. function is_shortstring(p : tdef) : boolean;
  599. begin
  600. is_shortstring:=(p.deftype=stringdef) and
  601. (tstringdef(p).string_typ=st_shortstring);
  602. end;
  603. { true if p is a char array def }
  604. function is_chararray(p : tdef) : boolean;
  605. begin
  606. is_chararray:=(p.deftype=arraydef) and
  607. is_equal(tarraydef(p).elementtype.def,cchartype.def) and
  608. not(is_special_array(p));
  609. end;
  610. { true if p is a widechar array def }
  611. function is_widechararray(p : tdef) : boolean;
  612. begin
  613. is_widechararray:=(p.deftype=arraydef) and
  614. is_equal(tarraydef(p).elementtype.def,cwidechartype.def) and
  615. not(is_special_array(p));
  616. end;
  617. { true if p is a pchar def }
  618. function is_pchar(p : tdef) : boolean;
  619. begin
  620. is_pchar:=(p.deftype=pointerdef) and
  621. (is_equal(tpointerdef(p).pointertype.def,cchartype.def) or
  622. (is_zero_based_array(tpointerdef(p).pointertype.def) and
  623. is_chararray(tpointerdef(p).pointertype.def)));
  624. end;
  625. { true if p is a pchar def }
  626. function is_pwidechar(p : tdef) : boolean;
  627. begin
  628. is_pwidechar:=(p.deftype=pointerdef) and
  629. (is_equal(tpointerdef(p).pointertype.def,cwidechartype.def) or
  630. (is_zero_based_array(tpointerdef(p).pointertype.def) and
  631. is_widechararray(tpointerdef(p).pointertype.def)));
  632. end;
  633. { true if p is a voidpointer def }
  634. function is_voidpointer(p : tdef) : boolean;
  635. begin
  636. is_voidpointer:=(p.deftype=pointerdef) and
  637. (tpointerdef(p).pointertype.def.deftype=orddef) and
  638. (torddef(tpointerdef(p).pointertype.def).typ=uvoid);
  639. end;
  640. { true if p is a smallset def }
  641. function is_smallset(p : tdef) : boolean;
  642. begin
  643. is_smallset:=(p.deftype=setdef) and
  644. (tsetdef(p).settype=smallset);
  645. end;
  646. { true, if def is a 64 bit int type }
  647. function is_64bitint(def : tdef) : boolean;
  648. begin
  649. is_64bitint:=(def.deftype=orddef) and (torddef(def).typ in [u64bit,s64bit])
  650. end;
  651. { if l isn't in the range of def a range check error (if not explicit) is generated and
  652. the value is placed within the range }
  653. procedure testrange(def : tdef;var l : tconstexprint;explicit:boolean);
  654. var
  655. lv,hv: TConstExprInt;
  656. error: boolean;
  657. begin
  658. error := false;
  659. { for 64 bit types we need only to check if it is less than }
  660. { zero, if def is a qword node }
  661. if is_64bitint(def) then
  662. begin
  663. if (l<0) and (torddef(def).typ=u64bit) then
  664. begin
  665. { don't zero the result, because it may come from hex notation
  666. like $ffffffffffffffff! (JM)
  667. l:=0; }
  668. if not explicit then
  669. begin
  670. if (cs_check_range in aktlocalswitches) then
  671. Message(parser_e_range_check_error)
  672. else
  673. Message(parser_w_range_check_error);
  674. end;
  675. error := true;
  676. end;
  677. end
  678. else
  679. begin
  680. getrange(def,lv,hv);
  681. if (def.deftype=orddef) and
  682. (torddef(def).typ=u32bit) then
  683. begin
  684. if (l < cardinal(lv)) or
  685. (l > cardinal(hv)) then
  686. begin
  687. if not explicit then
  688. begin
  689. if (cs_check_range in aktlocalswitches) then
  690. Message(parser_e_range_check_error)
  691. else
  692. Message(parser_w_range_check_error);
  693. end;
  694. error := true;
  695. end;
  696. end
  697. else if (l<lv) or (l>hv) then
  698. begin
  699. if not explicit then
  700. begin
  701. if ((def.deftype=enumdef) and
  702. { delphi allows range check errors in
  703. enumeration type casts FK }
  704. not(m_delphi in aktmodeswitches)) or
  705. (cs_check_range in aktlocalswitches) then
  706. Message(parser_e_range_check_error)
  707. else
  708. Message(parser_w_range_check_error);
  709. end;
  710. error := true;
  711. end;
  712. end;
  713. if error then
  714. begin
  715. { Fix the value to fit in the allocated space for this type of variable }
  716. case def.size of
  717. 1: l := l and $ff;
  718. 2: l := l and $ffff;
  719. { work around sign extension bug (to be fixed) (JM) }
  720. 4: l := l and (int64($fffffff) shl 4 + $f);
  721. end;
  722. { do sign extension if necessary (JM) }
  723. if is_signed(def) then
  724. begin
  725. case def.size of
  726. 1: l := shortint(l);
  727. 2: l := smallint(l);
  728. 4: l := longint(l);
  729. end;
  730. end;
  731. end;
  732. end;
  733. { return the range from def in l and h }
  734. procedure getrange(def : tdef;var l : TConstExprInt;var h : TConstExprInt);
  735. begin
  736. case def.deftype of
  737. orddef :
  738. begin
  739. l:=torddef(def).low;
  740. h:=torddef(def).high;
  741. end;
  742. enumdef :
  743. begin
  744. l:=tenumdef(def).min;
  745. h:=tenumdef(def).max;
  746. end;
  747. arraydef :
  748. begin
  749. l:=tarraydef(def).lowrange;
  750. h:=tarraydef(def).highrange;
  751. end;
  752. else
  753. internalerror(987);
  754. end;
  755. end;
  756. function mmx_type(p : tdef) : tmmxtype;
  757. begin
  758. mmx_type:=mmxno;
  759. if is_mmx_able_array(p) then
  760. begin
  761. if tarraydef(p).elementtype.def.deftype=floatdef then
  762. case tfloatdef(tarraydef(p).elementtype.def).typ of
  763. s32real:
  764. mmx_type:=mmxsingle;
  765. end
  766. else
  767. case torddef(tarraydef(p).elementtype.def).typ of
  768. u8bit:
  769. mmx_type:=mmxu8bit;
  770. s8bit:
  771. mmx_type:=mmxs8bit;
  772. u16bit:
  773. mmx_type:=mmxu16bit;
  774. s16bit:
  775. mmx_type:=mmxs16bit;
  776. u32bit:
  777. mmx_type:=mmxu32bit;
  778. s32bit:
  779. mmx_type:=mmxs32bit;
  780. end;
  781. end;
  782. end;
  783. function is_mmx_able_array(p : tdef) : boolean;
  784. begin
  785. {$ifdef SUPPORT_MMX}
  786. if (cs_mmx_saturation in aktlocalswitches) then
  787. begin
  788. is_mmx_able_array:=(p.deftype=arraydef) and
  789. not(is_special_array(p)) and
  790. (
  791. (
  792. (tarraydef(p).elementtype.def.deftype=orddef) and
  793. (
  794. (
  795. (tarraydef(p).lowrange=0) and
  796. (tarraydef(p).highrange=1) and
  797. (torddef(tarraydef(p).elementtype.def).typ in [u32bit,s32bit])
  798. )
  799. or
  800. (
  801. (tarraydef(p).lowrange=0) and
  802. (tarraydef(p).highrange=3) and
  803. (torddef(tarraydef(p).elementtype.def).typ in [u16bit,s16bit])
  804. )
  805. )
  806. )
  807. or
  808. (
  809. (
  810. (tarraydef(p).elementtype.def.deftype=floatdef) and
  811. (
  812. (tarraydef(p).lowrange=0) and
  813. (tarraydef(p).highrange=1) and
  814. (tfloatdef(tarraydef(p).elementtype.def).typ=s32real)
  815. )
  816. )
  817. )
  818. );
  819. end
  820. else
  821. begin
  822. is_mmx_able_array:=(p.deftype=arraydef) and
  823. (
  824. (
  825. (tarraydef(p).elementtype.def.deftype=orddef) and
  826. (
  827. (
  828. (tarraydef(p).lowrange=0) and
  829. (tarraydef(p).highrange=1) and
  830. (torddef(tarraydef(p).elementtype.def).typ in [u32bit,s32bit])
  831. )
  832. or
  833. (
  834. (tarraydef(p).lowrange=0) and
  835. (tarraydef(p).highrange=3) and
  836. (torddef(tarraydef(p).elementtype.def).typ in [u16bit,s16bit])
  837. )
  838. or
  839. (
  840. (tarraydef(p).lowrange=0) and
  841. (tarraydef(p).highrange=7) and
  842. (torddef(tarraydef(p).elementtype.def).typ in [u8bit,s8bit])
  843. )
  844. )
  845. )
  846. or
  847. (
  848. (tarraydef(p).elementtype.def.deftype=floatdef) and
  849. (
  850. (tarraydef(p).lowrange=0) and
  851. (tarraydef(p).highrange=1) and
  852. (tfloatdef(tarraydef(p).elementtype.def).typ=s32real)
  853. )
  854. )
  855. );
  856. end;
  857. {$else SUPPORT_MMX}
  858. is_mmx_able_array:=false;
  859. {$endif SUPPORT_MMX}
  860. end;
  861. function is_equal(def1,def2 : tdef) : boolean;
  862. var
  863. b : boolean;
  864. hd : tdef;
  865. begin
  866. { both types must exists }
  867. if not (assigned(def1) and assigned(def2)) then
  868. begin
  869. is_equal:=false;
  870. exit;
  871. end;
  872. { be sure, that if there is a stringdef, that this is def1 }
  873. if def2.deftype=stringdef then
  874. begin
  875. hd:=def1;
  876. def1:=def2;
  877. def2:=hd;
  878. end;
  879. b:=false;
  880. { both point to the same definition ? }
  881. if def1=def2 then
  882. b:=true
  883. else
  884. { pointer with an equal definition are equal }
  885. if (def1.deftype=pointerdef) and (def2.deftype=pointerdef) then
  886. begin
  887. { check if both are farpointer }
  888. if (tpointerdef(def1).is_far=tpointerdef(def2).is_far) then
  889. begin
  890. { here a problem detected in tabsolutesym }
  891. { the types can be forward type !! }
  892. if assigned(def1.typesym) and (tpointerdef(def1).pointertype.def.deftype=forwarddef) then
  893. b:=(def1.typesym=def2.typesym)
  894. else
  895. b:=tpointerdef(def1).pointertype.def=tpointerdef(def2).pointertype.def;
  896. end
  897. else
  898. b:=false;
  899. end
  900. else
  901. { ordinals are equal only when the ordinal type is equal }
  902. if (def1.deftype=orddef) and (def2.deftype=orddef) then
  903. begin
  904. case torddef(def1).typ of
  905. u8bit,u16bit,u32bit,
  906. s8bit,s16bit,s32bit:
  907. b:=((torddef(def1).typ=torddef(def2).typ) and
  908. (torddef(def1).low=torddef(def2).low) and
  909. (torddef(def1).high=torddef(def2).high));
  910. uvoid,uchar,uwidechar,
  911. bool8bit,bool16bit,bool32bit:
  912. b:=(torddef(def1).typ=torddef(def2).typ);
  913. end;
  914. end
  915. else
  916. if (def1.deftype=floatdef) and (def2.deftype=floatdef) then
  917. b:=tfloatdef(def1).typ=tfloatdef(def2).typ
  918. else
  919. { strings with the same length are equal }
  920. if (def1.deftype=stringdef) and (def2.deftype=stringdef) and
  921. (tstringdef(def1).string_typ=tstringdef(def2).string_typ) then
  922. begin
  923. b:=not(is_shortstring(def1)) or
  924. (tstringdef(def1).len=tstringdef(def2).len);
  925. end
  926. else
  927. if (def1.deftype=formaldef) and (def2.deftype=formaldef) then
  928. b:=true
  929. { file types with the same file element type are equal }
  930. { this is a problem for assign !! }
  931. { changed to allow if one is untyped }
  932. { all typed files are equal to the special }
  933. { typed file that has voiddef as elemnt type }
  934. { but must NOT match for text file !!! }
  935. else
  936. if (def1.deftype=filedef) and (def2.deftype=filedef) then
  937. b:=(tfiledef(def1).filetyp=tfiledef(def2).filetyp) and
  938. ((
  939. ((tfiledef(def1).typedfiletype.def=nil) and
  940. (tfiledef(def2).typedfiletype.def=nil)) or
  941. (
  942. (tfiledef(def1).typedfiletype.def<>nil) and
  943. (tfiledef(def2).typedfiletype.def<>nil) and
  944. is_equal(tfiledef(def1).typedfiletype.def,tfiledef(def2).typedfiletype.def)
  945. ) or
  946. ( (tfiledef(def1).typedfiletype.def=tdef(voidtype.def)) or
  947. (tfiledef(def2).typedfiletype.def=tdef(voidtype.def))
  948. )))
  949. { sets with the same element base type are equal }
  950. else
  951. if (def1.deftype=setdef) and (def2.deftype=setdef) then
  952. begin
  953. if assigned(tsetdef(def1).elementtype.def) and
  954. assigned(tsetdef(def2).elementtype.def) then
  955. b:=is_subequal(tsetdef(def1).elementtype.def,tsetdef(def2).elementtype.def)
  956. else
  957. { empty set is compatible with everything }
  958. b:=true;
  959. end
  960. else
  961. if (def1.deftype=procvardef) and (def2.deftype=procvardef) then
  962. begin
  963. { poassembler isn't important for compatibility }
  964. { if a method is assigned to a methodpointer }
  965. { is checked before }
  966. b:=(tprocvardef(def1).proctypeoption=tprocvardef(def2).proctypeoption) and
  967. (tprocvardef(def1).proccalloption=tprocvardef(def2).proccalloption) and
  968. ((tprocvardef(def1).procoptions * po_compatibility_options)=
  969. (tprocvardef(def2).procoptions * po_compatibility_options)) and
  970. is_equal(tprocvardef(def1).rettype.def,tprocvardef(def2).rettype.def) and
  971. equal_paras(tprocvardef(def1).para,tprocvardef(def2).para,cp_all);
  972. end
  973. else
  974. if (def1.deftype=arraydef) and (def2.deftype=arraydef) then
  975. begin
  976. if is_dynamic_array(def1) and is_dynamic_array(def2) then
  977. b:=is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def)
  978. else
  979. if is_array_of_const(def1) or is_array_of_const(def2) then
  980. begin
  981. b:=(is_array_of_const(def1) and is_array_of_const(def2)) or
  982. (is_array_of_const(def1) and is_array_constructor(def2)) or
  983. (is_array_of_const(def2) and is_array_constructor(def1));
  984. end
  985. else
  986. if (is_dynamic_array(def1) or is_dynamic_array(def2)) then
  987. begin
  988. b := is_dynamic_array(def1) and is_dynamic_array(def2) and
  989. is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def);
  990. end
  991. else
  992. if is_open_array(def1) or is_open_array(def2) then
  993. begin
  994. b:=is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def);
  995. end
  996. else
  997. begin
  998. b:=not(m_tp7 in aktmodeswitches) and
  999. not(m_delphi in aktmodeswitches) and
  1000. (tarraydef(def1).lowrange=tarraydef(def2).lowrange) and
  1001. (tarraydef(def1).highrange=tarraydef(def2).highrange) and
  1002. is_equal(tarraydef(def1).elementtype.def,tarraydef(def2).elementtype.def) and
  1003. is_equal(tarraydef(def1).rangetype.def,tarraydef(def2).rangetype.def);
  1004. end;
  1005. end
  1006. else
  1007. if (def1.deftype=classrefdef) and (def2.deftype=classrefdef) then
  1008. begin
  1009. { similar to pointerdef: }
  1010. if assigned(def1.typesym) and (tclassrefdef(def1).pointertype.def.deftype=forwarddef) then
  1011. b:=(def1.typesym=def2.typesym)
  1012. else
  1013. b:=is_equal(tclassrefdef(def1).pointertype.def,tclassrefdef(def2).pointertype.def);
  1014. end;
  1015. is_equal:=b;
  1016. end;
  1017. function is_subequal(def1, def2: tdef): boolean;
  1018. var
  1019. basedef1,basedef2 : tenumdef;
  1020. Begin
  1021. is_subequal := false;
  1022. if assigned(def1) and assigned(def2) then
  1023. Begin
  1024. if (def1.deftype = orddef) and (def2.deftype = orddef) then
  1025. Begin
  1026. { see p.47 of Turbo Pascal 7.01 manual for the separation of types }
  1027. { range checking for case statements is done with testrange }
  1028. case torddef(def1).typ of
  1029. u8bit,u16bit,u32bit,
  1030. s8bit,s16bit,s32bit,s64bit,u64bit :
  1031. is_subequal:=(torddef(def2).typ in [s64bit,u64bit,s32bit,u32bit,u8bit,s8bit,s16bit,u16bit]);
  1032. bool8bit,bool16bit,bool32bit :
  1033. is_subequal:=(torddef(def2).typ in [bool8bit,bool16bit,bool32bit]);
  1034. uchar :
  1035. is_subequal:=(torddef(def2).typ=uchar);
  1036. uwidechar :
  1037. is_subequal:=(torddef(def2).typ=uwidechar);
  1038. end;
  1039. end
  1040. else
  1041. Begin
  1042. { I assume that both enumerations are equal when the first }
  1043. { pointers are equal. }
  1044. { I changed this to assume that the enums are equal }
  1045. { if the basedefs are equal (FK) }
  1046. if (def1.deftype=enumdef) and (def2.deftype=enumdef) then
  1047. Begin
  1048. { get both basedefs }
  1049. basedef1:=tenumdef(def1);
  1050. while assigned(basedef1.basedef) do
  1051. basedef1:=basedef1.basedef;
  1052. basedef2:=tenumdef(def2);
  1053. while assigned(basedef2.basedef) do
  1054. basedef2:=basedef2.basedef;
  1055. is_subequal:=basedef1=basedef2;
  1056. {
  1057. if tenumdef(def1).firstenum = tenumdef(def2).firstenum then
  1058. is_subequal := TRUE;
  1059. }
  1060. end;
  1061. end;
  1062. end; { endif assigned ... }
  1063. end;
  1064. (* function assignment_overloaded(from_def,to_def : tdef) : tprocdef;
  1065. var
  1066. passprocs : pprocdeflist;
  1067. convtyp : tconverttype;
  1068. begin
  1069. assignment_overloaded:=nil;
  1070. if not assigned(overloaded_operators[_ASSIGNMENT]) then
  1071. exit;
  1072. { look for an exact match first }
  1073. passprocs:=overloaded_operators[_ASSIGNMENT].defs;
  1074. while assigned(passprocs) do
  1075. begin
  1076. if is_equal(passprocs^.def.rettype.def,to_def) and
  1077. (TParaItem(passprocs^.def.Para.first).paratype.def=from_def) then
  1078. begin
  1079. assignment_overloaded:=passprocs^.def;
  1080. exit;
  1081. end;
  1082. passprocs:=passprocs^.next;
  1083. end;
  1084. { .... then look for an equal match }
  1085. passprocs:=overloaded_operators[_ASSIGNMENT].defs;
  1086. while assigned(passprocs) do
  1087. begin
  1088. if is_equal(passprocs^.def.rettype.def,to_def) and
  1089. is_equal(TParaItem(passprocs^.def.Para.first).paratype.def,from_def) then
  1090. begin
  1091. assignment_overloaded:=passprocs^.def;
  1092. exit;
  1093. end;
  1094. passprocs:=passprocs^.next;
  1095. end;
  1096. { .... then for convert level 1 }
  1097. passprocs:=overloaded_operators[_ASSIGNMENT].defs;
  1098. while assigned(passprocs) do
  1099. begin
  1100. if is_equal(passprocs^.def.rettype.def,to_def) and
  1101. (isconvertable(from_def,TParaItem(passprocs^.def.Para.first).paratype.def,convtyp,ordconstn,false)=1) then
  1102. begin
  1103. assignment_overloaded:=passprocs^.def;
  1104. exit;
  1105. end;
  1106. passprocs:=passprocs^.next;
  1107. end;
  1108. end;
  1109. *)
  1110. function assignment_overloaded(from_def,to_def : tdef) : tprocdef;
  1111. begin
  1112. assignment_overloaded:=nil;
  1113. if not assigned(overloaded_operators[_ASSIGNMENT]) then
  1114. exit;
  1115. { look for an exact match first }
  1116. assignment_overloaded:=overloaded_operators[_ASSIGNMENT].
  1117. search_procdef_byretdef_by1paradef(to_def,from_def,dm_exact);
  1118. if assigned(assignment_overloaded) then
  1119. exit;
  1120. { .... then look for an equal match }
  1121. assignment_overloaded:=overloaded_operators[_ASSIGNMENT].
  1122. search_procdef_byretdef_by1paradef(to_def,from_def,dm_equal);
  1123. if assigned(assignment_overloaded) then
  1124. exit;
  1125. { .... then for convert level 1 }
  1126. assignment_overloaded:=overloaded_operators[_ASSIGNMENT].
  1127. search_procdef_byretdef_by1paradef(to_def,from_def,dm_convertl1);
  1128. end;
  1129. { Returns:
  1130. 0 - Not convertable
  1131. 1 - Convertable
  1132. 2 - Convertable, but not first choice }
  1133. function isconvertable(def_from,def_to : tdef;
  1134. var doconv : tconverttype;
  1135. fromtreetype : tnodetype;
  1136. explicit : boolean) : byte;
  1137. { Tbasetype:
  1138. uvoid,
  1139. u8bit,u16bit,u32bit,u64bit,
  1140. s8bit,s16bit,s32bit,s64bit,
  1141. bool8bit,bool16bit,bool32bit,
  1142. uchar,uwidechar }
  1143. type
  1144. tbasedef=(bvoid,bchar,bint,bbool);
  1145. const
  1146. basedeftbl:array[tbasetype] of tbasedef =
  1147. (bvoid,
  1148. bint,bint,bint,bint,
  1149. bint,bint,bint,bint,
  1150. bbool,bbool,bbool,
  1151. bchar,bchar);
  1152. basedefconverts : array[tbasedef,tbasedef] of tconverttype =
  1153. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  1154. (tc_not_possible,tc_char_2_char,tc_not_possible,tc_not_possible),
  1155. (tc_not_possible,tc_not_possible,tc_int_2_int,tc_int_2_bool),
  1156. (tc_not_possible,tc_not_possible,tc_bool_2_int,tc_bool_2_bool));
  1157. var
  1158. b : byte;
  1159. hd1,hd2 : tdef;
  1160. hct : tconverttype;
  1161. begin
  1162. { safety check }
  1163. if not(assigned(def_from) and assigned(def_to)) then
  1164. begin
  1165. isconvertable:=0;
  1166. exit;
  1167. end;
  1168. { tp7 procvar def support, in tp7 a procvar is always called, if the
  1169. procvar is passed explicit a addrn would be there }
  1170. if (m_tp_procvar in aktmodeswitches) and
  1171. (def_from.deftype=procvardef) and
  1172. (fromtreetype=loadn) and
  1173. { only if the procvar doesn't require any paramters }
  1174. (tprocvardef(def_from).minparacount = 0) then
  1175. begin
  1176. def_from:=tprocvardef(def_from).rettype.def;
  1177. end;
  1178. { we walk the wanted (def_to) types and check then the def_from
  1179. types if there is a conversion possible }
  1180. b:=0;
  1181. case def_to.deftype of
  1182. orddef :
  1183. begin
  1184. case def_from.deftype of
  1185. orddef :
  1186. begin
  1187. doconv:=basedefconverts[basedeftbl[torddef(def_from).typ],basedeftbl[torddef(def_to).typ]];
  1188. b:=1;
  1189. if (doconv=tc_not_possible) or
  1190. ((doconv=tc_int_2_bool) and
  1191. (not explicit) and
  1192. (not is_boolean(def_from))) or
  1193. ((doconv=tc_bool_2_int) and
  1194. (not explicit) and
  1195. (not is_boolean(def_to))) then
  1196. b:=0
  1197. else
  1198. { "punish" bad type conversions :) (JM) }
  1199. if not is_in_limit(def_from,def_to) and
  1200. (def_from.size > def_to.size) then
  1201. b := 2;
  1202. end;
  1203. enumdef :
  1204. begin
  1205. { needed for char(enum) }
  1206. if explicit then
  1207. begin
  1208. doconv:=tc_int_2_int;
  1209. b:=1;
  1210. end;
  1211. end;
  1212. end;
  1213. end;
  1214. stringdef :
  1215. begin
  1216. case def_from.deftype of
  1217. stringdef :
  1218. begin
  1219. doconv:=tc_string_2_string;
  1220. b:=1;
  1221. end;
  1222. orddef :
  1223. begin
  1224. { char to string}
  1225. if is_char(def_from) or
  1226. is_widechar(def_from) then
  1227. begin
  1228. doconv:=tc_char_2_string;
  1229. b:=1;
  1230. end;
  1231. end;
  1232. arraydef :
  1233. begin
  1234. { array of char to string, the length check is done by the firstpass of this node }
  1235. if is_chararray(def_from) or
  1236. (is_equal(tarraydef(def_from).elementtype.def,cchartype.def) and
  1237. is_open_array(def_from)) then
  1238. begin
  1239. doconv:=tc_chararray_2_string;
  1240. if is_open_array(def_from) or
  1241. (is_shortstring(def_to) and
  1242. (def_from.size <= 255)) or
  1243. (is_ansistring(def_to) and
  1244. (def_from.size > 255)) then
  1245. b:=1
  1246. else
  1247. b:=2;
  1248. end;
  1249. end;
  1250. pointerdef :
  1251. begin
  1252. { pchar can be assigned to short/ansistrings,
  1253. but not in tp7 compatible mode }
  1254. if is_pchar(def_from) and not(m_tp7 in aktmodeswitches) then
  1255. begin
  1256. doconv:=tc_pchar_2_string;
  1257. { trefer ansistrings because pchars can overflow shortstrings, }
  1258. { but only if ansistrings are the default (JM) }
  1259. if (is_shortstring(def_to) and
  1260. not(cs_ansistrings in aktlocalswitches)) or
  1261. (is_ansistring(def_to) and
  1262. (cs_ansistrings in aktlocalswitches)) then
  1263. b:=1
  1264. else
  1265. b:=2;
  1266. end;
  1267. end;
  1268. end;
  1269. end;
  1270. floatdef :
  1271. begin
  1272. case def_from.deftype of
  1273. orddef :
  1274. begin { ordinal to real }
  1275. if is_integer(def_from) then
  1276. begin
  1277. doconv:=tc_int_2_real;
  1278. b:=1;
  1279. end;
  1280. end;
  1281. floatdef :
  1282. begin { 2 float types ? }
  1283. if tfloatdef(def_from).typ=tfloatdef(def_to).typ then
  1284. doconv:=tc_equal
  1285. else
  1286. doconv:=tc_real_2_real;
  1287. b:=1;
  1288. end;
  1289. end;
  1290. end;
  1291. enumdef :
  1292. begin
  1293. if (def_from.deftype=enumdef) then
  1294. begin
  1295. if explicit then
  1296. begin
  1297. b:=1;
  1298. doconv:=tc_int_2_int;
  1299. end
  1300. else
  1301. begin
  1302. hd1:=def_from;
  1303. while assigned(tenumdef(hd1).basedef) do
  1304. hd1:=tenumdef(hd1).basedef;
  1305. hd2:=def_to;
  1306. while assigned(tenumdef(hd2).basedef) do
  1307. hd2:=tenumdef(hd2).basedef;
  1308. if (hd1=hd2) then
  1309. begin
  1310. b:=1;
  1311. { because of packenum they can have different sizes! (JM) }
  1312. doconv:=tc_int_2_int;
  1313. end;
  1314. end;
  1315. end;
  1316. end;
  1317. arraydef :
  1318. begin
  1319. { open array is also compatible with a single element of its base type }
  1320. if is_open_array(def_to) and
  1321. is_equal(tarraydef(def_to).elementtype.def,def_from) then
  1322. begin
  1323. doconv:=tc_equal;
  1324. b:=1;
  1325. end
  1326. else
  1327. begin
  1328. case def_from.deftype of
  1329. arraydef :
  1330. begin
  1331. { array constructor -> open array }
  1332. if is_open_array(def_to) and
  1333. is_array_constructor(def_from) then
  1334. begin
  1335. if is_void(tarraydef(def_from).elementtype.def) or
  1336. is_equal(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  1337. begin
  1338. doconv:=tc_equal;
  1339. b:=1;
  1340. end
  1341. else
  1342. if isconvertable(tarraydef(def_from).elementtype.def,
  1343. tarraydef(def_to).elementtype.def,hct,arrayconstructorn,false)<>0 then
  1344. begin
  1345. doconv:=hct;
  1346. b:=2;
  1347. end;
  1348. end
  1349. else
  1350. { dynamic array -> open array }
  1351. if is_dynamic_array(def_from) and
  1352. is_open_array(def_to) and
  1353. is_equal(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  1354. begin
  1355. doconv := tc_dynarray_2_openarray;
  1356. b := 2;
  1357. end
  1358. else
  1359. { array of tvarrec -> array of const }
  1360. if is_array_of_const(def_to) and
  1361. is_equal(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  1362. begin
  1363. doconv:=tc_equal;
  1364. b:=1;
  1365. end;
  1366. end;
  1367. pointerdef :
  1368. begin
  1369. if is_zero_based_array(def_to) and
  1370. is_equal(tpointerdef(def_from).pointertype.def,tarraydef(def_to).elementtype.def) then
  1371. begin
  1372. doconv:=tc_pointer_2_array;
  1373. b:=1;
  1374. end;
  1375. end;
  1376. stringdef :
  1377. begin
  1378. { string to char array }
  1379. if (not is_special_array(def_to)) and
  1380. is_char(tarraydef(def_to).elementtype.def) then
  1381. begin
  1382. doconv:=tc_string_2_chararray;
  1383. b:=1;
  1384. end;
  1385. end;
  1386. orddef:
  1387. begin
  1388. if is_chararray(def_to) and
  1389. is_char(def_from) then
  1390. begin
  1391. doconv:=tc_char_2_chararray;
  1392. b:=2;
  1393. end;
  1394. end;
  1395. recorddef :
  1396. begin
  1397. { tvarrec -> array of constconst }
  1398. if is_array_of_const(def_to) and
  1399. is_equal(def_from,tarraydef(def_to).elementtype.def) then
  1400. begin
  1401. doconv:=tc_equal;
  1402. b:=1;
  1403. end;
  1404. end;
  1405. end;
  1406. end;
  1407. end;
  1408. pointerdef :
  1409. begin
  1410. case def_from.deftype of
  1411. stringdef :
  1412. begin
  1413. { string constant (which can be part of array constructor)
  1414. to zero terminated string constant }
  1415. if (fromtreetype in [arrayconstructorn,stringconstn]) and
  1416. is_pchar(def_to) or is_pwidechar(def_to) then
  1417. begin
  1418. doconv:=tc_cstring_2_pchar;
  1419. b:=1;
  1420. end;
  1421. end;
  1422. orddef :
  1423. begin
  1424. { char constant to zero terminated string constant }
  1425. if (fromtreetype=ordconstn) then
  1426. begin
  1427. if is_equal(def_from,cchartype.def) and
  1428. is_pchar(def_to) then
  1429. begin
  1430. doconv:=tc_cchar_2_pchar;
  1431. b:=1;
  1432. end
  1433. else
  1434. if is_integer(def_from) then
  1435. begin
  1436. doconv:=tc_cord_2_pointer;
  1437. b:=1;
  1438. end;
  1439. end;
  1440. end;
  1441. arraydef :
  1442. begin
  1443. { chararray to pointer }
  1444. if is_zero_based_array(def_from) and
  1445. is_equal(tarraydef(def_from).elementtype.def,tpointerdef(def_to).pointertype.def) then
  1446. begin
  1447. doconv:=tc_array_2_pointer;
  1448. b:=1;
  1449. end;
  1450. end;
  1451. pointerdef :
  1452. begin
  1453. { child class pointer can be assigned to anchestor pointers }
  1454. if (
  1455. (tpointerdef(def_from).pointertype.def.deftype=objectdef) and
  1456. (tpointerdef(def_to).pointertype.def.deftype=objectdef) and
  1457. tobjectdef(tpointerdef(def_from).pointertype.def).is_related(
  1458. tobjectdef(tpointerdef(def_to).pointertype.def))
  1459. ) or
  1460. { all pointers can be assigned to void-pointer }
  1461. is_equal(tpointerdef(def_to).pointertype.def,voidtype.def) or
  1462. { in my opnion, is this not clean pascal }
  1463. { well, but it's handy to use, it isn't ? (FK) }
  1464. is_equal(tpointerdef(def_from).pointertype.def,voidtype.def) then
  1465. begin
  1466. { but don't allow conversion between farpointer-pointer }
  1467. if (tpointerdef(def_to).is_far=tpointerdef(def_from).is_far) then
  1468. begin
  1469. doconv:=tc_equal;
  1470. b:=1;
  1471. end;
  1472. end;
  1473. end;
  1474. procvardef :
  1475. begin
  1476. { procedure variable can be assigned to an void pointer }
  1477. { Not anymore. Use the @ operator now.}
  1478. if not(m_tp_procvar in aktmodeswitches) and
  1479. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  1480. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  1481. begin
  1482. doconv:=tc_equal;
  1483. b:=1;
  1484. end;
  1485. end;
  1486. classrefdef,
  1487. objectdef :
  1488. begin
  1489. { class types and class reference type
  1490. can be assigned to void pointers }
  1491. if (
  1492. is_class_or_interface(def_from) or
  1493. (def_from.deftype=classrefdef)
  1494. ) and
  1495. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  1496. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  1497. begin
  1498. doconv:=tc_equal;
  1499. b:=1;
  1500. end;
  1501. end;
  1502. end;
  1503. end;
  1504. setdef :
  1505. begin
  1506. { automatic arrayconstructor -> set conversion }
  1507. if is_array_constructor(def_from) then
  1508. begin
  1509. doconv:=tc_arrayconstructor_2_set;
  1510. b:=1;
  1511. end;
  1512. end;
  1513. procvardef :
  1514. begin
  1515. { proc -> procvar }
  1516. if (def_from.deftype=procdef) and
  1517. (m_tp_procvar in aktmodeswitches) then
  1518. begin
  1519. doconv:=tc_proc_2_procvar;
  1520. if proc_to_procvar_equal(tprocdef(def_from),tprocvardef(def_to),false) then
  1521. b:=1;
  1522. end
  1523. { procvar -> procvar }
  1524. else
  1525. if (def_from.deftype=procvardef) and
  1526. (proc_to_procvar_equal(tprocvardef(def_from),tprocvardef(def_to),false)) then
  1527. begin
  1528. doconv:=tc_equal;
  1529. b := 2;
  1530. end
  1531. else
  1532. { for example delphi allows the assignement from pointers }
  1533. { to procedure variables }
  1534. if (m_pointer_2_procedure in aktmodeswitches) and
  1535. (def_from.deftype=pointerdef) and
  1536. (tpointerdef(def_from).pointertype.def.deftype=orddef) and
  1537. (torddef(tpointerdef(def_from).pointertype.def).typ=uvoid) then
  1538. begin
  1539. doconv:=tc_equal;
  1540. b:=1;
  1541. end
  1542. else
  1543. { nil is compatible with procvars }
  1544. if (fromtreetype=niln) then
  1545. begin
  1546. doconv:=tc_equal;
  1547. b:=1;
  1548. end;
  1549. end;
  1550. objectdef :
  1551. begin
  1552. { object pascal objects }
  1553. if (def_from.deftype=objectdef) and
  1554. tobjectdef(def_from).is_related(tobjectdef(def_to)) then
  1555. begin
  1556. doconv:=tc_equal;
  1557. b:=1;
  1558. end
  1559. else
  1560. { Class/interface specific }
  1561. if is_class_or_interface(def_to) then
  1562. begin
  1563. { void pointer also for delphi mode }
  1564. if (m_delphi in aktmodeswitches) and
  1565. is_voidpointer(def_from) then
  1566. begin
  1567. doconv:=tc_equal;
  1568. b:=1;
  1569. end
  1570. else
  1571. { nil is compatible with class instances and interfaces }
  1572. if (fromtreetype=niln) then
  1573. begin
  1574. doconv:=tc_equal;
  1575. b:=1;
  1576. end
  1577. { classes can be assigned to interfaces }
  1578. else if is_interface(def_to) and
  1579. is_class(def_from) and
  1580. assigned(tobjectdef(def_from).implementedinterfaces) and
  1581. (tobjectdef(def_from).implementedinterfaces.searchintf(def_to)<>-1) then
  1582. begin
  1583. doconv:=tc_class_2_intf;
  1584. b:=1;
  1585. end
  1586. { Interface 2 GUID handling }
  1587. else if (def_to=tdef(rec_tguid)) and
  1588. (fromtreetype=typen) and
  1589. is_interface(def_from) and
  1590. tobjectdef(def_from).isiidguidvalid then
  1591. begin
  1592. b:=1;
  1593. doconv:=tc_equal;
  1594. end;
  1595. end;
  1596. end;
  1597. classrefdef :
  1598. begin
  1599. { class reference types }
  1600. if (def_from.deftype=classrefdef) then
  1601. begin
  1602. doconv:=tc_equal;
  1603. if tobjectdef(tclassrefdef(def_from).pointertype.def).is_related(
  1604. tobjectdef(tclassrefdef(def_to).pointertype.def)) then
  1605. b:=1;
  1606. end
  1607. else
  1608. { nil is compatible with class references }
  1609. if (fromtreetype=niln) then
  1610. begin
  1611. doconv:=tc_equal;
  1612. b:=1;
  1613. end;
  1614. end;
  1615. filedef :
  1616. begin
  1617. { typed files are all equal to the abstract file type
  1618. name TYPEDFILE in system.pp in is_equal in types.pas
  1619. the problem is that it sholud be also compatible to FILE
  1620. but this would leed to a problem for ASSIGN RESET and REWRITE
  1621. when trying to find the good overloaded function !!
  1622. so all file function are doubled in system.pp
  1623. this is not very beautiful !!}
  1624. if (def_from.deftype=filedef) and
  1625. (
  1626. (
  1627. (tfiledef(def_from).filetyp = ft_typed) and
  1628. (tfiledef(def_to).filetyp = ft_typed) and
  1629. (
  1630. (tfiledef(def_from).typedfiletype.def = tdef(voidtype.def)) or
  1631. (tfiledef(def_to).typedfiletype.def = tdef(voidtype.def))
  1632. )
  1633. ) or
  1634. (
  1635. (
  1636. (tfiledef(def_from).filetyp = ft_untyped) and
  1637. (tfiledef(def_to).filetyp = ft_typed)
  1638. ) or
  1639. (
  1640. (tfiledef(def_from).filetyp = ft_typed) and
  1641. (tfiledef(def_to).filetyp = ft_untyped)
  1642. )
  1643. )
  1644. ) then
  1645. begin
  1646. doconv:=tc_equal;
  1647. b:=1;
  1648. end
  1649. end;
  1650. recorddef :
  1651. begin
  1652. { interface -> guid }
  1653. if is_interface(def_from) and
  1654. (def_to=rec_tguid) then
  1655. begin
  1656. doconv:=tc_intf_2_guid;
  1657. b:=1;
  1658. end
  1659. else
  1660. begin
  1661. { assignment overwritten ?? }
  1662. if assignment_overloaded(def_from,def_to)<>nil then
  1663. b:=2;
  1664. end;
  1665. end;
  1666. else
  1667. begin
  1668. { assignment overwritten ?? }
  1669. if assignment_overloaded(def_from,def_to)<>nil then
  1670. b:=2;
  1671. end;
  1672. end;
  1673. isconvertable:=b;
  1674. end;
  1675. function CheckTypes(def1,def2 : tdef) : boolean;
  1676. var
  1677. s1,s2 : string;
  1678. begin
  1679. if not is_equal(def1,def2) then
  1680. begin
  1681. { Crash prevention }
  1682. if (not assigned(def1)) or (not assigned(def2)) then
  1683. Message(type_e_mismatch)
  1684. else
  1685. begin
  1686. s1:=def1.typename;
  1687. s2:=def2.typename;
  1688. if (s1<>'<unknown type>') and (s2<>'<unknown type>') then
  1689. Message2(type_e_not_equal_types,def1.typename,def2.typename)
  1690. else
  1691. Message(type_e_mismatch);
  1692. end;
  1693. CheckTypes:=false;
  1694. end
  1695. else
  1696. CheckTypes:=true;
  1697. end;
  1698. end.
  1699. {
  1700. $Log$
  1701. Revision 1.2 2002-07-23 09:51:22 daniel
  1702. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  1703. are worth comitting.
  1704. Revision 1.1 2002/07/20 11:57:53 florian
  1705. * types.pas renamed to defbase.pas because D6 contains a types
  1706. unit so this would conflicts if D6 programms are compiled
  1707. + Willamette/SSE2 instructions to assembler added
  1708. Revision 1.75 2002/07/11 14:41:32 florian
  1709. * start of the new generic parameter handling
  1710. Revision 1.74 2002/07/01 16:23:54 peter
  1711. * cg64 patch
  1712. * basics for currency
  1713. * asnode updates for class and interface (not finished)
  1714. Revision 1.73 2002/05/18 13:34:21 peter
  1715. * readded missing revisions
  1716. Revision 1.72 2002/05/16 19:46:47 carl
  1717. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1718. + try to fix temp allocation (still in ifdef)
  1719. + generic constructor calls
  1720. + start of tassembler / tmodulebase class cleanup
  1721. Revision 1.70 2002/05/12 16:53:16 peter
  1722. * moved entry and exitcode to ncgutil and cgobj
  1723. * foreach gets extra argument for passing local data to the
  1724. iterator function
  1725. * -CR checks also class typecasts at runtime by changing them
  1726. into as
  1727. * fixed compiler to cycle with the -CR option
  1728. * fixed stabs with elf writer, finally the global variables can
  1729. be watched
  1730. * removed a lot of routines from cga unit and replaced them by
  1731. calls to cgobj
  1732. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1733. u32bit then the other is typecasted also to u32bit without giving
  1734. a rangecheck warning/error.
  1735. * fixed pascal calling method with reversing also the high tree in
  1736. the parast, detected by tcalcst3 test
  1737. Revision 1.69 2002/04/25 20:16:39 peter
  1738. * moved more routines from cga/n386util
  1739. Revision 1.68 2002/04/15 19:08:22 carl
  1740. + target_info.size_of_pointer -> pointer_size
  1741. + some cleanup of unused types/variables
  1742. Revision 1.67 2002/04/07 13:40:29 carl
  1743. + update documentation
  1744. Revision 1.66 2002/04/02 17:11:32 peter
  1745. * tlocation,treference update
  1746. * LOC_CONSTANT added for better constant handling
  1747. * secondadd splitted in multiple routines
  1748. * location_force_reg added for loading a location to a register
  1749. of a specified size
  1750. * secondassignment parses now first the right and then the left node
  1751. (this is compatible with Kylix). This saves a lot of push/pop especially
  1752. with string operations
  1753. * adapted some routines to use the new cg methods
  1754. Revision 1.65 2002/04/01 20:57:14 jonas
  1755. * fixed web bug 1907
  1756. * fixed some other procvar related bugs (all related to accepting procvar
  1757. constructs with either too many or too little parameters)
  1758. (both merged, includes second typo fix of pexpr.pas)
  1759. Revision 1.64 2002/01/24 18:25:53 peter
  1760. * implicit result variable generation for assembler routines
  1761. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1762. Revision 1.63 2002/01/24 12:33:53 jonas
  1763. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1764. longer longint($ffffffff), but just $fffffff in psystem)
  1765. * small additional fix in 64bit rangecheck code generation for 32 bit
  1766. processors
  1767. * adaption of ranges required the matching talgorithm used for selecting
  1768. which overloaded procedure to call to be adapted. It should now always
  1769. select the closest match for ordinal parameters.
  1770. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1771. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1772. fixes were required to be able to add them)
  1773. * is_in_limit() moved from ncal to types unit, should always be used
  1774. instead of direct comparisons of low/high values of orddefs because
  1775. qword is a special case
  1776. Revision 1.62 2002/01/06 21:50:44 peter
  1777. * proc_to_procvar_equal fixed for procvar-procvar
  1778. Revision 1.61 2002/01/06 12:08:16 peter
  1779. * removed uauto from orddef, use new range_to_basetype generating
  1780. the correct ordinal type for a range
  1781. }