Annotation of gforth/forth.h, revision 1.12
1.1 anton 1: /*
2: Copyright 1992 by the ANSI figForth Development Group
3: */
4:
5: /* common header file */
6:
7: typedef void *Label;
8:
1.2 pazsan 9: /* symbol indexed constants */
10:
11: #define DOCOL 0
12: #define DOCON 1
13: #define DOVAR 2
14: #define DOUSER 3
1.8 anton 15: #define DODEFER 4
16: #define DODOES 5
17: #define DOESJUMP 6
1.6 benschop 18:
1.1 anton 19: #include "machine.h"
20:
21: /* Forth data types */
22: typedef int Bool;
23: #define FLAG(b) (-(b))
1.5 pazsan 24: #define FILEIO(error) (FLAG(error) & -37)
25: #define FILEEXIST(error) (FLAG(error) & -38)
1.1 anton 26:
27: #define F_TRUE (FLAG(0==0))
28: #define F_FALSE (FLAG(0!=0))
29:
30: typedef unsigned char Char;
31: typedef double Float;
32: typedef char *Address;
33:
34: #ifdef DIRECT_THREADED
35: typedef Label Xt;
36: #else
37: typedef Label *Xt;
38: #endif
39:
1.4 anton 40: Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp);
1.1 anton 41:
42: #ifndef DIRECT_THREADED
43: /* i.e. indirect threaded */
44: /* the direct threaded version is machine dependent and resides in machine.h */
45:
46: /* PFA gives the parameter field address corresponding to a cfa */
47: #define PFA(cfa) (((Cell *)cfa)+2)
48: /* PFA1 is a special version for use just after a NEXT1 */
49: #define PFA1(cfa) PFA(cfa)
50: /* CODE_ADDRESS is the address of the code jumped to through the code field */
51: #define CODE_ADDRESS(cfa) (*(Label *)(cfa))
52: /* DOES_CODE is the Forth code does jumps to */
53: #define DOES_CODE(cfa) (cfa[1])
54: #define DOES_CODE1(cfa) DOES_CODE(cfa)
55: /* MAKE_CF creates an appropriate code field at the cfa;
56: ca is the code address */
57: #define MAKE_CF(cfa,ca) ((*(Label *)(cfa)) = ((Label)ca))
58: /* make a code field for a defining-word-defined word */
1.2 pazsan 59: #define MAKE_DOES_CF(cfa,does_code) ({MAKE_CF(cfa,symbols[DODOES]); \
1.1 anton 60: ((Cell *)cfa)[1] = (Cell)does_code;})
61: /* the does handler resides between DOES> and the following Forth code */
62: #define DOES_HANDLER_SIZE 8
63: #define MAKE_DOES_HANDLER(addr) 0 /* do nothing */
64: #endif
65:
66: #ifdef DEBUG
1.10 pazsan 67: # define NAME(string) fprintf(stderr,"%08x: "string"\n",(int)ip);
1.1 anton 68: #else
69: # define NAME(string)
70: #endif
1.2 pazsan 71:
72: #define CF(const) (-const-2)
73:
74: #define CF_NIL -1
1.3 pazsan 75:
76: #ifndef CACHE_FLUSH
77: # define CACHE_FLUSH(addr,size)
78: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>