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

303 commits

Author SHA1 Message Date
Andy Wingo
c40944c9ff remove code-table slot from methods
* libguile/goops.c (scm_sys_invalidate_method_cache_x, scm_make)
  (create_standard_classes): Remove code-table slot from methods. The
  generic cache completely does its job, afaict.

* libguile/goops.h (scm_si_formals, scm_si_body, scm_si_make_procedure):
  Renumber slots.

* module/oop/goops.scm (initialize on <method>): No more code-table
  slot.

* module/oop/goops/compile.scm: Always "compile" a method, instead of
  looking for a hit in an always-empty cache.
2009-11-26 00:25:06 +01:00
Andy Wingo
6d33e90f0c remove used-by slot from generics
* libguile/goops.c (clear_method_cache)
  (scm_sys_invalidate_method_cache_x, scm_make)
  (create_standard_classes): Remove the used-by method from generics, as
  it is not used at all.

* libguile/goops.h: Renumber generic slots.

* module/oop/goops/dispatch.scm (memoize-method!): No more used-by slot.
2009-11-26 00:25:06 +01:00
Andy Wingo
0f84ac3fe6 first step towards effective methods
* libguile/goops.c (create_standard_classes):
* libguile/goops.h *scm_si_applicable_methods, scm_si_effective_method)
  (scm_si_applicable_setter_methods, scm_si_effective_setter_method):
  Add space for the new form of the generic cache and effective method.
2009-11-26 00:25:06 +01:00
Andy Wingo
b6cf4d0265 a very big commit cleaning up structs & goops. also applicable structs.
I tried to split this one, and I know it's a bit disruptive, but this
stuff really is one big cobweb. So instead we'll pretend like these are
separate commits, by separating the changelog.

Applicable struct runtime support.

* libguile/debug.c (scm_procedure_source):
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
  (scm_trampoline_2):
* libguile/eval.i.c (CEVAL):
* libguile/goops.c (scm_class_of):
* libguile/procprop.c (scm_i_procedure_arity):
* libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow
  for applicable structs. Whee!

* libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym
  for scm_vtable_index_self.
  (scm_vtable_index_printer): Alias scm_vtable_index_instance_printer.
  (scm_struct_i_free): Alias scm_vtable_index_instance_finalize.
  (scm_struct_i_flags): Alias scm_vtable_index_flags.
  (SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now.
  (SCM_SET_VTABLE_DESTRUCTOR): Implement by hand.

Hidden slots.

* libguile/struct.c (scm_make_struct_layout): Add support for "hidden"
  fields, writable fields that are not visible to make-struct. This
  allows us to add fields to vtables and not break existing make-struct
  invocations.
  (scm_struct_ref, scm_struct_set_x): Always get struct length from the
  vtable. Support hidden fields.

* libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New
  slot classes, to correspond to the new vtable slots.
  (scm_sys_prep_layout_x): Turn hidden slots into 'h'.
  (build_class_class_slots): Reorder the class slots to account for
  vtable fields coming out of negative-land, for name as a vtable slot,
  and for hidden fields.
  (create_standard_classes): Define <hidden-slot> and
  <protected-hidden-slot>.

Clean up struct.h.

* libguile/struct.h: Lay things out cleaner. There are no more hidden
  (negative) words. Names are nicer. The exposition is nicer. But the
  basics are the same. The incompatibilities are that <vtable> has more
  slots now, and that scm_alloc_struct's signature has changed. The
  former is ameliorated by the "hidden" slots mentioned before, and the
  latter, well, it was always a very internal thing...
  (scm_t_struct_finalize): New type, a finalizer function to be run when
  instances of a vtable are collected.
  (scm_t_struct_free): Removed, structs' data is managed by the GC now,
  and not freed by vtable functions.

* libguile/struct.c: (scm_vtable_p): Now we keep flags on
  vtable-vtables, so this check is cheaper.
  (scm_alloc_struct): No hidden words. Yippee.
  (struct_finalizer_trampoline): Entersify.
  (scm_make_struct): No need to babysit extra words, though now we have
  to babysit flags. Propagate the vtable, applicable, and setter flags
  appropriately.
  (scm_make_vtable_vtable): Update for new simplicity.
  (scm_print_struct): A better printer.
  (scm_init_struct): Define <applicable-struct-vtable>, a magical vtable
  like CL's funcallable-standard-class. Also define
  <applicable-struct-with-setter-vtable>.

Remove foreign object implementation.

* libguile/goops.h:
* libguile/goops.c (scm_make_foreign_object, scm_make_class)
  (scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these
  were undocumented and unworking.

Clean up goops.h, a little.

* libguile/goops.h:
* libguile/goops.c: Also clean up.
* module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset
  index.
2009-11-26 00:24:58 +01:00
Ken Raeburn
222831b443 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.
2009-11-16 14:24:32 -05:00
Andy Wingo
e161c9f85c actually set all 8 hashsets in classes
* libguile/goops.c (prep_hashsets): Actually set all 8 hashsets. Doh...
2009-11-15 20:28:12 +01:00
Andy Wingo
4d34fbe181 remove goops-local %tag-body
* libguile/goops.c (scm_sys_tag_body): Remove goops-local hack that is
  no longer necessary.
2009-11-15 20:28:12 +01:00
Andy Wingo
26fe6af140 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 :)
2009-11-15 20:28:12 +01:00
Andy Wingo
efcebb5b56 fold objects.[ch] into goops.[ch]
Remove objects.h #includes as appropriate.
2009-11-15 20:28:12 +01:00
Andy Wingo
11561496ba 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.
2009-11-15 20:28:11 +01:00
Andy Wingo
521ac49bde 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.
2009-11-15 20:28:11 +01:00
Andy Wingo
730d8ad9e6 remove operators 2009-11-15 20:28:11 +01:00
Ludovic Courtès
288bbc44cf 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.
2009-10-25 22:49:28 +01:00
Ken Raeburn
32b12f4050 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.
2009-10-23 14:02:56 -04:00
Ludovic Courtès
d587c9e8b2 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.
2009-10-20 00:10:18 +02:00
Ludovic Courtès
7af531508c Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/Makefile.am
	libguile/bytevectors.c
	libguile/gc-card.c
	libguile/gc-mark.c
	libguile/programs.c
	libguile/srcprop.c
	libguile/srfi-14.c
	libguile/symbols.c
	libguile/threads.c
	libguile/unif.c
	libguile/vm.c
2009-08-28 19:16:46 +02:00
Michael Gran
9db8cf1634 Avoid unpacking symbols in GOOPS
* libguile/goops.c (scm_make_extended_class_from_symbol): new function
  (scm_class_of): don't unpack symbol chars
  (wrap_init): don't unpack symbol chars
  (make_class_from_symbol): new function
  (make_struct_class): don't unpack symbol chars
2009-08-23 10:40:44 -07:00
Andy Wingo
2fb924f64f programs have their own tc7 now
* libguile/tags.h (scm_tc7_program):
* libguile/programs.h: Programs now have their own tc7 code. Fix up the
  macros appropriately.

* libguile/programs.c: Remove smobby bits, leaving marking, printing,
  and application for other parts of Guile.

* libguile/debug.c (scm_procedure_source):
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
  (scm_trampoline_2): Add cases for tc7_program.
* libguile/eval.i.c (CEVAL, SCM_APPLY):
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/gc-card.c (scm_i_sweep_card, scm_i_tag_name):
* libguile/gc-mark.c (1):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_thunk_p)
* libguile/vm-i-system.c (make-closure): Adapt to new procedure
  representation.

* libguile/procprop.c (scm_i_procedure_arity): Do the right thing for
  programs.
* test-suite/tests/procprop.test ("procedure-arity"): Arity test now
  succeeds.

* libguile/goops.c (scm_class_of): Programs now belong to the class
  <procedure>, not a smob class.

* libguile/vm.h (struct vm, struct vm_cont):
* libguile/vm-engine.c (vm_engine):
* libguile/frames.h (SCM_FRAME_BYTE_CAST, struct vm_frame):
* libguile/frames.c (scm_c_make_vm_frame): Fix usages of scm_byte_t,
  changing them to scm_t_uint8.
2009-08-20 18:52:51 +02:00
Ludovic Courtès
fbb857a472 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	lib/Makefile.am
	libguile/Makefile.am
	libguile/frames.c
	libguile/gc-card.c
	libguile/gc-freelist.c
	libguile/gc-mark.c
	libguile/gc-segment.c
	libguile/gc_os_dep.c
	libguile/load.c
	libguile/macros.c
	libguile/objcodes.c
	libguile/programs.c
	libguile/strings.c
	libguile/vm.c
	m4/gnulib-cache.m4
	m4/gnulib-comp.m4
	m4/inline.m4
2009-08-18 00:06:45 +02:00
Ludovic Courtès
4d0949ea45 Make the evaluator's memoizers private.
* libguile/eval.c (macroexp): Move upwards.
  (scm_m_quote, scm_m_begin, scm_m_if, scm_m_set_x, scm_m_and, scm_m_or,
  scm_m_case, scm_m_cond, scm_m_lambda, scm_m_letstar, scm_m_do,
  scm_m_quasiquote, scm_m_delay, scm_m_generalized_set_x,
  scm_m_define, scm_m_letrec, scm_m_let, scm_m_at, scm_m_atat,
  scm_m_apply, scm_m_cont, scm_m_nil_cond, scm_m_atfop,
  scm_m_atbind, scm_m_atslot_ref, scm_m_atslot_set_x,
  scm_m_at_call_with_values, scm_m_eval_when): New static
  declarations; definitions made static.
  (s_atslot_ref, s_atslot_set_x): New, from `goops.c'.

* libguile/eval.h (scm_m_quote, scm_m_begin, scm_m_if, scm_m_set_x,
  scm_m_vref, scm_m_vset, scm_m_and, scm_m_or, scm_m_case, scm_m_cond,
  scm_m_lambda, scm_m_letstar, scm_m_do, scm_m_quasiquote, scm_m_delay,
  scm_m_generalized_set_x, scm_m_future, scm_m_define, scm_m_letrec,
  scm_m_let, scm_m_at, scm_m_atat, scm_m_apply, scm_m_cont,
  scm_m_nil_cond, scm_m_atfop, scm_m_atbind, scm_m_atslot_ref,
  scm_m_atslot_set_x, scm_m_atdispatch, scm_m_at_call_with_values,
  scm_m_eval_when): Remove public declarations.

* libguile/goops.c (s_atslot_ref, s_atslot_set_x): Remove.
2009-08-13 23:30:49 +02:00
Andy Wingo
ce471ab8b0 rename SCM_SNAME to SCM_SUBR_NAME
* libguile/procs.h: Rename SCM_SNAME to SCM_SUBR_NAME.

* libguile/debug.c:
* libguile/eval.c:
* libguile/eval.i.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/print.c:
* libguile/procs.c: Update callers.
2009-06-19 11:20:34 +02:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Ludovic Courtès
d9e59f894e Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/continuations.c
	libguile/gc-freelist.c
	libguile/gc-mark.c
	libguile/symbols.c
	libguile/threads.c
	module/ice-9/boot-9.scm
2009-03-22 15:28:35 +01:00
Andy Wingo
3b91e017e3 Merge commit 'e20d7001c3' into vm-check
Conflicts:

	libguile/stacks.c
2009-03-17 16:40:52 +01:00
Andy Wingo
3e64d235e9 Merge commit 'feccd2d310' into vm-check 2009-03-17 16:09:41 +01:00
Andy Wingo
c872cc2f37 Merge commit '6290d3f109' into vm-check 2009-03-17 16:05:41 +01:00
Andy Wingo
80a7d5dc8e Merge commit '5bb2d903b9' into vm-check 2009-03-17 16:05:37 +01:00
Andy Wingo
798e66ab10 Merge commit '04795a1cb2' into vm-check 2009-03-17 16:04:04 +01:00
Andy Wingo
997eda2a30 Merge commit '202271f291' into vm-check 2009-03-17 16:01:35 +01:00
Ludovic Courtès
f307fbcec2 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/gc-card.c
	libguile/gc-mark.c
2009-03-08 23:04:06 +01:00
Ludovic Courtès
e20d7001c3 Remove "compiled closures" ("cclos") in favor of a simpler mechanism.
The idea is to introduce `gsubrs' whose arity is encoded in their type
(more precisely in the sizeof (void *) - 8 MSBs).  This removes the
indirection introduced by cclos and simplifies the code.

* libguile/__scm.h (CCLO): Remove.

* libguile/debug.c (scm_procedure_source, scm_procedure_environment):
  Remove references to `scm_tc7_cclo'.

* libguile/eval.c (scm_trampoline_0, scm_trampoline_1,
  scm_trampoline_2): Replace `scm_tc7_cclo' with `scm_tc7_gsubr'.

* libguile/eval.i.c (CEVAL): Likewise.  No longer make PROC the first
  argument.  Directly invoke `scm_gsubr_apply ()' instead of jump to the
  `evap(N+1)' label or call to `SCM_APPLY ()'.

* libguile/evalext.c (scm_self_evaluating_p): Remove reference to
  `scm_tc7_cclo'.

* libguile/gc-card.c (scm_i_sweep_card, scm_i_tag_name): Likewise.

* libguile/gc-mark.c (scm_gc_mark_dependencies): Likewise.

* libguile/goops.c (scm_class_of): Likewise.

* libguile/print.c (iprin1): Likewise.

* libguile/gsubr.c (create_gsubr): Use `unsigned int's for REQ, OPT and
  RST.  Use `scm_tc7_gsubr' instead of `scm_makcclo ()' in the default
  case.
  (scm_gsubr_apply): Remove calls to `SCM_GSUBR_PROC ()'.
  (scm_f_gsubr_apply): Remove.

* libguile/gsubr.h (SCM_GSUBR_TYPE): New definition.
  (SCM_GSUBR_MAX): Changed to 33.
  (SCM_SET_GSUBR_TYPE, SCM_GSUBR_PROC, SCM_SET_GSUBR_PROC,
  scm_f_gsubr_apply): Remove.

* libguile/procprop.c (scm_i_procedure_arity): Remove reference to
  `scm_tc7_cclo'; add proper handling of `scm_tc7_gsubr'.

* libguile/procs.c (scm_makcclo, scm_make_cclo): Remove.
  (scm_procedure_p): Remove reference to `scm_tc7_cclo'.
  (scm_thunk_p): Likewise, plus add proper `scm_tc7_gsubr' handling.

* libguile/procs.h (SCM_CCLO_LENGTH, SCM_MAKE_CCLO_TAG,
  SCM_SET_CCLO_LENGTH, SCM_CCLO_BASE, SCM_SET_CCLO_BASE, SCM_CCLO_REF,
  SCM_CCLO_SET, SCM_CCLO_SUBR, SCM_SET_CCLO_SUBR, scm_makcclo,
  scm_make_cclo): Remove.

* libguile/stacks.c (read_frames): Remove reference to `scm_f_gsubr_apply'.

* libguile/tags.h (scm_tc7_cclo): Remove.
  (scm_tc7_gsubr): New.
  (scm_tcs_subrs): Add `scm_tc7_gsubr'.
2009-03-02 00:20:43 +01:00
Ludovic Courtès
f7a1ab8b94 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/gc-mark.c
	libguile/procs.c
	libguile/procs.h
	libguile/threads.c
	libguile/threads.h
2009-02-14 17:32:46 +01:00
Andy Wingo
e177058bc4 don't re-enter the compiler during method dispatch
* libguile/goops.c (scm_make): In the pre-inst `make', default
  `procedure' to #f, and read a `make-procedure' instead of
  `compile-env'.

* libguile/goops.h (scm_si_make_procedure): This instead of
  scm_si_compile_env.

* module/oop/goops.scm (make-method): Remove this unused function. Users
  should use (make <method> ...) directly.
  (method): Capture `make-procedure' instead of `procedure' in the case
  that the body calls a next-method. Allows for the kind of
  "recompilation" that we were using before, but with closures instead of
  re-entering the compiler. Type-specific compilation is still
  interesting, but probably should be implemented in another way.
  (initialize): Default #:procedure to #f, and
  s/compile-env/make-procedure/.

* module/oop/goops/compile.scm (code-table-lookup): Just return the
  cmethod, not the entry -- since the entry is now just (append types
  cmethod).
  (compile-make-procedure): New procedure, returns a form that, when
  evaluated/compiled, will yield a procedure of one argument, the
  next-method. When called with a next-method, the procedure returns an
  actual method implementation. compile-make-procedure returns #f if the
  body doesn't call next-method.
  (compile-method): Unify to always return procedures. Much cleaner and
  *much* faster in the compiled case. In the interpreted case, there
  might be a slight slowdown, but if there is one it should be slight.

* module/oop/goops/dispatch.scm (method-cache-install!): Adapt to removal
  of compute-entry-with-cmethod.
2009-02-13 23:30:20 +01:00
Ludovic Courtès
feccd2d310 Add SCM_SET_SUBR_GENERIC ()' to replace SCM_SUBR_GENERIC ()' as an lvalue.
* libguile/goops.c (scm_c_extend_primitive_generic): Use
  `SCM_SET_SUBR_GENERIC ()' instead of using `SCM_SUBR_GENERIC ()' as an
  lvalue.

* libguile/procs.c (scm_c_make_subr_with_generic): Use `SCM_SET_SUBR_GENERIC_LOC ()'.

* libguile/procs.h (SCM_SET_SUBR_GENERIC, SCM_SET_SUBR_GENERIC_LOC): New macros.
2009-02-11 23:37:46 +01:00
Andy Wingo
bef9591104 "optimize" dispatch to specific GF's in goops
* libguile/goops.c: Some micro-optimizations so that calling generic
  functions as part of the protocol doesn't cons.
2009-02-04 00:49:55 +01:00
Ludovic Courtès
6290d3f109 GOOPS: Statically allocate the PORT class array.
* libguile/goops.c (scm_port_class): Statically allocate it.
  (create_port_classes): Don't use `scm_calloc ()'.

* libguile/goops.h (scm_port_class): Update declaration.

* libguile/ports.c (scm_make_port_type): When checking whether
  GOOPS is initialized, check whether the first element of
  SCM_PORT_CLASS is non-zero.
2009-02-03 00:03:09 +01:00
Ludovic Courtès
5bb2d903b9 Publish the maximum number of port types as `SCM_I_MAX_PORT_TYPE_COUNT'.
* libguile/goops.c (create_port_classes): Use
  `SCM_I_MAX_PORT_TYPE_COUNT' instead of a hard-wired 256.

* libguile/objects.h (SCM_OUT_PCLASS_INDEX, SCM_INOUT_PCLASS_INDEX):
  Likewise.

* libguile/ports.c (scm_make_port_type): Likewise.

* libguile/ports.h (SCM_I_MAX_PORT_TYPE_COUNT): New macro.
2009-02-03 00:02:59 +01:00
Ludovic Courtès
04795a1cb2 GOOPS: Statically allocate the SMOB class array.
* libguile/goops.c (scm_smob_class): Statically allocate it.
  (create_smob_classes): Don't malloc(3) `scm_smob_class'.

* libguile/goops.h (scm_smob_class): Update declaration.

* libguile/smob.c (scm_make_smob_type, scm_set_smob_apply): When
  checking whether GOOPS is initialized, check whether the first element
  of SCM_SMOB_CLASS is non-zero.
2009-02-03 00:02:50 +01:00
Ludovic Courtès
202271f291 Publish the maximum number of SMOB types as `SCM_I_MAX_SMOB_TYPE_COUNT'.
* libguile/goops.c (create_smob_classes): Refer to
  `SCM_I_MAX_SMOB_TYPE_COUNT' rather than 255 (which is wrong) or 256.

* libguile/smob.c (MAX_SMOB_COUNT): Alias for `SCM_I_MAX_SMOB_TYPE_COUNT'.

* libguile/smob.h (SCM_I_MAX_SMOB_TYPE_COUNT): New macro.
2009-02-03 00:02:36 +01:00
Ludovic Courtès
63385df2fd GOOPS: Statically allocate the PORT class array.
* libguile/goops.c (scm_port_class): Statically allocate it.
  (create_port_classes): Don't use `scm_calloc ()'.

* libguile/goops.h (scm_port_class): Update declaration.

* libguile/ports.c (scm_make_port_type): When checking whether
  GOOPS is initialized, check whether the first element of
  SCM_PORT_CLASS is non-zero.
2009-01-18 20:21:44 +01:00
Ludovic Courtès
0953b54946 Publish the maximum number of port types as `SCM_I_MAX_PORT_TYPE_COUNT'.
* libguile/goops.c (create_port_classes): Use
  `SCM_I_MAX_PORT_TYPE_COUNT' instead of a hard-wired 256.

* libguile/objects.h (SCM_OUT_PCLASS_INDEX, SCM_INOUT_PCLASS_INDEX):
  Likewise.

* libguile/ports.c (scm_make_port_type): Likewise.

* libguile/ports.h (SCM_I_MAX_PORT_TYPE_COUNT): New macro.
2009-01-18 18:47:20 +01:00
Ludovic Courtès
474554694f GOOPS: Statically allocate the SMOB class array.
* libguile/goops.c (scm_smob_class): Statically allocate it.
  (create_smob_classes): Don't malloc(3) `scm_smob_class'.

* libguile/goops.h (scm_smob_class): Update declaration.

* libguile/smob.c (scm_make_smob_type, scm_set_smob_apply): When
  checking whether GOOPS is initialized, check whether the first element
  of SCM_SMOB_CLASS is non-zero.
2009-01-18 16:53:01 +01:00
Ludovic Courtès
c891a40e9f Publish the maximum number of SMOB types as `SCM_I_MAX_SMOB_TYPE_COUNT'.
* libguile/goops.c (create_smob_classes): Refer to
  `SCM_I_MAX_SMOB_TYPE_COUNT' rather than 255 (which is wrong) or 256.

* libguile/smob.c (MAX_SMOB_COUNT): Alias for `SCM_I_MAX_SMOB_TYPE_COUNT'.

* libguile/smob.h (SCM_I_MAX_SMOB_TYPE_COUNT): New macro.
2009-01-18 16:42:17 +01:00
Ludovic Courtès
d0cad2492c Use scm_gc_malloc ()' when allocating GOOPS t_extension' objects.
* libguile/goops.c (extension_gc_hint): New.
  (scm_c_extend_primitive_generic): Use `scm_gc_malloc ()' instead of
  `scm_malloc ()'.
  (setup_extended_primitive_generics): Don't call `free(3)' when
  removing a `t_extension' object.
2009-01-18 16:30:36 +01:00
Ludovic Courtès
2b807ea75c Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	lib/Makefile.am
	m4/gnulib-cache.m4
	m4/gnulib-comp.m4
2009-01-17 22:44:05 +01:00
Andy Wingo
c32929d14d Merge commit 'origin/master' into vm
Conflicts:

	.gitignore
	guile-tools.in
	srfi/srfi-19.scm
2009-01-12 21:36:39 +01:00
Neil Jerram
a9931e4e1a Fix implementation of %fast-slot-ref and %fast-slot-set!
* libguile/goops.c (scm_sys_fast_slot_ref, scm_sys_fast_slot_set_x):
  Correct incantation for getting the number of slots of the specified
  instance.

* libguile/goops.h (SCM_NUMBER_OF_SLOTS): Removed (because wrong).

* test-suite/standalone/test-fast-slot-ref.in: New standalone test.

* configure.in: Generate test-suite/standalone/test-fast-slot-ref.

* test-suite/standalone/Makefile.am (check_SCRIPTS): Add
  test-fast-slot-ref.
2009-01-04 22:46:47 +00:00
Andy Wingo
4631414e29 compile goops submodules, goops.test now passes again
* libguile/goops.c (get_slot_value, set_slot_value): While keeping the
  inlined getter/setter dispatch for closures, allow the getters and
  setters to be any kind of procedure.

* oop/goops.scm (compute-getters-n-setters): Relax the checks on
  getter/setter procedures, so that if a getter is a procedure but not a
  closure, we don't try to poke its arity.

* oop/goops/Makefile.am (SOURCES): Compile all the goops submodules!

* oop/goops/old-define-method.scm: Removed, in an act of housekeeping.

* oop/goops/compile.scm:
* oop/goops/dispatch.scm: Break a circular module dependency by making
  sure that (oop goops) is loaded when we go to compile submodules.

* oop/goops/compile.scm (compile-method/memoizer)
  (compile-method/memoizer+next): Allow a procedure without source
  through. This can happen with getter and setter lambdas that were
  compiled, and in that case there is no next-method call anyway. Ideally
  we should be able to specify compile-method for accessor methods...
2008-10-31 11:35:47 +01:00
Andy Wingo
fd7ac322a5 fix chaining up from interpreted to compiled methods; allow compiled init-thunk
* libguile/goops.c (scm_sys_initialize_object): Don't assume that an init
  thunk is a closure; just go through scm_call_0 instead.

* oop/goops/compile.scm (make-make-next-method/memoizer): Allow for the
  case that the next method is compiled.
2008-10-31 10:14:49 +01:00
Andy Wingo
5487977b1b runtime byte compilation of goops methods, whooooo
* ice-9/boot-9.scm (make-modules-in): Change to make sure that we are
  making modules in modules; that is, that a global binding of `compile'
  doesn't prevent a module from importing a submodule named `compile'.
  (resolve-module): Clean up a bit, and serialize the logic.

* libguile/objects.c (scm_mcache_lookup_cmethod, scm_apply_generic):
* libguile/eval.i.c (CEVAL): Now that cmethod entries can have a program
  as their tail instead of a memoized proc, we have to change the halting
  condition on the method cache search, in both places: the one that's
  inlined into eval.i.c and the one in objects.c. If the cmethod isn't a
  pair, apply it.

* libguile/goops.c (make): In the `make' procedure that's used before
  GOOPS is booted, bind #:formals, #:body, and #:compile-env on methods.

* oop/goops/compile.scm (compute-entry-with-cmethod): There was a
  terrible trick here that involved putting a dummy pair in the cache,
  then modifying it in place with the result of memoization. The note
  claimed that this was to cut recursion short, or something. I can't see
  how it could recurse, given that `methods' is changing each time. Also,
  the pair trick doesn't work with byte-compiled methods. So, remove it.
  (compile-method): Dispatch to the appropriate method compiler, based on
  whether the method was defined with the interpreter or with the
  compiler.
  (make-next-method): New function, generically computes a `next-method'
  procedure, though the caller has to supply the arguments.
  (compile-method/vm): Exciting method byte compiler!
  (make-make-next-method/memoizer, compile-method/memoizer): Add the
  /memoizer suffix, and move all this code to the bottom of the file.
2008-10-30 13:42:40 +01:00