defutil.pas 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349
  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
  282. range_to_basetype:=s64bit;
  283. end;
  284. procedure range_to_type(l,h:TConstExprInt;var def:tdef);
  285. begin
  286. { prefer signed over unsigned }
  287. if (l>=int64(-128)) and (h<=127) then
  288. def:=s8inttype
  289. else if (l>=0) and (h<=255) then
  290. def:=u8inttype
  291. else if (l>=int64(-32768)) and (h<=32767) then
  292. def:=s16inttype
  293. else if (l>=0) and (h<=65535) then
  294. def:=u16inttype
  295. else if (l>=int64(low(longint))) and (h<=high(longint)) then
  296. def:=s32inttype
  297. else if (l>=low(cardinal)) and (h<=high(cardinal)) then
  298. def:=u32inttype
  299. else if (l>=low(int64)) and (h<=high(int64)) then
  300. def:=s64inttype
  301. else
  302. def:=u64inttype;
  303. end;
  304. procedure int_to_type(v:TConstExprInt;var def:tdef);
  305. begin
  306. range_to_type(v,v,def);
  307. end;
  308. { true if p is an ordinal }
  309. function is_ordinal(def : tdef) : boolean;
  310. var
  311. dt : tordtype;
  312. begin
  313. case def.typ of
  314. orddef :
  315. begin
  316. dt:=torddef(def).ordtype;
  317. is_ordinal:=dt in [uchar,uwidechar,
  318. u8bit,u16bit,u32bit,u64bit,
  319. s8bit,s16bit,s32bit,s64bit,
  320. pasbool8,pasbool16,pasbool32,pasbool64,
  321. bool8bit,bool16bit,bool32bit,bool64bit];
  322. end;
  323. enumdef :
  324. is_ordinal:=true;
  325. else
  326. is_ordinal:=false;
  327. end;
  328. end;
  329. { true if p is a string }
  330. function is_string(def : tdef) : boolean;
  331. begin
  332. is_string := (assigned(def) and (def.typ = stringdef));
  333. end;
  334. function is_stringlike(def : tdef) : boolean;
  335. begin
  336. result := is_string(def) or
  337. is_anychar(def) or
  338. is_pchar(def) or
  339. is_pwidechar(def) or
  340. is_chararray(def) or
  341. is_widechararray(def) or
  342. is_open_chararray(def) or
  343. is_open_widechararray(def) or
  344. (def=java_jlstring);
  345. end;
  346. function is_enum(def : tdef) : boolean;
  347. begin
  348. result:=def.typ=enumdef;
  349. end;
  350. function is_set(def : tdef) : boolean;
  351. begin
  352. result:=def.typ=setdef;
  353. end;
  354. { returns the min. value of the type }
  355. function get_min_value(def : tdef) : TConstExprInt;
  356. begin
  357. case def.typ of
  358. orddef:
  359. result:=torddef(def).low;
  360. enumdef:
  361. result:=int64(tenumdef(def).min);
  362. else
  363. result:=0;
  364. end;
  365. end;
  366. { returns the max. value of the type }
  367. function get_max_value(def : tdef) : TConstExprInt;
  368. begin
  369. case def.typ of
  370. orddef:
  371. result:=torddef(def).high;
  372. enumdef:
  373. result:=tenumdef(def).max;
  374. else
  375. result:=0;
  376. end;
  377. end;
  378. { true if p is an integer }
  379. function is_integer(def : tdef) : boolean;
  380. begin
  381. result:=(def.typ=orddef) and
  382. (torddef(def).ordtype in [u8bit,u16bit,u32bit,u64bit,
  383. s8bit,s16bit,s32bit,s64bit]);
  384. end;
  385. { true if p is a boolean }
  386. function is_boolean(def : tdef) : boolean;
  387. begin
  388. result:=(def.typ=orddef) and
  389. (torddef(def).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64,bool8bit,bool16bit,bool32bit,bool64bit]);
  390. end;
  391. function is_pasbool(def : tdef) : boolean;
  392. begin
  393. result:=(def.typ=orddef) and
  394. (torddef(def).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64]);
  395. end;
  396. { true if def is a C-style boolean (non-zero value = true, zero = false) }
  397. function is_cbool(def : tdef) : boolean;
  398. begin
  399. result:=(def.typ=orddef) and
  400. (torddef(def).ordtype in [bool8bit,bool16bit,bool32bit,bool64bit]);
  401. end;
  402. { true if p is a void }
  403. function is_void(def : tdef) : boolean;
  404. begin
  405. result:=(def.typ=orddef) and
  406. (torddef(def).ordtype=uvoid);
  407. end;
  408. { true if p is a char }
  409. function is_char(def : tdef) : boolean;
  410. begin
  411. result:=(def.typ=orddef) and
  412. (torddef(def).ordtype=uchar);
  413. end;
  414. { true if p is a wchar }
  415. function is_widechar(def : tdef) : boolean;
  416. begin
  417. result:=(def.typ=orddef) and
  418. (torddef(def).ordtype=uwidechar);
  419. end;
  420. { true if p is a char or wchar }
  421. function is_anychar(def : tdef) : boolean;
  422. begin
  423. result:=(def.typ=orddef) and
  424. (torddef(def).ordtype in [uchar,uwidechar])
  425. end;
  426. { true if p is signed (integer) }
  427. function is_signed(def : tdef) : boolean;
  428. begin
  429. case def.typ of
  430. orddef :
  431. result:=torddef(def).low < 0;
  432. enumdef :
  433. result:=tenumdef(def).min < 0;
  434. arraydef :
  435. result:=is_signed(tarraydef(def).rangedef);
  436. else
  437. result:=false;
  438. end;
  439. end;
  440. function is_in_limit(def_from,def_to : tdef) : boolean;
  441. begin
  442. if (def_from.typ<>def_to.typ) or
  443. not(def_from.typ in [orddef,enumdef,setdef]) then
  444. begin
  445. is_in_limit := false;
  446. exit;
  447. end;
  448. case def_from.typ of
  449. orddef:
  450. is_in_limit:=(torddef(def_from).low>=torddef(def_to).low) and
  451. (torddef(def_from).high<=torddef(def_to).high);
  452. enumdef:
  453. is_in_limit:=(tenumdef(def_from).min>=tenumdef(def_to).min) and
  454. (tenumdef(def_from).max<=tenumdef(def_to).max);
  455. setdef:
  456. is_in_limit:=(tsetdef(def_from).setbase>=tsetdef(def_to).setbase) and
  457. (tsetdef(def_from).setmax<=tsetdef(def_to).setmax);
  458. else
  459. is_in_limit:=false;
  460. end;
  461. end;
  462. function is_managed_type(def: tdef): boolean;{$ifdef USEINLINE}inline;{$endif}
  463. begin
  464. result:=def.needs_inittable;
  465. end;
  466. { true, if p points to an open array def }
  467. function is_open_string(p : tdef) : boolean;
  468. begin
  469. is_open_string:=(p.typ=stringdef) and
  470. (tstringdef(p).stringtype=st_shortstring) and
  471. (tstringdef(p).len=0);
  472. end;
  473. { true, if p points to a zero based array def }
  474. function is_zero_based_array(p : tdef) : boolean;
  475. begin
  476. result:=(p.typ=arraydef) and
  477. (tarraydef(p).lowrange=0) and
  478. not(is_special_array(p));
  479. end;
  480. { true if p points to a dynamic array def }
  481. function is_dynamic_array(p : tdef) : boolean;
  482. begin
  483. result:=(p.typ=arraydef) and
  484. (ado_IsDynamicArray in tarraydef(p).arrayoptions);
  485. end;
  486. { true, if p points to an open array def }
  487. function is_open_array(p : tdef) : boolean;
  488. begin
  489. { check for s32inttype is needed, because for u32bit the high
  490. range is also -1 ! (PFV) }
  491. result:=(p.typ=arraydef) and
  492. (tarraydef(p).rangedef=s32inttype) and
  493. (tarraydef(p).lowrange=0) and
  494. (tarraydef(p).highrange=-1) and
  495. ((tarraydef(p).arrayoptions * [ado_IsVariant,ado_IsArrayOfConst,ado_IsConstructor,ado_IsDynamicArray])=[]);
  496. end;
  497. { true, if p points to an array of const def }
  498. function is_array_constructor(p : tdef) : boolean;
  499. begin
  500. result:=(p.typ=arraydef) and
  501. (ado_IsConstructor in tarraydef(p).arrayoptions);
  502. end;
  503. { true, if p points to a variant array }
  504. function is_variant_array(p : tdef) : boolean;
  505. begin
  506. result:=(p.typ=arraydef) and
  507. (ado_IsVariant in tarraydef(p).arrayoptions);
  508. end;
  509. { true, if p points to an array of const }
  510. function is_array_of_const(p : tdef) : boolean;
  511. begin
  512. result:=(p.typ=arraydef) and
  513. (ado_IsArrayOfConst in tarraydef(p).arrayoptions);
  514. end;
  515. { true, if p points to a special array, bitpacked arrays aren't special in this regard though }
  516. function is_special_array(p : tdef) : boolean;
  517. begin
  518. result:=(p.typ=arraydef) and
  519. (
  520. ((tarraydef(p).arrayoptions * [ado_IsVariant,ado_IsArrayOfConst,ado_IsConstructor,ado_IsDynamicArray])<>[]) or
  521. is_open_array(p)
  522. );
  523. end;
  524. { true if p is an ansi string def }
  525. function is_ansistring(p : tdef) : boolean;
  526. begin
  527. is_ansistring:=(p.typ=stringdef) and
  528. (tstringdef(p).stringtype=st_ansistring);
  529. end;
  530. { true if p is an ansi string def with codepage CP_NONE }
  531. function is_rawbytestring(p : tdef) : boolean;
  532. begin
  533. is_rawbytestring:=(p.typ=stringdef) and
  534. (tstringdef(p).stringtype=st_ansistring) and
  535. (tstringdef(p).encoding=globals.CP_NONE);
  536. end;
  537. { true if p is an long string def }
  538. function is_longstring(p : tdef) : boolean;
  539. begin
  540. is_longstring:=(p.typ=stringdef) and
  541. (tstringdef(p).stringtype=st_longstring);
  542. end;
  543. { true if p is an wide string def }
  544. function is_widestring(p : tdef) : boolean;
  545. begin
  546. is_widestring:=(p.typ=stringdef) and
  547. (tstringdef(p).stringtype=st_widestring);
  548. end;
  549. function is_dynamicstring(p: tdef): boolean;
  550. begin
  551. is_dynamicstring:=(p.typ=stringdef) and
  552. (tstringdef(p).stringtype in [st_ansistring,st_widestring,st_unicodestring]);
  553. end;
  554. { true if p is an wide string def }
  555. function is_wide_or_unicode_string(p : tdef) : boolean;
  556. begin
  557. is_wide_or_unicode_string:=(p.typ=stringdef) and
  558. (tstringdef(p).stringtype in [st_widestring,st_unicodestring]);
  559. end;
  560. { true if p is an unicode string def }
  561. function is_unicodestring(p : tdef) : boolean;
  562. begin
  563. is_unicodestring:=(p.typ=stringdef) and
  564. (tstringdef(p).stringtype=st_unicodestring);
  565. end;
  566. { true if p is an short string def }
  567. function is_shortstring(p : tdef) : boolean;
  568. begin
  569. is_shortstring:=(p.typ=stringdef) and
  570. (tstringdef(p).stringtype=st_shortstring);
  571. end;
  572. { true if p is bit packed array def }
  573. function is_packed_array(p: tdef) : boolean;
  574. begin
  575. is_packed_array :=
  576. (p.typ = arraydef) and
  577. (ado_IsBitPacked in tarraydef(p).arrayoptions);
  578. end;
  579. { true if p is bit packed record def }
  580. function is_packed_record_or_object(p: tdef) : boolean;
  581. begin
  582. is_packed_record_or_object :=
  583. (p.typ in [recorddef,objectdef]) and
  584. (tabstractrecorddef(p).is_packed);
  585. end;
  586. { true if p is a char array def }
  587. function is_chararray(p : tdef) : boolean;
  588. begin
  589. is_chararray:=(p.typ=arraydef) and
  590. is_char(tarraydef(p).elementdef) and
  591. not(is_special_array(p));
  592. end;
  593. { true if p is a widechar array def }
  594. function is_widechararray(p : tdef) : boolean;
  595. begin
  596. is_widechararray:=(p.typ=arraydef) and
  597. is_widechar(tarraydef(p).elementdef) and
  598. not(is_special_array(p));
  599. end;
  600. { true if p is a open char array def }
  601. function is_open_chararray(p : tdef) : boolean;
  602. begin
  603. is_open_chararray:= is_open_array(p) and
  604. is_char(tarraydef(p).elementdef);
  605. end;
  606. { true if p is a open wide char array def }
  607. function is_open_widechararray(p : tdef) : boolean;
  608. begin
  609. is_open_widechararray:= is_open_array(p) and
  610. is_widechar(tarraydef(p).elementdef);
  611. end;
  612. { true if p is a pchar def }
  613. function is_pchar(p : tdef) : boolean;
  614. begin
  615. is_pchar:=(p.typ=pointerdef) and
  616. (is_char(tpointerdef(p).pointeddef) or
  617. (is_zero_based_array(tpointerdef(p).pointeddef) and
  618. is_chararray(tpointerdef(p).pointeddef)));
  619. end;
  620. { true if p is a pchar def }
  621. function is_pwidechar(p : tdef) : boolean;
  622. begin
  623. is_pwidechar:=(p.typ=pointerdef) and
  624. (is_widechar(tpointerdef(p).pointeddef) or
  625. (is_zero_based_array(tpointerdef(p).pointeddef) and
  626. is_widechararray(tpointerdef(p).pointeddef)));
  627. end;
  628. { true if p is a voidpointer def }
  629. function is_voidpointer(p : tdef) : boolean;
  630. begin
  631. is_voidpointer:=(p.typ=pointerdef) and
  632. (tpointerdef(p).pointeddef.typ=orddef) and
  633. (torddef(tpointerdef(p).pointeddef).ordtype=uvoid);
  634. end;
  635. { true, if def is a 8 bit int type }
  636. function is_8bitint(def : tdef) : boolean;
  637. begin
  638. result:=(def.typ=orddef) and (torddef(def).ordtype in [u8bit,s8bit])
  639. end;
  640. { true, if def is a 8 bit ordinal type }
  641. function is_8bit(def : tdef) : boolean;
  642. begin
  643. result:=(def.typ=orddef) and (torddef(def).ordtype in [u8bit,s8bit,pasbool8,bool8bit,uchar])
  644. end;
  645. { true, if def is a 16 bit int type }
  646. function is_16bitint(def : tdef) : boolean;
  647. begin
  648. result:=(def.typ=orddef) and (torddef(def).ordtype in [u16bit,s16bit])
  649. end;
  650. { true, if def is a 16 bit ordinal type }
  651. function is_16bit(def : tdef) : boolean;
  652. begin
  653. result:=(def.typ=orddef) and (torddef(def).ordtype in [u16bit,s16bit,pasbool16,bool16bit,uwidechar])
  654. end;
  655. { true, if def is a 32 bit int type }
  656. function is_32bitint(def : tdef) : boolean;
  657. begin
  658. result:=(def.typ=orddef) and (torddef(def).ordtype in [u32bit,s32bit])
  659. end;
  660. { true, if def is a 32 bit ordinal type }
  661. function is_32bit(def: tdef): boolean;
  662. begin
  663. result:=(def.typ=orddef) and (torddef(def).ordtype in [u32bit,s32bit,pasbool32,bool32bit])
  664. end;
  665. { true, if def is a 64 bit int type }
  666. function is_64bitint(def : tdef) : boolean;
  667. begin
  668. is_64bitint:=(def.typ=orddef) and (torddef(def).ordtype in [u64bit,s64bit])
  669. end;
  670. { true, if def is a 64 bit type }
  671. function is_64bit(def : tdef) : boolean;
  672. begin
  673. is_64bit:=(def.typ=orddef) and (torddef(def).ordtype in [u64bit,s64bit,scurrency,pasbool64,bool64bit])
  674. end;
  675. { true, if def is an int type, larger than the processor's native int size }
  676. function is_oversizedint(def : tdef) : boolean;
  677. begin
  678. {$if defined(cpu8bitalu)}
  679. result:=is_64bitint(def) or is_32bitint(def) or is_16bitint(def);
  680. {$elseif defined(cpu16bitalu)}
  681. result:=is_64bitint(def) or is_32bitint(def);
  682. {$elseif defined(cpu32bitaddr)}
  683. result:=is_64bitint(def);
  684. {$elseif defined(cpu64bitaddr)}
  685. result:=false;
  686. {$endif}
  687. end;
  688. { true, if def is an ordinal type, larger than the processor's native int size }
  689. function is_oversizedord(def : tdef) : boolean;
  690. begin
  691. {$if defined(cpu8bitalu)}
  692. result:=is_64bit(def) or is_32bit(def) or is_16bit(def);
  693. {$elseif defined(cpu16bitalu)}
  694. result:=is_64bit(def) or is_32bit(def);
  695. {$elseif defined(cpu32bitaddr)}
  696. result:=is_64bit(def);
  697. {$elseif defined(cpu64bitaddr)}
  698. result:=false;
  699. {$endif}
  700. end;
  701. { true, if def is an int type, equal in size to the processor's native int size }
  702. function is_nativeint(def: tdef): boolean;
  703. begin
  704. {$if defined(cpu8bitalu)}
  705. result:=is_8bitint(def);
  706. {$elseif defined(cpu16bitalu)}
  707. result:=is_16bitint(def);
  708. {$elseif defined(cpu32bitaddr)}
  709. result:=is_32bitint(def);
  710. {$elseif defined(cpu64bitaddr)}
  711. result:=is_64bitint(def);
  712. {$endif}
  713. end;
  714. { true, if def is an ordinal type, equal in size to the processor's native int size }
  715. function is_nativeord(def: tdef): boolean;
  716. begin
  717. {$if defined(cpu8bitalu)}
  718. result:=is_8bit(def);
  719. {$elseif defined(cpu16bitalu)}
  720. result:=is_16bit(def);
  721. {$elseif defined(cpu32bitaddr)}
  722. result:=is_32bit(def);
  723. {$elseif defined(cpu64bitaddr)}
  724. result:=is_64bit(def);
  725. {$endif}
  726. end;
  727. { true, if def is an unsigned int type, equal in size to the processor's native int size }
  728. function is_nativeuint(def: tdef): boolean;
  729. begin
  730. result:=is_nativeint(def) and (def.typ=orddef) and (torddef(def).ordtype in [u64bit,u32bit,u16bit,u8bit]);
  731. end;
  732. { true, if def is a signed int type, equal in size to the processor's native int size }
  733. function is_nativesint(def: tdef): boolean;
  734. begin
  735. result:=is_nativeint(def) and (def.typ=orddef) and (torddef(def).ordtype in [s64bit,s32bit,s16bit,s8bit]);
  736. end;
  737. { if l isn't in the range of todef a range check error (if not explicit) is generated and
  738. the value is placed within the range }
  739. procedure testrange(todef : tdef;var l : tconstexprint;explicit,forcerangecheck:boolean);
  740. var
  741. lv,hv: TConstExprInt;
  742. begin
  743. { for 64 bit types we need only to check if it is less than }
  744. { zero, if def is a qword node }
  745. getrange(todef,lv,hv);
  746. if (l<lv) or (l>hv) then
  747. begin
  748. if not explicit then
  749. begin
  750. if ((todef.typ=enumdef) and
  751. { delphi allows range check errors in
  752. enumeration type casts FK }
  753. not(m_delphi in current_settings.modeswitches)) or
  754. (cs_check_range in current_settings.localswitches) or
  755. forcerangecheck then
  756. Message3(type_e_range_check_error_bounds,tostr(l),tostr(lv),tostr(hv))
  757. else
  758. Message3(type_w_range_check_error_bounds,tostr(l),tostr(lv),tostr(hv));
  759. end;
  760. { Fix the value to fit in the allocated space for this type of variable }
  761. case longint(todef.size) of
  762. 1: l := l and $ff;
  763. 2: l := l and $ffff;
  764. 4: l := l and $ffffffff;
  765. end;
  766. {reset sign, i.e. converting -1 to qword changes the value to high(qword)}
  767. l.signed:=false;
  768. { do sign extension if necessary (JM) }
  769. if is_signed(todef) then
  770. begin
  771. case longint(todef.size) of
  772. 1: l.svalue := shortint(l.svalue);
  773. 2: l.svalue := smallint(l.svalue);
  774. 4: l.svalue := longint(l.svalue);
  775. end;
  776. l.signed:=true;
  777. end;
  778. end;
  779. end;
  780. { return the range from def in l and h }
  781. procedure getrange(def : tdef;out l, h : TConstExprInt);
  782. begin
  783. case def.typ of
  784. orddef :
  785. begin
  786. l:=torddef(def).low;
  787. h:=torddef(def).high;
  788. end;
  789. enumdef :
  790. begin
  791. l:=int64(tenumdef(def).min);
  792. h:=int64(tenumdef(def).max);
  793. end;
  794. arraydef :
  795. begin
  796. l:=int64(tarraydef(def).lowrange);
  797. h:=int64(tarraydef(def).highrange);
  798. end;
  799. else
  800. internalerror(200611054);
  801. end;
  802. end;
  803. function mmx_type(p : tdef) : tmmxtype;
  804. begin
  805. mmx_type:=mmxno;
  806. if is_mmx_able_array(p) then
  807. begin
  808. if tarraydef(p).elementdef.typ=floatdef then
  809. case tfloatdef(tarraydef(p).elementdef).floattype of
  810. s32real:
  811. mmx_type:=mmxsingle;
  812. end
  813. else
  814. case torddef(tarraydef(p).elementdef).ordtype of
  815. u8bit:
  816. mmx_type:=mmxu8bit;
  817. s8bit:
  818. mmx_type:=mmxs8bit;
  819. u16bit:
  820. mmx_type:=mmxu16bit;
  821. s16bit:
  822. mmx_type:=mmxs16bit;
  823. u32bit:
  824. mmx_type:=mmxu32bit;
  825. s32bit:
  826. mmx_type:=mmxs32bit;
  827. end;
  828. end;
  829. end;
  830. function is_vector(p : tdef) : boolean;
  831. begin
  832. result:=(p.typ=arraydef) and
  833. not(is_special_array(p)) and
  834. (tarraydef(p).elementdef.typ=floatdef) and
  835. (tfloatdef(tarraydef(p).elementdef).floattype in [s32real,s64real]);
  836. end;
  837. { returns if the passed type (array) fits into an mm register }
  838. function fits_in_mm_register(p : tdef) : boolean;
  839. begin
  840. {$ifdef x86}
  841. result:= is_vector(p) and
  842. (
  843. (tarraydef(p).elementdef.typ=floatdef) and
  844. (
  845. (tarraydef(p).lowrange=0) and
  846. (tarraydef(p).highrange=3) and
  847. (tfloatdef(tarraydef(p).elementdef).floattype=s32real)
  848. )
  849. ) or
  850. (
  851. (tarraydef(p).elementdef.typ=floatdef) and
  852. (
  853. (tarraydef(p).lowrange=0) and
  854. (tarraydef(p).highrange=1) and
  855. (tfloatdef(tarraydef(p).elementdef).floattype=s64real)
  856. )
  857. );
  858. {$else x86}
  859. result:=false;
  860. {$endif x86}
  861. end;
  862. function is_mmx_able_array(p : tdef) : boolean;
  863. begin
  864. {$ifdef SUPPORT_MMX}
  865. if (cs_mmx_saturation in current_settings.localswitches) then
  866. begin
  867. is_mmx_able_array:=(p.typ=arraydef) and
  868. not(is_special_array(p)) and
  869. (
  870. (
  871. (tarraydef(p).elementdef.typ=orddef) and
  872. (
  873. (
  874. (tarraydef(p).lowrange=0) and
  875. (tarraydef(p).highrange=1) and
  876. (torddef(tarraydef(p).elementdef).ordtype in [u32bit,s32bit])
  877. )
  878. or
  879. (
  880. (tarraydef(p).lowrange=0) and
  881. (tarraydef(p).highrange=3) and
  882. (torddef(tarraydef(p).elementdef).ordtype in [u16bit,s16bit])
  883. )
  884. )
  885. )
  886. or
  887. (
  888. (
  889. (tarraydef(p).elementdef.typ=floatdef) and
  890. (
  891. (tarraydef(p).lowrange=0) and
  892. (tarraydef(p).highrange=1) and
  893. (tfloatdef(tarraydef(p).elementdef).floattype=s32real)
  894. )
  895. )
  896. )
  897. );
  898. end
  899. else
  900. begin
  901. is_mmx_able_array:=(p.typ=arraydef) and
  902. (
  903. (
  904. (tarraydef(p).elementdef.typ=orddef) and
  905. (
  906. (
  907. (tarraydef(p).lowrange=0) and
  908. (tarraydef(p).highrange=1) and
  909. (torddef(tarraydef(p).elementdef).ordtype in [u32bit,s32bit])
  910. )
  911. or
  912. (
  913. (tarraydef(p).lowrange=0) and
  914. (tarraydef(p).highrange=3) and
  915. (torddef(tarraydef(p).elementdef).ordtype in [u16bit,s16bit])
  916. )
  917. or
  918. (
  919. (tarraydef(p).lowrange=0) and
  920. (tarraydef(p).highrange=7) and
  921. (torddef(tarraydef(p).elementdef).ordtype in [u8bit,s8bit])
  922. )
  923. )
  924. )
  925. or
  926. (
  927. (tarraydef(p).elementdef.typ=floatdef) and
  928. (
  929. (tarraydef(p).lowrange=0) and
  930. (tarraydef(p).highrange=1) and
  931. (tfloatdef(tarraydef(p).elementdef).floattype=s32real)
  932. )
  933. )
  934. );
  935. end;
  936. {$else SUPPORT_MMX}
  937. is_mmx_able_array:=false;
  938. {$endif SUPPORT_MMX}
  939. end;
  940. function def_cgsize(def: tdef): tcgsize;
  941. begin
  942. case def.typ of
  943. orddef,
  944. enumdef,
  945. setdef:
  946. begin
  947. result:=int_cgsize(def.size);
  948. if is_signed(def) then
  949. result:=tcgsize(ord(result)+(ord(OS_S8)-ord(OS_8)));
  950. end;
  951. classrefdef,
  952. pointerdef:
  953. result := OS_ADDR;
  954. procvardef:
  955. begin
  956. if not tprocvardef(def).is_addressonly then
  957. {$if sizeof(pint) = 2}
  958. result:=OS_32
  959. {$elseif sizeof(pint) = 4}
  960. result:=OS_64
  961. {$elseif sizeof(pint) = 8}
  962. result:=OS_128
  963. {$else}
  964. internalerror(200707141)
  965. {$endif}
  966. else
  967. result:=OS_ADDR;
  968. end;
  969. stringdef :
  970. begin
  971. if is_ansistring(def) or is_wide_or_unicode_string(def) then
  972. result := OS_ADDR
  973. else
  974. result:=int_cgsize(def.size);
  975. end;
  976. objectdef :
  977. begin
  978. if is_implicit_pointer_object_type(def) then
  979. result := OS_ADDR
  980. else
  981. result:=int_cgsize(def.size);
  982. end;
  983. floatdef:
  984. if cs_fp_emulation in current_settings.moduleswitches then
  985. result:=int_cgsize(def.size)
  986. else
  987. result:=tfloat2tcgsize[tfloatdef(def).floattype];
  988. recorddef :
  989. result:=int_cgsize(def.size);
  990. arraydef :
  991. begin
  992. if not is_special_array(def) then
  993. result := int_cgsize(def.size)
  994. else
  995. begin
  996. if is_dynamic_array(def) then
  997. result := OS_ADDR
  998. else
  999. result := OS_NO;
  1000. end;
  1001. end;
  1002. else
  1003. begin
  1004. { undefined size }
  1005. result:=OS_NO;
  1006. end;
  1007. end;
  1008. end;
  1009. { In Windows 95 era, ordinals were restricted to [u8bit,s32bit,s16bit,bool16bit]
  1010. As of today, both signed and unsigned types from 8 to 64 bits are supported. }
  1011. function is_automatable(p : tdef) : boolean;
  1012. begin
  1013. result:=false;
  1014. case p.typ of
  1015. orddef:
  1016. result:=torddef(p).ordtype in [u8bit,s8bit,u16bit,s16bit,u32bit,s32bit,
  1017. u64bit,s64bit,bool16bit,scurrency];
  1018. floatdef:
  1019. result:=tfloatdef(p).floattype in [s64currency,s64real,s32real];
  1020. stringdef:
  1021. result:=tstringdef(p).stringtype in [st_ansistring,st_widestring,st_unicodestring];
  1022. variantdef:
  1023. result:=true;
  1024. objectdef:
  1025. result:=tobjectdef(p).objecttype in [odt_interfacecom,odt_dispinterface,odt_interfacecorba];
  1026. end;
  1027. end;
  1028. {# returns true, if the type passed is a varset }
  1029. function is_smallset(p : tdef) : boolean;
  1030. begin
  1031. {$if defined(cpu8bitalu)}
  1032. result:=(p.typ=setdef) and (p.size = 1)
  1033. {$elseif defined(cpu16bitalu)}
  1034. result:=(p.typ=setdef) and (p.size in [1,2])
  1035. {$else}
  1036. result:=(p.typ=setdef) and (p.size in [1,2,4])
  1037. {$endif}
  1038. end;
  1039. function is_bareprocdef(pd : tprocdef): boolean;
  1040. begin
  1041. result:=(pd.maxparacount=0) and
  1042. (is_void(pd.returndef) or
  1043. (pd.proctypeoption = potype_constructor));
  1044. end;
  1045. function get_common_intdef(ld, rd: torddef; keep_sign_if_equal: boolean): torddef;
  1046. var
  1047. llow, lhigh: tconstexprint;
  1048. begin
  1049. llow:=min(ld.low,rd.low);
  1050. lhigh:=max(ld.high,rd.high);
  1051. case range_to_basetype(llow,lhigh) of
  1052. s8bit:
  1053. result:=torddef(s8inttype);
  1054. u8bit:
  1055. result:=torddef(u8inttype);
  1056. s16bit:
  1057. result:=torddef(s16inttype);
  1058. u16bit:
  1059. result:=torddef(u16inttype);
  1060. s32bit:
  1061. result:=torddef(s32inttype);
  1062. u32bit:
  1063. result:=torddef(u32inttype);
  1064. s64bit:
  1065. result:=torddef(s64inttype);
  1066. u64bit:
  1067. result:=torddef(u64inttype);
  1068. else
  1069. begin
  1070. { avoid warning }
  1071. result:=nil;
  1072. internalerror(200802291);
  1073. end;
  1074. end;
  1075. if keep_sign_if_equal and
  1076. (is_signed(ld)=is_signed(rd)) and
  1077. (is_signed(result)<>is_signed(ld)) then
  1078. case result.ordtype of
  1079. s8bit:
  1080. result:=torddef(u8inttype);
  1081. u8bit:
  1082. result:=torddef(s16inttype);
  1083. s16bit:
  1084. result:=torddef(u16inttype);
  1085. u16bit:
  1086. result:=torddef(s32inttype);
  1087. s32bit:
  1088. result:=torddef(u32inttype);
  1089. u32bit:
  1090. result:=torddef(s64inttype);
  1091. s64bit:
  1092. result:=torddef(u64inttype);
  1093. end;
  1094. end;
  1095. function is_valid_univ_para_type(def: tdef): boolean;
  1096. begin
  1097. result:=
  1098. not is_open_array(def) and
  1099. not is_void(def) and
  1100. (def.typ<>formaldef);
  1101. end;
  1102. function is_nested_pd(def: tabstractprocdef): boolean;{$ifdef USEINLINE}inline;{$endif}
  1103. begin
  1104. result:=def.parast.symtablelevel>normal_function_level;
  1105. end;
  1106. function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
  1107. begin
  1108. result:=(def.typ=undefineddef);
  1109. end;
  1110. function is_methodpointer(def: tdef): boolean;
  1111. begin
  1112. result:=(def.typ=procvardef) and (po_methodpointer in tprocvardef(def).procoptions);
  1113. end;
  1114. end.