aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpphash.h
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-02-10 02:23:08 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-02-10 02:23:08 +0000
commitbb52fa7f8606991a77af8ff6f0edabb8d7ffd280 (patch)
treea1c32725cdbb29b80f1f744fec3575eb7ad9997d /gcc/cpphash.h
parentae6f3fe9f6035dd43b0eaa153e95843325f67f08 (diff)
downloadgcc-bb52fa7f8606991a77af8ff6f0edabb8d7ffd280.zip
gcc-bb52fa7f8606991a77af8ff6f0edabb8d7ffd280.tar.gz
gcc-bb52fa7f8606991a77af8ff6f0edabb8d7ffd280.tar.bz2
cpplib.h: Provide HASHNODE typedef and forward decl of struct hashnode only.
* cpplib.h: Provide HASHNODE typedef and forward decl of struct hashnode only. Kill cpp_hashnode typedef. MACRODEF, DEFINITION, struct hashnode, struct macrodef, struct definition, scan_decls prototype, default defn of INCLUDE_LEN_FUDGE moved elsewhere. * cpphash.h: MACRODEF, DEFINITION, struct macrodef, struct definition, and struct hashnode moved here. Remove the unused 'predefined' field from struct definition. Replace the 'args' union with its sole member. All users updated (cpphash.c). Delete HASHSTEP and MAKE_POS macros, and hashf prototype. Add multiple include guard. * cpphash.c (hashf): Make static; use better algorithm; drop HASHSIZE parameter; return an unsigned int. (cpp_lookup): Drop HASH parameter. PFILE parameter is used. Calculate HASHSIZE modulus here. (cpp_install): Drop HASH parameter. Calculate HASHSIZE modulus here. (create_definition): Drop PREDEFINITION parameter. * cpplib.c (do_define): Don't calculate a hash value here. Don't pass (keyword == NULL) to create_definition. * scan.h: Prototype scan_decls here. * cppfiles.c: Move INCLUDE_LEN_FUDGE default defn here. * cppexp.c, cppfiles.c, cppinit.c, cpplib.c, fix-header.c: All callers of cpp_lookup and cpp_install updated. From-SVN: r31881
Diffstat (limited to 'gcc/cpphash.h')
-rw-r--r--gcc/cpphash.h78
1 files changed, 63 insertions, 15 deletions
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index 5422979..960700c 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -15,6 +15,65 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#ifndef __GCC_CPPHASH__
+#define __GCC_CPPHASH__
+
+/* Structure returned by create_definition */
+typedef struct macrodef MACRODEF;
+struct macrodef
+{
+ struct definition *defn;
+ const U_CHAR *symnam;
+ int symlen;
+};
+
+/* Structure allocated for every #define. For a simple replacement
+ such as
+ #define foo bar ,
+ nargs = -1, the `pattern' list is null, and the expansion is just
+ the replacement text. Nargs = 0 means a functionlike macro with no args,
+ e.g.,
+ #define getchar() getc (stdin) .
+ When there are args, the expansion is the replacement text with the
+ args squashed out, and the reflist is a list describing how to
+ build the output from the input: e.g., "3 chars, then the 1st arg,
+ then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg".
+ The chars here come from the expansion. Whatever is left of the
+ expansion after the last arg-occurrence is copied after that arg.
+ Note that the reflist can be arbitrarily long---
+ its length depends on the number of times the arguments appear in
+ the replacement text, not how many args there are. Example:
+ #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and
+ pattern list
+ { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL }
+ where (x, y) means (nchars, argno). */
+
+typedef struct definition DEFINITION;
+struct definition {
+ int nargs;
+ int length; /* length of expansion string */
+ unsigned char *expansion;
+ int line; /* Line number of definition */
+ const char *file; /* File of definition */
+ char rest_args; /* Nonzero if last arg. absorbs the rest */
+ struct reflist {
+ struct reflist *next;
+ char stringify; /* nonzero if this arg was preceded by a
+ # operator. */
+ char raw_before; /* Nonzero if a ## operator before arg. */
+ char raw_after; /* Nonzero if a ## operator after arg. */
+ char rest_args; /* Nonzero if this arg. absorbs the rest */
+ int nchars; /* Number of literal chars to copy before
+ this arg occurrence. */
+ int argno; /* Number of arg to substitute (origin-0) */
+ } *pattern;
+ /* Names of macro args, concatenated in reverse order
+ with comma-space between them.
+ The only use of this is that we warn on redefinition
+ if this differs between the old and new definitions. */
+ unsigned char *argnames;
+};
+
/* different kinds of things that can appear in the value field
of a hash node. */
union hashval
@@ -36,26 +95,15 @@ struct hashnode {
union hashval value; /* pointer to expansion, or whatever */
};
-typedef struct hashnode HASHNODE;
-
-/* Some definitions for the hash table. The hash function MUST be
- computed as shown in hashf () below. That is because the rescan
- loop computes the hash value `on the fly' for most tokens,
- in order to avoid the overhead of a lot of procedure calls to
- the hashf () function. Hashf () only exists for the sake of
- politeness, for use when speed isn't so important. */
-
-#define HASHSTEP(old, c) ((old << 2) + c)
-#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
-
extern HASHNODE *cpp_install PARAMS ((cpp_reader *, const U_CHAR *, int,
- enum node_type, const char *, int));
-extern int hashf PARAMS ((const U_CHAR *, int, int));
+ enum node_type, const char *));
extern void delete_macro PARAMS ((HASHNODE *));
extern MACRODEF create_definition PARAMS ((U_CHAR *, U_CHAR *,
- cpp_reader *, int));
+ cpp_reader *));
extern int compare_defs PARAMS ((cpp_reader *, DEFINITION *,
DEFINITION *));
extern void macroexpand PARAMS ((cpp_reader *, HASHNODE *));
extern void dump_definition PARAMS ((cpp_reader *, MACRODEF));
+
+#endif