defbase.pas 72 KB

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