From 32174d7855e70660e28964944b1d192225483ace Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 17 Jul 2014 16:38:18 +0900 Subject: [PATCH] remove box --- include/picrin/box.h | 28 ---------------------------- include/picrin/value.h | 3 --- src/box.c | 30 ------------------------------ src/codegen.c | 1 - src/gc.c | 8 -------- src/macro.c | 1 - src/write.c | 3 --- 7 files changed, 74 deletions(-) delete mode 100644 include/picrin/box.h delete mode 100644 src/box.c diff --git a/include/picrin/box.h b/include/picrin/box.h deleted file mode 100644 index f9826eed..00000000 --- a/include/picrin/box.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * See Copyright Notice in picrin.h - */ - -#ifndef PICRIN_BOX_H__ -#define PICRIN_BOX_H__ - -#if defined(__cplusplus) -extern "C" { -#endif - -struct pic_box { - PIC_OBJECT_HEADER - pic_value value; -}; - -#define pic_box_p(v) (pic_type(v) == PIC_TT_BOX) -#define pic_box_ptr(v) ((struct pic_box *)pic_ptr(v)) - -pic_value pic_box(pic_state *, pic_value); -pic_value pic_unbox(pic_state *, pic_value); -void pic_set_box(pic_state *, pic_value, pic_value); - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/include/picrin/value.h b/include/picrin/value.h index e8eb7342..283bac28 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -115,7 +115,6 @@ enum pic_tt { PIC_TT_VAR, PIC_TT_IREP, PIC_TT_DATA, - PIC_TT_BOX, PIC_TT_DICT }; @@ -267,8 +266,6 @@ pic_type_repr(enum pic_tt tt) return "irep"; case PIC_TT_DATA: return "data"; - case PIC_TT_BOX: - return "box"; case PIC_TT_DICT: return "dict"; } diff --git a/src/box.c b/src/box.c deleted file mode 100644 index b9948fc7..00000000 --- a/src/box.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "picrin.h" -#include "picrin/box.h" - -pic_value -pic_box(pic_state *pic, pic_value value) -{ - struct pic_box *box; - - box = (struct pic_box *)pic_obj_alloc(pic, sizeof(struct pic_box), PIC_TT_BOX); - box->value = value; - return pic_obj_value(box); -} - -pic_value -pic_unbox(pic_state *pic, pic_value box) -{ - if (! pic_box_p(box)) { - pic_errorf(pic, "expected box, but got ~s", box); - } - return pic_box_ptr(box)->value; -} - -void -pic_set_box(pic_state *pic, pic_value box, pic_value value) -{ - if (! pic_box_p(box)) { - pic_errorf(pic, "expected box, but got ~s", box); - } - pic_box_ptr(box)->value = value; -} diff --git a/src/codegen.c b/src/codegen.c index d098842e..df4c0239 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -830,7 +830,6 @@ analyze_node(analyze_state *state, pic_value obj, bool tailpos) case PIC_TT_VAR: case PIC_TT_IREP: case PIC_TT_DATA: - case PIC_TT_BOX: case PIC_TT_DICT: pic_errorf(pic, "invalid expression given: ~s", obj); } diff --git a/src/gc.c b/src/gc.c index 21aebb9e..aa2d383d 100644 --- a/src/gc.c +++ b/src/gc.c @@ -494,11 +494,6 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) } break; } - case PIC_TT_BOX: { - struct pic_box *box = (struct pic_box *)obj; - gc_mark(pic, box->value); - break; - } case PIC_TT_DICT: { struct pic_dict *dict = (struct pic_dict *)obj; xh_iter it; @@ -656,9 +651,6 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj) xh_destroy(&data->storage); break; } - case PIC_TT_BOX: { - break; - } case PIC_TT_DICT: { struct pic_dict *dict = (struct pic_dict *)obj; xh_destroy(&dict->hash); diff --git a/src/macro.c b/src/macro.c index 49fbe345..636a968e 100644 --- a/src/macro.c +++ b/src/macro.c @@ -524,7 +524,6 @@ macroexpand_node(pic_state *pic, pic_value expr, struct pic_senv *senv) case PIC_TT_VAR: case PIC_TT_IREP: case PIC_TT_DATA: - case PIC_TT_BOX: case PIC_TT_DICT: pic_errorf(pic, "unexpected value type: ~s", expr); } diff --git a/src/write.c b/src/write.c index 9ced3904..61551b1a 100644 --- a/src/write.c +++ b/src/write.c @@ -330,9 +330,6 @@ write_core(struct writer_control *p, pic_value obj) case PIC_TT_DATA: xfprintf(file, "#", pic_ptr(obj)); break; - case PIC_TT_BOX: - xfprintf(file, "#", pic_ptr(obj)); - break; case PIC_TT_DICT: xfprintf(file, "#", pic_ptr(obj)); break;