diff --git a/src/c/compiler.d b/src/c/compiler.d index 3a15e314b..d0c20f2d8 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -425,6 +425,8 @@ c_new_env(struct cl_compiler_env *new_c_env, cl_object env) for (env = ENV->variables; !Null(env); env = CDR(env)) { cl_object record = CAR(env); if (SYMBOLP(CAR(record)) && CADR(record) != @'si::symbol-macro') { + continue; + } else { ENV->lexical_level = 1; break; } diff --git a/src/cmp/cmpeval.lsp b/src/cmp/cmpeval.lsp index 89445a4ce..9d02344b1 100644 --- a/src/cmp/cmpeval.lsp +++ b/src/cmp/cmpeval.lsp @@ -48,7 +48,7 @@ (cond ((setq fd (get-sysprop fname 'c1special)) (funcall fd args)) ((c1call-local fname args)) ((setq fd (sch-local-macro fname)) - (c1expr (cmp-expand-macro fd fname args))) + (c1expr (cmp-expand-macro fd (list* fname args)))) ((and (setq fd (get-sysprop fname 'C1)) (inline-possible fname)) (funcall fd args)) @@ -59,11 +59,11 @@ (inline-possible fname) (let ((success nil)) (multiple-value-setq (fd success) - (cmp-expand-compiler-macro fd fname args)) + (cmp-expand-macro fd (list* fname args))) success)) (c1expr fd)) ((setq fd (macro-function fname)) - (c1expr (cmp-expand-macro fd fname args))) + (c1expr (cmp-expand-macro fd (list* fname args)))) ((and (setq fd (get-sysprop fname 'SYS::STRUCTURE-ACCESS)) (inline-possible fname) ;;; Structure hack. diff --git a/src/cmp/cmptop.lsp b/src/cmp/cmptop.lsp index 464f0206c..2ec33a729 100644 --- a/src/cmp/cmptop.lsp +++ b/src/cmp/cmptop.lsp @@ -44,14 +44,14 @@ (inline-possible fun) (let ((success nil)) (multiple-value-setq (fd success) - (cmp-expand-compiler-macro fd fun args)) + (cmp-expand-macro fd form)) success)) (t1expr* fd)) ((setq fd (macro-function fun)) - (t1expr* (cmp-expand-macro fd fun (cdr form)))) + (t1expr* (cmp-expand-macro fd form))) ((and (setq fd (assoc fun *funs*)) (eq (second fd) 'MACRO)) - (t1expr* (cmp-expand-macro (third fd) fun (cdr form)))) + (t1expr* (cmp-expand-macro (third fd) form))) (t (t1ordinary form)) ))))) diff --git a/src/cmp/cmputil.lsp b/src/cmp/cmputil.lsp index c85972be7..925fc3719 100644 --- a/src/cmp/cmputil.lsp +++ b/src/cmp/cmputil.lsp @@ -144,14 +144,13 @@ ~%;;; You are recommended to compile again.~%" form)))))) -(defun cmp-expand-macro (fd fname args) - (let ((env (and *funs* (cons nil *funs*))) - (throw-flag t)) +(defun cmp-expand-macro (fd form &optional (env (and *funs* (cons nil *funs*)))) + (let ((throw-flag t)) (unwind-protect - (prog1 - (cmp-toplevel-eval - `(funcall *macroexpand-hook* ',fd ',(cons fname args) ',env)) - (setq throw-flag nil)) + (let ((new-form (cmp-toplevel-eval + `(funcall *macroexpand-hook* ',fd ',form ',env)))) + (setq throw-flag nil) + (values new-form (not (eql new-form form)))) (if throw-flag (let ((*print-case* :upcase)) (print-current-form) @@ -160,22 +159,6 @@ ~%;;; You are recommended to compile again.~%" fname)))))) -(defun cmp-expand-compiler-macro (fd fname args) - (let ((env (and *funs* (cons nil *funs*))) - (throw-flag t) - (form (cons fname args))) - (unwind-protect - (let ((new-form (cmp-toplevel-eval `(funcall *macroexpand-hook* ',fd ',form ',env)))) - (setq throw-flag nil) - (values new-form (not (eql new-form form)))) - (when throw-flag - (let ((*print-case* :upcase)) - (print-current-form) - (format t - "~&;;; The macro form (~s ...) was not expanded successfully.~ - ~%;;; You are recommended to compile again.~%" - fname)))))) - (defun cmp-toplevel-eval (form) (let* #-:CCL