1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 20:30:28 +02:00

fix nil handling in the vm

* libguile/vm-i-scheme.c (not, not-not): Treat nil as false.
  (null?, not-null?): Treat nil as null.

* libguile/vm-i-system.c (br-if, br-if-not): Treat nil as false.
  (br-if-null, br-if-not-null): Treat nil as null.
This commit is contained in:
Mark H Weaver 2009-10-27 22:59:22 +01:00 committed by Andy Wingo
parent 45f4cbdf12
commit b02b05332f
2 changed files with 8 additions and 8 deletions

View file

@ -32,13 +32,13 @@
VM_DEFINE_FUNCTION (100, not, "not", 1) VM_DEFINE_FUNCTION (100, not, "not", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (SCM_BOOL (SCM_FALSEP (x))); RETURN (SCM_BOOL (scm_is_false_or_nil (x)));
} }
VM_DEFINE_FUNCTION (101, not_not, "not-not", 1) VM_DEFINE_FUNCTION (101, not_not, "not-not", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (SCM_BOOL (!SCM_FALSEP (x))); RETURN (SCM_BOOL (!scm_is_false_or_nil (x)));
} }
VM_DEFINE_FUNCTION (102, eq, "eq?", 2) VM_DEFINE_FUNCTION (102, eq, "eq?", 2)
@ -56,13 +56,13 @@ VM_DEFINE_FUNCTION (103, not_eq, "not-eq?", 2)
VM_DEFINE_FUNCTION (104, nullp, "null?", 1) VM_DEFINE_FUNCTION (104, nullp, "null?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (SCM_BOOL (SCM_NULLP (x))); RETURN (SCM_BOOL (scm_is_null_or_nil (x)));
} }
VM_DEFINE_FUNCTION (105, not_nullp, "not-null?", 1) VM_DEFINE_FUNCTION (105, not_nullp, "not-null?", 1)
{ {
ARGS1 (x); ARGS1 (x);
RETURN (SCM_BOOL (!SCM_NULLP (x))); RETURN (SCM_BOOL (!scm_is_null_or_nil (x)));
} }
VM_DEFINE_FUNCTION (106, eqv, "eqv?", 2) VM_DEFINE_FUNCTION (106, eqv, "eqv?", 2)

View file

@ -475,12 +475,12 @@ VM_DEFINE_INSTRUCTION (34, br, "br", 3, 0, 0)
VM_DEFINE_INSTRUCTION (35, br_if, "br-if", 3, 0, 0) VM_DEFINE_INSTRUCTION (35, br_if, "br-if", 3, 0, 0)
{ {
BR (!SCM_FALSEP (*sp)); BR (scm_is_true_and_not_nil (*sp));
} }
VM_DEFINE_INSTRUCTION (36, br_if_not, "br-if-not", 3, 0, 0) VM_DEFINE_INSTRUCTION (36, br_if_not, "br-if-not", 3, 0, 0)
{ {
BR (SCM_FALSEP (*sp)); BR (scm_is_false_or_nil (*sp));
} }
VM_DEFINE_INSTRUCTION (37, br_if_eq, "br-if-eq", 3, 0, 0) VM_DEFINE_INSTRUCTION (37, br_if_eq, "br-if-eq", 3, 0, 0)
@ -497,12 +497,12 @@ VM_DEFINE_INSTRUCTION (38, br_if_not_eq, "br-if-not-eq", 3, 0, 0)
VM_DEFINE_INSTRUCTION (39, br_if_null, "br-if-null", 3, 0, 0) VM_DEFINE_INSTRUCTION (39, br_if_null, "br-if-null", 3, 0, 0)
{ {
BR (SCM_NULLP (*sp)); BR (scm_is_null_or_nil (*sp));
} }
VM_DEFINE_INSTRUCTION (40, br_if_not_null, "br-if-not-null", 3, 0, 0) VM_DEFINE_INSTRUCTION (40, br_if_not_null, "br-if-not-null", 3, 0, 0)
{ {
BR (!SCM_NULLP (*sp)); BR (!scm_is_null_or_nil (*sp));
} }