1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

15149 commits

Author SHA1 Message Date
BT Templeton
85b3dd6cc2 signal an error for uncaught throws
* module/language/elisp/boot.el (%catch): New variable.

  (catch): Bind `%catch' to `t' during the evaluation of `body'. Call
  `throw' instead of signalling an exception directly.

  (throw): Signal a `no-catch' error if there is no `catch' to throw to.
2012-02-03 18:53:50 -05:00
BT Templeton
8fb678718c catch' in terms of condition-case'
* module/language/elisp/boot.el (throw): Define an `error-conditions'
  property for this symbol.

  (catch): Define in terms of `condition-case' instead of using Guile
  exceptions directly.

  (throw): Signal a `throw' condition instead of throwing a Guile
  exception directly.
2012-02-03 18:53:50 -05:00
BT Templeton
ce9b7cc22c standard error symbols
* module/language/elisp/boot.el (error, wrong-type-argument, no-catch,
  invalid-function): Define `error-conditions' properties for these
  standard error symbols.
2012-02-03 18:53:50 -05:00
BT Templeton
76c50ec52e `%plist-member' fix
* module/language/elisp/boot.el (%plist-member): Use recursion to avoid
  using `catch' and `throw'.
2012-02-03 18:53:50 -05:00
BT Templeton
5950f674bf condition-case
* module/language/elisp/boot.el (signal): Accept only two arguments, and
  throw an `elisp-condition' exception instead of an `elisp-error'
  exception.
  (condition-case): New macro.
2012-02-03 18:53:50 -05:00
BT Templeton
df9cd3b447 elisp `member' subrs
* module/language/elisp/boot.el (%member, member, memql, memq): New
  functions.
2012-02-03 18:53:50 -05:00
BT Templeton
c7e0d2f81c use `dynlet' for dynamic binding
* module/language/elisp/compile-tree-il.scm (let-dynamic): Remove. All
  callers changed to use `dynlet' instead.
2012-02-03 18:53:50 -05:00
BT Templeton
c64c51ebb0 inline generate-let' and generate-let*'
* module/language/elisp/compile-tree-il.scm (generate-let, compile-let):
  Inline the former into the latter.
  (generate-let*, compile-let*): Likewise.
2012-02-03 18:53:50 -05:00
BT Templeton
6bb004c435 define `flet' directly
* module/language/elisp/compile-tree-il.scm (compile-flet): Compile
  `flet' directly instead of using `generate-let'.
2012-02-03 18:53:50 -05:00
BT Templeton
9083c48d37 lexical binding macros
* 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.
2012-02-03 18:53:50 -05:00
BT Templeton
13f022c9f7 use `lexical' declarations in "boot.el"
* module/language/elisp/boot.el (prog1, cond, or, catch): Use `let' with
  `lexical' declarations instead of `lexical-let'.
  (%plist-put): Use `let' instead of `lexical-let', since "boot.el" now
  uses lexical binding by default.
2012-02-03 18:53:50 -05:00
BT Templeton
9b90b45398 elisp `while' macro
* module/language/elisp/compile-tree-il.scm (compile-while): Remove.

* module/language/elisp/boot.el (while): New macro.

* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:50 -05:00
BT Templeton
1c2f9636dc elisp `labels'
* module/language/elisp/compile-tree-il.scm (compile-labels): New
  special operator.

* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:50 -05:00
BT Templeton
0e5b7e74e4 fix `flet' syntax
* 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'.
2012-02-03 18:53:50 -05:00
BT Templeton
f6e0a4a60c elisp binding declarations
* 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.
2012-02-03 18:53:50 -05:00
BT Templeton
805b821189 declaration parsing
* 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'.
2012-02-03 18:53:50 -05:00
BT Templeton
1631817977 elisp lambda list parsing
* 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.
2012-02-03 18:53:49 -05:00
BT Templeton
b05ca4abb9 elisp function subrs
* 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.
2012-02-03 18:53:49 -05:00
BT Templeton
35724ee1dc remove dynamic function binding
* 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.
2012-02-03 18:53:49 -05:00
BT Templeton
0ab2a63af1 elisp nil equality
* module/language/elisp/boot.el (eq, equal): Return `#t' if both
  arguments are nil.
  (eql): New function.
2012-02-03 18:53:49 -05:00
BT Templeton
ddc9006b5d use lexical binding in boot.el
* module/language/elisp/boot.el: Use lexical binding.
2012-02-03 18:53:49 -05:00
BT Templeton
5bdd388cf0 remove unused code
* module/language/elisp/compile-tree-il.scm (runtime-error): Remove.
* module/language/elisp/runtime.scm (macro-error, runtime-error,
  elisp-bool, prim): Remove.
2012-02-03 18:53:49 -05:00
BT Templeton
d273b82656 new elisp special form `%funcall'
* module/language/elisp/compile-tree-il.scm (compile-%funcall): New
  procedure.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:49 -05:00
BT Templeton
5bcc6d9e70 rewrite eval' and load' in elisp
* module/language/elisp/subrs.scm (eval, load): Rewrite in Elisp and
  move to...
* module/language/elisp/boot.el (eval, load): ...here.
2012-02-03 18:53:49 -05:00
BT Templeton
48489836e2 evaluate the function position correctly
* 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.
2012-02-03 18:53:49 -05:00
BT Templeton
ed5276f827 purify elisp symbol cell modules
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/value-slot.scm: Define these as pure modules.
2012-02-03 18:53:49 -05:00
BT Templeton
d9806be144 record elisp function names
* 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.
2012-02-03 18:53:49 -05:00
BT Templeton
14b288ceb9 elisp variable aliases
* module/language/elisp/boot.el (defvaralias): New function.
2012-02-03 18:53:49 -05:00
BT Templeton
85bc6238bf simplify elisp symbol accessors
* module/language/elisp/boot.el (fset, symbol-value, symbol-function)
  (set, makunbound, fmakunbound, boundp, fboundp): Use procedures in
  `(language elisp runtime)'.
  (symbolp): New function.

* module/language/elisp/compile-tree-il.scm (set-variable!): Use
  `set-symbol-function!'.

* module/language/elisp/runtime.scm (reference-variable, set-variable!):
  Remove.
  (symbol-fluid, set-symbol-fluid!): New procedure.
  (symbol-value, set-symbol-value!, symbol-function)
  (set-symbol-function!, symbol-bound?, symbol-fbound?, makunbound!)
  (fmakunbound!): Moved from `(language elisp subrs)' and updated to
  avoid using `reference-variable' and `set-variable!'.

* module/language/elisp/runtime/subrs.scm (symbol-value)
  (symbol-function, set, fset, makunbound, fmakunbound, boundp)
  (fboundp): Move to `(language elisp runtime)'.
  (apply): Use `symbol-function'.
2012-02-03 18:53:49 -05:00
BT Templeton
12ca82caa2 elisp property lists
* module/language/elisp/boot.el (%plist-member, %plist-get, %plist-put)
  (plist-get, plist-put, plist-member, lax-plist-get, lax-plist-put)
  (symbol-plist, setplist, get, put): New functions.
  (plist-function): New variable.
2012-02-03 18:53:49 -05:00
BT Templeton
0c5fe7d804 simplify `mark-global!'
* module/language/elisp/bindings.scm (mark-global!): Use `lset-adjoin'.
2012-02-03 18:53:49 -05:00
BT Templeton
0a32abc462 remove `flet*' elisp special form
* module/language/elisp/compile-tree-il.scm (compile-flet*): Remove.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
* test-suite/tests/elisp-compiler.test
  ("Lambda Expressions")["flet and flet*"]: Remove `flet*' test.
2012-02-03 18:53:49 -05:00
BT Templeton
e5a361d1f9 remove `with-always-lexical' elisp special form
* 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'.
2012-02-03 18:53:49 -05:00
BT Templeton
03e00c5c9d emacs-compatible lexical binding
* 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.
2012-02-03 18:53:49 -05:00
BT Templeton
d4cb18ad9c remove `bind-arg-lexical?'
* module/language/elisp/compile-tree-il.scm (bind-arg-lexical?): Remove.
  All callers changed to use `bind-lexically?'.
2012-02-03 18:53:48 -05:00
BT Templeton
5fa5bf7d10 fix elisp `catch'
* module/language/elisp/boot.el (catch): Only catch exceptions of type
  `elisp-exception'.
2012-02-03 18:53:48 -05:00
BT Templeton
97d9da9a87 implement `throw' in elisp
* module/language/elisp/runtime/subrs.scm (throw): Rewrite in Elisp and
  move to...
* module/language/elisp/boot.el (throw): ...here.
2012-02-03 18:53:48 -05:00
BT Templeton
221dc803b0 rewrite `map-globals'
* module/language/elisp/bindings.scm (map-globals): Use `append-map' and
  `map' instead of explicit iteration with named `let'.
2012-02-03 18:53:48 -05:00
BT Templeton
d5da7661c8 use srfi-9 for elisp bindings records
* 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.
2012-02-03 18:53:48 -05:00
BT Templeton
d5ac6923c3 fix compilation of elisp forms with empty bodies
* 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.
2012-02-03 18:53:48 -05:00
BT Templeton
b652e2b93f rewrite elisp macros in elisp
* module/language/elisp/runtime/macros.scm: Remove.
  (macro-lambda, macro-prog1, macro-prog2, macro-cond, macro-and,
  macro-or, macro-catch, macro-unwind-protect): Rewrite in Elisp and
  move to...
* module/language/elisp/boot.el (lambda, prog1, prog2, cond, and, or,
  catch, unwind-protect): ...here.
  (eval-and-compile): New macro.
  (funcall, fset, null, consp, listp, car, cdr, make-symbol-signal):
  Wrap definitions in an `eval-and-compile' form so that they can be
  used by the rewritten macros.
* module/language/elisp/runtime.scm: Remove `built-in-macro'.
* module/language/elisp/Makefile.am: Remove
  module/language/elisp/runtime/macros.scm from `ELISP_LANG_SOURCES'.
2012-02-03 18:53:48 -05:00
BT Templeton
80687f2e4b new elisp special form `eval-when-compile'
* module/language/elisp/compile-tree-il.scm (compile-eval-when-compile):
  New function.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:48 -05:00
BT Templeton
a338fa3d87 remove unnecessary elisp macros
* module/language/elisp/runtime/macros.scm (when, unless, dotimes)
  (dolist, pop, push): Remove. (They are not special forms in Emacs.)

* module/language/elisp/runtime/function-slot.scm: Update import and
  export lists.

* test-suite/tests/elisp-compiler.test ("Conditionals")["failing when"]
  ["succeeding when", "failing unless", "succeeding unless"]: Remove.
  ("Iteration")["dotimes", "dolist"]: Remove.
  ("List Built-Ins")["pop", "push"]: Remove.
2012-02-03 18:53:48 -05:00
BT Templeton
59e46065ce elisp test fixes
* test-suite/tests/elisp-compiler.test ("Exceptions")["catch and
  throw"]: Use a freshly-consed object instead of a literal object. This
  test previously assumed that similar literal objects are never
  identical, which no longer true.
  ("Equivalence Predifcates")["eq"]: Likewise.
2012-02-03 18:53:48 -05:00
BT Templeton
8f2f65668a new string' and mapcar' elisp subrs
* module/language/elisp/boot.el (string, mapcar): New functions.
2012-02-03 18:53:48 -05:00
BT Templeton
9b15703d79 rewrite elisp subrs in elisp
* module/language/elisp/runtime/subrs.scm (%, *, +, -, /=, 1+, 1-, <)
  (<=, =, >, >=, abs, append, atom, car, car-safe, cdr, cdr-safe, cons)
  (consp, eq, equal, fceiling, ffloor, float, floatp, fround, ftruncate)
  (funcall, integerp, length, list, listp, make-list, max, min, nlistp)
  (nth, nthcdr, null, numberp, reverse, setcar, setcdr, wholenump)
  (zerop): Rewrite in Elisp and move to...
* module/language/elisp/boot.el: ...here. Some functions have stricter
  type checking, and `elisp-bool' is not currently used (so some
  predicate functions now return `#f' instead of `#nil').
  (boundp, eval, fboundp, fmakunbound, fset, load, makunbound, set)
  (symbol-function, symbol-value, throw): New functions; they call their
  existing implementations in subrs.scm.
  (@): New macro.
* module/language/elisp/runtime.scm (built-in-func): Remove. All uses
  changed.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:48 -05:00
BT Templeton
b0a9f1b4b4 remove unnecessary elisp subrs
* module/language/elisp/runtime/subrs.scm (copy-tree, number-sequence):
  Remove. (They are not subrs in Emacs.)

* test-suite/tests/elisp-compiler.test ("List Built-ins")["copy-tree",
  "number-sequence"]: Remove.
2012-02-03 18:53:48 -05:00
BT Templeton
16254e5a09 atomp' -> atom'
* module/language/elisp/runtime/subrs.scm (atomp) Rename to...
  (atom): ...this. All callers changed.
2012-02-03 18:53:48 -05:00
BT Templeton
30439aa8bb use `nil?' for elisp conditionals
* module/language/elisp/compile-tree-il.scm (compile-if): Use the `nil?'
  primitive for conditionals.
2012-02-03 18:53:48 -05:00
BT Templeton
9348168ed5 add `nil?' primitive
* libguile/boolean.c (scm_nil_p): New function.

* libguile/vm-i-scheme.c (nilp, not_nilp):
* libguile/vm-i-system.c (br_if_nil, br_if_not_nil): New instructions.
  Renumber other ops.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Increment.

* module/language/assembly/compile-bytecode.scm (compile-bytecode): Add
  support for writing `br-if-nil' and `br-if-not-nil' instructions.

* module/language/assembly/disassemble.scm (code-annotation): Add
  `br-if-nil' and `br-if-not-nil' to the list of branch instructions.

* module/language/tree-il/compile-glil.scm: Add `nil?' to
  `*primcall-ops*'.
  (flatten): Use the new branch instructions for `nil?' conditionals.

* module/language/tree-il/primitives.scm: Add `nil?' to
  `*interesting-primitive-names*', `*effect-free-primitives', and
  `*effect+exception-free-primitives*'.
2012-02-03 18:53:38 -05:00