cleanup
This commit is contained in:
		
							parent
							
								
									b02f81760c
								
							
						
					
					
						commit
						7dbb2c6de4
					
				| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pic_string {
 | 
					struct pic_string {
 | 
				
			||||||
  PIC_OBJECT_HEADER
 | 
					  PIC_OBJECT_HEADER
 | 
				
			||||||
  const char *str;
 | 
					  char *str;
 | 
				
			||||||
  size_t len;
 | 
					  size_t len;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,6 @@ struct sym_tbl {
 | 
				
			||||||
  size_t size;
 | 
					  size_t size;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct sym_tbl * sym_tbl_new();
 | 
					 | 
				
			||||||
pic_value sym_tbl_get(struct sym_tbl *, const char *);
 | 
					pic_value sym_tbl_get(struct sym_tbl *, const char *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								src/state.c
								
								
								
								
							
							
						
						
									
										26
									
								
								src/state.c
								
								
								
								
							| 
						 | 
					@ -17,12 +17,28 @@ new_empty_env()
 | 
				
			||||||
  return env;
 | 
					  return env;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct sym_tbl *
 | 
				
			||||||
 | 
					sym_tbl_new()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  struct sym_tbl *s_tbl;
 | 
				
			||||||
 | 
					  int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  s_tbl = (struct sym_tbl *)malloc(sizeof(struct sym_tbl));
 | 
				
			||||||
 | 
					  s_tbl->size = PIC_SYM_TBL_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0; i < PIC_SYM_TBL_SIZE; ++i) {
 | 
				
			||||||
 | 
					    s_tbl->tbl[i] = pic_nil_value();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return s_tbl;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pic_init_core(pic_state *);
 | 
					void pic_init_core(pic_state *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pic_state *
 | 
					pic_state *
 | 
				
			||||||
pic_open()
 | 
					pic_open()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  pic_state *pic;
 | 
					  pic_state *pic;
 | 
				
			||||||
 | 
					  int ai;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pic = (pic_state *)malloc(sizeof(pic_state));
 | 
					  pic = (pic_state *)malloc(sizeof(pic_state));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,6 +79,11 @@ pic_open()
 | 
				
			||||||
  /* GC arena */
 | 
					  /* GC arena */
 | 
				
			||||||
  pic->arena_idx = 0;
 | 
					  pic->arena_idx = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* global environment */
 | 
				
			||||||
 | 
					  pic->global_env = new_empty_env();
 | 
				
			||||||
 | 
					  pic_init_core(pic);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ai = pic_gc_arena_preserve(pic);
 | 
				
			||||||
  pic->sDEFINE = pic_intern_cstr(pic, "define");
 | 
					  pic->sDEFINE = pic_intern_cstr(pic, "define");
 | 
				
			||||||
  pic->sLAMBDA = pic_intern_cstr(pic, "lambda");
 | 
					  pic->sLAMBDA = pic_intern_cstr(pic, "lambda");
 | 
				
			||||||
  pic->sIF = pic_intern_cstr(pic, "if");
 | 
					  pic->sIF = pic_intern_cstr(pic, "if");
 | 
				
			||||||
| 
						 | 
					@ -76,10 +97,7 @@ pic_open()
 | 
				
			||||||
  pic->sSUB = pic_intern_cstr(pic, "-");
 | 
					  pic->sSUB = pic_intern_cstr(pic, "-");
 | 
				
			||||||
  pic->sMUL = pic_intern_cstr(pic, "*");
 | 
					  pic->sMUL = pic_intern_cstr(pic, "*");
 | 
				
			||||||
  pic->sDIV = pic_intern_cstr(pic, "/");
 | 
					  pic->sDIV = pic_intern_cstr(pic, "/");
 | 
				
			||||||
 | 
					  pic_gc_arena_restore(pic, ai);
 | 
				
			||||||
  /* global environment */
 | 
					 | 
				
			||||||
  pic->global_env = new_empty_env();
 | 
					 | 
				
			||||||
  pic_init_core(pic);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return pic;
 | 
					  return pic;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								src/symbol.c
								
								
								
								
							
							
						
						
									
										15
									
								
								src/symbol.c
								
								
								
								
							| 
						 | 
					@ -17,21 +17,6 @@ str_hash(const char *str)
 | 
				
			||||||
  return hash;
 | 
					  return hash;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct sym_tbl *
 | 
					 | 
				
			||||||
sym_tbl_new()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  struct sym_tbl *s_tbl;
 | 
					 | 
				
			||||||
  int i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  s_tbl = (struct sym_tbl *)malloc(sizeof(struct sym_tbl));
 | 
					 | 
				
			||||||
  s_tbl->size = PIC_SYM_TBL_SIZE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (i = 0; i < PIC_SYM_TBL_SIZE; ++i) {
 | 
					 | 
				
			||||||
    s_tbl->tbl[i] = pic_nil_value();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return s_tbl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pic_value
 | 
					pic_value
 | 
				
			||||||
sym_tbl_get(struct sym_tbl *s_tbl, const char *key)
 | 
					sym_tbl_get(struct sym_tbl *s_tbl, const char *key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue