bpt/guile.git
14 years agoSCM_DEBUG fix: Don't apply SCM_CAR to non-pairs when walking argument
Ken Raeburn [Mon, 16 Nov 2009 04:43:17 +0000 (23:43 -0500)]
SCM_DEBUG fix: Don't apply SCM_CAR to non-pairs when walking argument
lists in method cache matching.

* libguile/goops.c (scm_mcache_lookup_cmethod): Don't apply SCM_CAR to
  non-pairs when walking argument lists in method cache matching.
  Don't check for CLASSP or symbol in the car slot, since the end of
  the specifier list is a non-pair.  Update comments to reflect new
  structure of method cache entry.
* module/oops/goops/dispatch.scm: Update comments here too.

14 years agoAdd `iconv_open-solaris.h' to remove dependency on gperf.
Ludovic Courtès [Mon, 16 Nov 2009 13:57:01 +0000 (14:57 +0100)]
Add `iconv_open-solaris.h' to remove dependency on gperf.

* lib/iconv_open-solaris.h: New file.

14 years agoUse Gnulib's `alignof' module.
Ludovic Courtès [Sun, 15 Nov 2009 19:53:21 +0000 (20:53 +0100)]
Use Gnulib's `alignof' module.

* m4/gnulib-cache.m4: Use `alignof'.

* libguile/objcodes.c (scm_c_make_objcode_slice): Use `alignof_type'.

14 years agoDeprecate `inet-ntoa' and `inet-aton'.
Ludovic Courtès [Sun, 15 Nov 2009 19:50:08 +0000 (20:50 +0100)]
Deprecate `inet-ntoa' and `inet-aton'.

Suggested by Bruno Haible.

* libguile/inet_aton.c: Remove.

* libguile/Makefile.am (EXTRA_libguile_la_SOURCES): Remove
  `inet_aton.c'.

* libguile/deprecated.c (scm_inet_aton, scm_inet_ntoa): New functions.

* libguile/deprecated.h: Update accordingly.

* libguile/socket.c (scm_inet_aton, scm_inet_ntoa): Remove.

* doc/ref/posix.texi (Network Address Conversion): Mark `inet-ntoa' and
  `inet-aton' as deprecated.

14 years agoUse Gnulib's `inet_ntop' and `inet_pton' modules.
Ludovic Courtès [Sun, 15 Nov 2009 19:16:40 +0000 (20:16 +0100)]
Use Gnulib's `inet_ntop' and `inet_pton' modules.

* m4/gnulib-cache.m4: Add `inet_ntop' and `inet_pton'.

* configure.ac: Don't check for `inet_ntop' and `inet_pton'.

* libguile/socket.c (scm_inet_pton, scm_inet_ntop): Compile regardless
  of `HAVE_INET_PTON' and `HAVE_INET_NTOP' respectively.

* libguile/filesys.c: Use <stdlib.h> instead of <canonicalize.h>.

14 years agoRe-add an indirection in bytevectors.
Ludovic Courtès [Sun, 15 Nov 2009 18:34:38 +0000 (19:34 +0100)]
Re-add an indirection in bytevectors.

The intent is to allow for mmap(3) bindings and to actually reuse
user-provided buffers in `scm_c_take_bytevector ()'.

* libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Increment.
  (SCM_BYTEVECTOR_CONTENTS): Take the pointer from the second word.
  (SCM_BYTEVECTOR_CONTIGUOUS_P): New macro.
  (SCM_BYTEVECTOR_ELEMENT_TYPE): Adjust to live alongside the CONTIGUOUS
  flag.

* libguile/bytevectors.c (SCM_BYTEVECTOR_SET_CONTENTS,
  SCM_BYTEVECTOR_SET_CONTIGUOUS_P): New macros.
  (SCM_BYTEVECTOR_SET_ELEMENT_TYPE): Adjust.
  (SCM_BYTEVECTOR_TYPED_LENGTH): Properly parenthesize.
  (make_bytevector): Adjust to new bytevector header.
  (make_bytevector_from_buffer): Reuse CONTENTS.
  (scm_c_shrink_bytevector): Differentiate between contiguous and
  non-contiguous bytevectors.

14 years agoRemove unused internal bytevector functions.
Ludovic Courtès [Sun, 15 Nov 2009 18:22:01 +0000 (19:22 +0100)]
Remove unused internal bytevector functions.

* libguile/bytevectors.c (scm_i_make_typed_bytevector,
  scm_c_take_typed_bytevector): Remove.

* libguile/bytevectors.h: Adjust accordingly.

14 years agoRun the GC and retry `open-file' when getting `EMFILE'.
Ludovic Courtès [Sun, 15 Nov 2009 15:55:57 +0000 (16:55 +0100)]
Run the GC and retry `open-file' when getting `EMFILE'.

* libguile/fports.c (scm_open_file): Run the GC and retry when getting
  `EMFILE'.

14 years agoImprove documentation of supported encoding names.
Ludovic Courtès [Sun, 15 Nov 2009 13:46:33 +0000 (14:46 +0100)]
Improve documentation of supported encoding names.

* doc/ref/api-evaluation.texi (Character Encoding of Source Files):
  Mention IANA as the list of supported character encodings.  Thanks to
  Bruno Haible for pointing this out.

* doc/ref/api-io.texi (Ports): Likewise.  Improve documentation of
  `%default-port-encoding'.

14 years agoFix off-by-one error in processing Emacs-style coding declaration.
Ken Raeburn [Sat, 14 Nov 2009 19:53:46 +0000 (14:53 -0500)]
Fix off-by-one error in processing Emacs-style coding declaration.

* libguile/read.c (scm_i_scan_for_encoding): Don't copy the first
  character after the coding declaration into the new string.

14 years agoopcodes for bit twiddling (ash, logand, logior, logxor)
Andy Wingo [Fri, 6 Nov 2009 12:13:39 +0000 (13:13 +0100)]
opcodes for bit twiddling (ash, logand, logior, logxor)

* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/primitives.scm:
* libguile/vm-i-scheme.c (ash, logand, logior, logxor): New opcodes.

14 years agoclass-of has an opcode
Andy Wingo [Fri, 6 Nov 2009 11:40:20 +0000 (12:40 +0100)]
class-of has an opcode

* libguile/vm-i-scheme.c (class-of): New opcode.
* module/language/tree-il/compile-glil.scm:
* module/oop/goops.scm: Compile class-of into an opcode.

14 years agofaster conditionals
Andy Wingo [Fri, 6 Nov 2009 11:13:33 +0000 (12:13 +0100)]
faster conditionals

* module/language/tree-il/compile-glil.scm (flatten): Compile `if'
  statements with `eq?' and `null?', and their `not?' variants, into
  more specific bytecode.

14 years agofix (apply f) -- without the args list
Andy Wingo [Fri, 6 Nov 2009 10:16:54 +0000 (11:16 +0100)]
fix (apply f) -- without the args list

* module/language/tree-il/primitives.scm (apply): Only inline if we
  actually have an argument to apply.

14 years agoRevert "implement #:predicate" and remove predicate from <lambda-case>
Andy Wingo [Thu, 5 Nov 2009 09:22:01 +0000 (10:22 +0100)]
Revert "implement #:predicate" and remove predicate from <lambda-case>

Turns out this was not a very useful idea, and semantically tricky to
boot.

This reverts commit 24bf130fd15afbc8b3a2ccdc50a027f9b6c9e623, and makes
the following additional changes:

* module/ice-9/optargs.scm (parse-lambda-case, let-optional)
  (let-optional*, let-keywords, let-keywords*):
* module/language/tree-il.scm: (<lambda-case>, parse-tree-il)
  (unparse-tree-il, tree-il->scheme, tree-il-fold,
  make-tree-il-folder)
  (post-order!, pre-order!):
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/compile-glil.scm (compile-glil):
* module/language/tree-il/inline.scm (inline!): Remove all traces of
  #:predicate from tree-il.

* module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case)
  (chi-lambda-case): Adapt to tree-il change.
* module/ice-9/psyntax-pp.scm: Regenerated.

* module/language/brainfuck/compile-tree-il.scm (compile-body):
* module/language/ecmascript/compile-tree-il.scm (comp, comp-body):
* test-suite/tests/tree-il.test: Adapt to tree-il change.

* doc/ref/api-procedures.texi (Case-lambda): Remove mention of
  #:predicate.

14 years agoactually set all 8 hashsets in classes
Andy Wingo [Tue, 3 Nov 2009 21:43:29 +0000 (22:43 +0100)]
actually set all 8 hashsets in classes

* libguile/goops.c (prep_hashsets): Actually set all 8 hashsets. Doh...

14 years agoremove goops-local %tag-body
Andy Wingo [Tue, 3 Nov 2009 21:41:59 +0000 (22:41 +0100)]
remove goops-local %tag-body

* libguile/goops.c (scm_sys_tag_body): Remove goops-local hack that is
  no longer necessary.

14 years agoSCM_VALIDATE_VTABLE tweak
Andy Wingo [Tue, 3 Nov 2009 21:33:22 +0000 (22:33 +0100)]
SCM_VALIDATE_VTABLE tweak

* libguile/validate.h (SCM_VALIDATE_VTABLE): Simply call
  scm_struct_vtable_p.

14 years agofix printing-programs bug
Andy Wingo [Tue, 3 Nov 2009 21:32:39 +0000 (22:32 +0100)]
fix printing-programs bug

* module/system/vm/program.scm (write-program): Fix a bug if we couldn't
  get a procedure's arity.

14 years agovalues.c defines a vtable, not a vtable-vtable
Andy Wingo [Tue, 3 Nov 2009 21:28:26 +0000 (22:28 +0100)]
values.c defines a vtable, not a vtable-vtable

* libguile/values.c (scm_init_values): Define a vtable, not a
  "metaclass".

14 years agosrfi-35 properly uses vtable-offset-user
Andy Wingo [Tue, 3 Nov 2009 21:27:34 +0000 (22:27 +0100)]
srfi-35 properly uses vtable-offset-user

* module/srfi/srfi-35.scm (condition-type-id):
  (condition-type-parent, condition-type-all-fields): Don't ref fixed
  struct indices, use vtable-offset-user instead.

14 years agofix a structs.test test
Andy Wingo [Tue, 3 Nov 2009 21:26:46 +0000 (22:26 +0100)]
fix a structs.test test

* test-suite/tests/structs.test ("equal?"): Instantiate vtables, not
  vtable-vtables. "hello" is not a valid vtable layout.

14 years agoremove redundant, unnecessary instance size from struct vtables
Andy Wingo [Sun, 1 Nov 2009 20:09:42 +0000 (21:09 +0100)]
remove redundant, unnecessary instance size from struct vtables

* libguile/struct.h (scm_struct_i_size): Remove this shared field -- I
  mean, the slot is still there, but it's only used for flags.

* libguile/goops.h (SCM_SET_CLASS_INSTANCE_SIZE):
* libguile/goops.c (scm_sys_inherit_magic_x, scm_make_class): Remove
  uses and definition of SCM_SET_CLASS_INSTANCE_SIZE. Light structs used
  it, but you have that info in the layout; and foreign classes used it,
  but that is going away soon anyway :)

14 years agofold objects.[ch] into goops.[ch]
Andy Wingo [Sun, 1 Nov 2009 19:45:02 +0000 (20:45 +0100)]
fold objects.[ch] into goops.[ch]

Remove objects.h #includes as appropriate.

14 years agoremove support for "entities" -- a form of applicable struct
Andy Wingo [Sun, 1 Nov 2009 18:46:27 +0000 (19:46 +0100)]
remove support for "entities" -- a form of applicable struct

Entities were meant to be a form of applicable struct. Unfortunately,
the implementation is intertwingled with generics. Removing them, for
now, will make it possible to cleanly re-add applicable struct support.

* libguile/struct.h (SCM_STRUCTF_ENTITY): Remove.
  (SCM_STRUCTF_GOOPS_HACK): New flag; sigh.
* libguile/struct.c (scm_make_struct): We make "entity" structs if the
  GOOPS_HACK flag is set. This will be fixed when we rework flags and
  remove hidden words.

* libguile/goops.c (scm_class_of): Structs are not applicable, for now
  at least.
  (scm_sys_inherit_magic_x, scm_basic_basic_make_class)
  (scm_sys_allocate_instance, scm_sys_set_object_setter_x):
  (make_struct_class): Adapt for no more entities (and thus no entity
  flag).
  (create_standard_classes): For some reason, generic functions were
  getting the LIGHT flag set, after the ENTITY flag was removed; so for
  now explicitly clear that flag.
* libguile/goops.h (SCM_GENERIC_SETTER, SCM_SET_GENERIC_SETTER): New
  macros.

* libguile/objects.h:
* libguile/objects.c: Remove code for entities.

* libguile/debug.c: (scm_procedure_source): Only work with generics.

* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
  (scm_trampoline_2): Only handle generics.

* libguile/eval.i.c (CEVAL): #ifdef out the pieces about entities.

* libguile/procprop.c (scm_i_procedure_arity): Remove support for
  entities.

* libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Remove
  entity support.

14 years agoSCM_GENERIC_METHOD_CACHE macro splits from SCM_ENTITY_PROCEDURE
Andy Wingo [Sat, 31 Oct 2009 11:04:53 +0000 (12:04 +0100)]
SCM_GENERIC_METHOD_CACHE macro splits from SCM_ENTITY_PROCEDURE

* libguile/goops.h (SCM_GENERIC_METHOD_CACHE)
  (SCM_SET_GENERIC_METHOD_CACHE): Two new macros; the same as
  SCM_[SET_]ENTITY_PROCEDURE, but more reflecting the reality of the
  generic hack.

* libguile/eval.i.c:
* libguile/goops.c:
* libguile/objects.c:
* libguile/vm-i-system.c: Use the new macros when it is appropriate to
  do so.

14 years agoremove unused things from object.[ch]
Andy Wingo [Sat, 31 Oct 2009 10:17:12 +0000 (11:17 +0100)]
remove unused things from object.[ch]

* libguile/objects.h:
* libguile/objects.c (scm_object_procedure): Remove, it was only
  compiled with SCM_DEBUG.

* libguile/objects.h:
* libguile/objects.c (scm_make_class_object, scm_make_subclass_object,
  (scm_i_make_class_object, scm_metaclass_standard): Remove also. These
  implemented an undocumented object system, and are totally replaced by
  GOOPS.

14 years agoremove operators
Andy Wingo [Fri, 30 Oct 2009 23:28:43 +0000 (00:28 +0100)]
remove operators

14 years agogeneric dispatch in the vm (sorta)
Andy Wingo [Fri, 30 Oct 2009 23:08:42 +0000 (00:08 +0100)]
generic dispatch in the vm (sorta)

* libguile/vm-i-system.c (call, goto/args, mv-call): Add a case for
  generics, so we can avoid the evaluator in that case. Still have to
  cons up a list -- the real solution comes later.

14 years agoremove unused struct gc chain macros
Andy Wingo [Thu, 29 Oct 2009 08:47:00 +0000 (09:47 +0100)]
remove unused struct gc chain macros

* libguile/struct.h (SCM_STRUCT_GC_CHAIN, SCM_SET_STRUCT_GC_CHAIN):
  Remove, no longer necessary given topological finalization, provided
  by libGC.

14 years agode-inline goops dispatch from the evaluator
Andy Wingo [Fri, 30 Oct 2009 21:21:29 +0000 (22:21 +0100)]
de-inline goops dispatch from the evaluator

* libguile/eval.i.c: De-inline goops dispatch from the evaluator. Part
  of a refactor.

14 years agoadd quasisyntax
Andreas Rottmann [Sat, 14 Nov 2009 16:25:12 +0000 (17:25 +0100)]
add quasisyntax

* module/Makefile.am:
* module/ice-9/boot-9.scm:
* module/ice-9/quasisyntax.scm: Add quasisyntax. Implementation by Andre
  van Tonder, patch by Andreas Rottmann.
* test-suite/tests/srfi-10.test: Hack to remove srfi-10's clobbering of
  #,.
* test-suite/tests/syncase.test: Add a quasisyntax test.

14 years agoadd include-from-path
Andy Wingo [Sat, 14 Nov 2009 16:04:28 +0000 (17:04 +0100)]
add include-from-path

* module/ice-9/psyntax.scm (include-from-path): New syntax. Searches the
  load path for a file, and includes it.

14 years agopsyntax.scm uses #' shorthand for (syntax ...)
Andy Wingo [Sat, 14 Nov 2009 15:53:36 +0000 (16:53 +0100)]
psyntax.scm uses #' shorthand for (syntax ...)

* module/ice-9/psyntax.scm: Convert to use #'.

14 years agoAdd currently failing tests for optargs.
Ludovic Courtès [Sat, 14 Nov 2009 15:52:48 +0000 (16:52 +0100)]
Add currently failing tests for optargs.

* test-suite/tests/optargs.test (exception:unrecognized-keyword,
  exception:extraneous-arguments): New variables.
  ("define*")["extraneous arguments", "unrecognized keyword", "rest
  given before keywords"]: New tests.

14 years agoExplicitly disable TLS on NetBSD 5.0.
Ludovic Courtès [Sat, 14 Nov 2009 15:50:38 +0000 (16:50 +0100)]
Explicitly disable TLS on NetBSD 5.0.

* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): Explicitly disable TLS on
  NetBSD 5.0.

14 years agoHave `scm_scan_for_encoding ()' use GC-managed memory.
Ludovic Courtès [Sat, 14 Nov 2009 15:27:28 +0000 (16:27 +0100)]
Have `scm_scan_for_encoding ()' use GC-managed memory.

* libguile/read.c (scm_scan_for_encoding): Rename to ...
  (scm_i_scan_for_encoding): ... this; update callers.  Use
  `scm_gc_strndup ()' instead of `scm_malloc ()'.

* libguile/read.h: Update accordingly.

* libguile/load.c (scm_primitive_load): Don't call free(3) on the value
  returned by `scm_i_scan_for_encoding ()'.

14 years agoReplace `setbinary' by a public `%default-port-encoding' fluid.
Ludovic Courtès [Sat, 14 Nov 2009 15:14:20 +0000 (16:14 +0100)]
Replace `setbinary' by a public `%default-port-encoding' fluid.

* doc/ref/api-evaluation.texi (Character Encoding of Source Files): Add
  reference to the "Ports" node.

* doc/ref/api-io.texi (Ports): Document `%default-port-encoding'.

* libguile/ports.c (scm_port_encoding_var): Rename to...
  (default_port_encoding_var): ... this; update callers.  Make `static'.

* libguile/posix.c (scm_setbinary): Remove.

* libguile/posix.h: Adjust accordingly.

* test-suite/tests/numbers.test: Remove unneeded `setbinary' call.

* test-suite/tests/ports.test: Replace `setbinary' call by equivalent
  `%default-port-encoding' mutation and `set-port-encoding!' calls.

* test-suite/tests/r6rs-ports.test: Replace `setbinary' call by
  equivalent `%default-port-encoding' mutation.

14 years agoExplicitly require `sed'.
Ludovic Courtès [Sat, 14 Nov 2009 10:42:14 +0000 (11:42 +0100)]
Explicitly require `sed'.

* configure.ac: Use `AC_PROG_SED'.

14 years agofix bugs in ecmascript compiler
Andy Wingo [Sat, 14 Nov 2009 12:34:40 +0000 (13:34 +0100)]
fix bugs in ecmascript compiler

* module/language/ecmascript/compile-tree-il.scm: Fix a number of bugs,
  fallen out from the ghil->tree-il conversion.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add a hack
  for "return" for javascript. Scheme shouldn't see this because it's
  not an "interesting primitive".

14 years agofix scoping in let-keywords
Andy Wingo [Sat, 14 Nov 2009 12:26:46 +0000 (13:26 +0100)]
fix scoping in let-keywords

* module/ice-9/optargs.scm (let-keywords): I thought that I had the
  scoping right here, but I didn't. Make sure that the lambda formals
  for the initializers are new, fresh identifiers, so that let scoping
  works appropriately.

14 years agofix bug in string comparison
Andy Wingo [Sat, 14 Nov 2009 12:25:00 +0000 (13:25 +0100)]
fix bug in string comparison

* libguile/srfi-13.c (compare_strings): Switch the "longer" and
  "shorter" arguments. All the callers of this function assumed that
  shorter came first. Fixes (string<? "abc" "abcd").

14 years agoImprove the printer of SRFI-35 error conditions.
Ludovic Courtès [Tue, 10 Nov 2009 21:15:21 +0000 (22:15 +0100)]
Improve the printer of SRFI-35 error conditions.

* module/srfi/srfi-35.scm (print-condition): Print the name and value of
  each field.

14 years agoAdd support for multiple arities in `arity-mismatch-analysis'.
Ludovic Courtès [Sun, 8 Nov 2009 16:53:14 +0000 (17:53 +0100)]
Add support for multiple arities in `arity-mismatch-analysis'.

* module/language/tree-il/analyze.scm (validate-arity)[arity]: Rename
  to...
  [arities]: ... this.  Return all the arities of PROC.
  Update caller accordingly.

* test-suite/tests/tree-il.test ("warnings")["arity
  mismatch"]("case-lambda", "case-lambda with wrong number of
  arguments", "case-lambda*", "case-lambda* with wrong arguments"): New
  tests.

14 years agoUpdate `.gitignore'.
Ludovic Courtès [Sun, 8 Nov 2009 00:15:23 +0000 (01:15 +0100)]
Update `.gitignore'.

14 years agoFix C99-style comments.
Ludovic Courtès [Sun, 8 Nov 2009 00:13:46 +0000 (01:13 +0100)]
Fix C99-style comments.

* libguile/generalized-vectors.c, libguile/programs.c, libguile/vm.c:
  Replace C99-style comments by plain old C89 comments.

14 years agoCompile with `-Warity-mismatch'.
Ludovic Courtès [Sun, 8 Nov 2009 00:12:35 +0000 (01:12 +0100)]
Compile with `-Warity-mismatch'.

* am/guilec (GUILE_WARNINGS): New variable; add `-Warity-mismatch'.
  (.scm.go): Use it.

14 years agoAdd tests for `unbound-variable-analysis'.
Ludovic Courtès [Sun, 8 Nov 2009 00:11:19 +0000 (01:11 +0100)]
Add tests for `unbound-variable-analysis'.

* test-suite/tests/tree-il.test ("warnings")["unbound
  variable"]("optional arguments are visible", "keyword arguments are
  visible"): New tests.

14 years agoFix optional argument handling in `unused-variable-analysis'.
Ludovic Courtès [Sun, 8 Nov 2009 00:08:54 +0000 (01:08 +0100)]
Fix optional argument handling in `unused-variable-analysis'.

* module/language/tree-il/analyze.scm (unused-variable-analysis): Fix
  optional argument handling in <lambda-case>.

14 years agoAdd support for keyword arguments in `arity-mismatch-analysis'.
Ludovic Courtès [Sun, 8 Nov 2009 00:02:08 +0000 (01:02 +0100)]
Add support for keyword arguments in `arity-mismatch-analysis'.

* module/language/tree-il/analyze.scm
  (validate-arity)[filter-keyword-args]: New procedure.
  [arity]: Get accurate arity for programs, return ALLOW-OTHER-KEYS? as
  an additional value.
  Update to `arity' change; use `filter-keyword-args'.

* test-suite/tests/tree-il.test ("warnings")["arity mismatch"]("keyword
  not passed and quiet", "keyword passed and quiet", "keyword passed to
  global and quiet", "extra keyword", "extra keywords allowed"): New
  tests.

14 years agoFix typos leading to wrong argument counts.
Ludovic Courtès [Sat, 7 Nov 2009 18:24:49 +0000 (19:24 +0100)]
Fix typos leading to wrong argument counts.

* module/ice-9/channel.scm (eval): Fix number of arguments to
  `guile:eval'.

* module/oop/goops/save.scm (write-readably): Fix number of arguments to
  `write-array'.

* module/srfi/srfi-19.scm (priv:char->int): Fix number of arguments to
  `priv:time-error'.

14 years agoFix typos in `psyntax'.
Ludovic Courtès [Sat, 7 Nov 2009 18:19:16 +0000 (19:19 +0100)]
Fix typos in `psyntax'.

* module/ice-9/psyntax.scm (lambda*-formals): Fix argument count in
  `rest' invocations.
  [pred]: Fix argument count in `syntax->datum' invocation.

14 years agoAdd `arity-mismatch' warning type.
Ludovic Courtès [Sat, 7 Nov 2009 17:32:26 +0000 (18:32 +0100)]
Add `arity-mismatch' warning type.

* module/language/tree-il/analyze.scm (<arity-info>): New record type.
  (validate-arity, arity-analysis): New variables.

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

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

* test-suite/tests/tree-il.test (read-and-compile): Remove, as it's now
  public.
  (%opts-w-arity): New.
  ("warnings")["arity mismatch"]: New test prefix.

14 years agoCoalesce tree traversals made for warnings.
Ludovic Courtès [Fri, 6 Nov 2009 09:42:45 +0000 (10:42 +0100)]
Coalesce tree traversals made for warnings.

* module/language/tree-il/analyze.scm (<tree-analysis>): New type.
  (analyze-tree): New procedure.
  (report-unused-variables): Replace by...
  (unused-variable-analysis): ... this, as a <tree-analysis>.
  (report-possibly-unbound-variables): Replace by...
  (unbound-variable-analysis): ... this, as a <tree-analysis>.

* module/language/tree-il/compile-glil.scm (%warning-passes): Adjust
  accordingly.
  (compile-glil): Likewise.  Use `analyze-tree'.

14 years agoHold the GC lock when traversing weak hash table buckets.
Ludovic Courtès [Fri, 30 Oct 2009 10:31:51 +0000 (11:31 +0100)]
Hold the GC lock when traversing weak hash table buckets.

* libguile/hashtab.c (scm_fixup_weak_alist): Clarify comment.
  (struct t_assoc_args): New.
  (do_weak_bucket_assoc, weak_bucket_assoc): New.
  (START_WEAK_BUCKET_FIXUP, END_WEAK_BUCKET_FIXUP): Remove.
  (scm_hash_fn_get_handle, scm_hash_fn_create_handle_x,
  scm_hash_fn_remove_x): Use `weak_bucket_assoc ()' instead of
  `START_WEAK_BUCKET_FIXUP'/`END_WEAK_BUCKET_FIXUP'.

14 years agoFix snarfing of `SCM_DEFINE' with static allocation.
Ludovic Courtès [Thu, 5 Nov 2009 22:06:45 +0000 (23:06 +0100)]
Fix snarfing of `SCM_DEFINE' with static allocation.

* libguile/snarf.h (SCM_DEFINE)[SCM_SUPPORT_STATIC_ALLOCATION]: Provide
  a declaration for FNAME since the last argument to
  `SCM_IMMUTABLE_SUBR ()' refers to it.

14 years agoFill code coverage holes in continuations.c and keywords.c
Neil Jerram [Tue, 3 Nov 2009 21:51:28 +0000 (21:51 +0000)]
Fill code coverage holes in continuations.c and keywords.c

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

* test-suite/standalone/Makefile.am (test-loose-ends): New test.

* test-suite/standalone/test-loose-ends.c: New file.

* test-suite/tests/continuations.test: Three new tests.

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

14 years agoIncrease benchmark iterations to improve precision in comparisons over time
Neil Jerram [Tue, 3 Nov 2009 22:50:07 +0000 (22:50 +0000)]
Increase benchmark iterations to improve precision in comparisons over time

* benchmark-suite/benchmarks/continuations.bm: Increase "call/cc"
  iterations from 300 to 12000.

* benchmark-suite/benchmarks/srfi-13.bm ("strings"): Increase "copy"
  iterations from 1100 to 20000, and "pad" from 6800 to 34000.

* benchmark-suite/benchmarks/uniform-vector-read.bm
  ("uniform-vector-read!"): Increase "uniform-vector-write" iterations
  from 500 to 4000, and "uniform-vector-read!" from 500 to 20000.

14 years agoAllocate vectors in a contiguous memory area.
Ludovic Courtès [Sun, 1 Nov 2009 23:55:17 +0000 (00:55 +0100)]
Allocate vectors in a contiguous memory area.

* libguile/vectors.c (scm_c_make_vector): Allocate the whole vector and
  header with `scm_gc_malloc ()'.
  (scm_vector_copy): Use `scm_c_make_vector ()'.
  (scm_i_vector_free, MAKE_WEAK_VECTOR): Remove.
  (allocate_weak_vector): Rename to...
  (make_weak_vector): ... this.  Change to return the whole weak vector,
  allocated with `scm_gc_malloc_pointerless ()'.
  (scm_i_make_weak_vector, scm_i_make_weak_vector_from_list): Use
  `make_weak_vector ()'.

* libguile/vectors.h (SCM_I_VECTOR_HEADER_SIZE): New macro.
  (SCM_I_VECTOR_ELTS): Write in terms of `SCM_I_VECTOR_WELTS ()'.
  (SCM_I_VECTOR_WELTS): Update to the new representation.
  (SCM_I_WVECT_EXTRA, SCM_I_SET_WVECT_EXTRA): Likewise.
  (SCM_I_WVECT_GC_CHAIN, SCM_I_SET_WVECT_GC_CHAIN): Remove.

* libguile/weaks.h (SCM_I_WVECT_DELTA, SCM_I_SET_WVECT_DELTA): Remove.

14 years agoRestore signature of `scm_search_path ()' as found in 1.8.
Ludovic Courtès [Sun, 1 Nov 2009 22:29:36 +0000 (23:29 +0100)]
Restore signature of `scm_search_path ()' as found in 1.8.

The incompatibly was introduced by
22f4ee48822db5e30df3abf9a11b6066f2bab9d3 ("make primitive-load-path load
compiled files if available").

* doc/ref/api-options.texi (Build Config): Update `search-path'
  documentation.

* libguile/load.c (scm_search_path): Change C prototype to expect only 3
  arguments.  Parse the rest argument accordingly.  Update callers.

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

14 years agoMerge branch 'bdw-gc-static-alloc'
Ludovic Courtès [Sun, 1 Nov 2009 17:17:31 +0000 (18:17 +0100)]
Merge branch 'bdw-gc-static-alloc'

Conflicts:
acinclude.m4
libguile/__scm.h
libguile/bdw-gc.h
libguile/eval.c

14 years agoClean up some uses of old GC macros that don't exist any more.
Ken Raeburn [Thu, 29 Oct 2009 16:16:12 +0000 (12:16 -0400)]
Clean up some uses of old GC macros that don't exist any more.

* libguile/deprecated.h (SCM_GC8MARKP, SCM_SETGC8MARK, SCM_CLRGC8MARK):
  Delete.
* libguile/gc.c (scm_assert_cell_valid): Remove check of SCM_GC_MARK_P.

14 years agoSince support for "futures" in C has been completely disabled for some
Ken Raeburn [Thu, 29 Oct 2009 21:22:17 +0000 (17:22 -0400)]
Since support for "futures" in C has been completely disabled for some
time, and should be easily implementable in Scheme with the current
thread support, delete the C code.

* libguile/futures.c, libguile/futures.h: Delete.
* libguile/Makefile.am (libguile_la_SOURCES, DOT_X_FILES,
  DOT_DOC_FILES, modinclude_HEADERS): Delete references to futures.*
  files.

* libguile.h: Don't include futures.h.
* libguile/eval.c: Don't include futures.h.
  (isymnames): Delete "#@future" entry.
  (scm_m_future, s_future, scm_sym_future, unmemoize_future,
  unmemoize_builtin_macro): Delete disabled futures code.
* libguile/eval.i.c (CEVAL): Delete disabled futures code.
* libguile/init.c: Don't include futures.h.
  (scm_i_init_guile): Delete disabled futures initialization call.
* libguile/tags.h (SCM_IM_FUTURE): Delete.
  (SCM_IM_CALL_WITH_VALUES, SCM_IM_ELSE, SCM_IM_ARROW,
  SCM_IM_NIL_COND, SCM_IM_BIND): Renumber.

* doc/ref/api-scheduling.texi: Delete commented-out node on Futures.
* doc/maint/guile.texi: Delete make-future and future-ref mentions.

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.