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

704 commits

Author SHA1 Message Date
BT Templeton
52d2472441 elisp rng
* module/language/elisp/boot.el (random): New function.
2012-03-08 17:08:30 -05:00
BT Templeton
43ff6804d6 elisp i/o
* module/language/elisp/boot.el (send-string-to-terminal)
  (read-from-minibuffer, prin1-to-string): New functions.
2012-03-08 17:08:30 -05:00
BT Templeton
5c65ee510f elisp: symbol-name, intern
* module/language/elisp/boot.el (symbol-name, intern): New functions.
2012-03-08 17:08:30 -05:00
BT Templeton
c0652730bc elisp: when, unless
* module/language/elisp/boot.el (when, unless): New macros.
2012-03-08 17:08:30 -05:00
BT Templeton
12c00a0453 elisp sequence functions
* module/language/elisp/boot.el (nreverse, assoc, assq, rplaca, rplacd)
  (caar, cadr, cdar, cddr, dolist, stringp, string-equal, string=)
  (substring, upcase, downcase, string-match, make-vector, mapc, aref)
  (aset, concat): New functions.
2012-03-08 17:08:30 -05:00
BT Templeton
fc45b7e8e8 integerp, wholenump return nil for non-numbers
* module/language/elisp/boot.el (integerp, wholenump): Call `integer?'
  before `exact?' so that these predicates return nil for non-numbers
  instead of signalling an error.
2012-03-08 17:08:30 -05:00
BT Templeton
663c5875f5 use #nil as default for elisp rest parameters
* module/langauge/elisp/compile-tree-il.scm (compile-lambda): Bind the
  rest parameter to `#nil' instead of `()' by default.
2012-03-05 18:10:29 -05:00
BT Templeton
5ddd9645c9 Merge branch 'bt/elisp'
Conflicts:
	am/guilec
	libguile/_scm.h
	libguile/vm-i-scheme.c
	module/language/elisp/compile-tree-il.scm
	module/language/elisp/runtime.scm
	module/language/elisp/runtime/macros.scm
	module/language/tree-il/compile-glil.scm
	module/language/tree-il/primitives.scm
2012-03-05 16:52:05 -05:00
Mark H Weaver
d019ef9288 Merge branch 'stable-2.0'
Conflicts:
	module/ice-9/psyntax-pp.scm
	module/language/tree-il.scm
2012-03-03 20:20:16 -05:00
Mark H Weaver
72ee0ef71b tree-il->scheme improvements
* module/language/tree-il.scm (tree-il->scheme): New implementation that
  simply calls 'decompile-tree-il'.

* module/language/scheme/decompile-tree-il.scm (choose-output-names,
  do-decompile): New internal procedures.

  (decompile-tree-il): New and improved implementation.  Print source
  identifiers where possible, otherwise add minimal numeric suffixes.
  Previously we printed the gensyms.  Avoid 'begin' in contexts that
  provide an implicit 'begin'.  Produce 'cond', 'case', 'and', 'or',
  'let*', named let, and internal defines where appropriate.  Recognize
  keyword arguments in 'opts' to disable the production of these derived
  syntactic forms, and to optionally strip numeric suffixes from
  variable names.

* module/ice-9/compile-psyntax.scm: Disable partial evaluation, letrec
  fixing, and primitive expansion when producing psyntax-pp.scm, in
  order to produce output as close to the original source as practical.
  Disable production of derived syntactic forms as needed during
  bootstrap.  Strip numeric suffixes from variable names.  Adjust
  pretty-printing parameters.

* module/ice-9/psyntax-pp.scm: Regenerate.  It is now less than half
  of the original size.
2012-03-03 18:05:21 -05:00
Andy Wingo
d5dbe0c1d5 optimize dynamic-wind when we know winders are thunks
* libguile/vm-i-system.c (wind):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
  Instead of making `wind' call `scm_thunk_p' on the winder and unwinder
  at runtime, make it the responsibility of the compiler to emit code to
  call thunk? and error, but only if the compiler cannot prove them to
  be thunks.

* libguile/vm-engine.c (vm_engine): Remove a now-unused error block.
2012-03-03 21:46:38 +01:00
Andy Wingo
dee4e3ee3c Merge remote-tracking branch 'origin/stable-2.0' 2012-03-02 17:46:52 +01:00
Andy Wingo
dab48cc567 tweaks to -Wformat's gettext detection
* module/language/tree-il/analyze.scm (proc-ref?): Change to use less
  false-if-exception and more variable-bound?.  If a variable is present
  in the local module but not bound, assume that it is gettext if it has
  the right name.  This is to allow for (define _ gettext).

* test-suite/tests/tree-il.test ("warnings"): Update (_ "foo") example.
2012-03-02 17:46:28 +01:00
Andy Wingo
d489998364 Merge remote-tracking branch 'origin/stable-2.0'
There are a some failures currently:

    FAIL: tree-il.test: warnings: format: non-literal format string with forward declaration
    ERROR: srfi-18.test: current-exception-handler: current handler returned at top level - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
    ERROR: srfi-18.test: current-exception-handler: multiple levels of handler nesting - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
    ERROR: srfi-18.test: current-exception-handler: exception handler installation is thread-safe - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))

Conflicts:
	module/language/tree-il/peval.scm
	module/language/tree-il/primitives.scm
	test-suite/tests/tree-il.test
2012-03-02 17:20:47 +01:00
Andy Wingo
eebcacf41c peval: inline applications of lambda to rest args
* module/language/tree-il/peval.scm (peval): Add optimization to
  hoist the inner procedure out of e.g.
    (lambda args (apply (lambda ...) args))
  This commit restores the ability to detect escape-only prompts at
  compile-time.

* test-suite/tests/tree-il.test: Update test for prompt with a lambda,
  and add a specific test for lambda application.
2012-03-02 16:47:39 +01:00
Andy Wingo
542aa859de tree-il: fix `canonicalize!' for prompts
* module/language/tree-il/canonicalize.scm (canonicalize!): Fix a bug in
  which the sense of `escape-only?' was reversed.  We never saw this
  though, because for other reasons, no prompts were being identified as
  escape-only.
2012-03-02 16:47:39 +01:00
Andy Wingo
20337139d2 more general treatment of call-with-prompt
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Don't limit the call-with-prompt to <prompt> transition to lambda
  expressions.  Instead we can lexically bind the handler, and rely on
  peval to propagate a lambda expression.
2012-03-02 16:47:39 +01:00
Ludovic Courtès
d316047326 Avoid failure when `format-analysis' stumbles upon unbound variables.
* module/language/tree-il/analyze.scm (proc-ref?): Wrap `variable-ref'
  in `false-if-exception'.

* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
  format string with forward declaration"): New test.
2012-02-27 00:51:09 +01:00
Andy Wingo
9d15db65ff Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	module/language/tree-il/analyze.scm
2012-02-23 14:10:22 +01:00
Noah Lavine
3c65e3fda5 Optimize Equality Primitives
* module/language/tree-il/primitives.scm: add equality-primitive?,
  which is true for eq?, eqv?, and equal?
* module/language/tree-il/peval.scm: if an equality primitive is
  applied to the same variable twice, fold it to #t
* test-suite/tests/tree-il.test: add tests for pevaling equality
  primitives
2012-02-20 15:24:17 -05:00
Ludovic Courtès
98385ed20a Have -Wformat' recognize ngettext' calls.
* module/language/tree-il/analyze.scm (gettext?): Rename to...
  (proc-ref?): ... this.  Add `proc' and `special-name' parameters.
  (gettext?): Define in terms of `proc-ref?'.
  (ngettext?): New procedure.
  (const-fmt): Recognize `ngettext' calls.
  (format-analysis)[<down>](check-format-args]: Check
  constant-but-non-string 2nd argument in the (not (const-fmt ...))
  case.
  [check-simple-format-args]: Use `const-fmt'.

* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
  format string using ngettext", "non-literal format string using
  ngettext as N_"): New tests.
  ("simple-format")["unsupported, ngettext"]: New test.
2012-02-19 23:54:18 +01:00
Ludovic Courtès
afc9803113 Have -Wformat' better recognize the gettext' procedure.
Fixes <http://bugs.gnu.org/10846>.
Reported by Bruno Haible <bruno@clisp.org>.

* module/language/tree-il/analyze.scm (gettext?): New procedure.
  (const-fmt): Add `env' parameter; update callers.  Use `gettext?'.
  (format-analysis)[check-simple-format-args]: Actually support
  gettextized format strings.

* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
  format string using gettext"): Use `gettext' as the procedure name.
  ("non-literal format string using gettext as _"): New test.
  ["simple-format"]("unsupported, gettext"): New test.
2012-02-19 23:08:49 +01:00
Andy Wingo
0858753e82 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/gc-malloc.c
	libguile/ports.c
2012-02-08 11:48:08 +01:00
BT Templeton
eaeda0d550 function binding fixes
* 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'.
2012-02-03 18:53:51 -05:00
BT Templeton
5199c059e8 sharpsign-colon for uninterned symbols
* module/language/elisp/lexer.sm (lex): Add support for `#:' syntax for
  uninterned symbols.
2012-02-03 18:53:51 -05:00
BT Templeton
39864d2014 elisp I/O
* module/language/elisp/boot.el (princ, print, terpri, format*): New
  functions.
2012-02-03 18:53:50 -05:00
BT Templeton
66be42cb38 improve management of global special variables
* module/language/elisp/bindings.scm (bindings): Remove `globals'
  field. (global?, mark-global!, map-globals): Remove. All callers
  changed.

* module/language/elisp/compile-tree-il.scm (generate-ensure-global,
  ensuring-globals): Remove. All callers changed.

  (global?, ensure-globals!): New procedures.

  (bind-lexically?): Use new `global?'.

  (compile-lambda, compile-let, compile-let*): Use `ensure-globals!'.
2012-02-03 18:53:50 -05:00
BT Templeton
b07a74497a more lexical declarations
* module/language/elisp/boot.el (condition-case, catch): Add `lexical'
  declarations in macro expansions.
2012-02-03 18:53:50 -05:00
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