24 |
# include <config.h> |
# include <config.h> |
25 |
#endif |
#endif |
26 |
|
|
27 |
|
#include <assert.h> |
28 |
#include <m4module.h> |
#include <m4module.h> |
29 |
|
|
30 |
struct m4_module { |
struct m4_module_data { |
|
struct m4_module *next; /* previously loaded module */ |
|
|
char *modname; /* name of this module */ |
|
|
lt_dlhandle handle; /* libltdl module handle */ |
|
31 |
m4_builtin *bp; /* `m4_builtin_table' address */ |
m4_builtin *bp; /* `m4_builtin_table' address */ |
32 |
m4_macro *mp; /* `m4_macro_table' address */ |
m4_macro *mp; /* `m4_macro_table' address */ |
|
unsigned int ref_count; /* number of times module_load was called */ |
|
33 |
}; |
}; |
34 |
|
|
35 |
|
|
36 |
struct m4_token_data { |
struct m4_token_data { |
37 |
m4_token_data_t type; |
m4_token_data_t type; |
38 |
|
lt_dlhandle handle; |
39 |
union { |
union { |
40 |
struct { |
struct { |
41 |
char *text; |
char *text; |
51 |
}; |
}; |
52 |
|
|
53 |
#define M4_TOKEN_DATA_TYPE(Td) ((Td)->type) |
#define M4_TOKEN_DATA_TYPE(Td) ((Td)->type) |
54 |
|
#define M4_TOKEN_DATA_HANDLE(Td) ((Td)->handle) |
55 |
#define M4_TOKEN_DATA_TEXT(Td) ((Td)->u.u_t.text) |
#define M4_TOKEN_DATA_TEXT(Td) ((Td)->u.u_t.text) |
56 |
#ifdef ENABLE_CHANGEWORD |
#ifdef ENABLE_CHANGEWORD |
57 |
# define M4_TOKEN_DATA_ORIG_TEXT(Td) ((Td)->u.u_t.original_text) |
# define M4_TOKEN_DATA_ORIG_TEXT(Td) ((Td)->u.u_t.original_text) |
59 |
#define M4_TOKEN_DATA_FUNC(Td) ((Td)->u.u_f.func) |
#define M4_TOKEN_DATA_FUNC(Td) ((Td)->u.u_f.func) |
60 |
#define M4_TOKEN_DATA_FUNC_TRACED(Td) ((Td)->u.u_f.traced) |
#define M4_TOKEN_DATA_FUNC_TRACED(Td) ((Td)->u.u_f.traced) |
61 |
|
|
62 |
/* Redefine the exported function using macro to this faster |
/* Redefine the exported function to this faster |
63 |
macro based version for internal use by the m4 code. */ |
macro based version for internal use by the m4 code. */ |
64 |
#undef M4ARG |
#undef M4ARG |
65 |
#define M4ARG(i) (argc > (i) ? M4_TOKEN_DATA_TEXT (argv[i]) : "") |
#define M4ARG(i) (argc > (i) ? M4_TOKEN_DATA_TEXT (argv[i]) : "") |
74 |
|
|
75 |
char *name; |
char *name; |
76 |
m4_token_data data; |
m4_token_data data; |
|
const m4_module *module; |
|
77 |
}; |
}; |
78 |
|
|
79 |
#define SYMBOL_NEXT(S) ((S)->next) |
#define SYMBOL_NEXT(S) ((S)->next) |
81 |
#define SYMBOL_SHADOWED(S) ((S)->shadowed) |
#define SYMBOL_SHADOWED(S) ((S)->shadowed) |
82 |
#define SYMBOL_MACRO_ARGS(S) ((S)->macro_args) |
#define SYMBOL_MACRO_ARGS(S) ((S)->macro_args) |
83 |
#define SYMBOL_BLIND_NO_ARGS(S) ((S)->blind_no_args) |
#define SYMBOL_BLIND_NO_ARGS(S) ((S)->blind_no_args) |
|
#define SYMBOL_MODULE(S) ((S)->module) |
|
84 |
#define SYMBOL_NAME(S) ((S)->name) |
#define SYMBOL_NAME(S) ((S)->name) |
85 |
#define SYMBOL_TYPE(S) (M4_TOKEN_DATA_TYPE (&(S)->data)) |
#define SYMBOL_TYPE(S) (M4_TOKEN_DATA_TYPE (&(S)->data)) |
86 |
#define SYMBOL_TEXT(S) (M4_TOKEN_DATA_TEXT (&(S)->data)) |
#define SYMBOL_TEXT(S) (M4_TOKEN_DATA_TEXT (&(S)->data)) |
87 |
#define SYMBOL_FUNC(S) (M4_TOKEN_DATA_FUNC (&(S)->data)) |
#define SYMBOL_FUNC(S) (M4_TOKEN_DATA_FUNC (&(S)->data)) |
88 |
|
#define SYMBOL_HANDLE(S) (M4_TOKEN_DATA_HANDLE(&(S)->data)) |
89 |
|
|
90 |
|
|
91 |
/* Debugging the memory allocator. */ |
/* Debugging the memory allocator. */ |