Add -debug-symtabs and -debug-qsymtabs options for debugging symbol tables

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11724 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-11-04 22:49:39 +00:00
commit 64d1b6f0c6
6 changed files with 72 additions and 27 deletions

View file

@ -200,6 +200,8 @@ extern "C" {
/* --- Symbol table module --- */
extern void Swig_symbol_tables_print(Symtab *symtab);
extern void Swig_symbol_tables_summary_print(void);
extern void Swig_symbol_init(void);
extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
extern String *Swig_symbol_getscopename(void);
@ -207,6 +209,7 @@ extern "C" {
extern Symtab *Swig_symbol_newscope(void);
extern Symtab *Swig_symbol_setscope(Symtab *);
extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
extern Symtab *Swig_symbol_global_scope(void);
extern Symtab *Swig_symbol_current(void);
extern Symtab *Swig_symbol_popscope(void);
extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node);

View file

@ -175,20 +175,32 @@ static Hash *global_scope = 0; /* Global scope */
/* common attribute keys, to avoid calling find_key all the times */
/* -----------------------------------------------------------------------------
* Swig_symbol_tables_print()
*
* Debug display of symbol tables
* ----------------------------------------------------------------------------- */
#if 0
void Swig_symbol_dump_symtable() {
Printf(stdout, "DUMPING SYMTABLE start =======================================\n");
{
Hash *cst = Getattr(current_symtab, "csymtab");
Swig_print_tree(cst);
/*
Swig_print_tree(Getattr(cst, "NumSpace"));
*/
}
Printf(stdout, "DUMPING SYMTABLE end =======================================\n");
void Swig_symbol_tables_print(Symtab *symtab) {
if (!symtab)
symtab = current_symtab;
Printf(stdout, "SYMBOL TABLES start =======================================\n");
Swig_print_tree(symtab);
Printf(stdout, "SYMBOL TABLES finish =======================================\n");
}
/* -----------------------------------------------------------------------------
* Swig_symbol_tables_summary_print()
*
* Debug summary display of all symbol tables by fully-qualified name
* ----------------------------------------------------------------------------- */
void Swig_symbol_tables_summary_print(void) {
Printf(stdout, "SYMBOL TABLES SUMMARY start =======================================\n");
Swig_print_node(symtabs);
Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n");
}
#endif
/* -----------------------------------------------------------------------------
* Swig_symbol_init()
@ -196,7 +208,7 @@ void Swig_symbol_dump_symtable() {
* Create a new symbol table object
* ----------------------------------------------------------------------------- */
void Swig_symbol_init() {
void Swig_symbol_init(void) {
current = NewHash();
current_symtab = NewHash();
@ -240,7 +252,7 @@ void Swig_symbol_setscopename(const_String_or_char_ptr name) {
* Get the C scopename of the current symbol table
* ----------------------------------------------------------------------------- */
String *Swig_symbol_getscopename() {
String *Swig_symbol_getscopename(void) {
return Getattr(current_symtab, "name");
}
@ -295,7 +307,7 @@ String *Swig_symbol_qualifiedscopename(Symtab *symtab) {
* Create a new scope. Returns the newly created scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_newscope() {
Symtab *Swig_symbol_newscope(void) {
Hash *n;
Hash *hsyms, *h;
@ -346,7 +358,7 @@ Symtab *Swig_symbol_setscope(Symtab *sym) {
* scope to the parent scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_popscope() {
Symtab *Swig_symbol_popscope(void) {
Hash *h = current_symtab;
current_symtab = Getattr(current_symtab, "parentNode");
assert(current_symtab);
@ -357,13 +369,23 @@ Symtab *Swig_symbol_popscope() {
return h;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_global_scope()
*
* Return the symbol table for the global scope.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_global_scope(void) {
return global_scope;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_current()
*
* Return the current symbol table.
* ----------------------------------------------------------------------------- */
Symtab *Swig_symbol_current() {
Symtab *Swig_symbol_current(void) {
return current_symtab;
}