-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstubforth.h
68 lines (52 loc) · 1.63 KB
/
stubforth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef STUBFORTH_H
#define STUBFORTH_H
#include "config.h"
union cell {
void *a;
void **aa;
vmint i;
uvmint u;
char *s;
};
typedef union cell cell;
/* GCC supports static initialization of flexible arrays, but we work
around it for portability's sake and because it produces bogus
sizes in the ELF meta-info. */
#define staticword(len) \
const char *name; \
int compile_only : 1; \
int immediate : 1; \
int smudge : 1; \
struct word *link; \
void *code; \
cell data[len]; \
struct word {
staticword(0)
};
struct vmstate {
cell *dp; /* Points above top of data stack. */
cell *rp; /* Invalid during execution of a VM. */
cell *sp; /* Invalid during execution of a VM. */
struct word *dictionary;
char base; /* This ought to be cell-sized according to standards. */
int compiling : 1; /* Used by state-aware word INTERPRET */
};
struct terminal {
int raw : 1; /* Avoid translating lf to crlf, etc. Set this if you
want to process binary data. */
int quiet : 1; /* Don't echo incoming characters as they are
consumed by the VM. */
};
extern struct terminal terminal;
#define IS_WORD(c) (c > ' ')
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
#define CFA2WORD(cfa) ((word *)(((char *)cfa) - offsetof(word, code)))
extern struct vmstate vmstate;
typedef struct word word;
extern struct word *forth; /* points to the head of head of the static
dictionary. */
cell vm(struct vmstate *vmstate, void *const*xt);
void stubforth_init(void);
const word *find(const word *p, const char *key);
void my_puts(const char *s);
#endif