mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 04:40:29 +02:00
be more like the interpreter in signalling wrong-num-args
* libguile/vm-engine.c: Call scm_wrong_num_args in the wrong-num-args case, to be more like the interpreter. * libguile/vm-engine.h (ASSERT): New macro. * libguile/vm-i-system.c (apply, goto/apply): Assert that nargs >= 2, because the compiler should always feed us correct instructions. (call/cc): If no values are returned to the continuation, signal no_values instead of wrong_num_args.
This commit is contained in:
parent
7e91e01dd8
commit
9a8cc8e7f7
3 changed files with 15 additions and 7 deletions
|
@ -151,8 +151,9 @@ vm_run (SCM vm, SCM program, SCM args)
|
||||||
goto vm_error;
|
goto vm_error;
|
||||||
|
|
||||||
vm_error_wrong_num_args:
|
vm_error_wrong_num_args:
|
||||||
err_msg = scm_from_locale_string ("VM: Wrong number of arguments");
|
/* nargs and program are valid */
|
||||||
err_args = SCM_EOL;
|
scm_wrong_num_args (program);
|
||||||
|
/* shouldn't get here */
|
||||||
goto vm_error;
|
goto vm_error;
|
||||||
|
|
||||||
vm_error_wrong_type_apply:
|
vm_error_wrong_type_apply:
|
||||||
|
|
|
@ -127,6 +127,15 @@
|
||||||
* Cache/Sync
|
* Cache/Sync
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define ENABLE_ASSERTIONS
|
||||||
|
|
||||||
|
#ifdef ENABLE_ASSERTIONS
|
||||||
|
# define ASSERT(condition) if (SCM_UNLIKELY (!(condition))) abort()
|
||||||
|
#else
|
||||||
|
# define ASSERT(condition)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define CACHE_REGISTER() \
|
#define CACHE_REGISTER() \
|
||||||
{ \
|
{ \
|
||||||
ip = vp->ip; \
|
ip = vp->ip; \
|
||||||
|
|
|
@ -840,8 +840,7 @@ VM_DEFINE_INSTRUCTION (apply, "apply", 1, -1, 1)
|
||||||
POP (ls);
|
POP (ls);
|
||||||
|
|
||||||
nargs = FETCH ();
|
nargs = FETCH ();
|
||||||
if (nargs < 2)
|
ASSERT (nargs >= 2);
|
||||||
goto vm_error_wrong_num_args;
|
|
||||||
|
|
||||||
len = scm_ilength (ls);
|
len = scm_ilength (ls);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
|
@ -861,8 +860,7 @@ VM_DEFINE_INSTRUCTION (goto_apply, "goto/apply", 1, -1, 1)
|
||||||
POP (ls);
|
POP (ls);
|
||||||
|
|
||||||
nargs = FETCH ();
|
nargs = FETCH ();
|
||||||
if (nargs < 2)
|
ASSERT (nargs >= 2);
|
||||||
goto vm_error_wrong_num_args;
|
|
||||||
|
|
||||||
len = scm_ilength (ls);
|
len = scm_ilength (ls);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
|
@ -895,7 +893,7 @@ VM_DEFINE_INSTRUCTION (call_cc, "call/cc", 0, 1, 1)
|
||||||
SCM values;
|
SCM values;
|
||||||
values = scm_struct_ref (cont, SCM_INUM0);
|
values = scm_struct_ref (cont, SCM_INUM0);
|
||||||
if (SCM_NULLP (values))
|
if (SCM_NULLP (values))
|
||||||
goto vm_error_wrong_num_args;
|
goto vm_error_no_values;
|
||||||
/* non-tail context does not accept multiple values? */
|
/* non-tail context does not accept multiple values? */
|
||||||
PUSH (SCM_CAR (values));
|
PUSH (SCM_CAR (values));
|
||||||
NEXT;
|
NEXT;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue