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

4597 commits

Author SHA1 Message Date
Andy Wingo
5ddb366375 psyntax: Remove stale analyze-variable case
* module/ice-9/psyntax.scm (analyze-variable): Remove "bare" case, long
gone.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-19 09:59:15 +01:00
Andy Wingo
cdf8473b19 psyntax: Separate core expanders from their installation
* module/ice-9/psyntax.scm (expand-let, expand-letrec, ...): Name these
expanders, then install them.  Allows for better code evolution and
decreases the indent.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 16:53:41 +01:00
Andy Wingo
6c4f9a58c9 psyntax: Remove pre-3.0 hack about syntax transformer bindings.
* module/ice-9/psyntax.scm (resolve-identifier): Remove "transformer is
a pair" case.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 16:00:23 +01:00
Andy Wingo
527b4498a8 psyntax: Simplify to first-order bindings. NFC
* module/ice-9/psyntax.scm (no-source, make-empty-ribcage): Make normal
bindings, not macros.
2024-11-18 15:59:06 +01:00
Andy Wingo
522b0b4510 psyntax: Match when rebuilding macro output
* module/ice-9/psyntax.scm (expand-macro): Use match.
(eval-local-transformer): Use unless for side effect.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 15:08:18 +01:00
Andy Wingo
b4aebbd7a5 psyntax: Cleanups; ensure order of top-level expansion
* module/ice-9/psyntax.scm (build-lexical-reference): No "type"
parameter.  Adapt callers.
(valid-bound-ids?, distinct-bound-ids?, bound-id-member?): Use match.
(expand-sequence, expand-top-sequence): Use match.  For
expand-top-sequence, ensure that both phases of expansion are run in
order; was the case before, but by accident.  Don't accumulate results
in reverse.
(parse-when-list): Use match.
2024-11-18 11:15:15 +01:00
Andy Wingo
12afcc74fb psyntax: Simplify locally-bound-identifiers
* module/ice-9/psyntax.scm (locally-bound-identifiers): Simplify to use
match and scope.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 10:21:41 +01:00
Andy Wingo
54c8901adc psyntax: Simplify id-var-name
* module/ice-9/psyntax.scm (id-var-name): No need for `search` to return
the marks.  Simplify to use scope instead of repeating, and use match.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 10:11:53 +01:00
Andy Wingo
14414655d3 psyntax: Fix bug introduced in 0295409483
* module/ice-9/psyntax.scm (analyze-variable): Fix erroneous pattern
matching.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 10:07:50 +01:00
Andy Wingo
2daea40200 psyntax: Use new `match' instead of cdadring
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm: Use `match' more.  Also use more first-order
definitions.  NFC.
2024-11-15 15:35:10 +01:00
Andy Wingo
0295409483 psyntax: Use new `match' instead of cdadring
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm: Use `match' more.  NFC.
2024-11-15 14:27:27 +01:00
Andy Wingo
d94292724b psyntax: Add simple pattern matcher
* module/ice-9/psyntax.scm (simple-match1, simple-match-pat,
simple-match-patv, match): Add simple pattern matcher.
* module/ice-9/psyntax-pp.scm: Regenerate.  Just different renumbering
of temps.
2024-11-15 14:16:20 +01:00
Andy Wingo
d30b39e4ea psyntax: Avoid lambda in procedure definitions
* module/ice-9/psyntax.scm: Instead of e.g. (define foo (lambda (x)
  ...)), do (define (foo x) ...).  No functional change.
2024-11-15 14:06:32 +01:00
Andy Wingo
4f05d1709b psyntax: Remove a useless level of let
* module/ice-9/psyntax.scm: Remove let around the body.
2024-11-15 13:57:57 +01:00
Andy Wingo
3b230745fe psyntax: Inline the single use of define-structure
* module/ice-9/psyntax.scm (define-structure): Remove, inline into use.
No predicate needed.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-15 13:56:04 +01:00
Andy Wingo
8c78234e80 psyntax: Functional annotation of function names
* module/ice-9/psyntax.scm (maybe-name-value): Return a fresh lambda
instead of mutating the given lambda.
(define-expansion-accessors): No need to define setters.
2024-11-14 16:54:25 +01:00
Andy Wingo
f376e6445d psyntax: Clean up use of fx+, etc
* module/ice-9/psyntax.scm (fx+, fx-, fx=): Remove.  Replace uses with
1+, 1-, =.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 16:11:51 +01:00
Andy Wingo
dd18780fb8 psyntax: Rename top-level-eval, local-eval
* module/ice-9/psyntax.scm (top-level-eval, local-eval): Rename from
top-level-eval-hook, local-eval-hook.  Adapt callers.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 16:02:20 +01:00
Andy Wingo
d60aeb3ced psyntax: Use vectors instead of gensyms for labels, marks
* module/ice-9/psyntax.scm (gen-unique): Instead of making a string with
an embedded hex counter, make a vector.  A little less work than making
a string, and slightly smaller binaries.
(gen-label, gen-mark): Use gen-unique.
(resolve-identifier): Adapt case that recognizes labels denoting
lexicals to be less strict.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 16:00:18 +01:00
Andy Wingo
70e2616975 psyntax: Remove useless gen-label invocations
* module/ice-9/psyntax.scm (expand-top-sequence): Remove needless
gen-label uses, and replace one use with gen-lexical (which is what is
needed).
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 15:46:05 +01:00
Andy Wingo
ebbb10c92d psyntax: Clean up lexical gensym creation
* module/ice-9/psyntax.scm (gen-lexical): Add a nice comment.  Rename
from build-lexical-var, and remove unused src argument.
(gen-var, generate-temporaries): Use gen-lexical.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 15:34:15 +01:00
Tomas Volf
1a5e35f0eb
srfi-64: Accept symbols as test group names.
The specification mandates a string, but with rationale suggesting symbols
would be a more natural fit.

> In some ways using symbols would be preferable. However, we want
> human-readable names, and standard Scheme does not provide a way to include
> spaces or mixed-case text in literal symbols.

Add support for symbols as an implementation extension and for backwards
compatibility with the reference implementation.

* module/srfi/srfi-64.scm (%cmp-group-name): New procedure.
(test-end): Use it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Reported-by: Daniel Llorens <lloda@sarc.name>
2024-10-26 19:44:40 +02:00
Taylan Kammer
242e8698c2 Better REPL behavior on syntax errors in meta commands.
Fixes <https://bugs.gnu.org/30600>.

* module/system/repl/command.scm (define-meta-command): Flush all
remaining input after handling a read error.
* module/system/repl/common.scm (flush-all-input): New public procedure.
* module/system/repl/repl.scm: Remove local flush-all-input definition.
2024-10-25 13:35:31 +02:00
Tomas Volf
ad90f45a8c
Replace SRFI-64 with a new implementation.
The bundled (reference) implementation was of somewhat mixed quality and
it failed to follow standard in multiple places.  This commit replaces
it with a new one, written from scratch to follow the standard as close
as possible.

* module/srfi/srfi-64/testing.scm: Delete file.
* module/srfi/srfi-64.scm: Replace with new implementation.
* am/bootstrap.am (srfi/srfi-64.go): Remove extra dependencies.
(NOCOMP_SOURCES): Remove srfi/srfi-64/testing.scm.
* test-suite/tests/srfi-64-test.scm
("8.6.1. Simple (form 1) test-apply")
("8.6.2. Simple (form 2) test-apply"): Adjust tests to follow the
specification.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 19:11:42 +02:00
Arne Babenhauserheide
c0bfa3219c fix typo in comment
module/ice-9/command-line.scm (compile-shell-switches): fix typo
2024-10-12 14:07:02 +02:00
Matthew Wette
8d21dd7eb8 Create procedure to enable silencing the Guile welcome message. * module/system/repl/repl.scm: add parameter %inhibit-welcome-message' * module/system/repl/repl.scm(run-repl*): add condition for calling procedure repl-welcome: if (%inhibit-welcome-message) is #t', don't 2024-10-12 13:16:35 +02:00
Matthew Wette
78e9e51065 Redirect diagnostice output messages (e.g., auto-compiling code) to a newly defined current-info-port, and add a command line argument -I' to set the current-info-port to a void-port. * libguile/ports.c: add cur_infoport_fluid, scm_current_info_port, scm_set_current_info_port; define default current-info-port to stderr * libguile/load.c(compiled_is_fresh,load_thunk_from_path, do_try_auto_compile,scm_sys_warn_auto_compilation_enabled, scm_primitive_load_path): direct output messages to current_info_port; was current_warning_port * libguile/init.c(scm_init_standard_ports): set default current_info_port * module/ice-9/ports.scm: define current-info-port and set-current-info-port * module/ice-9/command-line.scm(*usage*,compile-shell-switches): add argument -I' to silence diagnostics (or current-info-port to void-port) * doc/ref/guile-invoke.texi: add description for `-I' command argument 2024-10-12 13:16:25 +02:00
Andy Wingo
aff9ac9688 Run sigbits fixpoint based on use/def graph, not cfg
* module/language/cps/specialize-numbers.scm (sigbits-ref): New helper.
(invert-graph*): New helper.
(compute-significant-bits): When visiting a term changes computed
needed-bits for one of its definitions, we need to revisit the variables
that contributed to its result (the uses), because they might need more
bits as well.  Previously we were doing this by enqueueing predecessors
to the term, which worked if the uses were defined in predecessors, or
if all defining terms were already in the worklist, which is the case
without loops.  But with loops, when revisiting a term, you could see
that it causes sigbits to change, enqueue its predecessors, but then the
predecessors don't change anything and the fixpoint stops before
reaching the definitions of the variables we need.  So instead we
compute the use-def graph and enqueue defs directly.
2024-09-26 11:14:52 +02:00
Andy Wingo
30c3849092 Tighten up range inference for scm->u64/truncate
* module/language/cps/types.scm (scm->u64/truncate): Better range
analysis.
2024-09-25 17:27:17 +02:00
Andy Wingo
e45b70dcde Fix boxing of non-fixnum negative u64 values
* module/language/cps/specialize-numbers.scm (u64->fixnum/truncate): New
helper.
(specialize-operations): Fix specialized boxing of u64 values to
truncate possibly-negative values, to avoid confusing CSE.  Fixes
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71891.
2024-09-25 17:24:51 +02:00
Andy Wingo
0dab58fc2a Fix fixpoint needed-bits computation in specialize-numbers
* module/language/cps/specialize-numbers.scm (next-power-of-two): Use
integer-length.  No change.
(compute-significant-bits): Fix the fixpoint computation, which was
failing to complete in some cases with loops.
2024-09-25 17:23:06 +02:00
Andy Wingo
b04071cc57 Partially revert d579848cb5
* module/language/cps/specialize-numbers.scm (specialize-operations):
Accept any operand to logand/immediate, provided the result is a u64 in
the right range.
2024-09-24 09:24:15 +02:00
Andy Wingo
5e6288c930 Narrow parameter of logand/immediate if no bits used
* module/language/cps/specialize-numbers.scm (specialize-operations):
Narrow ulogand/immediate param according to used bits.
2024-09-23 16:00:54 +02:00
Andy Wingo
d6af34c0e0 Remove needless constraints in type/range analysis
* module/language/cps/types.scm
(ulogand, ulogand/immediate, ulogsub, ulogior, ulogxor): Where we have
u64 inputs, there's no need to `restrict!`; the range will come from the
definition.
2024-09-23 15:32:45 +02:00
Andy Wingo
90e1205018 Add a workaround for pre-3.0.10 incorrect inlinable exports
* module/language/tree-il/peval.scm (peval)
(inlinable-kwargs-bug-fixup): Before 3.0.10, the inlinable exports pass
was incorrectly serializing functions with keyword arguments.  This was
fixed in 2c645571b3, but that meant that
3.0.10 compiling against 3.0.9 binaries could raise an exception at
compile-time; whoops.  Add a workaround so that 3.0.9 binaries still
work.

Fixes https://issues.guix.gnu.org/72936.
2024-09-23 14:07:53 +02:00
Andy Wingo
a970ed5bd5 Update psyntax copyright notice
* module/ice-9/psyntax.scm: Use the newer LGPLv3 header.  Add FSF
copyright lines for each year the file was modified.  Remove inline
changelogs.  Remove some comments describing psyntax in other Scheme
implementations.
2024-08-26 09:51:53 +02:00
Andy Wingo
d0790d766b Fix intset-fold-right on transient intsets
* module/language/cps/intset.scm (make-intset-folder): intset-fold-right
on a transient intset would dispatch to left fold after making the
persistent set.  Sadness!
2024-08-15 12:18:02 +02:00
Andy Wingo
7aa4cfa9de More thorough lowering of lognot to CPS
* module/language/tree-il/compile-cps.scm (canonicalize): Lower to a
logxor with -1.
2024-08-13 13:40:45 +02:00
Rob Browning
6338459159 Drop libguile srfi-1
...now that all of the C code has been migrated to Scheme.

* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
remove srfi-1.c.
(DOC_X_FILES): Remove srfi-1.x.
(DOT_DOC_FILES): Remove srfi-1.doc.
(modinclude_HEADERS): Remove srfi-1.h.
* libguile/init.c (scm_i_init_guile): Don't call scm_register_srfi_1.
* libguile/srfi-1.c: Remove.
* libguile/srfi-1.h: Remove.
* module/srfi/srfi-1.scm: Don't load srfi-1 from libguile.
2024-07-30 19:39:32 -05:00
Rob Browning
51b7021de1 srfi-1 delete-duplicates: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_delete-duplicates): delete.
* libguile/srfi-1.h (scm_srfi1_delete-duplicates): delete.
* module/srfi/srfi-1.scm: add delete-duplicates.
2024-07-30 19:28:37 -05:00
Rob Browning
a94b4406b7 srfi-1 delete-duplicates!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_delete-duplicates_x): delete.
* libguile/srfi-1.h (scm_srfi1_delete-duplicates_x): delete.
* module/srfi/srfi-1.scm: add delete-duplicates!.
2024-07-30 19:28:37 -05:00
Rob Browning
51e15d448f srfi-1 lset-difference: use remove
* module/srfi/srfi-1.scm (lset-difference): rely on remove like
lset-difference!; in addition to being simpler, this allows sharing a
common tail.
2024-07-30 19:28:37 -05:00
Rob Browning
945c97b14d srfi-1 lset-difference!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_lset-difference_x): delete.
* libguile/srfi-1.h (scm_srfi1_lset-difference_x): delete.
* module/srfi/srfi-1.scm: add lset-difference!.
* test-suite/tests/srfi-1.test: extend lset-difference! tests to cover
lset-difference.
2024-07-30 19:28:37 -05:00
Rob Browning
3eb6afe738 srfi-1 partition!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_partition_x): delete.
* libguile/srfi-1.h (scm_srfi1_partition_x): delete.
* module/srfi/srfi-1.scm: add partition!.
2024-07-30 19:28:37 -05:00
Rob Browning
925faf1f01 srfi-1 partition: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_partition): delete.
* libguile/srfi-1.h (scm_srfi1_partition): delete.
* module/srfi/srfi-1.scm: add partition.
2024-07-30 19:28:37 -05:00
Rob Browning
58246aee24 srfi-1 count: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_count): delete.
* libguile/srfi-1.h (scm_srfi1_count): delete.
* module/srfi/srfi-1.scm: add count.
2024-07-30 19:28:37 -05:00
Rob Browning
372a52e6aa srfi-1 length+: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_length_plus): delete.
* libguile/srfi-1.h (scm_srfi1_length_plus): delete.
* module/srfi/srfi-1.scm: add length+.
2024-07-30 19:28:37 -05:00
Rob Browning
3cb6309f62 srfi-1 append-reverse!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_append_reverse_x): delete.
* libguile/srfi-1.h (scm_srfi1_append_reverse_x): delete.
* module/srfi/srfi-1.scm: add append-reverse!.
2024-07-30 19:28:37 -05:00
Rob Browning
17281519df srfi-1 append-reverse: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_append_reverse): delete.
* libguile/srfi-1.h (scm_srfi1_append_reverse): delete.
* module/srfi/srfi-1.scm: add append-reverse.
2024-07-30 19:11:34 -05:00
Rob Browning
c62d2962d4 srfi-1 concatenate concatenate!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* libguile/srfi-1.h (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* module/srfi/srfi-1.scm: add concatenate and concatenate!.
2024-07-30 18:54:45 -05:00