From 25c0eb125eb7c98b2cf8324e07f75d2e48852ef6 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 10 Jun 2015 16:08:38 +0900 Subject: [PATCH] add identifier-variable and identifier-environment --- extlib/benz/macro.c | 28 +++++++++++++++++++++++++++- piclib/picrin/base.scm | 10 +++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/extlib/benz/macro.c b/extlib/benz/macro.c index 8a47e816..057e7dac 100644 --- a/extlib/benz/macro.c +++ b/extlib/benz/macro.c @@ -490,6 +490,30 @@ pic_macro_make_identifier(pic_state *pic) return pic_obj_value(pic_make_id(pic, var, pic_env_ptr(env))); } +static pic_value +pic_macro_identifier_variable(pic_state *pic) +{ + pic_value id; + + pic_get_args(pic, "o", &id); + + pic_assert_type(pic, id, id); + + return pic_id_ptr(id)->var; +} + +static pic_value +pic_macro_identifier_environment(pic_state *pic) +{ + pic_value id; + + pic_get_args(pic, "o", &id); + + pic_assert_type(pic, id, id); + + return pic_obj_value(pic_id_ptr(id)->env); +} + static pic_value pic_macro_variable_p(pic_state *pic) { @@ -526,8 +550,10 @@ pic_macro_variable_eq_p(pic_state *pic) void pic_init_macro(pic_state *pic) { - pic_defun(pic, "identifier?", pic_macro_identifier_p); pic_defun(pic, "make-identifier", pic_macro_make_identifier); + pic_defun(pic, "identifier?", pic_macro_identifier_p); + pic_defun(pic, "identifier-variable", pic_macro_identifier_variable); + pic_defun(pic, "identifier-environment", pic_macro_identifier_environment); pic_defun(pic, "variable?", pic_macro_variable_p); pic_defun(pic, "variable=?", pic_macro_variable_eq_p); diff --git a/piclib/picrin/base.scm b/piclib/picrin/base.scm index c81744a2..f2fbfbf6 100644 --- a/piclib/picrin/base.scm +++ b/piclib/picrin/base.scm @@ -239,9 +239,13 @@ (export make-parameter parameterize) - (export identifier? - identifier=? - make-identifier) + (export make-identifier + identifier? + identifier-variable + identifier-environment + + variable? + variable=?) (export call-with-current-continuation call/cc