old-scheme48.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. typedef long scheme_value;
  2. #define FIXNUM_TAG 0
  3. #define FIXNUMP(x) (((long)(x) & 3L) == FIXNUM_TAG)
  4. #define IMMEDIATE_TAG 1
  5. #define IMMEDIATEP(x) (((long)(x) & 3L) == IMMEDIATE_TAG)
  6. #define HEADER_TAG 2
  7. #define HEADERP(x) (((long)(x) & 3L) == HEADER_TAG)
  8. #define STOB_TAG 3
  9. #define STOBP(x) (((long)(x) & 3L) == STOB_TAG)
  10. #define ENTER_FIXNUM(n) ((scheme_value)((n) << 2))
  11. #define EXTRACT_FIXNUM(x) ((long)(x) >> 2)
  12. #define MISC_IMMEDIATE(n) (scheme_value)(IMMEDIATE_TAG | ((n) << 2))
  13. #define SCHFALSE MISC_IMMEDIATE(0)
  14. #define SCHTRUE MISC_IMMEDIATE(1)
  15. #define SCHCHAR MISC_IMMEDIATE(2)
  16. #define SCHUNSPECIFIC MISC_IMMEDIATE(3)
  17. #define SCHUNDEFINED MISC_IMMEDIATE(4)
  18. #define SCHEOF MISC_IMMEDIATE(5)
  19. #define SCHNULL MISC_IMMEDIATE(6)
  20. #define UNDEFINED SCHUNDEFINED
  21. #define UNSPECIFIC SCHUNSPECIFIC
  22. #define ENTER_BOOLEAN(n) ((n) ? SCHTRUE : SCHFALSE)
  23. #define EXTRACT_BOOLEAN(x) ((x) != SCHFALSE)
  24. #define ENTER_CHAR(c) (SCHCHAR | ((c) << 8))
  25. #define EXTRACT_CHAR(x) ((x) >> 8)
  26. #define CHARP(x) ((((long) (x)) & 0xff) == SCHCHAR)
  27. #define ADDRESS_AFTER_HEADER(x, type) ((type *)((x) - STOB_TAG))
  28. #define STOB_REF(x, i) ((ADDRESS_AFTER_HEADER(x, long))[i])
  29. #define STOB_TYPE(x) ((STOB_HEADER(x)>>2)&31)
  30. #define STOB_HEADER(x) (STOB_REF((x),-1))
  31. #define STOB_BLENGTH(x) (STOB_HEADER(x) >> 8)
  32. #define STOB_LLENGTH(x) (STOB_HEADER(x) >> 10)
  33. #define STOBTYPE_PAIR 0
  34. #define PAIRP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_PAIR))
  35. #define STOBTYPE_SYMBOL 1
  36. #define SYMBOLP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_SYMBOL))
  37. #define STOBTYPE_VECTOR 2
  38. #define VECTORP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_VECTOR))
  39. #define STOBTYPE_CLOSURE 3
  40. #define CLOSUREP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_CLOSURE))
  41. #define STOBTYPE_LOCATION 4
  42. #define LOCATIONP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_LOCATION))
  43. #define STOBTYPE_CHANNEL 5
  44. #define CHANNELP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_CHANNEL))
  45. #define STOBTYPE_PORT 6
  46. #define PORTP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_PORT))
  47. #define STOBTYPE_RATNUM 7
  48. #define RATNUMP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_RATNUM))
  49. #define STOBTYPE_RECORD 8
  50. #define RECORDP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_RECORD))
  51. #define STOBTYPE_CONTINUATION 9
  52. #define CONTINUATIONP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_CONTINUATION))
  53. #define STOBTYPE_EXTENDED_NUMBER 10
  54. #define EXTENDED_NUMBERP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_EXTENDED_NUMBER))
  55. #define STOBTYPE_TEMPLATE 11
  56. #define TEMPLATEP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_TEMPLATE))
  57. #define STOBTYPE_WEAK_POINTER 12
  58. #define WEAK_POINTERP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_WEAK_POINTER))
  59. #define STOBTYPE_SHARED_BINDING 13
  60. #define SHARED_BINDINGP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_SHARED_BINDING))
  61. #define STOBTYPE_UNUSED_D_HEADER1 14
  62. #define UNUSED_D_HEADER1P(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_UNUSED_D_HEADER1))
  63. #define STOBTYPE_UNUSED_D_HEADER2 15
  64. #define UNUSED_D_HEADER2P(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_UNUSED_D_HEADER2))
  65. #define STOBTYPE_STRING 16
  66. #define STRINGP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_STRING))
  67. #define STOBTYPE_CODE_VECTOR 17
  68. #define CODE_VECTORP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_CODE_VECTOR))
  69. #define STOBTYPE_DOUBLE 18
  70. #define DOUBLEP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_DOUBLE))
  71. #define STOBTYPE_BIGNUM 19
  72. #define BIGNUMP(x) (STOBP(x) && (STOB_TYPE(x) == STOBTYPE_BIGNUM))
  73. #define CAR(x) STOB_REF(x, 0)
  74. #define CDR(x) STOB_REF(x, 1)
  75. #define SYMBOL_TO_STRING(x) STOB_REF(x, 0)
  76. #define LOCATION_ID(x) STOB_REF(x, 0)
  77. #define CONTENTS(x) STOB_REF(x, 1)
  78. #define CLOSURE_TEMPLATE(x) STOB_REF(x, 0)
  79. #define CLOSURE_ENV(x) STOB_REF(x, 1)
  80. #define WEAK_POINTER_REF(x) STOB_REF(x, 0)
  81. #define SHARED_BINDING_NAME(x) STOB_REF(x, 0)
  82. #define SHARED_BINDING_IS_IMPORTP(x) STOB_REF(x, 1)
  83. #define SHARED_BINDING_REF(x) STOB_REF(x, 2)
  84. #define PORT_HANDLER(x) STOB_REF(x, 0)
  85. #define PORT_STATUS(x) STOB_REF(x, 1)
  86. #define PORT_LOCK(x) STOB_REF(x, 2)
  87. #define PORT_LOCKEDP(x) STOB_REF(x, 3)
  88. #define PORT_DATA(x) STOB_REF(x, 4)
  89. #define PORT_BUFFER(x) STOB_REF(x, 5)
  90. #define PORT_INDEX(x) STOB_REF(x, 6)
  91. #define PORT_LIMIT(x) STOB_REF(x, 7)
  92. #define PORT_PENDING_EOFP(x) STOB_REF(x, 8)
  93. #define CHANNEL_STATUS(x) STOB_REF(x, 0)
  94. #define CHANNEL_ID(x) STOB_REF(x, 1)
  95. #define CHANNEL_OS_INDEX(x) STOB_REF(x, 2)
  96. #define VECTOR_LENGTH(x) STOB_LLENGTH(x)
  97. #define VECTOR_REF(x, i) STOB_REF(x, i)
  98. #define CODE_VECTOR_LENGTH(x) STOB_BLENGTH(x)
  99. #define CODE_VECTOR_REF(x, i) (ADDRESS_AFTER_HEADER(x, unsigned char)[i])
  100. #define STRING_LENGTH(x) (STOB_BLENGTH(x)-1)
  101. #define STRING_REF(x, i) (ADDRESS_AFTER_HEADER(x, char)[i])