12 ( FB_DATACLASS_UNKNOWN, 0, FALSE, 0, FB_DATATYPE_VOID , -1 , @
"any" ), _
13 ( FB_DATACLASS_INTEGER, 1, TRUE , 10, FB_DATATYPE_BYTE , FB_SIZETYPE_INT8 , @
"byte" ), _
14 ( FB_DATACLASS_INTEGER, 1, FALSE, 15, FB_DATATYPE_UBYTE , FB_SIZETYPE_UINT8 , @
"ubyte" ), _
15 ( FB_DATACLASS_INTEGER, 1, FALSE, 0, FB_DATATYPE_UBYTE , FB_SIZETYPE_UINT8 , @
"zstring" ), _
16 ( FB_DATACLASS_INTEGER, 2, TRUE , 20, FB_DATATYPE_SHORT , FB_SIZETYPE_INT16 , @
"short" ), _
17 ( FB_DATACLASS_INTEGER, 2, FALSE, 25, FB_DATATYPE_USHORT , FB_SIZETYPE_UINT16 , @
"ushort" ), _
18 ( FB_DATACLASS_INTEGER, 2, FALSE, 0, -1 , -1 , @
"wstring" ), _
19 ( FB_DATACLASS_INTEGER, -1, TRUE , -1, FB_DATATYPE_INTEGER , -1 , @
"integer" ), _
20 ( FB_DATACLASS_INTEGER, -1, FALSE, -1, FB_DATATYPE_UINT , -1 , @
"uinteger" ), _
21 ( FB_DATACLASS_INTEGER, -1, TRUE , 0, FB_DATATYPE_INTEGER , -1 , @
"enum" ), _
22 ( FB_DATACLASS_INTEGER, -1, FALSE, 0, FB_DATATYPE_UINT , -1 , @
"bitfield" ), _
23 ( FB_DATACLASS_INTEGER, 4, TRUE , 40, FB_DATATYPE_LONG , FB_SIZETYPE_INT32 , @
"long" ), _
24 ( FB_DATACLASS_INTEGER, 4, FALSE, 45, FB_DATATYPE_ULONG , FB_SIZETYPE_UINT32 , @
"ulong" ), _
25 ( FB_DATACLASS_INTEGER, 8, TRUE , 80, FB_DATATYPE_LONGINT , FB_SIZETYPE_INT64 , @
"longint" ), _
26 ( FB_DATACLASS_INTEGER, 8, FALSE, 85, FB_DATATYPE_ULONGINT, FB_SIZETYPE_UINT64 , @
"ulongint" ), _
27 ( FB_DATACLASS_FPOINT , 4, TRUE , 0, FB_DATATYPE_SINGLE , FB_SIZETYPE_FLOAT32, @
"single" ), _
28 ( FB_DATACLASS_FPOINT , 8, TRUE , 0, FB_DATATYPE_DOUBLE , FB_SIZETYPE_FLOAT64, @
"double" ), _
29 ( FB_DATACLASS_STRING , -1, FALSE, 0, FB_DATATYPE_STRING , -1 , @
"string" ), _
30 ( FB_DATACLASS_STRING , 1, FALSE, 0, FB_DATATYPE_FIXSTR , -1 , @
"string" ), _
31 ( FB_DATACLASS_UDT , 0, FALSE, 0, FB_DATATYPE_STRUCT , -1 , @
"type" ), _
32 ( FB_DATACLASS_UDT , 0, FALSE, 0, FB_DATATYPE_NAMESPC , -1 , @
"namepace" ), _
33 ( FB_DATACLASS_INTEGER, 0, FALSE, 0, FB_DATATYPE_UINT , -1 , @
"function" ), _
34 ( FB_DATACLASS_UNKNOWN, 0, FALSE, 0, FB_DATATYPE_VOID , -1 , @
"fwdref" ), _
35 ( FB_DATACLASS_INTEGER, -1, FALSE, 0, FB_DATATYPE_UINT , -1 , @
"pointer" ), _
36 ( FB_DATACLASS_INTEGER, 16, FALSE, 0, FB_DATATYPE_XMMWORD , -1 , @
"xmmword" ) _
57 dim shared symb_dtypeMatchTB( FB_DATATYPE_BYTE
to FB_DATATYPE_DOUBLE, FB_DATATYPE_BYTE
to FB_DATATYPE_DOUBLE )
as integer
61 byval dtype
as FB_DATATYPE, _
62 byval dtype1
as FB_DATATYPE, _
63 byval dtype2
as FB_DATATYPE _
67 if( fbCpuTypeIs64bit( ) )
then
76 symb_dtypeTB(FB_DATATYPE_INTEGER ).sizetype = FB_SIZETYPE_INT64
77 symb_dtypeTB(FB_DATATYPE_UINT ).sizetype = FB_SIZETYPE_UINT64
78 symb_dtypeTB(FB_DATATYPE_ENUM ).sizetype = FB_SIZETYPE_INT64
79 symb_dtypeTB(FB_DATATYPE_BITFIELD).sizetype = FB_SIZETYPE_UINT64
80 symb_dtypeTB(FB_DATATYPE_POINTER ).sizetype = FB_SIZETYPE_UINT64
93 symb_dtypeTB(FB_DATATYPE_INTEGER ).sizetype = FB_SIZETYPE_INT32
94 symb_dtypeTB(FB_DATATYPE_UINT ).sizetype = FB_SIZETYPE_UINT32
95 symb_dtypeTB(FB_DATATYPE_ENUM ).sizetype = FB_SIZETYPE_INT32
96 symb_dtypeTB(FB_DATATYPE_BITFIELD).sizetype = FB_SIZETYPE_UINT32
97 symb_dtypeTB(FB_DATATYPE_POINTER ).sizetype = FB_SIZETYPE_UINT32
113 const NUMTYPES = FB_DATATYPE_DOUBLE - FB_DATATYPE_BYTE + 1
114 dim as FB_DATATYPE rank(0
to NUMTYPES - 1)
116 dim as FB_DATATYPE dtype1 =
any, dtype2 =
any
117 dim as integer i =
any, j =
any
119 for dtype1 = FB_DATATYPE_BYTE
to FB_DATATYPE_DOUBLE
122 for dtype2 = FB_DATATYPE_BYTE
to FB_DATATYPE_DOUBLE
123 rank(dtype2 - FB_DATATYPE_BYTE) = dtype2
127 for i = 0
to NUMTYPES - 2
128 for j = i + 1
to NUMTYPES - 1
129 if(
closestType( dtype1, rank(i), rank(j) ) = rank(j) )
then
130 swap rank(i), rank(j)
136 for i = 0
to NUMTYPES - 1
147 byval ldtype
as integer, _
148 byval lsubtype
as FBSYMBOL
ptr, _
149 byval rdtype
as integer, _
150 byval rsubtype
as FBSYMBOL
ptr, _
151 byref dtype
as integer, _
152 byref subtype
as FBSYMBOL
ptr _
155 dim as integer dtype1 =
any, dtype2 =
any
158 if( (typeGetDtAndPtrOnly( ldtype ) = typeGetDtAndPtrOnly( rdtype ))
and _
159 (lsubtype = rsubtype) )
then
168 if( dtype1 = dtype2 )
then
179 elseif( (typeGetClass( dtype1 ) = FB_DATACLASS_INTEGER)
and _
180 (typeGetClass( dtype2 ) = FB_DATACLASS_INTEGER) )
then
181 if( typeGetIntRank( dtype1 ) > typeGetIntRank( dtype2 ) )
then
192 elseif( dtype1 > dtype2 )
then
205 byval dtype
as integer, _
206 byval subtype
as FBSYMBOL
ptr _
209 dim as integer nd =
any
211 select case typeGet( dtype )
212 case FB_DATATYPE_BITFIELD
218 function = typeJoin( dtype, nd )
225 byval dtype
as integer _
228 dim as integer dt = typeGet( dtype ), nd =
any
230 if(
symb_dtypeTB(dt).
class <> FB_DATACLASS_INTEGER )
then
234 select case as const dt
235 case FB_DATATYPE_UBYTE, FB_DATATYPE_CHAR
236 nd = FB_DATATYPE_BYTE
238 case FB_DATATYPE_USHORT
239 nd = FB_DATATYPE_SHORT
241 case FB_DATATYPE_UINT
242 nd = FB_DATATYPE_INTEGER
244 case FB_DATATYPE_WCHAR
247 case FB_DATATYPE_ULONG, FB_DATATYPE_POINTER
248 nd = FB_DATATYPE_LONG
250 case FB_DATATYPE_ULONGINT
251 nd = FB_DATATYPE_LONGINT
257 function = typeJoin( dtype, nd )
264 byval dtype
as integer _
267 dim as integer dt = typeGet( dtype ), nd =
any
269 if(
symb_dtypeTB(dt).
class <> FB_DATACLASS_INTEGER )
then
273 select case as const dt
274 case FB_DATATYPE_BYTE
275 nd = FB_DATATYPE_UBYTE
277 case FB_DATATYPE_SHORT
278 nd = FB_DATATYPE_USHORT
280 case FB_DATATYPE_INTEGER, FB_DATATYPE_ENUM
281 nd = FB_DATATYPE_UINT
283 case FB_DATATYPE_LONG, FB_DATATYPE_POINTER
284 nd = FB_DATATYPE_ULONG
286 case FB_DATATYPE_LONGINT
287 nd = FB_DATATYPE_ULONGINT
293 function = typeJoin( dtype, nd )
299 byval dtype
as integer, _
300 byval subtype
as FBSYMBOL
ptr _
303 select case( typeGet( dtype ) )
304 case FB_DATATYPE_STRUCT
312 byval dtype
as integer, _
313 byval subtype
as FBSYMBOL
ptr _
316 select case( typeGet( dtype ) )
317 case FB_DATATYPE_STRUCT
325 byval dtype
as integer, _
326 byval subtype
as FBSYMBOL
ptr _
329 select case( typeGet( dtype ) )
330 case FB_DATATYPE_STRUCT
364 byval dtype1
as integer, _
365 byval dtype2
as integer _
368 dim as integer oldptrcount =
any, addptrcount =
any
371 oldptrcount = typeGetPtrCnt( dtype1 )
374 addptrcount = typeGetPtrCnt( dtype2 )
377 if( (oldptrcount + addptrcount) > FB_DT_PTRLEVELS )
then
378 errReport( FB_ERRMSG_TOOMANYPTRINDIRECTIONS )
380 oldptrcount = FB_DT_PTRLEVELS - addptrcount
385 dtype1 = typeMultAddrOf( dtype2, oldptrcount )
or _
386 typeGetConstMask( dtype1 )
395 byval dtype
as FB_DATATYPE, _
396 byval dtype1
as FB_DATATYPE, _
397 byval dtype2
as FB_DATATYPE _
401 if( dtype1 <> FB_DATATYPE_ENUM
and dtype2 = FB_DATATYPE_ENUM )
then return dtype1
402 if( dtype2 <> FB_DATATYPE_ENUM
and dtype1 = FB_DATATYPE_ENUM )
then return dtype2
404 if( dtype1 <> FB_DATATYPE_BITFIELD
and dtype2 = FB_DATATYPE_BITFIELD )
then return dtype1
405 if( dtype2 <> FB_DATATYPE_BITFIELD
and dtype1 = FB_DATATYPE_BITFIELD )
then return dtype2
407 if( dtype1 <> FB_DATATYPE_CHAR
and dtype2 = FB_DATATYPE_CHAR )
then return dtype1
408 if( dtype2 <> FB_DATATYPE_CHAR
and dtype1 = FB_DATATYPE_CHAR )
then return dtype2
410 if( dtype1 <> FB_DATATYPE_WCHAR
and dtype2 = FB_DATATYPE_WCHAR )
then return dtype1
411 if( dtype2 <> FB_DATATYPE_WCHAR
and dtype1 = FB_DATATYPE_WCHAR )
then return dtype2
415 dim as integer sameclass1 = (typeGetClass(dtype1) = typeGetClass(dtype))
416 dim as integer sameclass2 = (typeGetClass(dtype2) = typeGetClass(dtype))
418 if ( sameclass1
and not sameclass2 )
then return dtype1
419 if ( sameclass2
and not sameclass1 )
then return dtype2
423 dim as integer larger1 = (typeGetSize( dtype1 ) >= typeGetSize( dtype ))
424 dim as integer larger2 = (typeGetSize( dtype1 ) >= typeGetSize( dtype ))
426 if( larger1
and not larger2 )
then return dtype1
427 if( larger2
and not larger1 )
then return dtype2
431 dim as integer sizediff1 =
abs( typeGetSize( dtype1 ) - typeGetSize( dtype ) )
432 dim as integer sizediff2 =
abs( typeGetSize( dtype2 ) - typeGetSize( dtype ) )
434 if( sizediff1 < sizediff2 )
then return dtype1
435 if( sizediff2 < sizediff1 )
then return dtype2
439 dim as integer isint1 = (
typeToSigned( dtype1 ) = FB_DATATYPE_INTEGER)
440 dim as integer isint2 = (
typeToSigned( dtype2 ) = FB_DATATYPE_INTEGER)
442 if( isint1
and not isint2 )
then return dtype1
443 if( isint2
and not isint1 )
then return dtype2
447 dim as integer samesign1 = (typeIsSigned( dtype1 ) = typeIsSigned( dtype ))
448 dim as integer samesign2 = (typeIsSigned( dtype2 ) = typeIsSigned( dtype ))
450 if( samesign1
and not samesign2 )
then return dtype1
451 if( samesign2
and not samesign1 )
then return dtype2
455 assert( dtype1 = dtype2 )