defutil.pas 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  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. begin
  956. {$ifdef x86}
  957. if (def.typ=pointerdef) and
  958. (tpointerdef(def).x86pointertyp in [x86pt_far,x86pt_huge]) then
  959. begin
  960. {$if defined(i8086)}
  961. result := OS_32;
  962. {$elseif defined(i386)}
  963. internalerror(2013052201); { there's no OS_48 }
  964. {$elseif defined(x86_64)}
  965. internalerror(2013052202); { there's no OS_80 }
  966. {$endif}
  967. end
  968. else
  969. {$endif x86}
  970. result := OS_ADDR;
  971. end;
  972. procvardef:
  973. begin
  974. if not tprocvardef(def).is_addressonly then
  975. {$if sizeof(pint) = 2}
  976. result:=OS_32
  977. {$elseif sizeof(pint) = 4}
  978. result:=OS_64
  979. {$elseif sizeof(pint) = 8}
  980. result:=OS_128
  981. {$else}
  982. internalerror(200707141)
  983. {$endif}
  984. else
  985. result:=OS_ADDR;
  986. end;
  987. stringdef :
  988. begin
  989. if is_ansistring(def) or is_wide_or_unicode_string(def) then
  990. result := OS_ADDR
  991. else
  992. result:=int_cgsize(def.size);
  993. end;
  994. objectdef :
  995. begin
  996. if is_implicit_pointer_object_type(def) then
  997. result := OS_ADDR
  998. else
  999. result:=int_cgsize(def.size);
  1000. end;
  1001. floatdef:
  1002. if cs_fp_emulation in current_settings.moduleswitches then
  1003. result:=int_cgsize(def.size)
  1004. else
  1005. result:=tfloat2tcgsize[tfloatdef(def).floattype];
  1006. recorddef :
  1007. result:=int_cgsize(def.size);
  1008. arraydef :
  1009. begin
  1010. if not is_special_array(def) then
  1011. result := int_cgsize(def.size)
  1012. else
  1013. begin
  1014. if is_dynamic_array(def) then
  1015. result := OS_ADDR
  1016. else
  1017. result := OS_NO;
  1018. end;
  1019. end;
  1020. else
  1021. begin
  1022. { undefined size }
  1023. result:=OS_NO;
  1024. end;
  1025. end;
  1026. end;
  1027. { In Windows 95 era, ordinals were restricted to [u8bit,s32bit,s16bit,bool16bit]
  1028. As of today, both signed and unsigned types from 8 to 64 bits are supported. }
  1029. function is_automatable(p : tdef) : boolean;
  1030. begin
  1031. result:=false;
  1032. case p.typ of
  1033. orddef:
  1034. result:=torddef(p).ordtype in [u8bit,s8bit,u16bit,s16bit,u32bit,s32bit,
  1035. u64bit,s64bit,bool16bit,scurrency];
  1036. floatdef:
  1037. result:=tfloatdef(p).floattype in [s64currency,s64real,s32real];
  1038. stringdef:
  1039. result:=tstringdef(p).stringtype in [st_ansistring,st_widestring,st_unicodestring];
  1040. variantdef:
  1041. result:=true;
  1042. objectdef:
  1043. result:=tobjectdef(p).objecttype in [odt_interfacecom,odt_dispinterface,odt_interfacecorba];
  1044. end;
  1045. end;
  1046. {# returns true, if the type passed is a varset }
  1047. function is_smallset(p : tdef) : boolean;
  1048. begin
  1049. {$if defined(cpu8bitalu)}
  1050. result:=(p.typ=setdef) and (p.size = 1)
  1051. {$elseif defined(cpu16bitalu)}
  1052. result:=(p.typ=setdef) and (p.size in [1,2])
  1053. {$else}
  1054. result:=(p.typ=setdef) and (p.size in [1,2,4])
  1055. {$endif}
  1056. end;
  1057. function is_bareprocdef(pd : tprocdef): boolean;
  1058. begin
  1059. result:=(pd.maxparacount=0) and
  1060. (is_void(pd.returndef) or
  1061. (pd.proctypeoption = potype_constructor));
  1062. end;
  1063. function get_common_intdef(ld, rd: torddef; keep_sign_if_equal: boolean): torddef;
  1064. var
  1065. llow, lhigh: tconstexprint;
  1066. begin
  1067. llow:=min(ld.low,rd.low);
  1068. lhigh:=max(ld.high,rd.high);
  1069. case range_to_basetype(llow,lhigh) of
  1070. s8bit:
  1071. result:=torddef(s8inttype);
  1072. u8bit:
  1073. result:=torddef(u8inttype);
  1074. s16bit:
  1075. result:=torddef(s16inttype);
  1076. u16bit:
  1077. result:=torddef(u16inttype);
  1078. s32bit:
  1079. result:=torddef(s32inttype);
  1080. u32bit:
  1081. result:=torddef(u32inttype);
  1082. s64bit:
  1083. result:=torddef(s64inttype);
  1084. u64bit:
  1085. result:=torddef(u64inttype);
  1086. else
  1087. begin
  1088. { avoid warning }
  1089. result:=nil;
  1090. internalerror(200802291);
  1091. end;
  1092. end;
  1093. if keep_sign_if_equal and
  1094. (is_signed(ld)=is_signed(rd)) and
  1095. (is_signed(result)<>is_signed(ld)) then
  1096. case result.ordtype of
  1097. s8bit:
  1098. result:=torddef(u8inttype);
  1099. u8bit:
  1100. result:=torddef(s16inttype);
  1101. s16bit:
  1102. result:=torddef(u16inttype);
  1103. u16bit:
  1104. result:=torddef(s32inttype);
  1105. s32bit:
  1106. result:=torddef(u32inttype);
  1107. u32bit:
  1108. result:=torddef(s64inttype);
  1109. s64bit:
  1110. result:=torddef(u64inttype);
  1111. end;
  1112. end;
  1113. function is_valid_univ_para_type(def: tdef): boolean;
  1114. begin
  1115. result:=
  1116. not is_open_array(def) and
  1117. not is_void(def) and
  1118. (def.typ<>formaldef);
  1119. end;
  1120. function is_nested_pd(def: tabstractprocdef): boolean;{$ifdef USEINLINE}inline;{$endif}
  1121. begin
  1122. result:=def.parast.symtablelevel>normal_function_level;
  1123. end;
  1124. function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
  1125. begin
  1126. result:=(def.typ=undefineddef);
  1127. end;
  1128. function is_methodpointer(def: tdef): boolean;
  1129. begin
  1130. result:=(def.typ=procvardef) and (po_methodpointer in tprocvardef(def).procoptions);
  1131. end;
  1132. end.