* module/system/base/target.scm (with-native-target): New exported
procedure.
* module/language/elisp/spec.scm: In the top-level body expression, call
'compile-and-load' within 'with-native-target' to compile native code.
* module/language/elisp/compile-tree-il.scm
(eval-when-compile, defmacro): Compile native code.
* module/system/base/compile.scm (compile-file): Pass #:to-disk? as an
option to indicate that the result will be being loaded from disk.
Perhaps a linker might want to page-align in that case.
* module/language/elisp/compile-tree-il.scm (process-options!): Accept
and ignore the #:to-file compiler option.
* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
to push-fluid, and unwind-fluids to pop-fluid. They now only work on
one fluid binding at a time.
* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
primcalls to push-fluid and pop-fluid.
(custom-throw-handler, catch, with-throw-handler): Use with-fluid*
instead of with-fluids, as with-fluids is no longer available before
psyntax is loaded.
(with-fluids): Define in Scheme in terms of with-fluid*.
* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
don't expose to Scheme.
* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
(DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
helpers, like wind and unwind.
(memoize): Memoize wind and unwind primcalls. Don't memoize dynlet to
with-fluids.
(scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.
* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>. Add cases for
primcalls to push-fluid and pop-fluid in compile-glil.scm and
effects.scm.
* module/language/tree-il/peval.scm (peval): Factor out
with-temporaries; probably a bad idea, but works for now. Factor out
make-begin0 (a better idea). Inline primcalls to with-fluid*, and
remove dynlet cases.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
Add with-fluid*.
* module/language/elisp/bindings.scm (bindings): Add `function-bindings'
field.
(make-bindings): Initialize the `function-bindings' field.
(get-function-binding, with-function-bindings): New functions.
(access-variable, reference-variable, set-variable!): Remove the
`module' argument and only handle references to the value cell. All
callers changed. Callers passing `function-slot' as the module changed
to use the corresponding functions for the function cell instead.
(access-function, reference-function, set-function!): New procedures.
(compile-flet, compile-labels): Use `with-function-bindings' instead
of `with-lexical-bindings'.
* module/language/elisp/boot.el (lexical-let, lexical-let*): New macros.
* module/language/elisp/compile-tree-il.scm (bind-lexically?): Remove
the check for a `lexical' flag, since `lexical-let' and `lexical-let*'
are no longer special operators.
(compile-lexical-let, compile-lexical-let*): Remove.
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
* module/language/elisp/compile-tree-il.scm (process-let-bindings):
Remove.
(parse-let-binding, parse-flet-binding): New procedures.
(generate-let, generate-let*): Now takes an association list mapping
symbols to values for the `bindings' argument.
(compile-let, compile-let*, compile-lexical-let)
(compile-lexical-let*): Parse the bindings list with
`parse-let-binding'.
(compile-flet): Parse the bindings list with `parse-flet-binding'.
* module/language/elisp/compile-tree-il.scm (bind-lexically?): Accept a
new `decls' argument and check it for `lexical' declarations.
Establish the same kind of binding whether or not a lexical binding
for `sym' exists, whereas previously the presence of a lexical binding
would cause newly-established bindings to be lexical bindings as well.
(split-let-bindings): Remove. All callers changed.
(generate-let, generate-let*, compile-lambda): Pass the declarations
list to `bind-lexically?'.
* test-suite/tests/elisp-compiler.test: Explicitly disable the
lexical-binding mode. Add `lexical' declarations where necessary.
* module/language/elisp/compile-tree-il.scm (parse-body-1, parse-body)
(parse-lambda-body, parse-declaration): New procedures.
(generate-let, generate-let*): Use `parse-body'.
(compile-lambda): Use `parse-lambda-body'.
* module/language/elisp/compile-tree-il.scm (split-lambda-arguments):
Remove.
(parse-lambda-list, make-simple-lambda): New procedures.
(compile-lambda): Use `parse-lambda-list' and `make-simple-lambda'.
Set empty rest arguments to the empty list instead of `#nil'.
* test-suite/tests/elisp-compiler.test ("Lambda Expressions")["rest
argument"]: Use Elisp `null' instead of a Scheme equality check.
* module/language/elisp/boot.el (null, consp, listp, car, cdr)
(make-symbol, signal): Use `%funcall' instead of `funcall' or `fset'.
(symbolp, symbol-function, eval): Use `%funcall', since `funcall' now
calls these functions.
(functionp, %indirect-function): New functions.
(funcall): Define in terms of `%funcall' and `%indirect-function'.
(apply): New function. Previously defined in
"module/language/elisp/runtime/subrs.scm".
(fset): If `definition' is not a function, set the function cell of
`symbol' to an falias for `definition'.
* module/language/elisp/falias.scm: New file.
* module/language/elisp/subrs.scm: Remove file.
(apply): Remove. Now defined in "boot.el".
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
* module/Makefile.am: Update.
* module/language/elisp/compile-tree-il.scm (find-operator): Assume that
`name' is lexically bound.
* module/language/elisp/runtime.scm (symbol-fbound?, fmakunbound!):
Assume that `symbol' is lexically bound.
(defspecial): Bind special operators lexically.
* module/language/elisp/compile-tree-il (compile-pair): Use `function'
to perform functional evaluation. Previously, if the operator of a
compound form was not a symbol, the operator would be evaluated as a
normal expression. This happened to work only because there is a
`lambda' macro. The compiler will now signal an error if the operator
is neither a function name nor a lambda expression.
* test-suite/tests/elisp-compiler.test ("Lambda Expressions")["optional
argument"]: Remove an erroneous use of `function' in the function
position.
* language/elisp/compile-tree-il.scm (compile-lambda): Add a `meta'
argument for the procedure's properties.
(compile-function, compile-defmacro, compile-defun): Update
accordingly, passing a `name' property to `compile-lambda' where
possible.
* module/language/elisp/compile-tree-il.scm: (always-lexical): Remove.
All uses changed.
(with-added-symbols): Remove.
(compile-with-always-lexical): Remove.
(process-options!): Remove support for the `#:always-lexical' option.
* module/language/elisp/runtime/function-slot.scm: Update import and
re-export lists.
* test-suite/tests/elisp-compiler.test: Remove or update tests using
`with-always-lexical'.
* module/language/elisp/bindings.scm (global?): New function.
* module/language/elisp/compile-tree-il.scm (lexical-binding): New
variable.
(bind-lexically?): If lexical binding is enabled, bind lexically
unless a special binding exists.
(compile-%set-lexical-binding-mode): New function.
* module/language/elisp/lexer.scm (lexical-binding-regexp): New
variable.
(lex): Return a `set-lexical-binding-mode!' token if a comment is
found while reading the first line.
* module/language/elisp/parser.scm (get-expression): Add support for
`set-lexical-binding-mode!' tokens.
* module/language/elisp/runtime/function-slot.scm: Import and re-export
the `%set-lexical-binding-mode' special form.
* test-suite/tests/elisp-compiler.test
("Let and Let*")["lambda args inside lexical-let"]: Update.
* module/language/elisp/bindings.scm: Use `(srfi srfi-9)'.
(bindings-type): Remove low-level record type definition and replace
with...
(bindings): ...this, an SRFI-9 record type. All uses changed.
(mark-global-needed!): Rename to...
(mark-global!): ...this. All callers changed.
(map-globals-needed): Rename to...
(map-globals): ...this. All callers changed.
* module/language/elisp/compile-tree-il.scm (generate-let)
(generate-let*, compile-lambda, compile-with-added-symbols)
(compile-progn, compile-if): Return nil if the form's body is empty.
* test-suite/tests/elisp-compiler.test ("Sequencing")["empty progn"]:
New test.
("Conditionals")["if with no else"]: New test.
("Let and Let*")["empty let, empty let*"]: New test.
("Lambda Expressions")["empty lambda"]: New test.
* libguile/expand.h:
* module/language/tree-il.scm: Rename "sequence" to "seq", and instead
of taking a list of expressions, take a head and a tail.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/spec.scm:
* module/language/elisp/compile-tree-il.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/eval.scm:
* libguile/memoize.h:
* libguile/memoize.c:
* libguile/expand.c:
* libguile/eval.c: Adapt to the new seq format.
* module/language/elisp/compile-tree-il.scm (access-variable)
(reference-variable, set-variable!): Handle globally-bound non-special
variables.
(bind-lexically?): Create lexical bindings for flet and flet*.
* module/language/elisp/runtime.scm (reference-variable, set-variable!):
Handle globally-bound non-special variables.
(built-in-func): Set the variable directly instead of storing the
function in a fluid.
* module/language/elisp/runtime/subrs.scm (funcall): Call apply
directly.
* test-suite/tests/elisp-compiler.test ("Function Definitions")["flet
and flet*"]:
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/compile-tree-il.scm (reference-with-check)
(compile-without-void-checks, want-void-check?): Remove.
(compile-function, compile-pair): Use `reference-variable' instead of
`reference-with-check'.
(compile-defvar): Only set `sym' if `sym' is not bound to a bound
fluid, rather than requiring that its value be `void'.
(process-options!): Remove `#:disable-void-check' option handling.
* module/language/elisp/runtime.scm (void)
(reference-variable-with-check): Remove.
(ensure-fluid!): Use an undefined fluid as the initial value for
global variables.
* module/language/elisp/runtime/function-slot.scm (without-void-checks):
Don't import or re-export.
* module/language/elisp/runtime/macros.scm (prog1, cond, or, dolist):
Don't use `without-void-checks'.
* module/language/elisp/runtime/subrs.scm (symbol-value)
(symbol-function, apply): Use `reference-variable' instead of
`reference-variable-with-check'.
(makunbound, fmakunbound, boundp, fboundp): Unset the variable's fluid
(or the variable itself, if it isn't bound to a fluid).
* test-suite/tests/elisp-compiler.test ("Variable
Setting/Referencing")["disabled void check (all)", "disabled void
check (symbol list)", "without-void-checks"]: Remove.
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/compile-tree-il.scm (compile-function): the form
`(function SYMBOL)' evaluates to the functional value of SYMBOL
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/compile-tree-il.scm (compile-setq): Return nil
if called with no arguments, and set the last variable to nil if its
value is omitted.
Signed-off-by: Andy Wingo <wingo@pobox.com>
Use #{`}#, #{,}# and #{,@}# as the quasiquote, unquote and
unquote-splicing operators, respectively. Previously they were named
escaping.
* module/language/elisp/compile-tree-il.scm (unquote?): Change "\," to
"#{,}#".
(unquote-splicing): Change "\,@" to "#{,@}#".
(#{compile-`}#): Rename from #{compile-\`}#.
* module/language/elisp/runtime/function-slot.scm: Import #{compile-`}#
instead of #{compile-\`}#, and re-export as #{`}# instead of as
#{\`}#.
* module/language/elisp/parser.scm (quotation-symbols):
* test-suite/tests/elisp-compiler.test ("Eval", "Quotation"):
* test-suite/tests/elisp-reader.test ("Parser"): Change "\`", "\,", and
"\,@" to "#{`}#", "#{,}#" and "#{,@}#", respectively.
If the function slot of a symbol contains a pair with `special-operator'
in the car and a procedure in the cdr, the procedure is called to
compile the form to Tree-IL. This is similar to other Emacs Lisp
implementations, in which special operators are subrs.
* module/language/elisp/compile-tree-il.scm: Restructured to store
special operator definitions in the function slot. Import `(language
elisp runtime)' for `defspecial'. Export special operators so that
`(language elisp runtime function-slot)' can re-export them.
(backquote?): Removed; the backquote symbol is defined as a special
operator, so it's no longer used in `compile-pair'.
(is-macro?, get-macro): Replaced by `find-operator'.
(find-operator): New procedure.
(compile-progn, compile-if, compile-defconst, compile-defvar,
compile-setq, compile-let, compile-lexical-let, compile-flet,
compile-let*, compile-lexical-let*, compile-flet*,
compile-without-void-checks, compile-with-always-lexical,
compile-guile-ref, compile-guile-primitive, compile-while,
compile-function, compile-defmacro, compile-defun, #{compile-`}#,
compile-quote): New special operators with definitions taken from the
pmatch form in `compile-pair'. There is no special operator `lambda';
it is now a macro, as in other Elisp implementations.
(compile-pair): Instead of directly compiling special forms, check for
a special operator object in the function slot.
* module/language/elisp/runtime.scm: Export `defspecial'.
(make-id): New function.
(built-in-macro): Prefix macros with `macro-'.
(defspecial): New syntax.
* module/language/elisp/runtime/function-slot.scm: Import and re-export
special operators. Rename imported special operators and macros to
remove prefixes. Re-export new macro `lambda'.
* module/language/elisp/runtime/macros.scm (macro-lambda): New Elisp
macro.
* module/language/elisp/compile-tree-il.scm (ensuring-globals): New
procedure.
(define-macro!): Remove.
(compile-pair) <defmacro>: Make macro available at runtime, not only
during compilation.
(compile-tree-il): Use `ensuring-globals'.
Guile Emacs Lisp previously kept macros in a separate macro slot; now
macros are stored as macro objects in the function slot for
compatibility with other implementations.
* module/language/elisp/compile-tree-il.scm (macro-slot): Remove.
(is-macro?): Check that the argument is a symbol. Now-unnecessary
check removed in `compile-tree-il'.
(macro?, define-macro!, get-macro): Store macro definitions in the
function slot, not in a separate macro slot.
* module/language/elisp/runtime.scm (built-in-macro): Wrap the macro
function in a macro object (i.e., cons the symbol `macro' onto it).
* module/language/elisp/runtime/function-slot.scm: Move contents to
"subrs.scm". Re-export function and macro definitions instead of
defining functions directly in this module.
* module/language/elisp/runtime/macro-slot.scm: Move contents to
"macros.scm" and remove.
* module/language/elisp/runtime/macros.scm: New file containing macro
definitions from "macro-slot.scm".
* module/language/elisp/runtime/subrs.scm: New file containing function
definitions from "function-slot.scm".
Signed-off-by: Andy Wingo <wingo@pobox.com>
* module/language/elisp/compile-tree-il.scm (compile-lambda): Use
Tree-IL's support for optional arguments.
(process-optionals, process-rest): Remove.
Signed-off-by: Andy Wingo <wingo@pobox.com>