Fixed get_SymConst_kind() call, removed non-portable __FUNCTION__ extension, fixed...
[libfirm] / ir / ident / ident.h
index fb8edda..28d39b9 100644 (file)
    Copyright (C) 1995, 1996 Markus Armbruster */
 
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Martin Trapp, Christian Schaefer
+* All rights reserved.
+*
+* Authors: Martin Trapp, Christian Schaefer
 */
 
+/* $Id$ */
+
 # ifndef _IDENT_H_
 # define _IDENT_H_
 
-#include <assert.h>
-#include <stddef.h>
-#include "misc.h"
-#include "debug.h"
-#include "set.h"
+# include <stdio.h>
+# include <assert.h>
+# include "firm_common.h"
 
-# include "xprintf.h"
-# include "xp_help.h"
+/**
+ *
+ *   - identifiers in the firm library
+ *  Identifiers are used in the firm library. This is the interface to it.
+ */
 
 /* Identifiers */
+/**
+ *
+ *  the abstract data type ident
+ */
 typedef const struct set_entry ident;
 
-/* Caution: strings _not_ zero-terminated! */
-#define ID_FROM_STR(str, len) \
-  (assert ((len) > 0), \
-   (const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len))))
-#define ID_TO_STR(id) ((const char *)&(id)->dptr[0])
-#define ID_TO_STRLEN(id) ((id)->size)
-#define ID_TO_HASH(id) ((long)(id) + (id)->hash)
-
-ident *new_id_derived (const char *pfx, ident *);
-ident *new_id_internal (void);
-bool id_is_internal (ident *);
-void id_init (void);
-
-#ifdef NDEBUG
-# define ID_VRFY(id) ((void)0)
-# define IDS_VRFY(id) ((void)0)
-#else
-# define ID_VRFY(id) \
-    assert (   (id) \
-           && (   !d_ (df_vrfy_level, 1) \
-               || (ID_FROM_STR (ID_TO_STR((id)), ID_TO_STRLEN((id))) == (id))))
-# define IDS_VRFY(id) ids_vrfy ((id))
-void ids_vrfy (ident **id);
-#endif
-
-#ifdef STATS
-# define id_stats() set_stats (id_set)
-#else
-# define id_stats() ((void)0)
-#endif
-
-/* Private */
-
-/* @@@ tune */
-#define ID_HASH(str, len) \
-  (((  ((unsigned char *)(str))[0] * 33 \
-     + ((unsigned char *)(str))[(len)>>1]) * 31 \
-    + ((unsigned char *)(str))[(len)-1]) * 9 \
-   + (len))
-
-extern set *id_set;
-
-
-# define id_from_str  ID_FROM_STR
-# define id_to_str    ID_TO_STR
-# define id_to_strlen ID_TO_STRLEN
-
+/**
+ *
+ *  store a string and create an ident
+ *  Stores a string in the ident module and returns a handle for the string.
+ *  Copies the string.
+ *  @param str - the string (or whatever) which shall be stored
+ *  @param len - the length of the data in bytes
+ *  @return id - a handle for the generated ident
+ * @see id_to_str, id_to_strlen
+ * @see
+ */
+INLINE ident      *id_from_str (const char *str, int len);
+
+/**
+ *
+ *  return a string represented by an ident
+ *  Returns the string cp represented by id. This string cp is not
+ *  Null terminated!  The string may not be changed.
+ *  @param id - the ident
+ *  @return cp - a string
+ * @see id_from_str, id_to_strlen
+ * @see
+ */
+INLINE const char *id_to_str   (ident *id);
+
+/**
+ *
+ *  return the length of a string represented by an ident
+ *  Returns the length of string represented by id.
+ *  @param id - the ident
+ *  @return len - the length of the string
+ * @see id_from_str, id_to_str
+ * @see
+ */
+INLINE int  id_to_strlen(ident *id);
+
+/**
+ *
+ *
+ *  Returns true if prefix is prefix of id.
+ *  @param prefix - the prefix
+ *  @param id - the ident
+ * @see id_from_str, id_to_str, id_is_prefix
+ * @see
+ */
+/*  */
+int id_is_prefix (ident *prefix, ident *id);
+
+/**
+ *
+ *
+ *  Returns true if suffix is suffix of id.
+ *  @param suffix - the suffix
+ *  @param id - the ident
+ * @see id_from_str, id_to_str, id_is_prefix
+ * @see
+ */
+/*  */
+int id_is_suffix (ident *suffix, ident *id);
+
+/**
+ *
+ *
+ *  Prints the ident to stdout.
+ *  @param The ident to print.
+ * @see id_from_str, id_to_str, id_is_prefix, fprint_id
+ * @see
+ */
+/*  */
+int print_id (ident *id);
+
+/**
+ *
+ *
+ *  Prints the ident to the file passed.
+ *  @param The ident to print and the file.
+ * @see id_from_str, id_to_str, id_is_prefix, print_id
+ * @see
+ */
+/*  */
+int fprint_id (FILE *F, ident *id);
 
-int ident_print (XP_PAR1, const xprintf_info *, XP_PARN);
 
 # endif /* _IDENT_H_ */