mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 17:50:29 +02:00
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'.
60 lines
2 KiB
C
60 lines
2 KiB
C
/* classes: h_files */
|
||
|
||
#ifndef SCM_GSUBR_H
|
||
#define SCM_GSUBR_H
|
||
|
||
/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||
*
|
||
* This library is free software; you can redistribute it and/or
|
||
* modify it under the terms of the GNU Lesser General Public
|
||
* License as published by the Free Software Foundation; either
|
||
* version 2.1 of the License, or (at your option) any later version.
|
||
*
|
||
* This library is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
* Lesser General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU Lesser General Public
|
||
* License along with this library; if not, write to the Free Software
|
||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
*/
|
||
|
||
|
||
|
||
#include "libguile/__scm.h"
|
||
|
||
|
||
|
||
/* Return an integer describing the arity of GSUBR, a subr of type
|
||
`scm_tc7_gsubr'. The result can be interpreted with `SCM_GSUBR_REQ ()'
|
||
and similar. */
|
||
#define SCM_GSUBR_TYPE(gsubr) (SCM_CELL_TYPE (gsubr) >> 8)
|
||
|
||
#define SCM_GSUBR_MAKTYPE(req, opt, rst) ((req)|((opt)<<4)|((rst)<<8))
|
||
#define SCM_GSUBR_MAX 33
|
||
#define SCM_GSUBR_REQ(x) ((long)(x)&0xf)
|
||
#define SCM_GSUBR_OPT(x) (((long)(x)&0xf0)>>4)
|
||
#define SCM_GSUBR_REST(x) ((long)(x)>>8)
|
||
|
||
SCM_API SCM scm_c_make_gsubr (const char *name,
|
||
int req, int opt, int rst, SCM (*fcn) ());
|
||
SCM_API SCM scm_c_make_gsubr_with_generic (const char *name,
|
||
int req, int opt, int rst,
|
||
SCM (*fcn) (), SCM *gf);
|
||
SCM_API SCM scm_c_define_gsubr (const char *name,
|
||
int req, int opt, int rst, SCM (*fcn) ());
|
||
SCM_API SCM scm_c_define_gsubr_with_generic (const char *name,
|
||
int req, int opt, int rst,
|
||
SCM (*fcn) (), SCM *gf);
|
||
|
||
SCM_API SCM scm_gsubr_apply (SCM args);
|
||
SCM_INTERNAL void scm_init_gsubr (void);
|
||
|
||
#endif /* SCM_GSUBR_H */
|
||
|
||
/*
|
||
Local Variables:
|
||
c-file-style: "gnu"
|
||
End:
|
||
*/
|