#ifndef SCM_TAGS_H
#define SCM_TAGS_H
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
+ * Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* type checking while still resulting in very efficient code.
*/
typedef struct scm_unused_struct * SCM;
-# define SCM_UNPACK(x) ((scm_t_bits) (x))
+
+/*
+ The 0?: constructions makes sure that the code is never executed,
+ and that there is no performance hit. However, the alternative is
+ compiled, and does generate a warning when used with the wrong
+ pointer type.
+ */
+# define SCM_UNPACK(x) ((scm_t_bits) (0? (*(SCM*)0=(x)): x))
+
+/*
+ There is no typechecking on SCM_PACK, since all kinds of types
+ (unsigned long, void*) go in SCM_PACK
+ */
# define SCM_PACK(x) ((SCM) (x))
+
#else
/* This should be used as a fall back solution for machines on which casting
* to a pointer may lead to loss of bit information, e. g. in the three least
*/
typedef scm_t_bits SCM;
# define SCM_UNPACK(x) (x)
-# define SCM_PACK(x) ((scm_t_bits) (x))
+# define SCM_PACK(x) ((SCM) (x))
#endif
/* SCM values can not be compared by using the operator ==. Use the following
* macro instead, which is the equivalent of the scheme predicate 'eq?'.
*/
-#define SCM_EQ_P(x, y) (SCM_UNPACK (x) == SCM_UNPACK (y))
+#define scm_is_eq(x, y) (SCM_UNPACK (x) == SCM_UNPACK (y))
\f
* value and sign. Thus, the only scheme objects for which a further
* subdivision is of interest are the ones with tc3==100.
*
- * tc7, tc8, tc9 (for objects with tc3==100):
- * 00-0000-100: \ evaluator byte codes ('short instructions'). The byte
- * ... } code interpreter can dispatch on them in one step based
- * 00-1100-100: / on their tc7 value.
- * 00-1101-100: evaluator byte codes ('long instructions'). The byte code
- * interpreter needs to dispatch on them in two steps: The
- * first dispatch is based on the tc7-code. The second
- * dispatch is based on the actual byte code that is extracted
- * from the upper bits.
- * x1-1110-100: evaluator byte codes ('ilocs')
- * x1-1111-100: characters with x as their least significant bit
- * 10-1111-100: various constants ('flags')
+ * tc8 (for objects with tc3==100):
+ * 00000-100: special objects ('flags')
+ * 00001-100: characters
+ * 00010-100: evaluator byte codes ('isyms')
+ * 00011-100: evaluator byte codes ('ilocs')
*
*
* Summary of type codes on the heap
* cases. Thus, their tc7-codes are chosen to only differ in one bit. This
* makes it possible to check an object at the same time for being a vector
* or a weak vector by comparing its tc7 code with that bit masked (using
- * the TYP7S macro). Two more special tc7-codes are of interest: ports and
- * smobs in fact each represent collections of types, which are subdivided
- * using tc16-codes.
+ * the TYP7S macro). Three more special tc7-codes are of interest:
+ * numbers, ports and smobs in fact each represent collections of types,
+ * which are subdivided using tc16-codes.
*
* tc16 (for tc7==scm_tc7_smob):
* The largest part of the space of smob types is not subdivided in a
* predefined way, since smobs can be added arbitrarily by user C code.
* However, while Guile also defines a number of smob types throughout,
- * there are four smob types for which Guile assumes that they are declared
- * first and thus get known-in-advance tc16-codes. These are
- * scm_tc_free_cell, scm_tc16_big, scm_tc16_real and scm_tc16_complex. The
- * reason of requiring fixed tc16-codes for these types is performance. For
- * the same reason, scm_tc16_real and scm_tc16_complex are given tc16-codes
- * that only differ in one bit: This way, checking if an object is an
- * inexact number can be done quickly (using the TYP16S macro)
+ * there is one smob type, namely scm_tc_free_cell, for which Guile assumes
+ * that it is declared first and thus gets a known-in-advance tc16-code.
+ * The reason of requiring a fixed tc16-code for this type is performance.
*/
\f
/* Checking if a SCM variable holds an immediate integer: See numbers.h for
* the definition of the following macros: SCM_I_FIXNUM_BIT,
- * SCM_MOST_POSITIVE_FIXNUM, SCM_INUMP, SCM_MAKINUM, SCM_INUM. */
+ * SCM_MOST_POSITIVE_FIXNUM, SCM_I_INUMP, SCM_I_MAKINUM, SCM_I_INUM. */
/* Checking if a SCM variable holds a pair (for historical reasons, in Guile
* also known as a cons-cell): This is done by first checking that the SCM
* variable holds a non-immediate, and second, by checking that tc1==0 holds
- * for the SCM_CELL_TYPE of the SCM variable. */
-#define SCM_CONSP(x) (!SCM_IMP (x) && ((1 & SCM_CELL_TYPE (x)) == 0))
-#define SCM_NCONSP(x) (!SCM_CONSP (x))
+ * for the SCM_CELL_TYPE of the SCM variable.
+*/
+
+#define SCM_I_CONSP(x) (!SCM_IMP (x) && ((1 & SCM_CELL_TYPE (x)) == 0))
\f
#define scm_tc7_wvect 15
#define scm_tc7_string 21
-/* free 23 */
+#define scm_tc7_number 23
+#define scm_tc7_stringbuf 39
/* Many of the following should be turned
* into structs or smobs. We need back some
#define scm_tc7_pws 31
-#if SCM_HAVE_ARRAYS
-#define scm_tc7_llvect 29
-#define scm_tc7_uvect 37
-/* free 39 */
-#define scm_tc7_fvect 45
-#define scm_tc7_dvect 47
-#define scm_tc7_cvect 53
-#define scm_tc7_svect 55
-#define scm_tc7_bvect 71
-#define scm_tc7_byvect 77
-#define scm_tc7_ivect 79
-#endif
+#define scm_tc7_unused_1 29
+#define scm_tc7_unused_2 37
+#define scm_tc7_unused_3 45
+#define scm_tc7_unused_4 47
+#define scm_tc7_unused_5 53
+#define scm_tc7_unused_6 55
+#define scm_tc7_unused_7 71
+#define scm_tc7_unused_8 77
+#define scm_tc7_unused_9 79
#define scm_tc7_dsubr 61
#define scm_tc7_cclo 63
/* Definitions for tc16: */
#define SCM_TYP16(x) (0xffff & SCM_CELL_TYPE (x))
-#define SCM_TYP16S(x) (0xfeff & SCM_CELL_TYPE (x))
-
#define SCM_TYP16_PREDICATE(tag, x) (!SCM_IMP (x) && SCM_TYP16 (x) == (tag))
-/* Here are the first four smob subtypes. */
+
+/* Here is the first smob subtype. */
/* scm_tc_free_cell is the 0th smob type. We place this in free cells to tell
* the conservative marker not to trace it. */
#define scm_tc_free_cell (scm_tc7_smob + 0 * 256L)
-/* Smob type 1 to 3 (note the dependency on the predicate SCM_NUMP) */
-#define scm_tc16_big (scm_tc7_smob + 1 * 256L)
-#define scm_tc16_real (scm_tc7_smob + 2 * 256L)
-#define scm_tc16_complex (scm_tc7_smob + 3 * 256L)
-
\f
+
/* {Immediate Values}
*/
-enum scm_tags
+enum scm_tc8_tags
{
- scm_tc8_iloc = 0xf4,
- scm_tc8_char = 0xfc,
- scm_tc9_flag = 0x17c
+ scm_tc8_flag = scm_tc3_imm24 + 0x00, /* special objects ('flags') */
+ scm_tc8_char = scm_tc3_imm24 + 0x08, /* characters */
+ scm_tc8_isym = scm_tc3_imm24 + 0x10, /* evaluator byte codes ('isyms') */
+ scm_tc8_iloc = scm_tc3_imm24 + 0x18 /* evaluator byte codes ('ilocs') */
};
#define SCM_ITAG8(X) (SCM_UNPACK (X) & 0xff)
#define SCM_MAKE_ITAG8(X, TAG) SCM_PACK (((X) << 8) + TAG)
#define SCM_ITAG8_DATA(X) (SCM_UNPACK (X) >> 8)
-#define SCM_ITAG9(X) (SCM_UNPACK (X) & 0x1ff)
-#define SCM_MAKE_ITAG9(X, TAG) SCM_PACK (((X) << 9) + TAG)
-#define SCM_ITAG9_DATA(X) (SCM_UNPACK (X) >> 9)
-
-
\f
-/* Flags (various constants and special objects). The indices of the flags
- * must agree with the declarations in print.c: iflagnames. */
-#define SCM_IFLAGP(n) (SCM_ITAG9 (n) == scm_tc9_flag)
-#define SCM_MAKIFLAG(n) SCM_MAKE_ITAG9 ((n), scm_tc9_flag)
-#define SCM_IFLAGNUM(n) (SCM_ITAG9_DATA (n))
+/* Flags (special objects). The indices of the flags must agree with the
+ * declarations in print.c: iflagnames. */
+
+#define SCM_IFLAGP(n) (SCM_ITAG8 (n) == scm_tc8_flag)
+#define SCM_MAKIFLAG(n) SCM_MAKE_ITAG8 ((n), scm_tc8_flag)
+#define SCM_IFLAGNUM(n) (SCM_ITAG8_DATA (n))
#define SCM_BOOL_F SCM_MAKIFLAG (0)
#define SCM_BOOL_T SCM_MAKIFLAG (1)
#define SCM_ELISP_NIL SCM_MAKIFLAG (7)
-#define SCM_UNBNDP(x) (SCM_EQ_P ((x), SCM_UNDEFINED))
-
-
-/* Short instructions ('special symbols'), long instructions ('immediate
- * symbols'). The indices of the SCM_IM_ symbols must agree with the
- * declarations in print.c: scm_isymnames. */
-
-#define SCM_MAKSPCSYM(n) SCM_PACK (((n) << 9) + ((n) << 3) + 4L)
-#define SCM_MAKISYM(n) SCM_PACK (((n) << 9) + 0x6cL)
-
-/* SCM_ISYMP tests for ISPCSYM and ISYM */
-#define SCM_ISYMP(n) ((0x187 & SCM_UNPACK (n)) == 4)
-#define SCM_ISYMNUM(n) (SCM_UNPACK (n) >> 9)
-SCM_API char *scm_isymnames[]; /* defined in print.c */
-#define SCM_ISYMCHARS(n) (scm_isymnames[SCM_ISYMNUM (n)])
-
-/* Evaluator bytecodes (short instructions): These are uniquely identified by
- * their tc7 value. This makes it possible for the evaluator to dispatch on
- * them in one step. However, the type system allows for at most 13 short
- * instructions. Consequently, the most frequent instructions are chosen to
- * be represented as short instructions. These constants are used only in
- * eval but their values have to be allocated here. */
-
-#define SCM_IM_AND SCM_MAKSPCSYM (0)
-#define SCM_IM_BEGIN SCM_MAKSPCSYM (1)
-#define SCM_IM_CASE SCM_MAKSPCSYM (2)
-#define SCM_IM_COND SCM_MAKSPCSYM (3)
-#define SCM_IM_DO SCM_MAKSPCSYM (4)
-#define SCM_IM_IF SCM_MAKSPCSYM (5)
-#define SCM_IM_LAMBDA SCM_MAKSPCSYM (6)
-#define SCM_IM_LET SCM_MAKSPCSYM (7)
-#define SCM_IM_LETSTAR SCM_MAKSPCSYM (8)
-#define SCM_IM_LETREC SCM_MAKSPCSYM (9)
-#define SCM_IM_OR SCM_MAKSPCSYM (10)
-#define SCM_IM_QUOTE SCM_MAKSPCSYM (11)
-#define SCM_IM_SET_X SCM_MAKSPCSYM (12)
-
-
-/* Evaluator bytecodes (long instructions): All these share a common tc7
- * value. Thus, the evaluator needs to dispatch on them in two steps. These
- * constants are used only in eval but their values have to be allocated
- * here. */
-
-/* Evaluator bytecode for (define ...) statements. We make it a long
- * instruction since the evaluator will see this bytecode only for a very
- * limited number of times, namely once for every top-level and internal
- * definition: Top-level definitions are only executed once and internal
- * definitions are converted to letrec expressions. */
-#define SCM_IM_DEFINE SCM_MAKISYM (13)
+#define SCM_UNBNDP(x) (scm_is_eq ((x), SCM_UNDEFINED))
+
+\f
+/* Evaluator byte codes ('immediate symbols'). These constants are used only
+ * in eval but their values have to be allocated here. The indices of the
+ * SCM_IM_ symbols must agree with the declarations in print.c:
+ * scm_isymnames. */
+
+#define SCM_ISYMP(n) (SCM_ITAG8 (n) == scm_tc8_isym)
+#define SCM_MAKISYM(n) SCM_MAKE_ITAG8 ((n), scm_tc8_isym)
+
+#define SCM_IM_AND SCM_MAKISYM (0)
+#define SCM_IM_BEGIN SCM_MAKISYM (1)
+#define SCM_IM_CASE SCM_MAKISYM (2)
+#define SCM_IM_COND SCM_MAKISYM (3)
+#define SCM_IM_DO SCM_MAKISYM (4)
+#define SCM_IM_IF SCM_MAKISYM (5)
+#define SCM_IM_LAMBDA SCM_MAKISYM (6)
+#define SCM_IM_LET SCM_MAKISYM (7)
+#define SCM_IM_LETSTAR SCM_MAKISYM (8)
+#define SCM_IM_LETREC SCM_MAKISYM (9)
+#define SCM_IM_OR SCM_MAKISYM (10)
+#define SCM_IM_QUOTE SCM_MAKISYM (11)
+#define SCM_IM_SET_X SCM_MAKISYM (12)
+#define SCM_IM_DEFINE SCM_MAKISYM (13)
#define SCM_IM_APPLY SCM_MAKISYM (14)
#define SCM_IM_CONT SCM_MAKISYM (15)
#define SCM_IM_DISPATCH SCM_MAKISYM (16)
#define SCM_IM_DELAY SCM_MAKISYM (19)
#define SCM_IM_FUTURE SCM_MAKISYM (20)
#define SCM_IM_CALL_WITH_VALUES SCM_MAKISYM (21)
-
-/* Multi-language support */
-
-#define SCM_IM_NIL_COND SCM_MAKISYM (22)
-#define SCM_IM_BIND SCM_MAKISYM (23)
+#define SCM_IM_ELSE SCM_MAKISYM (22)
+#define SCM_IM_ARROW SCM_MAKISYM (23)
+#define SCM_IM_NIL_COND SCM_MAKISYM (24) /* Multi-language support */
+#define SCM_IM_BIND SCM_MAKISYM (25) /* Multi-language support */
\f