bpt/guile.git
14 years ago* meta/gdb-uninstalled-guile.in: Specify a path to libtool.
Ken Raeburn [Thu, 29 Oct 2009 16:45:04 +0000 (12:45 -0400)]
* meta/gdb-uninstalled-guile.in: Specify a path to libtool.

14 years agoFix autogen.sh for Mac OS X.
Ken Raeburn [Thu, 29 Oct 2009 17:06:35 +0000 (13:06 -0400)]
Fix autogen.sh for Mac OS X.

* autogen.sh: If uname indicates that the OS is Darwin, run "glibtool"
  instead of "libtool" for the version number check.

14 years agoFix incorrect display of wide strings in decompilation
Michael Gran [Wed, 28 Oct 2009 13:27:47 +0000 (06:27 -0700)]
Fix incorrect display of wide strings in decompilation

A byte ordering error caused incorrect display of wide strings
when using the ",c" decompilation from the REPL.

* module/language/assembly/decompile-bytecode.scm (decode-bytecode):
  wide strings are encoded in native endianness

14 years agoModify bytevectors/string conversions to allow wide strings
Michael Gran [Wed, 28 Oct 2009 13:24:23 +0000 (06:24 -0700)]
Modify bytevectors/string conversions to allow wide strings

The bytevector to string conversion functions were accomplished
by converting via locale strings.  This did not allow conversions
of wide strings in an 8-bit locale.  This is avoided by using knowledge
of the storage format of the string.

* libguile/bytevectors.c (STRING_TO_UTF, scm_string_to_utf8): modify
  string to bytevector conversion to use internal string information
  (UTF_TO_STRING, scm_utf8_to_string): modify bytevector to string
  conversion

14 years agofix nil handling in the vm
Mark H Weaver [Tue, 27 Oct 2009 21:59:22 +0000 (22:59 +0100)]
fix nil handling in the vm

* libguile/vm-i-scheme.c (not, not-not): Treat nil as false.
  (null?, not-null?): Treat nil as null.

* libguile/vm-i-system.c (br-if, br-if-not): Treat nil as false.
  (br-if-null, br-if-not-null): Treat nil as null.

14 years agothe cube of lisp booleans (#f nil () #t)
Mark H Weaver [Mon, 26 Oct 2009 22:56:03 +0000 (23:56 +0100)]
the cube of lisp booleans (#f nil () #t)

 * Renumbers the IFLAG constants.

 * Adds several macros related to boolean type tests, null tests, and
   boolean-truth testing (including lisp-style boolean-truth tests).

 * Adds compile-time checks to verify the necessary IFLAG numbering
   properties needed for the checks to work properly.

 * Changes some existing code to use the new optimized macros, without
   changing the semantics of the code at all (except that scm_is_bool
   is changed from a function to a macro).

I added the following macros, whose names explicitly state how %nil
should be handled.  See the comments in the patch for more information
about these.

  scm_is_false_assume_not_lisp_nil  scm_is_true_assume_not_lisp_nil
  scm_is_false_and_not_lisp_nil     scm_is_true_or_lisp_nil
  scm_is_false_or_lisp_nil          scm_is_true_and_not_lisp_nil

  scm_is_lisp_false                 scm_is_lisp_true

  scm_is_null_assume_not_lisp_nil
  scm_is_null_and_not_lisp_nil
  scm_is_null_or_lisp_nil

  scm_is_bool_and_not_lisp_nil
  scm_is_bool_or_lisp_nil

The following already-existing macros are defined as aliases, such
that their semantics is unchanged (although scm_is_bool used to be a
function and is now a macro).

  scm_is_null   -->  scm_is_null_and_not_lisp_nil
  scm_is_false  -->  scm_is_false_and_not_lisp_nil
  scm_is_true   -->  scm_is_true_or_lisp_nil
  scm_is_bool   -->  scm_is_bool_and_not_lisp_nil

(I still believe that these should be changed to versions that handle
 %nil properly, but await approval on that point, so these patches do
 not make those changes)

Also, if the preprocessor macro SCM_ENABLE_ELISP is not true (this
macro already existed and was used in lang.h), all overheads
associated with %nil handling are eliminated from the above macros.

* libguile/tags.h (SCM_BOOL_F, SCM_BOOL_T, SCM_UNSPECIFIED)
  (SCM_UNDEFINED, SCM_UNBOUND, SCM_ELISP_NIL): Renumber, so that a
  number of important distinctions (false versus true, end-of-list, etc)
  can be made by masking a single bit. Also define a number of
  build-time tests to assert that this condition holds.

* libguile/boolean.h (scm_is_false_and_not_nil, scm_is_true_or_nil)
  (scm_is_false_assume_not_nil, scm_is_true_assume_not_nil):
  (scm_is_false_or_nil, scm_is_true_and_not_nil)
  (scm_is_bool_or_nil, scm_is_bool_and_not_nil): New exciting macros to
  test certain boolean/end-of-list properties.
  (scm_is_false, scm_is_true): Use a restrictive definition, where only
  SCM_BOOL_F is false. Should probably change in the future.
  (scm_is_bool): Incompatible change: changed to be a macro. Was a
  function before. Probably should allow nil as a boolean, but that will
  be for a later patch.
  (scm_is_lisp_false, scm_is_lisp_true): New macros, implementing the
  standard Lisp boolean predicates, where '() is actually false.

* libguile/eval.i.c (CEVAL): Fix a number of false-or-nil and similar
  tests to use the new macros.

* libguile/lang.h (SCM_NULL_OR_NIL_P): Use scm_is_null_or_nil.

* libguile/pairs.c: Add a compile-time check that null and nil differ by
  only one bit.

* libguile/pairs.h (scm_is_null_and_not_nil, scm_is_null_assume_not_nil)
  (scm_is_null_or_nil): New exciting macros!
  (scm_is_null): Just be scm_is_null_and_not_nil, for now.

* libguile/print.c: Adapt to the reordering, and print suitably nasty
  things for the not-to-be-used values.

14 years agoUse proper fold/for-each function types in `hashtab.h'.
Ludovic Courtès [Mon, 26 Oct 2009 22:56:03 +0000 (23:56 +0100)]
Use proper fold/for-each function types in `hashtab.h'.

* libguile/hashtab.h (scm_t_hash_fold_fn, scm_t_hash_handle_fn): New
  types.
  (scm_internal_hash_fold, scm_internal_hash_for_each_handle): Use them.

* libguile/hashtab.c (scm_internal_hash_fold): Take an
  `scm_t_hash_fold_fn'.  Update callers.
  (scm_internal_hash_for_each_handle): Take an `scm_t_hash_handle_fn'.
  Update callers.

14 years agoUse proper assoc/hash function types in `hashtab.c'.
Ludovic Courtès [Mon, 26 Oct 2009 22:38:13 +0000 (23:38 +0100)]
Use proper assoc/hash function types in `hashtab.c'.

This is a followup to d587c9e8b27219e68f8813fb648fc6913c93be0f ("Use
proper types for hash/assoc functions in `hashtab.h'.").

* libguile/hashtab.c (scm_i_rehash, scm_hash_fn_create_handle_x,
  scm_hash_fn_ref, scm_hash_fn_set_x, scm_hash_fn_remove_x): Use
  `scm_t_hash_fn' and `scm_t_assoc_fn' as appropriate.

14 years agoupdate procedure docs for programs, lambda*, case-lambda
Andy Wingo [Mon, 26 Oct 2009 23:08:20 +0000 (00:08 +0100)]
update procedure docs for programs, lambda*, case-lambda

* module/system/vm/program.scm: Export the arity things again, and
  program-arity. Why not.

* doc/ref/api-procedures.texi (Compiled Procedures): Update for current
  API.
  (Optional Arguments): Update to assume lambda* and define* are always
  available, and (ice-9 optargs) is now the ghetto.
  (Case-lambda): Now here, moved from SRFI-16 docs. Also docs
  case-lambda*.

* doc/ref/srfi-modules.texi: Point to core case-lambda docs.

14 years agoimplement #:predicate
Andy Wingo [Mon, 26 Oct 2009 20:20:23 +0000 (21:20 +0100)]
implement #:predicate

will be useful for making e.g. typecase-lambda. Tough to tell though.

* module/ice-9/psyntax.scm (lambda-formals, lambda*-formals): Parse out
  a #:predicate, which goes right before the rest args. The vanilla
  lambda doesn't parse it out of course, but it does return another
  value.
  (chi-lambda-case, lambda*, lambda): Expand and pass the predicate on
  to build-lambda-case.

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

* module/language/tree-il/compile-glil.scm (flatten): Compile a failing
  predicate without an else clause into a call to `error'. Also, fix
  something the compile warnings caught.

14 years agoDon't use memset(3) after `GC_MALLOC ()' calls.
Ludovic Courtès [Mon, 26 Oct 2009 09:25:38 +0000 (10:25 +0100)]
Don't use memset(3) after `GC_MALLOC ()' calls.

* libguile/gc-malloc.c (scm_gc_calloc): Don't use memset(3) as it's not
  needed.  Reported by Andy Wingo.

14 years agoResolve warning in gcc-4.3 about transposed parameters passed to memset
Julian Graham [Sun, 25 Oct 2009 17:00:08 +0000 (13:00 -0400)]
Resolve warning in gcc-4.3 about transposed parameters passed to memset

* libguile/gc-malloc.c (scm_gc_calloc): Add explicit check on size parameter

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
14 years agoSRFI-35: Provide nice vtable names, to make GOOPS happier.
Ludovic Courtès [Sun, 25 Oct 2009 21:57:29 +0000 (22:57 +0100)]
SRFI-35: Provide nice vtable names, to make GOOPS happier.

* module/srfi/srfi-35.scm (%make-condition-type): New procedure.
  (make-condition-type, make-compound-condition-type): Use it.

* test-suite/tests/srfi-35.test ("condition
  types")["struct-vtable-name"]: New test.

14 years agoFix GOOPS `class-of' for nameless structs.
Ludovic Courtès [Sun, 25 Oct 2009 21:49:28 +0000 (22:49 +0100)]
Fix GOOPS `class-of' for nameless structs.

* libguile/goops.c (scm_class_of): Fix second argument for
  `scm_make_extended_class_from_symbol ()' for nameless structs.

* test-suite/tests/goops.test ("classes for built-in types")["struct
  vtable"]: New test case.

14 years agosrfi-16 just re-exports psyntax's case-lambda
Andy Wingo [Sun, 25 Oct 2009 12:19:11 +0000 (13:19 +0100)]
srfi-16 just re-exports psyntax's case-lambda

* module/srfi/srfi-16.scm (case-lambda): Just re-export the core's
  case-lambda, it's semantically the same but faster and better
  integrated.

14 years agocase-lambda, case-lambda* in psyntax
Andy Wingo [Sun, 25 Oct 2009 11:39:03 +0000 (12:39 +0100)]
case-lambda, case-lambda* in psyntax

* module/ice-9/psyntax.scm (case-lambda, case-lambda*): Add
  implementations of these, present in the base environment.

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

* module/srfi/srfi-16.scm (case-lambda): Replace the core's case-lambda
  definition with our own. We're not quite ready to switch yet.

14 years agoassembly/disassembly support for br-if-nargs-*
Andy Wingo [Sun, 25 Oct 2009 11:41:48 +0000 (12:41 +0100)]
assembly/disassembly support for br-if-nargs-*

* module/language/assembly/compile-bytecode.scm (write-bytecode): Handle
  br-if-nargs compilation.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  And decompile them nicely as well.

* module/language/assembly/disassemble.scm (code-annotation): And,
  present the disassembly if br-if-nargs-* nicely.

14 years agoarities can have noncontiguous starts and ends
Andy Wingo [Sun, 25 Oct 2009 12:01:57 +0000 (13:01 +0100)]
arities can have noncontiguous starts and ends

* module/language/glil/compile-assembly.scm (open-arity, close-arity)
  (begin-arity, glil->assembly): Refactor so that arities can have
  noncontiguous starts and ends. So within a prelude there is no arity
  -- only before (the previous arity) or after (the new arity).

* module/system/vm/program.scm (arity:end): Add this private accessor.
  Arities are expected to be in the new format. While not a change in
  objcode format, it is an incompatible change, so I'll bump the objcode
  cookie.
  (program-arity): Check that the ip is within both bounds of the arity.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/programs.c (scm_i_program_arity): Update for new arity format.

* module/system/vm/frame.scm (vm-frame-arguments): Avoid throwing an
  error in this function, which is called from the backtrace code.

14 years agorefactor psyntax.scm's treatment of lambda and lambda*
Andy Wingo [Sun, 25 Oct 2009 11:36:44 +0000 (12:36 +0100)]
refactor psyntax.scm's treatment of lambda and lambda*

* module/ice-9/psyntax.scm (lambda-formals, chi-simple-lambda)
  (lambda*-formals, chi-lambda-case): Refactor the lambda
  transformations with an eye to being able to do case-lambda.

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

* test-suite/tests/syntax.test: Adapted tests so that the errors we
  expect match what is given by psyntax.

14 years agodefine* in psyntax
Andy Wingo [Sat, 24 Oct 2009 14:32:27 +0000 (16:32 +0200)]
define* in psyntax

* module/ice-9/optargs.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm: Make define* available in the default
  environment, as lambda* is available there.

14 years agoprocedure property table is only key-weak, not doubly-weak
Andy Wingo [Sat, 24 Oct 2009 14:18:56 +0000 (16:18 +0200)]
procedure property table is only key-weak, not doubly-weak

* libguile/procprop.c: Make the procedure property table only key-weak.
  It seems that we want the association as long as the key is around.

14 years agoReduce some errors under -DSCM_DEBUG=1.
Ken Raeburn [Fri, 23 Oct 2009 18:00:19 +0000 (14:00 -0400)]
Reduce some errors under -DSCM_DEBUG=1.

* goops.c (scm_sys_modify_instance, scm_sys_modify_class): Use
SCM_{,SET_}CELL_WORD_[01] instead of SCM_{,SET}C[AD]R since the
objects passed are not pairs.

14 years ago(ice-9 optargs) based on the new lambda* work
Andy Wingo [Fri, 23 Oct 2009 14:29:06 +0000 (16:29 +0200)]
(ice-9 optargs) based on the new lambda* work

* module/ice-9/optargs.scm (let-optional, let-optional*, let-keywords)
  (let-keywords*): Implement in terms of parse-lambda-case, so all the
  logic is in one place.
  (lambda*): Re-export from the default environment -- it's all in the
  VM now :-))
  (define*, define*-public, defmacro*, defmacro*-public): Implement with
  syntax-case.

14 years agolambda* in psyntax
Andy Wingo [Fri, 23 Oct 2009 13:50:53 +0000 (15:50 +0200)]
lambda* in psyntax

* module/ice-9/psyntax.scm (build-lambda-case): Take an "inits" arg.
  Also work around a nasty memoizer bug: see
  http://article.gmane.org/gmane.lisp.guile.devel/9561.
  (lambda*): Implement in psyntax, in the default environment. Exciting
  stuff!

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

* module/ice-9/optargs.scm (parse-lambda-case): Helper for lambda* when
  we're running under the interpreter.

14 years agoseparate "inits" field in <lambda-case>; compile fixes for inits, kwargs
Andy Wingo [Fri, 23 Oct 2009 13:51:00 +0000 (15:51 +0200)]
separate "inits" field in <lambda-case>; compile fixes for inits, kwargs

* module/language/tree-il.scm (<lambda-case>): Add "inits" field, so we
  don't have to parse it out of opt and kw. Adapt the traversal
  procedures.
* module/language/tree-il/analyze.scm (analyze-lexicals): Analyze
  lexicals in the <lambda-case> init expressions as well. Fix keyword
  allocation.

* module/language/tree-il/compile-glil.scm (compile-glil): Adapt to
  make-lambda-case change.
  (flatten): Adapt to "inits" slot, actually init uninitialized args,
  and fix bugs related to keyword arguments.

* module/language/tree-il/inline.scm (inline!): Adapt a little bit --
  but with no effect.

* module/language/glil/compile-assembly.scm (glil->assembly): Flesh out
  <glil-kw-prelude> compilation some more. Add a "bound?" op for
  <glil-lexical>, which will push #t if the local is bound.

* module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case):
  Update for new signature of make-lambda-case.
* module/ice-9/psyntax-pp.scm: Regenerated.

* module/language/brainfuck/compile-tree-il.scm (compile-body):
* module/language/ecmascript/compile-tree-il.scm (comp):
* test-suite/tests/tree-il.test ("lambda"): Update for new lambda-case
  syntax.

14 years agoadd some optargs tests
Andy Wingo [Fri, 23 Oct 2009 13:47:08 +0000 (15:47 +0200)]
add some optargs tests

* libguile/modules.c (scm_module_lookup, scm_lookup): Throw to
  'unbound-variable, like eval.i.c does.

* test-suite/tests/optargs.test: Add an optargs test. Run optargs tests
  under both the VM and the interpreter.

14 years agovm support for optional/kwarg init code, and bugfixes
Andy Wingo [Fri, 23 Oct 2009 13:44:22 +0000 (15:44 +0200)]
vm support for optional/kwarg init code, and bugfixes

* libguile/vm-i-system.c (local-bound?, long-local-bound?)
  (variable-bound?): New instructions, push #f unless the local is
  bound. You can get unbound locals from optional arguments.
  (bind-optionals/shuffle): A number of bugfixes.
  (bind-kwargs): Bugfixes. If we enocunter an improper kwarg list but
  the procedure has a rest argument, just stop kwarg processing, but
  without an error.
  Renumbered ops.

* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump.

14 years agomore work towards compiling and interpreting keyword args
Andy Wingo [Mon, 19 Oct 2009 20:13:08 +0000 (22:13 +0200)]
more work towards compiling and interpreting keyword args

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bumparoo
* libguile/vm-i-system.c (push-rest, bind-rest): Logically there are
  actually two rest binders -- one that pops, conses, and pushes, and
  one that pops, conses, and local-sets. The latter is used on keyword
  arguments, because the keyword arguments themselves have been shuffled
  up on the stack. Renumber ops again.

* module/language/tree-il/compile-glil.scm (flatten): Attempt to handle
  compilation of lambda-case with keyword arguments. Might need some
  help.

* module/ice-9/psyntax.scm (build-lambda-case): An attempt to handle the
  interpreted case correctly. This might need a couple iterations, but
  at least it looks like the compile-glil code.

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

* module/language/glil.scm (<glil>): Rename "rest?" to "rest" in
  <glil-opt-prelude> and <glil-kw-prelude>, as it is no longer a simple
  boolean, but if true is an integer: the index of the local variable to
  which the rest should be bound.

* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
  "rest" vs "rest?". In the keyword case, use "bind-rest" instead of
  "push-rest".

* test-suite/tests/tree-il.test: Update for opt-prelude change.

14 years agofinish support for optional & keyword args; update ecmascript compiler
Andy Wingo [Sat, 17 Oct 2009 15:23:09 +0000 (17:23 +0200)]
finish support for optional & keyword args; update ecmascript compiler

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (br-if-nargs-ne, br-if-args-lt)
  (br-if-nargs-gt): New instructions, for use by different lambda cases.
  (bind-optionals, bind-optionals/shuffle, bind-kwargs): New
  instructions, for binding optional and keyword arguments. Renumber
  other ops.

* module/language/ecmascript/compile-tree-il.scm (comp, comp-body):
  Update for new tree-il. Use the new optional argument mechanism
  instead of emulating it with rest arguments.

* module/language/glil/compile-assembly.scm (glil->assembly): Tweaks for
  optional and keyword argument compilation.

* module/language/tree-il.scm (parse-tree-il, unparse-tree-il): Make the
  else case optional, in the s-expression serialization of tree-il.

* module/language/tree-il/compile-glil.scm (flatten): Handle all of the
  lambda-case capabilities.

14 years agofix brainfuck for new tree-il, and add tests
Andy Wingo [Fri, 16 Oct 2009 15:56:39 +0000 (17:56 +0200)]
fix brainfuck for new tree-il, and add tests

* test-suite/Makefile.am:
* test-suite/tests/brainfuck.test: Add a brainfuck test.

* module/system/base/compile.scm: Also export read-and-compile.

* module/language/tree-il/spec.scm (join): Fix the joiner in the
  0-expression case.

* module/language/tree-il/primitives.scm (+): Recognize (+ x -1) as 1-.

* module/language/brainfuck/parse.scm (read-brainfuck): Return EOF if we
  actually received EOF, and there were no expressions read.

* module/language/brainfuck/compile-tree-il.scm (compile-body): Fix the
  compiler for the new format of "lambda" in tree-il.

14 years agotree-il support for case-lambda
Andy Wingo [Tue, 13 Oct 2009 22:08:35 +0000 (00:08 +0200)]
tree-il support for case-lambda

* module/language/tree-il.scm (<lambda>, <lambda-case>): Split lambda
  into the lambda itself, denoting the procedure, and lambda-case,
  denoting a particular arity case. Lambda-case is fairly featureful,
  and has not yet been fully tested.
  (<let-values>): Use a <lambda-case> as the binding expression. Seems
  to suit the purpose well.
  Adapt parsers, unparsers, traversal operators, etc. Sometimes in this
  first version we assume there are no optional args, rest args, or a
  predicate.

* module/language/tree-il/analyze.scm (analyze-lexicals): Adapt for the
  new case-lambda regime. Fairly well commented. It actually simplifies
  things.
  (report-unused-variables): Update for new tree-il.

* module/language/tree-il/compile-glil.scm: Adapt for the new tree-il.
  There are some first stabs here at proper case-lambda compilation, but
  they are untested as of yet.

* module/language/tree-il/inline.scm (inline!): Rework so we can
  recurse on a single node; though these transformations are strictly
  reductive, so they should complete in bounded time. Simplify
  accordingly, and adapt to case-lambda. Oh, and we handle lambda->let
  in not just the nullary case.

* module/ice-9/psyntax.scm (build-simple-lambda, build-case-lambda)
  (build-lambda-case): New constructors. The idea is that after syntax
  expansion, we shouldn't have to deal with improper lists any more.
  Build-simple-lambda is a shortcut for the common case. The others are
  not fully exercised yet. Adapt callers.
  (syntax): Add some debugging in the lambda case. I don't fully
  understand this, but in practice we don't seem to see rest args here.
  (lambda): Inline chi-lambda-clause, and adapt for build-simple-lambda.
* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/tree-il.test: Update tests for new tree-il lambda
  format, and to expect post-prelude labels for all glil programs.

14 years agoprocedure property efficiency tweak
Andy Wingo [Tue, 13 Oct 2009 21:58:36 +0000 (23:58 +0200)]
procedure property efficiency tweak

* libguile/procprop.c (scm_procedure_property)
  scm_set_procedure_property_x): Fix to not call
  scm_procedure_properties(), and thus to avoid consing up the arity as
  well.

14 years agoflesh out glil support for optional and keyword arguments
Andy Wingo [Tue, 13 Oct 2009 21:55:58 +0000 (23:55 +0200)]
flesh out glil support for optional and keyword arguments

* libguile/vm-i-system.c (bind-rest): Renamed from push-rest-list.
  (reserve-locals): Change so that instead of reserving space for some
  additional number of locals, reserve-locals takes the absolute number
  of locals, including the arguments.

* module/language/glil.scm (<glil-std-prelude>, <glil-opt-prelude>)
  (<glil-kw-prelude>): New GLIL constructs, to replace <glil-arity>.

* module/language/glil/compile-assembly.scm (glil->assembly): Compile
  the new preludes. Some instructions are not yet implemented, though.

* module/language/tree-il/analyze.scm (analyze-lexicals): The nlocs for
  a lambda will now be the total number of locals, including arguments.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Update to
  write the new prelude.

* module/system/vm/program.scm (program-bindings-for-ip): If a given
  index doesn't have a binding at the ip given, don't cons it on the
  resulting list.

* test-suite/tests/tree-il.test: Update for GLIL changes.

14 years agode-nargs struct scm_objcode; procedure-property refactor
Andy Wingo [Tue, 13 Oct 2009 21:45:22 +0000 (23:45 +0200)]
de-nargs struct scm_objcode; procedure-property refactor

* libguile/objcodes.h (struct scm_objcode): Remove nargs, nrest, and
  nlocs, as they are no longer needed. Also obviates the need for a
  padding word.

* libguile/procs.c (scm_thunk_p): Use scm_i_program_arity for programs.

* libguile/procprop.c (scm_i_procedure_arity): Use scm_i_program_arity
  for programs.
  (scm_procedure_properties, scm_set_procedure_properties_x)
  (scm_procedure_property, scm_set_procedure_property_x): Rework so that
  non-closure properties are stored directly in a weak hash, instead of
  needing a weak hash of "stand-in" closures to hold the properties. Fix
  docstrings also.

* libguile/root.h (scm_stand_in_procs): Remove from the scm_sys_protects
  set. Actually with libGC, we should be able to store the elements of
  scm_sys_protects directly as global variables.
* libguile/gc.c (scm_init_storage): Remove scm_stand_in_procs
  initialization.

* libguile/programs.c (scm_i_program_arity): New private accessor, tries
  to determine the "minimum arity" of a program.

* libguile/vm.c (really_make_boot_program): Adapt to changes in
  struct scm_objcode.

* module/language/assembly.scm (*program-header-len*, byte-length):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/disassemble.scm (disassemble-load-program):
  Adapt to changes in objcode.

* module/system/xref.scm (program-callee-rev-vars): Adapt to changes in
  assembly.

* module/language/glil.scm: Remove nargs, nrest, and nlocs from
  glil-program.

* module/language/glil/compile-assembly.scm (make-meta, glil->assembly):
* module/language/glil/decompile-assembly.scm (decompile-toplevel):
  (decompile-load-program): Adapt to changes in GLIL and assembly.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Adapt to
  changes in GLIL.

* test-suite/tests/asm-to-bytecode.test: Adapt to assembly and bytecode
  changes.
* test-suite/tests/tree-il.test: Adapt to GLIL changes.

14 years agocallees now check their args, cons rest list, reserve locals
Andy Wingo [Mon, 28 Sep 2009 00:25:39 +0000 (20:25 -0400)]
callees now check their args, cons rest list, reserve locals

* gdbinit: Ignore SIGPWR and SIGXCPU, which the BDW GC seems to use.

* libguile/vm-engine.h (FETCH_WIDTH): Remove unused macro.
  (INIT_ARGS, INIT_FRAME): Remove; callees now check their args and
  reserve space for their locals.

* libguile/vm-engine.c:
* libguile/vm-i-system.c: Turn on callee arg checking and local
  reservation. Seems to work!

14 years agocallees reserve their own local vars
Andy Wingo [Sun, 27 Sep 2009 23:50:06 +0000 (19:50 -0400)]
callees reserve their own local vars

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (reserve-locals): New instruction, to reserve
  space for local vars. Other ops renumbered.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Emit
  reserve-locals instructions as necessary.

* test-suite/tests/tree-il.test: Update to expect reserve-locals as
  appropriate.

14 years agoruntime and debugging support for callee-parsed procedure args
Andy Wingo [Sun, 27 Sep 2009 23:25:58 +0000 (19:25 -0400)]
runtime and debugging support for callee-parsed procedure args

* libguile/objcodes.h: Bump for metadata format change.

* libguile/frames.h: Rework so we don't frob the program's nargs, nlocs,
  etc at runtime. Instead we don't really know what's a local var, an
  argument, or an intermediate value. It's a little unfortunate, but
  this will allow for case-lambda, and eventually for good polymorphic
  generic dispatch; and the nlocs etc can be heuristically
  reconstructed. Such a reconstruction would be better done at the
  Scheme level, though.
  (SCM_FRAME_STACK_ADDRESS): New macro, the pointer to the base of the
  stack elements (not counting the program).
  (SCM_FRAME_UPPER_ADDRESS): Repurpose to be the address of the last
  element in the bookkeeping part of the stack -- i.e. to point to the
  return address.

* libguile/vm-engine.h:
* libguile/vm-i-system.c: Adapt to removal of stack_base. Though we
  still detect stack-smashing underflow, we don't do so as precisely as
  we did before, because now we only detect overwriting of the frame
  metadata.

* libguile/vm-engine.c (vm_engine): Remove the stack_base variable. It
  is unnecessary, and difficult to keep track of in the face of
  case-lambda. Also fix miscommented "ra" and "mvra" pushes. Push the
  vp->ip as the first ra...
* libguile/vm-i-system.c (halt): ...because here we can restore the
  vp->ip instead of setting ip to 0. Allows us to introspect ips all
  down the stack, including in recursive VM invocations.

* libguile/frames.h:
* libguile/frames.c (scm_vm_frame_stack): Removed, because it's getting
  more difficult to tell what's an argument and what's a temporary stack
  element.
  (scm_vm_frame_num_locals): New accessor.
  (scm_vm_frame_instruction_pointer): New accessor.
  (scm_vm_frame_arguments): Defer to an implementation in Scheme.
  (scm_vm_frame_num_locals scm_vm_frame_local_ref)
  (scm_vm_frame_local_set_x): Since we can get not-yet-active frames on
  the stack now, with our current calling convention, we have to add a
  heuristic here to jump over those frames -- because frames have
  pointers in them, not Scheme values.

* libguile/programs.h:
* libguile/programs.c (scm_program_arity): Remove, in favor of..
  (scm_program_arities): ...this, which a list of arities, in a new
  format, occupying a slot in the metadata.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Fix mv-call decompilation.

* module/system/vm/frame.scm (vm-frame-bindings, vm-frame-binding-ref)
  (vm-frame-binding-set!): New functions, to access bindings by name in
  a frame.
  (vm-frame-arguments): Function now implemented in Scheme. Commented
  fairly extensively.

* module/system/vm/program.scm (program-bindings-by-index)
  (program-bindings-for-ip): New accessors, parsing the program bindings
  metadata into something more useful.
  (program-arities, program-arguments): In a case-lambda world, we have
  to assume that programs can have multiple arities. But it's tough to
  detect this algorithmically; instead we're going to require that the
  program metadata include information about the arities, and the parts
  of the program that that metadata applies to.
  (program-lambda-list): New accessor.
  (write-program): Show multiple arities.

* module/language/glil/compile-assembly.scm (glil->assembly): Add
  "arities" to the state of the compiler, and add arities entries as
  appropriate.

14 years agosteps on the way to have the callee check the number of arguments
Andy Wingo [Sun, 27 Sep 2009 22:16:56 +0000 (18:16 -0400)]
steps on the way to have the callee check the number of arguments

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/vm-i-system.c (assert-nargs-ee, assert-nargs-ge)
  (push-rest-list): New instructions, which for now don't actually do
  anything. Renumber the rest of the ops in this file.

* module/language/glil.scm (<glil-arity>): New GLIL type, an entity that
  checks the number of args for a block, optionally consing a rest list,
  and either branching or erroring if the arity doesn't match.

* module/language/glil/compile-assembly.scm (glil->assembly): Compile
  <glil-arity> to assembly. Some of these VM ops are not implemented --
  notably the branching case.

* module/language/tree-il/compile-glil.scm (flatten-lambda): Emit
  <glil-arity>.

* test-suite/tests/tree-il.test: Update.

14 years agoCompile Guile modules with `-Wunbound-variable'.
Ludovic Courtès [Thu, 22 Oct 2009 20:58:03 +0000 (22:58 +0200)]
Compile Guile modules with `-Wunbound-variable'.

* am/guilec (.scm.go): Compile with `-Wunbound-variable'.

14 years agoFix typos leading to unbound variable references.
Ludovic Courtès [Thu, 22 Oct 2009 20:42:45 +0000 (22:42 +0200)]
Fix typos leading to unbound variable references.

* module/ice-9/session.scm (help): Fix unbound reference to `env'.

* module/system/vm/program.scm (program-property): Fix typo.

* module/system/vm/frame.scm: Add missing `#:use-module (system vm
  objcode)'.

* module/system/repl/command.scm (guile:load): New.
  (load): Use either `primitive-load' or `load'.

* module/srfi/srfi-18.scm (thread-sleep!): Fix typo.

* module/srfi/srfi-19.scm: Use `(ice-9 rdelim)'.
  (date->broken-down-time, priv:year-day, priv:char->int): Fix typo.
  (time-*->time-*, time-*->time-*!): Fix reference to unbound variable
  `caller'.

* module/oop/goops.scm (bound-check-get): Fix typo.

* module/language/glil/compile-assembly.scm (glil->assembly): Fix typo.

* module/language/glil.scm (parse-glil): Fix typo.

* module/language/ecmascript/base.scm (object->value/string,
  object->value/number, ->number): Fix typos.

* module/language/assembly/disassemble.scm (disassemble-free-vars): Fix
  typo.

14 years agoAdjust `unbound-variable' GOOPS heuristic for `goops.scm'.
Ludovic Courtès [Thu, 22 Oct 2009 20:33:53 +0000 (22:33 +0200)]
Adjust `unbound-variable' GOOPS heuristic for `goops.scm'.

* module/language/tree-il/analyze.scm (goops-toplevel-definition): Add
  ENV argument.  Deal with GOOPS macros expanded within `goops.scm'.
  (report-possibly-unbound-variables): Adjust.

14 years agoFix bytecode disassembler.
Ludovic Courtès [Thu, 22 Oct 2009 20:29:22 +0000 (22:29 +0200)]
Fix bytecode disassembler.

* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Add missing argument to `ensure-label'.

14 years agoSRFI-88: Call `read-set!' at compile time and run time.
Ludovic Courtès [Thu, 22 Oct 2009 17:05:59 +0000 (19:05 +0200)]
SRFI-88: Call `read-set!' at compile time and run time.

* module/srfi/srfi-88.scm: Call `read-set!' both at compile time and run
  time.

14 years agoRemove obsolete `save-stack' case.
Ludovic Courtès [Wed, 21 Oct 2009 22:51:53 +0000 (00:51 +0200)]
Remove obsolete `save-stack' case.

* module/ice-9/boot-9.scm (save-stack): Remove obsolete `tk-stack' case.

14 years agoHave `-Wunbound-variable' account for GOOPS top-level definitions.
Ludovic Courtès [Wed, 21 Oct 2009 22:37:36 +0000 (00:37 +0200)]
Have `-Wunbound-variable' account for GOOPS top-level definitions.

* module/language/tree-il/analyze.scm (goops-toplevel-definition): New
  procedure.
  (report-possibly-unbound-variables): Check for GOOPS top-level
  definitions.

* test-suite/tests/tree-il.test ("warnings")["GOOPS definitions are
  visible"]: New test.

14 years agoAdd a `guile-2' SRFI-0 feature.
Ludovic Courtès [Wed, 21 Oct 2009 21:41:56 +0000 (23:41 +0200)]
Add a `guile-2' SRFI-0 feature.

* doc/ref/srfi-modules.texi (SRFI-0): Mention the `guile-2' feature.

* module/ice-9/boot-9.scm (%cond-expand-features): Add `guile-2'.

14 years agoUse proper types for hash/assoc functions in `hashtab.h'.
Ludovic Courtès [Mon, 19 Oct 2009 22:10:18 +0000 (00:10 +0200)]
Use proper types for hash/assoc functions in `hashtab.h'.

Partly fixes bug #23681 ("Function declarators with empty parentheses
should not be used").

* libguile/goops.c (scm_wrap_component): Cast `scm_sloppy_assq'.

* libguile/hashtab.c (scm_hash_fn_get_handle): Update to take functions
  of type `scm_t_hash_fn' and `scm_t_assoc_fn'.  Update callers.
  (scm_ihashx): Change to match `scm_t_hash_fn'.
  (scm_sloppy_assx): Change to match `scm_t_assoc_fn'.

* libguile/hashtab.h (scm_t_hash_fn, scm_t_assoc_fn): New types.
  (scm_t_hashtable)[hash_fn]: Change to `scm_t_hash_fn'.
  (scm_i_rehash, scm_hash_fn_get_handle, scm_hash_fn_create_handle_x,
  scm_hash_fn_ref, scm_hash_fn_set_x, scm_hash_fn_remove_x): Change to
  take `scm_t_hash_fn' and `scm_t_assoc_fn' parameters.

* libguile/srcprop.h (scm_whash_get_handle, scm_whash_create_handle,
  scm_whash_lookup): Implement in terms of `scm_hashq_*' instead of
  `scm_hash_fn_*'.

* libguile/struct.c (scm_struct_ihashq): Change to match
  `scm_t_hash_fn'.
  (scm_struct_create_handle): Cast `scm_sloppy_assq'.

* libguile/struct.h (scm_struct_ihashq): Update, make internal.

14 years agoFix typo in psyntax.scm related to syntax-violation reporting.
Julian Graham [Sun, 18 Oct 2009 21:56:13 +0000 (17:56 -0400)]
Fix typo in psyntax.scm related to syntax-violation reporting.

* module/ice-9/psyntax.scm (chi-macro): Replace `s' with `(wrap-subst w)'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
14 years agoAdd support for R6RS/SRFI-30 nested block comments.
Ludovic Courtès [Mon, 19 Oct 2009 20:38:34 +0000 (22:38 +0200)]
Add support for R6RS/SRFI-30 nested block comments.

Suggested by Andreas Rottmann <a.rottmann@gmx.at>.

* libguile/read.c (flush_ws, scm_read_sharp): Add support for
  R6RS/SRFI-30 block comments.
  (scm_read_r6rs_block_comment): New function.

* test-suite/tests/reader.test (exception:unterminated-block-comment):
  Adjust to match both block comment styles.
  ("reading")["R6RS/SRFI-30 block comment", "R6RS/SRFI-30 nested block
  comment", "R6RS/SRFI-30 block comment syntax overridden"]: New tests.
  ("exceptions")["R6RS/SRFI-30 unterminated nested block comment"]: New
  test.

* doc/ref/api-evaluation.texi (Block Comments): Mention SRFI-30/R6RS
  block comments.

* doc/ref/srfi-modules.texi (SRFI-30): New node.

14 years agocomment fixups to tree-il/compile-glil.scm
Andy Wingo [Sun, 27 Sep 2009 19:57:06 +0000 (15:57 -0400)]
comment fixups to tree-il/compile-glil.scm

* module/language/tree-il/compile-glil.scm: Remove some outdated
  comments.

14 years agojumps encoded using 24 bits, not 19; blocks no longer aligned
Andy Wingo [Thu, 17 Sep 2009 12:58:31 +0000 (14:58 +0200)]
jumps encoded using 24 bits, not 19; blocks no longer aligned

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (FETCH_OFFSET, BR): Labels are no longer 8-byte
  aligned; instead, jumps are encoded into 3 bytes instead of 2.
  (br, br-if, br-if-not, br-if-eq, br-if-not-eq, br-if-null)
  (br-if-not-null, mv-call): Adapt for new length of br instructions (3
  bytes instead of 2).

* libguile/vm.c (really_make_boot_program): Adapt hand-coded bytecode
  for new offset regime.

* module/language/assembly.scm (align-block): No alignment necessary.

* module/language/assembly/compile-bytecode.scm (write-bytecode): Write
  out breaks as 24-bit relative jumps.
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Decompile break instructions.

14 years agocompilation enviroments are always modules; simplifications & refactorings
Andy Wingo [Fri, 16 Oct 2009 13:27:10 +0000 (15:27 +0200)]
compilation enviroments are always modules; simplifications & refactorings

* module/ice-9/boot-9.scm (make-fresh-user-module): New public function,
  makes an anonymous beautified module.

* module/language/objcode/spec.scm: We used to have some things in here
  that allowed lexical variable names and values to be a part of the
  environment, but no more. Now an environment is just a module. If you
  want to "inject" free variables into code, just use lambda.

* module/language/scheme/compile-tree-il.scm (compile-tree-il): Same
  here. Also, rely on the fact that an environment *will* be a module --
  because (system base compile) guarantees that for us.

* module/language/scheme/spec.scm (scheme): In the reader, rely on the
  environment being a module. Define a #:make-default-environment
  handler, which returns a beautified module, augmented with a fresh
  definition for current-reader, so that side effects to current-reader
  are restricted to the compilation unit.

* module/language/tree-il/analyze.scm
  (report-possibly-unbound-variables):
* module/language/tree-il/compile-glil.scm (compile-glil):
* module/language/tree-il/optimize.scm (optimize!): The environment will
  be a module.

* module/system/base/language.scm (<language>): New field,
  `make-default-environment'. Defaults to `make-fresh-user-module'.
  (default-environment): New accessor, returns a default environment for
  a language.

* module/system/repl/common.scm (repl-compile): Always compile relative
  to the current module, because a module is always acceptable as an
  environment.

* module/system/base/compile.scm (compile-file, compile-and-load): Both
  of these have a new keyword argument, #:env. For `compile-file', it
  defaults to the default environment of the source language, and for
  `compile-and-load', to the current module.
  (read-and-compile): If there are no expressions read, pass the joiner
  its default environment (via `default-environment joint').

14 years agono more *compilation-environment* fluid
Andy Wingo [Fri, 16 Oct 2009 12:04:42 +0000 (14:04 +0200)]
no more *compilation-environment* fluid

* module/system/base/compile.scm (current-compilation-environment):
  Remove, as the only thing that needed it (language readers) now get
  the environment as an argument.
  (read-and-compile, compile): Rework for no *compilation-environment*,
  and default the environment using the define* mechanism.

* module/language/tree-il/analyze.scm (env-module): Hack around the lack
  of a current compilation module. Will fix this in the next commit so
  that the environment is always valid.

14 years agolanguage-readers receive environment as an arg
Andy Wingo [Fri, 16 Oct 2009 11:39:24 +0000 (13:39 +0200)]
language-readers receive environment as an arg

* module/language/assembly/spec.scm:
* module/language/brainfuck/spec.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/spec.scm:
* module/language/glil/spec.scm:
* module/language/scheme/spec.scm:
* module/language/tree-il/spec.scm: Language-readers now take two
  arguments: the port and the environment. This should allow for
  compile-environment-specific reader behavior.

* module/system/base/compile.scm (read-and-compile):
* module/system/repl/common.scm (repl-read): Pass the environment to the
  language-reader.

* module/system/repl/repl.scm (meta-reader, prompting-meta-read):
* module/system/repl/command.scm (define-meta-command): Use the second
  argument to repl-reader, so we avoid frobbing current-reader.

14 years agorepl-reader accepts optional "read" argument
Andy Wingo [Fri, 16 Oct 2009 11:30:52 +0000 (13:30 +0200)]
repl-reader accepts optional "read" argument

* module/ice-9/boot-9.scm (repl-reader): Accept an optional second
  argument, the reader to use. If it is given, use it instead of
  dereferencing the current-reader fluid.

* guile-readline/ice-9/readline.scm (activate-readline): Make our
  replacement definition of repl-reader compatible with boot-9.

14 years agoremove GHIL, Elisp, and R5RS languages
Andy Wingo [Fri, 16 Oct 2009 10:19:43 +0000 (12:19 +0200)]
remove GHIL, Elisp, and R5RS languages

GHIL is obsolete, and it's about time we got rid of it. Elisp and R5RS
were unmodified since their import from Guile-VM, so we ditch them too.

R5RS compilation is supported via compiling Scheme within an R5RS
environment.

Elisp will be supported when we merge in Daniel's work.

14 years agobitvector tweaks
Andy Wingo [Fri, 16 Oct 2009 09:59:30 +0000 (11:59 +0200)]
bitvector tweaks

* libguile/arrays.c (scm_from_contiguous_typed_array):
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): Error if the
  uniform element size is more than 8 bits, but not divisible by 8 --
  because our math could overflow in that case.

* module/ice-9/deprecated.scm (#\y): Indeed, #* is the valid bitvector
  syntax :)

14 years agoImprove TLS detection for systems with compiler support but no libc support.
Ludovic Courtès [Thu, 15 Oct 2009 21:52:00 +0000 (23:52 +0200)]
Improve TLS detection for systems with compiler support but no libc support.

* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): Use `AC_LINK_IFELSE'
  instead of `AC_COMPILE_IFELSE'.

14 years agoBump version number for 1.9.4.
Ludovic Courtès [Thu, 15 Oct 2009 21:31:57 +0000 (23:31 +0200)]
Bump version number for 1.9.4.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.

14 years agoFix compilation of literal bitvectors.
Ludovic Courtès [Thu, 15 Oct 2009 21:29:50 +0000 (23:29 +0200)]
Fix compilation of literal bitvectors.

* libguile/arrays.c (scm_from_contiguous_typed_array): Fix BYTE_LEN
  sanity check for bitvectors.

* test-suite/tests/unif.test ("syntax")["bitvector is self-evaluating"]:
  New test.

* module/ice-9/deprecated.scm (#\y): Fix deprecation comment: `#*' is
  not a read syntax.

14 years agoFix segfault for `(uniform-array->bytevector (bitvector))'.
Ludovic Courtès [Thu, 15 Oct 2009 21:24:19 +0000 (23:24 +0200)]
Fix segfault for `(uniform-array->bytevector (bitvector))'.

* libguile/bytevectors.c (scm_uniform_array_to_bytevector): Fix BYTE_LEN
  computation for bitvectors.

* test-suite/tests/bytevectors.test ("uniform-array->bytevector"): New
  test prefix.

14 years agoFix `gitlog-to-changelog' on NixOS.
Ludovic Courtès [Thu, 15 Oct 2009 19:55:54 +0000 (21:55 +0200)]
Fix `gitlog-to-changelog' on NixOS.

14 years agoDocument the interaction of the "compilee" with the compiler's current module.
Ludovic Courtès [Thu, 15 Oct 2009 19:29:42 +0000 (21:29 +0200)]
Document the interaction of the "compilee" with the compiler's current module.

This is a followup to 87c595c757b7db84ffdcfda96f736ab235e674a8 ("Compile
in a fresh module by default.") and
f65e2b1ec5ae1962e57322ac3085ab4d44025694 ("Honor and confine
expansion-time side-effects to `current-reader'.").

* doc/ref/api-evaluation.texi (Loading): Explain how to change
  `current-reader' in a compiler-friendly way.

* doc/ref/compiler.texi (The Scheme Compiler): Explain use of a fresh
  compilation module and separate `current-reader' fluid.

* test-suite/tests/compiler.test ("current-reader")["with eval-when"]:
  New test.

14 years agoFix REPL environment for languages other than scheme.
Ludovic Courtès [Thu, 15 Oct 2009 18:51:16 +0000 (20:51 +0200)]
Fix REPL environment for languages other than scheme.

* module/system/repl/common.scm (repl-compile): Use `#:env #f' for
  languages other than scheme.

14 years agosignedness fix fix fix
Andy Wingo [Thu, 15 Oct 2009 15:39:34 +0000 (17:39 +0200)]
signedness fix fix fix

* libguile/inline.h: Fix signedness fix fix.

14 years ago`load' autocompiles -- in the current module.
Andy Wingo [Thu, 15 Oct 2009 13:48:14 +0000 (15:48 +0200)]
`load' autocompiles -- in the current module.

* module/ice-9/boot-9.scm (load): Pull `autocompiled-file-name' inside
  `load', and make it autocompile in the current module. Should fix
  Julian's issue noted in
  http://article.gmane.org/gmane.lisp.guile.devel/9483.

14 years agoupdate NEWS for 1.9.4
Andy Wingo [Thu, 15 Oct 2009 13:45:03 +0000 (15:45 +0200)]
update NEWS for 1.9.4

14 years agofix scm_array_handle_ref signedness fix
Andy Wingo [Thu, 15 Oct 2009 13:44:45 +0000 (15:44 +0200)]
fix scm_array_handle_ref signedness fix

* libguile/inline.h: Fix signedness fix.

14 years agoadd back support for #y bitvector read syntax
Andy Wingo [Thu, 15 Oct 2009 13:05:36 +0000 (15:05 +0200)]
add back support for #y bitvector read syntax

* module/ice-9/deprecated.scm (#\y): Add deprecated support for
  #y(1 0 1 ...) bitvectors.

14 years agoUse pointer-less memory for `scm_gc_strdup ()'.
Ludovic Courtès [Wed, 14 Oct 2009 23:32:36 +0000 (01:32 +0200)]
Use pointer-less memory for `scm_gc_strdup ()'.

* libguile/gc-malloc.c (scm_gc_strndup): Use `GC_MALLOC_ATOMIC ()'
  instead of `GC_MALLOC ()'.

14 years agoRestore signature of `scm_primitive_load_path ()' as found in 1.8.
Ludovic Courtès [Wed, 14 Oct 2009 23:05:32 +0000 (01:05 +0200)]
Restore signature of `scm_primitive_load_path ()' as found in 1.8.

The incompatibility was introduced by
0fb81f95b0222c5ba49efd3e36cf797df54c0863 ("add exception_on_error
optional arg to primitive-load-path").

* libguile/load.c (scm_primitive_load_path): Change to take 1 rest
  argument.  Interpret the argument as either a file name (C-level
  backward compatibility with 1.8) or an actual argument list.
  (scm_c_primitive_load_path): Update caller.

* libguile/load.h (scm_primitive_load_path): Update accordingly.

* doc/ref/api-evaluation.texi (Loading): Update documentation of
  `primitive-load-path' and `scm_primitive_load_path ()'.

14 years agoUse GC-managed memory for port->encoding.
Ludovic Courtès [Wed, 14 Oct 2009 22:56:56 +0000 (00:56 +0200)]
Use GC-managed memory for port->encoding.

* libguile/ports.c (scm_new_port_table_entry): Use `scm_gc_strdup ()'
  instead of `strdup ()' for `entry->encoding'.
  (scm_i_set_port_encoding_x): Likewise.  Remove free(3) call.
  (scm_i_remove_port): Don't explicitly free memory.
  (scm_unget_byte): Remove outdated and misleading comment.

14 years agoFix signed/unsigned mismatch in `scm_array_handle_{ref,set} ()'.
Ludovic Courtès [Wed, 14 Oct 2009 21:20:54 +0000 (23:20 +0200)]
Fix signed/unsigned mismatch in `scm_array_handle_{ref,set} ()'.

* libguile/inline.h (scm_array_handle_ref, scm_array_handle_set): Cast
  `h->base' so that it matches the signedness of `p'.

14 years agoFlush output before forking, to make test output consistent and avoid
Ken Raeburn [Tue, 13 Oct 2009 15:45:34 +0000 (11:45 -0400)]
Flush output before forking, to make test output consistent and avoid
duplication.

* test-suite/tests/socket.test: Before calling primitive-fork, call
  force-output on the current output and error ports.

14 years agoadd $libir to the ltdl path, not $pkglibdir; add extensionsdir
Andy Wingo [Tue, 13 Oct 2009 09:31:02 +0000 (11:31 +0200)]
add $libir to the ltdl path, not $pkglibdir; add extensionsdir

* libguile/Makefile.am (libpath.h): Fix SCM_LIB_DIR to point to the
  libdir, not pkglibdir. Add SCM_EXTENSIONS_DIR, for a dir to put in the
  dynamic-link search path that's not managed by ldconfig or the like;
  and put this dir in the "extensionsdir" key of %guile-build-info.

* libguile/dynl.c (sysdep_dynl_init): Rename the installed-libdir
  environment var to GUILE_SYSTEM_EXTENSIONS_PATH (from
  GUILE_SYSTEM_LTDL_PATH). Also add SCM_EXTENSIONS_DIR to the ltdl
  search path in the default case.
* meta/uninstalled-env.in: Adapt override to match.

* meta/guile-2.0.pc.in: Add extensionsdir, so you can pkg-config
  --variable=extensionsdir guile-2.0.

14 years agoModify regexp.test to work better with mac/darwin
Michael Gran [Mon, 12 Oct 2009 13:55:25 +0000 (06:55 -0700)]
Modify regexp.test to work better with mac/darwin

* test-suite/tests/regexp.test (set-latin-1): also add .ISO8859-1 as a
  possible extension for latin-1 locales.  Use set-latin-1 exclusively
  to set the locale for tests.

14 years agoRevert changes that gather thread-specific local language
Michael Gran [Fri, 9 Oct 2009 14:06:14 +0000 (07:06 -0700)]
Revert changes that gather thread-specific local language

The method used was not portable.  However, the underlying problem
still exists: the uc_locale_language used by libunistring does not
work with thread-specific locale_t locales.

* libguile/i18n.c (locale_language): avoid unpacking semi-opaque type
  locale_t.

* test-suite/tests/i18n.test: set Turkish string and char locale upcase
  and downcase tests to throw untested

14 years agoAdjust to match changes in libgc's CVS (pre-7.2).
Ludovic Courtès [Fri, 9 Oct 2009 12:42:07 +0000 (14:42 +0200)]
Adjust to match changes in libgc's CVS (pre-7.2).

In libgc CVS the `GC_do_blocking ()' declaration is now public but it
uses a slightly different signature for its first argument.

* configure.ac: Check for `GC_fn_type'.

* libguile/threads.c (GC_fn_type)[HAVE_GC_DO_BLOCKING &&
  !HAVE_GC_FN_TYPE]: New typedef.
  (scm_without_guile): Explicitly cast `without_guile_trampoline' to
  `GC_fn_type'.  This is because the upstream definition currently
  looks like `typedef void * (extern *GC_fn_type)(void *);', which
  isn't compatible.

14 years agoUse TLS when available for `SCM_I_CURRENT_THREAD'.
Ludovic Courtès [Fri, 2 Oct 2009 14:32:34 +0000 (16:32 +0200)]
Use TLS when available for `SCM_I_CURRENT_THREAD'.

* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): New macro.

* configure.ac: Use it.

* libguile/__scm.h (SCM_THREAD_LOCAL): New macro.

* libguile/gen-scmconfig.c (main): Define `SCM_HAVE_THREAD_STORAGE_CLASS'.

* libguile/gen-scmconfig.h.in (SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS):
  New.

* libguile/threads.c
  (scm_i_current_thread)[SCM_HAVE_THREAD_STORAGE_CLASS]: New.
  (SET_CURRENT_THREAD): New macro.
  (guilify_self_1, on_thread_exit, init_thread_key): Use it.

* libguile/threads.h
  (scm_i_current_thread)[SCM_HAVE_THREAD_STORAGE_CLASS]: New
  declaration.
  (SCM_I_CURRENT_THREAD)[SCM_HAVE_THREAD_STORAGE_CLASS]: New macro.
  (init_thread_key_once, init_thread_key): Conditionalize on
  `!defined SCM_HAVE_THREAD_STORAGE_CLASS'.
  (scm_i_init_thread_for_guile): Update accordingly.

14 years agoArrange so that `SCM_I_CURRENT_THREAD' is not accessed outside of libguile.
Ludovic Courtès [Fri, 2 Oct 2009 13:28:29 +0000 (15:28 +0200)]
Arrange so that `SCM_I_CURRENT_THREAD' is not accessed outside of libguile.

* libguile/__scm.h (scm_async_tick): New declaration.
  (SCM_ASYNC_TICK)[!BUILDING_LIBGUILE]: Use `scm_async_tick ()'.

* libguile/async.c (scm_critical_section_start,
  scm_critical_section_end, scm_async_tick): New functions.

* libguile/async.h (scm_i_critical_section_mutex): Made internal.
  (scm_critical_section_start, scm_critical_section_end): New
  declarations.
  (SCM_CRITICAL_SECTION_START,
  SCM_CRITICAL_SECTION_END)[!BUILDING_LIBGUILE]: Use the same-named
  function (lower-case).

* libguile/stackchk.h (SCM_STACK_OVERFLOW_P): Conditionalize on
  `BUILDING_LIBGUILE'.

* libguile/threads.h (SCM_I_CURRENT_THREAD, scm_i_dynwinds,
  scm_i_set_dynwinds, scm_i_last_debug_frame,
  scm_i_set_last_debug_frame): Conditionalize on `BUILDING_LIBGUILE'.

14 years agoDeprecate `scm_mask_ints'.
Ludovic Courtès [Fri, 2 Oct 2009 13:02:52 +0000 (15:02 +0200)]
Deprecate `scm_mask_ints'.

* libguile/async.h (scm_mask_ints): Remove.

* libguile/deprecated.c (scm_i_mask_ints): New.

* libguile/deprecated.h (scm_mask_ints): New macro.
  (scm_i_mask_ints): New declaration.

14 years agoRevert "Change dynwind flag enums to #defines, for greater portability"
Neil Jerram [Wed, 7 Oct 2009 21:14:38 +0000 (22:14 +0100)]
Revert "Change dynwind flag enums to #defines, for greater portability"

This reverts commit b25aa0b9373d2798469e0fe999cd915e8beedc4f.

14 years agoFix typo in `scm_array_p_2 ()'.
Ludovic Courtès [Tue, 6 Oct 2009 21:40:30 +0000 (23:40 +0200)]
Fix typo in `scm_array_p_2 ()'.

* libguile/generalized-arrays.c (scm_array_p_2)[FUNC_NAME]: Fix.

14 years agoAdd compiler warning for possibly unbound variables.
Ludovic Courtès [Tue, 6 Oct 2009 21:39:56 +0000 (23:39 +0200)]
Add compiler warning for possibly unbound variables.

* module/language/tree-il/analyze.scm (<toplevel-info>): New record
  type.
  (env-module, report-possibly-unbound-variables): New procedures.

* module/language/tree-il/compile-glil.scm (%warning-passes): Add
  `unbound-variable'.

* module/system/base/message.scm (%warning-types): Likewise.

* test-suite/tests/tree-il.test (read-and-compile, %opts-w-unbound):
  New.
  ("warnings")["unbound variable"]: New test prefix.

14 years agotree-il: Pass the environment to warning passes.
Ludovic Courtès [Tue, 6 Oct 2009 21:36:53 +0000 (23:36 +0200)]
tree-il: Pass the environment to warning passes.

* module/language/tree-il/analyze.scm (report-unused-variables): Taken a
  new parameter, ENV.

* module/language/tree-il/compile-glil.scm (compile-glil): Pass E to
  individual warning passes.

14 years agoChange dynwind flag enums to #defines, for greater portability
Neil Jerram [Fri, 2 Oct 2009 21:18:52 +0000 (22:18 +0100)]
Change dynwind flag enums to #defines, for greater portability

Thanks to Inge Gutheil for raising this problem.

* doc/ref/api-control.texi (Dynamic Wind): Remove doc for
  scm_t_dynwind_flags, and change uses of scm_t_dynwind_flags to int.
  Mention possible flags inside doc for scm_dynwind_begin instead.
  Similarly for scm_t_wind_flags.  In this case the doc on possible
  flags is moved to after the four functions that can use them.

* libguile/dynwind.c (scm_dynwind_begin): Change scm_t_dynwind_flags
  to int.
  (scm_dynwind_unwind_handler): Change scm_t_wind_flags to int.
  (scm_dynwind_rewind_handler): Ditto.
  (scm_dynwind_unwind_handler_with_scm): Ditto.
  (scm_dynwind_rewind_handler_with_scm): Ditto.

* libguile/dynwind.h (SCM_F_DYNWIND_REWINDABLE): Use #define instead
  of typedef enum.
  (SCM_F_WIND_EXPLICITLY): Ditto.
  (function declarations): Change scm_t_dynwind_flags and
  scm_t_wind_flags to int.

* test-suite/standalone/test-unwind.c (check_cont_body): Change
  scm_t_dynwind_flags to int.

14 years agoUse `SCM_DEPRECATED' in declarations of deprecated functions/variables.
Ludovic Courtès [Fri, 2 Oct 2009 12:48:22 +0000 (14:48 +0200)]
Use `SCM_DEPRECATED' in declarations of deprecated functions/variables.

* libguile/deprecated.c (SCM_BUILDING_DEPRECATED_CODE): New macro.

* libguile/async.c (SCM_BUILDING_DEPRECATED_CODE): Likewise.

* libguile/macros.c (SCM_BUILDING_DEPRECATED_CODE): Likewise.

* libguile/async.h, libguile/deprecated.h, libguile/eval.h,
  libguile/gc.h, libguile/gc.h, libguile/macros.h, libguile/ports.h,
  libguile/srfi-4.h, libguile/strings.h: Change declarations of
  deprecated functions and variables to use `SCM_DEPRECATED' instead of
  `SCM_API'.

14 years agoAdd `SCM_DEPRECATED' macro to declare deprecated C functions/variables.
Ludovic Courtès [Fri, 2 Oct 2009 12:34:51 +0000 (14:34 +0200)]
Add `SCM_DEPRECATED' macro to declare deprecated C functions/variables.

* libguile/__scm.h (SCM_DEPRECATED): New macro.

14 years agoFix the argument list of gsubr stack frames.
Ludovic Courtès [Fri, 2 Oct 2009 08:26:30 +0000 (10:26 +0200)]
Fix the argument list of gsubr stack frames.

This fixes a bug introduced in e20d7001c3f7150400169fecb0bf0eefdf122fe2
and reported by Neil.

* libguile/eval.i.c (CEVAL)[DEVAL]: Don't duplicate ARG1 in
  `debug.info->a.args' for gsubr stack frames.
  (scm_apply): Likewise.

* test-suite/tests/eval.test ("stacks")["arguments of a gsubr stack
  frame"]: New test.

14 years agoFix doc for inet-ntop: always produces a string
Neil Jerram [Thu, 1 Oct 2009 22:38:57 +0000 (23:38 +0100)]
Fix doc for inet-ntop: always produces a string

Thanks to Scott McPeak for reporting this.

* libguile/socket.c (scm_inet_ntop): In docstring, add quotes around
  IPv6 address (+ reflow a bit).

* doc/ref/posix.texi (Network Address Conversion): Corresponding
  change.

* doc/maint/guile.texi: Corresponding change.

14 years agoFix handling of IPv6 addresses
Neil Jerram [Thu, 1 Oct 2009 22:27:59 +0000 (23:27 +0100)]
Fix handling of IPv6 addresses

Thanks to Scott McPeak for reporting this and providing a patch.

* libguile/socket.c (scm_to_ipv6): When address is the wrong type,
  provide more information in the exception message.

  (scm_to_sockaddr): scm_to_ipv6 expects just an address, not the
  whole vector.

* test-suite/tests/socket.test ("AF_INET6/SOCK_STREAM"): New set of
  tests.

14 years agoFix incorrect doc mentions of INADDR_LOCALHOST
Neil Jerram [Thu, 1 Oct 2009 21:27:07 +0000 (22:27 +0100)]
Fix incorrect doc mentions of INADDR_LOCALHOST

Thanks to Scott McPeak for reporting this.

* doc/ref/posix.texi (Network Sockets and Communication): Change
  INADDR_LOCALHOST to INADDR_LOOPBACK.

14 years agoAdd define-module to signals.test
Neil Jerram [Thu, 1 Oct 2009 20:56:49 +0000 (21:56 +0100)]
Add define-module to signals.test

* test-suite/tests/signals.test (test-suite): Add define-module form.

14 years agoChange signals.test to LGPLv3+
Neil Jerram [Thu, 1 Oct 2009 20:54:49 +0000 (21:54 +0100)]
Change signals.test to LGPLv3+

* test-suite/tests/signals.test: Update licence statement.

14 years agoRemove unused environments code and tests
Neil Jerram [Wed, 30 Sep 2009 22:06:02 +0000 (23:06 +0100)]
Remove unused environments code and tests

* libguile/environments.c, libguile/environments.h,
  test-suite/tests/environments.nottest: Deleted.

14 years agoFix spurious `throw from within critical section' errors
Neil Jerram [Tue, 10 Mar 2009 23:55:31 +0000 (23:55 +0000)]
Fix spurious `throw from within critical section' errors

The crux of this problem was that the thread doing a throw, and so
checking scm_i_critical_section_level, was different from the thread
that was in a critical section.

* libguile/async.h (scm_i_critical_section_level): Removed, replaced
  by per-thread critical_section_level.
  (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END): Use
  per-thread critical_section_level.

* libguile/continuations.c (scm_dynthrow): Check per-thread
  critical_section_level.

* libguile/threads.c (guilify_self_1): Init per-thread
  critical_section_level.
  (scm_i_critical_section_level): Removed.

* libguile/threads.h (scm_i_thread): New critical_section_level field.

* libguile/throw.c (scm_ithrow): Check per-thread critical_section_level.

14 years agoAvoid throw from critical section, given invalid sigaction call
Neil Jerram [Thu, 5 Mar 2009 20:03:33 +0000 (20:03 +0000)]
Avoid throw from critical section, given invalid sigaction call

* libguile/scmsigs.c (scm_sigaction_for_thread): Exit critical section
  before raising out-of-range error.

* test-suite/Makefile.am (SCM_TESTS): Add signals.test.

* test-suite/tests/signals.test: New file.

14 years agoMake `weaks.test' slightly more robust.
Ludovic Courtès [Mon, 28 Sep 2009 21:27:53 +0000 (23:27 +0200)]
Make `weaks.test' slightly more robust.

* test-suite/tests/weaks.test (global-weak): Use `string-copy' on all
  the keys, in case one of them is retained in `scm_source_whash' or
  similar.

14 years agoImprove description of `scm_set_smob_mark ()'.
Ludovic Courtès [Mon, 28 Sep 2009 21:21:47 +0000 (23:21 +0200)]
Improve description of `scm_set_smob_mark ()'.

* doc/ref/api-smobs.texi (Smobs): Improve description of
  `scm_set_smob_mark ()'.  Mention malloc(3) regions.

14 years agoRemove unneeded SMOB/port mark/free procedures.
Ludovic Courtès [Fri, 25 Sep 2009 11:45:16 +0000 (13:45 +0200)]
Remove unneeded SMOB/port mark/free procedures.

* libguile/arrays.c (array_mark, array_free): Remove.
  (scm_init_arrays): Adjust accordingly.

* libguile/bitvectors.c (bitvector_free): Remove.
  (scm_c_make_bitvector): Use `scm_gc_malloc_pointerless ()'.
  (scm_init_bitvectors): Adjust accordingly.

* libguile/strports.c (scm_make_stptob): Remove `scm_set_port_mark ()'
  call.

* libguile/vports.c (scm_make_sfptob): Likewise.