1/* Part of CPP library.  (Macro hash table support.)
2   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
3
4This program is free software; you can redistribute it and/or modify it
5under the terms of the GNU General Public License as published by the
6Free Software Foundation; either version 2, or (at your option) any
7later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17
18/* different kinds of things that can appear in the value field
19   of a hash node. */
20union hashval
21{
22  const char *cpval;		/* some predefined macros */
23  DEFINITION *defn;		/* #define */
24  struct hashnode *aschain;	/* #assert */
25};
26
27struct hashnode {
28  struct hashnode *next;	/* double links for easy deletion */
29  struct hashnode *prev;
30  struct hashnode **bucket_hdr;	/* also, a back pointer to this node's hash
31				   chain is kept, in case the node is the head
32				   of the chain and gets deleted. */
33  enum node_type type;		/* type of special token */
34  int length;			/* length of token, for quick comparison */
35  U_CHAR *name;			/* the actual name */
36  union hashval value;		/* pointer to expansion, or whatever */
37};
38
39typedef struct hashnode HASHNODE;
40
41/* Some definitions for the hash table.  The hash function MUST be
42   computed as shown in hashf () below.  That is because the rescan
43   loop computes the hash value `on the fly' for most tokens,
44   in order to avoid the overhead of a lot of procedure calls to
45   the hashf () function.  Hashf () only exists for the sake of
46   politeness, for use when speed isn't so important. */
47
48#define HASHSTEP(old, c) ((old << 2) + c)
49#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
50
51extern HASHNODE *cpp_install	  PARAMS ((cpp_reader *, U_CHAR *, int,
52					   enum node_type, const char *, int));
53extern int hashf		  PARAMS ((const U_CHAR *, int, int));
54extern void delete_macro	  PARAMS ((HASHNODE *));
55
56extern MACRODEF create_definition PARAMS ((U_CHAR *, U_CHAR *,
57					   cpp_reader *, int));
58extern int compare_defs		  PARAMS ((cpp_reader *, DEFINITION *,
59					   DEFINITION *));
60extern void macroexpand		  PARAMS ((cpp_reader *, HASHNODE *));
61extern void dump_definition	  PARAMS ((cpp_reader *, MACRODEF));
62