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

Annotation of /stack/stack.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sun Feb 17 04:03:57 2002 UTC (22 years, 2 months ago) by masse
Branch: MAIN
Changes since 1.1: +55 -54 lines
File MIME type: text/plain
(new_val, gc_init, main) GC bugfix/trimming.
(sx_666f72 "for") Changed name to "foreach".
(sx_666f72) New function.
(eval) "(*func)()" is equal to "func()".
(value) Data structure optimation.
(stack.h) Removed variable names from prototypes.

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     int gc_limit, gc_count;
50    
51     stackitem *head; /* Head of the stack */
52     hashtbl symbols; /* Hash table of all variable bindings */
53     int err; /* Error flag */
54     char *in_string; /* Input pending to be read */
55     char *free_string; /* Free this string when all input is
56     read from in_string */
57     FILE *inputstream; /* stdin or a file, most likely */
58     int interactive; /* print prompts, stack, etc */
59     } environment;
60    
61     /* A type for pointers to external functions */
62 masse 1.2 typedef void (*funcp)(environment*); /* funcp is a pointer to a void
63 teddy 1.1 function (environment *) */
64    
65 masse 1.2 void init_env(environment*);
66     void printerr(const char*);
67     extern void toss(environment*);
68     symbol **hash(hashtbl, const char*);
69     value* new_val(environment*);
70     void gc_mark(value*);
71     extern void gc_init(environment*);
72     void push_val(environment*, value*);
73     void push_int(environment*, int);
74     void push_cstring(environment*, const char*);
75     char *mangle_str(const char*);
76     extern void mangle(environment*);
77     void push_sym(environment*, const char*);
78 teddy 1.1 extern void nl();
79 masse 1.2 extern void type(environment*);
80     void print_h(stackitem*, int);
81     extern void print_(environment*);
82     extern void print(environment*);
83     extern void princ_(environment*);
84     extern void princ(environment*);
85     void print_st(stackitem*, long);
86     extern void printstack(environment*);
87     extern void swap(environment*);
88     extern void rot(environment*);
89     extern void rcl(environment*);
90     extern void eval(environment*);
91     extern void rev(environment*);
92     extern void pack(environment*);
93     extern void expand(environment*);
94     extern void eq(environment*);
95     extern void not(environment*);
96     extern void neq(environment*);
97     extern void def(environment*);
98     extern void quit(environment*);
99     extern void clear(environment*);
100     extern void words(environment*);
101     void forget_sym(symbol**);
102     extern void forget(environment*);
103     extern void errn(environment*);
104     extern void sx_2b(environment*);
105     extern void sx_2d(environment*);
106     extern void sx_3e(environment*);
107     value *copy_val(environment*, value*);
108     extern void sx_647570(environment*);
109     extern void sx_6966(environment*);
110     extern void ifelse(environment*);
111     extern void sx_7768696c65(environment*);
112     extern void sx_666f72(environment*);
113     extern void to(environment*);
114     extern void readline(environment*);
115     extern void sx_72656164(environment*);
116     extern void foreach(environment*);

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26