clarify the meanings of error functions

This commit is contained in:
Yuichi Nishiwaki 2013-10-20 17:41:48 +09:00
parent 12e2f10869
commit 4f8aa03b24
4 changed files with 14 additions and 12 deletions

View File

@ -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);
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);

View File

@ -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);
if (! b) {
pic_raise(pic, "unbound variable");
pic_abort(pic, "unbound variable");
}
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++;
}
else { /* nonlocal */
pic_raise(pic, "reference to closed variable not supported");
pic_abort(pic, "reference to closed variable not supported");
}
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_UNDEF:
case PIC_TT_PORT: {
pic_raise(pic, "invalid expression given");
pic_abort(pic, "invalid expression given");
}
}
}

View File

@ -4,8 +4,8 @@
#include "picrin.h"
void
pic_raise(pic_state *pic, const char *str)
pic_abort(pic_state *pic, const char *msg)
{
puts(str);
puts(msg);
abort();
}

View File

@ -40,7 +40,7 @@ pic_alloc(pic_state *pic, size_t size)
ptr = malloc(size);
if (ptr == NULL) {
pic_raise(pic, "memory exhausted");
pic_abort(pic, "memory exhausted");
}
return ptr;
}
@ -50,7 +50,7 @@ pic_realloc(pic_state *pic, void *ptr, size_t size)
{
ptr = realloc(ptr, size);
if (ptr == NULL) {
pic_raise(pic, "memory exhausted");
pic_abort(pic, "memory exhausted");
}
return ptr;
}
@ -65,7 +65,7 @@ static void
gc_protect(pic_state *pic, struct pic_object *obj)
{
if (pic->arena_idx >= PIC_ARENA_SIZE) {
pic_raise(pic, "arena overflow");
pic_abort(pic, "arena overflow");
}
pic->arena[pic->arena_idx++] = obj;
}
@ -149,7 +149,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
break;
}
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;
}
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);
obj = (struct pic_object *)gc_alloc(pic, size);
if (obj == NULL)
pic_raise(pic, "GC memory exhausted");
pic_abort(pic, "GC memory exhausted");
}
obj->tt = tt;