diff options
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | libguile/vm-engine.c | 6 | ||||
-rw-r--r-- | libguile/vm-i-system.c | 32 |
3 files changed, 34 insertions, 5 deletions
@@ -63,6 +63,7 @@ For fixes or providing information which led to a fix: Judy Hawkins Jon Herron Sam Hocevar + Kevin Holmnes Patrick Horgan Ales Hvezda Stefan Israelsson Tampe diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 341dbc8a7..20d9ed2c8 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -153,6 +153,12 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs) scm_list_1 (finish_args), SCM_BOOL_F); goto vm_error; + vm_error_not_a_variable: + SYNC_ALL (); + scm_error (scm_arg_type_key, func_name, "Not a variable: ~S", + scm_list_1 (finish_args), scm_list_1 (finish_args)); + goto vm_error; + vm_error_apply_to_non_list: SYNC_ALL (); scm_error (scm_arg_type_key, "apply", "Apply to non-list: ~S", diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c index 5b40c1b9d..57712cabd 100644 --- a/libguile/vm-i-system.c +++ b/libguile/vm-i-system.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001,2008,2009,2010 Free Software Foundation, Inc. +/* Copyright (C) 2001,2008,2009,2010,2011 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 License @@ -300,7 +300,17 @@ VM_DEFINE_INSTRUCTION (25, variable_ref, "variable-ref", 0, 1, 1) { SCM x = *sp; - if (SCM_UNLIKELY (!VARIABLE_BOUNDP (x))) + /* We don't use ASSERT_VARIABLE or ASSERT_BOUND_VARIABLE here because, + unlike in top-variable-ref, it really isn't an internal assertion + that can be optimized out -- the variable could be coming directly + from the user. */ + if (SCM_UNLIKELY (!SCM_VARIABLEP (x))) + { + func_name = "variable-ref"; + finish_args = x; + goto vm_error_not_a_variable; + } + else if (SCM_UNLIKELY (!VARIABLE_BOUNDP (x))) { SCM var_name; @@ -320,10 +330,16 @@ VM_DEFINE_INSTRUCTION (25, variable_ref, "variable-ref", 0, 1, 1) VM_DEFINE_INSTRUCTION (26, variable_bound, "variable-bound?", 0, 1, 1) { - if (VARIABLE_BOUNDP (*sp)) - *sp = SCM_BOOL_T; + SCM x = *sp; + + if (SCM_UNLIKELY (!SCM_VARIABLEP (x))) + { + func_name = "variable-bound?"; + finish_args = x; + goto vm_error_not_a_variable; + } else - *sp = SCM_BOOL_F; + *sp = scm_from_bool (VARIABLE_BOUNDP (x)); NEXT; } @@ -398,6 +414,12 @@ VM_DEFINE_INSTRUCTION (30, long_local_set, "long-local-set", 2, 1, 0) VM_DEFINE_INSTRUCTION (31, variable_set, "variable-set", 0, 2, 0) { + if (SCM_UNLIKELY (!SCM_VARIABLEP (sp[0]))) + { + func_name = "variable-set!"; + finish_args = sp[0]; + goto vm_error_not_a_variable; + } VARIABLE_SET (sp[0], sp[-1]); DROPN (2); NEXT; |