1 /* Callstack top pointer */
4 /* TAGGED currently executing quotation */
7 /* UNTAGGED currently executing word in quotation */
10 /* UNTAGGED end of quotation */
15 #define CARD_OFF_ENV 1 /* for compiling set-slot */
16 #define NLX_VECTOR_ENV 2 /* non-local exit hook */
17 #define NAMESTACK_ENV 3 /* used by library only */
20 #define CATCHSTACK_ENV 6 /* used by library only */
23 #define CALLCC_1_ENV 9 /* used by library only */
26 #define ERROR_ENV 12 /* a marker consed onto kernel errors */
29 #define GEN_ENV 15 /* set to gen_count */
30 #define IMAGE_ENV 16 /* image name */
31 #define CELL_SIZE_ENV 17 /* sizeof(CELL) */
33 /* TAGGED user environment data; see getenv/setenv prims */
34 DLLEXPORT CELL userenv[USER_ENV];
36 /* macros for reading/writing memory, useful when working around
38 INLINE CELL get(CELL where)
40 return *((CELL*)where);
43 INLINE void put(CELL where, CELL what)
45 *((CELL*)where) = what;
48 INLINE u16 cget(CELL where)
50 return *((u16*)where);
53 INLINE void cput(CELL where, u16 what)
55 *((u16*)where) = what;
58 INLINE CELL align8(CELL a)
63 /* Canonical T object. It's just a word */
66 #define SLOT(obj,slot) ((obj) + (slot) * CELLS)
68 INLINE CELL tag_header(CELL cell)
70 return RETAG(cell << TAG_BITS,OBJECT_TYPE);
73 INLINE CELL untag_header(CELL cell)
75 /* if((cell & TAG_MASK) != OBJECT_TYPE)
76 critical_error("Corrupt object header",cell); */
78 return cell >> TAG_BITS;
81 INLINE CELL tag_object(void* cell)
83 return RETAG(cell,OBJECT_TYPE);
86 INLINE CELL object_type(CELL tagged)
88 return untag_header(get(UNTAG(tagged)));
91 INLINE CELL type_of(CELL tagged)
95 else if(TAG(tagged) == FIXNUM_TYPE)
98 return object_type(tagged);
101 void call(CELL quot);
105 void run_toplevel(void);
106 DLLEXPORT void run_callback(CELL quot);
107 void platform_run(void);
108 void undefined(F_WORD *word);
109 void docol(F_WORD *word);
110 void dosym(F_WORD *word);
111 void primitive_execute(void);
112 void primitive_call(void);
113 void primitive_ifte(void);
114 void primitive_dispatch(void);
115 void primitive_getenv(void);
116 void primitive_setenv(void);
117 void primitive_exit(void);
118 void primitive_os_env(void);
119 void primitive_eq(void);
120 void primitive_millis(void);
121 void primitive_type(void);
122 void primitive_tag(void);
123 void primitive_slot(void);
124 void primitive_set_slot(void);
125 void primitive_integer_slot(void);
126 void primitive_set_integer_slot(void);
127 CELL clone(CELL obj);
128 void primitive_clone(void);
135 ERROR_UNDEFINED_WORD,
138 ERROR_NEGATIVE_ARRAY_SIZE,
142 ERROR_UNDEFINED_SYMBOL,
143 ERROR_USER_INTERRUPT,
153 /* Are we throwing an error? */
155 /* When throw_error throws an error, it sets this global and
156 longjmps back to the top-level. */
158 CELL thrown_keep_stacks;
159 /* Since longjmp restores registers, we must save all these values. */
163 void fatal_error(char* msg, CELL tagged);
164 void critical_error(char* msg, CELL tagged);
165 void throw_error(CELL error, bool keep_stacks);
166 void early_error(CELL error);
167 void general_error(F_ERRORTYPE error, CELL arg1, CELL arg2, bool keep_stacks);
168 void memory_protection_error(void *addr, int signal);
169 void signal_error(int signal);
170 void type_error(CELL type, CELL tagged);
171 void primitive_throw(void);
172 void primitive_die(void);
174 INLINE void type_check(CELL type, CELL tagged)
176 if(type_of(tagged) != type)
177 type_error(type,tagged);