#define INLINE inline static typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; typedef signed char s8; typedef signed short s16; typedef signed int s32; typedef signed long long s64; #ifdef _WIN64 typedef long long F_FIXNUM; typedef unsigned long long CELL; #else typedef long F_FIXNUM; typedef unsigned long CELL; #endif #define CELLS ((signed)sizeof(CELL)) /* must always be 16 bits */ #define CHARS ((signed)sizeof(u16)) #define WORD_SIZE (CELLS*8) #define HALF_WORD_SIZE (CELLS*4) #define HALF_WORD_MASK (((unsigned long)1<> TAG_BITS; } INLINE CELL tag_fixnum(F_FIXNUM untagged) { return RETAG(untagged << TAG_BITS,FIXNUM_TYPE); } INLINE void *untag_object(CELL tagged) { return (void *)UNTAG(tagged); } typedef void *XT; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; /* tagged */ CELL capacity; } F_ARRAY; typedef F_ARRAY F_BYTE_ARRAY; typedef F_ARRAY F_BIT_ARRAY; typedef F_ARRAY F_FLOAT_ARRAY; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { /* always tag_header(VECTOR_TYPE) */ CELL header; /* tagged */ CELL top; /* tagged */ CELL array; } F_VECTOR; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; /* tagged num of chars */ CELL length; /* tagged */ CELL hashcode; } F_STRING; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { /* always tag_header(SBUF_TYPE) */ CELL header; /* tagged */ CELL top; /* tagged */ CELL string; } F_SBUF; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { /* always tag_header(HASHTABLE_TYPE) */ CELL header; /* tagged */ CELL count; /* tagged */ CELL deleted; /* tagged */ CELL array; } F_HASHTABLE; /* The compiled code heap is structured into blocks. */ typedef struct { CELL type; /* this is WORD_TYPE or QUOTATION_TYPE */ CELL code_length; /* # bytes */ CELL reloc_length; /* # bytes */ CELL literals_length; /* # bytes */ CELL words_length; /* # bytes */ CELL profiler_prologue; /* # bytes */ CELL padding[2]; } F_COMPILED; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { /* TAGGED header */ CELL header; /* TAGGED hashcode */ CELL hashcode; /* TAGGED word name */ CELL name; /* TAGGED word vocabulary */ CELL vocabulary; /* TAGGED definition */ CELL def; /* TAGGED property assoc for library code */ CELL props; /* TAGGED t or f, depending on if the word is compiled or not */ CELL compiledp; /* TAGGED call count for profiling */ CELL counter; /* UNTAGGED execution token: jump here to execute word */ XT xt; /* UNTAGGED compiled code block */ F_COMPILED *code; } F_WORD; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; CELL object; } F_WRAPPER; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; CELL numerator; CELL denominator; } F_RATIO; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { /* C sucks. */ union { CELL header; long long padding; }; double n; } F_FLOAT; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; /* tagged */ CELL array; /* tagged */ CELL compiledp; /* UNTAGGED */ XT xt; /* UNTAGGED compiled code block */ F_COMPILED *code; } F_QUOTATION; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; CELL real; CELL imaginary; } F_COMPLEX; /* Assembly code makes assumptions about the layout of this struct */ typedef struct { CELL header; /* tagged */ CELL alien; /* tagged */ CELL expired; /* untagged */ CELL displacement; } F_ALIEN; typedef struct { CELL header; /* tagged byte array holding a C string */ CELL path; /* OS-specific handle */ void* dll; } F_DLL; typedef struct { CELL header; /* tagged */ CELL obj; /* tagged */ CELL quot; } F_CURRY; typedef struct { CELL header; /* tagged */ CELL length; } F_CALLSTACK; typedef struct { /* In compiled quotation frames, position within the array. In compiled word frames, unused. */ CELL scan; /* In compiled quotation frames, the quot->array slot. In compiled word frames, unused. */ CELL array; /* In all compiled frames, the XT on entry. */ XT xt; /* Frame size in bytes */ CELL size; } F_STACK_FRAME;