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_value features = pic_nil_value();
|
|
|
|
|
|
|
|
pic_get_args(pic, "");
|
|
|
|
|
|
|
|
pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "r7rs")), features);
|
|
|
|
pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "ieee-float")), features);
|
|
|
|
pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "picrin")), features);
|
|
|
|
|
|
|
|
return features;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pic_value
|
|
|
|
pic_libraries(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_value libs = pic_nil_value(), lib;
|
|
|
|
|
|
|
|
pic_get_args(pic, "");
|
|
|
|
|
|
|
|
pic_for_each (lib, pic->libs) {
|
|
|
|
libs = pic_cons(pic, pic_car(pic, lib), libs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return libs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_picrin(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_deflibrary (pic, "(picrin library)") {
|
|
|
|
pic_defun(pic, "libraries", pic_libraries);
|
|
|
|
}
|
|
|
|
|
|
|
|
pic_deflibrary (pic, "(scheme base)") {
|
|
|
|
pic_defun(pic, "features", pic_features);
|
|
|
|
|
|
|
|
pic_init_contrib(pic);
|
|
|
|
pic_load_piclib(pic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-28 09:08:03 -04:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[], char **envp)
|
|
|
|
{
|
|
|
|
pic_state *pic;
|
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-07-27 22:43:52 -04:00
|
|
|
pic_try {
|
2014-08-30 11:36:20 -04:00
|
|
|
pic_import(pic, pic_read_cstr(pic, "(picrin main)"));
|
|
|
|
pic_funcall(pic, "main", pic_nil_value());
|
2014-01-08 01:38:47 -05:00
|
|
|
}
|
2014-07-27 22:43:52 -04:00
|
|
|
pic_catch {
|
|
|
|
pic_print_backtrace(pic, pic->err);
|
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
|
|
|
}
|