1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 12:20:20 +02:00

* procs.c, procs.h (scm_subr_entry): New type: Stores data

associated with subrs.
(SCM_SUBRNUM, SCM_SUBR_ENTRY, SCM_SUBR_GENERIC, SCM_SUBR_PROPS,
SCM_SUBR_DOC): New macros.
(scm_subr_table): New variable.
(scm_mark_subr_table): New function.

* init.c (scm_boot_guile_1): Call scm_init_subr_table.

* gc.c (scm_gc_mark): Don't mark subr names here.
(scm_igc): Call scm_mark_subr_table.

* snarf.h (SCM_GPROC, SCM_GPROC1): New macros.

* procs.c, procs.h (scm_subr_p): New function (used internally).

* gsubr.c, gsubr.h (scm_make_gsubr_with_generic): New function.

* objects.c, objects.h (scm_primitive_generic): New class.

* objects.h (SCM_CMETHOD_CODE, SCM_CMETHOD_ENV): New macros.

* print.c (scm_iprin1): Print primitive-generics.

* __scm.h (SCM_WTA_DISPATCH_1, SCM_GASSERT1,
SCM_WTA_DISPATCH_2, SCM_GASSERT2): New macros.

* eval.c (SCM_CEVAL, SCM_APPLY): Replace scm_wta -->
SCM_WTA_DISPATCH_1 for scm_cxr's (unary floating point
primitives).  NOTE: This means that it is now *required* to use
SCM_GPROC1 when creating float scm_cxr's (float scm_cxr's is an
obscured representation that will be removed in the future anyway,
so backward compatibility is no problem here).

* numbers.c: Converted most numeric primitives (all but bit
comparison operations and bit operations) to dispatch on generic
if args don't match.

* eval.c, eval.h (scm_eval_body): New function.

* objects.c (scm_call_generic_0, scm_call_generic_1,
scm_call_generic_2, scm_call_generic_3, scm_apply_generic): New
functions.

* eval.c (SCM_CEVAL): Apply the cmethod directly after having
called scm_memoize_method instead of doing a second lookup.

* objects.h (scm_memoize_method): Now returns the memoized cmethod.

* procs.c (scm_make_subr_opt): Use scm_sysintern0 instead of
scm_sysintern so that the binding connected with the subr name
isn't cleared when we give set = 0.
This commit is contained in:
Mikael Djurfeldt 1999-08-26 04:24:42 +00:00
parent 52235e7173
commit 9de33deb2e
15 changed files with 614 additions and 128 deletions

View file

@ -70,11 +70,30 @@ typedef struct scm_dsubr
double (*dproc) ();
} scm_dsubr;
#define SCM_SNAME(x) ((SCM_CAR(x)>>8)?(SCM)(scm_heap_org+(SCM_CAR(x)>>8)):scm_nullstr)
typedef struct
{
SCM handle; /* link back to procedure object */
SCM name;
SCM *generic; /* 0 if no generic support
* *generic == 0 until first method
*/
SCM properties; /* procedure properties */
SCM documentation;
} scm_subr_entry;
#define SCM_SUBRNUM(subr) (SCM_CAR (subr) >> 8)
#define SCM_SET_SUBRNUM(subr, num) \
SCM_SETCAR (subr, (num >> 8) + SCM_TYP7 (subr))
#define SCM_SUBR_ENTRY(x) (scm_subr_table[SCM_SUBRNUM (x)])
#define SCM_SNAME(x) (SCM_SUBR_ENTRY (x).name)
#define SCM_SUBRF(x) (((scm_subr *)(SCM2PTR(x)))->cproc)
#define SCM_DSUBRF(x) (((scm_dsubr *)(SCM2PTR(x)))->dproc)
#define SCM_CCLO_SUBR(x) (SCM_VELTS(x)[0])
#define SCM_SUBR_GENERIC(x) (SCM_SUBR_ENTRY (x).generic)
#define SCM_SUBR_PROPS(x) (SCM_SUBR_ENTRY (x).properties)
#define SCM_SUBR_DOC(x) (SCM_SUBR_ENTRY (x).documentation)
/* Closures
*/
@ -139,9 +158,19 @@ typedef struct scm_dsubr
#define SCM_PROCEDURE(obj) SCM_CADR (obj)
#define SCM_SETTER(obj) SCM_CDDR (obj)
extern scm_subr_entry *scm_subr_table;
extern int scm_subr_table_size;
extern int scm_subr_table_room;
extern void scm_mark_subr_table (void);
extern void scm_free_subr_entry (SCM subr);
extern SCM scm_make_subr SCM_P ((const char *name, int type, SCM (*fcn) ()));
extern SCM scm_make_subr_with_generic (const char *name,
int type,
SCM (*fcn) (),
SCM *gf);
extern SCM scm_make_subr_opt SCM_P ((const char *name,
int type,
SCM (*fcn) (),
@ -150,12 +179,14 @@ extern SCM scm_makcclo SCM_P ((SCM proc, long len));
extern SCM scm_procedure_p SCM_P ((SCM obj));
extern SCM scm_closure_p SCM_P ((SCM obj));
extern SCM scm_thunk_p SCM_P ((SCM obj));
extern int scm_subr_p (SCM obj);
extern SCM scm_procedure_documentation SCM_P ((SCM proc));
extern SCM scm_procedure_with_setter_p SCM_P ((SCM obj));
extern SCM scm_make_procedure_with_setter SCM_P ((SCM procedure, SCM setter));
extern SCM scm_procedure SCM_P ((SCM proc));
extern SCM scm_setter SCM_P ((SCM proc));
extern void scm_init_iprocs SCM_P ((const scm_iproc *subra, int type));
extern void scm_init_subr_table (void);
extern void scm_init_procs SCM_P ((void));
#ifdef GUILE_DEBUG