clarify the meanings of error functions
This commit is contained in:
parent
12e2f10869
commit
4f8aa03b24
|
@ -66,7 +66,9 @@ pic_value pic_eval(pic_state *, pic_value, struct pic_env *);
|
||||||
pic_value pic_run(pic_state *, struct pic_proc *, pic_value);
|
pic_value pic_run(pic_state *, struct pic_proc *, pic_value);
|
||||||
struct pic_proc *pic_codegen(pic_state *, pic_value, struct pic_env *);
|
struct pic_proc *pic_codegen(pic_state *, pic_value, struct pic_env *);
|
||||||
|
|
||||||
void pic_raise(pic_state *, const char *);
|
void pic_abort(pic_state *, const char *);
|
||||||
|
void pic_raise(pic_state *, pic_value);
|
||||||
|
void pic_error(pic_state *, const char *, ...);
|
||||||
|
|
||||||
void pic_debug(pic_state *, pic_value);
|
void pic_debug(pic_state *, pic_value);
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ pic_gen(pic_state *pic, struct pic_irep *irep, pic_value obj, struct pic_env *en
|
||||||
|
|
||||||
b = env_lookup(pic, obj, env, &depth, &idx);
|
b = env_lookup(pic, obj, env, &depth, &idx);
|
||||||
if (! b) {
|
if (! b) {
|
||||||
pic_raise(pic, "unbound variable");
|
pic_abort(pic, "unbound variable");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth == -1) { /* global */
|
if (depth == -1) { /* global */
|
||||||
|
@ -218,7 +218,7 @@ pic_gen(pic_state *pic, struct pic_irep *irep, pic_value obj, struct pic_env *en
|
||||||
irep->clen++;
|
irep->clen++;
|
||||||
}
|
}
|
||||||
else { /* nonlocal */
|
else { /* nonlocal */
|
||||||
pic_raise(pic, "reference to closed variable not supported");
|
pic_abort(pic, "reference to closed variable not supported");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ pic_gen(pic_state *pic, struct pic_irep *irep, pic_value obj, struct pic_env *en
|
||||||
case PIC_TT_PROC:
|
case PIC_TT_PROC:
|
||||||
case PIC_TT_UNDEF:
|
case PIC_TT_UNDEF:
|
||||||
case PIC_TT_PORT: {
|
case PIC_TT_PORT: {
|
||||||
pic_raise(pic, "invalid expression given");
|
pic_abort(pic, "invalid expression given");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include "picrin.h"
|
#include "picrin.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_raise(pic_state *pic, const char *str)
|
pic_abort(pic_state *pic, const char *msg)
|
||||||
{
|
{
|
||||||
puts(str);
|
puts(msg);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
12
src/gc.c
12
src/gc.c
|
@ -40,7 +40,7 @@ pic_alloc(pic_state *pic, size_t size)
|
||||||
|
|
||||||
ptr = malloc(size);
|
ptr = malloc(size);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
pic_raise(pic, "memory exhausted");
|
pic_abort(pic, "memory exhausted");
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ pic_realloc(pic_state *pic, void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
ptr = realloc(ptr, size);
|
ptr = realloc(ptr, size);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
pic_raise(pic, "memory exhausted");
|
pic_abort(pic, "memory exhausted");
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ static void
|
||||||
gc_protect(pic_state *pic, struct pic_object *obj)
|
gc_protect(pic_state *pic, struct pic_object *obj)
|
||||||
{
|
{
|
||||||
if (pic->arena_idx >= PIC_ARENA_SIZE) {
|
if (pic->arena_idx >= PIC_ARENA_SIZE) {
|
||||||
pic_raise(pic, "arena overflow");
|
pic_abort(pic, "arena overflow");
|
||||||
}
|
}
|
||||||
pic->arena[pic->arena_idx++] = obj;
|
pic->arena[pic->arena_idx++] = obj;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
pic_raise(pic, "logic flaw");
|
pic_abort(pic, "logic flaw");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
pic_raise(pic, "logic flaw");
|
pic_abort(pic, "logic flaw");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ pic_obj_alloc(pic_state *pic, size_t size, enum pic_tt tt)
|
||||||
pic_gc_run(pic);
|
pic_gc_run(pic);
|
||||||
obj = (struct pic_object *)gc_alloc(pic, size);
|
obj = (struct pic_object *)gc_alloc(pic, size);
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
pic_raise(pic, "GC memory exhausted");
|
pic_abort(pic, "GC memory exhausted");
|
||||||
}
|
}
|
||||||
obj->tt = tt;
|
obj->tt = tt;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue