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

15149 commits

Author SHA1 Message Date
Andy Wingo
fca1414908 inlined port functions to ports.h
* libguile/inline.h:
* libguile/ports.h (scm_get_byte_or_eof, scm_peek_byte_or_eof)
  (scm_putc, scm_puts): Move definitions here, from inline.h.
2011-11-07 16:14:15 +01:00
Andy Wingo
30b126d2ba add lock to scm_t_port
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port)
  (scm_c_unlock_port): New inline functions.
  (scm_t_port): Add a lock field, if threads are enabled.  This is a
  first step towards threadsafe ports.

* libguile/ports.c (scm_c_make_port_with_encoding): Init the port's
  lock.

* libguile/inline.c: Residualize the inline functions from ports.h.
2011-11-07 16:01:01 +01:00
Andy Wingo
0f9f51a153 regenerate psyntax-pp
* module/ice-9/psyntax-pp.scm: Regenerate.
2011-11-07 11:48:30 +01:00
Andy Wingo
adf91e1cc5 add tests for hygienic name introduction
* test-suite/tests/syntax.test ("top-level define"): Add tests for
  hygienic introduction of names.
2011-11-07 11:48:04 +01:00
Andy Wingo
de41e56492 hygienically rename macro-introduced bindings, reproducibly
* module/ice-9/psyntax.scm (chi-top-sequence): Detect bindings to
  identifiers introduced by macros.  In that case, in order to preserve
  hygiene, uniquify the variable's name, but in a way that is
  reproduceable (i.e., yields the same uniquified name after a
  recompile).
2011-11-07 11:45:15 +01:00
Andy Wingo
49689a3f2d fix scope bug in <module> definition in boot-9
* module/ice-9/boot-9.scm (define-record-type): Fix scope bug when
  generating identifiers.
2011-11-07 11:45:15 +01:00
Andy Wingo
ab2d0f8f0c another scoping test
* test-suite/tests/syntax.test ("top-level define"): Add another test
  for scoping.
2011-11-07 11:45:15 +01:00
Andy Wingo
47e9919d22 resolve-identifier for toplevel definitions resolves by module
* module/ice-9/psyntax.scm (id-var-name): For mapping identifiers to
  toplevel definitions, also compare against the module.
  (resolve-identifier): Pass the module to id-var-name when looking up
  identifiers.
  (free-id=?): Adapt to id-var-name change.
  (chi-top-sequence): When adding a mapping from the given identifier
  to a toplevel definition, make the name be a pair.
2011-11-07 11:42:29 +01:00
Andy Wingo
1ce645567d add scoping test
* test-suite/tests/syntax.test ("top-level define"): Add a test for
  module scoping of introduced identifiers.
2011-11-07 11:42:29 +01:00
Andy Wingo
19ef14f9b8 defined identifiers scoped in the current module
* ice-9/psyntax.scm (chi-top-sequence): Wrap defined identifiers with
  the current module.  Fixes http://savannah.gnu.org/bugs/?31472.
2011-11-07 11:39:05 +01:00
Andy Wingo
5b36d6034b syntax parameters implemented properly
* module/ice-9/psyntax.scm (resolve-identifier): Take an additional
  argument, indicating whether syntax parameters should be resolved or
  not.  Just return three values: the binding type and value, and the
  module for resolving toplevels.
  (chi-install-global): Take an extra arg, the type.  If we are defining
  a syntax parameter, construct a pair for the binding.
  (chi-body): Syntax parameters now use a per-parameter unique value (a
  pair) as a key in the expansion-time environment `r'.
  (syntax-parameterize): Don't allow parameterization of
  non-parameters.  This is an incompatible change, but it is for the
  better; you don't want to allow users to parameterize `lambda', after
  all.
2011-11-07 11:39:04 +01:00
Andy Wingo
ea3ca4e4d0 syntax-parameterize, not fluid-let-syntax
* module/ice-9/psyntax.scm (syntax-parameterize): Rename from
  fluid-let-syntax.

* module/ice-9/boot-9.scm (define-inlinable): Use syntax-parameterize
  (and define-syntax-parameter).
2011-11-07 11:38:47 +01:00
Andy Wingo
c2d822de19 add define-syntax-parameter, same as define-syntax
* module/ice-9/psyntax.scm (define-syntax-parameter): New toplevel form.
  Will be used to implement syntax parameters, following Barzilay,
  Culpepper, and Flatt's 2011 SFP workshop paper, "Keeping it Clean with
  syntax-parameterize".  Adds a new binding type and definition form.
2011-11-07 11:38:47 +01:00
Andy Wingo
c070de6345 psyntax: resolve-identifier refactor
* module/ice-9/psyntax.scm (id-var-name): Add a nice long comment.
  (lookup): Remove, as it is no longer used.
  (resolve-identifier): New helper, replaces most uses of id-var-name
  then `lookup'.
  (syntax-type, syntax, set!, fluid-let-syntax): Adapt to use
  resolve-identifier.
  (free-id=?): Adapt to id-var-name returning syntax objects.
2011-11-07 11:38:40 +01:00
Andy Wingo
45f584674a chi-top-sequence refactor
* module/ice-9/psyntax.scm (chi-top-sequence): Reimplement, more like
  chi-body.  Instead of adding empty definitions to the toplevel, add
  toplevel definitions to the wrap shared by all forms in the sequence.
2011-11-04 15:52:40 +01:00
Andy Wingo
f698b7286f minor psyntax refactors
* module/ice-9/psyntax.scm (syntax-type): Remove redundant lexical
  case.
  (syntax-rules, define-syntax-rule): Use `_' instead of `dummy' for the
  keyword.

* module/ice-9/boot-9.scm (define-syntax-rule): Remove redundant
  definition.
2011-11-04 14:12:35 +01:00
Andy Wingo
ef9ffe5efd peval doesn't resolve primitives
* module/language/tree-il/peval.scm (peval): Don't resolve primitives,
  as resolve-primitives! handles that already.

* test-suite/tests/tree-il.test (pass-if-peval): Always resolve and
  expand primitives.
  ("partial evaluation"): Update tests to assume expanded primitives.
2011-11-04 14:12:25 +01:00
Andy Wingo
14b208185c resolve-primitives! does not primitivize local definitions
* module/language/tree-il/primitives.scm (resolve-primitives!): Don't
  resolve toplevels defined in the same compilation unit to primitives,
  as it could be that the module doesn't have those bindings yet.
2011-11-04 13:37:58 +01:00
Andy Wingo
58e68be4bb more robust scm_exit_status
* libguile/throw.c (scm_exit_status): In one of my bogus patches, I
  managed to make #<unspecified> reach this function, causing a segfault
  on SCM_CAR.  Refactor to be more robust.
2011-11-04 13:35:19 +01:00
Ian Price
d825841db0 Fix R6RS `fold-left' so the accumulator is the first argument.
* module/rnrs/lists.scm (fold-left): New procedure.

* module/rnrs/records/syntactic.scm (define-record-type): Fix to use
  corrected `fold-left'.

* test-suite/tests/r6rs-lists.test: Add tests.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-11-01 01:11:46 +01:00
Andy Wingo
148dfc2409 refactor chi-top-sequence
* module/ice-9/psyntax.scm (chi-top-sequence): Refactor slightly.
* module/ice-9/psyntax-pp.scm: Regenerate.
2011-10-28 12:14:00 +02:00
Andy Wingo
dd64fe65fd regenerate psyntax-pp
* module/ice-9/psyntax-pp.scm: Regenerate.
2011-10-28 11:41:08 +02:00
Andy Wingo
d5a4f51f9c add string-length, string-ref, vector-length instructions
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump the major version,
  indicating the first incompatibility between 2.0 and 2.2.

* libguile/vm-i-scheme.c (string-length, string-ref, vector-length): New
  instructions.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  primcall ops for the new instructions.
2011-10-28 11:38:56 +02:00
Andy Wingo
ba9f9f0d63 add vector-length primitive
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*): Recognize
  vector-length as an effect-free primitive.
2011-10-28 11:19:01 +02:00
Andy Wingo
f00a957499 simplify primitives.scm
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove a hack to compensate for the lack of a good inliner, now that
  we do have a good inliner.
2011-10-28 10:29:46 +02:00
Andy Wingo
175955725e fix the peval merge and a test
* module/language/tree-il/peval.scm (peval): Accessor primitives applied
  to constants are pure if the call type-checks.  Also, fold constants
  in accessor primcalls.

* test-suite/tests/tree-il.test ("partial evaluation"): Fix the "yo"
  test.
2011-10-27 14:09:47 +02:00
Andy Wingo
549333efd8 fix hash of zero-length vectors
* libguile/hash.c (scm_raw_ihash): Fix for zero-length vectors.
2011-10-27 14:00:38 +02:00
Andy Wingo
4938d3cb74 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/deprecated.c
	libguile/gc-malloc.c
	module/language/tree-il/peval.scm
2011-10-27 13:45:04 +02:00
Andy Wingo
9d01333015 update `hash'
* libguile/hash.c (scm_raw_ihash): Rename from `hasher'.  Remove the
  modulo argument; we expect the caller to deal with that.  Use
  scm_i_hashq for immediates and non-immediate integers.  Use
  scm_raw_ihashq on pointers too.  Update the vector and pairs hashing
  code.  There is still some work to do here.
  (scm_ihashv, scm_ihash): Adapt.
2011-10-26 01:44:48 +02:00
Andy Wingo
92e35e8daa don't downcase characters before hashing them
* libguile/hash.c (hasher, scm_ihashv): Don't downcase characters before
  hashing them.  That is silly.
2011-10-26 00:42:37 +02:00
Andy Wingo
d1d1c5dea5 scm_hasher is static
* libguile/hash.c (hasher): Make static.
* libguile/hash.h: Remove scm_hasher.
2011-10-26 00:41:03 +02:00
Andy Wingo
71f89dd7e9 add thomas wang's integer hash function; use it for hashq, hashv
* libguile/hash.c (scm_raw_ihashq): Add Thomas Wang's integer hash
  function, from http://www.cris.com/~Ttwang/tech/inthash.htm.
  (scm_ihashq, scm_ihashv): Use it here.
2011-10-26 00:37:24 +02:00
Andy Wingo
7914b2b069 symbols.h reindent
* libguile/symbols.h: Reindent.
2011-10-26 00:07:29 +02:00
Andy Wingo
1a04d29db7 use bob jenkins' hashword2 hash from lookup3.c for our string hash
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2, narrow_string_hash)
  (wide_string_hash, scm_string_hash, scm_i_string_hash)
  (scm_i_latin1_string_hash): Replace our lame string hash with Bob
  Jenkins' hash, treating each codepoint as a word, for the purposes of
  the algorithm.  There are probably more optimal hashes for our use
  cases.
  (scm_i_locale_string_hash): Remove optimization, as it wasn't used.
  (scm_i_utf8_string_hash): Add a specialized implementation for utf8.
  It's tricky but mostly just cut-and-paste.
2011-10-26 00:07:29 +02:00
Andy Wingo
cd644b5424 fix a vhash test
* test-suite/tests/vlist.test ("vhash"): As far as I can tell this test
  was not testing the right thing.
2011-10-26 00:07:29 +02:00
Andy Wingo
41d1d984ae optimize scm_from_utf8_stringn
* libguile/strings.c (decoding_error): Factor out of scm_from_stringn,
  properly handling errno.
  (scm_from_stringn): Adapt.
  (scm_from_utf8_stringn): Inline the conversion here, to avoid going
  through iconv.
2011-10-25 18:18:39 +02:00
Andy Wingo
25d50a051d most uses of scm_from_locale_symbol become scm_from_utf8_symbol
* libguile/array-handle.c:
* libguile/chars.c:
* libguile/expand.c:
* libguile/feature.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/instructions.c:
* libguile/load.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/options.c:
* libguile/print.c:
* libguile/smob.c:
* libguile/snarf.h: Change most uses of scm_from_locale_symbol to
  scm_from_utf8_symbol, as the symbols really are not locale-dependent.
2011-10-25 17:45:29 +02:00
Andy Wingo
f80d15c59e optimize utf8 symbol lookup
* libguile/symbols.c (utf8_string_equals_wide_string)
  (utf8_lookup_predicate_fn, lookup_interned_utf8_symbol): Optimize
  utf8 symbol lookup.
2011-10-25 17:35:58 +02:00
Andy Wingo
8b33752be7 slight scm_procedure_p, scm_i_procedure_arity refactor
* libguile/procs.c (scm_procedure_p):
* libguile/procprop.c (scm_i_procedure_arity): Refactor.
2011-10-24 19:01:12 +02:00
Andy Wingo
cf4c26625b remove CELL_P macro
* libguile/private-gc.h: Remove private CELL_P macro.
2011-10-24 19:00:59 +02:00
Andy Wingo
47ed8656db add SCM_HEAP_OBJECT_BASE
* libguile/tags.h (SCM_HEAP_OBJECT_BASE): New macro.  Given a SCM,
  returns a pointer to the start of its memory area on the heap.

* libguile/bytevectors.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/numbers.h:
* libguile/ports.c:
* libguile/smob.c:
* libguile/struct.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Use it.
2011-10-24 18:59:35 +02:00
Andy Wingo
8c5bb72920 add SCM_HEAP_OBJECT_P
* libguile/tags.h (SCM_HEAP_OBJECT_P): New macro, an alias for
  SCM_NIMP.

* libguile/arrays.c:
* libguile/debug.c:
* libguile/foreign.c:
* libguile/gdbint.c:
* libguile/guardians.c:
* libguile/list.c:
* libguile/modules.c:
* libguile/options.c:
* libguile/smob.c:
* libguile/validate.h:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Use it instead of SCM_NIMP or !SCM_IMP.
2011-10-24 18:55:43 +02:00
Andy Wingo
fdecb44f32 boot_closure_print cleanup
* libguile/eval.c (boot_closure_print): Get at the bits directly.
2011-10-24 18:55:35 +02:00
Andy Wingo
21041372ed add SCM_{PACK,UNPACK}_POINTER
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros.
  The old SCM2PTR and PTR2SCM were defined in such a way that
  round-tripping through a pointer could lose precision, even in the
  case in which you weren't interested in actually dereferencing the
  pointer, it was simply that you needed to plumb a SCM through APIs
  that take pointers.  These new macros are more like SCM_PACK and
  SCM_UNPACK, but for pointer types.  The bit representation of the
  pointer should be the same as the scm_t_bits representation.

* libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS
  pointers.  We are going to try tagging the SCM object itself in the
  future, and I don't think that keeping this support is worth its
  cost.  It probably doesn't work anyway.

* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/symbols.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Update many sites to use the new macros.
2011-10-24 18:54:04 +02:00
Andy Wingo
dc7da0be90 refactor tc7 and tc16 checks
* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New
  macros.

* libguile/bytevectors.h (SCM_BYTEVECTOR_P):
* libguile/control.h (SCM_PROMPT_P):
* libguile/filesys.h (SCM_DIRP):
* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P)
  (SCM_I_DYNAMIC_STATE_P):
* libguile/foreign.h (SCM_POINTER_P):
* libguile/fports.h (SCM_FPORTP):
* libguile/frames.h (SCM_VM_FRAME_P):
* libguile/hashtab.h (SCM_HASHTABLE_P):
* libguile/inline.h (scm_get_byte_or_eof):
* libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP):
* libguile/objcodes.h (SCM_OBJCODE_P):
* libguile/ports.h (SCM_OUTPUT_PORT_P):
* libguile/programs.h (SCM_PROGRAM_P):
* libguile/smob.h (SCM_SMOB_PREDICATE):
* libguile/srfi-14.h (SCM_CHARSETP):
* libguile/strings.c (IS_STRING):
* libguile/strports.h (SCM_STRPORTP):
* libguile/symbols.h (scm_is_symbol):
* libguile/variable.h (SCM_VARIABLEP):
* libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR):
* libguile/vm-i-system.c (call, tail-call, mv-call)
* libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P):
* libguile/weak-set.c (SCM_WEAK_SET_P):
* libguile/weak-table.c (SCM_WEAK_TABLE_P):
* libguile/weak-vector.h (SCM_I_WVECTP): Use them.
2011-10-24 18:54:01 +02:00
Andy Wingo
62fdadb0a5 check for pairs with scm_is_pair, not scm_nimp
* libguile/array-map.c (scm_ra_matchp, scm_ramapc):
* libguile/dynwind.c (scm_swap_bindings):
* libguile/hooks.c (hook_print, scm_c_run_hook, scm_c_run_hookn):
* libguile/objprop.c (scm_object_property, scm_set_object_property_x):
  Use !scm_is_pair as the termination condition, not scm_imp.
2011-10-24 17:22:47 +02:00
Andy Wingo
8c0e89ac90 de-inline cons in scm_acons
* libguile/alist.c (scm_acons): Don't inline the conses.
2011-10-24 17:14:27 +02:00
Andy Wingo
633f3a18b7 remove mutex in make-object-property
* module/ice-9/boot-9.scm (make-object-property): Remove the mutex; weak
  tables are now threadsafe.
2011-10-24 12:54:22 +02:00
Andy Wingo
a141db8604 remove weak pairs, rewrite weak vectors
* libguile/weak-vector.c:
* libguile/weak-vector.h: Renamed from weaks.[ch].  Remove weak pairs.
  They were not safe to access with `car' and `cdr'.  Remove weak alist
  vectors, as we have weak tables and sets.  Reimplement weak vectors,
  moving the implementation here.

* libguile/vectors.c:
* libguile/vectors.h: Remove the extra header word.  Use
  scm_c_weak_vector_ref / scm_c_weak_vector_set_x to access weak
  vectors.

* libguile/snarf.h: Remove the extra header word in vectors.

* libguile/threads.c (do_thread_exit, fat_mutex_lock, fat_mutex_unlock):
  Instead of weak pairs, store thread-owned mutexes in a list of
  one-element weak vectors.

* libguile/guardians.c (finalize_guarded): Similarly, store object
  guardians in a list of one-element weak vectors.

* libguile/modules.c (scm_module_reverse_lookup): We no longer need to
  handle the case of weak references.

* libguile/print.c (iprin1): Use the standard vector accessor to print
  vectors.

* libguile.h:
* libguile/Makefile.am:
* libguile/gc-malloc.c:
* libguile/gc.c:
* libguile/goops.c:
* libguile/init.c:
* libguile/objprop.c:
* libguile/struct.c: Update includes.

* module/ice-9/weak-vector.scm: Load weak vector definitions using an
  extension instead of %init-weaks-builtins.

* test-suite/tests/weaks.test: Use the make-...-hash-table names instead
  of the old alist vector names.
2011-10-24 12:54:14 +02:00
Andy Wingo
c4e83f74c2 remove a stale comment
* module/system/foreign.scm (define-wrapped-pointer-type): Remove stale
  comment.
2011-10-24 12:48:36 +02:00