defutil.pas 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. {
  2. Copyright (c) 1998-2006 by Florian Klaempfl
  3. This unit provides some help routines for type handling
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit defutil;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,globals,constexp,
  22. symconst,symtype,symdef,
  23. cgbase,cpubase;
  24. type
  25. tmmxtype = (mmxno,mmxu8bit,mmxs8bit,mmxu16bit,mmxs16bit,
  26. mmxu32bit,mmxs32bit,mmxfixed16,mmxsingle);
  27. {*****************************************************************************
  28. Basic type functions
  29. *****************************************************************************}
  30. {# Returns true, if definition defines an ordinal type }
  31. function is_ordinal(def : tdef) : boolean;
  32. {# Returns true, if definition defines a string type }
  33. function is_string(def : tdef): boolean;
  34. {# Returns True, if definition defines a type that behaves like a string,
  35. namely that can be joined and compared with another string-like type }
  36. function is_stringlike(def : tdef) : boolean;
  37. {# Returns True, if definition defines an enumeration type }
  38. function is_enum(def : tdef) : boolean;
  39. {# Returns True, if definition defines a set type }
  40. function is_set(def : tdef) : boolean;
  41. {# Returns the minimal integer value of the type }
  42. function get_min_value(def : tdef) : TConstExprInt;
  43. {# Returns the maximal integer value of the type }
  44. function get_max_value(def : tdef) : TConstExprInt;
  45. {# Returns basetype of the specified integer range }
  46. function range_to_basetype(l,h:TConstExprInt):tordtype;
  47. procedure range_to_type(l,h:TConstExprInt;var def:tdef);
  48. procedure int_to_type(v:TConstExprInt;var def:tdef);
  49. {# Returns true, if definition defines an integer type }
  50. function is_integer(def : tdef) : boolean;
  51. {# Returns true if definition is a boolean }
  52. function is_boolean(def : tdef) : boolean;
  53. {# Returns true if definition is a Pascal-style boolean (1 = true, zero = false) }
  54. function is_pasbool(def : tdef) : boolean;
  55. {# Returns true if definition is a C-style boolean (non-zero value = true, zero = false) }
  56. function is_cbool(def : tdef) : boolean;
  57. {# Returns true if definition is a char
  58. This excludes the unicode char.
  59. }
  60. function is_char(def : tdef) : boolean;
  61. {# Returns true if definition is a widechar }
  62. function is_widechar(def : tdef) : boolean;
  63. {# Returns true if definition is either an AnsiChar or a WideChar }
  64. function is_anychar(def : tdef) : boolean;
  65. {# Returns true if definition is a void}
  66. function is_void(def : tdef) : boolean;
  67. {# Returns true if definition is a smallset}
  68. function is_smallset(p : tdef) : boolean;
  69. {# Returns true, if def defines a signed data type
  70. (only for ordinal types)
  71. }
  72. function is_signed(def : tdef) : boolean;
  73. {# Returns whether def_from's range is comprised in def_to's if both are
  74. orddefs, false otherwise }
  75. function is_in_limit(def_from,def_to : tdef) : boolean;
  76. {# Returns whether def is reference counted }
  77. function is_managed_type(def: tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
  78. { function is_in_limit_value(val_from:TConstExprInt;def_from,def_to : tdef) : boolean;}
  79. {*****************************************************************************
  80. Array helper functions
  81. *****************************************************************************}
  82. {# Returns true, if p points to a zero based (non special like open or
  83. dynamic array def).
  84. This is mainly used to see if the array
  85. is convertable to a pointer
  86. }
  87. function is_zero_based_array(p : tdef) : boolean;
  88. {# Returns true if p points to an open array definition }
  89. function is_open_array(p : tdef) : boolean;
  90. {# Returns true if p points to a dynamic array definition }
  91. function is_dynamic_array(p : tdef) : boolean;
  92. {# Returns true, if p points to an array of const definition }
  93. function is_array_constructor(p : tdef) : boolean;
  94. {# Returns true, if p points to a variant array }
  95. function is_variant_array(p : tdef) : boolean;
  96. {# Returns true, if p points to an array of const }
  97. function is_array_of_const(p : tdef) : boolean;
  98. {# Returns true, if p points any kind of special array
  99. That is if the array is an open array, a variant
  100. array, an array constants constructor, or an
  101. array of const.
  102. Bitpacked arrays aren't special in this regard though.
  103. }
  104. function is_special_array(p : tdef) : boolean;
  105. {# Returns true if p is a bitpacked array }
  106. function is_packed_array(p: tdef) : boolean;
  107. {# Returns true if p is a bitpacked record }
  108. function is_packed_record_or_object(p: tdef) : boolean;
  109. {# Returns true if p is a char array def }
  110. function is_chararray(p : tdef) : boolean;
  111. {# Returns true if p is a wide char array def }
  112. function is_widechararray(p : tdef) : boolean;
  113. {# Returns true if p is a open char array def }
  114. function is_open_chararray(p : tdef) : boolean;
  115. {# Returns true if p is a open wide char array def }
  116. function is_open_widechararray(p : tdef) : boolean;
  117. {*****************************************************************************
  118. String helper functions
  119. *****************************************************************************}
  120. {# Returns true if p points to an open string type }
  121. function is_open_string(p : tdef) : boolean;
  122. {# Returns true if p is an ansi string type }
  123. function is_ansistring(p : tdef) : boolean;
  124. {# Returns true if p is an ansi string type with codepage 0 }
  125. function is_rawbytestring(p : tdef) : boolean;
  126. {# Returns true if p is a long string type }
  127. function is_longstring(p : tdef) : boolean;
  128. {# returns true if p is a wide string type }
  129. function is_widestring(p : tdef) : boolean;
  130. {# true if p is an unicode string def }
  131. function is_unicodestring(p : tdef) : boolean;
  132. {# true if p is an unicode/wide/ansistring string def }
  133. function is_dynamicstring(p : tdef) : boolean;
  134. {# returns true if p is a wide or unicode string type }
  135. function is_wide_or_unicode_string(p : tdef) : boolean;
  136. {# Returns true if p is a short string type }
  137. function is_shortstring(p : tdef) : boolean;
  138. {# Returns true if p is a pchar def }
  139. function is_pchar(p : tdef) : boolean;
  140. {# Returns true if p is a pwidechar def }
  141. function is_pwidechar(p : tdef) : boolean;
  142. {# Returns true if p is a voidpointer def }
  143. function is_voidpointer(p : tdef) : boolean;
  144. {# Returns true, if definition is a float }
  145. function is_fpu(def : tdef) : boolean;
  146. {# Returns true, if def is a currency type }
  147. function is_currency(def : tdef) : boolean;
  148. {# Returns true, if def is a single type }
  149. function is_single(def : tdef) : boolean;
  150. {# Returns true, if def is a double type }
  151. function is_double(def : tdef) : boolean;
  152. {# Returns true, if def is an extended type }
  153. function is_extended(def : tdef) : boolean;
  154. {# Returns true, if definition is a "real" real (i.e. single/double/extended) }
  155. function is_real(def : tdef) : boolean;
  156. { true, if def is a 8 bit int type }
  157. function is_8bitint(def : tdef) : boolean;
  158. { true, if def is a 8 bit ordinal type }
  159. function is_8bit(def : tdef) : boolean;
  160. { true, if def is a 16 bit int type }
  161. function is_16bitint(def : tdef) : boolean;
  162. { true, if def is a 16 bit ordinal type }
  163. function is_16bit(def : tdef) : boolean;
  164. {# Returns true, if def is a 32 bit integer type }
  165. function is_32bitint(def : tdef) : boolean;
  166. {# Returns true, if def is a 32 bit ordinal type }
  167. function is_32bit(def : tdef) : boolean;
  168. {# Returns true, if def is a 64 bit integer type }
  169. function is_64bitint(def : tdef) : boolean;
  170. {# Returns true, if def is a 64 bit type }
  171. function is_64bit(def : tdef) : boolean;
  172. { true, if def is an int type, larger than the processor's native int size }
  173. function is_oversizedint(def : tdef) : boolean;
  174. { true, if def is an ordinal type, larger than the processor's native int size }
  175. function is_oversizedord(def : tdef) : boolean;
  176. { true, if def is an int type, equal in size to the processor's native int size }
  177. function is_nativeint(def : tdef) : boolean;
  178. { true, if def is an ordinal type, equal in size to the processor's native int size }
  179. function is_nativeord(def : tdef) : boolean;
  180. { true, if def is an unsigned int type, equal in size to the processor's native int size }
  181. function is_nativeuint(def : tdef) : boolean;
  182. { true, if def is a signed int type, equal in size to the processor's native int size }
  183. function is_nativesint(def : tdef) : boolean;
  184. {# If @var(l) isn't in the range of todef a range check error (if not explicit) is generated and
  185. the value is placed within the range
  186. }
  187. procedure testrange(todef : tdef;var l : tconstexprint;explicit,forcerangecheck:boolean);
  188. {# Returns the range of def, where @var(l) is the low-range and @var(h) is
  189. the high-range.
  190. }
  191. procedure getrange(def : tdef;out l, h : TConstExprInt);
  192. { type being a vector? }
  193. function is_vector(p : tdef) : boolean;
  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 if the passed type (array) fits into an mm register }
  199. function fits_in_mm_register(p : tdef) : boolean;
  200. {# From a definition return the abstract code generator size enum. It is
  201. to note that the value returned can be @var(OS_NO) }
  202. function def_cgsize(def: tdef): tcgsize;
  203. {# returns true, if the type passed is can be used with windows automation }
  204. function is_automatable(p : tdef) : boolean;
  205. { # returns true if the procdef has no parameters and no specified return type }
  206. function is_bareprocdef(pd : tprocdef): boolean;
  207. { # returns the smallest base integer type whose range encompasses that of
  208. both ld and rd; if keep_sign_if_equal, then if ld and rd have the same
  209. signdness, the result will also get that signdness }
  210. function get_common_intdef(ld, rd: torddef; keep_sign_if_equal: boolean): torddef;
  211. { # returns whether the type is potentially a valid type of/for an "univ" parameter
  212. (basically: it must have a compile-time size) }
  213. function is_valid_univ_para_type(def: tdef): boolean;
  214. { # returns whether the procdef/procvardef represents a nested procedure
  215. or not }
  216. function is_nested_pd(def: tabstractprocdef): boolean;{$ifdef USEINLINE}inline;{$endif}
  217. { # returns whether def is a type parameter of a generic }
  218. function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
  219. { returns true of def is a methodpointer }
  220. function is_methodpointer(def : tdef) : boolean;
  221. implementation
  222. uses
  223. verbose,cutils;
  224. { returns true, if def uses FPU }
  225. function is_fpu(def : tdef) : boolean;
  226. begin
  227. is_fpu:=(def.typ=floatdef);
  228. end;
  229. { returns true, if def is a currency type }
  230. function is_currency(def : tdef) : boolean;
  231. begin
  232. case s64currencytype.typ of
  233. orddef :
  234. result:=(def.typ=orddef) and
  235. (torddef(s64currencytype).ordtype=torddef(def).ordtype);
  236. floatdef :
  237. result:=(def.typ=floatdef) and
  238. (tfloatdef(s64currencytype).floattype=tfloatdef(def).floattype);
  239. else
  240. internalerror(200304222);
  241. end;
  242. end;
  243. { returns true, if def is a single type }
  244. function is_single(def : tdef) : boolean;
  245. begin
  246. result:=(def.typ=floatdef) and
  247. (tfloatdef(def).floattype=s32real);
  248. end;
  249. { returns true, if def is a double type }
  250. function is_double(def : tdef) : boolean;
  251. begin
  252. result:=(def.typ=floatdef) and
  253. (tfloatdef(def).floattype=s64real);
  254. end;
  255. function is_extended(def : tdef) : boolean;
  256. begin
  257. result:=(def.typ=floatdef) and
  258. (tfloatdef(def).floattype in [s80real,sc80real]);
  259. end;
  260. { returns true, if definition is a "real" real (i.e. single/double/extended) }
  261. function is_real(def : tdef) : boolean;
  262. begin
  263. result:=(def.typ=floatdef) and
  264. (tfloatdef(def).floattype in [s32real,s64real,s80real]);
  265. end;
  266. function range_to_basetype(l,h:TConstExprInt):tordtype;
  267. begin
  268. { prefer signed over unsigned }
  269. if (l>=int64(-128)) and (h<=127) then
  270. range_to_basetype:=s8bit
  271. else if (l>=0) and (h<=255) then
  272. range_to_basetype:=u8bit
  273. else if (l>=int64(-32768)) and (h<=32767) then
  274. range_to_basetype:=s16bit
  275. else if (l>=0) and (h<=65535) then
  276. range_to_basetype:=u16bit
  277. else if (l>=int64(low(longint))) and (h<=high(longint)) then
  278. range_to_basetype:=s32bit
  279. else if (l>=low(cardinal)) and (h<=high(cardinal)) then
  280. range_to_basetype:=u32bit
  281. else if (l>=low(int64)) and (h<=high(int64)) then
  282. range_to_basetype:=s64bit
  283. else
  284. range_to_basetype:=u64bit;
  285. end;
  286. procedure range_to_type(l,h:TConstExprInt;var def:tdef);
  287. begin
  288. { prefer signed over unsigned }
  289. if (l>=int64(-128)) and (h<=127) then
  290. def:=s8inttype
  291. else if (l>=0) and (h<=255) then
  292. def:=u8inttype
  293. else if (l>=int64(-32768)) and (h<=32767) then
  294. def:=s16inttype
  295. else if (l>=0) and (h<=65535) then
  296. def:=u16inttype
  297. else if (l>=int64(low(longint))) and (h<=high(longint)) then
  298. def:=s32inttype
  299. else if (l>=low(cardinal)) and (h<=high(cardinal)) then
  300. def:=u32inttype
  301. else if (l>=low(int64)) and (h<=high(int64)) then
  302. def:=s64inttype
  303. else
  304. def:=u64inttype;
  305. end;
  306. procedure int_to_type(v:TConstExprInt;var def:tdef);
  307. begin
  308. range_to_type(v,v,def);
  309. end;
  310. { true if p is an ordinal }
  311. function is_ordinal(def : tdef) : boolean;
  312. var
  313. dt : tordtype;
  314. begin
  315. case def.typ of
  316. orddef :
  317. begin
  318. dt:=torddef(def).ordtype;
  319. is_ordinal:=dt in [uchar,uwidechar,
  320. u8bit,u16bit,u32bit,u64bit,
  321. s8bit,s16bit,s32bit,s64bit,
  322. pasbool8,pasbool16,pasbool32,pasbool64,
  323. bool8bit,bool16bit,bool32bit,bool64bit];
  324. end;
  325. enumdef :
  326. is_ordinal:=true;
  327. else
  328. is_ordinal:=false;
  329. end;
  330. end;
  331. { true if p is a string }
  332. function is_string(def : tdef) : boolean;
  333. begin
  334. is_string := (assigned(def) and (def.typ = stringdef));
  335. end;
  336. function is_stringlike(def : tdef) : boolean;
  337. begin
  338. result := is_string(def) or
  339. is_anychar(def) or
  340. is_pchar(def) or
  341. is_pwidechar(def) or
  342. is_chararray(def) or
  343. is_widechararray(def) or
  344. is_open_chararray(def) or
  345. is_open_widechararray(def) or
  346. (def=java_jlstring);
  347. end;
  348. function is_enum(def : tdef) : boolean;
  349. begin
  350. result:=def.typ=enumdef;
  351. end;
  352. function is_set(def : tdef) : boolean;
  353. begin
  354. result:=def.typ=setdef;
  355. end;
  356. { returns the min. value of the type }
  357. function get_min_value(def : tdef) : TConstExprInt;
  358. begin
  359. case def.typ of
  360. orddef:
  361. result:=torddef(def).low;
  362. enumdef:
  363. result:=int64(tenumdef(def).min);
  364. else
  365. result:=0;
  366. end;
  367. end;
  368. { returns the max. value of the type }
  369. function get_max_value(def : tdef) : TConstExprInt;
  370. begin
  371. case def.typ of
  372. orddef:
  373. result:=torddef(def).high;
  374. enumdef:
  375. result:=tenumdef(def).max;
  376. else
  377. result:=0;
  378. end;
  379. end;
  380. { true if p is an integer }
  381. function is_integer(def : tdef) : boolean;
  382. begin
  383. result:=(def.typ=orddef) and
  384. (torddef(def).ordtype in [u8bit,u16bit,u32bit,u64bit,
  385. s8bit,s16bit,s32bit,s64bit]);
  386. end;
  387. { true if p is a boolean }
  388. function is_boolean(def : tdef) : boolean;
  389. begin
  390. result:=(def.typ=orddef) and
  391. (torddef(def).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64,bool8bit,bool16bit,bool32bit,bool64bit]);
  392. end;
  393. function is_pasbool(def : tdef) : boolean;
  394. begin
  395. result:=(def.typ=orddef) and
  396. (torddef(def).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64]);
  397. end;
  398. { true if def is a C-style boolean (non-zero value = true, zero = false) }
  399. function is_cbool(def : tdef) : boolean;
  400. begin
  401. result:=(def.typ=orddef) and
  402. (torddef(def).ordtype in [bool8bit,bool16bit,bool32bit,bool64bit]);
  403. end;
  404. { true if p is a void }
  405. function is_void(def : tdef) : boolean;
  406. begin
  407. result:=(def.typ=orddef) and
  408. (torddef(def).ordtype=uvoid);
  409. end;
  410. { true if p is a char }
  411. function is_char(def : tdef) : boolean;
  412. begin
  413. result:=(def.typ=orddef) and
  414. (torddef(def).ordtype=uchar);
  415. end;
  416. { true if p is a wchar }
  417. function is_widechar(def : tdef) : boolean;
  418. begin
  419. result:=(def.typ=orddef) and
  420. (torddef(def).ordtype=uwidechar);
  421. end;
  422. { true if p is a char or wchar }
  423. function is_anychar(def : tdef) : boolean;
  424. begin
  425. result:=(def.typ=orddef) and
  426. (torddef(def).ordtype in [uchar,uwidechar])
  427. end;
  428. { true if p is signed (integer) }
  429. function is_signed(def : tdef) : boolean;
  430. begin
  431. case def.typ of
  432. orddef :
  433. result:=torddef(def).low < 0;
  434. enumdef :
  435. result:=tenumdef(def).min < 0;
  436. arraydef :
  437. result:=is_signed(tarraydef(def).rangedef);
  438. else
  439. result:=false;
  440. end;
  441. end;
  442. function is_in_limit(def_from,def_to : tdef) : boolean;
  443. begin
  444. if (def_from.typ<>def_to.typ) or
  445. not(def_from.typ in [orddef,enumdef,setdef]) then
  446. begin
  447. is_in_limit := false;
  448. exit;
  449. end;
  450. case def_from.typ of
  451. orddef:
  452. is_in_limit:=(torddef(def_from).low>=torddef(def_to).low) and
  453. (torddef(def_from).high<=torddef(def_to).high);
  454. enumdef:
  455. is_in_limit:=(tenumdef(def_from).min>=tenumdef(def_to).min) and
  456. (tenumdef(def_from).max<=tenumdef(def_to).max);
  457. setdef:
  458. is_in_limit:=(tsetdef(def_from).setbase>=tsetdef(def_to).setbase) and
  459. (tsetdef(def_from).setmax<=tsetdef(def_to).setmax);
  460. else
  461. is_in_limit:=false;
  462. end;
  463. end;
  464. function is_managed_type(def: tdef): boolean;{$ifdef USEINLINE}inline;{$endif}
  465. begin
  466. result:=def.needs_inittable;
  467. end;
  468. { true, if p points to an open array def }
  469. function is_open_string(p : tdef) : boolean;
  470. begin
  471. is_open_string:=(p.typ=stringdef) and
  472. (tstringdef(p).stringtype=st_shortstring) and
  473. (tstringdef(p).len=0);
  474. end;
  475. { true, if p points to a zero based array def }
  476. function is_zero_based_array(p : tdef) : boolean;
  477. begin
  478. result:=(p.typ=arraydef) and
  479. (tarraydef(p).lowrange=0) and
  480. not(is_special_array(p));
  481. end;
  482. { true if p points to a dynamic array def }
  483. function is_dynamic_array(p : tdef) : boolean;
  484. begin
  485. result:=(p.typ=arraydef) and
  486. (ado_IsDynamicArray in tarraydef(p).arrayoptions);
  487. end;
  488. { true, if p points to an open array def }
  489. function is_open_array(p : tdef) : boolean;
  490. begin
  491. { check for s32inttype is needed, because for u32bit the high
  492. range is also -1 ! (PFV) }
  493. result:=(p.typ=arraydef) and
  494. (tarraydef(p).rangedef=s32inttype) and
  495. (tarraydef(p).lowrange=0) and
  496. (tarraydef(p).highrange=-1) and
  497. ((tarraydef(p).arrayoptions * [ado_IsVariant,ado_IsArrayOfConst,ado_IsConstructor,ado_IsDynamicArray])=[]);
  498. end;
  499. { true, if p points to an array of const def }
  500. function is_array_constructor(p : tdef) : boolean;
  501. begin
  502. result:=(p.typ=arraydef) and
  503. (ado_IsConstructor in tarraydef(p).arrayoptions);
  504. end;
  505. { true, if p points to a variant array }
  506. function is_variant_array(p : tdef) : boolean;
  507. begin
  508. result:=(p.typ=arraydef) and
  509. (ado_IsVariant in tarraydef(p).arrayoptions);
  510. end;
  511. { true, if p points to an array of const }
  512. function is_array_of_const(p : tdef) : boolean;
  513. begin
  514. result:=(p.typ=arraydef) and
  515. (ado_IsArrayOfConst in tarraydef(p).arrayoptions);
  516. end;
  517. { true, if p points to a special array, bitpacked arrays aren't special in this regard though }
  518. function is_special_array(p : tdef) : boolean;
  519. begin
  520. result:=(p.typ=arraydef) and
  521. (
  522. ((tarraydef(p).arrayoptions * [ado_IsVariant,ado_IsArrayOfConst,ado_IsConstructor,ado_IsDynamicArray])<>[]) or
  523. is_open_array(p)
  524. );
  525. end;
  526. { true if p is an ansi string def }
  527. function is_ansistring(p : tdef) : boolean;
  528. begin
  529. is_ansistring:=(p.typ=stringdef) and
  530. (tstringdef(p).stringtype=st_ansistring);
  531. end;
  532. { true if p is an ansi string def with codepage CP_NONE }
  533. function is_rawbytestring(p : tdef) : boolean;
  534. begin
  535. is_rawbytestring:=(p.typ=stringdef) and
  536. (tstringdef(p).stringtype=st_ansistring) and
  537. (tstringdef(p).encoding=globals.CP_NONE);
  538. end;
  539. { true if p is an long string def }
  540. function is_longstring(p : tdef) : boolean;
  541. begin
  542. is_longstring:=(p.typ=stringdef) and
  543. (tstringdef(p).stringtype=st_longstring);
  544. end;
  545. { true if p is an wide string def }
  546. function is_widestring(p : tdef) : boolean;
  547. begin
  548. is_widestring:=(p.typ=stringdef) and
  549. (tstringdef(p).stringtype=st_widestring);
  550. end;
  551. function is_dynamicstring(p: tdef): boolean;
  552. begin
  553. is_dynamicstring:=(p.typ=stringdef) and
  554. (tstringdef(p).stringtype in [st_ansistring,st_widestring,st_unicodestring]);
  555. end;
  556. { true if p is an wide string def }
  557. function is_wide_or_unicode_string(p : tdef) : boolean;
  558. begin
  559. is_wide_or_unicode_string:=(p.typ=stringdef) and
  560. (tstringdef(p).stringtype in [st_widestring,st_unicodestring]);
  561. end;
  562. { true if p is an unicode string def }
  563. function is_unicodestring(p : tdef) : boolean;
  564. begin
  565. is_unicodestring:=(p.typ=stringdef) and
  566. (tstringdef(p).stringtype=st_unicodestring);
  567. end;
  568. { true if p is an short string def }
  569. function is_shortstring(p : tdef) : boolean;
  570. begin
  571. is_shortstring:=(p.typ=stringdef) and
  572. (tstringdef(p).stringtype=st_shortstring);
  573. end;
  574. { true if p is bit packed array def }
  575. function is_packed_array(p: tdef) : boolean;
  576. begin
  577. is_packed_array :=
  578. (p.typ = arraydef) and
  579. (ado_IsBitPacked in tarraydef(p).arrayoptions);
  580. end;
  581. { true if p is bit packed record def }
  582. function is_packed_record_or_object(p: tdef) : boolean;
  583. begin
  584. is_packed_record_or_object :=
  585. (p.typ in [recorddef,objectdef]) and
  586. (tabstractrecorddef(p).is_packed);
  587. end;
  588. { true if p is a char array def }
  589. function is_chararray(p : tdef) : boolean;
  590. begin
  591. is_chararray:=(p.typ=arraydef) and
  592. is_char(tarraydef(p).elementdef) and
  593. not(is_special_array(p));
  594. end;
  595. { true if p is a widechar array def }
  596. function is_widechararray(p : tdef) : boolean;
  597. begin
  598. is_widechararray:=(p.typ=arraydef) and
  599. is_widechar(tarraydef(p).elementdef) and
  600. not(is_special_array(p));
  601. end;
  602. { true if p is a open char array def }
  603. function is_open_chararray(p : tdef) : boolean;
  604. begin
  605. is_open_chararray:= is_open_array(p) and
  606. is_char(tarraydef(p).elementdef);
  607. end;
  608. { true if p is a open wide char array def }
  609. function is_open_widechararray(p : tdef) : boolean;
  610. begin
  611. is_open_widechararray:= is_open_array(p) and
  612. is_widechar(tarraydef(p).elementdef);
  613. end;
  614. { true if p is a pchar def }
  615. function is_pchar(p : tdef) : boolean;
  616. begin
  617. is_pchar:=(p.typ=pointerdef) and
  618. (is_char(tpointerdef(p).pointeddef) or
  619. (is_zero_based_array(tpointerdef(p).pointeddef) and
  620. is_chararray(tpointerdef(p).pointeddef)));
  621. end;
  622. { true if p is a pchar def }
  623. function is_pwidechar(p : tdef) : boolean;
  624. begin
  625. is_pwidechar:=(p.typ=pointerdef) and
  626. (is_widechar(tpointerdef(p).pointeddef) or
  627. (is_zero_based_array(tpointerdef(p).pointeddef) and
  628. is_widechararray(tpointerdef(p).pointeddef)));
  629. end;
  630. { true if p is a voidpointer def }
  631. function is_voidpointer(p : tdef) : boolean;
  632. begin
  633. is_voidpointer:=(p.typ=pointerdef) and
  634. (tpointerdef(p).pointeddef.typ=orddef) and
  635. (torddef(tpointerdef(p).pointeddef).ordtype=uvoid);
  636. end;
  637. { true, if def is a 8 bit int type }
  638. function is_8bitint(def : tdef) : boolean;
  639. begin
  640. result:=(def.typ=orddef) and (torddef(def).ordtype in [u8bit,s8bit])
  641. end;
  642. { true, if def is a 8 bit ordinal type }
  643. function is_8bit(def : tdef) : boolean;
  644. begin
  645. result:=(def.typ=orddef) and (torddef(def).ordtype in [u8bit,s8bit,pasbool8,bool8bit,uchar])
  646. end;
  647. { true, if def is a 16 bit int type }
  648. function is_16bitint(def : tdef) : boolean;
  649. begin
  650. result:=(def.typ=orddef) and (torddef(def).ordtype in [u16bit,s16bit])
  651. end;
  652. { true, if def is a 16 bit ordinal type }
  653. function is_16bit(def : tdef) : boolean;
  654. begin
  655. result:=(def.typ=orddef) and (torddef(def).ordtype in [u16bit,s16bit,pasbool16,bool16bit,uwidechar])
  656. end;
  657. { true, if def is a 32 bit int type }
  658. function is_32bitint(def : tdef) : boolean;
  659. begin
  660. result:=(def.typ=orddef) and (torddef(def).ordtype in [u32bit,s32bit])
  661. end;
  662. { true, if def is a 32 bit ordinal type }
  663. function is_32bit(def: tdef): boolean;
  664. begin
  665. result:=(def.typ=orddef) and (torddef(def).ordtype in [u32bit,s32bit,pasbool32,bool32bit])
  666. end;
  667. { true, if def is a 64 bit int type }
  668. function is_64bitint(def : tdef) : boolean;
  669. begin
  670. is_64bitint:=(def.typ=orddef) and (torddef(def).ordtype in [u64bit,s64bit])
  671. end;
  672. { true, if def is a 64 bit type }
  673. function is_64bit(def : tdef) : boolean;
  674. begin
  675. is_64bit:=(def.typ=orddef) and (torddef(def).ordtype in [u64bit,s64bit,scurrency,pasbool64,bool64bit])
  676. end;
  677. { true, if def is an int type, larger than the processor's native int size }
  678. function is_oversizedint(def : tdef) : boolean;
  679. begin
  680. {$if defined(cpu8bitalu)}
  681. result:=is_64bitint(def) or is_32bitint(def) or is_16bitint(def);
  682. {$elseif defined(cpu16bitalu)}
  683. result:=is_64bitint(def) or is_32bitint(def);
  684. {$elseif defined(cpu32bitaddr)}
  685. result:=is_64bitint(def);
  686. {$elseif defined(cpu64bitaddr)}
  687. result:=false;
  688. {$endif}
  689. end;
  690. { true, if def is an ordinal type, larger than the processor's native int size }
  691. function is_oversizedord(def : tdef) : boolean;
  692. begin
  693. {$if defined(cpu8bitalu)}
  694. result:=is_64bit(def) or is_32bit(def) or is_16bit(def);
  695. {$elseif defined(cpu16bitalu)}
  696. result:=is_64bit(def) or is_32bit(def);
  697. {$elseif defined(cpu32bitaddr)}
  698. result:=is_64bit(def);
  699. {$elseif defined(cpu64bitaddr)}
  700. result:=false;
  701. {$endif}
  702. end;
  703. { true, if def is an int type, equal in size to the processor's native int size }
  704. function is_nativeint(def: tdef): boolean;
  705. begin
  706. {$if defined(cpu8bitalu)}
  707. result:=is_8bitint(def);
  708. {$elseif defined(cpu16bitalu)}
  709. result:=is_16bitint(def);
  710. {$elseif defined(cpu32bitaddr)}
  711. result:=is_32bitint(def);
  712. {$elseif defined(cpu64bitaddr)}
  713. result:=is_64bitint(def);
  714. {$endif}
  715. end;
  716. { true, if def is an ordinal type, equal in size to the processor's native int size }
  717. function is_nativeord(def: tdef): boolean;
  718. begin
  719. {$if defined(cpu8bitalu)}
  720. result:=is_8bit(def);
  721. {$elseif defined(cpu16bitalu)}
  722. result:=is_16bit(def);
  723. {$elseif defined(cpu32bitaddr)}
  724. result:=is_32bit(def);
  725. {$elseif defined(cpu64bitaddr)}
  726. result:=is_64bit(def);
  727. {$endif}
  728. end;
  729. { true, if def is an unsigned int type, equal in size to the processor's native int size }
  730. function is_nativeuint(def: tdef): boolean;
  731. begin
  732. result:=is_nativeint(def) and (def.typ=orddef) and (torddef(def).ordtype in [u64bit,u32bit,u16bit,u8bit]);
  733. end;
  734. { true, if def is a signed int type, equal in size to the processor's native int size }
  735. function is_nativesint(def: tdef): boolean;
  736. begin
  737. result:=is_nativeint(def) and (def.typ=orddef) and (torddef(def).ordtype in [s64bit,s32bit,s16bit,s8bit]);
  738. end;
  739. { if l isn't in the range of todef a range check error (if not explicit) is generated and
  740. the value is placed within the range }
  741. procedure testrange(todef : tdef;var l : tconstexprint;explicit,forcerangecheck:boolean);
  742. var
  743. lv,hv: TConstExprInt;
  744. begin
  745. { for 64 bit types we need only to check if it is less than }
  746. { zero, if def is a qword node }
  747. getrange(todef,lv,hv);
  748. if (l<lv) or (l>hv) then
  749. begin
  750. if not explicit then
  751. begin
  752. if ((todef.typ=enumdef) and
  753. { delphi allows range check errors in
  754. enumeration type casts FK }
  755. not(m_delphi in current_settings.modeswitches)) or
  756. (cs_check_range in current_settings.localswitches) or
  757. forcerangecheck then
  758. Message3(type_e_range_check_error_bounds,tostr(l),tostr(lv),tostr(hv))
  759. else
  760. Message3(type_w_range_check_error_bounds,tostr(l),tostr(lv),tostr(hv));
  761. end;
  762. { Fix the value to fit in the allocated space for this type of variable }
  763. case longint(todef.size) of
  764. 1: l := l and $ff;
  765. 2: l := l and $ffff;
  766. 4: l := l and $ffffffff;
  767. end;
  768. {reset sign, i.e. converting -1 to qword changes the value to high(qword)}
  769. l.signed:=false;
  770. { do sign extension if necessary (JM) }
  771. if is_signed(todef) then
  772. begin
  773. case longint(todef.size) of
  774. 1: l.svalue := shortint(l.svalue);
  775. 2: l.svalue := smallint(l.svalue);
  776. 4: l.svalue := longint(l.svalue);
  777. end;
  778. l.signed:=true;
  779. end;
  780. end;
  781. end;
  782. { return the range from def in l and h }
  783. procedure getrange(def : tdef;out l, h : TConstExprInt);
  784. begin
  785. case def.typ of
  786. orddef :
  787. begin
  788. l:=torddef(def).low;
  789. h:=torddef(def).high;
  790. end;
  791. enumdef :
  792. begin
  793. l:=int64(tenumdef(def).min);
  794. h:=int64(tenumdef(def).max);
  795. end;
  796. arraydef :
  797. begin
  798. l:=int64(tarraydef(def).lowrange);
  799. h:=int64(tarraydef(def).highrange);
  800. end;
  801. else
  802. internalerror(200611054);
  803. end;
  804. end;
  805. function mmx_type(p : tdef) : tmmxtype;
  806. begin
  807. mmx_type:=mmxno;
  808. if is_mmx_able_array(p) then
  809. begin
  810. if tarraydef(p).elementdef.typ=floatdef then
  811. case tfloatdef(tarraydef(p).elementdef).floattype of
  812. s32real:
  813. mmx_type:=mmxsingle;
  814. end
  815. else
  816. case torddef(tarraydef(p).elementdef).ordtype of
  817. u8bit:
  818. mmx_type:=mmxu8bit;
  819. s8bit:
  820. mmx_type:=mmxs8bit;
  821. u16bit:
  822. mmx_type:=mmxu16bit;
  823. s16bit:
  824. mmx_type:=mmxs16bit;
  825. u32bit:
  826. mmx_type:=mmxu32bit;
  827. s32bit:
  828. mmx_type:=mmxs32bit;
  829. end;
  830. end;
  831. end;
  832. function is_vector(p : tdef) : boolean;
  833. begin
  834. result:=(p.typ=arraydef) and
  835. not(is_special_array(p)) and
  836. (tarraydef(p).elementdef.typ=floatdef) and
  837. (tfloatdef(tarraydef(p).elementdef).floattype in [s32real,s64real]);
  838. end;
  839. { returns if the passed type (array) fits into an mm register }
  840. function fits_in_mm_register(p : tdef) : boolean;
  841. begin
  842. {$ifdef x86}
  843. result:= is_vector(p) and
  844. (
  845. (tarraydef(p).elementdef.typ=floatdef) and
  846. (
  847. (tarraydef(p).lowrange=0) and
  848. (tarraydef(p).highrange=3) and
  849. (tfloatdef(tarraydef(p).elementdef).floattype=s32real)
  850. )
  851. ) or
  852. (
  853. (tarraydef(p).elementdef.typ=floatdef) and
  854. (
  855. (tarraydef(p).lowrange=0) and
  856. (tarraydef(p).highrange=1) and
  857. (tfloatdef(tarraydef(p).elementdef).floattype=s64real)
  858. )
  859. );
  860. {$else x86}
  861. result:=false;
  862. {$endif x86}
  863. end;
  864. function is_mmx_able_array(p : tdef) : boolean;
  865. begin
  866. {$ifdef SUPPORT_MMX}
  867. if (cs_mmx_saturation in current_settings.localswitches) then
  868. begin
  869. is_mmx_able_array:=(p.typ=arraydef) and
  870. not(is_special_array(p)) and
  871. (
  872. (
  873. (tarraydef(p).elementdef.typ=orddef) and
  874. (
  875. (
  876. (tarraydef(p).lowrange=0) and
  877. (tarraydef(p).highrange=1) and
  878. (torddef(tarraydef(p).elementdef).ordtype in [u32bit,s32bit])
  879. )
  880. or
  881. (
  882. (tarraydef(p).lowrange=0) and
  883. (tarraydef(p).highrange=3) and
  884. (torddef(tarraydef(p).elementdef).ordtype in [u16bit,s16bit])
  885. )
  886. )
  887. )
  888. or
  889. (
  890. (
  891. (tarraydef(p).elementdef.typ=floatdef) and
  892. (
  893. (tarraydef(p).lowrange=0) and
  894. (tarraydef(p).highrange=1) and
  895. (tfloatdef(tarraydef(p).elementdef).floattype=s32real)
  896. )
  897. )
  898. )
  899. );
  900. end
  901. else
  902. begin
  903. is_mmx_able_array:=(p.typ=arraydef) and
  904. (
  905. (
  906. (tarraydef(p).elementdef.typ=orddef) and
  907. (
  908. (
  909. (tarraydef(p).lowrange=0) and
  910. (tarraydef(p).highrange=1) and
  911. (torddef(tarraydef(p).elementdef).ordtype in [u32bit,s32bit])
  912. )
  913. or
  914. (
  915. (tarraydef(p).lowrange=0) and
  916. (tarraydef(p).highrange=3) and
  917. (torddef(tarraydef(p).elementdef).ordtype in [u16bit,s16bit])
  918. )
  919. or
  920. (
  921. (tarraydef(p).lowrange=0) and
  922. (tarraydef(p).highrange=7) and
  923. (torddef(tarraydef(p).elementdef).ordtype in [u8bit,s8bit])
  924. )
  925. )
  926. )
  927. or
  928. (
  929. (tarraydef(p).elementdef.typ=floatdef) and
  930. (
  931. (tarraydef(p).lowrange=0) and
  932. (tarraydef(p).highrange=1) and
  933. (tfloatdef(tarraydef(p).elementdef).floattype=s32real)
  934. )
  935. )
  936. );
  937. end;
  938. {$else SUPPORT_MMX}
  939. is_mmx_able_array:=false;
  940. {$endif SUPPORT_MMX}
  941. end;
  942. function def_cgsize(def: tdef): tcgsize;
  943. begin
  944. case def.typ of
  945. orddef,
  946. enumdef,
  947. setdef:
  948. begin
  949. result:=int_cgsize(def.size);
  950. if is_signed(def) then
  951. result:=tcgsize(ord(result)+(ord(OS_S8)-ord(OS_8)));
  952. end;
  953. classrefdef,
  954. pointerdef:
  955. result := OS_ADDR;
  956. procvardef:
  957. begin
  958. if not tprocvardef(def).is_addressonly then
  959. {$if sizeof(pint) = 2}
  960. result:=OS_32
  961. {$elseif sizeof(pint) = 4}
  962. result:=OS_64
  963. {$elseif sizeof(pint) = 8}
  964. result:=OS_128
  965. {$else}
  966. internalerror(200707141)
  967. {$endif}
  968. else
  969. result:=OS_ADDR;
  970. end;
  971. stringdef :
  972. begin
  973. if is_ansistring(def) or is_wide_or_unicode_string(def) then
  974. result := OS_ADDR
  975. else
  976. result:=int_cgsize(def.size);
  977. end;
  978. objectdef :
  979. begin
  980. if is_implicit_pointer_object_type(def) then
  981. result := OS_ADDR
  982. else
  983. result:=int_cgsize(def.size);
  984. end;
  985. floatdef:
  986. if cs_fp_emulation in current_settings.moduleswitches then
  987. result:=int_cgsize(def.size)
  988. else
  989. result:=tfloat2tcgsize[tfloatdef(def).floattype];
  990. recorddef :
  991. result:=int_cgsize(def.size);
  992. arraydef :
  993. begin
  994. if not is_special_array(def) then
  995. result := int_cgsize(def.size)
  996. else
  997. begin
  998. if is_dynamic_array(def) then
  999. result := OS_ADDR
  1000. else
  1001. result := OS_NO;
  1002. end;
  1003. end;
  1004. else
  1005. begin
  1006. { undefined size }
  1007. result:=OS_NO;
  1008. end;
  1009. end;
  1010. end;
  1011. { In Windows 95 era, ordinals were restricted to [u8bit,s32bit,s16bit,bool16bit]
  1012. As of today, both signed and unsigned types from 8 to 64 bits are supported. }
  1013. function is_automatable(p : tdef) : boolean;
  1014. begin
  1015. result:=false;
  1016. case p.typ of
  1017. orddef:
  1018. result:=torddef(p).ordtype in [u8bit,s8bit,u16bit,s16bit,u32bit,s32bit,
  1019. u64bit,s64bit,bool16bit,scurrency];
  1020. floatdef:
  1021. result:=tfloatdef(p).floattype in [s64currency,s64real,s32real];
  1022. stringdef:
  1023. result:=tstringdef(p).stringtype in [st_ansistring,st_widestring,st_unicodestring];
  1024. variantdef:
  1025. result:=true;
  1026. objectdef:
  1027. result:=tobjectdef(p).objecttype in [odt_interfacecom,odt_dispinterface,odt_interfacecorba];
  1028. end;
  1029. end;
  1030. {# returns true, if the type passed is a varset }
  1031. function is_smallset(p : tdef) : boolean;
  1032. begin
  1033. {$if defined(cpu8bitalu)}
  1034. result:=(p.typ=setdef) and (p.size = 1)
  1035. {$elseif defined(cpu16bitalu)}
  1036. result:=(p.typ=setdef) and (p.size in [1,2])
  1037. {$else}
  1038. result:=(p.typ=setdef) and (p.size in [1,2,4])
  1039. {$endif}
  1040. end;
  1041. function is_bareprocdef(pd : tprocdef): boolean;
  1042. begin
  1043. result:=(pd.maxparacount=0) and
  1044. (is_void(pd.returndef) or
  1045. (pd.proctypeoption = potype_constructor));
  1046. end;
  1047. function get_common_intdef(ld, rd: torddef; keep_sign_if_equal: boolean): torddef;
  1048. var
  1049. llow, lhigh: tconstexprint;
  1050. begin
  1051. llow:=min(ld.low,rd.low);
  1052. lhigh:=max(ld.high,rd.high);
  1053. case range_to_basetype(llow,lhigh) of
  1054. s8bit:
  1055. result:=torddef(s8inttype);
  1056. u8bit:
  1057. result:=torddef(u8inttype);
  1058. s16bit:
  1059. result:=torddef(s16inttype);
  1060. u16bit:
  1061. result:=torddef(u16inttype);
  1062. s32bit:
  1063. result:=torddef(s32inttype);
  1064. u32bit:
  1065. result:=torddef(u32inttype);
  1066. s64bit:
  1067. result:=torddef(s64inttype);
  1068. u64bit:
  1069. result:=torddef(u64inttype);
  1070. else
  1071. begin
  1072. { avoid warning }
  1073. result:=nil;
  1074. internalerror(200802291);
  1075. end;
  1076. end;
  1077. if keep_sign_if_equal and
  1078. (is_signed(ld)=is_signed(rd)) and
  1079. (is_signed(result)<>is_signed(ld)) then
  1080. case result.ordtype of
  1081. s8bit:
  1082. result:=torddef(u8inttype);
  1083. u8bit:
  1084. result:=torddef(s16inttype);
  1085. s16bit:
  1086. result:=torddef(u16inttype);
  1087. u16bit:
  1088. result:=torddef(s32inttype);
  1089. s32bit:
  1090. result:=torddef(u32inttype);
  1091. u32bit:
  1092. result:=torddef(s64inttype);
  1093. s64bit:
  1094. result:=torddef(u64inttype);
  1095. end;
  1096. end;
  1097. function is_valid_univ_para_type(def: tdef): boolean;
  1098. begin
  1099. result:=
  1100. not is_open_array(def) and
  1101. not is_void(def) and
  1102. (def.typ<>formaldef);
  1103. end;
  1104. function is_nested_pd(def: tabstractprocdef): boolean;{$ifdef USEINLINE}inline;{$endif}
  1105. begin
  1106. result:=def.parast.symtablelevel>normal_function_level;
  1107. end;
  1108. function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
  1109. begin
  1110. result:=(def.typ=undefineddef);
  1111. end;
  1112. function is_methodpointer(def: tdef): boolean;
  1113. begin
  1114. result:=(def.typ=procvardef) and (po_methodpointer in tprocvardef(def).procoptions);
  1115. end;
  1116. end.