Skip to content

Commit 56bc368

Browse files
committed
fbc: internal, add symbDumpLookup(id) for debugging
- symbDumpLookup(id) will print the identifier, - followed by all symbols reachable in the current namespace, - followed by all symbols in the import chain
1 parent 9c0a15f commit 56bc368

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/compiler/symb.bas

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,37 @@ sub symbDumpChain( byval chain_ as FBSYMCHAIN ptr )
29312931
loop while( chain_ )
29322932
end if
29332933
end sub
2934+
2935+
sub symbDumpLookup( byval id as zstring ptr )
2936+
2937+
static as zstring * FB_MAXNAMELEN+1 sname
2938+
hUcase( *id, sname )
2939+
id = @sname
2940+
2941+
print "symbol: " & *id
2942+
2943+
if( symbGetCurrentNamespc( ) <> NULL ) then
2944+
print "namespace: " & symbDumpToStr( symbGetCurrentNamespc( ) )
2945+
else
2946+
print "global namespace"
2947+
end if
2948+
2949+
dim as uinteger index = hashHash( id )
2950+
dim as FBHASHTB ptr hashtb = any
2951+
hashtb = symb.hashlist.tail
2952+
do
2953+
dim as FBSYMBOL ptr sym = hashLookupEx( @hashtb->tb, id, index )
2954+
while( sym )
2955+
print symbDumpToStr( sym )
2956+
sym = sym->hash.next
2957+
wend
2958+
hashtb = hashtb->prev
2959+
loop while( hashtb <> NULL )
2960+
2961+
dim as FBSYMCHAIN ptr imp_chain = hashLookupEx( @symb.imphashtb, id, index )
2962+
symbDumpChain( imp_chain )
2963+
2964+
end sub
29342965
#endif '' __FB_DEBUG__
29352966

29362967
dim shared as zstring ptr classnamesPretty(FB_SYMBCLASS_VAR to FB_SYMBCLASS_NSIMPORT) = _

src/compiler/symb.bi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,7 @@ declare function symbDumpToStr _
26642664
declare sub symbDump( byval s as FBSYMBOL ptr )
26652665
declare sub symbDumpNamespace( byval ns as FBSYMBOL ptr )
26662666
declare sub symbDumpChain( byval chain_ as FBSYMCHAIN ptr )
2667+
declare sub symbDumpLookup( byval id as zstring ptr )
26672668

26682669
'' FBARRAY: 6 pointer/integer fields + the dimTB with 3 integer fields per dimension
26692670
#define symbDescriptorHasRoomFor( sym, dimensions ) (symbGetLen( sym ) = env.pointersize * (((dimensions) * 3) + 6))

0 commit comments

Comments
 (0)