* eval.c, eval.h, evalext.c, evalext.h (scm_sym_setter,
scm_m_generalized_set_x, scm_init_evalext): Move the declaration
and definition of the memoizer for the generalized set! macro from
evalext.[ch] to eval.[ch]. Use the SCM_SYNTAX snarfer macro to
define the macro object.
* eval.c, eval.h (s_set_x, scm_s_set_x, scm_m_set_x,
scm_m_generalized_set_x): Since now scm_s_set_x is only used in
eval.c, it is made static and renamed to s_set_x.
* evalext.c (scm_defined_p, scm_m_undefine): Prefer !SCM_<foo>
over SCM_N<foo>.
2003-04-20 19:18:43 +00:00
|
|
|
|
/* Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
|
1998-10-31 13:31:25 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* 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.
|
1998-10-31 13:31:25 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* 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.
|
1998-10-31 13:31:25 +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
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1998-10-31 13:31:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
2000-06-21 02:46:01 +00:00
|
|
|
|
#include "libguile/fluids.h"
|
2003-05-06 20:05:04 +00:00
|
|
|
|
#include "libguile/modules.h"
|
1998-10-31 13:31:25 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/evalext.h"
|
1998-10-31 13:31:25 +00:00
|
|
|
|
|
2002-10-19 09:07:23 +00:00
|
|
|
|
SCM_DEFINE (scm_defined_p, "defined?", 1, 1, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM sym, SCM env),
|
2001-05-05 19:03:42 +00:00
|
|
|
|
"Return @code{#t} if @var{sym} is defined in the lexical "
|
2001-05-06 00:02:06 +00:00
|
|
|
|
"environment @var{env}. When @var{env} is not specified, "
|
|
|
|
|
|
"look in the top-level environment as defined by the "
|
2001-05-05 19:03:42 +00:00
|
|
|
|
"current module.")
|
2002-10-19 09:07:23 +00:00
|
|
|
|
#define FUNC_NAME s_scm_defined_p
|
1998-10-31 13:31:25 +00:00
|
|
|
|
{
|
2001-05-15 14:57:22 +00:00
|
|
|
|
SCM var;
|
1998-10-31 13:31:25 +00:00
|
|
|
|
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_SYMBOL (1, sym);
|
1998-10-31 13:31:25 +00:00
|
|
|
|
|
1998-11-20 17:14:41 +00:00
|
|
|
|
if (SCM_UNBNDP (env))
|
2001-05-15 14:57:22 +00:00
|
|
|
|
var = scm_sym2var (sym, scm_current_module_lookup_closure (),
|
|
|
|
|
|
SCM_BOOL_F);
|
1998-11-20 17:14:41 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM frames = env;
|
|
|
|
|
|
register SCM b;
|
|
|
|
|
|
for (; SCM_NIMP (frames); frames = SCM_CDR (frames))
|
|
|
|
|
|
{
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_ASSERT (SCM_CONSP (frames), env, SCM_ARG2, FUNC_NAME);
|
1998-11-20 17:14:41 +00:00
|
|
|
|
b = SCM_CAR (frames);
|
* eval.c, eval.h, evalext.c, evalext.h (scm_sym_setter,
scm_m_generalized_set_x, scm_init_evalext): Move the declaration
and definition of the memoizer for the generalized set! macro from
evalext.[ch] to eval.[ch]. Use the SCM_SYNTAX snarfer macro to
define the macro object.
* eval.c, eval.h (s_set_x, scm_s_set_x, scm_m_set_x,
scm_m_generalized_set_x): Since now scm_s_set_x is only used in
eval.c, it is made static and renamed to s_set_x.
* evalext.c (scm_defined_p, scm_m_undefine): Prefer !SCM_<foo>
over SCM_N<foo>.
2003-04-20 19:18:43 +00:00
|
|
|
|
if (!SCM_FALSEP (scm_procedure_p (b)))
|
1998-11-20 17:14:41 +00:00
|
|
|
|
break;
|
2000-01-12 01:51:18 +00:00
|
|
|
|
SCM_ASSERT (SCM_CONSP (b), env, SCM_ARG2, FUNC_NAME);
|
1998-11-20 17:14:41 +00:00
|
|
|
|
for (b = SCM_CAR (b); SCM_NIMP (b); b = SCM_CDR (b))
|
|
|
|
|
|
{
|
* eval.c, eval.h, evalext.c, evalext.h (scm_sym_setter,
scm_m_generalized_set_x, scm_init_evalext): Move the declaration
and definition of the memoizer for the generalized set! macro from
evalext.[ch] to eval.[ch]. Use the SCM_SYNTAX snarfer macro to
define the macro object.
* eval.c, eval.h (s_set_x, scm_s_set_x, scm_m_set_x,
scm_m_generalized_set_x): Since now scm_s_set_x is only used in
eval.c, it is made static and renamed to s_set_x.
* evalext.c (scm_defined_p, scm_m_undefine): Prefer !SCM_<foo>
over SCM_N<foo>.
2003-04-20 19:18:43 +00:00
|
|
|
|
if (!SCM_CONSP (b))
|
1998-11-20 17:14:41 +00:00
|
|
|
|
{
|
2000-04-03 08:47:51 +00:00
|
|
|
|
if (SCM_EQ_P (b, sym))
|
1998-11-20 17:14:41 +00:00
|
|
|
|
return SCM_BOOL_T;
|
|
|
|
|
|
else
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2000-04-03 08:47:51 +00:00
|
|
|
|
if (SCM_EQ_P (SCM_CAR (b), sym))
|
1998-11-20 17:14:41 +00:00
|
|
|
|
return SCM_BOOL_T;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2001-05-15 14:57:22 +00:00
|
|
|
|
var = scm_sym2var (sym,
|
|
|
|
|
|
SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F,
|
|
|
|
|
|
SCM_BOOL_F);
|
1998-11-20 17:14:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
return (SCM_FALSEP (var) || SCM_UNBNDP (SCM_VARIABLE_REF (var))
|
1998-11-20 17:14:41 +00:00
|
|
|
|
? SCM_BOOL_F
|
|
|
|
|
|
: SCM_BOOL_T);
|
1998-10-31 13:31:25 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-10-31 13:31:25 +00:00
|
|
|
|
|
2002-11-24 18:21:48 +00:00
|
|
|
|
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_REGISTER_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
|
1998-12-07 16:48:35 +00:00
|
|
|
|
|
2003-05-06 20:05:04 +00:00
|
|
|
|
|
2003-01-20 10:12:39 +00:00
|
|
|
|
SCM_DEFINE (scm_self_evaluating_p, "self-evaluating?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"Return #t for objects which Guile considers self-evaluating")
|
|
|
|
|
|
#define FUNC_NAME s_scm_self_evaluating_p
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (SCM_ITAG3 (obj))
|
|
|
|
|
|
{
|
|
|
|
|
|
case scm_tc3_int_1:
|
|
|
|
|
|
case scm_tc3_int_2:
|
|
|
|
|
|
/* inum */
|
|
|
|
|
|
return SCM_BOOL_T;
|
|
|
|
|
|
case scm_tc3_imm24:
|
|
|
|
|
|
/* characters, booleans, other immediates */
|
|
|
|
|
|
return SCM_BOOL (!SCM_NULLP (obj));
|
|
|
|
|
|
case scm_tc3_cons:
|
|
|
|
|
|
switch (SCM_TYP7 (obj))
|
|
|
|
|
|
{
|
|
|
|
|
|
case scm_tcs_closures:
|
|
|
|
|
|
case scm_tc7_vector:
|
|
|
|
|
|
case scm_tc7_wvect:
|
2003-03-27 20:07:10 +00:00
|
|
|
|
#if SCM_HAVE_ARRAYS
|
2003-01-20 10:12:39 +00:00
|
|
|
|
case scm_tc7_bvect:
|
|
|
|
|
|
case scm_tc7_byvect:
|
|
|
|
|
|
case scm_tc7_svect:
|
|
|
|
|
|
case scm_tc7_ivect:
|
|
|
|
|
|
case scm_tc7_uvect:
|
|
|
|
|
|
case scm_tc7_fvect:
|
|
|
|
|
|
case scm_tc7_dvect:
|
|
|
|
|
|
case scm_tc7_cvect:
|
2003-03-25 23:54:35 +00:00
|
|
|
|
#if SCM_SIZEOF_LONG_LONG != 0
|
2003-01-20 10:12:39 +00:00
|
|
|
|
case scm_tc7_llvect:
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#endif
|
|
|
|
|
|
case scm_tc7_string:
|
|
|
|
|
|
case scm_tc7_smob:
|
|
|
|
|
|
case scm_tc7_cclo:
|
|
|
|
|
|
case scm_tc7_pws:
|
|
|
|
|
|
case scm_tcs_subrs:
|
|
|
|
|
|
case scm_tcs_struct:
|
|
|
|
|
|
return SCM_BOOL_T;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_MISC_ERROR ("Internal error: Object ~S has unknown type",
|
|
|
|
|
|
scm_list_1 (obj));
|
|
|
|
|
|
return SCM_UNSPECIFIED; /* never reached */
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
1998-10-31 13:31:25 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_evalext ()
|
|
|
|
|
|
{
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/evalext.x"
|
1998-10-31 13:31:25 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|