2014-09-08 05:47:20 -04:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "picrin.h"
|
|
|
|
|
2015-01-17 10:32:52 -05:00
|
|
|
void
|
2015-07-12 19:20:07 -04:00
|
|
|
pic_load(pic_state *pic, struct pic_port *port)
|
2014-09-08 05:47:20 -04:00
|
|
|
{
|
2014-09-08 05:50:15 -04:00
|
|
|
pic_value form;
|
2015-06-19 13:32:25 -04:00
|
|
|
size_t ai = pic_gc_arena_preserve(pic);
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-19 13:32:25 -04:00
|
|
|
while (! pic_eof_p(form = pic_read(pic, port))) {
|
|
|
|
pic_eval(pic, form, pic->lib->env);
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-19 13:32:25 -04:00
|
|
|
pic_gc_arena_restore(pic, ai);
|
2014-09-08 05:50:15 -04:00
|
|
|
}
|
|
|
|
}
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2014-09-08 05:50:15 -04:00
|
|
|
void
|
|
|
|
pic_load_cstr(pic_state *pic, const char *src)
|
|
|
|
{
|
|
|
|
struct pic_port *port = pic_open_input_string(pic, src);
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-26 10:45:56 -04:00
|
|
|
pic_try {
|
2015-07-12 19:20:07 -04:00
|
|
|
pic_load(pic, port);
|
2015-06-26 10:45:56 -04:00
|
|
|
}
|
|
|
|
pic_catch {
|
|
|
|
pic_close_port(pic, port);
|
|
|
|
pic_raise(pic, pic->err);
|
|
|
|
}
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2014-09-08 05:50:15 -04:00
|
|
|
pic_close_port(pic, port);
|
2014-09-08 05:47:20 -04:00
|
|
|
}
|