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

Diff of /stack/stack.h

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

revision 1.18 by teddy, Wed Mar 20 17:19:46 2002 UTC revision 1.28 by masse, Mon Aug 18 14:39:16 2003 UTC
# Line 22  Line 22 
22    
23  #define HASHTBLSIZE 2048  #define HASHTBLSIZE 2048
24    
25    #define CAR(X) ((X)->content.c->car)
26    #define CDR(X) ((X)->content.c->cdr)
27    
28    /* printf, sscanf, fgets, fprintf, fopen, perror */
29    #include <stdio.h>
30    /* exit, EXIT_SUCCESS, malloc, free */
31    #include <stdlib.h>
32    /* NULL */
33    #include <stddef.h>
34    /* dlopen, dlsym, dlerror */
35    #include <dlfcn.h>
36    /* strcmp, strcpy, strlen, strcat, strdup */
37    #include <string.h>
38    /* getopt, STDIN_FILENO, STDOUT_FILENO, usleep */
39    #include <unistd.h>
40    /* EX_NOINPUT, EX_USAGE */
41    #include <sysexits.h>
42    /* assert */
43    #include <assert.h>
44    /* waitpid */
45    #include <sys/wait.h>
46    /* va_list, va_start, va_arg, va_end */
47    #include <stdarg.h>
48    /* time */
49    #include <time.h>
50    
51    #ifdef __linux__
52    /* mtrace, muntrace */
53    #include <mcheck.h>
54    /* ioctl */
55    #include <sys/ioctl.h>
56    /* KDMKTONE */
57    #include <linux/kd.h>
58    #endif /* __linux__ */
59    
60    
61    
62  /* First, define some types. */  /* First, define some types. */
63    
64  struct cons_struct;  struct cons_struct;
65  struct symbol_struct;  struct symbol_struct;
66    struct environment_struct;
67    
68    /* A type for pointers to external functions */
69    typedef void (*funcp)(struct environment_struct*);
70    /* funcp is a pointer to a void function (environment *) */
71    
72    enum type_enum {
73      unknown,
74      empty,                        /* The empty list */
75      integer,
76      tfloat,
77      string,
78      func,                 /* Function pointer */
79      symb,                 /* Symbol */
80      tcons,                        /* A pair of two values */
81      port                  /* An I/O port */
82    };                      /* Type of stack element */
83    
84    
85  /* A value of some type */  /* A value of some type */
86  typedef struct {  typedef struct {
87    enum {    enum type_enum type:4;
     empty,                      /* The empty list */  
     integer,  
     tfloat,  
     string,  
     func,                       /* Function pointer */  
     symb,                       /* Symbol */  
     tcons                       /* A pair of two values */  
   } type:4;                     /* Type of stack element */  
88    
89    union {    union {
90      struct {      struct {
# Line 51  typedef struct { Line 98  typedef struct {
98      void *ptr;                  /* Pointer to the content */      void *ptr;                  /* Pointer to the content */
99      struct cons_struct *c;      /* ...or a pointer to a cons cell */      struct cons_struct *c;      /* ...or a pointer to a cons cell */
100      struct symbol_struct *sym;  /* ...or a pointer to a symbol */      struct symbol_struct *sym;  /* ...or a pointer to a symbol */
101        FILE *p;                    /* ...or an I/O stream */
102      int i;                      /* ...or an integer */      int i;                      /* ...or an integer */
103      float f;                    /* ...or a floating point number */      float f;                    /* ...or a floating point number */
104        funcp func;                 /* ...or a function pointer */
105        char *string;               /* ...or a string */
106    } content;                    /* Stores a pointer or an integer */    } content;                    /* Stores a pointer or an integer */
107    
108  } value;  } value;
# Line 88  typedef struct { Line 138  typedef struct {
138    value *head;                  /* Head of the stack */    value *head;                  /* Head of the stack */
139    hashtbl symbols;              /* Hash table of all variable bindings */    hashtbl symbols;              /* Hash table of all variable bindings */
140    int err;                      /* Error flag */    int err;                      /* Error flag */
141      char *errsymb;
142    char *in_string;              /* Input pending to be read */    char *in_string;              /* Input pending to be read */
143    char *free_string;            /* Free this string when all input is    char *free_string;            /* Free this string when all input is
144                                     read from in_string */                                     read from in_string */
# Line 100  typedef struct { Line 151  typedef struct {
151    int gc_count;                 /* Amount currently allocated */    int gc_count;                 /* Amount currently allocated */
152  } environment;  } environment;
153    
 /* A type for pointers to external functions */  
 typedef void (*funcp)(environment*); /* funcp is a pointer to a void  
                                          function (environment *) */  
154    
155  void init_env(environment*);  void init_env(environment*);
156  void printerr(const char*);  void printerr(environment*);
157  extern void toss(environment*);  extern void toss(environment*);
158  symbol **hash(hashtbl, const char*);  symbol **hash(hashtbl, const char*);
159  value* new_val(environment*);  value* new_val(environment*);
# Line 121  void push_cstring(environment*, const ch Line 169  void push_cstring(environment*, const ch
169  char *mangle_str(const char*);  char *mangle_str(const char*);
170  extern void mangle(environment*);  extern void mangle(environment*);
171  void push_sym(environment*, const char*);  void push_sym(environment*, const char*);
172  extern void nl();  extern void nl(environment*);
173    extern void nlport(environment*);
174  extern void type(environment*);  extern void type(environment*);
175  void print_val(value*, int, stackitem*);  void print_val(environment *, value*, int, stackitem*, FILE*);
176  extern void print_(environment*);  extern void print_(environment*);
177  extern void print(environment*);  extern void print(environment*);
178  extern void princ_(environment*);  extern void princ_(environment*);
179  extern void princ(environment*);  extern void princ(environment*);
180  void print_st(value*, long);  extern void printport_(environment*);
181    extern void printport(environment*);
182    extern void princport_(environment*);
183    extern void princport(environment*);
184    void print_st(environment*, value*, long);
185  extern void printstack(environment*);  extern void printstack(environment*);
186  extern void swap(environment*);  extern void swap(environment*);
187  extern void rot(environment*);  extern void rot(environment*);
# Line 164  extern void sx_666f72(environment*); Line 217  extern void sx_666f72(environment*);
217  extern void foreach(environment*);  extern void foreach(environment*);
218  extern void to(environment*);  extern void to(environment*);
219  extern void readline(environment*);  extern void readline(environment*);
220    extern void readlineport(environment*);
221    void readlinestream(environment*, FILE*);
222  extern void sx_72656164(environment*);  extern void sx_72656164(environment*);
223    extern void readport(environment*);
224    void readstream(environment*, FILE*);
225  extern void beep(environment*);  extern void beep(environment*);
226  extern void sx_77616974(environment*);  extern void sx_77616974(environment*);
227  extern void copying(environment*);  extern void copying(environment*);
# Line 179  extern void car(environment*); Line 236  extern void car(environment*);
236  extern void cdr(environment*);  extern void cdr(environment*);
237  extern void cons(environment*);  extern void cons(environment*);
238  extern void assq(environment*);  extern void assq(environment*);
239    void assocgen(environment*, funcp);
240    extern void sx_646f(environment *);
241    extern void sx_6f70656e(environment*);
242    extern void sx_636c6f7365(environment*);
243    int check_args(environment*, int, ...);

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.28

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26