18 byval ismain
as integer _
51 dim shared as integer deftypeTB( 0
to (
asc(
"_" ) -
asc(
"A" ) + 1) - 1 )
61 listInit( @
symb.symlist, FB_INITSYMBOLNODES,
len( FBSYMBOL ), LIST_FLAGS_NOCLEAR )
64 poolInit( @
symb.namepool, FB_INITSYMBOLNODES \ 8, FB_MAXNAMELEN\8+1, FB_MAXNAMELEN+1 )
66 symb.chainpoolhead = 0
69 listInit( @
symb.nsextlist, FB_INITSYMBOLNODES \ 16,
len( FBNAMESPC_EXT ), LIST_FLAGS_CLEAR )
72 symb.globnspc.
class = FB_SYMBCLASS_NAMESPACE
73 symb.globnspc.
scope = FB_MAINSCOPE
75 with symb.globnspc.nspc
76 symbSymbTbInit( .ns.symtb, @
symb.globnspc )
77 symbHashTbInit( .ns.hashtb, @
symb.globnspc, FB_INITSYMBOLNODES )
78 .ns.ext = symbCompAllocExt( )
83 symb.symtb = @
symb.globnspc.nspc.ns.symtb
84 symb.hashtb = @
symb.globnspc.nspc.ns.hashtb
87 symb.hashlist.head = NULL
88 symb.hashlist.tail = NULL
94 listInit( @
symb.imphashlist, FB_INITSYMBOLNODES \ 2,
len( FBSYMCHAIN ), LIST_FLAGS_NOCLEAR )
105 dim as integer dtype, i
107 if( fbLangIsSet( FB_LANG_QB ) )
then
108 dtype = FB_DATATYPE_SINGLE
110 dtype = FB_DATATYPE_INTEGER
114 for i = 0
to (
asc(
"_")-
asc(
"A")+1)-1
123 byval ismain
as integer _
127 if(
symb.inited )
then
169 if(
symb.inited = FALSE )
then
176 symbGetGlobalTb( ).head = NULL
177 symbGetGlobalTb( ).tail = NULL
203 symbCompFreeExt(
symb.globnspc.nspc.ns.ext )
224 byval head_sym
as FBSYMBOL
ptr, _
225 byval s
as FBSYMBOL
ptr _
230 select case as const s->
class
232 case FB_SYMBCLASS_DEFINE, FB_SYMBCLASS_KEYWORD, _
233 FB_SYMBCLASS_NAMESPACE, FB_SYMBCLASS_CLASS, _
240 case FB_SYMBCLASS_STRUCT, FB_SYMBCLASS_ENUM, _
247 select case as const head_sym->
class
250 case FB_SYMBCLASS_DEFINE, FB_SYMBCLASS_NAMESPACE, _
251 FB_SYMBCLASS_STRUCT, FB_SYMBCLASS_ENUM, _
252 FB_SYMBCLASS_TYPEDEF, FB_SYMBCLASS_CLASS, _
258 head_sym = head_sym->hash.
next
259 loop while( head_sym <> NULL )
262 case FB_SYMBCLASS_FWDREF
265 select case head_sym->
class
268 case FB_SYMBCLASS_DEFINE, FB_SYMBCLASS_NAMESPACE, _
269 FB_SYMBCLASS_FWDREF, FB_SYMBCLASS_CLASS
274 case FB_SYMBCLASS_STRUCT
275 if( symbGetIsUnique( head_sym ) )
then
280 head_sym = head_sym->hash.
next
281 loop while( head_sym <> NULL )
284 case FB_SYMBCLASS_CONST, FB_SYMBCLASS_PROC
287 select case as const head_sym->
class
289 case FB_SYMBCLASS_LABEL, FB_SYMBCLASS_ENUM, _
290 FB_SYMBCLASS_TYPEDEF, FB_SYMBCLASS_FWDREF
293 case FB_SYMBCLASS_STRUCT
294 if( symbGetIsUnique( head_sym ) )
then
299 case FB_SYMBCLASS_KEYWORD, FB_SYMBCLASS_PROC
300 if( env.clopt.lang <> FB_LANG_QB )
then
305 if( symbIsProc( head_sym ) )
then
306 if( symbGetIsRTL( head_sym ) = FALSE )
then
311 if( symbGetIsRTL( head_sym ) )
then
318 if( symbIsSuffixed( s ) )
then
319 if( symbGetType( s ) = symbGetType( head_sym ) )
then
323 if( symbGetType( head_sym ) <> FB_DATATYPE_STRING )
then
332 head_sym = head_sym->hash.
next
333 loop while( head_sym <> NULL )
336 case FB_SYMBCLASS_VAR
339 select case as const head_sym->
class
341 case FB_SYMBCLASS_LABEL, FB_SYMBCLASS_ENUM, _
342 FB_SYMBCLASS_TYPEDEF, FB_SYMBCLASS_FWDREF
345 case FB_SYMBCLASS_STRUCT
346 if( symbGetIsUnique( head_sym ) )
then
351 case FB_SYMBCLASS_KEYWORD, FB_SYMBCLASS_PROC
352 if( env.clopt.lang <> FB_LANG_QB )
then
357 if( symbIsProc( head_sym ) )
then
358 if( symbGetIsRTL( head_sym ) = FALSE )
then
364 if( symbIsSuffixed( s ) )
then
365 if( symbGetType( s ) = symbGetType( head_sym ) )
then
369 if( symbGetType( head_sym ) <> FB_DATATYPE_STRING )
then
375 case FB_SYMBCLASS_FIELD
377 if( s->
scope = head_sym->
scope )
then
383 case FB_SYMBCLASS_VAR
385 if( s->
scope = head_sym->
scope )
then
386 if( env.clopt.lang = FB_LANG_FB )
then
391 if( symbGetType( head_sym ) = symbGetType( s ) )
then
396 if( ( symbIsSuffixed( head_sym ) = FALSE )
and ( symbIsSuffixed( s ) = FALSE ) )
then
406 head_sym = head_sym->hash.
next
407 loop while( head_sym <> NULL )
410 case FB_SYMBCLASS_LABEL
413 select case as const head_sym->
class
415 case FB_SYMBCLASS_DEFINE, FB_SYMBCLASS_NAMESPACE, _
416 FB_SYMBCLASS_KEYWORD, FB_SYMBCLASS_LABEL, _
422 case FB_SYMBCLASS_STRUCT
423 if( symbGetIsUnique( head_sym ) )
then
428 head_sym = head_sym->hash.
next
429 loop while( head_sym <> NULL )
432 case FB_SYMBCLASS_PARAM
445 byval options
as FB_SYMBOPT, _
446 byval s
as FBSYMBOL
ptr, _
447 byval symtb
as FBSYMBOLTB
ptr, _
448 byval hashtb
as FBHASHTB
ptr, _
449 byval class_
as FB_SYMBCLASS, _
450 byval id
as const zstring ptr, _
451 byval id_alias
as const zstring ptr, _
452 byval dtype
as integer, _
453 byval subtype
as FBSYMBOL
ptr, _
454 byval attrib
as FB_SYMBATTRIB _
457 dim as integer slen =
any, delok =
any
461 if( symtb = NULL )
then
465 if( fbIsModLevel( ) )
then
467 if( parser.
scope = FB_MAINSCOPE )
then
469 if( symbIsGlobalNamespc( ) )
then
472 symtb = @symbGetGlobalTb( )
475 attrib
and=
not FB_SYMBATTRIB_LOCAL
477 attrib
or= FB_SYMBATTRIB_LOCAL
480 attrib
or= FB_SYMBATTRIB_LOCAL
484 if( hashtb = NULL )
then
499 s->mangling = parser.mangling
505 if( (options
and FB_SYMBOPT_UNSCOPE) <> 0 )
then
506 if( (parser.currproc->stats
and (FB_SYMBSTATS_MAINPROC
or _
507 FB_SYMBSTATS_MODLEVELPROC)) <> 0 )
then
508 s->
scope = FB_MAINSCOPE
510 s->
scope = parser.currproc->
scope + 1
513 s->
scope = parser.
scope
517 slen =
iif( id <> NULL,
len( *id ), 0 )
520 if( (options
and FB_SYMBOPT_PRESERVECASE) = 0 )
then
527 options
and=
not FB_SYMBOPT_DOHASH
531 if( id_alias <> NULL )
then
532 s->id.
alias = ZstrAllocate(
len( *id_alias ) )
533 *s->id.
alias = *id_alias
547 if( (options
and FB_SYMBOPT_DOHASH) <> 0 )
then
548 dim as FBSYMBOL
ptr head_sym =
any
550 s->hash.index =
hashHash( s->id.
name )
553 head_sym =
hashLookupEx( @hashtb->tb, s->id.
name, s->hash.index )
554 if( head_sym = NULL )
then
556 s->hash.item =
hashAdd( @hashtb->tb, s->id.
name, s, s->hash.index )
562 if( (options
and FB_SYMBOPT_NODUPCHECK) = 0 )
then
565 ZstrFree( s->id.
alias )
566 ZstrFree( s->id.mangled )
574 s->hash.item = head_sym->hash.item
579 if( env.clopt.lang = FB_LANG_QB )
then
581 dim as FBSYMBOL
ptr prev = NULL
582 do while( symbIsKeyword( head_sym ) )
584 head_sym = head_sym->hash.
next
585 if( head_sym = NULL )
then
590 if( prev = NULL )
then
596 s->hash.
next = head_sym
597 if( head_sym <> NULL )
then
598 head_sym->hash.prev = s
602 add_prev: head_sym->hash.item->
data = s
603 head_sym->hash.item->
name = s->id.
name
604 head_sym->hash.prev = s
606 s->hash.
next = head_sym
618 if( symtb->tail <> NULL )
then
619 symtb->tail->
next = s
624 s->prev = symtb->tail
634 if( typeGetDtOnly( dtype ) = FB_DATATYPE_FWDREF )
then
650 byval hashtb
as FBHASHTB
ptr _
653 if(
symb.hashlist.tail <> NULL )
then
654 symb.hashlist.tail->
next = hashtb
656 symb.hashlist.head = hashtb
659 hashtb->prev =
symb.hashlist.tail
662 symb.hashlist.tail = hashtb
669 byval lasttb
as FBHASHTB
ptr, _
670 byval hashtb
as FBHASHTB
ptr _
673 if( lasttb->prev = NULL )
then
674 symb.hashlist.head = hashtb
676 lasttb->prev->
next = hashtb
679 hashtb->prev = lasttb->prev
680 hashtb->
next = lasttb
682 lasttb->prev = hashtb
689 byval hashtb
as FBHASHTB
ptr _
692 assert( hashtb->prev <> NULL
or hashtb->
next <> NULL )
694 if( hashtb->prev <> NULL )
then
695 hashtb->prev->
next = hashtb->
next
697 symb.hashlist.head = hashtb->
next
700 if( hashtb->
next <> NULL )
then
701 hashtb->
next->prev = hashtb->prev
703 symb.hashlist.tail = hashtb->prev
714 byval ns
as FBSYMBOL
ptr, _
715 byval src_head
as FBSYMBOL
ptr _
718 dim as FBSYMCHAIN
ptr imp_head = symbGetCompExt( ns )->impsym_head
719 dim as FBSYMCHAIN
ptr imp_tail = symbGetCompExt( ns )->impsym_tail
722 dim as FBSYMBOL
ptr s = src_head
725 if( s->hash.item <> NULL )
then
727 if( s->hash.prev = NULL )
then
737 if( head = NULL )
then
754 if( imp_tail <> NULL )
then
755 imp_tail->imp_next =
chain_
767 symbGetCompExt( ns )->impsym_head = imp_head
768 symbGetCompExt( ns )->impsym_tail = imp_tail
775 byval ns
as FBSYMBOL
ptr _
778 dim as FBSYMCHAIN
ptr chain_ = symbGetCompExt( ns )->impsym_head
781 dim as FBSYMCHAIN
ptr prv =
any, nxt =
any
786 if( prv <> NULL )
then
788 if( nxt <> NULL )
then
793 if( nxt <> NULL )
then
810 symbGetCompExt( ns )->impsym_head = NULL
811 symbGetCompExt( ns )->impsym_tail = NULL
816 symb.chainpoolhead += 1
817 if (
symb.chainpoolhead >= CHAINPOOL_SIZE)
then
818 symb.chainpoolhead = 0
820 return @
symb.chainpool(
symb.chainpoolhead)
826 byval id
as zstring ptr, _
827 byref tk
as FB_TOKEN, _
828 byref tk_class
as FB_TKCLASS, _
829 byval preserve_case
as integer _
832 static as zstring * FB_MAXNAMELEN+1 sname
836 tk_class = FB_TKCLASS_IDENTIFIER
838 if( preserve_case = FALSE )
then
843 dim as uinteger index =
hashHash( id )
844 dim as FBSYMCHAIN
ptr chain_ = NULL
847 dim as FBHASHTB
ptr hashtb =
symb.hashlist.tail
850 dim as FBSYMBOL
ptr sym =
hashLookupEx( @hashtb->tb, id, index )
851 if( sym <> NULL )
then
858 if( sym->
class = FB_SYMBCLASS_KEYWORD )
then
860 tk_class = sym->key.tkclass
863 if( tk_class <> FB_TKCLASS_QUIRKWD )
then
871 if( hashtb->owner <> @symbGetGlobalNamespc( ) )
then
875 if( symbGetCurrentNamespc( ) = @symbGetGlobalNamespc( ) )
then
884 hashtb = hashtb->prev
885 loop while( hashtb <> NULL )
888 dim as FBSYMCHAIN
ptr imp_chain =
hashLookupEx( @
symb.imphashtb, id, index )
902 byval ns
as FBSYMBOL
ptr, _
903 byval id
as const zstring ptr, _
904 byval index
as uinteger _
907 dim as FBSYMCHAIN
ptr chain_head =
hashLookupEx( @
symb.imphashtb, id, index )
908 if( chain_head = NULL )
then
912 dim as FBSYMCHAIN
ptr head = NULL, tail = NULL
915 dim as FBSYMCHAIN
ptr chain_ = chain_head
918 dim as FBSYMBOL
ptr exp_ = symbGetCompExportHead( symbGetNamespace(
chain_->sym ) )
920 if( symbGetExportNamespc( exp_ ) = ns )
then
925 node->isimport = TRUE
927 if( head = NULL )
then
938 exp_ = symbGetExportNext( exp_ )
939 loop while( exp_ <> NULL )
942 loop while(
chain_ <> NULL )
951 byval ns
as FBSYMBOL
ptr, _
952 byval id
as const zstring ptr, _
953 byval index
as uinteger _
956 dim as FBSYMCHAIN
ptr head = NULL, tail = NULL
959 dim as FBSYMBOL
ptr imp_ = symbGetCompImportHead( ns )
960 do while( imp_ <> NULL )
962 @symbGetCompHashTb( _
963 symbGetImportNamespc( imp_ ) ).tb, _
966 if( sym <> NULL )
then
973 if( head = NULL )
then
984 imp_ = symbGetImportNext( imp_ )
994 byval ns
as FBSYMBOL
ptr, _
995 byval id
as const zstring ptr, _
996 byval preserve_case
as integer, _
997 byval search_imports
as integer _
1000 static as zstring * FB_MAXNAMELEN+1 sname
1002 assert( symbIsStruct( ns )
or symbIsNamespace( ns )
or symbIsEnum( ns ) )
1004 if( preserve_case = FALSE )
then
1009 dim as uinteger index =
hashHash( id )
1012 dim as FBSYMBOL
ptr sym =
hashLookupEx( @symbGetCompHashTb( ns ).tb, id, index )
1013 if( sym = NULL )
then
1014 if( search_imports = FALSE )
then
1027 if( symbGetCompExt( ns ) = NULL )
then
1031 if( symbGetCompImportHead( ns ) = NULL )
then
1036 if( ns = @symbGetGlobalNamespc( ) )
then
1049 byval ns
as FBSYMBOL
ptr, _
1050 byval id
as const zstring ptr, _
1051 byval class_
as integer, _
1052 byval preserve_case
as integer, _
1053 byval search_imports
as integer _
1056 dim as FBSYMCHAIN
ptr chain_ =
any
1061 if(
chain_ <> NULL )
then
1073 byval ns
as FBSYMBOL
ptr, _
1074 byval id
as zstring ptr, _
1075 byval suffix
as integer, _
1076 byval preserve_case
as integer, _
1077 byval search_imports
as integer _
1080 dim as FBSYMCHAIN
ptr chain_ =
any
1085 if(
chain_ <> NULL )
then
1087 if( suffix = FB_DATATYPE_INVALID )
then
1102 byval chain_ as FBSYMCHAIN
ptr, _
1103 byval class_
as integer _
1106 dim as FBSYMBOL
ptr sym =
any
1107 dim as integer match = FALSE
1110 do while(
chain_ <> NULL )
1113 if( sym->
class = class_ )
then
1118 sym = sym->hash.
next
1119 loop while( sym <> NULL )
1124 if( match = FALSE )
then
1129 if( symbIsVar( sym ) )
then
1144 byval chain_ as FBSYMCHAIN
ptr, _
1145 byval suffix
as integer _
1148 dim as FBSYMBOL
ptr sym =
any
1153 if( suffix = FB_DATATYPE_STRING )
then
1154 do while(
chain_ <> NULL )
1157 if( symbIsVar( sym ) )
then
1158 select case symbGetType( sym )
1159 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR
1164 sym = sym->hash.
next
1165 loop while( sym <> NULL )
1172 do while(
chain_ <> NULL )
1175 if( symbIsVar( sym ) )
then
1176 if( symbGetType( sym ) = suffix )
then
1181 sym = sym->hash.
next
1182 loop while( sym <> NULL )
1203 byval chain_ as FBSYMCHAIN
ptr, _
1204 byval def_dtype
as integer _
1207 dim as FBSYMBOL
ptr sym =
any
1213 if( def_dtype = FB_DATATYPE_STRING )
then
1214 do while(
chain_ <> NULL )
1217 if( symbIsVar( sym ) )
then
1218 if( symbIsSuffixed( sym ) )
then
1219 select case sym->typ
1220 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR
1228 sym = sym->hash.
next
1229 loop while( sym <> NULL )
1236 do while(
chain_ <> NULL )
1239 if( symbIsVar( sym ) )
then
1240 if( symbIsSuffixed( sym ) )
then
1241 if( symbGetType( sym ) = def_dtype )
then
1249 sym = sym->hash.
next
1250 loop while( sym <> NULL )
1271 byval chain_ as FBSYMCHAIN
ptr, _
1272 byval dtype
as integer _
1275 dim as FBSYMBOL
ptr sym =
any
1277 do while(
chain_ <> NULL )
1280 if( symbIsVar( sym ) )
then
1281 if( symbGetFullType( sym ) = dtype )
then
1286 sym = sym->hash.
next
1287 loop while( sym <> NULL )
1311 byval s
as FBSYMBOL
ptr _
1314 dim as FBSYMBOL
ptr prv =
any, nxt =
any
1323 if( prv <> NULL )
then
1324 prv->hash.
next = nxt
1326 if( nxt <> NULL )
then
1327 nxt->hash.prev = prv
1332 if( nxt <> NULL )
then
1333 nxt->hash.prev = NULL
1336 s->hash.item->
data = nxt
1337 s->hash.item->
name = nxt->id.
name
1341 hashDel( @s->hash.tb->tb, s->hash.item, s->hash.index )
1350 byval s
as FBSYMBOL
ptr _
1353 if( s->hash.item = NULL )
then
1366 byval s
as FBSYMBOL
ptr _
1376 if( typeGetDtOnly( s->typ ) = FB_DATATYPE_FWDREF )
then
1377 assert( s->subtype->
class = FB_SYMBCLASS_FWDREF )
1392 byval s
as FBSYMBOL
ptr _
1398 ZstrFree( s->id.
alias )
1399 ZstrFree( s->id.mangled )
1408 byval s
as FBSYMBOL
ptr _
1411 dim as FBSYMBOLTB
ptr tb =
any
1412 dim as FBSYMBOL
ptr prv =
any, nxt =
any
1419 if( prv <> NULL )
then
1425 if( nxt <> NULL )
then
1438 byval s
as FBSYMBOL
ptr, _
1439 byval is_tbdel
as integer _
1449 select case as const s->
class
1450 case FB_SYMBCLASS_VAR
1453 case FB_SYMBCLASS_CONST
1456 case FB_SYMBCLASS_PROC
1459 case FB_SYMBCLASS_DEFINE
1462 case FB_SYMBCLASS_LABEL
1465 case FB_SYMBCLASS_ENUM
1468 case FB_SYMBCLASS_STRUCT
1471 case FB_SYMBCLASS_SCOPE
1474 case FB_SYMBCLASS_NAMESPACE
1477 case FB_SYMBCLASS_NSIMPORT
1480 case FB_SYMBCLASS_FIELD
1495 select case as const s->
class
1496 case FB_SYMBCLASS_PROC
1499 assert( symbGetIsFuncPtr( s ) )
1502 case FB_SYMBCLASS_VAR
1505 case FB_SYMBCLASS_CONST
1508 case FB_SYMBCLASS_LABEL
1511 case FB_SYMBCLASS_STRUCT
1527 dim as FBSYMBOL
ptr s = symbGetGlobalTb( ).tail
1540 byval tb
as FBSYMBOLTB
ptr, _
1541 byval hashonly
as integer _
1546 dim as FBSYMBOL
ptr s = tb->head
1550 if( s->
class = FB_SYMBCLASS_NSIMPORT )
then
1561 dim as FBSYMBOL
ptr s = tb->tail
1579 assert( symbIsStruct( sym ) = FALSE )
1585 assert( symbIsStruct( sym ) = FALSE )
1590 assert( symbIsStruct( sym ) = FALSE )
1597 byval sym
as FBSYMBOL
ptr _
1600 select case sym->
class
1601 case FB_SYMBCLASS_VAR, FB_SYMBCLASS_FIELD
1602 if (symbGetIsDynamic(sym))
then
1605 return symbGetArrayDimensions( sym ) <> 0
1616 byval dtype
as integer _
1619 select case as const dtype
1620 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
1631 byval sym1
as FBSYMBOL
ptr, _
1632 byval sym2
as FBSYMBOL
ptr _
1635 dim as FBSYMBOL
ptr paraml =
any, paramr =
any
1640 if( sym1 = sym2 )
then
1645 if( (sym1 = NULL)
or (sym2 = NULL) )
then
1650 if( sym1->
class <> sym2->
class )
then
1655 if( sym1->typ <> sym2->typ )
then
1659 select case sym1->
class
1661 case FB_SYMBCLASS_STRUCT
1665 case FB_SYMBCLASS_ENUM
1671 case FB_SYMBCLASS_PROC
1673 if( symbProcReturnsByref( sym1 ) <> symbProcReturnsByref( sym2 ) )
then
1683 if( symbGetProcParams( sym1 ) <> symbGetProcParams( sym2 ) )
then
1686 if( symbGetProcParams( sym1 ) = 0 )
then
1691 if( symbGetProcTailParam( sym1 )->param.mode <> FB_PARAMMODE_VARARG )
then
1696 if( (symbGetProcParams( sym2 ) - symbGetProcParams( sym1 )) < -1 )
then
1702 paraml = symbGetProcHeadParam( sym1 )
1703 paramr = symbGetProcHeadParam( sym2 )
1705 do while( paraml <> NULL )
1707 if( paraml->param.mode = FB_PARAMMODE_VARARG )
then
1712 if( paraml->param.mode <> paramr->param.mode )
then
1717 if( paraml->typ <> paramr->typ )
then
1722 if( paraml->subtype <> paramr->subtype )
then
1727 paraml = paraml->
next
1728 paramr = paramr->
next
1733 if( sym1->subtype <> sym2->subtype )
then
1734 function =
symbIsEqual( sym1->subtype, sym2->subtype )
1743 byval dtype
as integer, _
1744 byval subtype
as FBSYMBOL
ptr, _
1745 byval length
as longint _
1749 dim as integer dtypeonly =
any, ptrcount =
any
1751 if( dtype = FB_DATATYPE_INVALID )
then
1755 ptrcount = typeGetPtrCnt( dtype )
1756 if( typeIsConstAt( dtype, ptrcount ) )
then
1762 dtypeonly = typeGetDtOnly( dtype )
1764 select case as const( dtypeonly )
1765 case FB_DATATYPE_FWDREF, FB_DATATYPE_STRUCT, FB_DATATYPE_ENUM
1766 s += *symbGetName( subtype )
1768 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR, FB_DATATYPE_FIXSTR
1769 s += *symb_dtypeTB(dtypeonly).
name
1770 if( length > 0 )
then
1771 select case( dtypeonly )
1772 case FB_DATATYPE_FIXSTR
1777 case FB_DATATYPE_WCHAR
1779 length \= typeGetSize( FB_DATATYPE_WCHAR )
1781 s +=
" * " +
str( length )
1784 case FB_DATATYPE_FUNCTION
1788 assert( ptrcount > 0 )
1797 if( ptrcount > 0 )
then
1803 if( ptrcount > 0 )
then
1808 s += *symb_dtypeTB(dtypeonly).
name
1811 for i
as integer = ptrcount-1
to 0 step -1
1812 if( typeIsConstAt( dtype, i ) )
then
1824 byval symbol
as const zstring ptr _
1827 dim as integer c =
any
1828 dim as integer i =
any
1833 if( (c >=
asc(
"a"))
and (c <=
asc(
"z")) )
then
1834 c -= (
asc(
"a") -
asc(
"A"))
1842 if( fbLangIsSet( FB_LANG_QB ) )
then
1843 function = FB_DATATYPE_SINGLE
1845 function = FB_DATATYPE_INTEGER
1856 byval ichar
as integer, _
1857 byval echar
as integer, _
1858 byval dtype
as integer _
1861 dim as integer i =
any
1863 if( ichar <
asc(
"A") )
then
1865 elseif( ichar >
asc(
"_") )
then
1869 if( echar <
asc(
"A") )
then
1871 elseif( echar >
asc(
"_") )
then
1875 if( ichar > echar )
then
1879 for i = ichar
to echar
1887 if( sym->
class = FB_SYMBCLASS_PARAM )
then
1896 byval sym
as FBSYMBOL
ptr, _
1897 byval dtype
as integer, _
1898 byval subtype
as FBSYMBOL
ptr _
1902 sym->subtype = subtype
1907 if( symbIsProc( sym ) )
then
1913 if( typeGetDtOnly( dtype ) = FB_DATATYPE_FWDREF )
then
1921 byval dtype
as integer, _
1922 byval subtype
as FBSYMBOL
ptr _
1925 dtype = typeGet( dtype )
1927 select case as const( dtype )
1928 case FB_DATATYPE_FIXSTR
1931 case FB_DATATYPE_STRUCT, FB_DATATYPE_BITFIELD
1932 function = subtype->lgt
1935 function = typeGetSize( dtype )
1942 byval dtype
as integer, _
1943 byval subtype
as FBSYMBOL
ptr _
1946 dim as longint length =
any
1948 assert( typeIsPtr( dtype ) )
1950 length =
symbCalcLen( typeDeref( dtype ), subtype )
1953 if( length = 0 )
then
1955 if( dtype = typeAddrOf( FB_DATATYPE_VOID ) )
then
1966 dim as FBSYMBOL
ptr parent =
any, context =
any
1969 if( (sym->attrib
and (FB_SYMBATTRIB_VIS_PRIVATE
or FB_SYMBATTRIB_VIS_PROTECTED)) = 0 )
then
1990 assert( parent <> @symbGetGlobalNamespc( ) )
1991 parent = symbGetNamespace( parent )
1992 loop while(
not symbIsStruct( parent ) )
2002 context = symbGetCurrentNamespc( )
2003 while( context <> @symbGetGlobalNamespc( ) )
2006 if( symbIsStruct( context ) )
then
2008 if( context = parent )
then
2014 if( sym->attrib
and FB_SYMBATTRIB_VIS_PROTECTED )
then
2022 context = symbGetNamespace( context )
2030 byval ldtype
as FB_DATATYPE, _
2031 byval rdtype
as FB_DATATYPE, _
2032 byval lsubtype
as FBSYMBOL
ptr, _
2033 byval rsubtype
as FBSYMBOL
ptr, _
2034 byval mode
as FB_PARAMMODE = 0, _
2035 byref matches
as integer = 0 _
2042 if( (typeGetConstMask( ldtype )
or typeGetConstMask( rdtype )) = 0 )
then
2047 if( mode = FB_PARAMMODE_VARARG )
then
2051 dim as integer l_cnt = typeGetPtrCnt( ldtype ), r_cnt = typeGetPtrCnt( rdtype ), start_at =
any
2054 if( typeGetConstMask( rdtype )
and typeIsPtr( rdtype ) )
then
2057 if( typeGetDtAndPtrOnly( ldtype ) <> typeGetDtAndPtrOnly( rdtype ) )
then
2060 if( (typeGetDtAndPtrOnly( ldtype ) = typeAddrOf(FB_DATATYPE_VOID)) = FALSE )
then
2065 if( lsubtype <> rsubtype )
then
2069 if( l_cnt <> r_cnt )
then
2080 if( mode = FB_PARAMMODE_BYVAL )
then
2085 if( typeIsConst( ldtype ) )
then
2105 for i
as integer = start_at
to l_cnt
2108 if( typeIsConstAt( ldtype, i ) = typeIsConstAt( rdtype, i ) )
then
2109 if( (r_cnt) > matches )
then
2115 if( typeIsConstAt( rdtype, i ) )
then
2116 if( typeIsConstAt( ldtype, i ) = FALSE )
then
2129 static shared as zstring ptr classnames(FB_SYMBCLASS_VAR
to FB_SYMBCLASS_NSIMPORT) = _
2153 byval dtype
as integer, _
2154 byval subtype
as FBSYMBOL
ptr _
2158 dim as integer ok =
any, ptrcount =
any
2162 if( dtype
and FB_DATATYPE_INVALID )
then
2164 ok = (subtype = NULL)
2166 ptrcount =
abs( typeGetPtrCnt( dtype ) )
2168 if( typeIsConstAt( dtype, ptrcount ) )
then
2172 select case( typeGetDtOnly( dtype ) )
2173 case FB_DATATYPE_STRUCT
2175 case FB_DATATYPE_WCHAR
2178 dump += *symb_dtypeTB(typeGetDtOnly( dtype )).
name
2182 select case( typeGetDtOnly( dtype ) )
2183 case FB_DATATYPE_STRUCT, FB_DATATYPE_ENUM
2185 if( symbIsStruct( subtype ) )
then
2186 dump +=
" " + *symbGetName( subtype )
2191 for i
as integer = (ptrcount-1)
to 0 step -1
2192 if( typeIsConstAt( dtype, i ) )
then
2200 select case( typeGetDtOnly( dtype ) )
2201 case FB_DATATYPE_STRUCT
2202 ok = symbIsStruct( subtype )
2203 case FB_DATATYPE_ENUM
2204 ok = symbIsEnum( subtype )
2205 case FB_DATATYPE_NAMESPC
2206 ok = symbIsNamespace( subtype )
2207 case FB_DATATYPE_BITFIELD
2208 ok = symbIsBitfield( subtype )
2209 case FB_DATATYPE_FUNCTION
2210 ok = symbIsProc( subtype )
2211 case FB_DATATYPE_FWDREF
2212 ok = symbIsFwdref( subtype )
2217 select case( typeGetDtOnly( dtype ) )
2218 case FB_DATATYPE_STRUCT, FB_DATATYPE_ENUM, _
2219 FB_DATATYPE_NAMESPC, FB_DATATYPE_BITFIELD, _
2220 FB_DATATYPE_FUNCTION, FB_DATATYPE_FWDREF
2228 if( ok = FALSE )
then
2231 if( (subtype->
class >= FB_SYMBCLASS_VAR)
and _
2232 (subtype->
class < FB_SYMBCLASS_NSIMPORT) )
then
2235 dump +=
str( subtype->
class )
2248 dim as FBSYMBOL
ptr ns =
any
2251 ns = symbGetNamespace( sym )
2252 while( ns <> @symbGetGlobalNamespc( ) )
2253 s = *symbGetName( ns ) +
"." + s
2255 if( symbGetHashtb( ns ) = NULL )
then
2259 ns = symbGetNamespace( ns )
2265 function symbDump(
byval sym
as FBSYMBOL
ptr )
as string
2268 if( sym = NULL )
then
2273 s +=
"[" &
hex( sym ) &
"] "
2277 if( (sym->
class < FB_SYMBCLASS_VAR)
or (sym->
class > FB_SYMBCLASS_NSIMPORT) )
then
2278 s +=
"<bad class " +
str( sym->
class ) +
"> "
2285 #macro checkAttrib( ID )
2286 if( sym->attrib
and FB_SYMBATTRIB_##ID )
then
2287 s +=
lcase( #ID ) +
" "
2291 checkAttrib(
SHARED )
2292 checkAttrib(
STATIC )
2293 checkAttrib(
DYNAMIC )
2294 checkAttrib(
COMMON )
2295 checkAttrib(
EXTERN )
2296 checkAttrib(
PUBLIC )
2297 checkAttrib(
PRIVATE )
2298 checkAttrib(
LOCAL )
2299 checkAttrib(
EXPORT )
2300 checkAttrib(
IMPORT )
2301 checkAttrib( OVERLOADED )
2302 if( symbIsProc( sym ) )
then
2303 checkAttrib( METHOD )
2305 checkAttrib( PARAMINSTANCE )
2307 checkAttrib(
CONSTRUCTOR )
2308 checkAttrib(
DESTRUCTOR )
2309 checkAttrib(
OPERATOR )
2310 checkAttrib(
PROPERTY )
2311 checkAttrib( PARAMBYDESC )
2312 checkAttrib( PARAMBYVAL )
2313 checkAttrib( PARAMBYREF )
2314 checkAttrib( LITERAL )
2315 checkAttrib(
CONST )
2316 if( symbIsProc( sym ) )
then
2317 checkAttrib( STATICLOCALS )
2319 checkAttrib( OPTIONAL )
2322 checkAttrib( DESCRIPTOR )
2323 checkAttrib( FUNCRESULT )
2324 checkAttrib( RETURNSBYREF )
2325 checkAttrib( VIS_PRIVATE )
2326 checkAttrib( VIS_PROTECTED )
2327 if( symbIsProc( sym ) )
then
2328 checkAttrib(
NAKED )
2330 checkAttrib( SUFFIXED )
2332 checkAttrib(
ABSTRACT )
2333 checkAttrib(
VIRTUAL )
2337 #macro checkStat( ID )
2338 if( sym->stats
and FB_SYMBSTATS_##ID )
then
2339 s +=
lcase( #ID ) +
" "
2343 checkStat( VARALLOCATED )
2344 checkStat( ACCESSED )
2345 if( symbIsProc( sym ) )
then
2346 checkStat( CTORINITED )
2348 checkStat( INITIALIZED )
2350 checkStat( DECLARED )
2352 checkStat( THROWABLE )
2354 checkStat( HASALIAS )
2355 if( symbIsProc( sym ) )
then
2356 checkStat( EXCLPARENT )
2358 checkStat( DONTINIT )
2360 checkStat( MAINPROC )
2361 checkStat( MODLEVELPROC )
2362 checkStat( FUNCPTR )
2364 checkStat( GLOBALCTOR )
2365 checkStat( GLOBALDTOR )
2366 checkStat( CANTDUP )
2367 if( symbIsProc( sym ) )
then
2368 checkStat( GCCBUILTIN )
2369 checkStat( IRHLCBUILTIN )
2371 checkStat( HASRTTI )
2372 checkStat( CANTUNDEF )
2373 if( symbIsField( sym ) )
then
2374 checkStat( UNIONFIELD )
2375 elseif( symbIsProc( sym ) )
then
2376 checkStat( PROCEMITTED )
2378 checkStat(
WSTRING )
2380 checkStat( RTL_CONST )
2381 checkStat( EMITTED )
2382 checkStat( BEINGEMITTED )
2385 if( sym->
class = FB_SYMBCLASS_NSIMPORT )
then
2392 if( sym = @symbGetGlobalNamespc( ) )
then
2393 s +=
"<global namespace>"
2399 if( symbIsProc( sym )
and symbIsOperator( sym ) )
then
2400 s += *astGetOpId( symbGetProcOpOvl( sym ) )
2402 if( sym->id.
name )
then
2410 if( sym->id.
alias )
then
2411 s +=
" alias """ + *sym->id.
alias +
""""
2424 if( sym->typ
and FB_DATATYPE_INVALID )
then
2425 if( sym->
class = FB_SYMBCLASS_KEYWORD )
then
2433 if( sym->subtype = NULL )
then
2434 select case as const( sym->typ )
2435 case FB_DATATYPE_FWDREF
2437 case FB_DATATYPE_STRUCT
2438 if( symbIsStruct( sym ) )
then
2439 if( symbGetUDTIsUnion( sym ) )
then
2447 case FB_DATATYPE_ENUM
2461 dim as FBSYMBOL
ptr i =
any
2462 dim as THASH
ptr hash =
any
2463 dim as HASHITEM
ptr hashitem =
any
2465 select case( ns->
class )
2466 case FB_SYMBCLASS_STRUCT, FB_SYMBCLASS_ENUM, FB_SYMBCLASS_NAMESPACE
2469 print "symbDumpNamespace(): not a namespace"
2474 i = symbGetCompSymbTb( ns ).head
2480 hash = @symbGetCompHashTb( ns ).tb
2481 for index
as integer = 0
to hash->nodes-1
2482 hashitem = hash->list[index].head
2484 print " hashtb[" & index &
"]: " + *hashitem->
name +
" = " +
symbDump( hashitem->
data )
2485 hashitem = hashitem->
next