mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-08 18:40:23 +02:00
unbound fluids
* libguile/fluids.c (scm_make_undefined_fluid, scm_fluid_unset_x) (scm_fluid_bound_p): New functions. (fluid_ref): New function; like scm_fluid_ref, but will not throw an error for unbound fluids. (scm_fluid_ref, swap_fluid): Use `fluid_ref'. * libguile/fluids.h (scm_make_undefined_fluid, scm_fluid_unset_x) (scm_fluid_bound_p): New prototypes. * libguile/vm-i-system.c (fluid_ref): If fluid is unbound, jump to `vm_error_unbound_fluid'. * libguile/vm-engine.c (VM_NAME)[vm_error_unbound_fluid]: New error message. * test-suite/tests/fluids.test ("unbound fluids")["fluid-ref of unbound fluid", "fluid-bound? of bound fluid", "fluid-bound? of unbound fluid", "unbound fluids can be set", "bound fluids can be unset"]: New tests.
This commit is contained in:
parent
5cfb903459
commit
7f9041c80c
5 changed files with 90 additions and 13 deletions
|
@ -1594,7 +1594,7 @@ VM_DEFINE_INSTRUCTION (91, unwind_fluids, "unwind-fluids", 0, 0, 0)
|
|||
VM_DEFINE_INSTRUCTION (92, fluid_ref, "fluid-ref", 0, 1, 1)
|
||||
{
|
||||
size_t num;
|
||||
SCM fluids;
|
||||
SCM fluids, val;
|
||||
|
||||
CHECK_UNDERFLOW ();
|
||||
fluids = SCM_I_DYNAMIC_STATE_FLUIDS (dynstate);
|
||||
|
@ -1606,7 +1606,15 @@ VM_DEFINE_INSTRUCTION (92, fluid_ref, "fluid-ref", 0, 1, 1)
|
|||
*sp = scm_fluid_ref (*sp);
|
||||
}
|
||||
else
|
||||
*sp = SCM_SIMPLE_VECTOR_REF (fluids, num);
|
||||
{
|
||||
val = SCM_SIMPLE_VECTOR_REF (fluids, num);
|
||||
if (val == SCM_UNDEFINED)
|
||||
{
|
||||
finish_args = scm_list_1 (*sp);
|
||||
goto vm_error_unbound_fluid;
|
||||
}
|
||||
*sp = val;
|
||||
}
|
||||
|
||||
NEXT;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue