diff options
| author | Andrea Corallo | 2020-11-29 15:11:38 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-11-29 15:11:38 +0100 |
| commit | 6523b8401519a29ca0aefaf44c3dfa36f681f64e (patch) | |
| tree | a691422921ad1287fdeade2128efed4c59c14e8d /src/eval.c | |
| parent | 2e0256e0a02edad129e0af1ea97b9e263c5d83fb (diff) | |
| parent | 38ed05f49fcfe7c6d6908041010881a04a7ff6b1 (diff) | |
| download | emacs-6523b8401519a29ca0aefaf44c3dfa36f681f64e.tar.gz emacs-6523b8401519a29ca0aefaf44c3dfa36f681f64e.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 09e12bd3752..aa1775b3ada 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -690,6 +690,10 @@ default_toplevel_binding (Lisp_Object symbol) | |||
| 690 | case SPECPDL_UNWIND_EXCURSION: | 690 | case SPECPDL_UNWIND_EXCURSION: |
| 691 | case SPECPDL_UNWIND_VOID: | 691 | case SPECPDL_UNWIND_VOID: |
| 692 | case SPECPDL_BACKTRACE: | 692 | case SPECPDL_BACKTRACE: |
| 693 | #ifdef HAVE_MODULES | ||
| 694 | case SPECPDL_MODULE_RUNTIME: | ||
| 695 | case SPECPDL_MODULE_ENVIRONMENT: | ||
| 696 | #endif | ||
| 693 | case SPECPDL_LET_LOCAL: | 697 | case SPECPDL_LET_LOCAL: |
| 694 | break; | 698 | break; |
| 695 | 699 | ||
| @@ -700,6 +704,49 @@ default_toplevel_binding (Lisp_Object symbol) | |||
| 700 | return binding; | 704 | return binding; |
| 701 | } | 705 | } |
| 702 | 706 | ||
| 707 | /* Look for a lexical-binding of SYMBOL somewhere up the stack. | ||
| 708 | This will only find bindings created with interpreted code, since once | ||
| 709 | compiled names of lexical variables are basically gone anyway. */ | ||
| 710 | static bool | ||
| 711 | lexbound_p (Lisp_Object symbol) | ||
| 712 | { | ||
| 713 | union specbinding *pdl = specpdl_ptr; | ||
| 714 | while (pdl > specpdl) | ||
| 715 | { | ||
| 716 | switch ((--pdl)->kind) | ||
| 717 | { | ||
| 718 | case SPECPDL_LET_DEFAULT: | ||
| 719 | case SPECPDL_LET: | ||
| 720 | if (EQ (specpdl_symbol (pdl), Qinternal_interpreter_environment)) | ||
| 721 | { | ||
| 722 | Lisp_Object env = specpdl_old_value (pdl); | ||
| 723 | if (CONSP (env) && !NILP (Fassq (symbol, env))) | ||
| 724 | return true; | ||
| 725 | } | ||
| 726 | break; | ||
| 727 | |||
| 728 | case SPECPDL_UNWIND: | ||
| 729 | case SPECPDL_UNWIND_ARRAY: | ||
| 730 | case SPECPDL_UNWIND_PTR: | ||
| 731 | case SPECPDL_UNWIND_INT: | ||
| 732 | case SPECPDL_UNWIND_INTMAX: | ||
| 733 | case SPECPDL_UNWIND_EXCURSION: | ||
| 734 | case SPECPDL_UNWIND_VOID: | ||
| 735 | case SPECPDL_BACKTRACE: | ||
| 736 | #ifdef HAVE_MODULES | ||
| 737 | case SPECPDL_MODULE_RUNTIME: | ||
| 738 | case SPECPDL_MODULE_ENVIRONMENT: | ||
| 739 | #endif | ||
| 740 | case SPECPDL_LET_LOCAL: | ||
| 741 | break; | ||
| 742 | |||
| 743 | default: | ||
| 744 | emacs_abort (); | ||
| 745 | } | ||
| 746 | } | ||
| 747 | return false; | ||
| 748 | } | ||
| 749 | |||
| 703 | DEFUN ("default-toplevel-value", Fdefault_toplevel_value, Sdefault_toplevel_value, 1, 1, 0, | 750 | DEFUN ("default-toplevel-value", Fdefault_toplevel_value, Sdefault_toplevel_value, 1, 1, 0, |
| 704 | doc: /* Return SYMBOL's toplevel default value. | 751 | doc: /* Return SYMBOL's toplevel default value. |
| 705 | "Toplevel" means outside of any let binding. */) | 752 | "Toplevel" means outside of any let binding. */) |
| @@ -735,6 +782,15 @@ This is like `defvar' and `defconst' but without affecting the variable's | |||
| 735 | value. */) | 782 | value. */) |
| 736 | (Lisp_Object symbol, Lisp_Object doc) | 783 | (Lisp_Object symbol, Lisp_Object doc) |
| 737 | { | 784 | { |
| 785 | if (!XSYMBOL (symbol)->u.s.declared_special | ||
| 786 | && lexbound_p (symbol)) | ||
| 787 | /* This test tries to catch the situation where we do | ||
| 788 | (let ((<foo-var> ...)) ...(<foo-function> ...)....) | ||
| 789 | and where the `foo` package only gets loaded when <foo-function> | ||
| 790 | is called, so the outer `let` incorrectly made the binding lexical | ||
| 791 | because the <foo-var> wasn't yet declared as dynamic at that point. */ | ||
| 792 | error ("Defining as dynamic an already lexical var"); | ||
| 793 | |||
| 738 | XSYMBOL (symbol)->u.s.declared_special = true; | 794 | XSYMBOL (symbol)->u.s.declared_special = true; |
| 739 | if (!NILP (doc)) | 795 | if (!NILP (doc)) |
| 740 | { | 796 | { |
| @@ -3512,6 +3568,15 @@ record_unwind_protect_void (void (*function) (void)) | |||
| 3512 | } | 3568 | } |
| 3513 | 3569 | ||
| 3514 | void | 3570 | void |
| 3571 | record_unwind_protect_module (enum specbind_tag kind, void *ptr) | ||
| 3572 | { | ||
| 3573 | specpdl_ptr->kind = kind; | ||
| 3574 | specpdl_ptr->unwind_ptr.func = NULL; | ||
| 3575 | specpdl_ptr->unwind_ptr.arg = ptr; | ||
| 3576 | grow_specpdl (); | ||
| 3577 | } | ||
| 3578 | |||
| 3579 | void | ||
| 3515 | rebind_for_thread_switch (void) | 3580 | rebind_for_thread_switch (void) |
| 3516 | { | 3581 | { |
| 3517 | union specbinding *bind; | 3582 | union specbinding *bind; |
| @@ -3561,6 +3626,14 @@ do_one_unbind (union specbinding *this_binding, bool unwinding, | |||
| 3561 | break; | 3626 | break; |
| 3562 | case SPECPDL_BACKTRACE: | 3627 | case SPECPDL_BACKTRACE: |
| 3563 | break; | 3628 | break; |
| 3629 | #ifdef HAVE_MODULES | ||
| 3630 | case SPECPDL_MODULE_RUNTIME: | ||
| 3631 | finalize_runtime_unwind (this_binding->unwind_ptr.arg); | ||
| 3632 | break; | ||
| 3633 | case SPECPDL_MODULE_ENVIRONMENT: | ||
| 3634 | finalize_environment_unwind (this_binding->unwind_ptr.arg); | ||
| 3635 | break; | ||
| 3636 | #endif | ||
| 3564 | case SPECPDL_LET: | 3637 | case SPECPDL_LET: |
| 3565 | { /* If variable has a trivial value (no forwarding), and isn't | 3638 | { /* If variable has a trivial value (no forwarding), and isn't |
| 3566 | trapped, we can just set it. */ | 3639 | trapped, we can just set it. */ |
| @@ -3891,6 +3964,10 @@ backtrace_eval_unrewind (int distance) | |||
| 3891 | case SPECPDL_UNWIND_INTMAX: | 3964 | case SPECPDL_UNWIND_INTMAX: |
| 3892 | case SPECPDL_UNWIND_VOID: | 3965 | case SPECPDL_UNWIND_VOID: |
| 3893 | case SPECPDL_BACKTRACE: | 3966 | case SPECPDL_BACKTRACE: |
| 3967 | #ifdef HAVE_MODULES | ||
| 3968 | case SPECPDL_MODULE_RUNTIME: | ||
| 3969 | case SPECPDL_MODULE_ENVIRONMENT: | ||
| 3970 | #endif | ||
| 3894 | break; | 3971 | break; |
| 3895 | case SPECPDL_LET: | 3972 | case SPECPDL_LET: |
| 3896 | { /* If variable has a trivial value (no forwarding), we can | 3973 | { /* If variable has a trivial value (no forwarding), we can |
| @@ -4026,6 +4103,10 @@ NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'. | |||
| 4026 | case SPECPDL_UNWIND_EXCURSION: | 4103 | case SPECPDL_UNWIND_EXCURSION: |
| 4027 | case SPECPDL_UNWIND_VOID: | 4104 | case SPECPDL_UNWIND_VOID: |
| 4028 | case SPECPDL_BACKTRACE: | 4105 | case SPECPDL_BACKTRACE: |
| 4106 | #ifdef HAVE_MODULES | ||
| 4107 | case SPECPDL_MODULE_RUNTIME: | ||
| 4108 | case SPECPDL_MODULE_ENVIRONMENT: | ||
| 4109 | #endif | ||
| 4029 | break; | 4110 | break; |
| 4030 | 4111 | ||
| 4031 | default: | 4112 | default: |
| @@ -4072,6 +4153,14 @@ mark_specpdl (union specbinding *first, union specbinding *ptr) | |||
| 4072 | } | 4153 | } |
| 4073 | break; | 4154 | break; |
| 4074 | 4155 | ||
| 4156 | #ifdef HAVE_MODULES | ||
| 4157 | case SPECPDL_MODULE_RUNTIME: | ||
| 4158 | break; | ||
| 4159 | case SPECPDL_MODULE_ENVIRONMENT: | ||
| 4160 | mark_module_environment (pdl->unwind_ptr.arg); | ||
| 4161 | break; | ||
| 4162 | #endif | ||
| 4163 | |||
| 4075 | case SPECPDL_LET_DEFAULT: | 4164 | case SPECPDL_LET_DEFAULT: |
| 4076 | case SPECPDL_LET_LOCAL: | 4165 | case SPECPDL_LET_LOCAL: |
| 4077 | mark_object (specpdl_where (pdl)); | 4166 | mark_object (specpdl_where (pdl)); |