tags.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /* classes: h_files */
  2. #ifndef SCM_TAGS_H
  3. #define SCM_TAGS_H
  4. /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
  5. * 2003, 2004, 2008, 2011 Free Software Foundation, Inc.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /** This file defines the format of SCM values and cons pairs.
  22. ** It is here that tag bits are assigned for various purposes.
  23. **/
  24. /* picks up scmconfig.h too */
  25. #include "libguile/__scm.h"
  26. /* In the beginning was the Word:
  27. *
  28. * For the representation of scheme objects and their handling, Guile provides
  29. * two types: scm_t_bits and SCM.
  30. *
  31. * - scm_t_bits values can hold bit patterns of non-objects and objects:
  32. *
  33. * Non-objects -- in this case the value may not be changed into a SCM value
  34. * in any way.
  35. *
  36. * Objects -- in this case the value may be changed into a SCM value using
  37. * the SCM_PACK macro.
  38. *
  39. * - SCM values can hold proper scheme objects only. They can be changed into
  40. * a scm_t_bits value using the SCM_UNPACK macro.
  41. *
  42. * When working in the domain of scm_t_bits values, programmers must keep
  43. * track of any scm_t_bits value they create that is not a proper scheme
  44. * object. This makes sure that in the domain of SCM values developers can
  45. * rely on the fact that they are dealing with proper scheme objects only.
  46. * Thus, the distinction between scm_t_bits and SCM values helps to identify
  47. * those parts of the code where special care has to be taken not to create
  48. * bad SCM values.
  49. */
  50. /* For dealing with the bit level representation of scheme objects we define
  51. * scm_t_bits:
  52. */
  53. typedef scm_t_intptr scm_t_signed_bits;
  54. typedef scm_t_uintptr scm_t_bits;
  55. #define SCM_T_SIGNED_BITS_MAX SCM_T_INTPTR_MAX
  56. #define SCM_T_SIGNED_BITS_MIN SCM_T_INTPTR_MIN
  57. #define SCM_T_BITS_MAX SCM_T_UINTPTR_MAX
  58. /* But as external interface, we define SCM, which may, according to the
  59. * desired level of type checking, be defined in several ways:
  60. */
  61. #if (SCM_DEBUG_TYPING_STRICTNESS == 2)
  62. typedef union { struct { scm_t_bits n; } n; } SCM;
  63. static SCM scm_pack(scm_t_bits b) { SCM s; s.n.n = b; return s; }
  64. # define SCM_UNPACK(x) ((x).n.n)
  65. # define SCM_PACK(x) (scm_pack ((scm_t_bits) (x)))
  66. #elif (SCM_DEBUG_TYPING_STRICTNESS == 1)
  67. /* This is the default, which provides an intermediate level of compile time
  68. * type checking while still resulting in very efficient code.
  69. */
  70. typedef struct scm_unused_struct * SCM;
  71. /*
  72. The 0?: constructions makes sure that the code is never executed,
  73. and that there is no performance hit. However, the alternative is
  74. compiled, and does generate a warning when used with the wrong
  75. pointer type.
  76. The Tru64 and ia64-hp-hpux11.23 compilers fail on `case (0?0=0:x)'
  77. statements, so for them type-checking is disabled. */
  78. #if defined __DECC || defined __HP_cc
  79. # define SCM_UNPACK(x) ((scm_t_bits) (x))
  80. #else
  81. # define SCM_UNPACK(x) ((scm_t_bits) (0? (*(SCM*)0=(x)): x))
  82. #endif
  83. /*
  84. There is no typechecking on SCM_PACK, since all kinds of types
  85. (unsigned long, void*) go in SCM_PACK
  86. */
  87. # define SCM_PACK(x) ((SCM) (x))
  88. #else
  89. /* This should be used as a fall back solution for machines on which casting
  90. * to a pointer may lead to loss of bit information, e. g. in the three least
  91. * significant bits.
  92. */
  93. typedef scm_t_bits SCM;
  94. # define SCM_UNPACK(x) (x)
  95. # define SCM_PACK(x) ((SCM) (x))
  96. #endif
  97. /* SCM values can not be compared by using the operator ==. Use the following
  98. * macro instead, which is the equivalent of the scheme predicate 'eq?'.
  99. */
  100. #define scm_is_eq(x, y) (SCM_UNPACK (x) == SCM_UNPACK (y))
  101. /* Representation of scheme objects:
  102. *
  103. * Guile's type system is designed to work on systems where scm_t_bits and SCM
  104. * variables consist of at least 32 bits. The objects that a SCM variable can
  105. * represent belong to one of the following two major categories:
  106. *
  107. * - Immediates -- meaning that the SCM variable contains an entire Scheme
  108. * object. That means, all the object's data (including the type tagging
  109. * information that is required to identify the object's type) must fit into
  110. * 32 bits.
  111. *
  112. * - Non-immediates -- meaning that the SCM variable holds a pointer into the
  113. * heap of cells (see below). On systems where a pointer needs more than 32
  114. * bits this means that scm_t_bits and SCM variables need to be large enough
  115. * to hold such pointers. In contrast to immediates, the object's data of
  116. * a non-immediate can consume arbitrary amounts of memory: The heap cell
  117. * being pointed to consists of at least two scm_t_bits variables and thus
  118. * can be used to hold pointers to malloc'ed memory of any size.
  119. *
  120. * The 'heap' is the memory area that is under control of Guile's garbage
  121. * collector. It holds 'single-cells' or 'double-cells', which consist of
  122. * either two or four scm_t_bits variables, respectively. It is guaranteed
  123. * that the address of a cell on the heap is 8-byte aligned. That is, since
  124. * non-immediates hold a cell address, the three least significant bits of a
  125. * non-immediate can be used to store additional information. The bits are
  126. * used to store information about the object's type and thus are called
  127. * tc3-bits, where tc stands for type-code.
  128. *
  129. * For a given SCM value, the distinction whether it holds an immediate or
  130. * non-immediate object is based on the tc3-bits (see above) of its scm_t_bits
  131. * equivalent: If the tc3-bits equal #b000, then the SCM value holds a
  132. * non-immediate, and the scm_t_bits variable's value is just the pointer to
  133. * the heap cell.
  134. *
  135. * Summarized, the data of a scheme object that is represented by a SCM
  136. * variable consists of a) the SCM variable itself, b) in case of
  137. * non-immediates the data of the single-cell or double-cell the SCM object
  138. * points to, c) in case of non-immediates potentially additional data outside
  139. * of the heap (like for example malloc'ed data), and d) in case of
  140. * non-immediates potentially additional data inside of the heap, since data
  141. * stored in b) and c) may hold references to other cells.
  142. *
  143. *
  144. * Immediates
  145. *
  146. * Operations on immediate objects can typically be processed faster than on
  147. * non-immediates. The reason is that the object's data can be extracted
  148. * directly from the SCM variable (or rather a corresponding scm_t_bits
  149. * variable), instead of having to perform additional memory accesses to
  150. * obtain the object's data from the heap. In order to get the best possible
  151. * performance frequently used data types should be realized as immediates.
  152. * This is, as has been mentioned above, only possible if the objects can be
  153. * represented with 32 bits (including type tagging).
  154. *
  155. * In Guile, the following data types and special objects are realized as
  156. * immediates: booleans, characters, small integers (see below), the empty
  157. * list, the end of file object, the 'unspecified' object (which is delivered
  158. * as a return value by functions for which the return value is unspecified),
  159. * a 'nil' object used in the elisp-compatibility mode and certain other
  160. * 'special' objects which are only used internally in Guile.
  161. *
  162. * Integers in Guile can be arbitrarily large. On the other hand, integers
  163. * are one of the most frequently used data types. Especially integers with
  164. * less than 32 bits are commonly used. Thus, internally and transparently
  165. * for application code guile distinguishes between small and large integers.
  166. * Whether an integer is a large or a small integer depends on the number of
  167. * bits needed to represent its value. Small integers are those which can be
  168. * represented as immediates. Since they don't require more than a fixed
  169. * number of bits for their representation, they are also known as 'fixnums'.
  170. *
  171. * The tc3-combinations #b010 and #b110 are used to represent small integers,
  172. * which allows to use the most significant bit of the tc3-bits to be part of
  173. * the integer value being represented. This means that all integers with up
  174. * to 30 bits (including one bit for the sign) can be represented as
  175. * immediates. On systems where SCM and scm_t_bits variables hold more than
  176. * 32 bits, the amount of bits usable for small integers will even be larger.
  177. * The tc3-code #b100 is shared among booleans, characters and the other
  178. * special objects listed above.
  179. *
  180. *
  181. * Non-Immediates
  182. *
  183. * All object types not mentioned above in the list of immedate objects are
  184. * represented as non-immediates. Whether a non-immediate scheme object is
  185. * represented by a single-cell or a double-cell depends on the object's type,
  186. * namely on the set of attributes that have to be stored with objects of that
  187. * type. Every non-immediate type is allowed to define its own layout and
  188. * interpretation of the data stored in its cell (with some restrictions, see
  189. * below).
  190. *
  191. * One of the design goals of guile's type system is to make it possible to
  192. * store a scheme pair with as little memory usage as possible. The minimum
  193. * amount of memory that is required to store two scheme objects (car and cdr
  194. * of a pair) is the amount of memory required by two scm_t_bits or SCM
  195. * variables. Therefore pairs in guile are stored in single-cells.
  196. *
  197. * Another design goal for the type system is to store procedure objects
  198. * created by lambda expresssions (closures) and class instances (goops
  199. * objects) with as little memory usage as possible. Closures are represented
  200. * by a reference to the function code and a reference to the closure's
  201. * environment. Class instances are represented by a reference to the
  202. * instance's class definition and a reference to the instance's data. Thus,
  203. * closures as well as class instances also can be stored in single-cells.
  204. *
  205. * Certain other non-immediate types also store their data in single-cells.
  206. * By design decision, the heap is split into areas for single-cells and
  207. * double-cells, but not into areas for single-cells-holding-pairs and areas
  208. * for single-cells-holding-non-pairs. Any single-cell on the heap therefore
  209. * can hold pairs (consisting of two scm_t_bits variables representing two
  210. * scheme objects - the car and cdr of the pair) and non-pairs (consisting of
  211. * two scm_t_bits variables that hold bit patterns as defined by the layout of
  212. * the corresponding object's type).
  213. *
  214. *
  215. * Garbage collection
  216. *
  217. * During garbage collection, unreachable cells on the heap will be freed.
  218. * That is, the garbage collector will detect cells which have no SCM variable
  219. * pointing towards them. In order to properly release all memory belonging
  220. * to the object to which a cell belongs, the gc needs to be able to interpret
  221. * the cell contents in the correct way. That means that the gc needs to be
  222. * able to determine the object type associated with a cell only from the cell
  223. * itself.
  224. *
  225. * Consequently, if the gc detects an unreachable single-cell, those two
  226. * scm_t_bits variables must provide enough information to determine whether
  227. * they belong to a pair (i. e. both scm_t_bits variables represent valid
  228. * scheme objects), to a closure, a class instance or if they belong to any
  229. * other non-immediate. Guile's type system is designed to make it possible
  230. * to determine a the type to which a cell belongs in the majority of cases
  231. * from the cell's first scm_t_bits variable. (Given a SCM variable X holding
  232. * a non-immediate object, the macro SCM_CELL_TYPE(X) will deliver the
  233. * corresponding cell's first scm_t_bits variable.)
  234. *
  235. * If the cell holds a scheme pair, then we already know that the first
  236. * scm_t_bits variable of the cell will hold a scheme object with one of the
  237. * following tc3-codes: #b000 (non-immediate), #b010 (small integer), #b100
  238. * (small integer), #b110 (non-integer immediate). All these tc3-codes have
  239. * in common, that their least significant bit is #b0. This fact is used by
  240. * the garbage collector to identify cells that hold pairs. The remaining
  241. * tc3-codes are assigned as follows: #b001 (class instance or, more
  242. * precisely, a struct, of which a class instance is a special case), #b011
  243. * (closure), #b101/#b111 (all remaining non-immediate types).
  244. *
  245. *
  246. * Summary of type codes of scheme objects (SCM variables)
  247. *
  248. * Here is a summary of tagging bits as they might occur in a scheme object.
  249. * The notation is as follows: tc stands for type code as before, tc<n> with n
  250. * being a number indicates a type code formed by the n least significant bits
  251. * of the SCM variables corresponding scm_t_bits value.
  252. *
  253. * Note that (as has been explained above) tc1==1 can only occur in the first
  254. * scm_t_bits variable of a cell belonging to a non-immediate object that is
  255. * not a pair. For an explanation of the tc tags with tc1==1, see the next
  256. * section with the summary of the type codes on the heap.
  257. *
  258. * tc1:
  259. * 0: For scheme objects, tc1==0 must be fulfilled.
  260. * (1: This can never be the case for a scheme object.)
  261. *
  262. * tc2:
  263. * 00: Either a non-immediate or some non-integer immediate
  264. * (01: This can never be the case for a scheme object.)
  265. * 10: Small integer
  266. * (11: This can never be the case for a scheme object.)
  267. *
  268. * tc3:
  269. * 000: a non-immediate object (pair, closure, class instance etc.)
  270. * (001: This can never be the case for a scheme object.)
  271. * 010: an even small integer (least significant bit is 0).
  272. * (011: This can never be the case for a scheme object.)
  273. * 100: Non-integer immediate
  274. * (101: This can never be the case for a scheme object.)
  275. * 110: an odd small integer (least significant bit is 1).
  276. * (111: This can never be the case for a scheme object.)
  277. *
  278. * The remaining bits of the non-immediate objects form the pointer to the
  279. * heap cell. The remaining bits of the small integers form the integer's
  280. * value and sign. Thus, the only scheme objects for which a further
  281. * subdivision is of interest are the ones with tc3==100.
  282. *
  283. * tc8 (for objects with tc3==100):
  284. * 00000-100: special objects ('flags')
  285. * 00001-100: characters
  286. * 00010-100: evaluator byte codes ('isyms')
  287. * 00011-100: evaluator byte codes ('ilocs')
  288. *
  289. *
  290. * Summary of type codes on the heap
  291. *
  292. * Here is a summary of tagging in scm_t_bits values as they might occur in
  293. * the first scm_t_bits variable of a heap cell.
  294. *
  295. * tc1:
  296. * 0: the cell belongs to a pair.
  297. * 1: the cell belongs to a non-pair.
  298. *
  299. * tc2:
  300. * 00: the cell belongs to a pair with no short integer in its car.
  301. * 01: the cell belongs to a non-pair (struct or some other non-immediate).
  302. * 10: the cell belongs to a pair with a short integer in its car.
  303. * 11: the cell belongs to a non-pair (closure or some other non-immediate).
  304. *
  305. * tc3:
  306. * 000: the cell belongs to a pair with a non-immediate in its car.
  307. * 001: the cell belongs to a struct
  308. * 010: the cell belongs to a pair with an even short integer in its car.
  309. * 011: the cell belongs to a closure
  310. * 100: the cell belongs to a pair with a non-integer immediate in its car.
  311. * 101: the cell belongs to some other non-immediate.
  312. * 110: the cell belongs to a pair with an odd short integer in its car.
  313. * 111: the cell belongs to some other non-immediate.
  314. *
  315. * tc7 (for tc3==1x1):
  316. * See below for the list of types. Note the special case of scm_tc7_vector
  317. * and scm_tc7_wvect: vectors and weak vectors are treated the same in many
  318. * cases. Thus, their tc7-codes are chosen to only differ in one bit. This
  319. * makes it possible to check an object at the same time for being a vector
  320. * or a weak vector by comparing its tc7 code with that bit masked (using
  321. * the TYP7S macro). Three more special tc7-codes are of interest:
  322. * numbers, ports and smobs in fact each represent collections of types,
  323. * which are subdivided using tc16-codes.
  324. *
  325. * tc16 (for tc7==scm_tc7_smob):
  326. * The largest part of the space of smob types is not subdivided in a
  327. * predefined way, since smobs can be added arbitrarily by user C code.
  328. * However, while Guile also defines a number of smob types throughout,
  329. * there is one smob type, namely scm_tc_free_cell, for which Guile assumes
  330. * that it is declared first and thus gets a known-in-advance tc16-code.
  331. * The reason of requiring a fixed tc16-code for this type is performance.
  332. */
  333. /* Checking if a SCM variable holds an immediate or a non-immediate object:
  334. * This check can either be performed by checking for tc3==000 or tc3==00x,
  335. * since for a SCM variable it is known that tc1==0. */
  336. #define SCM_IMP(x) (6 & SCM_UNPACK (x))
  337. #define SCM_NIMP(x) (!SCM_IMP (x))
  338. /* Checking if a SCM variable holds an immediate integer: See numbers.h for
  339. * the definition of the following macros: SCM_I_FIXNUM_BIT,
  340. * SCM_MOST_POSITIVE_FIXNUM, SCM_I_INUMP, SCM_I_MAKINUM, SCM_I_INUM. */
  341. /* Checking if a SCM variable holds a pair (for historical reasons, in Guile
  342. * also known as a cons-cell): This is done by first checking that the SCM
  343. * variable holds a non-immediate, and second, by checking that tc1==0 holds
  344. * for the SCM_CELL_TYPE of the SCM variable.
  345. */
  346. #define SCM_I_CONSP(x) (!SCM_IMP (x) && ((1 & SCM_CELL_TYPE (x)) == 0))
  347. /* Definitions for tc2: */
  348. #define scm_tc2_int 2
  349. /* Definitions for tc3: */
  350. #define SCM_ITAG3(x) (7 & SCM_UNPACK (x))
  351. #define SCM_TYP3(x) (7 & SCM_CELL_TYPE (x))
  352. #define scm_tc3_cons 0
  353. #define scm_tc3_struct 1
  354. #define scm_tc3_int_1 (scm_tc2_int + 0)
  355. #define scm_tc3_closure 3
  356. #define scm_tc3_imm24 4
  357. #define scm_tc3_tc7_1 5
  358. #define scm_tc3_int_2 (scm_tc2_int + 4)
  359. #define scm_tc3_tc7_2 7
  360. /* Definitions for tc7: */
  361. #define SCM_ITAG7(x) (127 & SCM_UNPACK (x))
  362. #define SCM_TYP7(x) (0x7f & SCM_CELL_TYPE (x))
  363. #define SCM_TYP7S(x) ((0x7f & ~2) & SCM_CELL_TYPE (x))
  364. #define scm_tc7_symbol 5
  365. #define scm_tc7_variable 7
  366. /* couple */
  367. #define scm_tc7_vector 13
  368. #define scm_tc7_wvect 15
  369. #define scm_tc7_string 21
  370. #define scm_tc7_number 23
  371. #define scm_tc7_stringbuf 39
  372. /* Many of the following should be turned
  373. * into structs or smobs. We need back some
  374. * of these 7 bit tags! */
  375. #define scm_tc7_pws 31
  376. #define scm_tc7_unused_1 29
  377. #define scm_tc7_unused_2 37
  378. #define scm_tc7_unused_3 45
  379. #define scm_tc7_unused_4 47
  380. #define scm_tc7_unused_5 53
  381. #define scm_tc7_unused_6 55
  382. #define scm_tc7_unused_7 71
  383. #define scm_tc7_unused_8 77
  384. #define scm_tc7_unused_9 79
  385. #define scm_tc7_dsubr 61
  386. #define scm_tc7_cclo 63
  387. #define scm_tc7_rpsubr 69
  388. #define scm_tc7_subr_0 85
  389. #define scm_tc7_subr_1 87
  390. #define scm_tc7_cxr 93
  391. #define scm_tc7_subr_3 95
  392. #define scm_tc7_subr_2 101
  393. #define scm_tc7_asubr 103
  394. #define scm_tc7_subr_1o 109
  395. #define scm_tc7_subr_2o 111
  396. #define scm_tc7_lsubr_2 117
  397. #define scm_tc7_lsubr 119
  398. /* There are 256 port subtypes. */
  399. #define scm_tc7_port 125
  400. /* There are 256 smob subtypes. [**] If you change scm_tc7_smob, you must
  401. * also change the places it is hard coded in this file and possibly others.
  402. * Dirk:FIXME:: Any hard coded reference to scm_tc7_smob must be replaced by a
  403. * symbolic reference. */
  404. #define scm_tc7_smob 127 /* DO NOT CHANGE [**] */
  405. /* Definitions for tc16: */
  406. #define SCM_TYP16(x) (0xffff & SCM_CELL_TYPE (x))
  407. #define SCM_TYP16_PREDICATE(tag, x) (!SCM_IMP (x) && SCM_TYP16 (x) == (tag))
  408. /* Here is the first smob subtype. */
  409. /* scm_tc_free_cell is the 0th smob type. We place this in free cells to tell
  410. * the conservative marker not to trace it. */
  411. #define scm_tc_free_cell (scm_tc7_smob + 0 * 256L)
  412. /* {Immediate Values}
  413. */
  414. enum scm_tc8_tags
  415. {
  416. scm_tc8_flag = scm_tc3_imm24 + 0x00, /* special objects ('flags') */
  417. scm_tc8_char = scm_tc3_imm24 + 0x08, /* characters */
  418. scm_tc8_isym = scm_tc3_imm24 + 0x10, /* evaluator byte codes ('isyms') */
  419. scm_tc8_iloc = scm_tc3_imm24 + 0x18 /* evaluator byte codes ('ilocs') */
  420. };
  421. #define SCM_ITAG8(X) (SCM_UNPACK (X) & 0xff)
  422. #define SCM_MAKE_ITAG8(X, TAG) SCM_PACK (((X) << 8) + TAG)
  423. #define SCM_ITAG8_DATA(X) (SCM_UNPACK (X) >> 8)
  424. /* Flags (special objects). The indices of the flags must agree with the
  425. * declarations in print.c: iflagnames. */
  426. #define SCM_IFLAGP(n) (SCM_ITAG8 (n) == scm_tc8_flag)
  427. #define SCM_MAKIFLAG(n) SCM_MAKE_ITAG8 ((n), scm_tc8_flag)
  428. #define SCM_IFLAGNUM(n) (SCM_ITAG8_DATA (n))
  429. #define SCM_BOOL_F SCM_MAKIFLAG (0)
  430. #define SCM_BOOL_T SCM_MAKIFLAG (1)
  431. #define SCM_UNDEFINED SCM_MAKIFLAG (2)
  432. #define SCM_EOF_VAL SCM_MAKIFLAG (3)
  433. #define SCM_EOL SCM_MAKIFLAG (4)
  434. #define SCM_UNSPECIFIED SCM_MAKIFLAG (5)
  435. /* When a variable is unbound this is marked by the SCM_UNDEFINED
  436. * value. The following is an unbound value which can be handled on
  437. * the Scheme level, i.e., it can be stored in and retrieved from a
  438. * Scheme variable. This value is only intended to mark an unbound
  439. * slot in GOOPS. It is needed now, but we should probably rewrite
  440. * the code which handles this value in C so that SCM_UNDEFINED can be
  441. * used instead. It is not ideal to let this kind of unique and
  442. * strange values loose on the Scheme level. */
  443. #define SCM_UNBOUND SCM_MAKIFLAG (6)
  444. /* The Elisp nil value. */
  445. #define SCM_ELISP_NIL SCM_MAKIFLAG (7)
  446. #define SCM_UNBNDP(x) (scm_is_eq ((x), SCM_UNDEFINED))
  447. /* Evaluator byte codes ('immediate symbols'). These constants are used only
  448. * in eval but their values have to be allocated here. The indices of the
  449. * SCM_IM_ symbols must agree with the declarations in print.c:
  450. * scm_isymnames. */
  451. #define SCM_ISYMP(n) (SCM_ITAG8 (n) == scm_tc8_isym)
  452. #define SCM_MAKISYM(n) SCM_MAKE_ITAG8 ((n), scm_tc8_isym)
  453. #define SCM_IM_AND SCM_MAKISYM (0)
  454. #define SCM_IM_BEGIN SCM_MAKISYM (1)
  455. #define SCM_IM_CASE SCM_MAKISYM (2)
  456. #define SCM_IM_COND SCM_MAKISYM (3)
  457. #define SCM_IM_DO SCM_MAKISYM (4)
  458. #define SCM_IM_IF SCM_MAKISYM (5)
  459. #define SCM_IM_LAMBDA SCM_MAKISYM (6)
  460. #define SCM_IM_LET SCM_MAKISYM (7)
  461. #define SCM_IM_LETSTAR SCM_MAKISYM (8)
  462. #define SCM_IM_LETREC SCM_MAKISYM (9)
  463. #define SCM_IM_OR SCM_MAKISYM (10)
  464. #define SCM_IM_QUOTE SCM_MAKISYM (11)
  465. #define SCM_IM_SET_X SCM_MAKISYM (12)
  466. #define SCM_IM_DEFINE SCM_MAKISYM (13)
  467. #define SCM_IM_APPLY SCM_MAKISYM (14)
  468. #define SCM_IM_CONT SCM_MAKISYM (15)
  469. #define SCM_IM_DISPATCH SCM_MAKISYM (16)
  470. #define SCM_IM_SLOT_REF SCM_MAKISYM (17)
  471. #define SCM_IM_SLOT_SET_X SCM_MAKISYM (18)
  472. #define SCM_IM_DELAY SCM_MAKISYM (19)
  473. #define SCM_IM_FUTURE SCM_MAKISYM (20)
  474. #define SCM_IM_CALL_WITH_VALUES SCM_MAKISYM (21)
  475. #define SCM_IM_ELSE SCM_MAKISYM (22)
  476. #define SCM_IM_ARROW SCM_MAKISYM (23)
  477. #define SCM_IM_NIL_COND SCM_MAKISYM (24) /* Multi-language support */
  478. #define SCM_IM_BIND SCM_MAKISYM (25) /* Multi-language support */
  479. /* Dispatching aids:
  480. When switching on SCM_TYP7 of a SCM value, use these fake case
  481. labels to catch types that use fewer than 7 bits for tagging. */
  482. /* For cons pairs with immediate values in the CAR
  483. */
  484. #define scm_tcs_cons_imcar \
  485. scm_tc2_int + 0: case scm_tc2_int + 4: case scm_tc3_imm24 + 0:\
  486. case scm_tc2_int + 8: case scm_tc2_int + 12: case scm_tc3_imm24 + 8:\
  487. case scm_tc2_int + 16: case scm_tc2_int + 20: case scm_tc3_imm24 + 16:\
  488. case scm_tc2_int + 24: case scm_tc2_int + 28: case scm_tc3_imm24 + 24:\
  489. case scm_tc2_int + 32: case scm_tc2_int + 36: case scm_tc3_imm24 + 32:\
  490. case scm_tc2_int + 40: case scm_tc2_int + 44: case scm_tc3_imm24 + 40:\
  491. case scm_tc2_int + 48: case scm_tc2_int + 52: case scm_tc3_imm24 + 48:\
  492. case scm_tc2_int + 56: case scm_tc2_int + 60: case scm_tc3_imm24 + 56:\
  493. case scm_tc2_int + 64: case scm_tc2_int + 68: case scm_tc3_imm24 + 64:\
  494. case scm_tc2_int + 72: case scm_tc2_int + 76: case scm_tc3_imm24 + 72:\
  495. case scm_tc2_int + 80: case scm_tc2_int + 84: case scm_tc3_imm24 + 80:\
  496. case scm_tc2_int + 88: case scm_tc2_int + 92: case scm_tc3_imm24 + 88:\
  497. case scm_tc2_int + 96: case scm_tc2_int + 100: case scm_tc3_imm24 + 96:\
  498. case scm_tc2_int + 104: case scm_tc2_int + 108: case scm_tc3_imm24 + 104:\
  499. case scm_tc2_int + 112: case scm_tc2_int + 116: case scm_tc3_imm24 + 112:\
  500. case scm_tc2_int + 120: case scm_tc2_int + 124: case scm_tc3_imm24 + 120
  501. /* For cons pairs with non-immediate values in the SCM_CAR
  502. */
  503. #define scm_tcs_cons_nimcar \
  504. scm_tc3_cons + 0:\
  505. case scm_tc3_cons + 8:\
  506. case scm_tc3_cons + 16:\
  507. case scm_tc3_cons + 24:\
  508. case scm_tc3_cons + 32:\
  509. case scm_tc3_cons + 40:\
  510. case scm_tc3_cons + 48:\
  511. case scm_tc3_cons + 56:\
  512. case scm_tc3_cons + 64:\
  513. case scm_tc3_cons + 72:\
  514. case scm_tc3_cons + 80:\
  515. case scm_tc3_cons + 88:\
  516. case scm_tc3_cons + 96:\
  517. case scm_tc3_cons + 104:\
  518. case scm_tc3_cons + 112:\
  519. case scm_tc3_cons + 120
  520. /* For structs
  521. */
  522. #define scm_tcs_struct \
  523. scm_tc3_struct + 0:\
  524. case scm_tc3_struct + 8:\
  525. case scm_tc3_struct + 16:\
  526. case scm_tc3_struct + 24:\
  527. case scm_tc3_struct + 32:\
  528. case scm_tc3_struct + 40:\
  529. case scm_tc3_struct + 48:\
  530. case scm_tc3_struct + 56:\
  531. case scm_tc3_struct + 64:\
  532. case scm_tc3_struct + 72:\
  533. case scm_tc3_struct + 80:\
  534. case scm_tc3_struct + 88:\
  535. case scm_tc3_struct + 96:\
  536. case scm_tc3_struct + 104:\
  537. case scm_tc3_struct + 112:\
  538. case scm_tc3_struct + 120
  539. /* For closures
  540. */
  541. #define scm_tcs_closures \
  542. scm_tc3_closure + 0:\
  543. case scm_tc3_closure + 8:\
  544. case scm_tc3_closure + 16:\
  545. case scm_tc3_closure + 24:\
  546. case scm_tc3_closure + 32:\
  547. case scm_tc3_closure + 40:\
  548. case scm_tc3_closure + 48:\
  549. case scm_tc3_closure + 56:\
  550. case scm_tc3_closure + 64:\
  551. case scm_tc3_closure + 72:\
  552. case scm_tc3_closure + 80:\
  553. case scm_tc3_closure + 88:\
  554. case scm_tc3_closure + 96:\
  555. case scm_tc3_closure + 104:\
  556. case scm_tc3_closure + 112:\
  557. case scm_tc3_closure + 120
  558. /* For subrs
  559. */
  560. #define scm_tcs_subrs \
  561. scm_tc7_asubr:\
  562. case scm_tc7_subr_0:\
  563. case scm_tc7_subr_1:\
  564. case scm_tc7_dsubr:\
  565. case scm_tc7_cxr:\
  566. case scm_tc7_subr_3:\
  567. case scm_tc7_subr_2:\
  568. case scm_tc7_rpsubr:\
  569. case scm_tc7_subr_1o:\
  570. case scm_tc7_subr_2o:\
  571. case scm_tc7_lsubr_2:\
  572. case scm_tc7_lsubr
  573. #if (SCM_ENABLE_DEPRECATED == 1)
  574. #define SCM_CELLP(x) (((sizeof (scm_t_cell) - 1) & SCM_UNPACK (x)) == 0)
  575. #define SCM_NCELLP(x) (!SCM_CELLP (x))
  576. #endif
  577. #endif /* SCM_TAGS_H */
  578. /*
  579. Local Variables:
  580. c-file-style: "gnu"
  581. End:
  582. */