/[cvs]/stack/stack.h
ViewVC logotype

Annotation of /stack/stack.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Thu Mar 7 01:21:07 2002 UTC (22 years, 2 months ago) by masse
Branch: MAIN
Changes since 1.2: +3 -0 lines
File MIME type: text/plain
(protect, unprotect): New functions to protect values from GC.

1 teddy 1.1
2     #define HASHTBLSIZE 2048
3    
4     /* First, define some types. */
5    
6     /* A value of some type */
7     typedef struct {
8     enum {
9     integer,
10     string,
11     func, /* Function pointer */
12     symb,
13     list
14 masse 1.2 } type:3; /* Type of stack element */
15    
16     int gc_garb:1;
17 teddy 1.1
18     union {
19     void *ptr; /* Pointer to the content */
20     int val; /* ...or an integer */
21     } content; /* Stores a pointer or an integer */
22    
23     } value;
24    
25     /* A symbol with a name and possible value */
26     /* (These do not need reference counters, they are kept unique by
27     hashing.) */
28     typedef struct symbol_struct {
29     char *id; /* Symbol name */
30     value *val; /* The value (if any) bound to it */
31     struct symbol_struct *next; /* In case of hashing conflicts, a */
32     } symbol; /* symbol is a kind of stack item. */
33    
34     /* A type for a hash table for symbols */
35     typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */
36    
37     /* An item (value) on a stack */
38     typedef struct stackitem_struct
39     {
40     value *item; /* The value on the stack */
41     /* (This is never NULL) */
42     struct stackitem_struct *next; /* Next item */
43     } stackitem;
44    
45     /* An environment; gives access to the stack and a hash table of
46     defined symbols */
47     typedef struct {
48     stackitem *gc_ref;
49 masse 1.3 stackitem *gc_protect;
50 teddy 1.1 int gc_limit, gc_count;
51    
52     stackitem *head; /* Head of the stack */
53     hashtbl symbols; /* Hash table of all variable bindings */
54     int err; /* Error flag */
55     char *in_string; /* Input pending to be read */
56     char *free_string; /* Free this string when all input is
57     read from in_string */
58     FILE *inputstream; /* stdin or a file, most likely */
59     int interactive; /* print prompts, stack, etc */
60     } environment;
61    
62     /* A type for pointers to external functions */
63 masse 1.2 typedef void (*funcp)(environment*); /* funcp is a pointer to a void
64 teddy 1.1 function (environment *) */
65    
66 masse 1.2 void init_env(environment*);
67     void printerr(const char*);
68     extern void toss(environment*);
69     symbol **hash(hashtbl, const char*);
70     value* new_val(environment*);
71     void gc_mark(value*);
72     extern void gc_init(environment*);
73     void push_val(environment*, value*);
74     void push_int(environment*, int);
75     void push_cstring(environment*, const char*);
76     char *mangle_str(const char*);
77     extern void mangle(environment*);
78     void push_sym(environment*, const char*);
79 teddy 1.1 extern void nl();
80 masse 1.2 extern void type(environment*);
81     void print_h(stackitem*, int);
82     extern void print_(environment*);
83     extern void print(environment*);
84     extern void princ_(environment*);
85     extern void princ(environment*);
86     void print_st(stackitem*, long);
87     extern void printstack(environment*);
88     extern void swap(environment*);
89     extern void rot(environment*);
90     extern void rcl(environment*);
91     extern void eval(environment*);
92     extern void rev(environment*);
93     extern void pack(environment*);
94     extern void expand(environment*);
95     extern void eq(environment*);
96     extern void not(environment*);
97     extern void neq(environment*);
98     extern void def(environment*);
99     extern void quit(environment*);
100     extern void clear(environment*);
101     extern void words(environment*);
102     void forget_sym(symbol**);
103     extern void forget(environment*);
104     extern void errn(environment*);
105     extern void sx_2b(environment*);
106     extern void sx_2d(environment*);
107     extern void sx_3e(environment*);
108     value *copy_val(environment*, value*);
109     extern void sx_647570(environment*);
110     extern void sx_6966(environment*);
111     extern void ifelse(environment*);
112     extern void sx_7768696c65(environment*);
113     extern void sx_666f72(environment*);
114     extern void to(environment*);
115     extern void readline(environment*);
116     extern void sx_72656164(environment*);
117     extern void foreach(environment*);
118 masse 1.3 void protect(environment*, value*);
119     void unprotect(environment*);

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26