aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/alloc.c13
-rw-r--r--src/bytecode.c71
3 files changed, 59 insertions, 31 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c638e1fa4b5..e8b3c57fbd0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12011-03-06 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * bytecode.c (exec_byte_code): Remove old lexical binding slot handling
4 and replace it with the a integer args-desc handling.
5 * eval.c (funcall_lambda): Adjust arglist test accordingly.
6
12011-03-01 Stefan Monnier <monnier@iro.umontreal.ca> 72011-03-01 Stefan Monnier <monnier@iro.umontreal.ca>
2 8
3 * callint.c (quotify_arg): Simplify the logic. 9 * callint.c (quotify_arg): Simplify the logic.
diff --git a/src/alloc.c b/src/alloc.c
index 0b7db7ec627..c7fd8747f74 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2945,10 +2945,19 @@ usage: (vector &rest OBJECTS) */)
2945 2945
2946DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0, 2946DEFUN ("make-byte-code", Fmake_byte_code, Smake_byte_code, 4, MANY, 0,
2947 doc: /* Create a byte-code object with specified arguments as elements. 2947 doc: /* Create a byte-code object with specified arguments as elements.
2948The arguments should be the arglist, bytecode-string, constant vector, 2948The arguments should be the ARGLIST, bytecode-string BYTE-CODE, constant
2949stack size, (optional) doc string, and (optional) interactive spec. 2949vector CONSTANTS, maximum stack size DEPTH, (optional) DOCSTRING,
2950and (optional) INTERACTIVE-SPEC.
2950The first four arguments are required; at most six have any 2951The first four arguments are required; at most six have any
2951significance. 2952significance.
2953The ARGLIST can be either like the one of `lambda', in which case the arguments
2954will be dynamically bound before executing the byte code, or it can be an
2955integer of the form NNNNNNNRMMMMMMM where the 7bit MMMMMMM specifies the
2956minimum number of arguments, the 7-bit NNNNNNN specifies the maximum number
2957of arguments (ignoring &rest) and the R bit specifies whether there is a &rest
2958argument to catch the left-over arguments. If such an integer is used, the
2959arguments will not be dynamically bound but will be instead pushed on the
2960stack before executing the byte-code.
2952usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) 2961usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */)
2953 (register int nargs, Lisp_Object *args) 2962 (register int nargs, Lisp_Object *args)
2954{ 2963{
diff --git a/src/bytecode.c b/src/bytecode.c
index 9693a5a9196..dbab02886e2 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -502,37 +502,50 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
502 stacke = stack.bottom - 1 + XFASTINT (maxdepth); 502 stacke = stack.bottom - 1 + XFASTINT (maxdepth);
503#endif 503#endif
504 504
505 if (! NILP (args_template)) 505 if (INTEGERP (args_template))
506 /* We should push some arguments on the stack. */
507 { 506 {
508 Lisp_Object at; 507 int at = XINT (args_template);
509 int pushed = 0, optional = 0; 508 int rest = at & 128;
510 509 int mandatory = at & 127;
511 for (at = args_template; CONSP (at); at = XCDR (at)) 510 int nonrest = at >> 8;
512 if (EQ (XCAR (at), Qand_optional)) 511 eassert (mandatory <= nonrest);
513 optional = 1; 512 if (nargs <= nonrest)
514 else if (EQ (XCAR (at), Qand_rest)) 513 {
515 { 514 int i;
516 PUSH (pushed < nargs 515 for (i = 0 ; i < nargs; i++, args++)
517 ? Flist (nargs - pushed, args) 516 PUSH (*args);
518 : Qnil); 517 if (nargs < mandatory)
519 pushed = nargs; 518 /* Too few arguments. */
520 at = Qnil; 519 Fsignal (Qwrong_number_of_arguments,
521 break; 520 Fcons (Fcons (make_number (mandatory),
522 } 521 rest ? Qand_rest : make_number (nonrest)),
523 else if (pushed < nargs) 522 Fcons (make_number (nargs), Qnil)));
524 { 523 else
525 PUSH (*args++); 524 {
526 pushed++; 525 for (; i < nonrest; i++)
527 } 526 PUSH (Qnil);
528 else if (optional) 527 if (rest)
529 PUSH (Qnil); 528 PUSH (Qnil);
530 else 529 }
531 break; 530 }
532 531 else if (rest)
533 if (pushed != nargs || !NILP (at)) 532 {
533 int i;
534 for (i = 0 ; i < nonrest; i++, args++)
535 PUSH (*args);
536 PUSH (Flist (nargs - nonrest, args));
537 }
538 else
539 /* Too many arguments. */
534 Fsignal (Qwrong_number_of_arguments, 540 Fsignal (Qwrong_number_of_arguments,
535 Fcons (args_template, Fcons (make_number (nargs), Qnil))); 541 Fcons (Fcons (make_number (mandatory),
542 make_number (nonrest)),
543 Fcons (make_number (nargs), Qnil)));
544 }
545 else if (! NILP (args_template))
546 /* We should push some arguments on the stack. */
547 {
548 error ("Unknown args template!");
536 } 549 }
537 550
538 while (1) 551 while (1)