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

2083 commits

Author SHA1 Message Date
Andy Wingo
5d9516637b Implement R6RS output-port-buffer-mode
* module/rnrs/io/ports.scm (r6rs-open): Set buffer-mode on new port.
  (output-port-buffer-mode): Implement and export.
* module/rnrs.scm (rnrs): Export output-port-buffer-mode
* test-suite/tests/r6rs-ports.test (test-output-file-opener): Add
  tests.
2016-06-21 11:06:25 +02:00
Taylan Ulrich Bayırlı/Kammer
d545e4551d (rnrs hashtables): Hash functions of eq? and eqv? hashtables
Also pinging this thread with a (very slightly) updated patch. :-)

[2. text/x-diff; 0001-Hashtable-hash-function-returns-f-on-eq-and-eqv-tabl.patch]

From 17599f6ce7ba0beb100e80455ff99af07333d871 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Tue, 21 Jun 2016 00:23:29 +0200
Subject: [PATCH] Hashtable-hash-function returns #f on eq and eqv tables.

* module/rnrs/hashtables.scm (r6rs:hashtable)[type]: New field.
(r6rs:hashtable-type): New procedure.
* test-suite/tests/r6rs-hashtables.test: Add related tests.
2016-06-21 09:48:36 +02:00
Taylan Ulrich Bayırlı/Kammer
c1abe68dbc (rnrs hashtables): Mutation of immutable hashtable ignored
Pinging this thread with a (very slightly) updated patch. :-)

[2. text/x-diff; 0001-Hashtable-set-errors-on-immutable-hashtable.patch]

From 7f35d515d711e255bba5a89a013d9d92034edf41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Tue, 21 Jun 2016 00:25:19 +0200
Subject: [PATCH] Hashtable-set! errors on immutable hashtable.

* module/rnrs/hashtables.scm (hashtable-set!): Raise an assertion
  violation error when the hashtable is immutable.
* test-suite/tests/r6rs-hashtables.test: Fix accordingly.
2016-06-21 09:47:07 +02:00
Andy Wingo
beea6302e0 Fix fixnum-range changes in R6RS fixnum bitops
* module/rnrs/arithmetic/fixnums.scm (fxcopy-bit, fxbit-field)
  (fxcopy-bit-field, fxarithmetic-shift)
  (fxarithmetic-shift-left, fx-arithmetic-shift-right)
  (fxrotate-bit-field, fxreverse-bit-field): Enforce range on amount by
  which to shift.  Fixes #14917.
* test-suite/tests/r6rs-arithmetic-fixnums.test ("fxarithmetic-shift-left"):
  Update test to not shift left by a negative amount.
2016-06-21 09:32:30 +02:00
Andy Wingo
845c873acf Add another code coverage test
* test-suite/tests/coverage.test ("line-execution-counts"): Add a test
  from Taylan Ulrich B, from bug #14849.
2016-06-21 09:07:26 +02:00
Andy Wingo
fff013215f Fix peval on (call-with-values foo (lambda (x) x))
* module/language/tree-il/peval.scm (peval): Don't
  inline (call-with-values foo (lambda (x) exp)) to (let ((x (foo)))
  exp).  The idea is that call-with-values sets up an explicit context
  in which we are requesting an explicit return arity, and that dropping
  extra values when there's not a rest argument is the wrong thing.
  Fixes #13966.
* test-suite/tests/peval.test ("partial evaluation"): Update test.
2016-06-20 22:04:45 +02:00
Andy Wingo
dc7bc06f69 Fix size measurement in bytevector_large_set
* libguile/bytevectors.c (bytevector_large_set): Fix computation of
  value size in words.
* test-suite/tests/bytevectors.test: Add test.

Thanks to Ben Rocer <fleabyte@mail.com> for the bug report and fix.
2016-06-20 17:15:21 +02:00
Andy Wingo
687d393e2c Fix uri-decode behavior for "+"
* module/web/uri.scm (uri-decode): Add #:decode-plus-to-space? keyword
  argument.
  (split-and-decode-uri-path): Don't decode plus to space.
* doc/ref/web.texi (URIs): Update documentation.
* test-suite/tests/web-uri.test ("decode"): Add tests.
* NEWS: Add entry.

Based on a patch by Brent <brent@tomski.co.za>.
2016-06-20 14:48:15 +02:00
Andy Wingo
c7c11f3af9 Update port documentation, rename sports to suspendable ports
* module/ice-9/suspendable-ports.scm: Rename from ice-9/sports.scm, and
  adapt module names.  Remove exports that are not related to the
  suspendable ports facility; we want people to continue using the port
  operations from their original locations.  Add put-string to the
  replacement list.
* module/Makefile.am: Adapt to rename.
* test-suite/tests/suspendable-ports.test: Rename from sports.test.
* test-suite/Makefile.am: Adapt to rename.
* module/ice-9/textual-ports.scm (unget-char, unget-string): New
  functions.
* doc/ref/api-io.texi (Textual I/O, Simple Output): Flesh out
  documentation.
  (Line/Delimited): Undocument write-line, read-string, and
  read-string!.  This is handled by (ice-9 textual-ports).
  (Bytevector Ports): Fix duplicated section.
  (String Ports): Move the note about encodings down to the end.
  (Custom Ports): Add explanatory text.  Remove mention of C functions;
  they should use the C port interface.
  (Venerable Port Interfaces): Add text, and make documentation refer to
  recommended interfaces.
  (Using Ports from C): Add documentation.
  (Non-Blocking I/O): Document more fully and adapt to suspendable-ports
  name change.
2016-06-09 10:50:32 +02:00
Andy Wingo
c95a19376b get-bytevector-n in Scheme.
* module/ice-9/sports.scm (fill-input): Add io-mode optional arg.
  (get-bytevector-n): New implementation.
  (port-bindings): Add get-bytevector-n.
* test-suite/tests/sports.test: Add r6rs-ports tests.
2016-05-22 23:03:16 +02:00
Andy Wingo
2c95a21027 More thorough ice-9 sports testing
* module/ice-9/sports.scm: Export read-line, %read-line, and
  read-delimited.  Add these latest three to install-sports!, and fix
  install-sports! if the current module isn't (ice-9 sports).

* test-suite/tests/sports.test: Use install-sports! instead of lexical
  bindings, to allow us to nicely frob bindings in rdelim.  Include
  rdelim tests.
2016-05-22 20:40:54 +02:00
Ludovic Courtès
b9f6e89a27 http: Accept date strings with a leading space for hours.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (parse-rfc-822-date): Add two clauses for hours
with a leading space.
* test-suite/tests/web-http.test ("general headers"): Add two tests.
2016-05-22 20:14:34 +02:00
Ludovic Courtès
f53145d41c http: Accept empty reason phrases.
Fixes <http://bugs.gnu.org/22273>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (read-header-line): New procedure.
(read-response-line): Use it instead of 'read-line*'.
* test-suite/tests/web-http.test ("read-response-line"): Add test.
2016-05-22 20:02:37 +02:00
Ludovic Courtès
3829047ec7 http: Test that responses lacking CR/LF are rejected.
* test-suite/tests/web-http.test ("read-response-line")["missing
CR/LF"]: New test.
2016-05-22 20:02:36 +02:00
Ludovic Courtès
2e3f6c3c67 i18n: Add new collation test for posterity.
* test-suite/tests/i18n.test ("text collation (Czech)"): New test
  prefix.
2016-05-22 19:49:44 +02:00
Ludovic Courtès
0bcf5d78ec web: Gracefully handle premature EOF when reading chunk header.
* module/web/http.scm (read-chunk-header): Return 0 when 'read-line'
  returns EOF.
2016-05-22 19:49:33 +02:00
Ludovic Courtès
d52edc05d3 web: Fix 'close' method of delimited input ports.
* module/web/response.scm (make-delimited-input-port)[close]: Replace
  erroneous self-recursive call with a call to 'close-port'.
* test-suite/tests/web-response.test ("example-1")["response-body-port +
  close"]: New test.
2016-05-22 19:48:47 +02:00
Andreas Rottmann
d77247b90b Heed the reader settings implied by #!r6rs
When encountering the #!r6rs directive, apply the appropriate reader
settings to the port.

* libguile/read.scm (read-string-as-list): New helper procedure.
  (scm_read_shebang): Set reader options implied by the R6RS syntax
  upon encountering the #!r6rs directive.
* test-suite/tests/reader.test (per-port-read-options): Add tests for
  the #!r6rs directive.
2016-05-22 19:40:37 +02:00
Mark H Weaver
aa13da5189 Fix atan procedure when applied to complex numbers.
Fixes a regression introduced in commit
ad79736c68.

* libguile/numbers.c (scm_atan): Fix the complex case.
* test-suite/tests/numbers.test ("atan"): Add test.
2016-05-22 19:29:38 +02:00
Mark H Weaver
82357f7bd8 Add more R6RS port encoding tests
Originally applied to stable-2.0 as "Fix bytevector and custom binary
ports to actually use ISO-8859-1 encoding.", commit
d574d96f87.  Related to
http://bugs.gnu.org/20200, which was introduced in in stable-2.0 but
never existed on master.  Test modified by Andy Wingo to add a
`force-output' where needed.

* test-suite/tests/r6rs-ports.test: Add tests.
2016-05-22 19:29:09 +02:00
Ludovic Courtès
70d8ef786a tests: Gracefully handle ENOSYS return for 'setaffinity'.
Fixes <http://bugs.gnu.org/19646>.
Reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>.

* test-suite/tests/posix.test ("affinity")["setaffinity"]: Wrap in
  'catch' and throw 'unresolved upon ENOSYS.
2016-05-22 19:09:33 +02:00
Mark H Weaver
e390e5760b Implement 'string-utf8-length' and 'scm_c_string_utf8_length'.
* libguile/strings.c (utf8_length, scm_c_string_utf8_length)
  (scm_string_utf8_length): New functions.
* libguile/strings.h (scm_c_string_utf8_length, scm_string_utf8_length):
  New prototypes.
* doc/ref/api-data.texi (Bytevectors as Strings): Add docs.
* doc/ref/guile.texi: Update manual copyright date to 2015.
* test-suite/tests/strings.test (string-utf8-length): Add tests.
2016-05-22 19:03:37 +02:00
Ludovic Courtès
751a55e355 http: Do not buffer HTTP chunks.
Fixes <http://bugs.gnu.org/19939>.

* module/web/http.scm (read-chunk, read-chunk-body): Remove.
  (make-chunked-input-port)[next-chunk, buffer-, buffer-size,
  buffer-pointer]: Remove.
  [chunk-size, remaining]: New variables.
  [read!]: Rewrite to write directly to BV.
* test-suite/tests/web-http.test ("chunked encoding")["reads chunks
  without buffering", "reads across chunk boundaries"]: New tests.
2016-05-22 18:43:28 +02:00
Ludovic Courtès
c6d88d1234 tests: Use 'pass-if-equal' in web-http chunked encoding tests.
* test-suite/tests/web-http.test ("chunked encoding"): Use
  'pass-if-equal' where appropriate.
2016-05-22 18:40:43 +02:00
Andy Wingo
534139e458 Support for non-blocking I/O
* doc/ref/api-io.texi (I/O Extensions): Document read_wait_fd /
  write_wait_fd members.
  (Non-Blocking I/O): New section.
* libguile/fports.c (fport_read, fport_write): Return -1 if the
  operation would block.
  (fport_wait_fd, scm_make_fptob): Add read/write wait-fd
  implementation.
* libguile/ports-internal.h (scm_t_port_type): Add read_wait_fd /
  write_wait_fd.
* libguile/ports.c (default_read_wait_fd, default_write_wait_fd): New
  functions.
  (scm_make_port_type): Initialize default read/write wait fd impls.
  (trampoline_to_c_read, trampoline_to_scm_read)
  (trampoline_to_c_write, trampoline_to_scm_write): To Scheme, a return
  of #f indicates EWOULDBLOCk.
  (scm_set_port_read_wait_fd, scm_set_port_write_wait_fd): New
  functions.
  (port_read_wait_fd, port_write_wait_fd, scm_port_read_wait_fd)
  (scm_port_write_wait_fd, port_poll, scm_port_poll): New functions.
  (scm_i_read_bytes, scm_i_write_bytes): Poll if the read or write would
  block.
* libguile/ports.h (scm_set_port_read_wait_fd)
  (scm_set_port_write_wait_fd): Add declarations.
* module/ice-9/ports.scm: Shunt port-poll and port-{read,write}-wait-fd
  to the internals module.
* module/ice-9/sports.scm (current-write-waiter):
  (current-read-waiter): Implement.
* test-suite/tests/ports.test: Adapt non-blocking test to new behavior.
* NEWS: Add entry.
2016-05-20 14:57:27 +02:00
Andy Wingo
8b6f4df3f4 Fix sports.test
* test-suite/tests/sports.test (include-tests): Fix encoding when
  reading ports.test.
2016-05-18 22:11:32 +02:00
Andy Wingo
e32dcf214e Test Scheme port implementation
* module/ice-9/ports.scm: Add port-decode-char to internals export
  list.
* test-suite/Makefile.am:
* test-suite/tests/sports.test: Add new test.
2016-05-16 14:04:54 +02:00
Andy Wingo
1e058add7b U+FFFD is the input substitution character
* libguile/ports.c (UNICODE_REPLACEMENT_CHARACTER):
* libguile/ports.c (peek_utf8_codepoint)
  (scm_port_decode_char, peek_iconv_codepoint):
* module/ice-9/sports.scm (peek-char-and-len/utf8):
  (peek-char-and-len/iconv): Return U+FFFD when we get a decoding error
  when reading, instead of '?', in accordance with Unicode
  recommendations.
* test-suite/tests/iconv.test:
* test-suite/tests/ports.test:
* test-suite/tests/rdelim.test: Update tests.
* NEWS: Update.
2016-05-16 10:48:35 +02:00
Andy Wingo
1953d29038 Decoding errors do not advance read pointer
* libguile/ports.c (scm_getc): If the port conversion strategy is
  'error, signal an error before advancing the read pointer.  This is a
  change from previous behavior; before, we advanced the read pointer
  under an understanding that that was what R6RS required.  But, that
  seems to be not the case.
* test-suite/tests/ports.test ("string ports"): Update decoding-error
  tests to assume that read-char with an error doesn't advance the read
  pointer.
* test-suite/tests/rdelim.test ("read-line"): Likewise.
2016-05-10 11:36:28 +02:00
Andy Wingo
5e470ea48f Fix R6RS imports of interfaces that use interfaces
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): In Guile, a
  module's public interface is just another module, and that means that
  it can import other modules as well.  Allow for R6RS modules that
  import module whose interfaces import other modules to access all
  visible bindings.
* test-suite/tests/rnrs-libraries.test ("import features"): Update
  test.
2016-04-14 12:35:55 +02:00
Andy Wingo
8399e7af51 Generic port facility provides buffering uniformly
* libguile/ports.h (struct scm_t_port_buffer): New data type.
  (struct scm_t_port): Refactor to use port buffers instead of
  implementation-managed read and write pointers.  Add "read_buffering"
  member.
  (SCM_INITIAL_PUTBACK_BUF_SIZE, SCM_READ_BUFFER_EMPTY_P): Remove.
  (scm_t_ptob_descriptor): Rename "fill_input" function to "read", and
  take a port buffer, returning void.  Likewise "write" takes a port
  buffer and returns void.  Remove "end_input"; instead if there is
  buffered input and rw_random is true, then there must be a seek
  function, so just seek back if needed.  Remove "flush"; instead all
  calls to the "write" function implicitly include a "flush", since the
  buffering happens in the generic port code now.  Remove "setvbuf", but
  add "get_natural_buffer_sizes"; instead the generic port code can
  buffer any port.
  (scm_make_port_type): Adapt to read and write prototype changes.
  (scm_set_port_flush, scm_set_port_end_input, scm_set_port_setvbuf):
  Remove.
  (scm_slow_get_byte_or_eof_unlocked)
  (scm_slow_get_peek_or_eof_unlocked): Remove; the slow path is to call
  scm_fill_input.
  (scm_set_port_get_natural_buffer_sizes): New function.
  (scm_c_make_port_buffer): New internal function.
  (scm_port_non_buffer): Remove.  This was a function for
  implementations that is no longer needed.  Instead open with BUF0 or
  use (setvbuf port 'none).
  (scm_fill_input, scm_fill_input_unlocked): Return the filled port
  buffer.
  (scm_get_byte_or_eof_unlocked, scm_peek_byte_or_eof_unlocked): Adapt
  to changes in buffering and EOF management.
* libguile/ports.c: Adapt to port interface changes.
  (initialize_port_buffers): New function, using the port mode flags to
  set up appropriate initial buffering for all ports.
  (scm_c_make_port_with_encoding): Create port buffers here instead of
  delegating to implementations.
  (scm_close_port): Flush the port if needed instead of delegating to
  the implementation.
* libguile/filesys.c (set_element): Adapt to buffering changes.
* libguile/fports.c (fport_get_natural_buffer_sizes): New function,
  replacing scm_fport_buffer_add.
  (fport_write, fport_read): Update to let the generic ports code do the
  buffering.
  (fport_flush, fport_end_input): Remove.
  (fport_close): Don't flush in a dynwind; that's the core ports' job.
  (scm_make_fptob): Adapt.
* libguile/ioext.c (scm_redirect_port): Adapt to buffering changes.
* libguile/poll.c (scm_primitive_poll): Adapt to buffering changes.
* libguile/ports-internal.h (struct scm_port_internal): Remove
  pending_eof flag; this is now set on the read buffer.
* libguile/r6rs-ports.c (struct bytevector_input_port): New type.  The
  new buffering arrangement means that there's now an intermediate
  buffer between the bytevector and the user of the port; this could
  lead to a perf degradation, but on the other hand there are some other
  speedups enabled by the buffering refactor, so probably the memcpy
  cost is dwarfed by the cost of the other parts of the ports
  machinery.
  (make_bytevector_input_port, bytevector_input_port_read):
  (bytevector_input_port_seek, initialize_bytevector_input_ports): Adapt
  to new buffering arrangement.
  (struct custom_binary_port): Remove read buffer, as Guile handles that
  now.
  (custom_binary_input_port_setvbuf): Remove; now handled by Guile.
  (make_custom_binary_input_port, custom_binary_input_port_read)
  (initialize_custom_binary_input_ports): Adapt.
  (scm_get_bytevector_some): Adapt to new EOF management.
  (scm_t_bytevector_output_port_buffer): Hold on to the underlying port,
  so we can flush it if it's open.
  (make_bytevector_output_port, bytevector_output_port_write):
  (bytevector_output_port_seek): Adapt.
  (bytevector_output_port_procedure): Flush the port as appropriate, so
  that we get all the bytes.
  (make_custom_binary_output_port, custom_binary_output_port_write):
  Adapt.
  (make_transcoded_port): Don't muck with buffering.
  (transcoded_port_write): Simply forward the write to the underlying
  port.
  (transcoded_port_read): Likewise.
  (transcoded_port_close): No need to flush.
  (initialize_transcoded_ports): Adapt.
* libguile/read.c (scm_i_scan_for_encoding): Adapt to buffering
  changes.
* libguile/rw.c (scm_write_string_partial): Adapt to buffering changes.
* libguile/strports.c: Adapt to the fact that we don't manage the
  buffer.  Probably room for speed improvements here...
* libguile/vports.c (soft_port_get_natural_buffer_sizes): New function.
  Adapt the rest of the file for the new buffering regime.
* test-suite/tests/r6rs-ports.test ("8.2.10 Output ports"): Custom
  binary output ports need to be flushed before you can rely on the
  write! procedure having been called.  Add necessary flush-port
  invocations.
  ("8.2.6  Input and output ports"): Transcoded ports now have an
  internal buffer by default.  This test checks that the characters are
  transcoded one at a time, so to do that, call setvbuf on the
  transcoded port to remove the buffer.
* test-suite/tests/web-client.test (run-with-http-transcript): Fix for
  different flushing regime on soft ports.  (The vestigial flush
  procedure is now called after each write, which is not what the test
  was expecting.)
* test-suite/standalone/test-scm-c-read.c: Update for changes to the C
  interface for defining port types.
* doc/ref/api-io.texi (Ports): Update to discuss buffering in a generic
  way, and to remove a hand-wavey paragraph describing string ports as
  "interesting and powerful".
  (Reading, Writing): Remove placeholder comments.  Document
  `scm_lfwrite'.
  (Buffering): New section.
  (File Ports): Link to buffering.
  (I/O Extensions): Join subnodes into parent and describe new API,
  including buffering API.
* doc/ref/posix.texi (Ports and File Descriptors): Link to buffering.
  Remove unread-char etc, as they are documented elsewhere.
  (Pipes, Network Sockets and Communication): Link to buffering.
2016-04-06 19:21:44 +02:00
Andy Wingo
b77fb752dd Flush buffered reads / writes before seeking
* libguile/ports.c (scm_seek): Flush before seeking on a buffered port.
* libguile/fports.c (fport_seek):
* libguile/strports.c (st_seek): Remove code to flush buffers.
* test-suite/tests/ports.test: Update test expectations that the
  putback buffer is flushed on a seek.  Previously there was a special
  case for SEEK_CUR with an offset of 0 to avoid flushing buffers, but
  that's an arbitrary choice that differs from all other combinations of
  OFFSET and WHENCE.
2016-04-04 16:30:57 +02:00
Andy Wingo
59a18451b8 Use symbols instead of _IONBF values as args to setvbuf
* libguile/ports.c (scm_setvbuf): Use the symbols `none', `line', and
  `block' instead of the values `_IONBF', `_IOLBF', and `_IOFBF'.
* NEWS: Update.
* doc/ref/posix.texi (Ports and File Descriptors): Update setvbuf
documentation.
* module/ice-9/deprecated.scm (define-deprecated): New helper.
(_IONBF, _IOLBF, _IOFBF): Define deprecated values.
* benchmark-suite/benchmarks/read.bm ("read"):
* benchmark-suite/benchmarks/uniform-vector-read.bm
("uniform-vector-read!"):
* libguile/r6rs-ports.c (cbip_fill_input):
* module/system/base/types.scm (%ffi-memory-backend):
* module/web/client.scm (open-socket-for-uri):
* module/web/server/http.scm (http-read):
* test-suite/tests/ports.test ("pipe, fdopen, and line buffering"):
("setvbuf"):
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports"): Update to use
non-deprecated interfaces.
2016-04-04 16:30:56 +02:00
Andy Wingo
6d7c09c8a9 web: Be less strict when parsing entity tags.
* module/web/http.scm (parse-entity-tag): Be less strict, accepting
  unquoted strings as well.

* test-suite/tests/web-http.test ("response headers"): Add a test for
  etag parsing.
2016-01-07 10:53:57 +01:00
Andy Wingo
8f18b71b7a Remove add1 and sub1
* libguile/vm-engine.c: Remove add1 and sub1 instructions.  Will replace
  with add/immediate and sub/immediate.
* module/language/tree-il/peval.scm (peval): If we reify a new
  <primcall>, expand it.  Removes 1- and similar primcalls.
* module/language/tree-il/primitives.scm: Don't specialize (+ x 1) to 1+.
  (expand-primcall): New export, does a single primcall expansion.
  (expand-primitives): Use the new helper.
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm:
* module/language/cps/types.scm:
* module/system/vm/assembler.scm: Remove support for add1 and sub1 CPS
  primitives.
* test-suite/tests/peval.test ("partial evaluation"): Adapt tests that
  expect 1+/1- to expect +/-.
2015-12-01 11:30:55 +01:00
Andy Wingo
58153e3a08 Remove frame-procedure
* libguile/frames.h:
* libguile/frames.c (scm_frame_procedure): Remove.
* test-suite/tests/eval.test ("stacks"): Adapt test.
* NEWS: Add news item.
* doc/ref/api-debug.texi (Frames): Document frame-procedure-name instead
  of frame-procedure.
2015-12-01 11:30:54 +01:00
Andy Wingo
e5d7c0f13b All arities serialize a "closure" binding
* module/language/cps/compile-bytecode.scm (compile-function): Always
  define a 'closure binding in slot 0.
* module/system/vm/frame.scm (available-bindings): No need to futz
  around not having a closure binding.
* module/system/vm/debug.scm (arity-arguments-alist): Expect a closure
  binding.
* test-suite/tests/rtl.test: Emit definitions for the closure.
2015-12-01 10:57:20 +01:00
Andy Wingo
e3cc0eeb3a Reflection support for unboxed f64 slots
* module/system/vm/assembler.scm (emit-definition): Add representation
  field.
  (write-arities): Emit representations into the arities section.

* module/system/vm/debug.scm (arity-definitions): Read representations.

* module/system/vm/frame.scm (<binding>): Add representation field and
  binding-representation getter.
  (available-bindings): Pass representation to make-binding.
  (frame-binding-set!, frame-binding-ref, frame-call-representation):
  Pass representation to frame-local-ref / frame-local-set!.

* test-suite/tests/rtl.test: Update definition instructions.

* module/language/cps/slot-allocation.scm ($allocation): Add
  representations field.
  (lookup-representation): New public function.
  (allocate-slots): Pass representations to make-$allocation.

* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
  emit-definition change.

* libguile/frames.h:
* libguile/frames.c (scm_frame_local_ref, scm_frame_local_set_x): Take
  representation argument.
  (scm_to_stack_item_representation): New internal helper.
2015-10-28 17:43:55 +00:00
Andy Wingo
8db54c80ce rtl.test uses return-values
* test-suite/tests/rtl.test: Fix up to use return-values.
2015-10-28 11:33:17 +00:00
Andy Wingo
70c317ab51 SP-relative local addressing
* libguile/vm-engine.c: S24/S12/S8 operands addressed relative to the
  SP, not the FP.  Cache the SP instead of a FP-relative locals
  pointer.  Further cleanups to follow.

* libguile/vm.c (vm_builtin_call_with_values_code): Adapt to mov operand
  addresing change.

* module/language/cps/compile-bytecode.scm (compile-function): Reify
  SP-relative local indexes where appropriate.

* module/system/vm/assembler.scm (emit-fmov*): New helper, exported as
  emit-fmov.
  (shuffling-assembler, define-shuffling-assembler): Rewrite to shuffle
  via push/pop/drop.
  (standard-prelude, opt-prelude, kw-prelude): No need to provide for
  shuffling args.

* test-suite/tests/rtl.test: Update.

* module/language/cps/slot-allocation.scm: Don't reserve slots 253-255.
2015-10-21 11:49:20 +02:00
Mark H Weaver
00884bb79f Allow decoding of UTF-8 containing U+FFFD, the replacement character.
* libguile/strings.c (scm_from_utf8_stringn): Use 'u8_mbtoucr' and check
  for a decoding error by its 'nbytes' return value.  Previously we used
  'u8_mbtouc' and improperly assumed that a U+FFFD character indicated a
  decoding error.
* libguile/symbols.c (utf8_string_equals_wide_string): Likewise.
* test-suite/tests/bytevectors.test (exception:decoding-error): New
  variable.
  ("2.9 Operations on Strings"): Add tests.
2015-08-13 01:31:36 -04:00
Andy Wingo
4632f3d998 Fix bug compiling fixpoint combinator
* module/language/tree-il/peval.scm (<operand>): Rename "alias-value"
  field to "alias", which is now an operand and not an expression.
  This allows the operand to capture its environment; before, the
  alias was being visited in its use environment instead of its
  definition environment.
  (peval): Adapt to operand change.  Fix construction of rest bindings
  as well.
* test-suite/tests/peval.test ("partial evaluation"): New test.
2015-05-20 19:18:45 +02:00
Daniel Llorens
eb3d623da5 Non-vector 1D arrays print as #1()
* libguile/arrays.c (scm_i_print_array): Print the dimension whenever
  the array is a true scm_tc7_array.

* test-suite/tests/arrays.test: Check that non-vector 1D arrays print as
  expected.
2015-02-18 09:32:30 +01:00
Andy Wingo
577eab817c (system base types) knows about variables
* module/system/base/types.scm (%tc7-variable): New tc7.
  (cell->object): Handle tc7-variable.

* test-suite/tests/types.test ("opaque objects"): Add a test.
2015-02-17 10:58:29 +01:00
Andy Wingo
37ae02ffa0 Fix infinite loop in expander
* module/ice-9/psyntax.scm (resolve-identifier): There is a case where a
  syntax object can resolve to itself.  Prevent an infinite loop in that
  case by continuing to resolve by name.

* module/ice-9/psyntax-pp.scm: Regenerate.

* test-suite/tests/syncase.test ("infinite loop bug"): Add a test.
2015-02-13 16:43:01 +01:00
Andy Wingo
26350edcac Add #:static-slot-allocation?
* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_STATIC): Reserve the fourth
  GOOPS flag to indicate that a class has static slot allocation.

* libguile/goops.c (scm_init_goops_builtins): Define
  vtable-flag-goops-static for goops.scm.

* module/oop/goops.scm (class-has-statically-allocated-slots?): New
  helper.
  (build-slots-list): Instead of the ad-hoc checks for <class> or
  <slot>, use the new helper.
  (initialize): Accept #:static-slot-allocation? keyword.

* module/system/foreign-object.scm (make-foreign-object-type): Declare
  foreign object classes as having static slot allocation.

* test-suite/tests/goops.test ("static slot allocation"): Add tests.
2015-02-06 13:25:17 +01:00
Andy Wingo
7b0a8dfb75 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/goops.c
	libguile/vm-engine.h
	module/oop/goops.scm
	module/oop/goops/compile.scm
	module/oop/goops/dispatch.scm
	test-suite/tests/goops.test
2015-01-26 18:13:38 +01:00
Andy Wingo
649ec8d823 Accessor methods only apply to subclasses with their slot
* libguile/goops.c (is_accessor_method, scm_compute_applicable_methods):
  Fix regression from 51f66c9120 (2009).
  Accessor methods are added on each subclass on which the slot is
  present; therefore if a subclass doesn't have a method, then the
  methods doesn't apply.  Truly fixes #17355, unlike
  583a23bf10.

* module/oop/goops.scm (compute-cmethod, compute-getter-method)
  (compute-setter-method): Revert earlier changes.

* test-suite/tests/goops.test ("accessor slots"): Update for new
  expectations, in agreement with Guile 1.8.
2015-01-26 17:57:44 +01:00
Andy Wingo
583a23bf10 Fix accessor struct field inlining
* module/oop/goops/compile.scm: Inline into goops.scm, leaving a
  compatible interface stub behind.

* module/oop/goops/dispatch.scm: Don't import (oop goops compile), to
  break circularities.

* module/oop/goops.scm: Move (oop goops util) include up to the top, and
  import (ice-9 match).
  (compute-cmethod): Move here from compile.scm.  Add a special case for
  accessor methods, so as to fix bug #17355.
  (compute-getter-method, compute-setter-method): #:procedure slot is
  now generic.

* test-suite/tests/goops.test ("accessor slots"): New test.
2015-01-24 19:23:08 +01:00
Andy Wingo
e7097386cb Fix accessor struct inlining in GOOPS
Fixes bug #17355.

* module/oop/goops.scm (memoize-effective-method!): Adapt to
  compute-effective-method change.
  (compute-effective-method, %compute-effective-method): Renamed from
  compute-cmethod; now a generic protocol.
  (compute-specialized-effective-method)
  (%compute-specialized-effective-method): New sub-protocol.
  (memoize-generic-function-application!): Adapt to call the hard-wired
  compute-applicable-methods based on the concrete arguments types --
  the semantics is that %compute-applicable-methods is the
  implementation for <generic> functions.  Perhaps we should do the same
  for sort-applicable-methods and method-more-specific?.
  (compute-getter-method, compute-setter-method): The standard
  #:procedure is now a generic slot-ref.  It wasn't valid to inline
  field access here, because subtypes could have different field
  layouts.
  (compute-applicable-methods): Refactor generic definition to use
  lexical scoping.
  (compute-specialized-effective-method): New method for
  <accessor-method>, which does field access inlining based on the
  concrete types being applied.

* test-suite/tests/goops.test ("accessor slots"): New test.
2015-01-24 18:59:15 +01:00