add library-name and current-library

This commit is contained in:
Yuichi Nishiwaki 2015-06-17 00:03:52 +09:00
parent 4f69cb8ec3
commit 490c97cd81
2 changed files with 36 additions and 0 deletions

View File

@ -336,6 +336,38 @@ pic_lib_find_library(pic_state *pic)
return pic_obj_value(lib);
}
static pic_value
pic_lib_current_library(pic_state *pic)
{
pic_value lib;
size_t n;
n = pic_get_args(pic, "|o", &lib);
if (n == 0) {
return pic_obj_value(pic->lib);
}
else {
pic_assert_type(pic, lib, lib);
pic->lib = pic_lib_ptr(lib);
return pic_undef_value();
}
}
static pic_value
pic_lib_library_name(pic_state *pic)
{
pic_value lib;
pic_get_args(pic, "o", &lib);
pic_assert_type(pic, lib, lib);
return pic_lib_ptr(lib)->name;
}
static pic_value
pic_lib_library_exports(pic_state *pic)
{
@ -378,6 +410,8 @@ pic_init_lib(pic_state *pic)
pic_defun(pic, "make-library", pic_lib_make_library);
pic_defun(pic, "find-library", pic_lib_find_library);
pic_defun(pic, "current-library", pic_lib_current_library);
pic_defun(pic, "library-name", pic_lib_library_name);
pic_defun(pic, "library-exports", pic_lib_library_exports);
pic_defun(pic, "library-environment", pic_lib_library_environment);
}

View File

@ -254,6 +254,8 @@
(export make-library
find-library
current-library
library-name
library-exports
library-environment)