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

Diff of /stack/stack.h

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

revision 1.8 by masse, Sun Mar 10 09:13:36 2002 UTC revision 1.13 by masse, Tue Mar 12 14:53:19 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 {
# Line 31  typedef struct { Line 34  typedef struct {
34      tfloat,      tfloat,
35      string,      string,
36      func,                       /* Function pointer */      func,                       /* Function pointer */
37      symb,      symb,                       /* Symbol */
38      list      tcons                       /* A pair of two values */
39    } type:4;                     /* Type of stack element */    } type:4;                     /* Type of stack element */
40    
41    int gc_garb:1;    union {
42    int gc_protect:1;      struct {
43          unsigned int mark:1;      /* Used internally in the GC */
44          unsigned int protect:1;   /* Protect from GC */
45        } flag;
46        unsigned int no_gc:2;       /* Both flags as one integer */
47      } gc;                         /* Garbage collector stuff */
48    
49    union {    union {
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;
58    
59    /* An item (value) on a stack */
60    typedef struct stackitem_struct
61    {
62      value *item;                 /* The value on the stack */
63                                   /* (This is never NULL) */
64      struct stackitem_struct *next; /* Next item */
65    } stackitem;
66    
67    typedef struct cons_struct {    /* A pair of two values */
68      value *car;
69      value *cdr;
70    } cons;
71    
72  /* A symbol with a name and possible value */  /* A symbol with a name and possible value */
73  /* (These do not need reference counters, they are kept unique by  /* (These do not need reference counters, they are kept unique by
74     hashing.) */     hashing.) */
# Line 58  typedef struct symbol_struct { Line 81  typedef struct symbol_struct {
81  /* A type for a hash table for symbols */  /* A type for a hash table for symbols */
82  typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */  typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */
83    
 /* 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;  
   
84  /* An environment; gives access to the stack and a hash table of  /* An environment; gives access to the stack and a hash table of
85     defined symbols */     defined symbols */
86  typedef struct {  typedef struct {
87    stackitem *gc_ref;    stackitem *gc_ref;
88    int gc_limit, gc_count;    int gc_limit, gc_count;
89    
90    stackitem *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 */
# Line 103  extern void mangle(environment*); Line 118  extern void mangle(environment*);
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(stackitem*, 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(stackitem*, 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*);

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.13

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26