Skip to content

Commit

Permalink
don't include picrin/state.h by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nyuichi committed Feb 20, 2016
1 parent 10aae77 commit 317369a
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions contrib/10.callcc/callcc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

struct pic_fullcont {
jmp_buf jmp;
Expand Down
2 changes: 1 addition & 1 deletion etc/mkloader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
pic_catch {
/* error! */
xfputs(pic, "fatal error: failure in loading $dirname/$basename\\n", xstderr);
pic_raise(pic, pic->err);
pic_raise(pic, pic_err(pic));
}
EOL
}
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

struct pic_cont {
PIC_JMPBUF *jmp;
Expand Down
11 changes: 7 additions & 4 deletions extlib/benz/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

pic_value
pic_get_backtrace(pic_state *pic)
Expand Down Expand Up @@ -36,16 +37,18 @@ pic_get_backtrace(pic_state *pic)
void
pic_print_backtrace(pic_state *pic, xFILE *file)
{
assert(! pic_invalid_p(pic, pic->err));
pic_value err = pic_err(pic);

if (! pic_error_p(pic, pic->err)) {
assert(! pic_invalid_p(pic, err));

if (! pic_error_p(pic, err)) {
xfprintf(pic, file, "raise: ");
pic_fwrite(pic, pic->err, file);
pic_fwrite(pic, err, file);
} else {
struct pic_error *e;
pic_value elem, it;

e = pic_error_ptr(pic, pic->err);
e = pic_error_ptr(pic, err);
if (! pic_eq_p(pic, pic_obj_value(e->type), pic_intern_lit(pic, ""))) {
pic_fwrite(pic, pic_obj_value(e->type), file);
xfprintf(pic, file, " ");
Expand Down
7 changes: 7 additions & 0 deletions extlib/benz/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

void
pic_panic(pic_state PIC_UNUSED(*pic), const char *msg)
Expand Down Expand Up @@ -98,6 +99,12 @@ pic_pop_handler(pic_state *pic)
return pic_obj_value(*--pic->xp);
}

pic_value
pic_err(pic_state *pic)
{
return pic->err;
}

pic_value
pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs)
{
Expand Down
3 changes: 2 additions & 1 deletion extlib/benz/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "picrin.h"
#include "picrin/object.h"
#include "picrin/opcode.h"
#include "picrin/state.h"

static pic_value
optimize_beta(pic_state *pic, pic_value expr)
Expand Down Expand Up @@ -891,7 +892,7 @@ pic_eval(pic_state *pic, pic_value program, const char *lib)
}
pic_catch {
pic_in_library(pic, prev_lib);
pic_raise(pic, pic->err);
pic_raise(pic, pic_err(pic));
}
pic_in_library(pic, prev_lib);

Expand Down
5 changes: 5 additions & 0 deletions extlib/benz/file.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/**
* See Copyright Notice in picrin.h
*/

#include "picrin.h"
#include "picrin/state.h"

#ifndef EOF
# define EOF (-1)
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

enum {
WHITE = 0,
Expand Down
7 changes: 4 additions & 3 deletions extlib/benz/include/picrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void pic_export(pic_state *, pic_value sym);

PIC_NORETURN void pic_panic(pic_state *, const char *msg);
PIC_NORETURN void pic_errorf(pic_state *, const char *fmt, ...);
PIC_NORETURN void pic_error(pic_state *, const char *type, const char *msg, pic_value irrs);
PIC_NORETURN void pic_raise(pic_state *, pic_value v);

pic_value pic_lambda(pic_state *, pic_func_t f, int n, ...);
Expand Down Expand Up @@ -296,8 +295,6 @@ int xvfprintf(pic_state *, xFILE *fp, const char *fmt, va_list);
/* extra stuff */


#include "picrin/state.h"

void *pic_default_allocf(void *, void *, size_t);

#define pic_assert_type(pic, v, type) \
Expand Down Expand Up @@ -355,6 +352,8 @@ void pic_exit_point(pic_state *);

/* do not return from try block! */

pic_value pic_err(pic_state *);

#define pic_try \
pic_try_(PIC_GENSYM(cont), PIC_GENSYM(handler))
#define pic_catch \
Expand All @@ -376,6 +375,8 @@ void pic_exit_point(pic_state *);
if (0) \
label:

PIC_NORETURN void pic_error(pic_state *, const char *type, const char *msg, pic_value irrs);

#define pic_for_each(var, list, it) \
for (it = (list); ! pic_nil_p(pic, it); it = pic_cdr(pic, it)) \
if ((var = pic_car(pic, it)), true)
Expand Down
2 changes: 2 additions & 0 deletions extlib/benz/include/picrin/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
extern "C" {
#endif

#include "picrin/khash.h"

typedef struct pic_identifier pic_id;
typedef pic_id pic_sym;

Expand Down
1 change: 1 addition & 0 deletions extlib/benz/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

KHASH_DEFINE(ltable, const char *, struct pic_lib, kh_str_hash_func, kh_str_cmp_func)

Expand Down
2 changes: 1 addition & 1 deletion extlib/benz/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pic_load_cstr(pic_state *pic, const char *str)
}
pic_catch {
pic_close_port(pic, port);
pic_raise(pic, pic->err);
pic_raise(pic, pic_err(pic));
}

pic_close_port(pic, port);
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

KHASH_DEFINE(env, pic_id *, pic_sym *, kh_ptr_hash_func, kh_ptr_hash_equal)

Expand Down
1 change: 1 addition & 0 deletions extlib/benz/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/file.h"

#undef EOF
#define EOF (-1)
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "picrin.h"
#include "picrin/object.h"
#include "picrin/opcode.h"
#include "picrin/state.h"

#define MIN(x,y) ((x) < (y) ? (x) : (y))

Expand Down
3 changes: 2 additions & 1 deletion extlib/benz/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

#undef EOF
#define EOF (-1)
Expand Down Expand Up @@ -852,7 +853,7 @@ pic_read_cstr(pic_state *pic, const char *str)
}
pic_catch {
pic_close_port(pic, port);
pic_raise(pic, pic->err);
pic_raise(pic, pic_err(pic));
}

pic_close_port(pic, port);
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

static void
pic_init_features(pic_state *pic)
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

#define kh_pic_str_hash(a) (pic_str_hash(pic, pic_obj_value(a)))
#define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, pic_obj_value(a), pic_obj_value(b)) == 0)
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

static pic_value
var_get(pic_state *pic, pic_value var)
Expand Down
1 change: 1 addition & 0 deletions extlib/benz/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "picrin.h"
#include "picrin/object.h"
#include "picrin/state.h"

KHASH_DECLARE(l, void *, int)
KHASH_DECLARE(v, void *, int)
Expand Down

0 comments on commit 317369a

Please sign in to comment.