-/* Copyright (C) 1998,2000,2001,2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998,2000,2001,2002, 2003, 2004 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
return scm_c_with_fluid (the_module, module, func, data);
}
+void
+scm_frame_current_module (SCM module)
+{
+ scm_frame_fluid (the_module, module);
+}
/*
convert "A B C" to scheme list (A B C)
ptr++;
if (ptr > name)
{
- *tail = scm_cons (scm_mem2symbol (name, ptr-name), SCM_EOL);
+ SCM sym = scm_from_locale_symboln (name, ptr-name);
+ *tail = scm_cons (sym, SCM_EOL);
tail = SCM_CDRLOC (*tail);
}
name = ptr;
if (name)
{
va_list ap;
- SCM names = scm_cons (scm_str2symbol (name), SCM_EOL);
+ SCM names = scm_cons (scm_from_locale_symbol (name), SCM_EOL);
SCM *tail = SCM_CDRLOC (names);
va_start (ap, name);
while (1)
const char *n = va_arg (ap, const char *);
if (n == NULL)
break;
- *tail = scm_cons (scm_str2symbol (n), SCM_EOL);
+ *tail = scm_cons (scm_from_locale_symbol (n), SCM_EOL);
tail = SCM_CDRLOC (*tail);
}
va_end (ap);
SCM
scm_env_top_level (SCM env)
{
- while (SCM_CONSP (env))
+ while (scm_is_pair (env))
{
SCM car_env = SCM_CAR (env);
- if (!SCM_CONSP (car_env) && !SCM_FALSEP (scm_procedure_p (car_env)))
+ if (!scm_is_pair (car_env) && scm_is_true (scm_procedure_p (car_env)))
return car_env;
env = SCM_CDR (env);
}
SCM
scm_lookup_closure_module (SCM proc)
{
- if (SCM_FALSEP (proc))
+ if (scm_is_false (proc))
return the_root_module ();
else if (SCM_EVAL_CLOSURE_P (proc))
return SCM_PACK (SCM_SMOB_DATA (proc));
else
{
SCM mod = scm_procedure_property (proc, sym_module);
- if (SCM_FALSEP (mod))
+ if (scm_is_false (mod))
mod = the_root_module ();
return mod;
}
module_variable (SCM module, SCM sym)
{
#define SCM_BOUND_THING_P(b) \
- (!SCM_FALSEP (b))
+ (scm_is_true (b))
/* 1. Check module obarray */
SCM b = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym, SCM_UNDEFINED);
return b;
{
SCM binder = SCM_MODULE_BINDER (module);
- if (!SCM_FALSEP (binder))
+ if (scm_is_true (binder))
/* 2. Custom binder */
{
b = scm_call_3 (binder, module, sym, SCM_BOOL_F);
{
/* 3. Search the use list */
SCM uses = SCM_MODULE_USES (module);
- while (SCM_CONSP (uses))
+ while (scm_is_pair (uses))
{
b = module_variable (SCM_CAR (uses), sym);
if (SCM_BOUND_THING_P (b))
scm_eval_closure_lookup (SCM eclo, SCM sym, SCM definep)
{
SCM module = SCM_PACK (SCM_SMOB_DATA (eclo));
- if (!SCM_FALSEP (definep))
+ if (scm_is_true (definep))
{
if (SCM_EVAL_CLOSURE_INTERFACE_P (eclo))
return SCM_BOOL_F;
}
#undef FUNC_NAME
+
+SCM_DEFINE (scm_eval_closure_module, "eval-closure-module", 1, 0, 0,
+ (SCM closure),
+ "Return the module for @var{closure}.")
+#define FUNC_NAME s_scm_eval_closure_module
+{
+ SCM_ASSERT_TYPE(SCM_EVAL_CLOSURE_P (closure), closure, SCM_ARG1, FUNC_NAME, "eval-closure");
+ return SCM_PACK (SCM_CELL_WORD_1(closure));
+}
+#undef FUNC_NAME
+
+
+
SCM_DEFINE (scm_standard_interface_eval_closure,
"standard-interface-eval-closure", 1, 0, 0,
(SCM module),
SCM
scm_module_lookup_closure (SCM module)
{
- if (SCM_FALSEP (module))
+ if (scm_is_false (module))
return SCM_BOOL_F;
else
return SCM_MODULE_EVAL_CLOSURE (module);
SCM
scm_module_transformer (SCM module)
{
- if (SCM_FALSEP (module))
+ if (scm_is_false (module))
return SCM_BOOL_F;
else
return SCM_MODULE_TRANSFORMER (module);
"")
#define FUNC_NAME s_scm_module_import_interface
{
-#define SCM_BOUND_THING_P(b) (!SCM_FALSEP (b))
+#define SCM_BOUND_THING_P(b) (scm_is_true (b))
SCM uses;
SCM_VALIDATE_MODULE (SCM_ARG1, module);
/* Search the use list */
uses = SCM_MODULE_USES (module);
- while (SCM_CONSP (uses))
+ while (scm_is_pair (uses))
{
SCM _interface = SCM_CAR (uses);
/* 1. Check module obarray */
return _interface;
{
SCM binder = SCM_MODULE_BINDER (_interface);
- if (!SCM_FALSEP (binder))
+ if (scm_is_true (binder))
/* 2. Custom binder */
{
b = scm_call_3 (binder, _interface, sym, SCM_BOOL_F);
}
/* 3. Search use list recursively. */
_interface = scm_module_import_interface (_interface, sym);
- if (!SCM_FALSEP (_interface))
+ if (scm_is_true (_interface))
return _interface;
uses = SCM_CDR (uses);
}
{
SCM handle;
- if (SCM_FALSEP (definep))
+ if (scm_is_false (definep))
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);
- if (SCM_FALSEP (var))
+ if (scm_is_false (var))
{
var = scm_make_variable (SCM_UNDEFINED);
SCM_SETCDR (handle, var);
}
}
- if (!SCM_FALSEP (var) && !SCM_VARIABLEP (var))
+ if (scm_is_true (var) && !SCM_VARIABLEP (var))
SCM_MISC_ERROR ("~S is not bound to a variable", scm_list_1 (sym));
return var;
SCM
scm_c_module_lookup (SCM module, const char *name)
{
- return scm_module_lookup (module, scm_str2symbol (name));
+ return scm_module_lookup (module, scm_from_locale_symbol (name));
}
SCM
SCM_VALIDATE_MODULE (1, module);
var = scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
- if (SCM_FALSEP (var))
+ if (scm_is_false (var))
SCM_MISC_ERROR ("unbound variable: ~S", scm_list_1 (sym));
return var;
}
SCM
scm_c_lookup (const char *name)
{
- return scm_lookup (scm_str2symbol (name));
+ return scm_lookup (scm_from_locale_symbol (name));
}
SCM
{
SCM var =
scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_F);
- if (SCM_FALSEP (var))
+ if (scm_is_false (var))
scm_misc_error ("scm_lookup", "unbound variable: ~S", scm_list_1 (sym));
return var;
}
SCM
scm_c_module_define (SCM module, const char *name, SCM value)
{
- return scm_module_define (module, scm_str2symbol (name), value);
+ return scm_module_define (module, scm_from_locale_symbol (name), value);
}
SCM
SCM
scm_c_define (const char *name, SCM value)
{
- return scm_define (scm_str2symbol (name), value);
+ return scm_define (scm_from_locale_symbol (name), value);
}
SCM
SCM obarray;
long i, n;
- if (SCM_FALSEP (module))
+ if (scm_is_false (module))
obarray = scm_pre_modules_obarray;
else
{
n = SCM_HASHTABLE_N_BUCKETS (obarray);
for (i = 0; i < n; ++i)
{
- SCM ls = SCM_HASHTABLE_BUCKETS (obarray)[i], handle;
- while (!SCM_NULLP (ls))
+ SCM ls = SCM_HASHTABLE_BUCKET (obarray, i), handle;
+ while (!scm_is_null (ls))
{
handle = SCM_CAR (ls);
if (SCM_CDR (handle) == variable)
*/
{
SCM uses = SCM_MODULE_USES (module);
- while (SCM_CONSP (uses))
+ while (scm_is_pair (uses))
{
SCM sym = scm_module_reverse_lookup (SCM_CAR (uses), variable);
- if (!SCM_FALSEP (sym))
+ if (scm_is_true (sym))
return sym;
uses = SCM_CDR (uses);
}
scm_system_module_env_p (SCM env)
{
SCM proc = scm_env_top_level (env);
- if (SCM_FALSEP (proc))
+ if (scm_is_false (proc))
return SCM_BOOL_T;
- return ((!SCM_FALSEP (scm_procedure_property (proc,
+ return ((scm_is_true (scm_procedure_property (proc,
scm_sym_system_module)))
? SCM_BOOL_T
: SCM_BOOL_F);