implement missing pic_ref definition
This commit is contained in:
		
							parent
							
								
									4a7a32829d
								
							
						
					
					
						commit
						3fb407329f
					
				|  | @ -1,4 +1,5 @@ | |||
| #include <stdio.h> | ||||
| #include <assert.h> | ||||
| 
 | ||||
| #include "picrin.h" | ||||
| #include "picrin/pair.h" | ||||
|  | @ -950,6 +951,21 @@ pic_define(pic_state *pic, const char *name, pic_value val) | |||
|   pic_export(pic, pic_intern_cstr(pic, name)); | ||||
| } | ||||
| 
 | ||||
| pic_value | ||||
| pic_ref(pic_state *pic, const char *name) | ||||
| { | ||||
|   struct xh_entry *e; | ||||
| 
 | ||||
|   if (! (e = xh_get(pic->lib->senv->tbl, name))) { | ||||
|     pic_error(pic, "symbol not defined"); | ||||
|   } | ||||
|   assert(e->val >= 0); | ||||
|   if (! (e = xh_get(pic->global_tbl, pic_symbol_name(pic, (pic_sym)e->val)))) { | ||||
|     pic_abort(pic, "logic flaw"); | ||||
|   } | ||||
|   return pic->globals[e->val]; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| print_code(pic_state *pic, struct pic_code c) | ||||
| { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Yuichi Nishiwaki
						Yuichi Nishiwaki