From 18b873f72350f9ba3dae733287fd0505b8b10103 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 19 Feb 2016 00:56:56 +0900 Subject: [PATCH] remove proc.h --- contrib/10.callcc/callcc.c | 4 +-- contrib/40.srfi/src/106.c | 2 +- extlib/benz/debug.c | 1 + extlib/benz/error.c | 1 + extlib/benz/include/picrin.h | 1 - extlib/benz/include/picrin/object.h | 42 ++++++++++++++++++++++ extlib/benz/include/picrin/proc.h | 54 ----------------------------- extlib/benz/macro.c | 1 + 8 files changed, 48 insertions(+), 58 deletions(-) delete mode 100644 extlib/benz/include/picrin/proc.h diff --git a/contrib/10.callcc/callcc.c b/contrib/10.callcc/callcc.c index 4388e8bb..68cbd4d9 100644 --- a/contrib/10.callcc/callcc.c +++ b/contrib/10.callcc/callcc.c @@ -276,8 +276,8 @@ pic_callcc_callcc(pic_state *pic) } } -#define pic_redefun(pic, lib, name, func) \ - pic_set(pic, lib, name, pic_obj_value(pic_make_proc(pic, func, 0, NULL))) +#define pic_redefun(pic, lib, name, func) \ + pic_set(pic, lib, name, pic_obj_value(pic_lambda(pic, func, 0))) void pic_init_callcc(pic_state *pic) diff --git a/contrib/40.srfi/src/106.c b/contrib/40.srfi/src/106.c index ee26620e..e8029bc6 100644 --- a/contrib/40.srfi/src/106.c +++ b/contrib/40.srfi/src/106.c @@ -392,7 +392,7 @@ pic_init_srfi_106(pic_state *pic) { pic_deflibrary(pic, "srfi.106"); -#define pic_defun_(pic, name, f) pic_define(pic, "srfi.106", name, pic_obj_value(pic_make_proc(pic, f, 0, NULL))) +#define pic_defun_(pic, name, f) pic_define(pic, "srfi.106", name, pic_obj_value(pic_lambda(pic, f, 0))) #define pic_define_(pic, name, v) pic_define(pic, "srfi.106", name, v) pic_defun_(pic, "socket?", pic_socket_socket_p); diff --git a/extlib/benz/debug.c b/extlib/benz/debug.c index 7bde1990..c9c8c2af 100644 --- a/extlib/benz/debug.c +++ b/extlib/benz/debug.c @@ -3,6 +3,7 @@ */ #include "picrin.h" +#include "picrin/object.h" struct pic_string * pic_get_backtrace(pic_state *pic) diff --git a/extlib/benz/error.c b/extlib/benz/error.c index 39c2e9d9..658d85af 100644 --- a/extlib/benz/error.c +++ b/extlib/benz/error.c @@ -3,6 +3,7 @@ */ #include "picrin.h" +#include "picrin/object.h" void pic_panic(pic_state PIC_UNUSED(*pic), const char *msg) diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index f0c85c9e..5f0c58f0 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -264,7 +264,6 @@ int pic_str_hash(pic_state *, struct pic_string *); #include "picrin/macro.h" #include "picrin/pair.h" #include "picrin/port.h" -#include "picrin/proc.h" #include "picrin/record.h" #include "picrin/symbol.h" diff --git a/extlib/benz/include/picrin/object.h b/extlib/benz/include/picrin/object.h index 411d4d35..63473828 100644 --- a/extlib/benz/include/picrin/object.h +++ b/extlib/benz/include/picrin/object.h @@ -80,6 +80,48 @@ struct pic_data { #define pic_data_ptr(o) ((struct pic_data *)pic_obj_ptr(o)) +/* context */ + +struct pic_context { + PIC_OBJECT_HEADER + pic_value *regs; + int regc; + struct pic_context *up; + pic_value storage[1]; +}; + +#define pic_context_ptr(o) ((struct pic_context *)pic_obj_ptr(o)) + + +/* procedure */ + +struct pic_proc { + PIC_OBJECT_HEADER + enum { + PIC_PROC_TAG_IREP, + PIC_PROC_TAG_FUNC + } tag; + union { + struct { + pic_func_t func; + int localc; + } f; + struct { + struct pic_irep *irep; + struct pic_context *cxt; + } i; + } u; + pic_value locals[1]; +}; + +#define pic_proc_ptr(o) ((struct pic_proc *)pic_obj_ptr(o)) + +#define pic_proc_func_p(proc) ((proc)->tag == PIC_PROC_TAG_FUNC) +#define pic_proc_irep_p(proc) ((proc)->tag == PIC_PROC_TAG_IREP) + +struct pic_proc *pic_make_proc(pic_state *, pic_func_t, int, pic_value *); +struct pic_proc *pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_context *); + #if defined(__cplusplus) } #endif diff --git a/extlib/benz/include/picrin/proc.h b/extlib/benz/include/picrin/proc.h deleted file mode 100644 index 7fcbe509..00000000 --- a/extlib/benz/include/picrin/proc.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * See Copyright Notice in picrin.h - */ - -#ifndef PICRIN_PROC_H -#define PICRIN_PROC_H - -#if defined(__cplusplus) -extern "C" { -#endif - -struct pic_context { - PIC_OBJECT_HEADER - pic_value *regs; - int regc; - struct pic_context *up; - pic_value storage[1]; -}; - -struct pic_proc { - PIC_OBJECT_HEADER - enum { - PIC_PROC_TAG_IREP, - PIC_PROC_TAG_FUNC - } tag; - union { - struct { - pic_func_t func; - int localc; - } f; - struct { - struct pic_irep *irep; - struct pic_context *cxt; - } i; - } u; - pic_value locals[1]; -}; - -#define pic_proc_func_p(proc) ((proc)->tag == PIC_PROC_TAG_FUNC) -#define pic_proc_irep_p(proc) ((proc)->tag == PIC_PROC_TAG_IREP) - -#define pic_proc_ptr(o) ((struct pic_proc *)pic_obj_ptr(o)) - -#define pic_context_p(o) (pic_type(pic, o) == PIC_TYPE_CXT) -#define pic_context_ptr(o) ((struct pic_context *)pic_obj_ptr(o)) - -struct pic_proc *pic_make_proc(pic_state *, pic_func_t, int, pic_value *); -struct pic_proc *pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_context *); - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/extlib/benz/macro.c b/extlib/benz/macro.c index 8a65f594..c6572765 100644 --- a/extlib/benz/macro.c +++ b/extlib/benz/macro.c @@ -3,6 +3,7 @@ */ #include "picrin.h" +#include "picrin/object.h" KHASH_DEFINE(env, pic_id *, pic_sym *, kh_ptr_hash_func, kh_ptr_hash_equal)