]> gitweb.factorcode.org Git - factor.git/blob - native/run.h
working on native image output
[factor.git] / native / run.h
1 #define USER_ENV 16
2
3 #define STDIN_ENV      0
4 #define STDOUT_ENV     1
5 #define STDERR_ENV     2
6 #define NAMESTACK_ENV  3
7 #define GLOBAL_ENV     4
8 #define BREAK_ENV      5
9 #define CATCHSTACK_ENV 6
10 #define GC_ENV         7
11
12 /* Error handlers restore this */
13 jmp_buf toplevel;
14
15 typedef struct {
16         /* TAGGED top of datastack; EMPTY if datastack is empty */
17         CELL dt;
18         /* TAGGED currently executing quotation */
19         CELL cf;
20         /* TAGGED pointer to datastack bottom */
21         CELL ds_bot;
22         /* raw pointer to datastack top */
23         CELL ds;
24         /* TAGGED pointer to callstack bottom */
25         CELL cs_bot;
26         /* raw pointer to callstack top */
27         CELL cs;
28         /* raw pointer to currently executing word */
29         WORD* w;
30         /* TAGGED bootstrap quotation */
31         CELL boot;
32         /* TAGGED user environment data */
33         CELL user[USER_ENV];
34 } ENV;
35
36 ENV env;
37
38 void clear_environment(void);
39 void init_environment(void);
40 void check_non_empty(CELL cell);
41
42 INLINE CELL dpop(void)
43 {
44         env.ds -= CELLS;
45         return get(env.ds);
46 }
47
48 INLINE void dpush(CELL top)
49 {
50         put(env.ds,top);
51         env.ds += CELLS;
52 }
53
54 INLINE CELL dpeek(void)
55 {
56         return get(env.ds - CELLS);
57 }
58
59 INLINE CELL cpop(void)
60 {
61         env.cs -= CELLS;
62         return get(env.cs);
63 }
64
65 INLINE void cpush(CELL top)
66 {
67         put(env.cs,top);
68         env.cs += CELLS;
69 }
70
71 INLINE CELL cpeek(void)
72 {
73         return get(env.cs - CELLS);
74 }
75
76 void run(void);
77 void undefined(void);
78 void call(void);
79 void primitive_execute(void);
80 void primitive_call(void);
81 void primitive_ifte(void);
82 void primitive_getenv(void);
83 void primitive_setenv(void);
84 void primitive_exit(void);