TSymbol / TSymTable

Sources: source/classes/tsymbol.prg, source/classes/tsymtabl.prg

Standalone classes

TSymbol and TSymTable provide runtime introspection of the Harbour symbol table. TSymbol wraps a single symbol handle (hSymbol) and exposes its name and visibility. TSymTable provides iteration over the entire symbol table, returning TSymbol objects. These classes are useful for debuggers, profilers, and tools that need to enumerate all public/static symbols in the current application.

TSymbol

TSymbol represents a single symbol entry in the Harbour symbol table.

Key DATA

DATATypeDescription
hSymbolNumericHandle to the internal Harbour symbol entry

Key METHODs

MethodDescription
Name()Return the symbol name as a character string
IsStatic()Return .T. if the symbol is static (module-scoped)

TSymTable

TSymTable provides indexed access to all symbols in the symbol table.

Key METHODs

MethodDescription
Get( n )Return the TSymbol at position n (1-based)
Len()Return the total number of symbols in the table
Size()Return the total size (same as Len())
GetFirst()Return the first TSymbol in the table
GetLast()Return the last TSymbol in the table

Example: Iterate All Symbols

#include "FiveWin.ch"

function Main()

   local oSymTable := TSymTable():New()
   local oSym, n

   ? "Total symbols:", oSymTable:Len()
   ? "---"

   // Print first 20 symbols
   for n := 1 to Min( 20, oSymTable:Len() )
      oSym := oSymTable:Get( n )
      if oSym != nil
         ? oSym:Name(), ;
           if( oSym:IsStatic(), "(static)", "(public)" )
      endif
   next

   // Get first and last symbols
   oSym := oSymTable:GetFirst()
   if oSym != nil
      ? "First symbol:", oSym:Name()
   endif

   oSym := oSymTable:GetLast()
   if oSym != nil
      ? "Last symbol:", oSym:Name()
   endif

return nil

Notes

Ver También