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

Diff of /stack/stack.h

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

revision 1.1 by teddy, Sat Feb 16 00:51:32 2002 UTC revision 1.4 by teddy, Thu Mar 7 03:28:29 2002 UTC
# Line 1  Line 1 
1    /*
2        stack - an interactive interpreter for a stack-based language
3        Copyright (C) 2002  Mats Alritzson and Teddy Hogeborn
4    
5        This program is free software; you can redistribute it and/or modify
6        it under the terms of the GNU General Public License as published by
7        the Free Software Foundation; either version 2 of the License, or
8        (at your option) any later version.
9    
10        This program is distributed in the hope that it will be useful,
11        but WITHOUT ANY WARRANTY; without even the implied warranty of
12        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13        GNU General Public License for more details.
14    
15        You should have received a copy of the GNU General Public License
16        along with this program; if not, write to the Free Software
17        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18    
19        Authors: Mats Alritzson <masse@fukt.bth.se>
20                 Teddy Hogeborn <teddy@fukt.bth.se>
21    */
22    
23  #define HASHTBLSIZE 2048  #define HASHTBLSIZE 2048
24    
# Line 11  typedef struct { Line 32  typedef struct {
32      func,                       /* Function pointer */      func,                       /* Function pointer */
33      symb,      symb,
34      list      list
35    } type;                       /* Type of stack element */    } type:3;                     /* Type of stack element */
36    
37      int gc_garb:1;
38    
39    union {    union {
40      void *ptr;                  /* Pointer to the content */      void *ptr;                  /* Pointer to the content */
41      int val;                    /* ...or an integer */      int val;                    /* ...or an integer */
42    } content;                    /* Stores a pointer or an integer */    } content;                    /* Stores a pointer or an integer */
43    
   int gc_garb;  
   
44  } value;  } value;
45    
46  /* A symbol with a name and possible value */  /* A symbol with a name and possible value */
# Line 46  typedef struct stackitem_struct Line 67  typedef struct stackitem_struct
67     defined symbols */     defined symbols */
68  typedef struct {  typedef struct {
69    stackitem *gc_ref;    stackitem *gc_ref;
70      stackitem *gc_protect;
71    int gc_limit, gc_count;    int gc_limit, gc_count;
72    
73    stackitem *head;              /* Head of the stack */    stackitem *head;              /* Head of the stack */
# Line 53  typedef struct { Line 75  typedef struct {
75    int err;                      /* Error flag */    int err;                      /* Error flag */
76    char *in_string;              /* Input pending to be read */    char *in_string;              /* Input pending to be read */
77    char *free_string;            /* Free this string when all input is    char *free_string;            /* Free this string when all input is
78                                     read from in_string */                                     read from in_string */
79    FILE *inputstream;            /* stdin or a file, most likely */    FILE *inputstream;            /* stdin or a file, most likely */
80    int interactive;              /* print prompts, stack, etc */    int interactive;              /* print prompts, stack, etc */
81  } environment;  } environment;
82    
83  /* A type for pointers to external functions */  /* A type for pointers to external functions */
84  typedef void (*funcp)(environment *); /* funcp is a pointer to a void  typedef void (*funcp)(environment*); /* funcp is a pointer to a void
85                                           function (environment *) */                                           function (environment *) */
86    
87  void init_env(environment *env);  void init_env(environment*);
88  void printerr(const char* in_string);  void printerr(const char*);
89  extern void toss(environment *env);  extern void toss(environment*);
90  symbol **hash(hashtbl in_hashtbl, const char *in_string);  symbol **hash(hashtbl, const char*);
91  value* new_val(environment *env);  value* new_val(environment*);
92  void gc_mark(value *val);  void gc_mark(value*);
93  extern void gc_init(environment *env);  extern void gc_init(environment*);
94  void push_val(environment *env, value *val);  void push_val(environment*, value*);
95  void push_int(environment *env, int in_val);  void push_int(environment*, int);
96  void push_cstring(environment *env, const char *in_string);  void push_cstring(environment*, const char*);
97  char *mangle_str(const char *old_string);  char *mangle_str(const char*);
98  extern void mangle(environment *env);  extern void mangle(environment*);
99  void push_sym(environment *env, const char *in_string);  void push_sym(environment*, const char*);
100  extern void nl();  extern void nl();
101  extern void type(environment *env);  extern void type(environment*);
102  void print_h(stackitem *stack_head, int noquote);  void print_h(stackitem*, int);
103  extern void print_(environment *env);  extern void print_(environment*);
104  extern void print(environment *env);  extern void print(environment*);
105  extern void princ_(environment *env);  extern void princ_(environment*);
106  extern void princ(environment *env);  extern void princ(environment*);
107  void print_st(stackitem *stack_head, long counter);  void print_st(stackitem*, long);
108  extern void printstack(environment *env);  extern void printstack(environment*);
109  extern void swap(environment *env);  extern void swap(environment*);
110  extern void rot(environment *env);  extern void rot(environment*);
111  extern void rcl(environment *env);  extern void rcl(environment*);
112  extern void eval(environment *env);  extern void eval(environment*);
113  extern void rev(environment *env);  extern void rev(environment*);
114  extern void pack(environment *env);  extern void pack(environment*);
115  extern void expand(environment *env);  extern void expand(environment*);
116  extern void eq(environment *env);  extern void eq(environment*);
117  extern void not(environment *env);  extern void not(environment*);
118  extern void neq(environment *env);  extern void neq(environment*);
119  extern void def(environment *env);  extern void def(environment*);
120  extern void quit(environment *env);  extern void quit(environment*);
121  extern void clear(environment *env);  extern void clear(environment*);
122  extern void words(environment *env);  extern void words(environment*);
123  void forget_sym(symbol **hash_entry);  void forget_sym(symbol**);
124  extern void forget(environment *env);  extern void forget(environment*);
125  extern void errn(environment *env);  extern void errn(environment*);
126  extern void sx_2b(environment *env);  extern void sx_2b(environment*);
127  extern void sx_2d(environment *env);  extern void sx_2d(environment*);
128  extern void sx_3e(environment *env);  extern void sx_3e(environment*);
129  value *copy_val(environment *env, value *old_value);  value *copy_val(environment*, value*);
130  extern void sx_647570(environment *env);  extern void sx_647570(environment*);
131  extern void sx_6966(environment *env);  extern void sx_6966(environment*);
132  extern void ifelse(environment *env);  extern void ifelse(environment*);
133  extern void sx_7768696c65(environment *env);  extern void sx_7768696c65(environment*);
134  extern void sx_666f72(environment *env);  extern void sx_666f72(environment*);
135  extern void to(environment *env);  extern void to(environment*);
136  extern void readline(environment *env);  extern void readline(environment*);
137  extern void sx_72656164(environment *env);  extern void sx_72656164(environment*);
138    extern void foreach(environment*);
139    void protect(environment*, value*);
140    void unprotect(environment*);
141    extern void copying(environment *env);
142    extern void warranty(environment *env);

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

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26