struct pic_error * -> pic_value
This commit is contained in:
parent
d851273f60
commit
da30be167b
|
@ -45,7 +45,7 @@ pic_print_backtrace(pic_state *pic, xFILE *file)
|
||||||
struct pic_error *e;
|
struct pic_error *e;
|
||||||
pic_value elem, it;
|
pic_value elem, it;
|
||||||
|
|
||||||
e = pic_error_ptr(pic->err);
|
e = pic_error_ptr(pic, pic->err);
|
||||||
if (! pic_eq_p(pic, pic_obj_value(e->type), pic_intern_lit(pic, ""))) {
|
if (! pic_eq_p(pic, pic_obj_value(e->type), pic_intern_lit(pic, ""))) {
|
||||||
pic_fwrite(pic, pic_obj_value(e->type), file);
|
pic_fwrite(pic, pic_obj_value(e->type), file);
|
||||||
xfprintf(pic, file, " ");
|
xfprintf(pic, file, " ");
|
||||||
|
|
|
@ -88,7 +88,7 @@ pic_pop_handler(pic_state *pic)
|
||||||
return pic_obj_value(*--pic->xp);
|
return pic_obj_value(*--pic->xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pic_error *
|
pic_value
|
||||||
pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs)
|
pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
struct pic_error *e;
|
||||||
|
@ -102,7 +102,7 @@ pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs
|
||||||
e->irrs = irrs;
|
e->irrs = irrs;
|
||||||
e->stack = pic_str_ptr(pic, stack);
|
e->stack = pic_str_ptr(pic, stack);
|
||||||
|
|
||||||
return e;
|
return pic_obj_value(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
@ -136,11 +136,7 @@ pic_raise(pic_state *pic, pic_value err)
|
||||||
void
|
void
|
||||||
pic_error(pic_state *pic, const char *type, const char *msg, pic_value irrs)
|
pic_error(pic_state *pic, const char *type, const char *msg, pic_value irrs)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
pic_raise(pic, pic_make_error(pic, type, msg, irrs));
|
||||||
|
|
||||||
e = pic_make_error(pic, type, msg, irrs);
|
|
||||||
|
|
||||||
pic_raise(pic, pic_obj_value(e));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -204,31 +200,37 @@ pic_error_error_object_p(pic_state *pic)
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_error_error_object_message(pic_state *pic)
|
pic_error_error_object_message(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
pic_value e;
|
||||||
|
|
||||||
pic_get_args(pic, "e", &e);
|
pic_get_args(pic, "o", &e);
|
||||||
|
|
||||||
return pic_obj_value(e->msg);
|
pic_assert_type(pic, e, error);
|
||||||
|
|
||||||
|
return pic_obj_value(pic_error_ptr(pic, e)->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_error_error_object_irritants(pic_state *pic)
|
pic_error_error_object_irritants(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
pic_value e;
|
||||||
|
|
||||||
pic_get_args(pic, "e", &e);
|
pic_get_args(pic, "o", &e);
|
||||||
|
|
||||||
return e->irrs;
|
pic_assert_type(pic, e, error);
|
||||||
|
|
||||||
|
return pic_error_ptr(pic, e)->irrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_error_error_object_type(pic_state *pic)
|
pic_error_error_object_type(pic_state *pic)
|
||||||
{
|
{
|
||||||
struct pic_error *e;
|
pic_value e;
|
||||||
|
|
||||||
pic_get_args(pic, "e", &e);
|
pic_get_args(pic, "o", &e);
|
||||||
|
|
||||||
return pic_obj_value(e->type);
|
pic_assert_type(pic, e, error);
|
||||||
|
|
||||||
|
return pic_obj_value(pic_error_ptr(pic, e)->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -51,8 +51,6 @@ typedef struct {
|
||||||
} pic_value;
|
} pic_value;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct pic_error;
|
|
||||||
|
|
||||||
typedef void *(*pic_allocf)(void *userdata, void *ptr, size_t n);
|
typedef void *(*pic_allocf)(void *userdata, void *ptr, size_t n);
|
||||||
|
|
||||||
pic_state *pic_open(pic_allocf f, void *userdata);
|
pic_state *pic_open(pic_allocf f, void *userdata);
|
||||||
|
|
|
@ -145,9 +145,9 @@ struct pic_checkpoint {
|
||||||
#define pic_proc_ptr(pic, o) ((struct pic_proc *)pic_obj_ptr(o))
|
#define pic_proc_ptr(pic, o) ((struct pic_proc *)pic_obj_ptr(o))
|
||||||
#define pic_env_ptr(pic, o) ((struct pic_env *)pic_obj_ptr(o))
|
#define pic_env_ptr(pic, o) ((struct pic_env *)pic_obj_ptr(o))
|
||||||
#define pic_port_ptr(pic, o) ((struct pic_port *)pic_obj_ptr(o))
|
#define pic_port_ptr(pic, o) ((struct pic_port *)pic_obj_ptr(o))
|
||||||
|
#define pic_error_ptr(pic, o) ((struct pic_error *)pic_obj_ptr(o))
|
||||||
#define pic_context_ptr(o) ((struct pic_context *)pic_obj_ptr(o))
|
#define pic_context_ptr(o) ((struct pic_context *)pic_obj_ptr(o))
|
||||||
#define pic_rec_ptr(v) ((struct pic_record *)pic_obj_ptr(v))
|
#define pic_rec_ptr(v) ((struct pic_record *)pic_obj_ptr(v))
|
||||||
#define pic_error_ptr(v) ((struct pic_error *)pic_obj_ptr(v))
|
|
||||||
|
|
||||||
#define pic_obj_p(pic,v) (pic_vtype(pic,v) == PIC_IVAL_END)
|
#define pic_obj_p(pic,v) (pic_vtype(pic,v) == PIC_IVAL_END)
|
||||||
#define pic_env_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ENV)
|
#define pic_env_p(pic, v) (pic_type(pic, v) == PIC_TYPE_ENV)
|
||||||
|
@ -173,9 +173,9 @@ struct pic_object *pic_obj_alloc(pic_state *, size_t, int type);
|
||||||
pic_value pic_make_identifier(pic_state *, pic_value id, pic_value env);
|
pic_value pic_make_identifier(pic_state *, pic_value id, pic_value env);
|
||||||
pic_value pic_make_proc(pic_state *, pic_func_t, int, pic_value *);
|
pic_value pic_make_proc(pic_state *, pic_func_t, int, pic_value *);
|
||||||
pic_value pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_context *);
|
pic_value pic_make_proc_irep(pic_state *, struct pic_irep *, struct pic_context *);
|
||||||
struct pic_record *pic_make_rec(pic_state *, pic_value, pic_value);
|
|
||||||
struct pic_error *pic_make_error(pic_state *, const char *, const char *, pic_value);
|
|
||||||
pic_value pic_make_env(pic_state *, pic_value env);
|
pic_value pic_make_env(pic_state *, pic_value env);
|
||||||
|
pic_value pic_make_error(pic_state *, const char *type, const char *msg, pic_value irrs);
|
||||||
|
struct pic_record *pic_make_rec(pic_state *, pic_value, pic_value);
|
||||||
|
|
||||||
pic_value pic_add_identifier(pic_state *, pic_value id, pic_value env);
|
pic_value pic_add_identifier(pic_state *, pic_value id, pic_value env);
|
||||||
pic_value pic_put_identifier(pic_state *, pic_value id, pic_value uid, pic_value env);
|
pic_value pic_put_identifier(pic_state *, pic_value id, pic_value uid, pic_value env);
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
* l pic_value * lambda object
|
* l pic_value * lambda object
|
||||||
* p pic_value * port object
|
* p pic_value * port object
|
||||||
* d pic_value * dictionary object
|
* d pic_value * dictionary object
|
||||||
* e struct pic_error ** error object
|
|
||||||
* r struct pic_record ** record object
|
* r struct pic_record ** record object
|
||||||
*
|
*
|
||||||
* | optional operator
|
* | optional operator
|
||||||
|
@ -147,7 +146,6 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
||||||
#define PTR_CASE(c, type, ctype) \
|
#define PTR_CASE(c, type, ctype) \
|
||||||
VAL_CASE(c, type, ctype, pic_## type ##_ptr(v))
|
VAL_CASE(c, type, ctype, pic_## type ##_ptr(v))
|
||||||
|
|
||||||
PTR_CASE('e', error, struct pic_error *)
|
|
||||||
PTR_CASE('r', rec, struct pic_record *)
|
PTR_CASE('r', rec, struct pic_record *)
|
||||||
|
|
||||||
#define OBJ_CASE(c, type) VAL_CASE(c, type, pic_value, v)
|
#define OBJ_CASE(c, type) VAL_CASE(c, type, pic_value, v)
|
||||||
|
|
Loading…
Reference in New Issue