2009-10-23 15:47:08 +02:00
|
|
|
|
/* Copyright (C) 1998,2000,2001,2002,2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc.
|
2007-05-05 20:38:57 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
1998-11-22 12:05:14 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1998-11-22 12:05:14 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 20:35:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/eval.h"
|
2000-09-10 22:22:36 +00:00
|
|
|
|
#include "libguile/smob.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/procprop.h"
|
2000-06-04 01:30:05 +00:00
|
|
|
|
#include "libguile/vectors.h"
|
|
|
|
|
|
#include "libguile/hashtab.h"
|
|
|
|
|
|
#include "libguile/struct.h"
|
|
|
|
|
|
#include "libguile/variable.h"
|
2000-06-21 02:42:31 +00:00
|
|
|
|
#include "libguile/fluids.h"
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
#include "libguile/deprecation.h"
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/modules.h"
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
int scm_module_system_booted_p = 0;
|
2000-08-11 08:44:02 +00:00
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_bits scm_module_tag;
|
2000-08-11 08:44:02 +00:00
|
|
|
|
|
1998-11-22 12:05:14 +00:00
|
|
|
|
static SCM the_module;
|
|
|
|
|
|
|
2008-02-01 22:51:34 +00:00
|
|
|
|
static SCM the_root_module_var;
|
|
|
|
|
|
|
2009-10-23 15:47:08 +02:00
|
|
|
|
static SCM unbound_variable (const char *func, SCM sym)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_error (scm_from_locale_symbol ("unbound-variable"), func,
|
|
|
|
|
|
"Unbound variable: ~S", scm_list_1 (sym), SCM_BOOL_F);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-02-01 22:51:34 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
the_root_module ()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (scm_module_system_booted_p)
|
|
|
|
|
|
return SCM_VARIABLE_REF (the_root_module_var);
|
|
|
|
|
|
else
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-04-24 23:40:18 +00:00
|
|
|
|
SCM_DEFINE (scm_current_module, "current-module", 0, 0, 0,
|
|
|
|
|
|
(),
|
|
|
|
|
|
"Return the current module.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_current_module
|
1998-11-22 12:05:14 +00:00
|
|
|
|
{
|
2008-02-01 22:51:34 +00:00
|
|
|
|
SCM curr = scm_fluid_ref (the_module);
|
|
|
|
|
|
|
|
|
|
|
|
return scm_is_true (curr) ? curr : the_root_module ();
|
1998-11-22 12:05:14 +00:00
|
|
|
|
}
|
2001-04-24 23:40:18 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
static void scm_post_boot_init_modules (void);
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2001-04-24 23:40:18 +00:00
|
|
|
|
SCM_DEFINE (scm_set_current_module, "set-current-module", 1, 0, 0,
|
|
|
|
|
|
(SCM module),
|
2001-11-11 15:01:52 +00:00
|
|
|
|
"Set the current module to @var{module} and return\n"
|
2001-04-24 23:40:18 +00:00
|
|
|
|
"the previous current module.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_set_current_module
|
1998-11-22 12:05:14 +00:00
|
|
|
|
{
|
2001-04-24 23:40:18 +00:00
|
|
|
|
SCM old;
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
if (!scm_module_system_booted_p)
|
|
|
|
|
|
scm_post_boot_init_modules ();
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_MODULE (SCM_ARG1, module);
|
2001-04-24 23:40:18 +00:00
|
|
|
|
|
|
|
|
|
|
old = scm_current_module ();
|
|
|
|
|
|
scm_fluid_set_x (the_module, module);
|
|
|
|
|
|
|
1998-11-22 12:05:14 +00:00
|
|
|
|
return old;
|
|
|
|
|
|
}
|
2001-04-24 23:40:18 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-11-22 12:05:14 +00:00
|
|
|
|
|
2000-08-11 08:44:02 +00:00
|
|
|
|
SCM_DEFINE (scm_interaction_environment, "interaction-environment", 0, 0, 0,
|
|
|
|
|
|
(),
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"Return a specifier for the environment that contains\n"
|
|
|
|
|
|
"implementation--defined bindings, typically a superset of those\n"
|
|
|
|
|
|
"listed in the report. The intent is that this procedure will\n"
|
|
|
|
|
|
"return the environment in which the implementation would\n"
|
|
|
|
|
|
"evaluate expressions dynamically typed by the user.")
|
2000-08-11 08:44:02 +00:00
|
|
|
|
#define FUNC_NAME s_scm_interaction_environment
|
|
|
|
|
|
{
|
2001-02-08 18:49:52 +00:00
|
|
|
|
return scm_current_module ();
|
2000-08-11 08:44:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
1998-11-22 12:05:14 +00:00
|
|
|
|
SCM
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
scm_c_call_with_current_module (SCM module,
|
|
|
|
|
|
SCM (*func)(void *), void *data)
|
1998-11-22 12:05:14 +00:00
|
|
|
|
{
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
return scm_c_with_fluid (the_module, module, func, data);
|
1998-11-22 12:05:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-03-02 20:14:59 +00:00
|
|
|
|
void
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_current_module (SCM module)
|
2005-03-02 20:14:59 +00:00
|
|
|
|
{
|
2006-01-29 00:23:28 +00:00
|
|
|
|
scm_dynwind_fluid (the_module, module);
|
2005-03-02 20:14:59 +00:00
|
|
|
|
}
|
2002-12-10 13:26:25 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
convert "A B C" to scheme list (A B C)
|
|
|
|
|
|
*/
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
convert_module_name (const char *name)
|
1998-11-23 02:35:11 +00:00
|
|
|
|
{
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
SCM list = SCM_EOL;
|
|
|
|
|
|
SCM *tail = &list;
|
1998-11-23 02:35:11 +00:00
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
const char *ptr;
|
|
|
|
|
|
while (*name)
|
|
|
|
|
|
{
|
|
|
|
|
|
while (*name == ' ')
|
|
|
|
|
|
name++;
|
|
|
|
|
|
ptr = name;
|
|
|
|
|
|
while (*ptr && *ptr != ' ')
|
|
|
|
|
|
ptr++;
|
|
|
|
|
|
if (ptr > name)
|
|
|
|
|
|
{
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
SCM sym = scm_from_locale_symboln (name, ptr-name);
|
|
|
|
|
|
*tail = scm_cons (sym, SCM_EOL);
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
tail = SCM_CDRLOC (*tail);
|
|
|
|
|
|
}
|
|
|
|
|
|
name = ptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
1998-11-22 12:05:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
static SCM process_define_module_var;
|
|
|
|
|
|
static SCM process_use_modules_var;
|
|
|
|
|
|
static SCM resolve_module_var;
|
|
|
|
|
|
|
2001-02-11 18:14:34 +00:00
|
|
|
|
SCM
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
scm_c_resolve_module (const char *name)
|
2001-02-11 18:14:34 +00:00
|
|
|
|
{
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
return scm_resolve_module (convert_module_name (name));
|
2001-02-11 18:14:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2001-04-24 23:40:18 +00:00
|
|
|
|
SCM
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
scm_resolve_module (SCM name)
|
2001-04-24 23:40:18 +00:00
|
|
|
|
{
|
2001-06-26 15:46:40 +00:00
|
|
|
|
return scm_call_1 (SCM_VARIABLE_REF (resolve_module_var), name);
|
2001-04-24 23:40:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
scm_c_define_module (const char *name,
|
|
|
|
|
|
void (*init)(void *), void *data)
|
2001-04-24 23:40:18 +00:00
|
|
|
|
{
|
2001-06-26 15:46:40 +00:00
|
|
|
|
SCM module = scm_call_1 (SCM_VARIABLE_REF (process_define_module_var),
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
scm_list_1 (convert_module_name (name)));
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
if (init)
|
|
|
|
|
|
scm_c_call_with_current_module (module, (SCM (*)(void*))init, data);
|
|
|
|
|
|
return module;
|
2001-04-24 23:40:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_c_use_module (const char *name)
|
1998-11-26 17:59:15 +00:00
|
|
|
|
{
|
2001-06-26 15:46:40 +00:00
|
|
|
|
scm_call_1 (SCM_VARIABLE_REF (process_use_modules_var),
|
2001-11-23 21:38:33 +00:00
|
|
|
|
scm_list_1 (scm_list_1 (convert_module_name (name))));
|
1998-11-26 17:59:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
static SCM module_export_x_var;
|
1998-11-23 02:35:11 +00:00
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_module_export (SCM module, SCM namelist)
|
2002-12-10 13:26:25 +00:00
|
|
|
|
{
|
2002-12-10 16:07:30 +00:00
|
|
|
|
return scm_call_2 (SCM_VARIABLE_REF (module_export_x_var),
|
|
|
|
|
|
module, namelist);
|
2002-12-10 13:26:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2001-11-20 22:45:24 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
@code{scm_c_export}(@var{name-list})
|
|
|
|
|
|
|
|
|
|
|
|
@code{scm_c_export} exports the named bindings from the current
|
|
|
|
|
|
module, making them visible to users of the module. This function
|
|
|
|
|
|
takes a list of string arguments, terminated by NULL, e.g.
|
|
|
|
|
|
|
|
|
|
|
|
@example
|
|
|
|
|
|
scm_c_export ("add-double-record", "bamboozle-money", NULL);
|
|
|
|
|
|
@end example
|
|
|
|
|
|
*/
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_c_export (const char *name, ...)
|
1998-11-23 02:35:11 +00:00
|
|
|
|
{
|
2001-11-20 22:45:24 +00:00
|
|
|
|
if (name)
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
{
|
2001-11-20 22:45:24 +00:00
|
|
|
|
va_list ap;
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
SCM names = scm_cons (scm_from_locale_symbol (name), SCM_EOL);
|
2001-11-20 22:45:24 +00:00
|
|
|
|
SCM *tail = SCM_CDRLOC (names);
|
|
|
|
|
|
va_start (ap, name);
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
{
|
|
|
|
|
|
const char *n = va_arg (ap, const char *);
|
|
|
|
|
|
if (n == NULL)
|
|
|
|
|
|
break;
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
*tail = scm_cons (scm_from_locale_symbol (n), SCM_EOL);
|
2001-11-20 22:45:24 +00:00
|
|
|
|
tail = SCM_CDRLOC (*tail);
|
|
|
|
|
|
}
|
|
|
|
|
|
va_end (ap);
|
2007-05-05 20:38:57 +00:00
|
|
|
|
scm_module_export (scm_current_module (), names);
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
}
|
1998-11-23 02:35:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-12-10 13:26:25 +00:00
|
|
|
|
|
2000-08-11 08:44:02 +00:00
|
|
|
|
/* Environments */
|
1999-03-19 02:28:09 +00:00
|
|
|
|
|
|
|
|
|
|
SCM
|
1999-12-12 20:35:02 +00:00
|
|
|
|
scm_top_level_env (SCM thunk)
|
1999-03-19 02:28:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (SCM_IMP (thunk))
|
|
|
|
|
|
return SCM_EOL;
|
|
|
|
|
|
else
|
|
|
|
|
|
return scm_cons (thunk, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_env_top_level (SCM env)
|
|
|
|
|
|
{
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (scm_is_pair (env))
|
1999-03-19 02:28:09 +00:00
|
|
|
|
{
|
2002-11-16 16:56:52 +00:00
|
|
|
|
SCM car_env = SCM_CAR (env);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_pair (car_env) && scm_is_true (scm_procedure_p (car_env)))
|
2002-11-16 16:56:52 +00:00
|
|
|
|
return car_env;
|
1999-03-19 02:28:09 +00:00
|
|
|
|
env = SCM_CDR (env);
|
|
|
|
|
|
}
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
SCM_SYMBOL (sym_module, "module");
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_lookup_closure_module (SCM proc)
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (proc))
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
return the_root_module ();
|
2001-05-15 14:57:22 +00:00
|
|
|
|
else if (SCM_EVAL_CLOSURE_P (proc))
|
|
|
|
|
|
return SCM_PACK (SCM_SMOB_DATA (proc));
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2008-11-05 18:50:23 +01:00
|
|
|
|
SCM mod;
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: The `module' property is no longer set. See
|
|
|
|
|
|
`set-module-eval-closure!' in `boot-9.scm'. */
|
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
|
|
mod = scm_procedure_property (proc, sym_module);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (mod))
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
mod = the_root_module ();
|
2001-05-15 14:57:22 +00:00
|
|
|
|
return mod;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-25 13:15:57 +00:00
|
|
|
|
SCM_DEFINE (scm_env_module, "env-module", 1, 0, 0,
|
|
|
|
|
|
(SCM env),
|
|
|
|
|
|
"Return the module of @var{ENV}, a lexical environment.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_env_module
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
return scm_lookup_closure_module (scm_env_top_level (env));
|
|
|
|
|
|
}
|
2001-05-25 13:15:57 +00:00
|
|
|
|
#undef FUNC_NAME
|
2001-05-15 14:57:22 +00:00
|
|
|
|
|
2000-06-04 01:30:05 +00:00
|
|
|
|
/*
|
|
|
|
|
|
* C level implementation of the standard eval closure
|
|
|
|
|
|
*
|
2006-11-02 21:10:37 +00:00
|
|
|
|
* This increases loading speed substantially. The code may be
|
|
|
|
|
|
* replaced by something based on environments.[ch], in a future
|
|
|
|
|
|
* release.
|
2000-06-04 01:30:05 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* The `module-make-local-var!' variable. */
|
|
|
|
|
|
static SCM module_make_local_var_x_var = SCM_UNSPECIFIED;
|
2000-06-04 01:30:05 +00:00
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* The `default-duplicate-binding-procedures' variable. */
|
|
|
|
|
|
static SCM default_duplicate_binding_procedures_var = SCM_UNSPECIFIED;
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the list of default duplicate binding handlers (procedures). */
|
|
|
|
|
|
static inline SCM
|
|
|
|
|
|
default_duplicate_binding_handlers (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM get_handlers;
|
|
|
|
|
|
|
|
|
|
|
|
get_handlers = SCM_VARIABLE_REF (default_duplicate_binding_procedures_var);
|
|
|
|
|
|
|
|
|
|
|
|
return (scm_call_0 (get_handlers));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Resolve the import of SYM in MODULE, where SYM is currently provided by
|
|
|
|
|
|
both IFACE1 as VAR1 and IFACE2 as VAR2. Return the variable chosen by the
|
|
|
|
|
|
duplicate binding handlers or `#f'. */
|
|
|
|
|
|
static inline SCM
|
|
|
|
|
|
resolve_duplicate_binding (SCM module, SCM sym,
|
|
|
|
|
|
SCM iface1, SCM var1,
|
|
|
|
|
|
SCM iface2, SCM var2)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM result = SCM_BOOL_F;
|
|
|
|
|
|
|
|
|
|
|
|
if (!scm_is_eq (var1, var2))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM val1, val2;
|
|
|
|
|
|
SCM handlers, h, handler_args;
|
|
|
|
|
|
|
|
|
|
|
|
val1 = SCM_VARIABLE_REF (var1);
|
|
|
|
|
|
val2 = SCM_VARIABLE_REF (var2);
|
|
|
|
|
|
|
|
|
|
|
|
val1 = (val1 == SCM_UNSPECIFIED) ? SCM_BOOL_F : val1;
|
|
|
|
|
|
val2 = (val2 == SCM_UNSPECIFIED) ? SCM_BOOL_F : val2;
|
|
|
|
|
|
|
|
|
|
|
|
handlers = SCM_MODULE_DUPLICATE_HANDLERS (module);
|
|
|
|
|
|
if (scm_is_false (handlers))
|
|
|
|
|
|
handlers = default_duplicate_binding_handlers ();
|
|
|
|
|
|
|
|
|
|
|
|
handler_args = scm_list_n (module, sym,
|
|
|
|
|
|
iface1, val1, iface2, val2,
|
|
|
|
|
|
var1, val1,
|
|
|
|
|
|
SCM_UNDEFINED);
|
|
|
|
|
|
|
|
|
|
|
|
for (h = handlers;
|
|
|
|
|
|
scm_is_pair (h) && scm_is_false (result);
|
|
|
|
|
|
h = SCM_CDR (h))
|
|
|
|
|
|
{
|
|
|
|
|
|
result = scm_apply (SCM_CAR (h), handler_args, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
result = var1;
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-09-02 00:49:17 -07:00
|
|
|
|
SCM scm_pre_modules_obarray;
|
|
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* Lookup SYM as an imported variable of MODULE. */
|
|
|
|
|
|
static inline SCM
|
|
|
|
|
|
module_imported_variable (SCM module, SCM sym)
|
|
|
|
|
|
{
|
|
|
|
|
|
#define SCM_BOUND_THING_P scm_is_true
|
|
|
|
|
|
register SCM var, imports;
|
|
|
|
|
|
|
|
|
|
|
|
/* Search cached imported bindings. */
|
|
|
|
|
|
imports = SCM_MODULE_IMPORT_OBARRAY (module);
|
|
|
|
|
|
var = scm_hashq_ref (imports, sym, SCM_UNDEFINED);
|
|
|
|
|
|
if (SCM_BOUND_THING_P (var))
|
|
|
|
|
|
return var;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Search the use list for yet uncached imported bindings, possibly
|
|
|
|
|
|
resolving duplicates as needed and caching the result in the import
|
|
|
|
|
|
obarray. */
|
|
|
|
|
|
SCM uses;
|
|
|
|
|
|
SCM found_var = SCM_BOOL_F, found_iface = SCM_BOOL_F;
|
|
|
|
|
|
|
|
|
|
|
|
for (uses = SCM_MODULE_USES (module);
|
|
|
|
|
|
scm_is_pair (uses);
|
|
|
|
|
|
uses = SCM_CDR (uses))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM iface;
|
|
|
|
|
|
|
|
|
|
|
|
iface = SCM_CAR (uses);
|
|
|
|
|
|
var = scm_module_variable (iface, sym);
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_BOUND_THING_P (var))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_BOUND_THING_P (found_var))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* SYM is a duplicate binding (imported more than once) so we
|
|
|
|
|
|
need to resolve it. */
|
|
|
|
|
|
found_var = resolve_duplicate_binding (module, sym,
|
|
|
|
|
|
found_iface, found_var,
|
|
|
|
|
|
iface, var);
|
|
|
|
|
|
if (scm_is_eq (found_var, var))
|
|
|
|
|
|
found_iface = iface;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
/* Keep track of the variable we found and check for other
|
|
|
|
|
|
occurences of SYM in the use list. */
|
|
|
|
|
|
found_var = var, found_iface = iface;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_BOUND_THING_P (found_var))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Save the lookup result for future reference. */
|
|
|
|
|
|
(void) scm_hashq_set_x (imports, sym, found_var);
|
|
|
|
|
|
return found_var;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
#undef SCM_BOUND_THING_P
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_module_local_variable, "module-local-variable", 2, 0, 0,
|
|
|
|
|
|
(SCM module, SCM sym),
|
|
|
|
|
|
"Return the variable bound to @var{sym} in @var{module}. Return "
|
|
|
|
|
|
"@code{#f} is @var{sym} is not bound locally in @var{module}.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_module_local_variable
|
2000-06-04 01:30:05 +00:00
|
|
|
|
{
|
2001-10-13 15:40:29 +00:00
|
|
|
|
#define SCM_BOUND_THING_P(b) \
|
2004-07-06 10:59:25 +00:00
|
|
|
|
(scm_is_true (b))
|
2001-10-13 15:40:29 +00:00
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
register SCM b;
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_module_system_booted_p)
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_SYMBOL (2, sym);
|
|
|
|
|
|
|
2009-04-26 13:10:30 +02:00
|
|
|
|
if (scm_is_false (module))
|
|
|
|
|
|
return scm_hashq_ref (scm_pre_modules_obarray, sym, SCM_UNDEFINED);
|
2007-05-05 20:38:57 +00:00
|
|
|
|
|
2000-06-04 01:30:05 +00:00
|
|
|
|
/* 1. Check module obarray */
|
2007-05-05 20:38:57 +00:00
|
|
|
|
b = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym, SCM_UNDEFINED);
|
2001-10-13 15:40:29 +00:00
|
|
|
|
if (SCM_BOUND_THING_P (b))
|
2000-06-04 01:30:05 +00:00
|
|
|
|
return b;
|
2007-05-05 20:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
/* 2. Search imported bindings. In order to be consistent with
|
|
|
|
|
|
`module-variable', the binder gets called only when no imported binding
|
|
|
|
|
|
matches SYM. */
|
|
|
|
|
|
b = module_imported_variable (module, sym);
|
|
|
|
|
|
if (SCM_BOUND_THING_P (b))
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
|
2000-06-04 01:30:05 +00:00
|
|
|
|
{
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* 3. Query the custom binder. */
|
2000-08-11 08:44:02 +00:00
|
|
|
|
SCM binder = SCM_MODULE_BINDER (module);
|
2007-05-05 20:38:57 +00:00
|
|
|
|
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (binder))
|
2000-06-04 01:30:05 +00:00
|
|
|
|
{
|
2001-06-26 15:46:40 +00:00
|
|
|
|
b = scm_call_3 (binder, module, sym, SCM_BOOL_F);
|
2001-10-13 15:40:29 +00:00
|
|
|
|
if (SCM_BOUND_THING_P (b))
|
2000-06-04 01:30:05 +00:00
|
|
|
|
return b;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-05-05 20:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
|
|
|
|
|
|
#undef SCM_BOUND_THING_P
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_module_variable, "module-variable", 2, 0, 0,
|
|
|
|
|
|
(SCM module, SCM sym),
|
|
|
|
|
|
"Return the variable bound to @var{sym} in @var{module}. This "
|
|
|
|
|
|
"may be both a local variable or an imported variable. Return "
|
|
|
|
|
|
"@code{#f} is @var{sym} is not bound in @var{module}.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_module_variable
|
|
|
|
|
|
{
|
|
|
|
|
|
#define SCM_BOUND_THING_P(b) \
|
|
|
|
|
|
(scm_is_true (b))
|
|
|
|
|
|
|
|
|
|
|
|
register SCM var;
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_module_system_booted_p)
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_SYMBOL (2, sym);
|
|
|
|
|
|
|
2008-09-02 00:49:17 -07:00
|
|
|
|
if (scm_is_false (module))
|
|
|
|
|
|
return scm_hashq_ref (scm_pre_modules_obarray, sym, SCM_UNDEFINED);
|
|
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* 1. Check module obarray */
|
|
|
|
|
|
var = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym, SCM_UNDEFINED);
|
|
|
|
|
|
if (SCM_BOUND_THING_P (var))
|
|
|
|
|
|
return var;
|
|
|
|
|
|
|
|
|
|
|
|
/* 2. Search among the imported variables. */
|
|
|
|
|
|
var = module_imported_variable (module, sym);
|
|
|
|
|
|
if (SCM_BOUND_THING_P (var))
|
|
|
|
|
|
return var;
|
|
|
|
|
|
|
2000-06-04 01:30:05 +00:00
|
|
|
|
{
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* 3. Query the custom binder. */
|
|
|
|
|
|
SCM binder;
|
|
|
|
|
|
|
|
|
|
|
|
binder = SCM_MODULE_BINDER (module);
|
|
|
|
|
|
if (scm_is_true (binder))
|
2000-06-04 01:30:05 +00:00
|
|
|
|
{
|
2007-05-05 20:38:57 +00:00
|
|
|
|
var = scm_call_3 (binder, module, sym, SCM_BOOL_F);
|
|
|
|
|
|
if (SCM_BOUND_THING_P (var))
|
|
|
|
|
|
return var;
|
2000-06-04 01:30:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2007-05-05 20:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
|
2001-10-13 15:40:29 +00:00
|
|
|
|
#undef SCM_BOUND_THING_P
|
2000-06-04 01:30:05 +00:00
|
|
|
|
}
|
2007-05-05 20:38:57 +00:00
|
|
|
|
#undef FUNC_NAME
|
2000-06-04 01:30:05 +00:00
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_bits scm_tc16_eval_closure;
|
2000-06-04 01:30:05 +00:00
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
#define SCM_F_EVAL_CLOSURE_INTERFACE (1<<16)
|
|
|
|
|
|
#define SCM_EVAL_CLOSURE_INTERFACE_P(e) \
|
|
|
|
|
|
(SCM_CELL_WORD_0 (e) & SCM_F_EVAL_CLOSURE_INTERFACE)
|
|
|
|
|
|
|
2000-09-10 22:22:36 +00:00
|
|
|
|
/* NOTE: This function may be called by a smob application
|
|
|
|
|
|
or from another C function directly. */
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep)
|
2000-06-04 01:30:05 +00:00
|
|
|
|
{
|
2000-09-10 22:22:36 +00:00
|
|
|
|
SCM module = SCM_PACK (SCM_SMOB_DATA (eclo));
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (definep))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (SCM_EVAL_CLOSURE_INTERFACE_P (eclo))
|
|
|
|
|
|
return SCM_BOOL_F;
|
2001-06-26 15:46:40 +00:00
|
|
|
|
return scm_call_2 (SCM_VARIABLE_REF (module_make_local_var_x_var),
|
|
|
|
|
|
module, sym);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
2000-06-04 01:30:05 +00:00
|
|
|
|
else
|
2007-05-05 20:38:57 +00:00
|
|
|
|
return scm_module_variable (module, sym);
|
2000-06-04 01:30:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_standard_eval_closure, "standard-eval-closure", 1, 0, 0,
|
|
|
|
|
|
(SCM module),
|
2001-02-16 15:11:11 +00:00
|
|
|
|
"Return an eval closure for the module @var{module}.")
|
2000-06-04 01:30:05 +00:00
|
|
|
|
#define FUNC_NAME s_scm_standard_eval_closure
|
|
|
|
|
|
{
|
2000-12-08 17:32:56 +00:00
|
|
|
|
SCM_RETURN_NEWSMOB (scm_tc16_eval_closure, SCM_UNPACK (module));
|
2000-06-04 01:30:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2005-06-11 01:48:19 +00:00
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
SCM_DEFINE (scm_standard_interface_eval_closure,
|
|
|
|
|
|
"standard-interface-eval-closure", 1, 0, 0,
|
|
|
|
|
|
(SCM module),
|
|
|
|
|
|
"Return a interface eval closure for the module @var{module}. "
|
|
|
|
|
|
"Such a closure does not allow new bindings to be added.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_standard_interface_eval_closure
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_RETURN_NEWSMOB (scm_tc16_eval_closure | SCM_F_EVAL_CLOSURE_INTERFACE,
|
|
|
|
|
|
SCM_UNPACK (module));
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2009-03-30 21:20:44 -07:00
|
|
|
|
SCM_DEFINE (scm_eval_closure_module,
|
|
|
|
|
|
"eval-closure-module", 1, 0, 0,
|
|
|
|
|
|
(SCM eval_closure),
|
|
|
|
|
|
"Return the module associated with this eval closure.")
|
|
|
|
|
|
/* the idea is that eval closures are really not the way to do things, they're
|
|
|
|
|
|
superfluous given our module system. this function lets mmacros migrate away
|
|
|
|
|
|
from eval closures. */
|
|
|
|
|
|
#define FUNC_NAME s_scm_eval_closure_module
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_MAKE_VALIDATE_MSG (SCM_ARG1, eval_closure, EVAL_CLOSURE_P,
|
|
|
|
|
|
"eval-closure");
|
|
|
|
|
|
return SCM_SMOB_OBJECT (eval_closure);
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_module_lookup_closure (SCM module)
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (module))
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
else
|
|
|
|
|
|
return SCM_MODULE_EVAL_CLOSURE (module);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_current_module_lookup_closure ()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (scm_module_system_booted_p)
|
|
|
|
|
|
return scm_module_lookup_closure (scm_current_module ());
|
|
|
|
|
|
else
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-03-09 20:49:54 +01:00
|
|
|
|
SCM_SYMBOL (sym_sys_pre_modules_transformer, "%pre-modules-transformer");
|
|
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_module_transformer (SCM module)
|
|
|
|
|
|
{
|
2009-03-09 20:49:54 +01:00
|
|
|
|
if (SCM_UNLIKELY (scm_is_false (module)))
|
|
|
|
|
|
{ SCM v = scm_hashq_ref (scm_pre_modules_obarray,
|
|
|
|
|
|
sym_sys_pre_modules_transformer,
|
|
|
|
|
|
SCM_BOOL_F);
|
|
|
|
|
|
if (scm_is_false (v))
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
else
|
|
|
|
|
|
return SCM_VARIABLE_REF (v);
|
|
|
|
|
|
}
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
else
|
|
|
|
|
|
return SCM_MODULE_TRANSFORMER (module);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_current_module_transformer ()
|
|
|
|
|
|
{
|
2009-03-09 20:49:54 +01:00
|
|
|
|
return scm_module_transformer (scm_current_module ());
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2003-03-11 15:58:02 +00:00
|
|
|
|
SCM_DEFINE (scm_module_import_interface, "module-import-interface", 2, 0, 0,
|
|
|
|
|
|
(SCM module, SCM sym),
|
2007-05-05 20:38:57 +00:00
|
|
|
|
"Return the module or interface from which @var{sym} is imported "
|
|
|
|
|
|
"in @var{module}. If @var{sym} is not imported (i.e., it is not "
|
|
|
|
|
|
"defined in @var{module} or it is a module-local binding instead "
|
|
|
|
|
|
"of an imported one), then @code{#f} is returned.")
|
2003-03-11 15:58:02 +00:00
|
|
|
|
#define FUNC_NAME s_scm_module_import_interface
|
|
|
|
|
|
{
|
2007-05-05 20:38:57 +00:00
|
|
|
|
SCM var, result = SCM_BOOL_F;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
SCM_VALIDATE_SYMBOL (2, sym);
|
|
|
|
|
|
|
|
|
|
|
|
var = scm_module_variable (module, sym);
|
|
|
|
|
|
if (scm_is_true (var))
|
2003-03-11 15:58:02 +00:00
|
|
|
|
{
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* Look for the module that provides VAR. */
|
|
|
|
|
|
SCM local_var;
|
|
|
|
|
|
|
|
|
|
|
|
local_var = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym,
|
|
|
|
|
|
SCM_UNDEFINED);
|
|
|
|
|
|
if (scm_is_eq (local_var, var))
|
|
|
|
|
|
result = module;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Look for VAR among the used modules. */
|
|
|
|
|
|
SCM uses, imported_var;
|
|
|
|
|
|
|
|
|
|
|
|
for (uses = SCM_MODULE_USES (module);
|
|
|
|
|
|
scm_is_pair (uses) && scm_is_false (result);
|
|
|
|
|
|
uses = SCM_CDR (uses))
|
|
|
|
|
|
{
|
|
|
|
|
|
imported_var = scm_module_variable (SCM_CAR (uses), sym);
|
|
|
|
|
|
if (scm_is_eq (imported_var, var))
|
|
|
|
|
|
result = SCM_CAR (uses);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-03-11 15:58:02 +00:00
|
|
|
|
}
|
2007-05-05 20:38:57 +00:00
|
|
|
|
|
|
|
|
|
|
return result;
|
2003-03-11 15:58:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2008-09-29 21:36:25 +02:00
|
|
|
|
SCM_SYMBOL (sym_sys_module_public_interface, "%module-public-interface");
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_module_public_interface, "module-public-interface", 1, 0, 0,
|
|
|
|
|
|
(SCM module),
|
|
|
|
|
|
"Return the public interface of @var{module}.\n\n"
|
|
|
|
|
|
"If @var{module} has no public interface, @code{#f} is returned.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_module_public_interface
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM var;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
var = scm_module_local_variable (module, sym_sys_module_public_interface);
|
|
|
|
|
|
if (scm_is_true (var))
|
|
|
|
|
|
return SCM_VARIABLE_REF (var);
|
|
|
|
|
|
else
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
/* scm_sym2var
|
|
|
|
|
|
*
|
|
|
|
|
|
* looks up the variable bound to SYM according to PROC. PROC should be
|
|
|
|
|
|
* a `eval closure' of some module.
|
|
|
|
|
|
*
|
|
|
|
|
|
* When no binding exists, and DEFINEP is true, create a new binding
|
|
|
|
|
|
* with a initial value of SCM_UNDEFINED. Return `#f' when DEFINEP as
|
|
|
|
|
|
* false and no binding exists.
|
|
|
|
|
|
*
|
|
|
|
|
|
* When PROC is `#f', it is ignored and the binding is searched for in
|
|
|
|
|
|
* the scm_pre_modules_obarray (a `eq' hash table).
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_sym2var (SCM sym, SCM proc, SCM definep)
|
|
|
|
|
|
#define FUNC_NAME "scm_sym2var"
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM var;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_NIMP (proc))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_EVAL_CLOSURE_P (proc))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Bypass evaluator in the standard case. */
|
|
|
|
|
|
var = scm_eval_closure_lookup (proc, sym, definep);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2001-06-26 15:46:40 +00:00
|
|
|
|
var = scm_call_2 (proc, sym, definep);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM handle;
|
|
|
|
|
|
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (definep))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
var = scm_hashq_ref (scm_pre_modules_obarray, sym, SCM_BOOL_F);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
handle = scm_hashq_create_handle_x (scm_pre_modules_obarray,
|
|
|
|
|
|
sym, SCM_BOOL_F);
|
|
|
|
|
|
var = SCM_CDR (handle);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (var))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
var = scm_make_variable (SCM_UNDEFINED);
|
|
|
|
|
|
SCM_SETCDR (handle, var);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (var) && !SCM_VARIABLEP (var))
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
SCM_MISC_ERROR ("~S is not bound to a variable", scm_list_1 (sym));
|
2001-05-15 14:57:22 +00:00
|
|
|
|
|
|
|
|
|
|
return var;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_c_module_lookup (SCM module, const char *name)
|
|
|
|
|
|
{
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
return scm_module_lookup (module, scm_from_locale_symbol (name));
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_module_lookup (SCM module, SCM sym)
|
|
|
|
|
|
#define FUNC_NAME "module-lookup"
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM var;
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
|
|
|
|
|
|
var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (var))
|
2009-10-23 15:47:08 +02:00
|
|
|
|
unbound_variable (FUNC_NAME, sym);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
return var;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_c_lookup (const char *name)
|
|
|
|
|
|
{
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
return scm_lookup (scm_from_locale_symbol (name));
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_lookup (SCM sym)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM var =
|
|
|
|
|
|
scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_F);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (var))
|
2009-10-23 15:47:08 +02:00
|
|
|
|
unbound_variable (NULL, sym);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
return var;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_c_module_define (SCM module, const char *name, SCM value)
|
|
|
|
|
|
{
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
return scm_module_define (module, scm_from_locale_symbol (name), value);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_module_define (SCM module, SCM sym, SCM value)
|
|
|
|
|
|
#define FUNC_NAME "module-define"
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM var;
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
|
|
|
|
|
|
var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_T);
|
|
|
|
|
|
SCM_VARIABLE_SET (var, value);
|
|
|
|
|
|
return var;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_c_define (const char *name, SCM value)
|
|
|
|
|
|
{
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
return scm_define (scm_from_locale_symbol (name), value);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_define (SCM sym, SCM value)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM var =
|
|
|
|
|
|
scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_T);
|
|
|
|
|
|
SCM_VARIABLE_SET (var, value);
|
|
|
|
|
|
return var;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
SCM_DEFINE (scm_module_reverse_lookup, "module-reverse-lookup", 2, 0, 0,
|
|
|
|
|
|
(SCM module, SCM variable),
|
|
|
|
|
|
"Return the symbol under which @var{variable} is bound in "
|
|
|
|
|
|
"@var{module} or @var{#f} if @var{variable} is not visible "
|
|
|
|
|
|
"from @var{module}. If @var{module} is @code{#f}, then the "
|
|
|
|
|
|
"pre-module obarray is used.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_module_reverse_lookup
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM obarray;
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long i, n;
|
2001-05-15 14:57:22 +00:00
|
|
|
|
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (module))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
obarray = scm_pre_modules_obarray;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_MODULE (1, module);
|
|
|
|
|
|
obarray = SCM_MODULE_OBARRAY (module);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-09-12 15:11:09 +00:00
|
|
|
|
if (!SCM_HASHTABLE_P (obarray))
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
/* XXX - We do not use scm_hash_fold here to avoid searching the
|
|
|
|
|
|
whole obarray. We should have a scm_hash_find procedure. */
|
|
|
|
|
|
|
* hooks.c (scm_c_hook_add): Fixed bug in append mode.
* environments.c (obarray_enter, obarray_retrieve, obarray_remove,
leaf_environment_fold, obarray_remove_all): Use hashtable
accessors.
* gc.c (scm_init_storage): Moved hook initialization to
scm_storage_prehistory.
(scm_storage_prehistory): New function.
(scm_igc): Added commentary about placement of
scm_after_sweep_c_hook.
* gc-mark.c (scm_mark_all): Use hashtable accessors.
(scm_gc_mark_dependencies): Use SCM_WVECT_WEAK_KEY_P and
SCM_WVECT_WEAK_VALUE_P.
* hashtab.c, hashtab.h (scm_hash_for_each, scm_hash_map): New
functions.
(scm_vector_to_hash_table, scm_c_make_resizing_hash_table):
Removed.
(scm_make_weak_key_hash_table, scm_make_weak_value_hash_table,
scm_make_doubly_weak_hash_table): Moved here from weaks.c.
* init.c (scm_init_guile_1): Removed call to scm_init_weaks; Added
calls to scm_storage_prehistory and scm_hashtab_prehistory.
* modules.c (module-reverse-lookup): Use hashtable accessors.
* symbols.c, symbols.h (scm_i_hash_symbol): New function.
* weaks.c, weaks.h (scm_make_weak_key_alist_vector,
scm_make_weak_value_alist_vector,
scm_make_doubly_weak_alist_vector): New functions.
* weaks.c (scm_init_weaks_builtins): New function.
* weaks.h (SCM_WVECTF_WEAK_KEY, SCM_WVECTF_WEAK_VALUE,
SCM_WVECTF_NOSCAN, SCM_WVECT_WEAK_KEY_P, SCM_WVECT_WEAK_VALUE_P,
SCM_WVECT_NOSCAN_P): New macros.
* weaks.c (scm_scan_weak_vectors): Use SCM_WVECT_WEAK_KEY_P
and SCM_WVECT_WEAK_VALUE_P.
* weaks.c, weaks.h (scm_i_allocate_weak_vector): Renamed from
allocate_weak_vector and exported.
* Makefile.am (ice9_sources): Added weak-vector.scm.
* weak-vector.scm: New file.
* boot-9.scm (module-clear!): Use hash-clear!.
(module-for-each): Use hash-for-each.
(module-map): Use hash-map.
2003-02-19 15:04:51 +00:00
|
|
|
|
n = SCM_HASHTABLE_N_BUCKETS (obarray);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
for (i = 0; i < n; ++i)
|
|
|
|
|
|
{
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM ls = SCM_HASHTABLE_BUCKET (obarray, i), handle;
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (!scm_is_null (ls))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
handle = SCM_CAR (ls);
|
2006-05-09 22:11:09 +00:00
|
|
|
|
|
|
|
|
|
|
if (SCM_CAR (handle) == SCM_PACK (NULL))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* FIXME: We hit a weak pair whose car has become unreachable.
|
|
|
|
|
|
We should remove the pair in question or something. */
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_CDR (handle) == variable)
|
|
|
|
|
|
return SCM_CAR (handle);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
ls = SCM_CDR (ls);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2007-05-05 20:38:57 +00:00
|
|
|
|
/* Try the `uses' list. */
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM uses = SCM_MODULE_USES (module);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (scm_is_pair (uses))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM sym = scm_module_reverse_lookup (SCM_CAR (uses), variable);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (sym))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
return sym;
|
|
|
|
|
|
uses = SCM_CDR (uses);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_get_pre_modules_obarray, "%get-pre-modules-obarray", 0, 0, 0,
|
|
|
|
|
|
(),
|
|
|
|
|
|
"Return the obarray that is used for all new bindings before "
|
|
|
|
|
|
"the module system is booted. The first call to "
|
|
|
|
|
|
"@code{set-current-module} will boot the module system.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_get_pre_modules_obarray
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_pre_modules_obarray;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
SCM_SYMBOL (scm_sym_system_module, "system-module");
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_system_module_env_p (SCM env)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM proc = scm_env_top_level (env);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (proc))
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
return SCM_BOOL_T;
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return ((scm_is_true (scm_procedure_property (proc,
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
scm_sym_system_module)))
|
|
|
|
|
|
? SCM_BOOL_T
|
|
|
|
|
|
: SCM_BOOL_F);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_modules_prehistory ()
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_pre_modules_obarray
|
2003-02-19 16:16:46 +00:00
|
|
|
|
= scm_permanent_object (scm_c_make_hash_table (1533));
|
2001-05-15 14:57:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
1998-11-22 12:05:14 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_modules ()
|
|
|
|
|
|
{
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/modules.x"
|
2001-05-15 14:57:22 +00:00
|
|
|
|
module_make_local_var_x_var = scm_c_define ("module-make-local-var!",
|
|
|
|
|
|
SCM_UNDEFINED);
|
2000-12-08 17:32:56 +00:00
|
|
|
|
scm_tc16_eval_closure = scm_make_smob_type ("eval-closure", 0);
|
|
|
|
|
|
scm_set_smob_apply (scm_tc16_eval_closure, scm_eval_closure_lookup, 2, 0, 0);
|
2001-04-24 23:40:18 +00:00
|
|
|
|
|
|
|
|
|
|
the_module = scm_permanent_object (scm_make_fluid ());
|
1998-11-22 12:05:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
static void
|
1998-11-22 12:05:14 +00:00
|
|
|
|
scm_post_boot_init_modules ()
|
|
|
|
|
|
{
|
2001-05-15 14:57:22 +00:00
|
|
|
|
#define PERM(x) scm_permanent_object(x)
|
|
|
|
|
|
|
|
|
|
|
|
SCM module_type = SCM_VARIABLE_REF (scm_c_lookup ("module-type"));
|
* tags.h: Update tag system docs.
(scm_tc3_cons_gloc): Renamed to scm_tc3_struct. Changed all uses.
(scm_tcs_cons_gloc): Renamed to scm_tcs_struct. Changed all uses.
(SCM_ECONSP, SCM_NECONSP): Removed. Changed all uses to SCM_CONSP
or SCM_NCONSP, respectively.
* struct.c, struct.h, srcprop.c, procs.c, procprop.c, print.c,
objects.c. modules.c, goops.c, eval.c, debug.c: Changed all uses
of scm_tc3_cond_gloc and scm_tcs_cons_gloc. See above.
* print.c (scm_iprin1): Remove printing of glocs. Do not try to
tell glocs from structs.
* gc.c (scm_gc_mark, scm_gc_sweep): Remove handling of glocs.
* eval.c (scm_m_atbind): Make a list of variables, not glocs.
(scm_ceval, scm_deval): For SCM_IM_BIND, fiddle with variables
instead of with glocs.
(EVALCAR): Do not test for glocs.
(scm_lookupcar, scm_lookupcar1): Do not handle glocs in race
condition.
(scm_unmemocar): Do not handle glocs.
(scm_m_atfop): Memoize as a variable, not as a gloc.
(scm_eval_args, scm_deval_args): Do not handle glocs.
(scm_ceval, scm_deval): Likewise.
* eval.h (SCM_XEVALCAR): Do not test for glocs.
(SCM_GLOC_VAR, SCM_GLOC_VAL, SCM_GLOC_SET_VAL, SCM_GLOC_VAL_LOC):
Removed.
* debug.h, debug.c (scm_make_gloc, scm_gloc_p): Removed.
* dynwind.c (scm_swap_bindings): Likewise.
(scm_dowinds): Updated to recognize lists of variables instead of
lists of glocs.
* __scm.h (SCM_CAUTIOS, SCM_RECKLESS): Update comments.
2001-07-26 21:40:18 +00:00
|
|
|
|
scm_module_tag = (SCM_CELL_WORD_1 (module_type) + scm_tc3_struct);
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
|
|
|
|
|
|
resolve_module_var = PERM (scm_c_lookup ("resolve-module"));
|
|
|
|
|
|
process_define_module_var = PERM (scm_c_lookup ("process-define-module"));
|
|
|
|
|
|
process_use_modules_var = PERM (scm_c_lookup ("process-use-modules"));
|
|
|
|
|
|
module_export_x_var = PERM (scm_c_lookup ("module-export!"));
|
|
|
|
|
|
the_root_module_var = PERM (scm_c_lookup ("the-root-module"));
|
2007-05-05 20:38:57 +00:00
|
|
|
|
default_duplicate_binding_procedures_var =
|
|
|
|
|
|
PERM (scm_c_lookup ("default-duplicate-binding-procedures"));
|
* modules.h, modules.c: Moved around a lot of code so that
deprecated features appear at the bottom.
(root_module_lookup_closure, scm_sym_app, scm_sym_modules,
module_prefix, make_modules_in_var, beautify_user_module_x_var,
scm_the_root_module, scm_make_module, scm_ensure_user_module,
scm_load_scheme_module): Deprecated.
(scm_system_module_env_p): Return SCM_BOOL_T directly for
environments corresponding to the root module.
(convert_module_name, scm_c_resolve_module,
scm_c_call_with_current_module, scm_c_define_module,
scm_c_use_module, scm_c_export): New.
(the_root_module): New static variant of scm_the_root_module. Use
it everywhere instead of scm_the_root_module.
2001-05-19 01:22:12 +00:00
|
|
|
|
|
2000-08-11 08:44:02 +00:00
|
|
|
|
scm_module_system_booted_p = 1;
|
1998-11-22 12:05:14 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|