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-02-16 00:24:00 +01:00
|
|
|
|
/* Copyright (C) 1995,1996,1998,2000,2001,2003,2004, 2006, 2008, 2009 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "libguile/alist.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
|
|
|
|
|
#include "libguile/procs.h"
|
|
|
|
|
|
#include "libguile/gsubr.h"
|
|
|
|
|
|
#include "libguile/objects.h"
|
2000-08-25 04:08:50 +00:00
|
|
|
|
#include "libguile/smob.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/root.h"
|
|
|
|
|
|
#include "libguile/vectors.h"
|
2004-08-11 19:38:58 +00:00
|
|
|
|
#include "libguile/hashtab.h"
|
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 14:27:38 +02:00
|
|
|
|
#include "libguile/programs.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
|
|
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/procprop.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
1999-03-12 08:17:50 +00:00
|
|
|
|
SCM_GLOBAL_SYMBOL (scm_sym_system_procedure, "system-procedure");
|
1998-05-04 11:32:58 +00:00
|
|
|
|
SCM_GLOBAL_SYMBOL (scm_sym_arity, "arity");
|
|
|
|
|
|
|
1998-11-26 07:44:35 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_i_procedure_arity (SCM proc)
|
1998-05-04 11:32:58 +00:00
|
|
|
|
{
|
|
|
|
|
|
int a = 0, o = 0, r = 0;
|
1998-11-26 07:44:35 +00:00
|
|
|
|
if (SCM_IMP (proc))
|
|
|
|
|
|
return SCM_BOOL_F;
|
1998-05-04 11:32:58 +00:00
|
|
|
|
loop:
|
|
|
|
|
|
switch (SCM_TYP7 (proc))
|
|
|
|
|
|
{
|
|
|
|
|
|
case scm_tc7_subr_1o:
|
|
|
|
|
|
o = 1;
|
|
|
|
|
|
case scm_tc7_subr_0:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case scm_tc7_subr_2o:
|
|
|
|
|
|
o = 1;
|
|
|
|
|
|
case scm_tc7_subr_1:
|
This set of patches separates the representation of the cxr family
of functions (car, cdr etc.) from the dsubr family of functions
(i. e. functions that take a double precision floating point
argument). Further, the algorithm for handling the cxr function
is improved.
* eval.c (SCM_CEVAL, SCM_APPLY, scm_trampoline_1), numbers.c
(scm_asinh, scm_acosh, scm_atanh, scm_truncate, scm_round, floor,
ceil, sqrt, fabs, exp, log, sin, cos, tan, asin, acos, atan, sinh,
cosh, tanh), objects.c (scm_class_of), procprop.c
(scm_i_procedure_arity), ramap.c (scm_array_map_x), tags.h
(scm_tc7_dsubr, scm_tcs_subrs): Introduce scm_tc7_dsubr as new
typecode for the dsubr family of functions.
* ramap.c (ramap_cxr, ramap_dsubr): Renamed ramap_cxr to
ramap_dsubr.
* eval.c (SCM_CEVAL, SCM_APPLY, call_cxr_1), pairs.c
(scm_init_pairs): Make use of the (now usable) second cell element
of a scm_tc7_cxr function to implement the cxr family of functions
more efficiently.
2003-06-01 13:58:42 +00:00
|
|
|
|
case scm_tc7_dsubr:
|
1998-05-04 11:32:58 +00:00
|
|
|
|
case scm_tc7_cxr:
|
|
|
|
|
|
a += 1;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case scm_tc7_subr_2:
|
|
|
|
|
|
a += 2;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case scm_tc7_subr_3:
|
|
|
|
|
|
a += 3;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case scm_tc7_asubr:
|
|
|
|
|
|
case scm_tc7_rpsubr:
|
|
|
|
|
|
case scm_tc7_lsubr:
|
|
|
|
|
|
r = 1;
|
1998-11-26 08:33:49 +00:00
|
|
|
|
break;
|
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 14:27:38 +02:00
|
|
|
|
case scm_tc7_program:
|
|
|
|
|
|
a += SCM_PROGRAM_DATA (proc)->nargs;
|
|
|
|
|
|
r = SCM_PROGRAM_DATA (proc)->nrest;
|
|
|
|
|
|
a -= r;
|
|
|
|
|
|
break;
|
1998-05-04 11:32:58 +00:00
|
|
|
|
case scm_tc7_lsubr_2:
|
|
|
|
|
|
a += 2;
|
1998-11-26 08:33:49 +00:00
|
|
|
|
r = 1;
|
1998-05-04 11:32:58 +00:00
|
|
|
|
break;
|
2000-08-25 04:08:50 +00:00
|
|
|
|
case scm_tc7_smob:
|
2000-12-07 07:10:26 +00:00
|
|
|
|
if (SCM_SMOB_APPLICABLE_P (proc))
|
2000-12-04 17:19:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
int type = SCM_SMOB_DESCRIPTOR (proc).gsubr_type;
|
|
|
|
|
|
a += SCM_GSUBR_REQ (type);
|
|
|
|
|
|
o = SCM_GSUBR_OPT (type);
|
|
|
|
|
|
r = SCM_GSUBR_REST (type);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2000-08-25 04:08:50 +00:00
|
|
|
|
return SCM_BOOL_F;
|
2000-12-04 17:19:35 +00:00
|
|
|
|
}
|
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-02-16 00:24:00 +01:00
|
|
|
|
case scm_tc7_gsubr:
|
|
|
|
|
|
{
|
|
|
|
|
|
unsigned int type = SCM_GSUBR_TYPE (proc);
|
|
|
|
|
|
a = SCM_GSUBR_REQ (type);
|
|
|
|
|
|
o = SCM_GSUBR_OPT (type);
|
|
|
|
|
|
r = SCM_GSUBR_REST (type);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
1999-03-11 11:47:22 +00:00
|
|
|
|
case scm_tc7_pws:
|
|
|
|
|
|
proc = SCM_PROCEDURE (proc);
|
|
|
|
|
|
goto loop;
|
1998-05-04 11:32:58 +00:00
|
|
|
|
case scm_tcs_closures:
|
2001-04-19 14:46:01 +00:00
|
|
|
|
proc = SCM_CLOSURE_FORMALS (proc);
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (scm_is_null (proc))
|
1998-05-04 11:32:58 +00:00
|
|
|
|
break;
|
2004-09-22 17:41:37 +00:00
|
|
|
|
while (scm_is_pair (proc))
|
1998-05-04 11:32:58 +00:00
|
|
|
|
{
|
|
|
|
|
|
++a;
|
|
|
|
|
|
proc = SCM_CDR (proc);
|
|
|
|
|
|
}
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_null (proc))
|
1998-05-04 11:32:58 +00:00
|
|
|
|
r = 1;
|
|
|
|
|
|
break;
|
* tags.h: Update tag system docs.
(scm_tc3_cons_gloc): Renamed to scm_tc3_struct. Changed all uses.
(scm_tcs_cons_gloc): Renamed to scm_tcs_struct. Changed all uses.
(SCM_ECONSP, SCM_NECONSP): Removed. Changed all uses to SCM_CONSP
or SCM_NCONSP, respectively.
* struct.c, struct.h, srcprop.c, procs.c, procprop.c, print.c,
objects.c. modules.c, goops.c, eval.c, debug.c: Changed all uses
of scm_tc3_cond_gloc and scm_tcs_cons_gloc. See above.
* print.c (scm_iprin1): Remove printing of glocs. Do not try to
tell glocs from structs.
* gc.c (scm_gc_mark, scm_gc_sweep): Remove handling of glocs.
* eval.c (scm_m_atbind): Make a list of variables, not glocs.
(scm_ceval, scm_deval): For SCM_IM_BIND, fiddle with variables
instead of with glocs.
(EVALCAR): Do not test for glocs.
(scm_lookupcar, scm_lookupcar1): Do not handle glocs in race
condition.
(scm_unmemocar): Do not handle glocs.
(scm_m_atfop): Memoize as a variable, not as a gloc.
(scm_eval_args, scm_deval_args): Do not handle glocs.
(scm_ceval, scm_deval): Likewise.
* eval.h (SCM_XEVALCAR): Do not test for glocs.
(SCM_GLOC_VAR, SCM_GLOC_VAL, SCM_GLOC_SET_VAL, SCM_GLOC_VAL_LOC):
Removed.
* debug.h, debug.c (scm_make_gloc, scm_gloc_p): Removed.
* dynwind.c (scm_swap_bindings): Likewise.
(scm_dowinds): Updated to recognize lists of variables instead of
lists of glocs.
* __scm.h (SCM_CAUTIOS, SCM_RECKLESS): Update comments.
2001-07-26 21:40:18 +00:00
|
|
|
|
case scm_tcs_struct:
|
1999-08-29 03:27:18 +00:00
|
|
|
|
if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
|
|
|
|
|
|
{
|
|
|
|
|
|
r = 1;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!SCM_I_OPERATORP (proc))
|
1998-11-26 07:44:35 +00:00
|
|
|
|
return SCM_BOOL_F;
|
1999-08-29 03:27:18 +00:00
|
|
|
|
proc = (SCM_I_ENTITYP (proc)
|
|
|
|
|
|
? SCM_ENTITY_PROCEDURE (proc)
|
|
|
|
|
|
: SCM_OPERATOR_PROCEDURE (proc));
|
|
|
|
|
|
a -= 1;
|
|
|
|
|
|
goto loop;
|
1998-11-26 07:44:35 +00:00
|
|
|
|
default:
|
|
|
|
|
|
return SCM_BOOL_F;
|
1998-05-04 11:32:58 +00:00
|
|
|
|
}
|
2004-07-23 15:43:02 +00:00
|
|
|
|
return scm_list_3 (scm_from_int (a), scm_from_int (o), scm_from_bool(r));
|
1998-05-04 11:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2004-08-19 20:34:58 +00:00
|
|
|
|
/* XXX - instead of using a stand-in value for everything except
|
|
|
|
|
|
closures, we should find other ways to store the procedure
|
|
|
|
|
|
properties for those other kinds of procedures. For example, subrs
|
|
|
|
|
|
have their own property slot, which is unused at present.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
static SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_stand_in_scm_proc(SCM proc)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-11 19:38:58 +00:00
|
|
|
|
SCM handle, answer;
|
|
|
|
|
|
handle = scm_hashq_get_handle (scm_stand_in_procs, proc);
|
|
|
|
|
|
if (scm_is_false (handle))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
answer = scm_closure (scm_list_2 (SCM_EOL, SCM_BOOL_F), SCM_EOL);
|
2004-08-11 19:38:58 +00:00
|
|
|
|
scm_hashq_set_x (scm_stand_in_procs, proc, answer);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2004-08-11 19:38:58 +00:00
|
|
|
|
answer = SCM_CDR (handle);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return answer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_procedure_properties, "procedure-properties", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM proc),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return @var{obj}'s property list.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_procedure_properties
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_PROC (1, proc);
|
1998-05-04 11:32:58 +00:00
|
|
|
|
return scm_acons (scm_sym_arity, scm_i_procedure_arity (proc),
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_PROCPROPS (SCM_CLOSUREP (proc)
|
1998-05-04 11:32:58 +00:00
|
|
|
|
? proc
|
|
|
|
|
|
: scm_stand_in_scm_proc (proc)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_set_procedure_properties_x, "set-procedure-properties!", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM proc, SCM new_val),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Set @var{obj}'s property list to @var{alist}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_set_procedure_properties_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
if (!SCM_CLOSUREP (proc))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
proc = scm_stand_in_scm_proc(proc);
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CLOSURE (1, proc);
|
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:31:08 +00:00
|
|
|
|
SCM_SETPROCPROPS (proc, new_val);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_procedure_property, "procedure-property", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM p, SCM k),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return the property of @var{obj} with name @var{key}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_procedure_property
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM assoc;
|
2004-07-27 15:41:49 +00:00
|
|
|
|
if (scm_is_eq (k, scm_sym_arity))
|
1998-11-26 07:44:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM arity;
|
2004-07-06 10:59:25 +00:00
|
|
|
|
SCM_ASSERT (scm_is_true (arity = scm_i_procedure_arity (p)),
|
1999-12-12 02:36:16 +00:00
|
|
|
|
p, SCM_ARG1, FUNC_NAME);
|
1998-11-26 07:44:35 +00:00
|
|
|
|
return arity;
|
|
|
|
|
|
}
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_PROC (1, p);
|
1998-05-04 11:32:58 +00:00
|
|
|
|
assoc = scm_sloppy_assq (k,
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_PROCPROPS (SCM_CLOSUREP (p)
|
1998-05-04 11:32:58 +00:00
|
|
|
|
? p
|
|
|
|
|
|
: scm_stand_in_scm_proc (p)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return (SCM_NIMP (assoc) ? SCM_CDR (assoc) : SCM_BOOL_F);
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_set_procedure_property_x, "set-procedure-property!", 3, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM p, SCM k, SCM v),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"In @var{obj}'s property list, set the property named @var{key} to\n"
|
|
|
|
|
|
"@var{value}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_set_procedure_property_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM assoc;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
if (!SCM_CLOSUREP (p))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
p = scm_stand_in_scm_proc(p);
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CLOSURE (1, p);
|
2004-07-27 15:41:49 +00:00
|
|
|
|
if (scm_is_eq (k, scm_sym_arity))
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_MISC_ERROR ("arity is a read-only property", SCM_EOL);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
assoc = scm_sloppy_assq (k, SCM_PROCPROPS (p));
|
|
|
|
|
|
if (SCM_NIMP (assoc))
|
|
|
|
|
|
SCM_SETCDR (assoc, v);
|
|
|
|
|
|
else
|
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:31:08 +00:00
|
|
|
|
SCM_SETPROCPROPS (p, scm_acons (k, v, SCM_PROCPROPS (p)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_procprop ()
|
|
|
|
|
|
{
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/procprop.x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|