Andy Wingo [Wed, 7 Jan 2015 21:31:56 +0000 (16:31 -0500)]
Remove GOOPS random state
* libguile/goops.c: Remove GOOPS random state, now that there are no
more hashsets.
Andy Wingo [Wed, 7 Jan 2015 21:03:09 +0000 (16:03 -0500)]
More goops.c cleanups, and fix a security issue
* libguile/goops.c: Remove unused #includes.
(make_class_name): New helper, replaces unsafe use of sprintf.
(scm_make_extended_class): Rewrite to call scm_make_standard_class
directly.
(scm_make_port_classes): Rewrite to use scm_make_standard_class, and
no need to patch the CPL any more.
Andy Wingo [Tue, 6 Jan 2015 20:02:52 +0000 (15:02 -0500)]
Remove unused union scm_t_debug_info
* libguile/debug.h (union scm_t_debug_info): Remove unused type
declaration.
Andy Wingo [Tue, 6 Jan 2015 20:00:28 +0000 (15:00 -0500)]
More unused code removal in GOOPS
* libguile/goops.c: Remove unused sym_memoize_method_x.
Andy Wingo [Tue, 6 Jan 2015 19:59:02 +0000 (14:59 -0500)]
Remove private var_no_applicable_method capture
* libguile/goops.c (var_no_applicable_method): Remove unused capture.
(sym_no_applicable_method): Remove unused symbol.
Andy Wingo [Tue, 6 Jan 2015 19:54:44 +0000 (14:54 -0500)]
Remove scm_assert_bound
* libguile/goops.c (scm_assert_bound): Remove unexported unused helper.
* module/oop/goops.scm (make-generic-bound-check-getter): Change
assert-bound use to use `unbound?'.
Andy Wingo [Tue, 6 Jan 2015 19:51:44 +0000 (14:51 -0500)]
Remove scm_at_assert_bound_ref
* libguile/goops.c (scm_at_assert_bound_ref): Remove unused, unexported
function.
Andy Wingo [Tue, 6 Jan 2015 19:24:27 +0000 (14:24 -0500)]
Remove hashset slots from GOOPS classes
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, SCM_INSTANCE_HASH)
(SCM_SET_HASHSET):
* libguile/goops.c (prep_hashsets, scm_sys_make_root_class,
scm_sys_init_layout_x):
* module/oop/goops.scm (build-<class>-slots): Remove hashsets from
classes. We haven't implemented hashed dispatch since Guile 1.8, and
it's not clear that the particular formulation of dispatch is a good
idea.
Andy Wingo [Tue, 6 Jan 2015 19:16:03 +0000 (14:16 -0500)]
Deprecate C exports of GOOPS classes.
* libguile/deprecated.h:
(scm_class_boolean, scm_class_char, scm_class_pair)
(scm_class_procedure, scm_class_string, scm_class_symbol)
(scm_class_primitive_generic, scm_class_vector, scm_class_null)
(scm_class_real, scm_class_complex, scm_class_integer)
(scm_class_fraction, scm_class_unknown, scm_class_top)
(scm_class_object, scm_class_class, scm_class_applicable)
(scm_class_applicable_struct, scm_class_applicable_struct_with_setter)
(scm_class_generic, scm_class_generic_with_setter, scm_class_accessor)
(scm_class_extended_generic, scm_class_extended_generic_with_setter)
(scm_class_extended_accessor, scm_class_method)
(scm_class_accessor_method, scm_class_procedure_class)
(scm_class_applicable_struct_class, scm_class_number, scm_class_list)
(scm_class_keyword, scm_class_port, scm_class_input_output_port)
(scm_class_input_port, scm_class_output_port, scm_class_foreign_slot)
(scm_class_self, scm_class_protected, scm_class_hidden)
(scm_class_opaque, scm_class_read_only, scm_class_protected_hidden)
(scm_class_protected_opaque, scm_class_protected_read_only)
(scm_class_scm, scm_class_int, scm_class_float)
(scm_class_double, scm_port_class, scm_smob_class): Deprecate.
* libguile/deprecated.c:
* libguile/goops.c:
* libguile/goops.h: Adapt to deprecation.
* libguile/goops.h
* libguile/goops.c (scm_is_generic, scm_is_method): New interfaces.
(SCM_GENERICP, SCM_METHODP): Change to use new interfaces.
* libguile/ports.c (scm_make_port_type):
* libguile/smob.c (scm_make_smob_type, scm_set_smob_apply): Use internal
names for the port and smob class arrays.
Andy Wingo [Tue, 6 Jan 2015 18:41:56 +0000 (13:41 -0500)]
Generics with setters have <applicable-struct-with-setter> layout
* libguile/goops.c (scm_sys_set_object_setter_x): Remove. Instead, we
use slot-set! of 'setter.
(scm_i_define_class_for_vtable): Move lower in the file, and fold in
scm_make_extended_class_from_symbol and make_class_from_symbol.
Properly handle applicable structs with setters.
(scm_class_applicable_struct_with_setter_class): New private capture.
(scm_sys_bless_applicable_struct_vtables_x): Rename to take two
arguments, and bless the second argument as an applicable struct with
setter vtable.
(scm_sys_goops_early_init): Capture setter classes.
* libguile/deprecated.c (SPEC_OF, CPL_OF): Access slots by name, not by
index.
(applicablep, more_specificp): Adapt to use CPL_OF.
(scm_find_method): Access "methods" slot by name.
* libguile/procs.c (scm_setter): Remove special case for generics; if
it's a setter, it will be a normal applicable struct.
* module/oop/goops.scm (<applicable-struct-with-setter-class>)
(<applicable-struct-with-setter>): New classes.
(<generic-with-setter>): Now an instance of the setter metaclass and a
child of the setter class, so that the "setter" slot ends up in the
right place.
(<accessor>, <extended-generic-with-setter>, <extended-accessor>): Be
instances of the setter metaclass.
(<method>, <accessor-method>): Move definitions farther down.
(make): Use slot-set! when initializing setters here.
(initialize): Likewise for <applicable-struct-with-setter>. Remove
specialization for <generic-with-setter>.
Andy Wingo [Tue, 6 Jan 2015 17:06:59 +0000 (12:06 -0500)]
Remove unused CPP defines naming <method> slots
* libguile/goops.h (scm_si_generic_function, scm_si_specializers)
(scm_si_procedure, scm_si_formals, scm_si_body)
(scm_si_make_procedure): Remove unused CPP defines.
Andy Wingo [Tue, 6 Jan 2015 17:03:25 +0000 (12:03 -0500)]
Remove unused `default-slot-definition-class' <class> slot
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, scm_si_slotdef_class)
* module/oop/goops.scm (build-<class>-slots): Remove unused
`default-slot-definition-class' <class> slot.
Andy Wingo [Tue, 6 Jan 2015 16:56:23 +0000 (11:56 -0500)]
Remove useless scm_s_slot_set_x export
* libguile/goops.c:
* libguile/goops.h (scm_s_slot_set_x): Remove unused and useless
export.
Andy Wingo [Tue, 6 Jan 2015 16:50:37 +0000 (11:50 -0500)]
Remove unreachable code in scm_setter
* libguile/procs.c (scm_setter): Remove unreachable code.
Andy Wingo [Tue, 6 Jan 2015 16:50:16 +0000 (11:50 -0500)]
Deprecate scm_no_applicable_method C export
* libguile/deprecated.c (scm_init_deprecated_goops)
(scm_no_applicable_method):
* libguile/goops.h:
* libguile/goops.c (scm_no_applicable_method)
(scm_sys_goops_early_init): Deprecate scm_no_applicable_method C
export.
Andy Wingo [Tue, 6 Jan 2015 16:30:24 +0000 (11:30 -0500)]
Remove unused scm_t_method and SCM_METHOD
* libguile/goops.h (scm_t_method, SCM_METHOD): Remove unused struct
type, typedef, and macro.
Andy Wingo [Sun, 4 Jan 2015 20:52:12 +0000 (15:52 -0500)]
Fold GOOPS compile and dispatch modules into main GOOPS module
* libguile/goops.c (scm_sys_invalidate_method_cache_x): Remove C
interface to this internal method. Instead, internal callers are all
from Scheme, so we move the implementation to Scheme.
(scm_make): Dispatch to `make' in Scheme. This is an incompatible but
great change, as it fulfills the common user perception that scm_make
is the same as GOOPS's `make'.
(scm_sys_goops_early_init): Capture `make'.
(scm_no_applicable_method): Define in Scheme and capture in C.
* module/Makefile.am: Remove oop/goops/compile.scm and
oop/goops/dispatch.scm.
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm: Fold into goops.scm.
* module/oop/goops.scm: Fold in the generic compile and dispatch
modules. This eliminates a circularity that caused some eval-when
shenanigans, so remove the eval-whens as well. Reimplement the boot
version of `make' in Scheme, and make the <generic> `initialize'
method handle invalidation instead of the generic %allocate-instance.
(no-applicable-method): Define here. Import the utils module in the
normal define-module block.
Andy Wingo [Sun, 4 Jan 2015 20:37:03 +0000 (15:37 -0500)]
Remove unused *goops-module* definition.
* module/oop/goops.scm (*goops-module*): Remove.
Andy Wingo [Sun, 4 Jan 2015 20:35:25 +0000 (15:35 -0500)]
define-generic, define-extended-generic are hygienic syntax
* module/oop/goops.scm (define-generic, define-extended-generic):
(define-extended-generics): Reimplement using syntax-case.
Andy Wingo [Sun, 4 Jan 2015 20:18:39 +0000 (15:18 -0500)]
`class' is a hygienic macro
* module/oop/goops.scm (class): Rewrite as a hygienic macro.
Andy Wingo [Sun, 4 Jan 2015 18:43:14 +0000 (13:43 -0500)]
Deprecate scm_basic_make_class
* libguile/deprecated.h:
* libguile/deprecated.c (scm_basic_make_class): Deprecate.
* libguile/goops.c:
* libguile/goops.h (scm_make_standard_class): New internal helper. It's
a better spelling, as it matches make-standard-class, and is internal
so as not to cause confusion between boot GOOPS helpers and "real"
GOOPS interfaces.
Andy Wingo [Sun, 4 Jan 2015 18:41:09 +0000 (13:41 -0500)]
Move GOOPS boot to Scheme
* module/oop/goops.scm (build-<class>-slots): New helper, replacing
build_class_class_slots.
(build-slots-list, %compute-getters-n-setters, %compute-layout): New
private helpers, moved here from C.
(%prep-layout!): Reimplement in Scheme.
(make-standard-class): New private helper, replacing
scm_basic_make_class.
(<class>, <top>, <object>): Define in Scheme.
(<foreign-slot>, <protected-slot>, <hidden-slot>, <opaque-slot>,
<read-only-slot>, <self-slot>, <protected-opaque-slot>,
<protected-hidden-slot>, <protected-read-only-slot>, <scm-slot>,
<int-slot>, <float-slot>, <double-slot>, <procedure-class>,
<applicable-struct-class>, <method>, <accessor-method>, <applicable>,
<applicable-struct>, <generic>, <extended-generic>,
<generic-with-setter>, <accessor>, <extended-generic-with-setter>,
<extended-accessor>): Define in Scheme.
(<boolean>, <char>, <list>, <pair>, <null>, <string>, <symbol>,
<vector>, <foreign>, <hashtable>, <fluid>, <dynamic-state>, <frame>,
<vm-continuation>, <bytevector>, <uvec>, <array>, <bitvector>,
<number>, <complex>, <real>, <integer>, <fraction>, <keyword>,
<unknown>, <procedure>, <primitive-generic>, <port>, <input-port>,
<output-port>, <input-output-port>): Define in Scheme.
(compute-slots): Use build-slots-list helper.
* libguile/goops.h:
* libguile/goops.c (scm_basic_basic_make_class, scm_sys_compute_slots)
(scm_sys_prep_layout_x): Remove. These were available to C, but were
undocumented internals that were dangerous, confusing, and
unnecessary.
* libguile/goops.c: Add note about variable versus value references.
Remove internal C routines that were just used during boot, as they
have been moved to Scheme.
(scm_basic_make_class): Change to call out to make-standard-class in
Scheme.
(scm_sys_make_root_class, scm_sys_bless_applicable_struct_vtable_x)
(scm_sys_bless_pure_generic_vtable_x, scm_sys_init_layout_x): New
private helpers.
(scm_sys_goops_early_init): Change to capture values defined in
Scheme.
Andy Wingo [Sun, 4 Jan 2015 18:20:55 +0000 (13:20 -0500)]
Remove declarations without definitions
* libguile/goops.h: Remove declarations for scm_oldfmt, scm_c_oldfmt0,
and scm_c_oldfmt. These symbols were not defined.
Andy Wingo [Sun, 4 Jan 2015 18:19:50 +0000 (13:19 -0500)]
Remove unused %fast-slot-ref / %fast-slot-set! from GOOPS
* libguile/goops.h:
* libguile/goops.c (scm_sys_fast_slot_ref, scm_sys_fast_slot_set_x):
Remove these unused, unsafe functions. They were publically available
only to C.
* module/oop/goops/active-slot.scm (compute-get-n-set): Update to use
struct-ref / struct-set! instead of %fast-slot-ref / %fast-slot-set!
from (oop goops internal).
Andy Wingo [Wed, 24 Dec 2014 16:29:45 +0000 (11:29 -0500)]
Preparation for more GOOPS refactorings
* libguile/goops.c (scm_sys_goops_early_init)
(scm_init_goops_builtins): Factor out some initialization to a
separate helper. This will be the base for moving more things from C
to Scheme in the future.
* module/oop/goops.scm: Call %goops-early-init.
Andy Wingo [Wed, 24 Dec 2014 16:07:47 +0000 (11:07 -0500)]
%init-goops-builtins is an extension, not a global
* libguile/goops.h:
* libguile/goops.c (scm_init_goops, scm_init_goops_builtins): Move
%init-goops-builtins to be an extension instead of a globally
accessible function.
* module/oop/goops.scm: Adapt.
Andy Wingo [Wed, 24 Dec 2014 14:37:14 +0000 (09:37 -0500)]
compute-cpl implementation only in Scheme
* libguile/goops.c (build_class_class_slots, create_basic_classes):
Instead of creating <class> with uninitialized `direct-slots',
`slots', and `getters-n-setters' fields and initializing them later,
create <class> with a "boot" version of unspecialized slots and later
replace the fields with specialized slot classes. This allows
slot-ref to work during early boot, which is necessary to move
compute-cpl to Scheme.
(create_standard_classes): Finish initializing <class> here.
(map, filter_cpl, compute_cpl): Remove the boot-time compute-cpl in C
and its helpers.
(scm_basic_basic_make_class): Call compute-cpl in Scheme.
(fix_cpl): Remove; since we use the correct compute-cpl from the
beginning, there's no need to correct for the deficiencies of the C
implementation any more.
(build_slots_list): Adapt to build_class_class_slots change.
* module/oop/goops.scm (compute-std-cpl, compute-cpl): Move these up to
the top, so they can be called by the boot process.
(compute-clos-cpl, top-sort, std-tie-breaker, build-transitive-closure)
(build-constraints): Remove unused private code.
Andy Wingo [Thu, 18 Dec 2014 21:10:10 +0000 (22:10 +0100)]
More useless goops.c code removal
* libguile/goops.c: Remove needless scm_sym_define_public definition.
Andy Wingo [Thu, 18 Dec 2014 21:08:15 +0000 (22:08 +0100)]
Remove unused macros in goops.c
* libguile/goops.c (NXT_MTHD_METHODS, NXT_MTHD_ARGS): Remove unused
macros.
Andy Wingo [Thu, 18 Dec 2014 20:57:24 +0000 (21:57 +0100)]
Rewrite %method-more-specific? to be in Scheme
* libguile/goops.h:
* libguile/goops.c (more_specificp, scm_sys_method_more_specific_p):
* module/oop/goops.scm (%method-more-specific?): Rewrite in Scheme. We
remove the scm_sys_method_more_specific_p interface as it is a private
interface and it's not extensible.
Andy Wingo [Thu, 18 Dec 2014 20:31:18 +0000 (21:31 +0100)]
Deprecate C interfaces scm_compute_applicable_methods, scm_find_method
* libguile/deprecated.h:
* libguile/deprecated.c (scm_compute_applicable_methods): Deprecate.
This was the boot version of compute-applicable-methods, not the full
version; the right thing to do is to call scheme.
(scm_find_method): Deprecate. Again, the right thing is to do this on
the Scheme level.
* libguile/goops.c:
* libguile/goops.h: Deprecated code moved to deprecated.[ch].
Andy Wingo [Thu, 18 Dec 2014 11:51:11 +0000 (12:51 +0100)]
%compute-applicable-methods in Scheme
* libguile/goops.c: Move %compute-applicable-methods to Scheme.
(scm_sys_goops_loaded): No need to initialize
var_compute_applicable_methods.
* libguile/goops.h (scm_sys_compute_applicable_methods): Remove. This
was internal so it shouldn't cause a problem.
* module/oop/goops.scm (%sort-applicable-methods):
(%compute-applicable-methods): New definitions.
Andy Wingo [Fri, 23 Jan 2015 15:15:45 +0000 (16:15 +0100)]
Mark two coverage tests as XFAIL
* test-suite/tests/coverage.test ("several times", "one proc hit, one
proc unused"): Mark as XFAIL until we can fix either the expander or
the compiler to have proper source info.
Andy Wingo [Fri, 23 Jan 2015 15:07:00 +0000 (16:07 +0100)]
Fix the assembler for unexpected source properties
* module/system/vm/assembler.scm (link-debug): Fix for source properties
that don't have line and column, as are currently being produced by
the new lalr.
Andy Wingo [Thu, 22 Jan 2015 13:54:17 +0000 (14:54 +0100)]
Merge commit '
5b7632331e7551ac202bbaba37c572b96a791c6e'
Conflicts:
module/oop/goops.scm
Andy Wingo [Thu, 22 Jan 2015 13:53:06 +0000 (14:53 +0100)]
Merge commit '
ed72201a795ac1c8d6c0288b6bb710f2bd0ebd9c'
Conflicts:
test-suite/tests/r6rs-ports.test
Andy Wingo [Thu, 22 Jan 2015 13:49:36 +0000 (14:49 +0100)]
Merge commit '
01a301d1b606b84d986b735049e7155d2f4cd6aa'
Conflicts:
libguile/hash.c
Andy Wingo [Thu, 22 Jan 2015 13:48:40 +0000 (14:48 +0100)]
Merge commit '
894d0b894daae001495c748b3352cd79918d3789'
Conflicts:
libguile/hash.c
Andy Wingo [Thu, 22 Jan 2015 13:38:00 +0000 (14:38 +0100)]
Andy Wingo [Thu, 22 Jan 2015 13:37:52 +0000 (14:37 +0100)]
Andy Wingo [Thu, 22 Jan 2015 13:37:18 +0000 (14:37 +0100)]
Merge commit '
cdcba5b2f6270de808e51b3b933374170611b91d'
Conflicts:
module/statprof.scm
Andy Wingo [Thu, 22 Jan 2015 12:34:48 +0000 (13:34 +0100)]
Merge commit '
5d971db802eaa8038db17e1aa5b4c69452739744'
Conflicts:
libguile/ports.c
Andy Wingo [Thu, 22 Jan 2015 12:33:07 +0000 (13:33 +0100)]
Andy Wingo [Thu, 22 Jan 2015 12:32:59 +0000 (13:32 +0100)]
Merge commit '
7c433cbbce83bc9f2f9967afba00bbb68e312657'
Conflicts:
meta/Makefile.am
Andy Wingo [Thu, 22 Jan 2015 12:30:25 +0000 (13:30 +0100)]
Merge commit '
5fac1a7ada362d78f13143acbc0ceca7f2f101de'
Conflicts:
configure.ac
doc/ref/libguile-parallel.texi
Andy Wingo [Thu, 22 Jan 2015 12:24:30 +0000 (13:24 +0100)]
Andy Wingo [Thu, 22 Jan 2015 12:16:49 +0000 (13:16 +0100)]
Merge commit '
81d2c84674f03f9028f26474ab19d3d3f353881a'
Some fixups in bytevectors.c.
Andy Wingo [Thu, 22 Jan 2015 12:04:34 +0000 (13:04 +0100)]
Andy Wingo [Thu, 22 Jan 2015 12:04:11 +0000 (13:04 +0100)]
Andy Wingo [Mon, 19 Jan 2015 15:57:42 +0000 (16:57 +0100)]
Keywords have a tc7
* libguile/tags.h (scm_tc7_keyword): Allocate a tc7, so that the VM can
have cheap keyword? tests.
* libguile/keywords.c:
* libguile/keywords.h: Adapt.
* libguile/goops.c (scm_class_of, scm_sys_goops_early_init): Capture
<keyword>.
* libguile/print.c (iprin1): Inline keyword printer.
* libguile/evalext.c (scm_self_evaluating_p): Add keywords here.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_tc16_keyword): Deprecate.
* module/language/cps/compile-bytecode.scm (compile-fun): Add keyword?
case, and bitvector? case while we're at it.
* module/language/cps/effects-analysis.scm (define-primitive-effects):
Add bytevector?, keyword?, and bitvector? cases.
* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
keyword?.
* module/language/cps/types.scm (bitvector?, keyword?, bytevector?): Add
branch inferrers.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*effect-free-primitives*):
(*effect+exception-free-primitives*): Add bytevector?, keyword?, and
bitvector?.
* module/oop/goops.scm (<keyword>): New class.
* module/system/base/types.scm (%tc7-keyword, cell->object): Add cases.
* module/system/vm/assembler.scm (br-if-keyword): New definition.
* module/system/vm/disassembler.scm (code-annotation): Add br-if-tc7
case for keywords.
* test-suite/tests/types.test ("clonable objects"): Update now that
keywords are cloneable.
Andy Wingo [Mon, 19 Jan 2015 09:37:34 +0000 (10:37 +0100)]
Add allocate-struct, struct-ref, struct-set! instructions
* libguile/vm-engine.c (allocate-struct, struct-ref, struct-set!): New
instructions, to complement their "immediate" variants.
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Wire up the new instructions.
Andy Wingo [Thu, 22 Jan 2015 11:50:18 +0000 (12:50 +0100)]
Merge commit '
5af307de43e4b65eec7f235b48a8908f2a00f134'
Conflicts:
test-suite/tests/reader.test
Andy Wingo [Thu, 22 Jan 2015 11:46:11 +0000 (12:46 +0100)]
Andy Wingo [Thu, 22 Jan 2015 11:40:43 +0000 (12:40 +0100)]
Fix #:init-value on class-allocated slots
Allocating an instance of a class with a #:class or #:each-subclass slot
allocation should not re-initialize the class-allocated slot. In Guile
1.8, this worked by effectively doing a slot-bound? within
%initialize-object. In Guile 2.0 we instead initialize the slot when it
is allocated -- in compute-get-n-set.
* module/oop/goops.scm (compute-getters-n-setters): Don't set an
init-thunk for class-allocated slots.
(compute-get-n-set): Initialize class-allocated slots here, if an
init-thunk or init-value are present.
* test-suite/tests/goops.test ("#:each-subclass"): Add test.
Ludovic Courtès [Sun, 18 Jan 2015 20:52:48 +0000 (21:52 +0100)]
Fix buffer overrun with unbuffered custom binary input ports.
Fixes <http://bugs.gnu.org/19621>.
Before that, in 'cbip_fill_input', BUFFERED would be set to 0 when
reading from 'scm_getc' et al, because 'shortbuf' was being used. Thus,
we could eventually execute this line:
/* Copy the data back to the internal buffer. */
memcpy ((char *) c_port->read_pos, SCM_BYTEVECTOR_CONTENTS (bv),
c_octets);
But 'read_pos' would quickly point to the fields beyond 'shortbuf',
thereby leading to a corruption of the 'scm_t_port' itself.
* libguile/r6rs-ports.c (cbip_setvbuf): When READ_SIZE is 0, keep using
BV as the 'read_buf'.
(cbip_fill_input): Adjust assertion to accept 'read_buf_size = 1'.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port unbuffered & 'get-string-all'", "custom binary input port
unbuffered UTF-8 & 'get-string-all'"]: New tests.
Ludovic Courtès [Tue, 13 Jan 2015 08:30:08 +0000 (09:30 +0100)]
Improve output of command-line errors.
* module/ice-9/command-line.scm (shell-usage): Add 'newline' call when
FMT is true.
(compile-shell-switches)[error]: Prepend "error: " and append "~%" to
FMT.
Use a lower-case message.
Ludovic Courtès [Sun, 11 Jan 2015 21:40:07 +0000 (22:40 +0100)]
Optimize 'string-hash'.
This yields a 50% improvement on the "narrow string" benchmark of
'hash.bm', 41% on "wide string", and 76% on "long string".
* libguile/hash.c (scm_i_string_hash): Rewrite to avoid
'scm_i_string_ref' calls.
Ludovic Courtès [Sun, 11 Jan 2015 21:37:00 +0000 (22:37 +0100)]
Add 'string-hash' benchmarks.
* benchmark-suite/benchmarks/hash.bm: New file.
* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add it.
Ludovic Courtès [Sun, 11 Jan 2015 21:11:17 +0000 (22:11 +0100)]
Deprecate 'scm_string_hash'.
This function has been unused internally for some time and is undocumented.
* libguile/hash.c (scm_string_hash): Wrap if #if SCM_ENABLE_DEPRECATED
== 1.
* libguile/hash.h (scm_string_hash): Likewise, and replace SCM_API with
SCM_DEPRECATED.
Ludovic Courtès [Sun, 11 Jan 2015 20:57:54 +0000 (21:57 +0100)]
Optimize 'write' for strings.
This shows a 19% improvement on the "string without escapes"
micro-benchmark of 'write.bm', and 12% on "string with escapes".
* libguile/print.c (iprin1) <scm_tc7_string>: Replace 'scm_i_string_ref'
loop with a call to 'write_string'.
(display_character): Adjust description of return value in comment.
(write_string): New function.
Ludovic Courtès [Sun, 11 Jan 2015 19:58:34 +0000 (20:58 +0100)]
Avoid converting the 'mode' argument of 'open-file'.
* libguile/fports.c (scm_open_file_with_encoding): const-qualify 'md'
and 'ptr'. Add call to 'scm_i_try_narrow_string'. Use
'scm_i_string_chars' instead of 'scm_to_locale_string' plus '
scm_dynwind_free'.
* test-suite/tests/ports.test ("invalid wide mode string",
"valid wide mode string"): New tests.
Ludovic Courtès [Sun, 11 Jan 2015 19:44:36 +0000 (20:44 +0100)]
statprof: 'statprof' and 'with-statprof' return the code's return values.
* module/statprof.scm (statprof): Return the return values of THUNK.
(with-statprof): Adjust docstring accordingly.
* test-suite/tests/statprof.test ("return values"): New test.
* doc/ref/statprof.texi (Statprof): Adjust accordingly.
Ludovic Courtès [Fri, 9 Jan 2015 14:47:15 +0000 (15:47 +0100)]
Improve deprecation message of 'scm_add_to_port_table'.
Reported by Thien-Thi Nguyen <ttn@gnu.org>.
* libguile/ports.c (scm_add_to_port_table): Mention
'scm_new_port_table_entry'.
Mark H Weaver [Sun, 14 Dec 2014 15:24:00 +0000 (10:24 -0500)]
Assembler: Cope with non-string port filenames.
Fixes <http://bugs.gnu.org/19354>.
Reported by Linas Vepstas <linasvepstas@gmail.com>.
* module/system/vm/assembler.scm (write-sources): Intern the filename
only if it's a string. (For sockets, the filename is a symbol).
Andy Wingo [Wed, 10 Dec 2014 13:34:44 +0000 (14:34 +0100)]
Convert primitive-eval to "compile" its expressions to linked closures
* libguile/memoize.c (memoize): Fix meta on subsequent case-lambda
clauses.
* module/ice-9/eval.scm (primitive-eval): Rewrite to compile expressions
to thunks, to avoid runtime dispatch cost.
Andy Wingo [Wed, 10 Dec 2014 15:25:19 +0000 (16:25 +0100)]
Fix syntax.test
* test-suite/tests/syntax.test (exception:variable-ref): Change expected
error.
Andy Wingo [Sun, 7 Dec 2014 18:03:19 +0000 (19:03 +0100)]
Minor evaluator tweaks
* libguile/eval.c (eval): Remove unused variable.
* libguile/memoize.c (unmemoize): Fix unmemoization.
* module/ice-9/eval.scm: Attempt to speed up common box-ref cases.
Andy Wingo [Sun, 7 Dec 2014 14:52:34 +0000 (15:52 +0100)]
Simplify variable resolution in the evaluator
* libguile/expand.c (convert_assignment): Handle creation of the default
lambda-case body here.
* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval):
* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_BOX_REF, MAKMEMO_BOX_SET):
(MAKMEMO_TOP_BOX, MAKMEMO_MOD_BOX): Refactor all global var resolution
to go through "resolve". Add "box-ref" and "box-set!". Rename
memoize-variable-access! to %resolve-variable, and don't be
destructive.
Andy Wingo [Sun, 7 Dec 2014 08:34:22 +0000 (09:34 +0100)]
Closure conversion in evaluator
* libguile/memoize.c (MAKMEMO_CAPTURE_ENV, push_nested_link)
(push_flat_link, env_link_is_flat, env_link_vars)
(env_link_add_flat_var, lookup, capture_flat_env, memoize): Capture
flat environments around closures.
Andy Wingo [Sat, 6 Dec 2014 18:43:24 +0000 (19:43 +0100)]
Add capture-env to evaluator
* libguile/eval.c (eval):
* libguile/memoize.c (memoized_tags, unmemoize):
* libguile/memoize.h (SCM_M_CAPTURE_ENV):
* module/ice-9/eval.scm (primitive-eval): Add capture-env memoized
expression type.
Ludovic Courtès [Sat, 6 Dec 2014 14:57:23 +0000 (15:57 +0100)]
build: Better handle substitutions in 'guile-2.0.pc' & co.
* meta/Makefile.am (dependency_substitutions): Use '|' as the separate
instead of ','. See <http://hydra.nixos.org/build/
17684751>.
Andy Wingo [Fri, 5 Dec 2014 15:54:35 +0000 (16:54 +0100)]
Simplify the interpreter for trivial inits and no letrec
* libguile/memoize.c (FULL_ARITY): Serialize "ninits" and the unbound
value instead of the init list.
(memoize): Adapt to FULL_ARITY changes. Remove LETREC case.
(unmemoize): Adapt to memoized code change.
* libguile/eval.c (BOOT_CLOSURE_PARSE_FULL): Adapt to parse ninits and
unbound instead of inits.
(eval): Lexical-ref can no longer raise an error.
(prepare_boot_closure_env_for_apply): Adapt to inits change.
* module/ice-9/eval.scm (primitive-eval): Adapt to ninits/unbound
change.
* libguile/expand.c (expand_named_let): Fix lambda-case creation to make
lists for opt and inits.
Andy Wingo [Thu, 4 Dec 2014 14:07:01 +0000 (15:07 +0100)]
Assignment conversion in the interpreter
* libguile/expand.c (compute_assigned, convert_assignment)
(scm_convert_assignment): New functions.
* libguile/expand.h: Declare scm_convert_assignment.
* libguile/memoize.c (scm_memoize_expression): Do assignment conversion
before memoization.
* test-suite/tests/syntax.test ("letrec"): Detection of unbound letrec
variables now works.
Ludovic Courtès [Wed, 3 Dec 2014 22:09:12 +0000 (23:09 +0100)]
build: Add missing substitutions for 'guile-2.0.pc'.
This is a followup to
5fac1a7.
* meta/Makefile.am (substitute): Add GUILE_* and LIBGUILE_* substitutions,
and $(dependency_substitutions).
(dependency_substitutions): New variable.
Ludovic Courtès [Wed, 3 Dec 2014 18:07:28 +0000 (19:07 +0100)]
doc: Clarify the unit of the 'offset' argument of 'seek'.
Reported in <http://bugs.gnu.org/18520>
by David Kastrup <dak@gnu.org>.
* doc/ref/api-io.texi (Random Access): Clarify the unit of the 'offset'
argument to 'seek'.
Ludovic Courtès [Wed, 3 Dec 2014 17:59:00 +0000 (18:59 +0100)]
Add the 'guild' and 'guile' variables to 'guile-2.0.pc'.
* configure.ac: Remove meta/guile-2.0.pc and
meta/guile-2.0-uninstalled.pc from 'AC_CONFIG_FILES'.
* meta/Makefile.am (substitute): New variable.
(guile-2.0.pc, guile-2.0-uninstalled.pc): New targets.
(guile-config, guild): Use $(substitute) instead of duplicated sed
script.
(CLEANFILES): Add the .pc files.
* meta/guile-2.0.pc.in (bindir, guild, guile): New variables.
* doc/ref/libguile-parallel.texi (Parallel Installations): Document the
'guild' and 'guile' pkg-config variables.
Ludovic Courtès [Tue, 2 Dec 2014 20:25:26 +0000 (21:25 +0100)]
Update (system base lalr) from upstream.
Suggested by Jan Nieuwenhuizen <janneke@gnu.org>.
* module/system/base/lalr.upstream.scm: Update from
<https://github.com/schemeway/lalr-scm.git>, commit
4c4f149.
Ludovic Courtès [Tue, 2 Dec 2014 17:35:55 +0000 (18:35 +0100)]
doc: Tell when 'GUILE_INSTALL_LOCALE' first appeared.
* doc/ref/guile-invoke.texi (Environment Variables): Add footnote about
the Guile version where 'GUILE_INSTALL_LOCALE' appeared.
Chris Jester-Young [Sun, 30 Nov 2014 10:20:54 +0000 (05:20 -0500)]
Implement SRFI 28: Basic Format Strings.
* module/srfi/srfi-28.scm: New module.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-28.scm.
* doc/ref/srfi-modules.texi (SRFI-28): New node.
Ludovic Courtès [Thu, 20 Nov 2014 20:32:44 +0000 (21:32 +0100)]
doc: Clarify behavior of 'select' in the presence of signal interruptions.
Fixes <http://bugs.gnu.org/18988>.
Reported by Chris Vine <chris@cvine.freeserve.co.uk>.
* libguile/filesys.c (scm_select): Clarify handling of signal
interruptions.
* doc/ref/posix.texi (Ports and File Descriptors): Adjust accordingly.
Rob Browning [Wed, 24 Sep 2014 21:47:55 +0000 (16:47 -0500)]
Recognize m68k, s390x, and sh4 as compilation targets
* module/system/base/target.scm (cpu-endianness, triplet-pointer-size):
Add cases for "m68k", "sh4", and "s390x".
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Mark H Weaver [Wed, 12 Nov 2014 05:40:47 +0000 (00:40 -0500)]
Fix bytevector-fill! to accept fill arguments greater than 127.
Fixes <http://bugs.gnu.org/19027>.
* libguile/bytevectors.c (scm_bytevector_fill_x): Accept fill arguments
between -128 and 255.
* test-suite/tests/bytevectors.test ("2.2 General Operations"): Add
tests.
Mark H Weaver [Wed, 12 Nov 2014 05:35:34 +0000 (00:35 -0500)]
Avoid signed overflow and use size_t in bytevectors.c.
* libguile/bytevectors.c (ULONG_MAX): Remove (unportable) fallback
definition. It is no longer used.
(scm_make_bytevector): Use 'size_t' instead of 'unsigned' for
indices. Use 'scm_t_uint8' instead of 'signed char' for elements
and c_fill. Previously relied on GNU-C-specific behavior when
casting integers in the range 128-255 to signed char.
(GENERIC_INTEGER_ACCESSOR_PROLOGUE, INTEGER_LIST_TO_BYTEVECTOR)
(scm_bytevector_eq_p, scm_bytevector_copy_x, scm_bytevector_copy)
(scm_bytevector_to_u8_list, scm_u8_list_to_bytevector)
(scm_bytevector_fill_x): Use 'size_t' instead of 'unsigned' for
indices. Use 'scm_t_uint8' for elements.
Mark H Weaver [Wed, 12 Nov 2014 05:19:10 +0000 (00:19 -0500)]
Add SCM_VALIDATE_SIZE_COPY and SCM_NUM2SIZE.
* libguile/validate.h (SCM_VALIDATE_SIZE_COPY, SCM_NUM2SIZE): New
macros.
Mark H Weaver [Wed, 12 Nov 2014 04:14:26 +0000 (23:14 -0500)]
Fix bytevector-copy when applied to SRFI-4 homogeneous numeric vectors.
Fixes <http://bugs.gnu.org/18866>.
Reported by tantalum <sph@posteo.eu>.
* libguile/bytevectors.c (scm_bytevector_copy): Always create a VU8
bytevector.
* test-suite/tests/bytevectors.test: Add test.
Thomas Klausner [Wed, 29 Oct 2014 23:33:39 +0000 (00:33 +0100)]
Avoid bash-specific '==' comparison operator in guile.m4.
Fixes <http://bugs.gnu.org/18898>.
* meta/guile.m4 (GUILE_PROGS): Use '=' instead of the bash-specific '=='
comparison operator in 'test' call.
Mark H Weaver [Wed, 12 Nov 2014 03:30:14 +0000 (22:30 -0500)]
Fix strerror error handling when given a non-integer argument.
Fixes <http://bugs.gnu.org/18065>.
Reported and fixed by Glenn Michaels <gmichaels@Safe-mail.net>.
* libguile/error.c (scm_strerror): Convert the argument to a C integer
outside of the critical section, to avoid deadlock on error.
* THANKS: Add Glenn Michaels to the fixes section.
Andy Wingo [Sun, 9 Nov 2014 15:56:33 +0000 (15:56 +0000)]
texinfo: fix @url{@@} parsing
* module/texinfo.scm (texi-command-specs): The body of @url{} can have
texinfo commands.
* test-suite/tests/texinfo.test ("test-texinfo->stexinfo"): Add tests.
Andy Wingo [Wed, 15 Oct 2014 09:49:41 +0000 (11:49 +0200)]
web: Location header is URI-reference; better URI-reference support
* module/web/uri.scm (validate-uri): Add reference? keyword argument,
for validating references.
(build-uri): Clarify comments to indicate that the result is an
absolute URI.
(build-uri-reference): New interface, to build URI-references.
(string->uri-reference): Rename from string->uri*. Fix fragment
parsing to not include the #.
(string->uri): Adapt to string->uri-reference name change.
* module/web/request.scm (request-absolute-uri): Add default-scheme
optional argument. Use it if the request-uri has no scheme, or
error.
* module/web/http.scm (write-uri): Reflow to use "when". Fix writing of
URI-reference instances.
(declare-uri-reference-header!): Rename from
declare-relative-uri-header!. Use string->uri-reference.
("Location"): Declare as a URI-reference header, as per RFC 7231.
* module/web/client.scm (open-socket-for-uri): Handle the case in which
there is no URI scheme.
* test-suite/tests/web-http.test:
* test-suite/tests/web-uri.test: Add tests.
Ludovic Courtès [Fri, 31 Oct 2014 21:53:04 +0000 (22:53 +0100)]
Use on-stack or GC-managed memory in 'search-path'.
* libguile/load.c (stringbuf_free): Remove.
(stringbuf_grow): Use 'scm_gc_malloc_pointerless' instead of 'scm_realloc'.
(search_path): Use stack-allocated INITIAL_BUFFER instead of
'scm_malloc'. Remove use of 'stringbuf_free'.
Ludovic Courtès [Fri, 31 Oct 2014 22:27:44 +0000 (23:27 +0100)]
Reduce C heap allocations in 'search-path'.
* libguile/load.c (scm_c_string_has_an_ext): Rename to...
(string_has_an_ext): ... this. Add docstring. Change
'str' to be an SCM, and remove 'len' parameter. Change loop body to
use 'scm_string_suffix_p'.
(search_path): Update accordingly.
Daniel Llorens [Thu, 30 Oct 2014 10:42:05 +0000 (11:42 +0100)]
Merge branch 'lloda-array-support'
Mark H Weaver [Wed, 15 Oct 2014 00:36:11 +0000 (20:36 -0400)]
i18n: Add HAVE_USELOCALE as a requirement for USE_GNU_LOCALE_API.
* configure.ac: Check for uselocale.
* libguile/i18n.c: Add HAVE_USELOCALE to the list of requirements
before defining USE_GNU_LOCALE_API.
Mark H Weaver [Sat, 11 Oct 2014 02:36:54 +0000 (22:36 -0400)]
scm_boot_guile: Gracefully handle the case where argc == 0.
Fixes <http://bugs.gnu.org/18680>.
Reported by Nala Ginrut <nalaginrut@gmail.com>.
* libguile/init.c (scm_boot_guile): Do not canonicalize argv[0] unless
argc > 0.
* THANKS: Add Nala Ginrut to the fixes section.
Mark H Weaver [Tue, 7 Oct 2014 03:53:08 +0000 (23:53 -0400)]
Thank Per Bothner.
* THANKS: Add Per Bothner to the "libraries" section (for SRFI-64).
Ludovic Courtès [Mon, 6 Oct 2014 13:22:44 +0000 (15:22 +0200)]
build: Adjust autogen.sh to 'libtoolize' name on Darwin.
Reported by Daniel Llorens.
* autogen.sh: Use 'glibtoolize' on Darwin.
Mark H Weaver [Thu, 2 Oct 2014 00:45:41 +0000 (20:45 -0400)]
read: Accept "\(" in string literals.
Suggested by David Kastrup <dak@gnu.org> in <http://bugs.gnu.org/13644>.
* libguile/read.c (scm_read_string_like_syntax): Accept "\(" as
equivalent to "(".
* doc/ref/api-data.texi (String Syntax): Document it.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Wed, 1 Oct 2014 22:57:44 +0000 (18:57 -0400)]
docs: Fix documented return type of 'scm_c_export'.
Fixes <http://bugs.gnu.org/17869>.
Reported and fixed by Alexei Matveev <alexei.matveev@gmail.com>.
* doc/ref/api-modules.texi (Accessing Modules from C): Change documented
return type of 'scm_c_export' to 'void' to reflect reality.
* THANKS: Add Alexei Matveev to the fixes section.
Daniel Llorens [Fri, 19 Sep 2014 12:48:59 +0000 (14:48 +0200)]
Intern general arrays
* module/system/vm/assembler.scm (intern-constant, link-data): handle
the array case.
Daniel Llorens [Fri, 19 Sep 2014 12:48:22 +0000 (14:48 +0200)]
Pack array dimensions in array object
* libguile/arrays.c (scm_i_make_array): redo object layout.
* libguile/arrays.h (SCM_I_ARRAY_V, SCM_ARRAY_BASE, SCM_I_ARRAY_DIMS):
to match new layout.
(SCM_I_ARRAY_SET_V, SCM_ARRAY_SET_BASE): new setters.
(SCM_I_ARRAY_MEM, scm_i_t_array): unused, remove.
(scm_i_shap2ra, scm_make_typed_array, scm_from_contiguous_typed_array,
scm_from_contiguous_array, scm_make_shared_array, scm_transpose_array,
scm_array_contents): fix uses of SCM_I_ARRAY_V, SCM_ARRAY_BASE as
lvalues.
* libguile/array-map.c (make1array, scm_ramapc): fix uses of
SCM_I_ARRAY_V, SCM_ARRAY_BASE as lvalues.