diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-11-08 19:43:15 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-11-08 19:43:15 -0800 |
commit | f76fe935c227edcf73297c4292cedbb5b560e369 (patch) | |
tree | bfcec215a5f0dee2f36215d1b3c60ceba4a82d3b /lisplib.c | |
parent | cc73eb8ce1ce45e248c57003f5bb176c42bf688e (diff) | |
download | txr-f76fe935c227edcf73297c4292cedbb5b560e369.tar.gz txr-f76fe935c227edcf73297c4292cedbb5b560e369.tar.bz2 txr-f76fe935c227edcf73297c4292cedbb5b560e369.zip |
compiler: handle constant expressions that throw.
When the compiler evaluates constant expressions, it's
possible that they throw, for instance (/ 1 0).
We now handle it better; the compiler warns about it
and is able to keep working, avoiding constant-folding
the expression.
* stdlib/compiler.tl (eval-cache-entry): New struct type.
(%eval-cache%): New hash table variable.
(compiler (comp-arith-form, comp-fun-form)): Add some missing
rlcp calls to track locations for rewritten arithmetic
expressions, so we usefullly diagnose a (sys:b/ ...) and such.
(compiler (comp-if, comp-ift, comp-arith-form,
comp-apply-call, reduce-constant, lambda-apply-transform)):
Replace instances of eval of constantp expressions with
safe-const-eval, and instances of the result of eval being
quoted with safe-const-reduce.
(orig-form, safe-const-reduce, safe-const-eval,
eval-cache-emit-warnings): New functions.
(compile-top-level, with-compilation-unit): Call
eval-emit-cache-warnings to warn about constant expressions
that threw.
squash! compiler: handle constant expressions that throw.
Diffstat (limited to 'lisplib.c')
0 files changed, 0 insertions, 0 deletions