1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

make late-variable-{ref,set} work before module system boot

* libguile/vm-i-system.c (late-variable-ref, late-variable-set): If the
  module system isn't booted, do a simple scm_lookup. In the -ref case,
  actually cache the variable location (doh!).
This commit is contained in:
Andy Wingo 2008-09-02 00:33:31 -07:00
parent 1b79210aa2
commit 3aabb7b793

View file

@ -269,15 +269,24 @@ VM_DEFINE_INSTRUCTION (late_variable_ref, "late-variable-ref", 1, 0, 1)
if (!SCM_VARIABLEP (pair_or_var))
{
SYNC_REGISTER ();
/* either one of these calls might longjmp */
SCM mod = scm_resolve_module (SCM_CAR (pair_or_var));
pair_or_var = scm_module_lookup (mod, SCM_CDR (pair_or_var));
OBJECT_SET (objnum, pair_or_var);
if (SCM_LIKELY (scm_module_system_booted_p))
{
/* either one of these calls might longjmp */
SCM mod = scm_resolve_module (SCM_CAR (pair_or_var));
pair_or_var = scm_module_lookup (mod, SCM_CDR (pair_or_var));
}
else
{
pair_or_var = scm_lookup (SCM_CDR (pair_or_var));
}
if (!VARIABLE_BOUNDP (pair_or_var))
{
err_args = SCM_LIST1 (pair_or_var);
goto vm_error_unbound;
}
OBJECT_SET (objnum, pair_or_var);
}
PUSH (VARIABLE_REF (pair_or_var));
@ -325,9 +334,17 @@ VM_DEFINE_INSTRUCTION (late_variable_set, "late-variable-set", 1, 1, 0)
if (!SCM_VARIABLEP (pair_or_var))
{
SYNC_BEFORE_GC ();
SCM mod = scm_resolve_module (SCM_CAR (pair_or_var));
/* module_lookup might longjmp */
pair_or_var = scm_module_lookup (mod, SCM_CDR (pair_or_var));
if (SCM_LIKELY (scm_module_system_booted_p))
{
/* either one of these calls might longjmp */
SCM mod = scm_resolve_module (SCM_CAR (pair_or_var));
pair_or_var = scm_module_lookup (mod, SCM_CDR (pair_or_var));
}
else
{
pair_or_var = scm_lookup (SCM_CDR (pair_or_var));
}
OBJECT_SET (objnum, pair_or_var);
}