2014-01-17 06:58:31 -05:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
2013-10-27 05:38:55 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-10-15 08:14:33 -04:00
|
|
|
#include "picrin.h"
|
2013-10-30 04:06:01 -04:00
|
|
|
#include "picrin/pair.h"
|
2013-12-07 23:48:24 -05:00
|
|
|
#include "picrin/lib.h"
|
|
|
|
#include "picrin/macro.h"
|
2013-10-15 08:14:33 -04:00
|
|
|
|
2013-10-30 11:29:55 -04:00
|
|
|
void pic_init_bool(pic_state *);
|
2013-10-22 23:01:06 -04:00
|
|
|
void pic_init_pair(pic_state *);
|
2013-10-15 08:14:33 -04:00
|
|
|
void pic_init_port(pic_state *);
|
2013-10-15 10:26:18 -04:00
|
|
|
void pic_init_number(pic_state *);
|
2013-10-19 23:04:15 -04:00
|
|
|
void pic_init_time(pic_state *);
|
2013-10-20 22:51:02 -04:00
|
|
|
void pic_init_system(pic_state *);
|
2013-10-22 02:16:35 -04:00
|
|
|
void pic_init_file(pic_state *);
|
2013-10-24 11:37:20 -04:00
|
|
|
void pic_init_proc(pic_state *);
|
2013-10-28 13:49:38 -04:00
|
|
|
void pic_init_symbol(pic_state *);
|
2013-11-04 20:53:33 -05:00
|
|
|
void pic_init_vector(pic_state *);
|
2013-11-04 22:58:16 -05:00
|
|
|
void pic_init_blob(pic_state *);
|
2013-11-09 00:14:25 -05:00
|
|
|
void pic_init_cont(pic_state *);
|
2013-11-14 06:41:22 -05:00
|
|
|
void pic_init_char(pic_state *);
|
2013-11-17 03:25:26 -05:00
|
|
|
void pic_init_error(pic_state *);
|
2013-11-17 03:42:52 -05:00
|
|
|
void pic_init_str(pic_state *);
|
2013-11-27 01:04:44 -05:00
|
|
|
void pic_init_macro(pic_state *);
|
2014-01-08 10:39:13 -05:00
|
|
|
void pic_init_var(pic_state *);
|
2014-01-12 23:54:52 -05:00
|
|
|
void pic_init_load(pic_state *);
|
2014-01-16 07:31:46 -05:00
|
|
|
void pic_init_write(pic_state *);
|
2013-10-15 08:14:33 -04:00
|
|
|
|
2013-10-27 05:38:55 -04:00
|
|
|
void
|
|
|
|
pic_load_stdlib(pic_state *pic)
|
|
|
|
{
|
2014-03-09 12:12:19 -04:00
|
|
|
pic_try {
|
2014-03-15 07:52:49 -04:00
|
|
|
pic_load(pic, "piclib/built-in.scm");
|
|
|
|
pic_load(pic, "piclib/srfi/1.scm");
|
|
|
|
pic_load(pic, "piclib/srfi/95.scm");
|
2013-10-27 05:38:55 -04:00
|
|
|
}
|
2014-03-09 12:12:19 -04:00
|
|
|
pic_catch {
|
2014-01-13 00:52:19 -05:00
|
|
|
/* error! */
|
|
|
|
fputs("fatal error: failure in loading built-in.scm\n", stderr);
|
2014-02-10 23:21:00 -05:00
|
|
|
fputs(pic_errmsg(pic), stderr);
|
2013-10-27 05:38:55 -04:00
|
|
|
abort();
|
|
|
|
}
|
2014-03-15 07:52:49 -04:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
puts("successfully loaded stdlib");
|
|
|
|
#endif
|
|
|
|
|
2013-10-27 05:38:55 -04:00
|
|
|
}
|
|
|
|
|
2013-11-17 11:46:28 -05:00
|
|
|
#define PUSH_SYM(pic, lst, name) \
|
|
|
|
lst = pic_cons(pic, pic_symbol_value(pic_intern_cstr(pic, name)), lst)
|
|
|
|
|
|
|
|
static pic_value
|
|
|
|
pic_features(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_value fs = pic_nil_value();
|
|
|
|
|
|
|
|
pic_get_args(pic, "");
|
|
|
|
|
|
|
|
PUSH_SYM(pic, fs, "r7rs");
|
|
|
|
PUSH_SYM(pic, fs, "ieee-float");
|
|
|
|
PUSH_SYM(pic, fs, "picrin");
|
|
|
|
|
|
|
|
return fs;
|
|
|
|
}
|
|
|
|
|
2013-10-15 08:14:33 -04:00
|
|
|
#define DONE pic_gc_arena_restore(pic, ai);
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_core(pic_state *pic)
|
|
|
|
{
|
2013-12-07 23:48:24 -05:00
|
|
|
int ai = pic_gc_arena_preserve(pic);
|
|
|
|
|
2014-03-01 05:54:29 -05:00
|
|
|
pic_deflibrary ("(scheme base)") {
|
|
|
|
|
|
|
|
/* load core syntaces */
|
|
|
|
pic->lib->senv = pic_core_syntactic_env(pic);
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "define"));
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "set!"));
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "quote"));
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "lambda"));
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "if"));
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "begin"));
|
|
|
|
pic_export(pic, pic_intern_cstr(pic, "define-syntax"));
|
|
|
|
|
|
|
|
pic_init_bool(pic); DONE;
|
|
|
|
pic_init_pair(pic); DONE;
|
|
|
|
pic_init_port(pic); DONE;
|
|
|
|
pic_init_number(pic); DONE;
|
|
|
|
pic_init_time(pic); DONE;
|
|
|
|
pic_init_system(pic); DONE;
|
|
|
|
pic_init_file(pic); DONE;
|
|
|
|
pic_init_proc(pic); DONE;
|
|
|
|
pic_init_symbol(pic); DONE;
|
|
|
|
pic_init_vector(pic); DONE;
|
|
|
|
pic_init_blob(pic); DONE;
|
|
|
|
pic_init_cont(pic); DONE;
|
|
|
|
pic_init_char(pic); DONE;
|
|
|
|
pic_init_error(pic); DONE;
|
|
|
|
pic_init_str(pic); DONE;
|
|
|
|
pic_init_macro(pic); DONE;
|
|
|
|
pic_init_var(pic); DONE;
|
|
|
|
pic_init_load(pic); DONE;
|
|
|
|
pic_init_write(pic); DONE;
|
|
|
|
|
|
|
|
pic_load_stdlib(pic); DONE;
|
|
|
|
|
|
|
|
pic_defun(pic, "features", pic_features);
|
|
|
|
|
|
|
|
}
|
2013-10-15 08:14:33 -04:00
|
|
|
}
|