* 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.
* 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.
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
* 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.
* 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.
* 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.
* 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.
* 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
* 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.
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.
* 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*'.
* module/language/tree-il/analyze.scm (format-string-argument-count):
Add support for ~h.
* test-suite/tests/tree-il.test ("warnings")["format"]("~h", "~:h with
locale object", "~:h without locale object"): New tests.
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (dynamic-wind): When you make a
gensym that just has to be compared against other gensyms, it will be
unique if the prefix doesn't end in something that can be interpreted
as a number. There's no reason to make that character something
difficult like " ". So change to use a dash in that case.
* module/ice-9/psyntax-pp.scm: Regenerate. More readable now.
* module/language/tree-il/analyze.scm
(format-analysis)[check-simple-format-args]: New procedure. Use it.
Add support for applications of <module-ref>.
* module/system/base/message.scm (%warning-types): Handle the `format
simple-format' warning.
* module/language/scheme/spec.scm (scheme)[make-default-environment]:
Use `simple-format' as the default `format'.
* test-suite/tests/tree-il.test ("warnings")["format"]: Explicitly use
(@ (ice-9 format) format) where needed.
("simple-format"): New test prefix.
* module/language/tree-il/peval.scm (peval): Fold (values
'singly-valued-expression) to 'singly-valued-expression in contexts
that expect multiple values, in addition to those that expect single
values.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Fix
miscompilation of `values' in a push context with RA.
* test-suite/tests/tree-il.test: Add low-level test for this
miscompilation.
* module/language/tree-il/peval.scm (singly-valued-expression?): New
helper.
(truncate-values): Use the helper.
(make-operand): Minor refactor.
(set-operand-residual-value!): Try to undo the effects of (values
FOO), if the continuation will check itself for the correct number of
values.
(peval): Fold helpers into fold-constant. Add a constant-expression?
case for (values FOO). Add a new context: "values", for contexts in
which multiple values are allowed, either because of being in a tail
context relative to a function, or because of let-values. "value" is
now for single values. Don't visit operands for "values", as their
binding form truncates to one value. Add a case to fold (values ...)
forms. Fix folding of (lambda), to process the cases in values
context instead of tail context (which could have been "value", which
would cause the procedure to truncate).
Reported by Cédric Cellier <rixed@happyleptic.org>.
* module/language/tree-il/peval.scm (truncate-values): New procedure.
(make-operand): Call `truncate-values' SOURCE.
* test-suite/tests/tree-il.test ("partial evaluation"): New tests for
multiple value truncation.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Clear
lexical stack slots at the end of a non-tail let, letrec, or fix.
Fixes http://debbugs.gnu.org/9900.
* test-suite/tests/gc.test ("gc"): Add test.
* module/language/tree-il.scm (<tree-il>): Add `pre' and `post' fields
to <dynwind>, so that we can inline the guard bodies in the normal
control-flow case. It also avoids duplicating code in compile-glil,
which probably hides more bugs in 2.0.
(parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold)
(make-tree-il-folder, post-order!, pre-order!): Update.
* module/language/tree-il/analyze.scm (analyze-lexicals): Update.
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update
to use `pre' and `post' instead of compiling code twice.
* module/language/tree-il/debug.scm (verify-tree-il): Update.
* module/language/tree-il/peval.scm (peval): Update. Instead of doing
complicated things in <dynwind>, handle 'dynamic-wind primcalls.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove 'dynamic-wind mess. Adapt '@dynamic-wind.
* test-suite/tests/tree-il.test ("partial evaluation"): Update tests.
* module/language/tree-il/peval.scm (peval): The <dynwind> compiler will
copy the winder and unwinder values, so make sure that they are
constant, and if not, create lexical bindings. Fixes
http://debbugs.gnu.org/9844.
* test-suite/tests/tree-il.test ("partial evaluation"): Add a couple
<dynwind> tests.
* module/language/tree-il/peval.scm (peval): Since constant-expression?
is used to determine whether to copy values, return #f if any lexical
is assigned.
* module/language/tree-il/primitives.scm (resolve-primitives!): Don't
resolve toplevels defined in the same compilation unit to primitives,
as it could be that the module doesn't have those bindings yet.
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump the major version,
indicating the first incompatibility between 2.0 and 2.2.
* libguile/vm-i-scheme.c (string-length, string-ref, vector-length): New
instructions.
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
primcall ops for the new instructions.
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*, *effect-free-primitives*): Recognize
vector-length as an effect-free primitive.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Remove a hack to compensate for the lack of a good inliner, now that
we do have a good inliner.
* module/language/tree-il/peval.scm (peval): Accessor primitives applied
to constants are pure if the call type-checks. Also, fold constants
in accessor primcalls.
* test-suite/tests/tree-il.test ("partial evaluation"): Fix the "yo"
test.
* module/language/tree-il/analyze.scm (analyze-lexicals): When stepping
into a non-tail form, we know that labels allocation will be invalid,
so use an empty labels set. Fixes http://debbugs.gnu.org/9769.
* test-suite/tests/tree-il.test ("labels allocation"): Add a test.
* module/language/tree-il/peval.scm (peval): Factor constant folding out
to a helper. Use it in the accessor case in addition to the normal
effect-free-primitive case.
* test-suite/tests/tree-il.test: Add a test.