factor/native/run.h

89 lines
1.4 KiB
C
Raw Normal View History

2004-07-16 02:26:21 -04:00
#define USER_ENV 16
2004-07-29 17:18:41 -04:00
#define STDIN_ENV 0
#define STDOUT_ENV 1
#define STDERR_ENV 2
#define NAMESTACK_ENV 3
#define GLOBAL_ENV 4
#define BREAK_ENV 5
#define CATCHSTACK_ENV 6
#define GC_ENV 7
2004-07-16 02:26:21 -04:00
/* Error handlers restore this */
sigjmp_buf toplevel;
2004-07-16 02:26:21 -04:00
typedef struct {
/* TAGGED currently executing quotation */
CELL cf;
2004-08-12 02:13:43 -04:00
/* raw pointer to datastack bottom */
2004-07-16 02:26:21 -04:00
CELL ds_bot;
/* raw pointer to datastack top */
CELL ds;
2004-08-12 02:13:43 -04:00
/* raw pointer to callstack bottom */
2004-07-16 02:26:21 -04:00
CELL cs_bot;
/* raw pointer to callstack top */
CELL cs;
/* raw pointer to currently executing word */
WORD* w;
/* TAGGED bootstrap quotation */
CELL boot;
/* TAGGED user environment data */
CELL user[USER_ENV];
} ENV;
ENV env;
2004-08-16 21:05:38 -04:00
void init_signals(void);
2004-07-16 02:26:21 -04:00
void clear_environment(void);
INLINE CELL dpop(void)
{
env.ds -= CELLS;
return get(env.ds);
}
INLINE void drepl(CELL top)
{
put(env.ds - CELLS,top);
}
2004-07-16 02:26:21 -04:00
INLINE void dpush(CELL top)
{
put(env.ds,top);
env.ds += CELLS;
}
INLINE CELL dpeek(void)
{
return get(env.ds - CELLS);
}
INLINE CELL cpop(void)
{
env.cs -= CELLS;
return get(env.cs);
}
INLINE void cpush(CELL top)
{
put(env.cs,top);
env.cs += CELLS;
}
INLINE CELL cpeek(void)
{
return get(env.cs - CELLS);
}
void run(void);
void undefined(void);
void call(void);
void primitive_execute(void);
void primitive_call(void);
void primitive_ifte(void);
void primitive_getenv(void);
void primitive_setenv(void);
void primitive_exit(void);
2004-07-30 16:22:20 -04:00
void primitive_os_env(void);