add pic_closure_ref, pic_closure_set, and pic_lambda
This commit is contained in:
@@ -151,6 +151,8 @@ void pic_defvar(pic_state *, const char *, pic_value, struct pic_proc *);
|
||||
void pic_define(pic_state *, struct pic_lib *, const char *, pic_value);
|
||||
pic_value pic_ref(pic_state *, struct pic_lib *, const char *);
|
||||
void pic_set(pic_state *, struct pic_lib *, const char *, pic_value);
|
||||
pic_value pic_closure_ref(pic_state *, int);
|
||||
void pic_closure_set(pic_state *, int, pic_value);
|
||||
pic_value pic_funcall(pic_state *pic, struct pic_lib *, const char *, int, ...);
|
||||
|
||||
struct pic_lib *pic_make_library(pic_state *, pic_value);
|
||||
@@ -161,13 +163,13 @@ void pic_export(pic_state *, pic_sym *);
|
||||
PIC_NORETURN void pic_panic(pic_state *, const char *);
|
||||
PIC_NORETURN void pic_errorf(pic_state *, const char *, ...);
|
||||
|
||||
struct pic_proc *pic_lambda(pic_state *, pic_func_t, int, ...);
|
||||
struct pic_proc *pic_vlambda(pic_state *, pic_func_t, int, va_list);
|
||||
pic_value pic_call(pic_state *, struct pic_proc *, int, ...);
|
||||
pic_value pic_vcall(pic_state *, struct pic_proc *, int, va_list);
|
||||
pic_value pic_apply(pic_state *, struct pic_proc *, int, pic_value *);
|
||||
pic_value pic_applyk(pic_state *, struct pic_proc *, int, pic_value *);
|
||||
|
||||
pic_value pic_eval(pic_state *, pic_value, struct pic_lib *);
|
||||
|
||||
bool pic_eq_p(pic_value, pic_value);
|
||||
bool pic_eqv_p(pic_value, pic_value);
|
||||
bool pic_equal_p(pic_state *, pic_value, pic_value);
|
||||
@@ -208,6 +210,8 @@ pic_value pic_read_cstr(pic_state *, const char *);
|
||||
void pic_load(pic_state *, struct pic_port *);
|
||||
void pic_load_cstr(pic_state *, const char *);
|
||||
|
||||
pic_value pic_eval(pic_state *, pic_value, struct pic_lib *);
|
||||
|
||||
struct pic_proc *pic_make_var(pic_state *, pic_value, struct pic_proc *);
|
||||
|
||||
#define pic_deflibrary(pic, spec) \
|
||||
|
||||
@@ -35,8 +35,7 @@ struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_value
|
||||
if (PIC_SETJMP(pic, cont.jmp) == 0) { \
|
||||
extern pic_value pic_native_exception_handler(pic_state *); \
|
||||
struct pic_proc *handler; \
|
||||
handler = pic_make_proc(pic, pic_native_exception_handler); \
|
||||
pic_proc_env_set(pic, handler, "cont", pic_obj_value(pic_make_cont(pic, &cont))); \
|
||||
handler = pic_lambda(pic, pic_native_exception_handler, 1, pic_obj_value(pic_make_cont(pic, &cont))); \
|
||||
do { \
|
||||
pic_push_handler(pic, handler);
|
||||
#define pic_catch_(label) \
|
||||
|
||||
@@ -26,13 +26,14 @@ struct pic_proc {
|
||||
union {
|
||||
struct {
|
||||
pic_func_t func;
|
||||
struct pic_dict *env;
|
||||
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)
|
||||
@@ -44,14 +45,9 @@ struct pic_proc {
|
||||
#define pic_context_p(o) (pic_type(o) == PIC_TT_CXT)
|
||||
#define pic_context_ptr(o) ((struct pic_context *)pic_ptr(o))
|
||||
|
||||
struct pic_proc *pic_make_proc(pic_state *, pic_func_t);
|
||||
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 *);
|
||||
|
||||
struct pic_dict *pic_proc_env(pic_state *, struct pic_proc *);
|
||||
bool pic_proc_env_has(pic_state *, struct pic_proc *, const char *);
|
||||
pic_value pic_proc_env_ref(pic_state *, struct pic_proc *, const char *);
|
||||
void pic_proc_env_set(pic_state *, struct pic_proc *, const char *, pic_value);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user