1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-04 22:40:25 +02:00
guile/libguile/evalext.c
Marius Vollmer 8dc9439fc6 * alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file.  Thanks
to Lars J. Aas!

* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions.  Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00

160 lines
4.9 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
#include "libguile/_scm.h"
#include "libguile/eval.h"
#include "libguile/macros.h"
#include "libguile/modules.h"
#include "libguile/fluids.h"
#include "libguile/validate.h"
#include "libguile/evalext.h"
SCM_SYMBOL (scm_sym_setter, "setter");
SCM
scm_m_generalized_set_x (SCM xorig, SCM env)
{
SCM x = SCM_CDR (xorig);
SCM_ASSYNT (2 == scm_ilength (x), xorig, scm_s_expression, scm_s_set_x);
if (SCM_SYMBOLP (SCM_CAR (x)))
return scm_cons (SCM_IM_SET_X, x);
else if (SCM_CONSP (SCM_CAR (x)))
return scm_cons (SCM_LIST2 (scm_sym_setter, SCM_CAAR (x)),
scm_append (SCM_LIST2 (SCM_CDAR (x), SCM_CDR (x))));
return scm_wta (xorig, scm_s_variable, scm_s_set_x);
}
SCM_DEFINE (scm_definedp, "defined?", 1, 1, 0,
(SCM sym, SCM env),
"Return @code{#t} if @var{sym} is defined in the top-level environment.")
#define FUNC_NAME s_scm_definedp
{
SCM vcell;
SCM_VALIDATE_SYMBOL (1,sym);
if (SCM_UNBNDP (env))
vcell = scm_sym2vcell(sym,
scm_module_system_booted_p
? SCM_TOP_LEVEL_LOOKUP_CLOSURE
: SCM_EOL,
SCM_BOOL_F);
else
{
SCM frames = env;
register SCM b;
for (; SCM_NIMP (frames); frames = SCM_CDR (frames))
{
SCM_ASSERT (SCM_CONSP (frames), env, SCM_ARG2, FUNC_NAME);
b = SCM_CAR (frames);
if (SCM_NFALSEP (scm_procedure_p (b)))
break;
SCM_ASSERT (SCM_CONSP (b), env, SCM_ARG2, FUNC_NAME);
for (b = SCM_CAR (b); SCM_NIMP (b); b = SCM_CDR (b))
{
if (SCM_NCONSP (b))
{
if (SCM_EQ_P (b, sym))
return SCM_BOOL_T;
else
break;
}
if (SCM_EQ_P (SCM_CAR (b), sym))
return SCM_BOOL_T;
}
}
vcell = scm_sym2vcell (sym,
SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F,
SCM_BOOL_F);
}
return (SCM_FALSEP (vcell) || SCM_UNBNDP (SCM_CDR (vcell))
? SCM_BOOL_F
: SCM_BOOL_T);
}
#undef FUNC_NAME
SCM_SYNTAX (s_undefine, "undefine", scm_makacro, scm_m_undefine);
SCM
scm_m_undefine (SCM x, SCM env)
{
SCM arg1 = x;
x = SCM_CDR (x);
SCM_ASSYNT (SCM_TOP_LEVEL (env), arg1, "bad placement ", s_undefine);
SCM_ASSYNT (SCM_CONSP (x) && SCM_NULLP (SCM_CDR (x)),
arg1, scm_s_expression, s_undefine);
x = SCM_CAR (x);
SCM_ASSYNT (SCM_SYMBOLP (x), arg1, scm_s_variable, s_undefine);
arg1 = scm_sym2vcell (x, scm_env_top_level (env), SCM_BOOL_F);
SCM_ASSYNT (SCM_NFALSEP (arg1) && !SCM_UNBNDP (SCM_CDR (arg1)),
x, "variable already unbound ", s_undefine);
SCM_SETCDR (arg1, SCM_UNDEFINED);
#ifdef SICP
return SCM_CAR (arg1);
#else
return SCM_UNSPECIFIED;
#endif
}
SCM_REGISTER_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
void
scm_init_evalext ()
{
scm_make_synt (scm_s_set_x, scm_makmmacro, scm_m_generalized_set_x);
#ifndef SCM_MAGIC_SNARFER
#include "libguile/evalext.x"
#endif
}
/*
Local Variables:
c-file-style: "gnu"
End:
*/