2006-07-07 00:07:18 -04:00
|
|
|
/* Callstack top pointer */
|
|
|
|
CELL cs;
|
|
|
|
|
|
|
|
/* TAGGED currently executing quotation */
|
|
|
|
CELL callframe;
|
|
|
|
|
|
|
|
/* UNTAGGED currently executing word in quotation */
|
|
|
|
CELL callframe_scan;
|
|
|
|
|
|
|
|
/* UNTAGGED end of quotation */
|
|
|
|
CELL callframe_end;
|
|
|
|
|
2005-09-24 17:26:04 -04:00
|
|
|
#define USER_ENV 32
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-12-11 15:14:41 -05:00
|
|
|
#define CARD_OFF_ENV 1 /* for compiling set-slot */
|
|
|
|
/* 2 is unused */
|
|
|
|
#define NAMESTACK_ENV 3 /* used by library only */
|
|
|
|
#define GLOBAL_ENV 4
|
|
|
|
#define BREAK_ENV 5
|
|
|
|
#define CATCHSTACK_ENV 6 /* used by library only */
|
|
|
|
#define CPU_ENV 7
|
|
|
|
#define BOOT_ENV 8
|
|
|
|
#define CALLCC_1_ENV 9 /* used by library only */
|
|
|
|
#define ARGS_ENV 10
|
|
|
|
#define OS_ENV 11
|
|
|
|
#define ERROR_ENV 12 /* a marker consed onto kernel errors */
|
|
|
|
#define IN_ENV 13
|
|
|
|
#define OUT_ENV 14
|
|
|
|
#define GEN_ENV 15 /* set to gen_count */
|
|
|
|
#define IMAGE_ENV 16 /* image name */
|
|
|
|
#define CELL_SIZE_ENV 17 /* sizeof(CELL) */
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-05-13 00:09:49 -04:00
|
|
|
/* TAGGED user environment data; see getenv/setenv prims */
|
2005-05-13 20:37:28 -04:00
|
|
|
DLLEXPORT CELL userenv[USER_ENV];
|
2005-05-13 00:09:49 -04:00
|
|
|
|
2006-05-17 14:55:46 -04:00
|
|
|
void call(CELL quot);
|
2004-08-23 01:13:09 -04:00
|
|
|
|
2006-02-19 22:08:08 -05:00
|
|
|
void handle_error();
|
2006-02-23 02:09:34 -05:00
|
|
|
void run(void);
|
2006-02-13 16:00:21 -05:00
|
|
|
void run_toplevel(void);
|
2006-02-14 23:23:08 -05:00
|
|
|
DLLEXPORT void run_callback(CELL quot);
|
2005-02-08 17:05:08 -05:00
|
|
|
void platform_run(void);
|
2005-09-14 00:37:50 -04:00
|
|
|
void undefined(F_WORD *word);
|
|
|
|
void docol(F_WORD *word);
|
|
|
|
void dosym(F_WORD *word);
|
2004-07-16 02:26:21 -04:00
|
|
|
void primitive_execute(void);
|
|
|
|
void primitive_call(void);
|
|
|
|
void primitive_ifte(void);
|
2005-06-12 03:38:57 -04:00
|
|
|
void primitive_dispatch(void);
|
2004-07-16 02:26:21 -04:00
|
|
|
void primitive_getenv(void);
|
|
|
|
void primitive_setenv(void);
|
2006-07-07 00:07:18 -04:00
|
|
|
void primitive_exit(void);
|
|
|
|
void primitive_os_env(void);
|
|
|
|
void primitive_eq(void);
|
|
|
|
void primitive_millis(void);
|
|
|
|
|
|
|
|
/* Runtime errors */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ERROR_EXPIRED,
|
|
|
|
ERROR_IO,
|
|
|
|
ERROR_UNDEFINED_WORD,
|
|
|
|
ERROR_TYPE,
|
|
|
|
ERROR_SIGNAL,
|
|
|
|
ERROR_NEGATIVE_ARRAY_SIZE,
|
|
|
|
ERROR_C_STRING,
|
|
|
|
ERROR_FFI,
|
|
|
|
ERROR_HEAP_SCAN,
|
|
|
|
ERROR_UNDEFINED_SYMBOL,
|
|
|
|
ERROR_USER_INTERRUPT,
|
|
|
|
ERROR_DS_UNDERFLOW,
|
|
|
|
ERROR_DS_OVERFLOW,
|
|
|
|
ERROR_RS_UNDERFLOW,
|
|
|
|
ERROR_RS_OVERFLOW,
|
|
|
|
ERROR_CS_UNDERFLOW,
|
|
|
|
ERROR_CS_OVERFLOW,
|
|
|
|
ERROR_OBJECTIVE_C
|
|
|
|
} F_ERRORTYPE;
|
|
|
|
|
|
|
|
/* Are we throwing an error? */
|
|
|
|
bool throwing;
|
|
|
|
/* When throw_error throws an error, it sets this global and
|
|
|
|
longjmps back to the top-level. */
|
|
|
|
CELL thrown_error;
|
|
|
|
CELL thrown_keep_stacks;
|
|
|
|
/* Since longjmp restores registers, we must save all these values. */
|
|
|
|
CELL thrown_ds;
|
|
|
|
CELL thrown_rs;
|
|
|
|
|
|
|
|
void fatal_error(char* msg, CELL tagged);
|
|
|
|
void critical_error(char* msg, CELL tagged);
|
|
|
|
void throw_error(CELL error, bool keep_stacks);
|
|
|
|
void early_error(CELL error);
|
|
|
|
void general_error(F_ERRORTYPE error, CELL arg1, CELL arg2, bool keep_stacks);
|
2006-08-03 17:00:33 -04:00
|
|
|
void memory_protection_error(void *addr, int signal);
|
2006-07-07 00:07:18 -04:00
|
|
|
void signal_error(int signal);
|
|
|
|
void type_error(CELL type, CELL tagged);
|
|
|
|
void primitive_throw(void);
|
|
|
|
void primitive_die(void);
|