32 |
|
|
33 |
#include "m4private.h" |
#include "m4private.h" |
34 |
|
|
35 |
/*----------------------------------------------------------------------. |
/* Initialise the symbol table, by allocating the necessary storage, and |
36 |
| Initialise the symbol table, by allocating the necessary storage, and | |
zeroing all the entries. */ |
|
| zeroing all the entries. | |
|
|
`----------------------------------------------------------------------*/ |
|
37 |
|
|
38 |
/* Pointer to symbol table. */ |
/* Pointer to symbol table. */ |
39 |
m4_symbol **m4_symtab; |
m4_symbol **m4_symtab; |
50 |
*symbol++ = NULL; |
*symbol++ = NULL; |
51 |
} |
} |
52 |
|
|
53 |
/*--------------------------------------------------. |
/* Return a hashvalue for a string, from GNU-emacs. */ |
|
| Return a hashvalue for a string, from GNU-emacs. | |
|
|
`--------------------------------------------------*/ |
|
|
|
|
54 |
static int |
static int |
55 |
hash (const char *s) |
hash (const char *s) |
56 |
{ |
{ |
69 |
return val % hash_table_size; |
return val % hash_table_size; |
70 |
} |
} |
71 |
|
|
72 |
/*--------------------------------------------. |
/* Free all storage associated with a symbol. */ |
|
| Free all storage associated with a symbol. | |
|
|
`--------------------------------------------*/ |
|
|
|
|
73 |
static void |
static void |
74 |
free_symbol (m4_symbol *symbol) |
free_symbol (m4_symbol *symbol) |
75 |
{ |
{ |
80 |
xfree ((VOID *) symbol); |
xfree ((VOID *) symbol); |
81 |
} |
} |
82 |
|
|
83 |
/*------------------------------------------------------------------------. |
/* Search in, and manipulation of the symbol table, are all done by |
84 |
| Search in, and manipulation of the symbol table, are all done by | |
m4_lookup_symbol (). It basically hashes NAME to a list in the symbol |
85 |
| m4_lookup_symbol (). It basically hashes NAME to a list in the symbol | |
table, and searched this list for the first occurence of a symbol with |
86 |
| table, and searched this list for the first occurence of a symbol with | |
the name. |
87 |
| the name. | |
|
88 |
| | |
The MODE parameter determines what m4_lookup_symbol () will do. It can |
89 |
| The MODE parameter determines what m4_lookup_symbol () will do. It can | |
either just do a lookup, do a lookup and insert if not present, do an |
90 |
| either just do a lookup, do a lookup and insert if not present, do an | |
insertion even if the name is already in the list, delete the first |
91 |
| insertion even if the name is already in the list, delete the first | |
occurrence of the name on the list or delete all occurences of the name |
92 |
| occurrence of the name on the list or delete all occurences of the name | |
on the list. */ |
|
| on the list. | |
|
|
`------------------------------------------------------------------------*/ |
|
|
|
|
93 |
m4_symbol * |
m4_symbol * |
94 |
m4_lookup_symbol (const char *name, m4_symbol_lookup mode) |
m4_lookup_symbol (const char *name, m4_symbol_lookup mode) |
95 |
{ |
{ |
186 |
return NULL; |
return NULL; |
187 |
} |
} |
188 |
|
|
189 |
/*--------------------------------------------------------------------. |
/* The following function removes from the symbol table, every symbol |
190 |
| The following function removes from the symbol table, every symbol | |
that references a function in the given builtin table. */ |
|
| that references a function in the given builtin table. | |
|
|
`-------------------------------------------------------------------*/ |
|
|
|
|
|
/* FIXME: This can be reimplemented to work much faster now that each |
|
|
symtab entry carries a reference to its defining module. */ |
|
191 |
void |
void |
192 |
m4_remove_table_reference_symbols (builtins, macros) |
m4_remove_table_reference_symbols (builtins, macros) |
193 |
m4_builtin *builtins; |
m4_builtin *builtins; |
194 |
m4_macro *macros; |
m4_macro *macros; |
195 |
{ |
{ |
196 |
|
/* FIXME: This can be reimplemented to work much faster now that each |
197 |
|
symtab entry carries a reference to its defining module. */ |
198 |
m4_symbol *symbol; |
m4_symbol *symbol; |
199 |
int h; |
int h; |
200 |
|
|
270 |
} |
} |
271 |
} |
} |
272 |
|
|
273 |
/*----------------------------------------------------------------------. |
/* The following function is used for the cases, where we want to do |
274 |
| The following function is used for the cases, where we want to do | |
something to each and every symbol in the table. The function |
275 |
| something to each and every symbol in the table. The function | |
hack_all_symbols () traverses the symbol table, and calls a specified |
276 |
| hack_all_symbols () traverses the symbol table, and calls a specified | |
function FUNC for each symbol in the table. FUNC is called with a |
277 |
| function FUNC for each symbol in the table. FUNC is called with a | |
pointer to the symbol, and the DATA argument. */ |
|
| pointer to the symbol, and the DATA argument. | |
|
|
`----------------------------------------------------------------------*/ |
|
|
|
|
278 |
void |
void |
279 |
m4_hack_all_symbols (func, data) |
m4_hack_all_symbols (func, data) |
280 |
m4_hack_symbol *func; |
m4_hack_symbol *func; |