add pic_load_cstr
This commit is contained in:
+28
@@ -5,6 +5,34 @@
|
||||
#include "picrin.h"
|
||||
#include "picrin/pair.h"
|
||||
|
||||
pic_value
|
||||
pic_load_cstr(pic_state *pic, const char *src)
|
||||
{
|
||||
int ai;
|
||||
pic_value v, exprs;
|
||||
struct pic_proc *proc;
|
||||
|
||||
exprs = pic_parse_cstr(pic, src);
|
||||
if (pic_undef_p(exprs)) {
|
||||
pic_error(pic, "load: unexpected EOF");
|
||||
}
|
||||
|
||||
pic_for_each (v, exprs) {
|
||||
ai = pic_gc_arena_preserve(pic);
|
||||
|
||||
proc = pic_compile(pic, v);
|
||||
if (proc == NULL) {
|
||||
pic_error(pic, "load: compilation failure");
|
||||
}
|
||||
|
||||
pic_apply(pic, proc, pic_nil_value());
|
||||
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
}
|
||||
|
||||
return pic_none_value();
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_load(pic_state *pic, const char *fn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user