25 |
/* First, define some types. */ |
/* First, define some types. */ |
26 |
|
|
27 |
struct cons_struct; |
struct cons_struct; |
28 |
|
struct symbol_struct; |
29 |
|
|
30 |
/* A value of some type */ |
/* A value of some type */ |
31 |
typedef struct { |
typedef struct { |
34 |
tfloat, |
tfloat, |
35 |
string, |
string, |
36 |
func, /* Function pointer */ |
func, /* Function pointer */ |
37 |
symb, |
symb, /* Symbol */ |
38 |
tcons |
tcons /* A pair of two values */ |
39 |
} type:4; /* Type of stack element */ |
} type:4; /* Type of stack element */ |
40 |
|
|
41 |
union { |
union { |
42 |
struct { |
struct { |
43 |
unsigned int mark:1; |
unsigned int mark:1; /* Used internally in the GC */ |
44 |
unsigned int protect:1; |
unsigned int protect:1; /* Protect from GC */ |
45 |
} flag; |
} flag; |
46 |
unsigned int no_gc:2; |
unsigned int no_gc:2; /* Both flags as one integer */ |
47 |
} gc; |
} gc; /* Garbage collector stuff */ |
48 |
|
|
49 |
union { |
union { |
|
struct cons_struct *c; |
|
50 |
void *ptr; /* Pointer to the content */ |
void *ptr; /* Pointer to the content */ |
51 |
|
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
52 |
|
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
53 |
int i; /* ...or an integer */ |
int i; /* ...or an integer */ |
54 |
float f; |
float f; /* ...or a floating point number */ |
55 |
} content; /* Stores a pointer or an integer */ |
} content; /* Stores a pointer or an integer */ |
56 |
|
|
57 |
} value; |
} value; |
64 |
struct stackitem_struct *next; /* Next item */ |
struct stackitem_struct *next; /* Next item */ |
65 |
} stackitem; |
} stackitem; |
66 |
|
|
67 |
typedef struct cons_struct { |
typedef struct cons_struct { /* A pair of two values */ |
68 |
value *car; |
value *car; |
69 |
value *cdr; |
value *cdr; |
70 |
} cons; |
} cons; |
87 |
stackitem *gc_ref; |
stackitem *gc_ref; |
88 |
int gc_limit, gc_count; |
int gc_limit, gc_count; |
89 |
|
|
90 |
cons *head; /* Head of the stack */ |
value *head; /* Head of the stack */ |
91 |
hashtbl symbols; /* Hash table of all variable bindings */ |
hashtbl symbols; /* Hash table of all variable bindings */ |
92 |
int err; /* Error flag */ |
int err; /* Error flag */ |
93 |
char *in_string; /* Input pending to be read */ |
char *in_string; /* Input pending to be read */ |
118 |
void push_sym(environment*, const char*); |
void push_sym(environment*, const char*); |
119 |
extern void nl(); |
extern void nl(); |
120 |
extern void type(environment*); |
extern void type(environment*); |
121 |
void print_h(cons*, int); |
void print_h(value*, int); |
122 |
extern void print_(environment*); |
extern void print_(environment*); |
123 |
extern void print(environment*); |
extern void print(environment*); |
124 |
extern void princ_(environment*); |
extern void princ_(environment*); |
125 |
extern void princ(environment*); |
extern void princ(environment*); |
126 |
void print_st(cons*, long); |
void print_st(value*, long); |
127 |
extern void printstack(environment*); |
extern void printstack(environment*); |
128 |
extern void swap(environment*); |
extern void swap(environment*); |
129 |
extern void rot(environment*); |
extern void rot(environment*); |