2014-01-17 06:58:31 -05:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
2013-10-10 03:15:41 -04:00
|
|
|
#include "picrin.h"
|
2014-09-08 07:20:08 -04:00
|
|
|
#include "picrin/pair.h"
|
2014-03-23 23:30:21 -04:00
|
|
|
#include "picrin/error.h"
|
2013-10-10 03:15:41 -04:00
|
|
|
|
2014-09-08 11:09:31 -04:00
|
|
|
void pic_init_contrib(pic_state *);
|
|
|
|
void pic_load_piclib(pic_state *);
|
|
|
|
|
2014-09-08 07:20:08 -04:00
|
|
|
static pic_value
|
|
|
|
pic_features(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_get_args(pic, "");
|
|
|
|
|
2014-09-09 13:13:38 -04:00
|
|
|
return pic->features;
|
2014-09-08 07:20:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static pic_value
|
|
|
|
pic_libraries(pic_state *pic)
|
|
|
|
{
|
2015-01-22 05:28:31 -05:00
|
|
|
pic_value libs = pic_nil_value(), lib, it;
|
2014-09-08 07:20:08 -04:00
|
|
|
|
|
|
|
pic_get_args(pic, "");
|
|
|
|
|
2015-01-22 05:28:31 -05:00
|
|
|
pic_for_each (lib, pic->libs, it) {
|
2014-09-08 07:20:08 -04:00
|
|
|
libs = pic_cons(pic, pic_car(pic, lib), libs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return libs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_picrin(pic_state *pic)
|
|
|
|
{
|
2014-09-09 13:13:38 -04:00
|
|
|
pic_add_feature(pic, "r7rs");
|
|
|
|
|
2014-09-08 07:20:08 -04:00
|
|
|
pic_deflibrary (pic, "(picrin library)") {
|
|
|
|
pic_defun(pic, "libraries", pic_libraries);
|
|
|
|
}
|
|
|
|
|
|
|
|
pic_deflibrary (pic, "(scheme base)") {
|
|
|
|
pic_defun(pic, "features", pic_features);
|
|
|
|
}
|
2015-01-22 04:06:10 -05:00
|
|
|
|
|
|
|
pic_init_contrib(pic);
|
|
|
|
pic_load_piclib(pic);
|
2014-09-08 07:20:08 -04:00
|
|
|
}
|
|
|
|
|
2013-10-28 09:08:03 -04:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[], char **envp)
|
|
|
|
{
|
|
|
|
pic_state *pic;
|
2014-09-16 03:20:03 -04:00
|
|
|
struct pic_lib *PICRIN_MAIN;
|
2014-07-29 02:43:59 -04:00
|
|
|
int status = 0;
|
2013-10-28 09:08:03 -04:00
|
|
|
|
2014-09-08 11:09:31 -04:00
|
|
|
pic = pic_open(argc, argv, envp);
|
2013-10-28 09:08:03 -04:00
|
|
|
|
2014-08-31 20:53:19 -04:00
|
|
|
pic_init_picrin(pic);
|
|
|
|
|
2014-09-16 03:20:03 -04:00
|
|
|
PICRIN_MAIN = pic_find_library(pic, pic_read_cstr(pic, "(picrin main)"));
|
|
|
|
|
2014-07-27 22:43:52 -04:00
|
|
|
pic_try {
|
2014-09-16 03:20:03 -04:00
|
|
|
pic_funcall(pic, PICRIN_MAIN, "main", pic_nil_value());
|
2014-01-08 01:38:47 -05:00
|
|
|
}
|
2014-07-27 22:43:52 -04:00
|
|
|
pic_catch {
|
2014-09-16 11:51:01 -04:00
|
|
|
pic_print_backtrace(pic);
|
2014-07-29 02:43:59 -04:00
|
|
|
status = 1;
|
2013-10-28 09:08:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pic_close(pic);
|
|
|
|
|
2014-07-29 02:43:59 -04:00
|
|
|
return status;
|
2013-10-28 09:08:03 -04:00
|
|
|
}
|