aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.h
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-05-20 06:26:45 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-05-20 06:26:45 +0000
commit2a967f3d3a45294640e155381ef549e0b8090ad4 (patch)
tree31a2cc3c54959e2908bad78e488472f5e3ce3d69 /gcc/cpplib.h
parent9e800206badd2be563d344e4a0aee83e3ac96f03 (diff)
downloadgcc-2a967f3d3a45294640e155381ef549e0b8090ad4.zip
gcc-2a967f3d3a45294640e155381ef549e0b8090ad4.tar.gz
gcc-2a967f3d3a45294640e155381ef549e0b8090ad4.tar.bz2
Makefile.in (OBJS, [...]): Update.
* Makefile.in (OBJS, LIBCPP_OBJS, LIBCPP_DEPS, cpplib.o, cpphash.o, fix-header): Update. (hashtable.o): New target. * c-common.h: Include cpplib.h. Define C_RID_CODE and struct c_common_identifier here. * c-lang.c (c_init_options): Update. Call set_identifier_size. * c-lex.c (c_lex): Update. * c-pragma.h: Update. * c-tree.h (struct lang_identifier): Contain c_common_identifier. Delete rid_code. (C_RID_CODE): Delete. * cpphash.c: Rewrite to use hashtable.c. * cpphash.h: Update include guards. (struct cpp_reader): Remove hashtab. hash_ob and buffer_ob are no longer pointers. Add hash_table and our_hashtable. (HASHSTEP, _cpp_init_hashtable, _cpp_lookup_with_hash): Delete. (_cpp_cleanup_hashtable): Rename _cpp_destroy_hashtable. (_cpp_cleanup_stacks): Rename _cpp_init_directives. * cppinit.c (cpp_create_reader): Update. * cpplex.c (cpp_ideq, parse_identifier, cpp_output_token): Update. (cpp_interpret_charconst): Eliminate warning. * cpplib.c (do_pragma, do_endif, push_conditional, cpp_push_buffer, cpp_pop_buffer): Update. (_cpp_init_stacks): Rename cpp_init_directives. (_cpp_cleanup_stacks): Remove. * cpplib.h: Update include guards. Include tree-core.h and c-rid.h. (cpp_hashnode, cpp_token, NODE_LEN, NODE_NAME, cpp_forall_identifiers, cpp_create_reader): Update. (C_RID_CODE, cpp_make_node): New. (c_common_identifier): New identifier node for C front ends. * cppmain.c (main): Update. * fix-header.c (read_scan_file): Update. * flags.h (id_clash_len): Make unsigned. * ggc.h (ggc_mark_nonnull_tree): New. * hashtable.c: New. * hashtable.h: New. * stringpool.c: Update comments and copyright. Update to use hashtable.c. * toplev.c (approx_sqrt): Move to hashtable.c. (id_clash_len): Make unsigned. * toplev.h (ident_hash): New. * tree.c (gcc_obstack_init): Move to hashtable.c. * tree.h: Include hashtable.h. (IDENTIFIER_POINTER, IDENTIFIER_LENGTH): Update. (GCC_IDENT_TO_HT_IDENT, HT_IDENT_TO_GCC_IDENT): New. (struct tree_identifier): Update. (make_identifier): New. cp: * cp-tree.h (struct lang_identifier, C_RID_YYCODE): Update. (C_RID_CODE): Remove. * lex.c (cxx_init_options): Call set_identifier_size. Update. (init_parse): Don't do it here. objc: * objc-act.c (objc_init_options): Call set_identifier_size. Update. From-SVN: r42334
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r--gcc/cpplib.h49
1 files changed, 31 insertions, 18 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 7730a24..cc42e34 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -20,10 +20,11 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
-#ifndef __GCC_CPPLIB__
-#define __GCC_CPPLIB__
+#ifndef GCC_CPPLIB_H
+#define GCC_CPPLIB_H
#include <sys/types.h>
+#include "hashtable.h"
#ifdef __cplusplus
extern "C" {
@@ -45,6 +46,7 @@ typedef struct cpp_callbacks cpp_callbacks;
struct answer;
struct file_name_map_list;
+struct ht;
/* The first two groups, apart from '=', can appear in preprocessor
expressions. This allows a lookup table to be implemented in
@@ -177,7 +179,7 @@ struct cpp_token
union
{
- struct cpp_hashnode *node; /* An identifier. */
+ cpp_hashnode *node; /* An identifier. */
struct cpp_string str; /* A string, or number. */
unsigned int arg_no; /* Argument no. for a CPP_MACRO_ARG. */
unsigned char c; /* Character represented by CPP_OTHER. */
@@ -466,18 +468,22 @@ enum builtin_type
BT_STDC /* `__STDC__' */
};
-#define NODE_LEN(NODE) (NODE->len)
-#define NODE_NAME(NODE) (NODE->name)
+#define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE))
+#define HT_NODE(NODE) ((ht_identifier *) (NODE))
+#define NODE_LEN(NODE) HT_LEN (&(NODE)->ident)
+#define NODE_NAME(NODE) HT_STR (&(NODE)->ident)
+/* The common part of an identifier node shared amongst all 3 C front
+ ends. Also used to store CPP identifiers, which are a superset of
+ identifiers in the grammatical sense. */
struct cpp_hashnode
{
- const unsigned char *name; /* Null-terminated name. */
- unsigned int hash; /* Cached hash value. */
- unsigned short len; /* Length of name excluding null. */
+ struct ht_identifier ident;
unsigned short arg_index; /* Macro argument index. */
unsigned char directive_index; /* Index into directive table. */
- ENUM_BITFIELD(node_type) type : 8; /* Node type. */
- unsigned char flags; /* Node flags. */
+ unsigned char rid_code; /* Rid code - for front ends. */
+ ENUM_BITFIELD(node_type) type : 8; /* CPP node type. */
+ unsigned char flags; /* CPP flags. */
union
{
@@ -488,8 +494,12 @@ struct cpp_hashnode
} value;
};
-/* Call this first to get a handle to pass to other functions. */
-extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
+/* Call this first to get a handle to pass to other functions. If you
+ want cpplib to manage its own hashtable, pass in a NULL pointer.
+ Or you can pass in an initialised hash table that cpplib will use;
+ this technique is used by the C front ends. */
+extern cpp_reader *cpp_create_reader PARAMS ((struct ht *,
+ enum c_lang));
/* Call this to release the handle. Any use of the handle after this
function returns is invalid. Returns cpp_errors (pfile). */
@@ -593,13 +603,16 @@ extern void cpp_output_token PARAMS ((const cpp_token *, FILE *));
extern const char *cpp_type2name PARAMS ((enum cpp_ttype));
/* In cpphash.c */
+
+/* Lookup an identifier in the hashtable. Puts the identifier in the
+ table if it is not already there. */
extern cpp_hashnode *cpp_lookup PARAMS ((cpp_reader *,
- const unsigned char *, size_t));
+ const unsigned char *,
+ unsigned int));
+
+typedef int (*cpp_cb) PARAMS ((cpp_reader *, cpp_hashnode *, void *));
extern void cpp_forall_identifiers PARAMS ((cpp_reader *,
- int (*) PARAMS ((cpp_reader *,
- cpp_hashnode *,
- void *)),
- void *));
+ cpp_cb, void *));
/* In cppmacro.c */
extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *, int));
@@ -614,4 +627,4 @@ extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
#ifdef __cplusplus
}
#endif
-#endif /* __GCC_CPPLIB__ */
+#endif /* GCC_CPPLIB_H */