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

Diff of /stack/stack.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by teddy, Thu Mar 7 03:28:29 2002 UTC revision 1.21 by teddy, Sat Mar 30 02:31:24 2002 UTC
# Line 24  Line 24 
24    
25  /* First, define some types. */  /* First, define some types. */
26    
27    struct cons_struct;
28    struct symbol_struct;
29    
30  /* A value of some type */  /* A value of some type */
31  typedef struct {  typedef struct {
32    enum {    enum {
33        empty,                      /* The empty list */
34      integer,      integer,
35        tfloat,
36      string,      string,
37      func,                       /* Function pointer */      func,                       /* Function pointer */
38      symb,      symb,                       /* Symbol */
39      list      tcons,                      /* A pair of two values */
40    } type:3;                     /* Type of stack element */      port                        /* An I/O port */
41      } type:4;                     /* Type of stack element */
42    
43    int gc_garb:1;    union {
44        struct {
45          unsigned int mark:1;      /* Used internally in the GC */
46          unsigned int protect:1;   /* Protect from GC */
47        } flag;
48        unsigned int no_gc:2;       /* Both flags as one integer */
49      } gc;                         /* Garbage collector stuff */
50    
51    union {    union {
52      void *ptr;                  /* Pointer to the content */      void *ptr;                  /* Pointer to the content */
53      int val;                    /* ...or an integer */      struct cons_struct *c;      /* ...or a pointer to a cons cell */
54        struct symbol_struct *sym;  /* ...or a pointer to a symbol */
55        FILE *p;                    /* ...or an I/O stream */
56        int i;                      /* ...or an integer */
57        float f;                    /* ...or a floating point number */
58    } content;                    /* Stores a pointer or an integer */    } content;                    /* Stores a pointer or an integer */
59    
60  } value;  } value;
61    
62    /* An item (value) on a stack */
63    typedef struct stackitem_struct
64    {
65      value *item;                 /* The value on the stack */
66                                   /* (This is never NULL) */
67      struct stackitem_struct *next; /* Next item */
68    } stackitem;
69    
70    typedef struct cons_struct {    /* A pair of two values */
71      value *car;
72      value *cdr;
73    } pair;
74    
75  /* A symbol with a name and possible value */  /* A symbol with a name and possible value */
76  /* (These do not need reference counters, they are kept unique by  /* (These do not need reference counters, they are kept unique by
77     hashing.) */     hashing.) */
# Line 55  typedef struct symbol_struct { Line 84  typedef struct symbol_struct {
84  /* A type for a hash table for symbols */  /* A type for a hash table for symbols */
85  typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */  typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */
86    
 /* An item (value) on a stack */  
 typedef struct stackitem_struct  
 {  
   value *item;                  /* The value on the stack */  
                                 /* (This is never NULL) */  
   struct stackitem_struct *next; /* Next item */  
 } stackitem;  
   
87  /* An environment; gives access to the stack and a hash table of  /* An environment; gives access to the stack and a hash table of
88     defined symbols */     defined symbols */
89  typedef struct {  typedef struct {
90    stackitem *gc_ref;    value *head;                  /* Head of the stack */
   stackitem *gc_protect;  
   int gc_limit, gc_count;  
   
   stackitem *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 */
# Line 78  typedef struct { Line 95  typedef struct {
95                                     read from in_string */                                     read from in_string */
96    FILE *inputstream;            /* stdin or a file, most likely */    FILE *inputstream;            /* stdin or a file, most likely */
97    int interactive;              /* print prompts, stack, etc */    int interactive;              /* print prompts, stack, etc */
98    
99      /* Garbage Collector stuff*/
100      stackitem *gc_ref;            /* Stack of all allocated values */
101      int gc_limit;                 /* Run GC when this much is allocated */
102      int gc_count;                 /* Amount currently allocated */
103  } environment;  } environment;
104    
105  /* A type for pointers to external functions */  /* A type for pointers to external functions */
# Line 90  extern void toss(environment*); Line 112  extern void toss(environment*);
112  symbol **hash(hashtbl, const char*);  symbol **hash(hashtbl, const char*);
113  value* new_val(environment*);  value* new_val(environment*);
114  void gc_mark(value*);  void gc_mark(value*);
115    void gc_maybe(environment*);
116  extern void gc_init(environment*);  extern void gc_init(environment*);
117    void protect(value*);
118    void unprotect(value*);
119  void push_val(environment*, value*);  void push_val(environment*, value*);
120  void push_int(environment*, int);  void push_int(environment*, int);
121    void push_float(environment*, float);
122  void push_cstring(environment*, const char*);  void push_cstring(environment*, const char*);
123  char *mangle_str(const char*);  char *mangle_str(const char*);
124  extern void mangle(environment*);  extern void mangle(environment*);
125  void push_sym(environment*, const char*);  void push_sym(environment*, const char*);
126  extern void nl();  extern void nl(environment*);
127    extern void nlport(environment*);
128  extern void type(environment*);  extern void type(environment*);
129  void print_h(stackitem*, int);  void print_val(environment *, value*, int, stackitem*, FILE*);
130  extern void print_(environment*);  extern void print_(environment*);
131  extern void print(environment*);  extern void print(environment*);
132  extern void princ_(environment*);  extern void princ_(environment*);
133  extern void princ(environment*);  extern void princ(environment*);
134  void print_st(stackitem*, long);  extern void printport_(environment*);
135    extern void printport(environment*);
136    extern void princport_(environment*);
137    extern void princport(environment*);
138    void print_st(environment*, value*, long);
139  extern void printstack(environment*);  extern void printstack(environment*);
140  extern void swap(environment*);  extern void swap(environment*);
141  extern void rot(environment*);  extern void rot(environment*);
# Line 126  extern void errn(environment*); Line 157  extern void errn(environment*);
157  extern void sx_2b(environment*);  extern void sx_2b(environment*);
158  extern void sx_2d(environment*);  extern void sx_2d(environment*);
159  extern void sx_3e(environment*);  extern void sx_3e(environment*);
160    extern void sx_3c(environment*);
161    extern void sx_3c3d(environment*);
162    extern void sx_3e3d(environment*);
163  value *copy_val(environment*, value*);  value *copy_val(environment*, value*);
164  extern void sx_647570(environment*);  extern void sx_647570(environment*);
165  extern void sx_6966(environment*);  extern void sx_6966(environment*);
166  extern void ifelse(environment*);  extern void ifelse(environment*);
167    extern void sx_656c7365(environment*);
168    extern void then(environment*);
169  extern void sx_7768696c65(environment*);  extern void sx_7768696c65(environment*);
170  extern void sx_666f72(environment*);  extern void sx_666f72(environment*);
171    extern void foreach(environment*);
172  extern void to(environment*);  extern void to(environment*);
173  extern void readline(environment*);  extern void readline(environment*);
174    extern void readlineport(environment*);
175    void readlinestream(environment*, FILE*);
176  extern void sx_72656164(environment*);  extern void sx_72656164(environment*);
177  extern void foreach(environment*);  extern void readport(environment*);
178  void protect(environment*, value*);  void readstream(environment*, FILE*);
179  void unprotect(environment*);  extern void beep(environment*);
180  extern void copying(environment *env);  extern void sx_77616974(environment*);
181  extern void warranty(environment *env);  extern void copying(environment*);
182    extern void warranty(environment*);
183    extern void sx_2a(environment*);
184    extern void sx_2f(environment*);
185    extern void mod(environment*);
186    extern void sx_646976(environment*);
187    extern void setcar(environment*);
188    extern void setcdr(environment*);
189    extern void car(environment*);
190    extern void cdr(environment*);
191    extern void cons(environment*);
192    extern void assq(environment*);
193    void assocgen(environment*, funcp);
194    extern void sx_646f(environment *);
195    extern void sx_6f70656e(environment*);
196    extern void sx_636c6f7365(environment*);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.21

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26