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

Diff of /stack/stack.c

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

revision 1.80 by teddy, Thu Feb 14 12:20:09 2002 UTC revision 1.82 by masse, Thu Feb 14 19:49:48 2002 UTC
# Line 58  typedef struct { Line 58  typedef struct {
58    stackitem *head;              /* Head of the stack */    stackitem *head;              /* Head of the stack */
59    hashtbl symbols;              /* Hash table of all variable bindings */    hashtbl symbols;              /* Hash table of all variable bindings */
60    int err;                      /* Error flag */    int err;                      /* Error flag */
   int non_eval_flag;  
61    char *in_string;              /* Input pending to be read */    char *in_string;              /* Input pending to be read */
62    char *free_string;            /* Free this string when all input is    char *free_string;            /* Free this string when all input is
63                                     read from in_string */                                     read from in_string */
# Line 75  void init_env(environment *env) Line 74  void init_env(environment *env)
74    
75    env->in_string= NULL;    env->in_string= NULL;
76    env->err= 0;    env->err= 0;
   env->non_eval_flag= 0;  
77    for(i= 0; i<HASHTBLSIZE; i++)    for(i= 0; i<HASHTBLSIZE; i++)
78      env->symbols[i]= NULL;      env->symbols[i]= NULL;
79  }  }
# Line 102  void free_val(value *val){ Line 100  void free_val(value *val){
100          free(item);             /* free the stackitem */          free(item);             /* free the stackitem */
101          item=temp;              /* go to next stackitem */          item=temp;              /* go to next stackitem */
102        }        }
       free(val);                /* Free the actual list value */  
103        break;        break;
104      case integer:      case integer:
105      case func:      case func:
106          break;
107      case symb:      case symb:
108          free(((symbol*)(val->content.ptr))->id);
109          if(((symbol*)(val->content.ptr))->val!=NULL)
110            free_val(((symbol*)(val->content.ptr))->val);
111          free(val->content.ptr);
112        break;        break;
113      }      }
114        free(val);          /* Free the actual list value */
115    }    }
116  }  }
117    
# Line 174  void push_int(environment *env, int in_v Line 177  void push_int(environment *env, int in_v
177        
178    new_value->content.val= in_val;    new_value->content.val= in_val;
179    new_value->type= integer;    new_value->type= integer;
180    new_value->refcount=1;    new_value->refcount= 1;
181    
182    push_val(env, new_value);    push_val(env, new_value);
183  }  }
# Line 187  void push_cstring(environment *env, cons Line 190  void push_cstring(environment *env, cons
190    new_value->content.ptr= malloc(strlen(in_string)+1);    new_value->content.ptr= malloc(strlen(in_string)+1);
191    strcpy(new_value->content.ptr, in_string);    strcpy(new_value->content.ptr, in_string);
192    new_value->type= string;    new_value->type= string;
193    new_value->refcount=1;    new_value->refcount= 1;
194    
195    push_val(env, new_value);    push_val(env, new_value);
196  }  }
# Line 213  char *mangle_str(const char *old_string) Line 216  char *mangle_str(const char *old_string)
216  }  }
217    
218  extern void mangle(environment *env){  extern void mangle(environment *env){
   value *new_value;  
219    char *new_string;    char *new_string;
220    
221    if((env->head)==NULL) {    if((env->head)==NULL) {
# Line 233  extern void mangle(environment *env){ Line 235  extern void mangle(environment *env){
235    toss(env);    toss(env);
236    if(env->err) return;    if(env->err) return;
237    
238    new_value= malloc(sizeof(value));    push_cstring(env, new_string);
   new_value->content.ptr= new_string;  
   new_value->type= string;  
   new_value->refcount=1;  
   
   push_val(env, new_value);  
239  }  }
240    
241  /* Push a symbol onto the stack. */  /* Push a symbol onto the stack. */

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.82

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26