diff options
| author | Jim Blandy | 1991-07-12 04:00:11 +0000 |
|---|---|---|
| committer | Jim Blandy | 1991-07-12 04:00:11 +0000 |
| commit | a6e3fa71a42d4305f69186e20a9d46fbbb177a1e (patch) | |
| tree | 00cf5235ca0de914d50e29ce0976ded400c97cf1 /src/eval.c | |
| parent | a726e0d12ccb1c49ca1f3e1fbe64addea9b7d3b4 (diff) | |
| download | emacs-a6e3fa71a42d4305f69186e20a9d46fbbb177a1e.tar.gz emacs-a6e3fa71a42d4305f69186e20a9d46fbbb177a1e.zip | |
*** empty log message ***
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 87 |
1 files changed, 55 insertions, 32 deletions
diff --git a/src/eval.c b/src/eval.c index c0aafa88d86..4a8ebf7938b 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -454,13 +454,12 @@ and input is currently coming from the keyboard (not in keyboard macro).") | |||
| 454 | (if interpreted) or the frame of byte-code (if called from | 454 | (if interpreted) or the frame of byte-code (if called from |
| 455 | compiled function). */ | 455 | compiled function). */ |
| 456 | btp = backtrace_list; | 456 | btp = backtrace_list; |
| 457 | if (! XTYPE (*btp->function) == Lisp_Compiled) | 457 | if (XTYPE (*btp->function) != Lisp_Compiled) |
| 458 | btp = btp->next; | 458 | btp = btp->next; |
| 459 | for (; | 459 | while (btp |
| 460 | btp && (btp->nargs == UNEVALLED | 460 | && (btp->nargs == UNEVALLED || EQ (*btp->function, Qbytecode))) |
| 461 | || EQ (*btp->function, Qbytecode)); | 461 | btp = btp->next; |
| 462 | btp = btp->next) | 462 | |
| 463 | {} | ||
| 464 | /* btp now points at the frame of the innermost function | 463 | /* btp now points at the frame of the innermost function |
| 465 | that DOES eval its args. | 464 | that DOES eval its args. |
| 466 | If it is a built-in function (such as load or eval-region) | 465 | If it is a built-in function (such as load or eval-region) |
| @@ -1445,12 +1444,12 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, | |||
| 1445 | args_left = Fcdr (args_left); | 1444 | args_left = Fcdr (args_left); |
| 1446 | gcpro3.nvars = argnum; | 1445 | gcpro3.nvars = argnum; |
| 1447 | } | 1446 | } |
| 1448 | UNGCPRO; | ||
| 1449 | 1447 | ||
| 1450 | backtrace.args = vals; | 1448 | backtrace.args = vals; |
| 1451 | backtrace.nargs = XINT (numargs); | 1449 | backtrace.nargs = XINT (numargs); |
| 1452 | 1450 | ||
| 1453 | val = (*XSUBR (fun)->function) (XINT (numargs), vals); | 1451 | val = (*XSUBR (fun)->function) (XINT (numargs), vals); |
| 1452 | UNGCPRO; | ||
| 1454 | goto done; | 1453 | goto done; |
| 1455 | } | 1454 | } |
| 1456 | 1455 | ||
| @@ -1552,6 +1551,7 @@ Thus, (apply '+ 1 2 '(3 4)) returns 10.") | |||
| 1552 | register Lisp_Object spread_arg; | 1551 | register Lisp_Object spread_arg; |
| 1553 | register Lisp_Object *funcall_args; | 1552 | register Lisp_Object *funcall_args; |
| 1554 | Lisp_Object fun; | 1553 | Lisp_Object fun; |
| 1554 | struct gcpro gcpro1; | ||
| 1555 | 1555 | ||
| 1556 | fun = args [0]; | 1556 | fun = args [0]; |
| 1557 | funcall_args = 0; | 1557 | funcall_args = 0; |
| @@ -1568,7 +1568,7 @@ Thus, (apply '+ 1 2 '(3 4)) returns 10.") | |||
| 1568 | return Ffuncall (nargs, args); | 1568 | return Ffuncall (nargs, args); |
| 1569 | } | 1569 | } |
| 1570 | 1570 | ||
| 1571 | numargs = nargs - 2 + numargs; | 1571 | numargs += nargs - 2; |
| 1572 | 1572 | ||
| 1573 | while (XTYPE (fun) == Lisp_Symbol) | 1573 | while (XTYPE (fun) == Lisp_Symbol) |
| 1574 | { | 1574 | { |
| @@ -1595,14 +1595,21 @@ Thus, (apply '+ 1 2 '(3 4)) returns 10.") | |||
| 1595 | * sizeof (Lisp_Object)); | 1595 | * sizeof (Lisp_Object)); |
| 1596 | for (i = numargs; i < XSUBR (fun)->max_args;) | 1596 | for (i = numargs; i < XSUBR (fun)->max_args;) |
| 1597 | funcall_args[++i] = Qnil; | 1597 | funcall_args[++i] = Qnil; |
| 1598 | GCPRO1 (*funcall_args); | ||
| 1599 | gcpro1.nvars = 1 + XSUBR (fun)->max_args; | ||
| 1598 | } | 1600 | } |
| 1599 | } | 1601 | } |
| 1600 | funcall: | 1602 | funcall: |
| 1601 | /* We add 1 to numargs because funcall_args includes the | 1603 | /* We add 1 to numargs because funcall_args includes the |
| 1602 | function itself as well as its arguments. */ | 1604 | function itself as well as its arguments. */ |
| 1603 | if (!funcall_args) | 1605 | if (!funcall_args) |
| 1604 | funcall_args = (Lisp_Object *) alloca ((1 + numargs) | 1606 | { |
| 1605 | * sizeof (Lisp_Object)); | 1607 | funcall_args = (Lisp_Object *) alloca ((1 + numargs) |
| 1608 | * sizeof (Lisp_Object)); | ||
| 1609 | GCPRO1 (*funcall_args); | ||
| 1610 | gcpro1.nvars = 1 + numargs; | ||
| 1611 | } | ||
| 1612 | |||
| 1606 | bcopy (args, funcall_args, nargs * sizeof (Lisp_Object)); | 1613 | bcopy (args, funcall_args, nargs * sizeof (Lisp_Object)); |
| 1607 | /* Spread the last arg we got. Its first element goes in | 1614 | /* Spread the last arg we got. Its first element goes in |
| 1608 | the slot that it used to occupy, hence this value of I. */ | 1615 | the slot that it used to occupy, hence this value of I. */ |
| @@ -1612,8 +1619,8 @@ Thus, (apply '+ 1 2 '(3 4)) returns 10.") | |||
| 1612 | funcall_args [i++] = XCONS (spread_arg)->car; | 1619 | funcall_args [i++] = XCONS (spread_arg)->car; |
| 1613 | spread_arg = XCONS (spread_arg)->cdr; | 1620 | spread_arg = XCONS (spread_arg)->cdr; |
| 1614 | } | 1621 | } |
| 1615 | 1622 | ||
| 1616 | return Ffuncall (numargs + 1, funcall_args); | 1623 | RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args)); |
| 1617 | } | 1624 | } |
| 1618 | 1625 | ||
| 1619 | /* Apply fn to arg */ | 1626 | /* Apply fn to arg */ |
| @@ -1621,17 +1628,22 @@ Lisp_Object | |||
| 1621 | apply1 (fn, arg) | 1628 | apply1 (fn, arg) |
| 1622 | Lisp_Object fn, arg; | 1629 | Lisp_Object fn, arg; |
| 1623 | { | 1630 | { |
| 1631 | struct gcpro gcpro1; | ||
| 1632 | |||
| 1633 | GCPRO1 (fn); | ||
| 1624 | if (NULL (arg)) | 1634 | if (NULL (arg)) |
| 1625 | return Ffuncall (1, &fn); | 1635 | RETURN_UNGCPRO (Ffuncall (1, &fn)); |
| 1636 | gcpro1.nvars = 2; | ||
| 1626 | #ifdef NO_ARG_ARRAY | 1637 | #ifdef NO_ARG_ARRAY |
| 1627 | { | 1638 | { |
| 1628 | Lisp_Object args[2]; | 1639 | Lisp_Object args[2]; |
| 1629 | args[0] = fn; | 1640 | args[0] = fn; |
| 1630 | args[1] = arg; | 1641 | args[1] = arg; |
| 1631 | return Fapply (2, args); | 1642 | gcpro1.var = args; |
| 1643 | RETURN_UNGCPRO (Fapply (2, args)); | ||
| 1632 | } | 1644 | } |
| 1633 | #else /* not NO_ARG_ARRAY */ | 1645 | #else /* not NO_ARG_ARRAY */ |
| 1634 | return Fapply (2, &fn); | 1646 | RETURN_UNGCPRO (Fapply (2, &fn)); |
| 1635 | #endif /* not NO_ARG_ARRAY */ | 1647 | #endif /* not NO_ARG_ARRAY */ |
| 1636 | } | 1648 | } |
| 1637 | 1649 | ||
| @@ -1640,7 +1652,10 @@ Lisp_Object | |||
| 1640 | call0 (fn) | 1652 | call0 (fn) |
| 1641 | Lisp_Object fn; | 1653 | Lisp_Object fn; |
| 1642 | { | 1654 | { |
| 1643 | return Ffuncall (1, &fn); | 1655 | struct gcpro gcpro1; |
| 1656 | |||
| 1657 | GCPRO1 (fn); | ||
| 1658 | RETURN_UNGCPRO (Ffuncall (1, &fn)); | ||
| 1644 | } | 1659 | } |
| 1645 | 1660 | ||
| 1646 | /* Call function fn with argument arg */ | 1661 | /* Call function fn with argument arg */ |
| @@ -1649,13 +1664,19 @@ Lisp_Object | |||
| 1649 | call1 (fn, arg) | 1664 | call1 (fn, arg) |
| 1650 | Lisp_Object fn, arg; | 1665 | Lisp_Object fn, arg; |
| 1651 | { | 1666 | { |
| 1667 | struct gcpro gcpro1; | ||
| 1652 | #ifdef NO_ARG_ARRAY | 1668 | #ifdef NO_ARG_ARRAY |
| 1653 | Lisp_Object args[2]; | 1669 | Lisp_Object args[2]; |
| 1670 | |||
| 1654 | args[0] = fn; | 1671 | args[0] = fn; |
| 1655 | args[1] = arg; | 1672 | args[1] = arg; |
| 1656 | return Ffuncall (2, args); | 1673 | GCPRO1 (args[0]); |
| 1674 | gcpro1.nvars = 2; | ||
| 1675 | RETURN_UNGCPRO (Ffuncall (2, args)); | ||
| 1657 | #else /* not NO_ARG_ARRAY */ | 1676 | #else /* not NO_ARG_ARRAY */ |
| 1658 | return Ffuncall (2, &fn); | 1677 | GCPRO1 (fn); |
| 1678 | gcpro1.nvars = 2; | ||
| 1679 | RETURN_UNGCPRO (Ffuncall (2, &fn)); | ||
| 1659 | #endif /* not NO_ARG_ARRAY */ | 1680 | #endif /* not NO_ARG_ARRAY */ |
| 1660 | } | 1681 | } |
| 1661 | 1682 | ||
| @@ -1665,14 +1686,19 @@ Lisp_Object | |||
| 1665 | call2 (fn, arg, arg1) | 1686 | call2 (fn, arg, arg1) |
| 1666 | Lisp_Object fn, arg, arg1; | 1687 | Lisp_Object fn, arg, arg1; |
| 1667 | { | 1688 | { |
| 1689 | struct gcpro gcpro1; | ||
| 1668 | #ifdef NO_ARG_ARRAY | 1690 | #ifdef NO_ARG_ARRAY |
| 1669 | Lisp_Object args[3]; | 1691 | Lisp_Object args[3]; |
| 1670 | args[0] = fn; | 1692 | args[0] = fn; |
| 1671 | args[1] = arg; | 1693 | args[1] = arg; |
| 1672 | args[2] = arg1; | 1694 | args[2] = arg1; |
| 1673 | return Ffuncall (3, args); | 1695 | GCPRO1 (args[0]); |
| 1696 | gcpro1.nvars = 3; | ||
| 1697 | RETURN_UNGCPRO (Ffuncall (3, args)); | ||
| 1674 | #else /* not NO_ARG_ARRAY */ | 1698 | #else /* not NO_ARG_ARRAY */ |
| 1675 | return Ffuncall (3, &fn); | 1699 | GCPRO1 (fn); |
| 1700 | gcpro1.nvars = 3; | ||
| 1701 | RETURN_UNGCPRO (Ffuncall (3, &fn)); | ||
| 1676 | #endif /* not NO_ARG_ARRAY */ | 1702 | #endif /* not NO_ARG_ARRAY */ |
| 1677 | } | 1703 | } |
| 1678 | 1704 | ||
| @@ -1682,15 +1708,20 @@ Lisp_Object | |||
| 1682 | call3 (fn, arg, arg1, arg2) | 1708 | call3 (fn, arg, arg1, arg2) |
| 1683 | Lisp_Object fn, arg, arg1, arg2; | 1709 | Lisp_Object fn, arg, arg1, arg2; |
| 1684 | { | 1710 | { |
| 1711 | struct gcpro gcpro1; | ||
| 1685 | #ifdef NO_ARG_ARRAY | 1712 | #ifdef NO_ARG_ARRAY |
| 1686 | Lisp_Object args[4]; | 1713 | Lisp_Object args[4]; |
| 1687 | args[0] = fn; | 1714 | args[0] = fn; |
| 1688 | args[1] = arg; | 1715 | args[1] = arg; |
| 1689 | args[2] = arg1; | 1716 | args[2] = arg1; |
| 1690 | args[3] = arg2; | 1717 | args[3] = arg2; |
| 1691 | return Ffuncall (4, args); | 1718 | GCPRO1 (args[0]); |
| 1719 | gcpro1.nvars = 4; | ||
| 1720 | RETURN_UNGCPRO (Ffuncall (4, args)); | ||
| 1692 | #else /* not NO_ARG_ARRAY */ | 1721 | #else /* not NO_ARG_ARRAY */ |
| 1693 | return Ffuncall (4, &fn); | 1722 | GCPRO1 (fn); |
| 1723 | gcpro1.nvars = 4; | ||
| 1724 | RETURN_UNGCPRO (Ffuncall (4, &fn)); | ||
| 1694 | #endif /* not NO_ARG_ARRAY */ | 1725 | #endif /* not NO_ARG_ARRAY */ |
| 1695 | } | 1726 | } |
| 1696 | 1727 | ||
| @@ -1712,15 +1743,7 @@ Thus, (funcall 'cons 'x 'y) returns (x . y).") | |||
| 1712 | 1743 | ||
| 1713 | QUIT; | 1744 | QUIT; |
| 1714 | if (consing_since_gc > gc_cons_threshold) | 1745 | if (consing_since_gc > gc_cons_threshold) |
| 1715 | { | 1746 | Fgarbage_collect (); |
| 1716 | struct gcpro gcpro1; | ||
| 1717 | |||
| 1718 | /* The backtrace protects the arguments for the rest of the function. */ | ||
| 1719 | GCPRO1 (*args); | ||
| 1720 | gcpro1.nvars = nargs; | ||
| 1721 | Fgarbage_collect (); | ||
| 1722 | UNGCPRO; | ||
| 1723 | } | ||
| 1724 | 1747 | ||
| 1725 | if (++lisp_eval_depth > max_lisp_eval_depth) | 1748 | if (++lisp_eval_depth > max_lisp_eval_depth) |
| 1726 | { | 1749 | { |