-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 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.
+ * 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.
*
- * 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.
+ * 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.
*
- * 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. */
+ * 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
+ */
\f
/* SECTION: This code is compiled once.
*/
-#ifndef DEVAL
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
-/* We need this to get the definitions for HAVE_ALLOCA_H, etc. */
-#include "libguile/scmconfig.h"
+#include "libguile/__scm.h"
+
+#ifndef DEVAL
/* AIX requires this to be the first thing in the file. The #pragma
directive is indented so pre-ANSI compilers will ignore it, rather
#include "libguile/alist.h"
#include "libguile/eq.h"
#include "libguile/continuations.h"
+#include "libguile/futures.h"
#include "libguile/throw.h"
#include "libguile/smob.h"
#include "libguile/macros.h"
* Originally, it is defined to scm_ceval, but is redefined to
* scm_deval during the second pass.
*
- * SIDEVAL corresponds to SCM_CEVAL, but is used in situations where
- * only side effects of expressions matter. All immediates are
- * ignored.
- *
* SCM_EVALIM is used when it is known that the expression is an
* immediate. (This macro never calls an evaluator.)
*
* EVALCAR evaluates the car of an expression.
*
- * EVALCELLCAR is like EVALCAR, but is used when it is known that the
- * car is a lisp cell.
- *
* The following macros should be used in code which is read once
* (where the choice of evaluator is dynamic):
*
*/
#define SCM_CEVAL scm_ceval
-#define SIDEVAL(x, env) if (SCM_NIMP (x)) SCM_CEVAL((x), (env))
-
-#define EVALCELLCAR(x, env) (SCM_SYMBOLP (SCM_CAR (x)) \
- ? *scm_lookupcar (x, env, 1) \
- : SCM_CEVAL (SCM_CAR (x), env))
#define EVALCAR(x, env) (SCM_IMP (SCM_CAR (x)) \
? SCM_EVALIM (SCM_CAR (x), env) \
- : EVALCELLCAR (x, env))
+ : (SCM_SYMBOLP (SCM_CAR (x)) \
+ ? *scm_lookupcar (x, env, 1) \
+ : SCM_CEVAL (SCM_CAR (x), env)))
-#define EXTEND_ENV SCM_EXTEND_ENV
+SCM_REC_MUTEX (source_mutex);
-#ifdef MEMOIZE_LOCALS
+/* Lookup a given local variable in an environment. The local variable is
+ * given as an iloc, that is a triple <frame, binding, last?>, where frame
+ * indicates the relative number of the environment frame (counting upwards
+ * from the innermost environment frame), binding indicates the number of the
+ * binding within the frame, and last? (which is extracted from the iloc using
+ * the macro SCM_ICDRP) indicates whether the binding forms the binding at the
+ * very end of the improper list of bindings. */
SCM *
scm_ilookup (SCM iloc, SCM env)
{
- register long ir = SCM_IFRAME (iloc);
- register SCM er = env;
- for (; 0 != ir; --ir)
- er = SCM_CDR (er);
- er = SCM_CAR (er);
- for (ir = SCM_IDIST (iloc); 0 != ir; --ir)
- er = SCM_CDR (er);
+ unsigned int frame_nr = SCM_IFRAME (iloc);
+ unsigned int binding_nr = SCM_IDIST (iloc);
+ SCM frames = env;
+ SCM bindings;
+
+ for (; 0 != frame_nr; --frame_nr)
+ frames = SCM_CDR (frames);
+
+ bindings = SCM_CAR (frames);
+ for (; 0 != binding_nr; --binding_nr)
+ bindings = SCM_CDR (bindings);
+
if (SCM_ICDRP (iloc))
- return SCM_CDRLOC (er);
- return SCM_CARLOC (SCM_CDR (er));
+ return SCM_CDRLOC (bindings);
+ return SCM_CARLOC (SCM_CDR (bindings));
}
-#endif
-#ifdef USE_THREADS
/* The Lookup Car Race
- by Eva Luator
arbitrary amount of time or even deadlock. But with the current
solution a lot of unnecessary work is potentially done. */
-/* SCM_LOOKUPCAR1 is was SCM_LOOKUPCAR used to be but is allowed to
+/* SCM_LOOKUPCAR1 is what SCM_LOOKUPCAR used to be but is allowed to
return NULL to indicate a failed lookup due to some race conditions
between threads. This only happens when VLOC is the first cell of
a special form that will eventually be memoized (like `let', etc.)
for NULL. I think I've found the only places where this
applies. */
-#endif /* USE_THREADS */
-
SCM_SYMBOL (scm_unbound_variable_key, "unbound-variable");
-#ifdef USE_THREADS
static SCM *
scm_lookupcar1 (SCM vloc, SCM genv, int check)
-#else
-SCM *
-scm_lookupcar (SCM vloc, SCM genv, int check)
-#endif
{
SCM env = genv;
register SCM *al, fl, var = SCM_CAR (vloc);
-#ifdef MEMOIZE_LOCALS
register SCM iloc = SCM_ILOC00;
-#endif
for (; SCM_NIMP (env); env = SCM_CDR (env))
{
if (!SCM_CONSP (SCM_CAR (env)))
{
if (SCM_EQ_P (fl, var))
{
-#ifdef MEMOIZE_LOCALS
-#ifdef USE_THREADS
if (! SCM_EQ_P (SCM_CAR (vloc), var))
goto race;
-#endif
SCM_SET_CELL_WORD_0 (vloc, SCM_UNPACK (iloc) + SCM_ICDR);
-#endif
return SCM_CDRLOC (*al);
}
else
al = SCM_CDRLOC (*al);
if (SCM_EQ_P (SCM_CAR (fl), var))
{
-#ifdef MEMOIZE_LOCALS
-#ifndef SCM_RECKLESS /* letrec inits to SCM_UNDEFINED */
if (SCM_UNBNDP (SCM_CAR (*al)))
{
env = SCM_EOL;
goto errout;
}
-#endif
-#ifdef USE_THREADS
if (!SCM_EQ_P (SCM_CAR (vloc), var))
goto race;
-#endif
SCM_SETCAR (vloc, iloc);
-#endif
return SCM_CARLOC (*al);
}
-#ifdef MEMOIZE_LOCALS
iloc = SCM_PACK (SCM_UNPACK (iloc) + SCM_IDINC);
-#endif
}
-#ifdef MEMOIZE_LOCALS
iloc = SCM_PACK ((~SCM_IDSTMSK) & (SCM_UNPACK(iloc) + SCM_IFRINC));
-#endif
}
{
SCM top_thunk, real_var;
if (SCM_FALSEP (real_var))
goto errout;
-#ifndef SCM_RECKLESS
if (!SCM_NULLP (env) || SCM_UNBNDP (SCM_VARIABLE_REF (real_var)))
{
errout:
return &undef_object;
}
}
-#endif
-#ifdef USE_THREADS
if (!SCM_EQ_P (SCM_CAR (vloc), var))
{
/* Some other thread has changed the very cell we are working
var = SCM_CAR (vloc);
if (SCM_VARIABLEP (var))
return SCM_VARIABLE_LOC (var);
-#ifdef MEMOIZE_LOCALS
if (SCM_ITAG7 (var) == SCM_ITAG7 (SCM_ILOC00))
return scm_ilookup (var, genv);
-#endif
/* We can't cope with anything else than variables and ilocs. When
a special form has been memoized (i.e. `let' into `#@let') we
return NULL and expect the calling function to do the right
the dispatch on the car of the form. */
return NULL;
}
-#endif /* USE_THREADS */
SCM_SETCAR (vloc, real_var);
return SCM_VARIABLE_LOC (real_var);
}
}
-#ifdef USE_THREADS
SCM *
scm_lookupcar (SCM vloc, SCM genv, int check)
{
abort ();
return loc;
}
-#endif
#define unmemocar scm_unmemocar
sym = sym_three_question_marks;
SCM_SETCAR (form, sym);
}
-#ifdef MEMOIZE_LOCALS
else if (SCM_ILOCP (c))
{
unsigned long int ir;
env = SCM_CDR (env);
SCM_SETCAR (form, SCM_ICDRP (c) ? env : SCM_CAR (env));
}
-#endif
return form;
}
}
SCM_GLOBAL_SYMBOL (scm_sym_unquote, "unquote");
SCM_GLOBAL_SYMBOL (scm_sym_uq_splicing, "unquote-splicing");
-SCM scm_f_apply;
-
-#ifdef DEBUG_EXTENSIONS
SCM_GLOBAL_SYMBOL (scm_sym_enter_frame, "enter-frame");
SCM_GLOBAL_SYMBOL (scm_sym_apply_frame, "apply-frame");
SCM_GLOBAL_SYMBOL (scm_sym_exit_frame, "exit-frame");
SCM_GLOBAL_SYMBOL (scm_sym_trace, "trace");
-#endif
/* Check that the body denoted by XORIG is valid and rewrite it into
}
-SCM_SYNTAX (s_quote, "quote", scm_makmmacro, scm_m_quote);
-SCM_GLOBAL_SYMBOL (scm_sym_quote, s_quote);
-
-SCM
-scm_m_quote (SCM xorig, SCM env SCM_UNUSED)
-{
- SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 1, scm_s_expression, s_quote);
- return scm_cons (SCM_IM_QUOTE, SCM_CDR (xorig));
-}
-
-
-SCM_SYNTAX (s_begin, "begin", scm_makmmacro, scm_m_begin);
-SCM_GLOBAL_SYMBOL (scm_sym_begin, s_begin);
-
-SCM
-scm_m_begin (SCM xorig, SCM env SCM_UNUSED)
-{
- SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 0, scm_s_expression, s_begin);
- return scm_cons (SCM_IM_BEGIN, SCM_CDR (xorig));
-}
-
-
-SCM_SYNTAX (s_if, "if", scm_makmmacro, scm_m_if);
-SCM_GLOBAL_SYMBOL (scm_sym_if, s_if);
-
-SCM
-scm_m_if (SCM xorig, SCM env SCM_UNUSED)
-{
- long len = scm_ilength (SCM_CDR (xorig));
- SCM_ASSYNT (len >= 2 && len <= 3, scm_s_expression, s_if);
- return scm_cons (SCM_IM_IF, SCM_CDR (xorig));
-}
-
-
-/* Will go into the RnRS module when Guile is factorized.
-SCM_SYNTAX (scm_s_set_x,"set!", scm_makmmacro, scm_m_set_x); */
-const char scm_s_set_x[] = "set!";
-SCM_GLOBAL_SYMBOL (scm_sym_set_x, scm_s_set_x);
-
-SCM
-scm_m_set_x (SCM xorig, SCM env SCM_UNUSED)
-{
- SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (scm_ilength (x) == 2, scm_s_expression, scm_s_set_x);
- SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (x)), scm_s_variable, scm_s_set_x);
- return scm_cons (SCM_IM_SET_X, x);
-}
+/* Start of the memoizers for the standard R5RS builtin macros. */
SCM_SYNTAX (s_and, "and", scm_makmmacro, scm_m_and);
}
-SCM_SYNTAX (s_or, "or", scm_makmmacro, scm_m_or);
-SCM_GLOBAL_SYMBOL (scm_sym_or, s_or);
+SCM_SYNTAX (s_begin, "begin", scm_makmmacro, scm_m_begin);
+SCM_GLOBAL_SYMBOL (scm_sym_begin, s_begin);
SCM
-scm_m_or (SCM xorig, SCM env SCM_UNUSED)
+scm_m_begin (SCM xorig, SCM env SCM_UNUSED)
{
- long len = scm_ilength (SCM_CDR (xorig));
- SCM_ASSYNT (len >= 0, scm_s_test, s_or);
- if (len >= 1)
- return scm_cons (SCM_IM_OR, SCM_CDR (xorig));
- else
- return SCM_BOOL_F;
+ SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 0, scm_s_expression, s_begin);
+ return scm_cons (SCM_IM_BEGIN, SCM_CDR (xorig));
}
}
-SCM_SYNTAX (s_lambda, "lambda", scm_makmmacro, scm_m_lambda);
-SCM_GLOBAL_SYMBOL (scm_sym_lambda, s_lambda);
+SCM_SYNTAX(s_define, "define", scm_makmmacro, scm_m_define);
+SCM_GLOBAL_SYMBOL(scm_sym_define, s_define);
-/* Return true if OBJ is `eq?' to one of the elements of LIST or to the
- * cdr of the last cons. (Thus, LIST is not required to be a proper
- * list and OBJ can also be found in the improper ending.) */
-static int
-scm_c_improper_memq (SCM obj, SCM list)
+/* Guile provides an extension to R5RS' define syntax to represent function
+ * currying in a compact way. With this extension, it is allowed to write
+ * (define <nested-variable> <body>), where <nested-variable> has of one of
+ * the forms (<nested-variable> <formals>), (<nested-variable> . <formal>),
+ * (<variable> <formals>) or (<variable> . <formal>). As in R5RS, <formals>
+ * should be either a sequence of zero or more variables, or a sequence of one
+ * or more variables followed by a space-delimited period and another
+ * variable. Each level of argument nesting wraps the <body> within another
+ * lambda expression. For example, the following forms are allowed, each one
+ * followed by an equivalent, more explicit implementation.
+ * Example 1:
+ * (define ((a b . c) . d) <body>) is equivalent to
+ * (define a (lambda (b . c) (lambda d <body>)))
+ * Example 2:
+ * (define (((a) b) c . d) <body>) is equivalent to
+ * (define a (lambda () (lambda (b) (lambda (c . d) <body>))))
+ */
+/* Dirk:FIXME:: We should provide an implementation for 'define' in the R5RS
+ * module that does not implement this extension. */
+SCM
+scm_m_define (SCM x, SCM env)
{
- for (; SCM_CONSP (list); list = SCM_CDR (list))
+ SCM name;
+ x = SCM_CDR (x);
+ SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_expression, s_define);
+ name = SCM_CAR (x);
+ x = SCM_CDR (x);
+ while (SCM_CONSP (name))
{
- if (SCM_EQ_P (SCM_CAR (list), obj))
- return 1;
+ /* This while loop realizes function currying by variable nesting. */
+ SCM formals = SCM_CDR (name);
+ x = scm_list_1 (scm_cons2 (scm_sym_lambda, formals, x));
+ name = SCM_CAR (name);
}
- return SCM_EQ_P (list, obj);
-}
-
-SCM
-scm_m_lambda (SCM xorig, SCM env SCM_UNUSED)
-{
- SCM formals;
- SCM x = SCM_CDR (xorig);
-
- SCM_ASSYNT (SCM_CONSP (x), scm_s_formals, s_lambda);
-
- formals = SCM_CAR (x);
- while (SCM_CONSP (formals))
+ SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_variable, s_define);
+ SCM_ASSYNT (scm_ilength (x) == 1, scm_s_expression, s_define);
+ if (SCM_TOP_LEVEL (env))
{
- SCM formal = SCM_CAR (formals);
- SCM_ASSYNT (SCM_SYMBOLP (formal), scm_s_formals, s_lambda);
- if (scm_c_improper_memq (formal, SCM_CDR (formals)))
- scm_misc_error (s_lambda, scm_s_duplicate_formals, SCM_EOL);
- formals = SCM_CDR (formals);
+ SCM var;
+ x = scm_eval_car (x, env);
+ if (SCM_REC_PROCNAMES_P)
+ {
+ SCM tmp = x;
+ while (SCM_MACROP (tmp))
+ tmp = SCM_MACRO_CODE (tmp);
+ if (SCM_CLOSUREP (tmp)
+ /* Only the first definition determines the name. */
+ && SCM_FALSEP (scm_procedure_property (tmp, scm_sym_name)))
+ scm_set_procedure_property_x (tmp, scm_sym_name, name);
+ }
+ var = scm_sym2var (name, scm_env_top_level (env), SCM_BOOL_T);
+ SCM_VARIABLE_SET (var, x);
+ return SCM_UNSPECIFIED;
}
- if (!SCM_NULLP (formals) && !SCM_SYMBOLP (formals))
- scm_misc_error (s_lambda, scm_s_formals, SCM_EOL);
-
- return scm_cons2 (SCM_IM_LAMBDA, SCM_CAR (x),
- scm_m_body (SCM_IM_LAMBDA, SCM_CDR (x), s_lambda));
+ else
+ return scm_cons2 (SCM_IM_DEFINE, name, x);
}
-SCM_SYNTAX (s_letstar, "let*", scm_makmmacro, scm_m_letstar);
-SCM_GLOBAL_SYMBOL (scm_sym_letstar, s_letstar);
+SCM_SYNTAX (s_delay, "delay", scm_makmmacro, scm_m_delay);
+SCM_GLOBAL_SYMBOL (scm_sym_delay, s_delay);
-/* (let* ((v1 i1) (v2 i2) ...) body) with variables v1 .. vk and initializers
- * i1 .. ik is transformed into the form (#@let* (v1 i1 v2 i2 ...) body*). */
+/* Promises are implemented as closures with an empty parameter list. Thus,
+ * (delay <expression>) is transformed into (#@delay '() <expression>), where
+ * the empty list represents the empty parameter list. This representation
+ * allows for easy creation of the closure during evaluation. */
SCM
-scm_m_letstar (SCM xorig, SCM env SCM_UNUSED)
+scm_m_delay (SCM xorig, SCM env SCM_UNUSED)
{
- SCM bindings;
- SCM x = SCM_CDR (xorig);
- SCM vars = SCM_EOL;
- SCM *varloc = &vars;
-
- SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letstar);
-
- bindings = SCM_CAR (x);
- SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_letstar);
- while (!SCM_NULLP (bindings))
- {
- SCM binding = SCM_CAR (bindings);
- SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, s_letstar);
- SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, s_letstar);
- *varloc = scm_list_2 (SCM_CAR (binding), SCM_CADR (binding));
- varloc = SCM_CDRLOC (SCM_CDR (*varloc));
- bindings = SCM_CDR (bindings);
- }
-
- return scm_cons2 (SCM_IM_LETSTAR, vars,
- scm_m_body (SCM_IM_LETSTAR, SCM_CDR (x), s_letstar));
+ SCM_ASSYNT (scm_ilength (xorig) == 2, scm_s_expression, s_delay);
+ return scm_cons2 (SCM_IM_DELAY, SCM_EOL, SCM_CDR (xorig));
}
}
-SCM_SYNTAX (s_quasiquote, "quasiquote", scm_makacro, scm_m_quasiquote);
-SCM_GLOBAL_SYMBOL (scm_sym_quasiquote, s_quasiquote);
+SCM_SYNTAX (s_if, "if", scm_makmmacro, scm_m_if);
+SCM_GLOBAL_SYMBOL (scm_sym_if, s_if);
-/* Internal function to handle a quasiquotation: 'form' is the parameter in
- * the call (quasiquotation form), 'env' is the environment where unquoted
- * expressions will be evaluated, and 'depth' is the current quasiquotation
- * nesting level and is known to be greater than zero. */
-static SCM
-iqq (SCM form, SCM env, unsigned long int depth)
+SCM
+scm_m_if (SCM xorig, SCM env SCM_UNUSED)
{
- if (SCM_CONSP (form))
+ long len = scm_ilength (SCM_CDR (xorig));
+ SCM_ASSYNT (len >= 2 && len <= 3, scm_s_expression, s_if);
+ return scm_cons (SCM_IM_IF, SCM_CDR (xorig));
+}
+
+
+SCM_SYNTAX (s_lambda, "lambda", scm_makmmacro, scm_m_lambda);
+SCM_GLOBAL_SYMBOL (scm_sym_lambda, s_lambda);
+
+/* Return true if OBJ is `eq?' to one of the elements of LIST or to the
+ * cdr of the last cons. (Thus, LIST is not required to be a proper
+ * list and OBJ can also be found in the improper ending.) */
+static int
+scm_c_improper_memq (SCM obj, SCM list)
+{
+ for (; SCM_CONSP (list); list = SCM_CDR (list))
{
- SCM tmp = SCM_CAR (form);
- if (SCM_EQ_P (tmp, scm_sym_quasiquote))
- {
- SCM args = SCM_CDR (form);
- SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
- return scm_list_2 (tmp, iqq (SCM_CAR (args), env, depth + 1));
- }
- else if (SCM_EQ_P (tmp, scm_sym_unquote))
- {
- SCM args = SCM_CDR (form);
- SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
- if (depth - 1 == 0)
- return scm_eval_car (args, env);
- else
- return scm_list_2 (tmp, iqq (SCM_CAR (args), env, depth - 1));
- }
- else if (SCM_CONSP (tmp)
- && SCM_EQ_P (SCM_CAR (tmp), scm_sym_uq_splicing))
- {
- SCM args = SCM_CDR (tmp);
- SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
- if (depth - 1 == 0)
- {
- SCM list = scm_eval_car (args, env);
- SCM rest = SCM_CDR (form);
- SCM_ASSYNT (scm_ilength (list) >= 0, s_splicing, s_quasiquote);
- return scm_append (scm_list_2 (list, iqq (rest, env, depth)));
- }
- else
- return scm_cons (iqq (SCM_CAR (form), env, depth - 1),
- iqq (SCM_CDR (form), env, depth));
- }
- else
- return scm_cons (iqq (SCM_CAR (form), env, depth),
- iqq (SCM_CDR (form), env, depth));
- }
- else if (SCM_VECTORP (form))
- {
- size_t i = SCM_VECTOR_LENGTH (form);
- SCM *data = SCM_VELTS (form);
- SCM tmp = SCM_EOL;
- while (i != 0)
- tmp = scm_cons (data[--i], tmp);
- scm_remember_upto_here_1 (form);
- return scm_vector (iqq (tmp, env, depth));
+ if (SCM_EQ_P (SCM_CAR (list), obj))
+ return 1;
}
- else
- return form;
-}
-
-SCM
-scm_m_quasiquote (SCM xorig, SCM env)
-{
- SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (scm_ilength (x) == 1, scm_s_expression, s_quasiquote);
- return iqq (SCM_CAR (x), env, 1);
+ return SCM_EQ_P (list, obj);
}
-
-SCM_SYNTAX (s_delay, "delay", scm_makmmacro, scm_m_delay);
-SCM_GLOBAL_SYMBOL (scm_sym_delay, s_delay);
-
-/* Promises are implemented as closures with an empty parameter list. Thus,
- * (delay <expression>) is transformed into (#@delay '() <expression>), where
- * the empty list represents the empty parameter list. This representation
- * allows for easy creation of the closure during evaluation. */
SCM
-scm_m_delay (SCM xorig, SCM env SCM_UNUSED)
+scm_m_lambda (SCM xorig, SCM env SCM_UNUSED)
{
- SCM_ASSYNT (scm_ilength (xorig) == 2, scm_s_expression, s_delay);
- return scm_cons2 (SCM_IM_DELAY, SCM_EOL, SCM_CDR (xorig));
-}
-
+ SCM formals;
+ SCM x = SCM_CDR (xorig);
-SCM_SYNTAX(s_define, "define", scm_makmmacro, scm_m_define);
-SCM_GLOBAL_SYMBOL(scm_sym_define, s_define);
+ SCM_ASSYNT (SCM_CONSP (x), scm_s_formals, s_lambda);
-/* Guile provides an extension to R5RS' define syntax to represent function
- * currying in a compact way. With this extension, it is allowed to write
- * (define <nested-variable> <body>), where <nested-variable> has of one of
- * the forms (<nested-variable> <formals>), (<nested-variable> . <formal>),
- * (<variable> <formals>) or (<variable> . <formal>). As in R5RS, <formals>
- * should be either a sequence of zero or more variables, or a sequence of one
- * or more variables followed by a space-delimited period and another
- * variable. Each level of argument nesting wraps the <body> within another
- * lambda expression. For example, the following forms are allowed, each one
- * followed by an equivalent, more explicit implementation.
- * Example 1:
- * (define ((a b . c) . d) <body>) is equivalent to
- * (define a (lambda (b . c) (lambda d <body>)))
- * Example 2:
- * (define (((a) b) c . d) <body>) is equivalent to
- * (define a (lambda () (lambda (b) (lambda (c . d) <body>))))
- */
-/* Dirk:FIXME:: We should provide an implementation for 'define' in the R5RS
- * module that does not implement this extension. */
-SCM
-scm_m_define (SCM x, SCM env)
-{
- SCM name;
- x = SCM_CDR (x);
- SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_expression, s_define);
- name = SCM_CAR (x);
- x = SCM_CDR (x);
- while (SCM_CONSP (name))
- {
- /* This while loop realizes function currying by variable nesting. */
- SCM formals = SCM_CDR (name);
- x = scm_list_1 (scm_cons2 (scm_sym_lambda, formals, x));
- name = SCM_CAR (name);
- }
- SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_variable, s_define);
- SCM_ASSYNT (scm_ilength (x) == 1, scm_s_expression, s_define);
- if (SCM_TOP_LEVEL (env))
+ formals = SCM_CAR (x);
+ while (SCM_CONSP (formals))
{
- SCM var;
- x = scm_eval_car (x, env);
- if (SCM_REC_PROCNAMES_P)
- {
- SCM tmp = x;
- while (SCM_MACROP (tmp))
- tmp = SCM_MACRO_CODE (tmp);
- if (SCM_CLOSUREP (tmp)
- /* Only the first definition determines the name. */
- && SCM_FALSEP (scm_procedure_property (tmp, scm_sym_name)))
- scm_set_procedure_property_x (tmp, scm_sym_name, name);
- }
- var = scm_sym2var (name, scm_env_top_level (env), SCM_BOOL_T);
- SCM_VARIABLE_SET (var, x);
- return SCM_UNSPECIFIED;
+ SCM formal = SCM_CAR (formals);
+ SCM_ASSYNT (SCM_SYMBOLP (formal), scm_s_formals, s_lambda);
+ if (scm_c_improper_memq (formal, SCM_CDR (formals)))
+ scm_misc_error (s_lambda, scm_s_duplicate_formals, SCM_EOL);
+ formals = SCM_CDR (formals);
}
- else
- return scm_cons2 (SCM_IM_DEFINE, name, x);
+ if (!SCM_NULLP (formals) && !SCM_SYMBOLP (formals))
+ scm_misc_error (s_lambda, scm_s_formals, SCM_EOL);
+
+ return scm_cons2 (SCM_IM_LAMBDA, SCM_CAR (x),
+ scm_m_body (SCM_IM_LAMBDA, SCM_CDR (x), s_lambda));
}
}
-SCM_SYNTAX(s_letrec, "letrec", scm_makmmacro, scm_m_letrec);
-SCM_GLOBAL_SYMBOL(scm_sym_letrec, s_letrec);
-
-SCM
-scm_m_letrec (SCM xorig, SCM env)
-{
- SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letrec);
-
- if (SCM_NULLP (SCM_CAR (x)))
- {
- /* null binding, let* faster */
- SCM body = scm_m_body (SCM_IM_LETREC, SCM_CDR (x), s_letrec);
- return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), SCM_EOL, body), env);
- }
- else
- {
- SCM rvars, inits, body;
- transform_bindings (SCM_CAR (x), &rvars, &inits, "letrec");
- body = scm_m_body (SCM_IM_LETREC, SCM_CDR (x), "letrec");
- return scm_cons2 (SCM_IM_LETREC, rvars, scm_cons (inits, body));
- }
-}
-
-
SCM_SYNTAX(s_let, "let", scm_makmmacro, scm_m_let);
SCM_GLOBAL_SYMBOL(scm_sym_let, s_let);
}
-SCM_SYNTAX (s_atapply,"@apply", scm_makmmacro, scm_m_apply);
+SCM_SYNTAX (s_letstar, "let*", scm_makmmacro, scm_m_letstar);
+SCM_GLOBAL_SYMBOL (scm_sym_letstar, s_letstar);
+
+/* (let* ((v1 i1) (v2 i2) ...) body) with variables v1 .. vk and initializers
+ * i1 .. ik is transformed into the form (#@let* (v1 i1 v2 i2 ...) body*). */
+SCM
+scm_m_letstar (SCM xorig, SCM env SCM_UNUSED)
+{
+ SCM bindings;
+ SCM x = SCM_CDR (xorig);
+ SCM vars = SCM_EOL;
+ SCM *varloc = &vars;
+
+ SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letstar);
+
+ bindings = SCM_CAR (x);
+ SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_letstar);
+ while (!SCM_NULLP (bindings))
+ {
+ SCM binding = SCM_CAR (bindings);
+ SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, s_letstar);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, s_letstar);
+ *varloc = scm_list_2 (SCM_CAR (binding), SCM_CADR (binding));
+ varloc = SCM_CDRLOC (SCM_CDR (*varloc));
+ bindings = SCM_CDR (bindings);
+ }
+
+ return scm_cons2 (SCM_IM_LETSTAR, vars,
+ scm_m_body (SCM_IM_LETSTAR, SCM_CDR (x), s_letstar));
+}
+
+
+SCM_SYNTAX(s_letrec, "letrec", scm_makmmacro, scm_m_letrec);
+SCM_GLOBAL_SYMBOL(scm_sym_letrec, s_letrec);
+
+SCM
+scm_m_letrec (SCM xorig, SCM env)
+{
+ SCM x = SCM_CDR (xorig);
+ SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letrec);
+
+ if (SCM_NULLP (SCM_CAR (x)))
+ {
+ /* null binding, let* faster */
+ SCM body = scm_m_body (SCM_IM_LETREC, SCM_CDR (x), s_letrec);
+ return scm_m_letstar (scm_cons2 (SCM_CAR (xorig), SCM_EOL, body), env);
+ }
+ else
+ {
+ SCM rvars, inits, body;
+ transform_bindings (SCM_CAR (x), &rvars, &inits, "letrec");
+ body = scm_m_body (SCM_IM_LETREC, SCM_CDR (x), "letrec");
+ return scm_cons2 (SCM_IM_LETREC, rvars, scm_cons (inits, body));
+ }
+}
+
+
+SCM_SYNTAX (s_or, "or", scm_makmmacro, scm_m_or);
+SCM_GLOBAL_SYMBOL (scm_sym_or, s_or);
+
+SCM
+scm_m_or (SCM xorig, SCM env SCM_UNUSED)
+{
+ long len = scm_ilength (SCM_CDR (xorig));
+ SCM_ASSYNT (len >= 0, scm_s_test, s_or);
+ if (len >= 1)
+ return scm_cons (SCM_IM_OR, SCM_CDR (xorig));
+ else
+ return SCM_BOOL_F;
+}
+
+
+SCM_SYNTAX (s_quasiquote, "quasiquote", scm_makacro, scm_m_quasiquote);
+SCM_GLOBAL_SYMBOL (scm_sym_quasiquote, s_quasiquote);
+
+/* Internal function to handle a quasiquotation: 'form' is the parameter in
+ * the call (quasiquotation form), 'env' is the environment where unquoted
+ * expressions will be evaluated, and 'depth' is the current quasiquotation
+ * nesting level and is known to be greater than zero. */
+static SCM
+iqq (SCM form, SCM env, unsigned long int depth)
+{
+ if (SCM_CONSP (form))
+ {
+ SCM tmp = SCM_CAR (form);
+ if (SCM_EQ_P (tmp, scm_sym_quasiquote))
+ {
+ SCM args = SCM_CDR (form);
+ SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
+ return scm_list_2 (tmp, iqq (SCM_CAR (args), env, depth + 1));
+ }
+ else if (SCM_EQ_P (tmp, scm_sym_unquote))
+ {
+ SCM args = SCM_CDR (form);
+ SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
+ if (depth - 1 == 0)
+ return scm_eval_car (args, env);
+ else
+ return scm_list_2 (tmp, iqq (SCM_CAR (args), env, depth - 1));
+ }
+ else if (SCM_CONSP (tmp)
+ && SCM_EQ_P (SCM_CAR (tmp), scm_sym_uq_splicing))
+ {
+ SCM args = SCM_CDR (tmp);
+ SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
+ if (depth - 1 == 0)
+ {
+ SCM list = scm_eval_car (args, env);
+ SCM rest = SCM_CDR (form);
+ SCM_ASSYNT (scm_ilength (list) >= 0, s_splicing, s_quasiquote);
+ return scm_append (scm_list_2 (list, iqq (rest, env, depth)));
+ }
+ else
+ return scm_cons (iqq (SCM_CAR (form), env, depth - 1),
+ iqq (SCM_CDR (form), env, depth));
+ }
+ else
+ return scm_cons (iqq (SCM_CAR (form), env, depth),
+ iqq (SCM_CDR (form), env, depth));
+ }
+ else if (SCM_VECTORP (form))
+ {
+ size_t i = SCM_VECTOR_LENGTH (form);
+ SCM const *const data = SCM_VELTS (form);
+ SCM tmp = SCM_EOL;
+ while (i != 0)
+ tmp = scm_cons (data[--i], tmp);
+ scm_remember_upto_here_1 (form);
+ return scm_vector (iqq (tmp, env, depth));
+ }
+ else
+ return form;
+}
+
+SCM
+scm_m_quasiquote (SCM xorig, SCM env)
+{
+ SCM x = SCM_CDR (xorig);
+ SCM_ASSYNT (scm_ilength (x) == 1, scm_s_expression, s_quasiquote);
+ return iqq (SCM_CAR (x), env, 1);
+}
+
+
+SCM_SYNTAX (s_quote, "quote", scm_makmmacro, scm_m_quote);
+SCM_GLOBAL_SYMBOL (scm_sym_quote, s_quote);
+
+SCM
+scm_m_quote (SCM xorig, SCM env SCM_UNUSED)
+{
+ SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 1, scm_s_expression, s_quote);
+ return scm_cons (SCM_IM_QUOTE, SCM_CDR (xorig));
+}
+
+
+/* Will go into the RnRS module when Guile is factorized.
+SCM_SYNTAX (s_set_x, "set!", scm_makmmacro, scm_m_set_x); */
+static const char s_set_x[] = "set!";
+SCM_GLOBAL_SYMBOL (scm_sym_set_x, s_set_x);
+
+SCM
+scm_m_set_x (SCM xorig, SCM env SCM_UNUSED)
+{
+ SCM x = SCM_CDR (xorig);
+ SCM_ASSYNT (scm_ilength (x) == 2, scm_s_expression, s_set_x);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (x)), scm_s_variable, s_set_x);
+ return scm_cons (SCM_IM_SET_X, x);
+}
+
+
+/* Start of the memoizers for non-R5RS builtin macros. */
+
+
+SCM_SYNTAX (s_atapply, "@apply", scm_makmmacro, scm_m_apply);
SCM_GLOBAL_SYMBOL (scm_sym_atapply, s_atapply);
SCM_GLOBAL_SYMBOL (scm_sym_apply, s_atapply + 1);
}
-SCM_SYNTAX(s_atcall_cc,"@call-with-current-continuation", scm_makmmacro, scm_m_cont);
-SCM_GLOBAL_SYMBOL(scm_sym_atcall_cc,s_atcall_cc);
+/* (@bind ((var exp) ...) body ...)
+
+ This will assign the values of the `exp's to the global variables
+ named by `var's (symbols, not evaluated), creating them if they
+ don't exist, executes body, and then restores the previous values of
+ the `var's. Additionally, whenever control leaves body, the values
+ of the `var's are saved and restored when control returns. It is an
+ error when a symbol appears more than once among the `var's.
+ All `exp's are evaluated before any `var' is set.
+
+ Think of this as `let' for dynamic scope.
+
+ It is memoized into (#@bind ((var ...) . (reversed-val ...)) body ...).
+
+ XXX - also implement `@bind*'.
+*/
+
+SCM_SYNTAX (s_atbind, "@bind", scm_makmmacro, scm_m_atbind);
+
+SCM
+scm_m_atbind (SCM xorig, SCM env)
+{
+ SCM x = SCM_CDR (xorig);
+ SCM top_level = scm_env_top_level (env);
+ SCM vars = SCM_EOL, var;
+ SCM exps = SCM_EOL;
+
+ SCM_ASSYNT (scm_ilength (x) > 1, scm_s_expression, s_atbind);
+
+ x = SCM_CAR (x);
+ while (SCM_NIMP (x))
+ {
+ SCM rest;
+ SCM sym_exp = SCM_CAR (x);
+ SCM_ASSYNT (scm_ilength (sym_exp) == 2, scm_s_bindings, s_atbind);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (sym_exp)), scm_s_bindings, s_atbind);
+ x = SCM_CDR (x);
+ for (rest = x; SCM_NIMP (rest); rest = SCM_CDR (rest))
+ if (SCM_EQ_P (SCM_CAR (sym_exp), SCM_CAAR (rest)))
+ scm_misc_error (s_atbind, scm_s_duplicate_bindings, SCM_EOL);
+ /* The first call to scm_sym2var will look beyond the current
+ module, while the second call wont. */
+ var = scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_F);
+ if (SCM_FALSEP (var))
+ var = scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_T);
+ vars = scm_cons (var, vars);
+ exps = scm_cons (SCM_CADR (sym_exp), exps);
+ }
+ return scm_cons (SCM_IM_BIND,
+ scm_cons (scm_cons (scm_reverse_x (vars, SCM_EOL), exps),
+ SCM_CDDR (xorig)));
+}
+
+
+SCM_SYNTAX(s_atcall_cc, "@call-with-current-continuation", scm_makmmacro, scm_m_cont);
+SCM_GLOBAL_SYMBOL(scm_sym_atcall_cc, s_atcall_cc);
SCM
return scm_cons (SCM_IM_CONT, SCM_CDR (xorig));
}
-#ifdef SCM_ENABLE_ELISP
+
+SCM_SYNTAX (s_at_call_with_values, "@call-with-values", scm_makmmacro, scm_m_at_call_with_values);
+SCM_GLOBAL_SYMBOL(scm_sym_at_call_with_values, s_at_call_with_values);
+
+SCM
+scm_m_at_call_with_values (SCM xorig, SCM env SCM_UNUSED)
+{
+ SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 2,
+ scm_s_expression, s_at_call_with_values);
+ return scm_cons (SCM_IM_CALL_WITH_VALUES, SCM_CDR (xorig));
+}
+
+
+SCM_SYNTAX (s_future, "future", scm_makmmacro, scm_m_future);
+SCM_GLOBAL_SYMBOL (scm_sym_future, s_future);
+
+/* Like promises, futures are implemented as closures with an empty
+ * parameter list. Thus, (future <expression>) is transformed into
+ * (#@future '() <expression>), where the empty list represents the
+ * empty parameter list. This representation allows for easy creation
+ * of the closure during evaluation. */
+SCM
+scm_m_future (SCM xorig, SCM env SCM_UNUSED)
+{
+ SCM_ASSYNT (scm_ilength (xorig) == 2, scm_s_expression, s_future);
+ return scm_cons2 (SCM_IM_FUTURE, SCM_EOL, SCM_CDR (xorig));
+}
+
+
+SCM_SYNTAX (s_gset_x, "set!", scm_makmmacro, scm_m_generalized_set_x);
+SCM_SYMBOL (scm_sym_setter, "setter");
+
+SCM
+scm_m_generalized_set_x (SCM xorig, SCM env SCM_UNUSED)
+{
+ SCM x = SCM_CDR (xorig);
+ SCM_ASSYNT (2 == scm_ilength (x), scm_s_expression, 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_list_2 (scm_sym_setter, SCM_CAAR (x)),
+ scm_append (scm_list_2 (SCM_CDAR (x), SCM_CDR (x))));
+ else
+ scm_misc_error (s_set_x, scm_s_variable, SCM_EOL);
+}
+
+
+static const char* s_atslot_ref = "@slot-ref";
+
+/* @slot-ref is bound privately in the (oop goops) module from goops.c. As
+ * soon as the module system allows us to more freely create bindings in
+ * arbitrary modules during the startup phase, the code from goops.c should be
+ * moved here. */
+SCM
+scm_m_atslot_ref (SCM xorig, SCM env SCM_UNUSED)
+#define FUNC_NAME s_atslot_ref
+{
+ SCM x = SCM_CDR (xorig);
+ SCM_ASSYNT (scm_ilength (x) == 2, scm_s_expression, FUNC_NAME);
+ SCM_VALIDATE_INUM (SCM_ARG2, SCM_CADR (x));
+ return scm_cons (SCM_IM_SLOT_REF, x);
+}
+#undef FUNC_NAME
+
+
+static const char* s_atslot_set_x = "@slot-set!";
+
+/* @slot-set! is bound privately in the (oop goops) module from goops.c. As
+ * soon as the module system allows us to more freely create bindings in
+ * arbitrary modules during the startup phase, the code from goops.c should be
+ * moved here. */
+SCM
+scm_m_atslot_set_x (SCM xorig, SCM env SCM_UNUSED)
+#define FUNC_NAME s_atslot_set_x
+{
+ SCM x = SCM_CDR (xorig);
+ SCM_ASSYNT (scm_ilength (x) == 3, scm_s_expression, FUNC_NAME);
+ SCM_VALIDATE_INUM (SCM_ARG2, SCM_CADR (x));
+ return scm_cons (SCM_IM_SLOT_SET_X, x);
+}
+#undef FUNC_NAME
+
+
+#if SCM_ENABLE_ELISP
SCM_SYNTAX (s_nil_cond, "nil-cond", scm_makmmacro, scm_m_nil_cond);
return scm_cons (SCM_IM_NIL_COND, SCM_CDR (xorig));
}
+
SCM_SYNTAX (s_atfop, "@fop", scm_makmmacro, scm_m_atfop);
SCM
#endif /* SCM_ENABLE_ELISP */
-/* (@bind ((var exp) ...) body ...)
-
- This will assign the values of the `exp's to the global variables
- named by `var's (symbols, not evaluated), creating them if they
- don't exist, executes body, and then restores the previous values of
- the `var's. Additionally, whenever control leaves body, the values
- of the `var's are saved and restored when control returns. It is an
- error when a symbol appears more than once among the `var's.
- All `exp's are evaluated before any `var' is set.
-
- Think of this as `let' for dynamic scope.
-
- It is memoized into (#@bind ((var ...) . (reversed-val ...)) body ...).
-
- XXX - also implement `@bind*'.
-*/
-
-SCM_SYNTAX (s_atbind, "@bind", scm_makmmacro, scm_m_atbind);
-
-SCM
-scm_m_atbind (SCM xorig, SCM env)
-{
- SCM x = SCM_CDR (xorig);
- SCM top_level = scm_env_top_level (env);
- SCM vars = SCM_EOL, var;
- SCM exps = SCM_EOL;
-
- SCM_ASSYNT (scm_ilength (x) > 1, scm_s_expression, s_atbind);
-
- x = SCM_CAR (x);
- while (SCM_NIMP (x))
- {
- SCM rest;
- SCM sym_exp = SCM_CAR (x);
- SCM_ASSYNT (scm_ilength (sym_exp) == 2, scm_s_bindings, s_atbind);
- SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (sym_exp)), scm_s_bindings, s_atbind);
- x = SCM_CDR (x);
- for (rest = x; SCM_NIMP (rest); rest = SCM_CDR (rest))
- if (SCM_EQ_P (SCM_CAR (sym_exp), SCM_CAAR (rest)))
- scm_misc_error (s_atbind, scm_s_duplicate_bindings, SCM_EOL);
- /* The first call to scm_sym2var will look beyond the current
- module, while the second call wont. */
- var = scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_F);
- if (SCM_FALSEP (var))
- var = scm_sym2var (SCM_CAR (sym_exp), top_level, SCM_BOOL_T);
- vars = scm_cons (var, vars);
- exps = scm_cons (SCM_CADR (sym_exp), exps);
- }
- return scm_cons (SCM_IM_BIND,
- scm_cons (scm_cons (scm_reverse_x (vars, SCM_EOL), exps),
- SCM_CDDR (xorig)));
-}
-
-SCM_SYNTAX (s_at_call_with_values, "@call-with-values", scm_makmmacro, scm_m_at_call_with_values);
-SCM_GLOBAL_SYMBOL(scm_sym_at_call_with_values, s_at_call_with_values);
-
-SCM
-scm_m_at_call_with_values (SCM xorig, SCM env SCM_UNUSED)
-{
- SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 2,
- scm_s_expression, s_at_call_with_values);
- return scm_cons (SCM_IM_CALL_WITH_VALUES, SCM_CDR (xorig));
-}
SCM
scm_m_expand_body (SCM xorig, SCM env)
if (!SCM_SYMBOLP (orig_sym))
return x;
-#ifdef USE_THREADS
{
SCM *proc_ptr = scm_lookupcar1 (x, env, 0);
if (proc_ptr == NULL)
}
proc = *proc_ptr;
}
-#else
- proc = *scm_lookupcar (x, env, 0);
-#endif
/* Only handle memoizing macros. `Acros' and `macros' are really
special forms and should not be evaluated here. */
goto macro_tail;
}
+#define SCM_BIT7(x) (127 & SCM_UNPACK (x))
+
+/* A function object to implement "apply" for non-closure functions. */
+static SCM f_apply;
+/* An endless list consisting of #<undefined> objects: */
+static SCM undefineds;
+
/* scm_unmemocopy takes a memoized expression together with its
* environment and rewrites it to its original form. Thus, it is the
* inversion of the rewrite rules above. The procedure is not
* This ought to change.
*/
-#define SCM_BIT8(x) (127 & SCM_UNPACK (x))
-
static SCM
build_binding_list (SCM names, SCM inits)
{
unmemocopy (SCM x, SCM env)
{
SCM ls, z;
-#ifdef DEBUG_EXTENSIONS
SCM p;
-#endif
if (!SCM_CONSP (x))
return x;
-#ifdef DEBUG_EXTENSIONS
p = scm_whash_lookup (scm_source_whash, x);
-#endif
switch (SCM_ITAG7 (SCM_CAR (x)))
{
- case SCM_BIT8(SCM_IM_AND):
+ case SCM_BIT7 (SCM_IM_AND):
ls = z = scm_cons (scm_sym_and, SCM_UNSPECIFIED);
break;
- case SCM_BIT8(SCM_IM_BEGIN):
+ case SCM_BIT7 (SCM_IM_BEGIN):
ls = z = scm_cons (scm_sym_begin, SCM_UNSPECIFIED);
break;
- case SCM_BIT8(SCM_IM_CASE):
+ case SCM_BIT7 (SCM_IM_CASE):
ls = z = scm_cons (scm_sym_case, SCM_UNSPECIFIED);
break;
- case SCM_BIT8(SCM_IM_COND):
+ case SCM_BIT7 (SCM_IM_COND):
ls = z = scm_cons (scm_sym_cond, SCM_UNSPECIFIED);
break;
- case SCM_BIT8 (SCM_IM_DO):
+ case SCM_BIT7 (SCM_IM_DO):
{
/* format: (#@do (nk nk-1 ...) (i1 ... ik) (test) (body) s1 ... sk),
* where nx is the name of a local variable, ix is an initializer for
names = SCM_CAR (x);
x = SCM_CDR (x);
inits = scm_reverse (unmemocopy (SCM_CAR (x), env));
- env = EXTEND_ENV (names, SCM_EOL, env);
+ env = SCM_EXTEND_ENV (names, SCM_EOL, env);
x = SCM_CDR (x);
test = unmemocopy (SCM_CAR (x), env);
x = SCM_CDR (x);
x = scm_cons (SCM_BOOL_F, memoized_body);
break;
}
- case SCM_BIT8(SCM_IM_IF):
+ case SCM_BIT7 (SCM_IM_IF):
ls = z = scm_cons (scm_sym_if, SCM_UNSPECIFIED);
break;
- case SCM_BIT8 (SCM_IM_LET):
+ case SCM_BIT7 (SCM_IM_LET):
{
/* format: (#@let (nk nk-1 ...) (i1 ... ik) b1 ...),
* where nx is the name of a local variable, ix is an initializer for
names = SCM_CAR (x);
x = SCM_CDR (x);
inits = scm_reverse (unmemocopy (SCM_CAR (x), env));
- env = EXTEND_ENV (names, SCM_EOL, env);
+ env = SCM_EXTEND_ENV (names, SCM_EOL, env);
bindings = build_binding_list (names, inits);
z = scm_cons (bindings, SCM_UNSPECIFIED);
ls = scm_cons (scm_sym_let, z);
break;
}
- case SCM_BIT8 (SCM_IM_LETREC):
+ case SCM_BIT7 (SCM_IM_LETREC):
{
/* format: (#@letrec (nk nk-1 ...) (i1 ... ik) b1 ...),
* where nx is the name of a local variable, ix is an initializer for
x = SCM_CDR (x);
names = SCM_CAR (x);
- env = EXTEND_ENV (names, SCM_EOL, env);
+ env = SCM_EXTEND_ENV (names, SCM_EOL, env);
x = SCM_CDR (x);
inits = scm_reverse (unmemocopy (SCM_CAR (x), env));
ls = scm_cons (scm_sym_letrec, z);
break;
}
- case SCM_BIT8(SCM_IM_LETSTAR):
+ case SCM_BIT7 (SCM_IM_LETSTAR):
{
SCM b, y;
x = SCM_CDR (x);
y = SCM_EOL;
if SCM_IMP (b)
{
- env = EXTEND_ENV (SCM_EOL, SCM_EOL, env);
+ env = SCM_EXTEND_ENV (SCM_EOL, SCM_EOL, env);
goto letstar;
}
y = z = scm_acons (SCM_CAR (b),
unmemocar (
scm_cons (unmemocopy (SCM_CADR (b), env), SCM_EOL), env),
SCM_UNSPECIFIED);
- env = EXTEND_ENV (SCM_CAR (b), SCM_BOOL_F, env);
+ env = SCM_EXTEND_ENV (SCM_CAR (b), SCM_BOOL_F, env);
b = SCM_CDDR (b);
if (SCM_IMP (b))
{
SCM_SETCDR (y, SCM_EOL);
- ls = scm_cons (scm_sym_let, z = scm_cons (y, SCM_UNSPECIFIED));
+ z = scm_cons (y, SCM_UNSPECIFIED);
+ ls = scm_cons (scm_sym_let, z);
break;
}
do
scm_list_1 (unmemocopy (SCM_CADR (b), env)), env),
SCM_UNSPECIFIED));
z = SCM_CDR (z);
- env = EXTEND_ENV (SCM_CAR (b), SCM_BOOL_F, env);
+ env = SCM_EXTEND_ENV (SCM_CAR (b), SCM_BOOL_F, env);
b = SCM_CDDR (b);
}
while (SCM_NIMP (b));
SCM_SETCDR (z, SCM_EOL);
letstar:
- ls = scm_cons (scm_sym_letstar, z = scm_cons (y, SCM_UNSPECIFIED));
+ z = scm_cons (y, SCM_UNSPECIFIED);
+ ls = scm_cons (scm_sym_letstar, z);
break;
}
- case SCM_BIT8(SCM_IM_OR):
+ case SCM_BIT7 (SCM_IM_OR):
ls = z = scm_cons (scm_sym_or, SCM_UNSPECIFIED);
break;
- case SCM_BIT8(SCM_IM_LAMBDA):
+ case SCM_BIT7 (SCM_IM_LAMBDA):
x = SCM_CDR (x);
z = scm_cons (SCM_CAR (x), SCM_UNSPECIFIED);
ls = scm_cons (scm_sym_lambda, z);
- env = EXTEND_ENV (SCM_CAR (x), SCM_EOL, env);
+ env = SCM_EXTEND_ENV (SCM_CAR (x), SCM_EOL, env);
break;
- case SCM_BIT8(SCM_IM_QUOTE):
+ case SCM_BIT7 (SCM_IM_QUOTE):
ls = z = scm_cons (scm_sym_quote, SCM_UNSPECIFIED);
break;
- case SCM_BIT8(SCM_IM_SET_X):
+ case SCM_BIT7 (SCM_IM_SET_X):
ls = z = scm_cons (scm_sym_set_x, SCM_UNSPECIFIED);
break;
- case SCM_BIT8(SCM_IM_DEFINE):
+ case SCM_BIT7 (SCM_IM_DEFINE):
{
SCM n;
x = SCM_CDR (x);
z = scm_cons (n, SCM_UNSPECIFIED);
ls = scm_cons (scm_sym_define, z);
if (!SCM_NULLP (env))
- SCM_SETCAR (SCM_CAR (env), scm_cons (n, SCM_CAAR (env)));
+ env = scm_cons (scm_cons (scm_cons (n, SCM_CAAR (env)),
+ SCM_CDAR (env)),
+ SCM_CDR (env));
break;
}
- case SCM_BIT8(SCM_MAKISYM (0)):
+ case SCM_BIT7 (SCM_MAKISYM (0)):
z = SCM_CAR (x);
if (!SCM_ISYMP (z))
goto unmemo;
ls = z = scm_cons (scm_sym_delay, SCM_UNSPECIFIED);
x = SCM_CDR (x);
goto loop;
+ case (SCM_ISYMNUM (SCM_IM_FUTURE)):
+ ls = z = scm_cons (scm_sym_future, SCM_UNSPECIFIED);
+ x = SCM_CDR (x);
+ goto loop;
case (SCM_ISYMNUM (SCM_IM_CALL_WITH_VALUES)):
ls = z = scm_cons (scm_sym_at_call_with_values, SCM_UNSPECIFIED);
goto loop;
x = SCM_CDR (x);
}
SCM_SETCDR (z, x);
-#ifdef DEBUG_EXTENSIONS
if (!SCM_FALSEP (p))
scm_whash_insert (scm_source_whash, ls, p);
-#endif
return ls;
}
return unmemocopy (x, env);
}
-#ifndef SCM_RECKLESS
int
scm_badargsp (SCM formals, SCM args)
return !SCM_NULLP (args) ? 1 : 0;
}
-#endif
static int
scm_badformalsp (SCM closure, int n)
lloc = SCM_CDRLOC (*lloc);
l = SCM_CDR (l);
}
-#ifdef SCM_CAUTIOUS
if (!SCM_NULLP (l))
scm_wrong_num_args (proc);
-#endif
return results;
}
+
SCM
scm_eval_body (SCM code, SCM env)
{
{
if (SCM_ISYMP (SCM_CAR (code)))
{
- code = scm_m_expand_body (code, env);
+ scm_rec_mutex_lock (&source_mutex);
+ /* check for race condition */
+ if (SCM_ISYMP (SCM_CAR (code)))
+ code = scm_m_expand_body (code, env);
+ scm_rec_mutex_unlock (&source_mutex);
goto again;
}
}
return SCM_XEVALCAR (code, env);
}
-
#endif /* !DEVAL */
#define ENTER_APPLY \
do { \
SCM_SET_ARGSREADY (debug);\
- if (CHECK_APPLY && SCM_TRAPS_P)\
+ if (scm_check_apply_p && SCM_TRAPS_P)\
if (SCM_APPLY_FRAME_P || (SCM_TRACE_P && PROCTRACEP (proc)))\
{\
SCM tmp, tail = SCM_BOOL(SCM_TRACED_FRAME_P (debug)); \
* any stack swaps.
*/
-#ifndef USE_THREADS
-scm_t_debug_frame *scm_last_debug_frame;
-#endif
-
/* scm_debug_eframe_size is the number of slots available for pseudo
* stack frames at each real stack frame.
*/
(SCM setting),
"Option interface for the evaluation options. Instead of using\n"
"this procedure directly, use the procedures @code{eval-enable},\n"
- "@code{eval-disable}, @code{eval-set!} and @var{eval-options}.")
+ "@code{eval-disable}, @code{eval-set!} and @code{eval-options}.")
#define FUNC_NAME s_scm_eval_options_interface
{
SCM ans;
}
#undef FUNC_NAME
+
SCM_DEFINE (scm_evaluator_traps, "evaluator-traps-interface", 0, 1, 0,
(SCM setting),
"Option interface for the evaluator trap options.")
}
#undef FUNC_NAME
+
static SCM
deval_args (SCM l, SCM env, SCM proc, SCM *lloc)
{
lloc = SCM_CDRLOC (*lloc);
l = SCM_CDR (l);
}
-#ifdef SCM_CAUTIOUS
if (!SCM_NULLP (l))
scm_wrong_num_args (proc);
-#endif
return *results;
}
#define UPDATE_TOPLEVEL_ENV(env) \
do { \
SCM p = scm_current_module_lookup_closure (); \
- if (p != SCM_CAR(env)) \
+ if (p != SCM_CAR (env)) \
env = scm_top_level_env (p); \
} while (0)
SCM
SCM_CEVAL (SCM x, SCM env)
{
- union
- {
- SCM *lloc;
- SCM arg1;
- } t;
- SCM proc, arg2, orig_sym;
+ SCM proc, arg1;
#ifdef DEVAL
scm_t_debug_frame debug;
scm_t_debug_info *debug_info_end;
goto start;
#endif
-loopnoap:
- PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
loop:
#ifdef DEVAL
SCM_CLEAR_ARGSREADY (debug);
*
* For this to be the case, however, it is necessary that primitive
* special forms which jump back to `loop', `begin' or some similar
- * label call PREP_APPLY. A convenient way to do this is to jump to
- * `loopnoap' or `cdrxnoap'.
+ * label call PREP_APPLY.
*/
else if (++debug.info >= debug_info_end)
{
start:
debug.info->e.exp = x;
debug.info->e.env = env;
- if (CHECK_ENTRY && SCM_TRAPS_P)
- if (SCM_ENTER_FRAME_P || (SCM_BREAKPOINTS_P && SRCBRKP (x)))
- {
- SCM tail = SCM_BOOL(SCM_TAILRECP (debug));
- SCM_SET_TAILREC (debug);
- if (SCM_CHEAPTRAPS_P)
- t.arg1 = scm_make_debugobj (&debug);
- else
- {
- int first;
- SCM val = scm_make_continuation (&first);
-
- if (first)
- t.arg1 = val;
- else
- {
- x = val;
- if (SCM_IMP (x))
- RETURN (x);
- else
- /* This gives the possibility for the debugger to
- modify the source expression before evaluation. */
- goto dispatch;
- }
- }
- SCM_TRAPS_P = 0;
- scm_call_4 (SCM_ENTER_FRAME_HDLR,
- scm_sym_enter_frame,
- t.arg1,
- tail,
- scm_unmemocopy (x, env));
- SCM_TRAPS_P = 1;
- }
+ if (scm_check_entry_p && SCM_TRAPS_P)
+ {
+ if (SCM_ENTER_FRAME_P
+ || (SCM_BREAKPOINTS_P && scm_c_source_property_breakpoint_p (x)))
+ {
+ SCM stackrep;
+ SCM tail = SCM_BOOL (SCM_TAILRECP (debug));
+ SCM_SET_TAILREC (debug);
+ if (SCM_CHEAPTRAPS_P)
+ stackrep = scm_make_debugobj (&debug);
+ else
+ {
+ int first;
+ SCM val = scm_make_continuation (&first);
+
+ if (first)
+ stackrep = val;
+ else
+ {
+ x = val;
+ if (SCM_IMP (x))
+ RETURN (x);
+ else
+ /* This gives the possibility for the debugger to
+ modify the source expression before evaluation. */
+ goto dispatch;
+ }
+ }
+ SCM_TRAPS_P = 0;
+ scm_call_4 (SCM_ENTER_FRAME_HDLR,
+ scm_sym_enter_frame,
+ stackrep,
+ tail,
+ scm_unmemocopy (x, env));
+ SCM_TRAPS_P = 1;
+ }
+ }
#endif
-#if defined (USE_THREADS) || defined (DEVAL)
dispatch:
-#endif
SCM_TICK;
switch (SCM_TYP7 (x))
{
x = scm_cons (x, SCM_UNDEFINED);
RETURN (*scm_lookupcar (x, env, 1));
- case SCM_BIT8 (SCM_IM_AND):
+ case SCM_BIT7 (SCM_IM_AND):
x = SCM_CDR (x);
while (!SCM_NULLP (SCM_CDR (x)))
{
PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
goto carloop;
- case SCM_BIT8 (SCM_IM_BEGIN):
- if (SCM_NULLP (SCM_CDR (x)))
+ case SCM_BIT7 (SCM_IM_BEGIN):
+ x = SCM_CDR (x);
+ if (SCM_NULLP (x))
RETURN (SCM_UNSPECIFIED);
- /* (currently unused)
- cdrxnoap: */
PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
- /* (currently unused)
- cdrxbegin: */
- x = SCM_CDR (x);
begin:
/* If we are on toplevel with a lookup closure, we need to sync
else
goto nontoplevel_begin;
- nontoplevel_cdrxnoap:
- PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
- x = SCM_CDR (x);
nontoplevel_begin:
while (!SCM_NULLP (SCM_CDR (x)))
{
{
if (SCM_ISYMP (form))
{
- x = scm_m_expand_body (x, env);
+ scm_rec_mutex_lock (&source_mutex);
+ /* check for race condition */
+ if (SCM_ISYMP (SCM_CAR (x)))
+ x = scm_m_expand_body (x, env);
+ scm_rec_mutex_unlock (&source_mutex);
goto nontoplevel_begin;
}
else
}
- case SCM_BIT8 (SCM_IM_CASE):
+ case SCM_BIT7 (SCM_IM_CASE):
x = SCM_CDR (x);
{
SCM key = EVALCAR (x, env);
RETURN (SCM_UNSPECIFIED);
- case SCM_BIT8 (SCM_IM_COND):
+ case SCM_BIT7 (SCM_IM_COND):
x = SCM_CDR (x);
while (!SCM_NULLP (x))
{
}
else
{
- t.arg1 = EVALCAR (clause, env);
- if (!SCM_FALSEP (t.arg1) && !SCM_NILP (t.arg1))
+ arg1 = EVALCAR (clause, env);
+ if (!SCM_FALSEP (arg1) && !SCM_NILP (arg1))
{
x = SCM_CDR (clause);
if (SCM_NULLP (x))
- RETURN (t.arg1);
+ RETURN (arg1);
else if (!SCM_EQ_P (SCM_CAR (x), scm_sym_arrow))
{
PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
proc = SCM_CDR (x);
proc = EVALCAR (proc, env);
SCM_ASRTGO (!SCM_IMP (proc), badfun);
- PREP_APPLY (proc, scm_list_1 (t.arg1));
+ PREP_APPLY (proc, scm_list_1 (arg1));
ENTER_APPLY;
if (SCM_CLOSUREP(proc) && scm_badformalsp (proc, 1))
goto umwrongnumargs;
RETURN (SCM_UNSPECIFIED);
- case SCM_BIT8 (SCM_IM_DO):
+ case SCM_BIT7 (SCM_IM_DO):
x = SCM_CDR (x);
{
/* Compute the initialization values and the initial environment. */
init_values = scm_cons (EVALCAR (init_forms, env), init_values);
init_forms = SCM_CDR (init_forms);
}
- env = EXTEND_ENV (SCM_CAR (x), init_values, env);
+ env = SCM_EXTEND_ENV (SCM_CAR (x), init_values, env);
}
x = SCM_CDDR (x);
{
SCM value = EVALCAR (temp_forms, env);
step_values = scm_cons (value, step_values);
}
- env = EXTEND_ENV (SCM_CAAR (env), step_values, SCM_CDR (env));
+ env = SCM_EXTEND_ENV (SCM_CAAR (env),
+ step_values,
+ SCM_CDR (env));
}
test_result = EVALCAR (test_form, env);
goto nontoplevel_begin;
- case SCM_BIT8 (SCM_IM_IF):
+ case SCM_BIT7 (SCM_IM_IF):
x = SCM_CDR (x);
{
SCM test_result = EVALCAR (x, env);
goto carloop;
- case SCM_BIT8 (SCM_IM_LET):
+ case SCM_BIT7 (SCM_IM_LET):
x = SCM_CDR (x);
{
SCM init_forms = SCM_CADR (x);
init_forms = SCM_CDR (init_forms);
}
while (!SCM_NULLP (init_forms));
- env = EXTEND_ENV (SCM_CAR (x), init_values, env);
+ env = SCM_EXTEND_ENV (SCM_CAR (x), init_values, env);
}
- x = SCM_CDR (x);
- goto nontoplevel_cdrxnoap;
+ x = SCM_CDDR (x);
+ PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
+ goto nontoplevel_begin;
- case SCM_BIT8 (SCM_IM_LETREC):
+ case SCM_BIT7 (SCM_IM_LETREC):
x = SCM_CDR (x);
- env = EXTEND_ENV (SCM_CAR (x), scm_undefineds, env);
+ env = SCM_EXTEND_ENV (SCM_CAR (x), undefineds, env);
x = SCM_CDR (x);
{
SCM init_forms = SCM_CAR (x);
while (!SCM_NULLP (init_forms));
SCM_SETCDR (SCM_CAR (env), init_values);
}
- goto nontoplevel_cdrxnoap;
+ x = SCM_CDR (x);
+ PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
+ goto nontoplevel_begin;
- case SCM_BIT8 (SCM_IM_LETSTAR):
+ case SCM_BIT7 (SCM_IM_LETSTAR):
x = SCM_CDR (x);
{
SCM bindings = SCM_CAR (x);
if (SCM_NULLP (bindings))
- env = EXTEND_ENV (SCM_EOL, SCM_EOL, env);
+ env = SCM_EXTEND_ENV (SCM_EOL, SCM_EOL, env);
else
{
do
{
SCM name = SCM_CAR (bindings);
SCM init = SCM_CDR (bindings);
- env = EXTEND_ENV (name, EVALCAR (init, env), env);
+ env = SCM_EXTEND_ENV (name, EVALCAR (init, env), env);
bindings = SCM_CDR (init);
}
while (!SCM_NULLP (bindings));
}
}
- goto nontoplevel_cdrxnoap;
+ x = SCM_CDR (x);
+ PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
+ goto nontoplevel_begin;
- case SCM_BIT8 (SCM_IM_OR):
+ case SCM_BIT7 (SCM_IM_OR):
x = SCM_CDR (x);
while (!SCM_NULLP (SCM_CDR (x)))
{
goto carloop;
- case SCM_BIT8 (SCM_IM_LAMBDA):
+ case SCM_BIT7 (SCM_IM_LAMBDA):
RETURN (scm_closure (SCM_CDR (x), env));
- case SCM_BIT8 (SCM_IM_QUOTE):
+ case SCM_BIT7 (SCM_IM_QUOTE):
RETURN (SCM_CADR (x));
- case SCM_BIT8 (SCM_IM_SET_X):
+ case SCM_BIT7 (SCM_IM_SET_X):
x = SCM_CDR (x);
{
SCM *location;
SCM variable = SCM_CAR (x);
- if (SCM_VARIABLEP (variable))
- location = SCM_VARIABLE_LOC (variable);
-#ifdef MEMOIZE_LOCALS
- else if (SCM_ILOCP (variable))
+ if (SCM_ILOCP (variable))
location = scm_ilookup (variable, env);
-#endif
+ else if (SCM_VARIABLEP (variable))
+ location = SCM_VARIABLE_LOC (variable);
else /* (SCM_SYMBOLP (variable)) is known to be true */
location = scm_lookupcar (x, env, 1);
x = SCM_CDR (x);
RETURN (SCM_UNSPECIFIED);
- case SCM_BIT8(SCM_IM_DEFINE): /* only for internal defines */
+ case SCM_BIT7 (SCM_IM_DEFINE): /* only for internal defines */
scm_misc_error (NULL, "Bad define placement", SCM_EOL);
/* new syntactic forms go here. */
- case SCM_BIT8 (SCM_MAKISYM (0)):
+ case SCM_BIT7 (SCM_MAKISYM (0)):
proc = SCM_CAR (x);
SCM_ASRTGO (SCM_ISYMP (proc), badfun);
switch (SCM_ISYMNUM (proc))
if (SCM_CLOSUREP (proc))
{
PREP_APPLY (proc, SCM_EOL);
- t.arg1 = SCM_CDDR (x);
- t.arg1 = EVALCAR (t.arg1, env);
+ arg1 = SCM_CDDR (x);
+ arg1 = EVALCAR (arg1, env);
apply_closure:
/* Go here to tail-call a closure. PROC is the closure
- and T.ARG1 is the list of arguments. Do not forget to
- call PREP_APPLY. */
+ and ARG1 is the list of arguments. Do not forget to
+ call PREP_APPLY. */
{
SCM formals = SCM_CLOSURE_FORMALS (proc);
#ifdef DEVAL
- debug.info->a.args = t.arg1;
-#endif
-#ifndef SCM_RECKLESS
- if (scm_badargsp (formals, t.arg1))
- goto wrongnumargs;
+ debug.info->a.args = arg1;
#endif
+ if (scm_badargsp (formals, arg1))
+ scm_wrong_num_args (proc);
ENTER_APPLY;
/* Copy argument list */
- if (SCM_NULL_OR_NIL_P (t.arg1))
- env = EXTEND_ENV (formals, SCM_EOL, SCM_ENV (proc));
+ if (SCM_NULL_OR_NIL_P (arg1))
+ env = SCM_EXTEND_ENV (formals, SCM_EOL, SCM_ENV (proc));
else
{
- SCM args = scm_list_1 (SCM_CAR (t.arg1));
+ SCM args = scm_list_1 (SCM_CAR (arg1));
SCM tail = args;
- t.arg1 = SCM_CDR (t.arg1);
- while (!SCM_NULL_OR_NIL_P (t.arg1))
+ arg1 = SCM_CDR (arg1);
+ while (!SCM_NULL_OR_NIL_P (arg1))
{
- SCM new_tail = scm_list_1 (SCM_CAR (t.arg1));
+ SCM new_tail = scm_list_1 (SCM_CAR (arg1));
SCM_SETCDR (tail, new_tail);
tail = new_tail;
- t.arg1 = SCM_CDR (t.arg1);
+ arg1 = SCM_CDR (arg1);
}
- env = EXTEND_ENV (formals, args, SCM_ENV (proc));
+ env = SCM_EXTEND_ENV (formals, args, SCM_ENV (proc));
}
x = SCM_CLOSURE_BODY (proc);
}
else
{
- proc = scm_f_apply;
+ proc = f_apply;
goto evapply;
}
int first;
SCM val = scm_make_continuation (&first);
- if (first)
- t.arg1 = val;
- else
+ if (!first)
RETURN (val);
- }
- proc = SCM_CDR (x);
- proc = scm_eval_car (proc, env);
- SCM_ASRTGO (SCM_NIMP (proc), badfun);
- PREP_APPLY (proc, scm_list_1 (t.arg1));
- ENTER_APPLY;
- if (SCM_CLOSUREP(proc) && scm_badformalsp (proc, 1))
- goto umwrongnumargs;
- goto evap1;
-
- case (SCM_ISYMNUM (SCM_IM_DELAY)):
- RETURN (scm_makprom (scm_closure (SCM_CDR (x), env)));
-
- case (SCM_ISYMNUM (SCM_IM_DISPATCH)):
- {
- /* If not done yet, evaluate the operand forms. The result is a
- * list of arguments stored in t.arg1, which is used to perform the
- * function dispatch. */
- SCM operand_forms = SCM_CADR (x);
- PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
- if (SCM_ILOCP (operand_forms))
- t.arg1 = *scm_ilookup (operand_forms, env);
- else if (SCM_VARIABLEP (operand_forms))
- t.arg1 = SCM_VARIABLE_REF (operand_forms);
- else if (!SCM_CONSP (operand_forms))
- t.arg1 = *scm_lookupcar (SCM_CDR (x), env, 1);
else
{
- SCM tail = t.arg1 = scm_list_1 (EVALCAR (operand_forms, env));
- operand_forms = SCM_CDR (operand_forms);
- while (!SCM_NULLP (operand_forms))
- {
- SCM new_tail = scm_list_1 (EVALCAR (operand_forms, env));
- SCM_SETCDR (tail, new_tail);
- tail = new_tail;
- operand_forms = SCM_CDR (operand_forms);
- }
+ arg1 = val;
+ proc = SCM_CDR (x);
+ proc = scm_eval_car (proc, env);
+ SCM_ASRTGO (SCM_NIMP (proc), badfun);
+ PREP_APPLY (proc, scm_list_1 (arg1));
+ ENTER_APPLY;
+ if (SCM_CLOSUREP(proc) && scm_badformalsp (proc, 1))
+ goto umwrongnumargs;
+ goto evap1;
}
}
+
+ case (SCM_ISYMNUM (SCM_IM_DELAY)):
+ RETURN (scm_makprom (scm_closure (SCM_CDR (x), env)));
+
+
+ case (SCM_ISYMNUM (SCM_IM_FUTURE)):
+ RETURN (scm_i_make_future (scm_closure (SCM_CDR (x), env)));
+
+
+ /* PLACEHOLDER for case (SCM_ISYMNUM (SCM_IM_DISPATCH)): The
+ following code (type_dispatch) is intended to be the tail
+ of the case clause for the internal macro
+ SCM_IM_DISPATCH. Please don't remove it from this
+ location without discussing it with Mikael
+ <djurfeldt@nada.kth.se> */
+
/* The type dispatch code is duplicated below
* (c.f. objects.c:scm_mcache_compute_cmethod) since that
* cuts down execution time for type dispatch to 50%. */
- type_dispatch: /* inputs: x, t.arg1 */
+ type_dispatch: /* inputs: x, arg1 */
/* Type dispatch means to determine from the types of the function
* arguments (i. e. the 'signature' of the call), which method from
* a generic function is to be called. This process of selecting
* method in the method cache. */
unsigned long int hashset = SCM_INUM (tmp);
unsigned long int counter = specializers + 1;
- SCM tmp_arg = t.arg1;
+ SCM tmp_arg = arg1;
hash_value = 0;
while (!SCM_NULLP (tmp_arg) && counter != 0)
{
SCM z;
do
{
- SCM args = t.arg1; /* list of arguments */
+ SCM args = arg1; /* list of arguments */
z = SCM_VELTS (method_cache)[hash_value];
while (!SCM_NULLP (args))
{
} while (hash_value != cache_end_pos);
/* No appropriate method was found in the cache. */
- z = scm_memoize_method (x, t.arg1);
+ z = scm_memoize_method (x, arg1);
- apply_cmethod: /* inputs: z, t.arg1 */
+ apply_cmethod: /* inputs: z, arg1 */
{
SCM formals = SCM_CMETHOD_FORMALS (z);
- env = EXTEND_ENV (formals, t.arg1, SCM_CMETHOD_ENV (z));
+ env = SCM_EXTEND_ENV (formals, arg1, SCM_CMETHOD_ENV (z));
x = SCM_CMETHOD_BODY (z);
goto nontoplevel_begin;
}
}
-#ifdef SCM_ENABLE_ELISP
+#if SCM_ENABLE_ELISP
case (SCM_ISYMNUM (SCM_IM_NIL_COND)):
{
x = EVALCAR (proc, env);
proc = SCM_CDR (proc);
proc = EVALCAR (proc, env);
- t.arg1 = SCM_APPLY (x, SCM_EOL, SCM_EOL);
- if (SCM_VALUESP (t.arg1))
- t.arg1 = scm_struct_ref (t.arg1, SCM_INUM0);
+ arg1 = SCM_APPLY (x, SCM_EOL, SCM_EOL);
+ if (SCM_VALUESP (arg1))
+ arg1 = scm_struct_ref (arg1, SCM_INUM0);
else
- t.arg1 = scm_list_1 (t.arg1);
+ arg1 = scm_list_1 (arg1);
if (SCM_CLOSUREP (proc))
{
- PREP_APPLY (proc, t.arg1);
+ PREP_APPLY (proc, arg1);
goto apply_closure;
}
- return SCM_APPLY (proc, t.arg1, SCM_EOL);
+ return SCM_APPLY (proc, arg1, SCM_EOL);
}
scm_misc_error (NULL, "Wrong type to apply: ~S", scm_list_1 (proc));
case scm_tc7_vector:
case scm_tc7_wvect:
-#ifdef HAVE_ARRAYS
+#if SCM_HAVE_ARRAYS
case scm_tc7_bvect:
case scm_tc7_byvect:
case scm_tc7_svect:
case scm_tc7_fvect:
case scm_tc7_dvect:
case scm_tc7_cvect:
-#ifdef HAVE_LONG_LONGS
+#if SCM_SIZEOF_LONG_LONG != 0
case scm_tc7_llvect:
#endif
#endif
case scm_tc7_variable:
RETURN (SCM_VARIABLE_REF(x));
-#ifdef MEMOIZE_LOCALS
- case SCM_BIT8(SCM_ILOC00):
+ case SCM_BIT7 (SCM_ILOC00):
proc = *scm_ilookup (SCM_CAR (x), env);
SCM_ASRTGO (SCM_NIMP (proc), badfun);
-#ifndef SCM_RECKLESS
-#ifdef SCM_CAUTIOUS
goto checkargs;
-#endif
-#endif
- break;
-#endif /* ifdef MEMOIZE_LOCALS */
case scm_tcs_cons_nimcar:
- orig_sym = SCM_CAR (x);
- if (SCM_SYMBOLP (orig_sym))
+ if (SCM_SYMBOLP (SCM_CAR (x)))
{
-#ifdef USE_THREADS
+ SCM orig_sym = SCM_CAR (x);
{
SCM *location = scm_lookupcar1 (x, env, 1);
if (location == NULL)
}
proc = *location;
}
-#else
- proc = *scm_lookupcar (x, env, 1);
-#endif
if (SCM_IMP (proc))
{
{
SCM_SETCAR (x, orig_sym); /* Undo memoizing effect of
lookupcar */
- handle_a_macro:
+ handle_a_macro: /* inputs: x, env, proc */
#ifdef DEVAL
/* Set a flag during macro expansion so that macro
application frames can be deleted from the backtrace. */
SCM_SET_MACROEXP (debug);
#endif
- t.arg1 = SCM_APPLY (SCM_MACRO_CODE (proc), x,
+ arg1 = SCM_APPLY (SCM_MACRO_CODE (proc), x,
scm_cons (env, scm_listofnull));
#ifdef DEVAL
switch (SCM_MACRO_TYPE (proc))
{
case 2:
- if (scm_ilength (t.arg1) <= 0)
- t.arg1 = scm_list_2 (SCM_IM_BEGIN, t.arg1);
+ if (scm_ilength (arg1) <= 0)
+ arg1 = scm_list_2 (SCM_IM_BEGIN, arg1);
#ifdef DEVAL
if (!SCM_CLOSUREP (SCM_MACRO_CODE (proc)))
{
SCM_DEFER_INTS;
- SCM_SETCAR (x, SCM_CAR (t.arg1));
- SCM_SETCDR (x, SCM_CDR (t.arg1));
+ SCM_SETCAR (x, SCM_CAR (arg1));
+ SCM_SETCDR (x, SCM_CDR (arg1));
SCM_ALLOW_INTS;
goto dispatch;
}
SCM_CDR (x));
#endif
SCM_DEFER_INTS;
- SCM_SETCAR (x, SCM_CAR (t.arg1));
- SCM_SETCDR (x, SCM_CDR (t.arg1));
+ SCM_SETCAR (x, SCM_CAR (arg1));
+ SCM_SETCDR (x, SCM_CDR (arg1));
SCM_ALLOW_INTS;
- goto loopnoap;
+ PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
+ goto loop;
+#if SCM_ENABLE_DEPRECATED == 1
case 1:
- if (SCM_NIMP (x = t.arg1))
- goto loopnoap;
+ x = arg1;
+ if (SCM_NIMP (x))
+ {
+ PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
+ goto loop;
+ }
+ else
+ RETURN (arg1);
+#endif
case 0:
- RETURN (t.arg1);
+ RETURN (arg1);
}
}
}
else
proc = SCM_CEVAL (SCM_CAR (x), env);
SCM_ASRTGO (!SCM_IMP (proc), badfun);
-#ifndef SCM_RECKLESS
-#ifdef SCM_CAUTIOUS
+
checkargs:
-#endif
if (SCM_CLOSUREP (proc))
{
- arg2 = SCM_CLOSURE_FORMALS (proc);
- t.arg1 = SCM_CDR (x);
- while (!SCM_NULLP (arg2))
+ SCM formals = SCM_CLOSURE_FORMALS (proc);
+ SCM args = SCM_CDR (x);
+ while (!SCM_NULLP (formals))
{
- if (!SCM_CONSP (arg2))
+ if (!SCM_CONSP (formals))
goto evapply;
- if (SCM_IMP (t.arg1))
+ if (SCM_IMP (args))
goto umwrongnumargs;
- arg2 = SCM_CDR (arg2);
- t.arg1 = SCM_CDR (t.arg1);
+ formals = SCM_CDR (formals);
+ args = SCM_CDR (args);
}
- if (!SCM_NULLP (t.arg1))
+ if (!SCM_NULLP (args))
goto umwrongnumargs;
}
else if (SCM_MACROP (proc))
goto handle_a_macro;
-#endif
}
-evapply:
+evapply: /* inputs: x, proc */
PREP_APPLY (proc, SCM_EOL);
if (SCM_NULLP (SCM_CDR (x))) {
ENTER_APPLY;
goto badfun;
RETURN (SCM_SMOB_APPLY_0 (proc));
case scm_tc7_cclo:
- t.arg1 = proc;
+ arg1 = proc;
proc = SCM_CCLO_SUBR (proc);
#ifdef DEVAL
debug.info->a.proc = proc;
- debug.info->a.args = scm_list_1 (t.arg1);
+ debug.info->a.args = scm_list_1 (arg1);
#endif
goto evap1;
case scm_tc7_pws:
goto umwrongnumargs;
case scm_tcs_closures:
x = SCM_CLOSURE_BODY (proc);
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), SCM_EOL, SCM_ENV (proc));
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ SCM_EOL,
+ SCM_ENV (proc));
goto nontoplevel_begin;
case scm_tcs_struct:
if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
{
x = SCM_ENTITY_PROCEDURE (proc);
- t.arg1 = SCM_EOL;
+ arg1 = SCM_EOL;
goto type_dispatch;
}
else if (!SCM_I_OPERATORP (proc))
goto badfun;
else
{
- t.arg1 = proc;
+ arg1 = proc;
proc = (SCM_I_ENTITYP (proc)
? SCM_ENTITY_PROCEDURE (proc)
: SCM_OPERATOR_PROCEDURE (proc));
#ifdef DEVAL
debug.info->a.proc = proc;
- debug.info->a.args = scm_list_1 (t.arg1);
+ debug.info->a.args = scm_list_1 (arg1);
#endif
if (SCM_NIMP (proc))
goto evap1;
case scm_tc7_lsubr_2:
umwrongnumargs:
unmemocar (x, env);
- wrongnumargs:
scm_wrong_num_args (proc);
default:
/* handle macros here */
/* must handle macros by here */
x = SCM_CDR (x);
-#ifdef SCM_CAUTIOUS
- if (SCM_IMP (x))
- goto wrongnumargs;
- else if (SCM_CONSP (x))
- {
- if (SCM_IMP (SCM_CAR (x)))
- t.arg1 = SCM_EVALIM (SCM_CAR (x), env);
- else
- t.arg1 = EVALCELLCAR (x, env);
- }
+ if (SCM_CONSP (x))
+ arg1 = EVALCAR (x, env);
else
- goto wrongnumargs;
-#else
- t.arg1 = EVALCAR (x, env);
-#endif
+ scm_wrong_num_args (proc);
#ifdef DEVAL
- debug.info->a.args = scm_list_1 (t.arg1);
+ debug.info->a.args = scm_list_1 (arg1);
#endif
x = SCM_CDR (x);
- if (SCM_NULLP (x))
- {
- ENTER_APPLY;
- evap1:
- switch (SCM_TYP7 (proc))
- { /* have one argument in t.arg1 */
- case scm_tc7_subr_2o:
- RETURN (SCM_SUBRF (proc) (t.arg1, SCM_UNDEFINED));
- case scm_tc7_subr_1:
- case scm_tc7_subr_1o:
- RETURN (SCM_SUBRF (proc) (t.arg1));
- case scm_tc7_cxr:
- if (SCM_SUBRF (proc))
+ {
+ SCM arg2;
+ if (SCM_NULLP (x))
+ {
+ ENTER_APPLY;
+ evap1: /* inputs: proc, arg1 */
+ switch (SCM_TYP7 (proc))
+ { /* have one argument in arg1 */
+ case scm_tc7_subr_2o:
+ RETURN (SCM_SUBRF (proc) (arg1, SCM_UNDEFINED));
+ case scm_tc7_subr_1:
+ case scm_tc7_subr_1o:
+ RETURN (SCM_SUBRF (proc) (arg1));
+ case scm_tc7_cxr:
+ if (SCM_SUBRF (proc))
+ {
+ if (SCM_INUMP (arg1))
+ {
+ RETURN (scm_make_real (SCM_DSUBRF (proc) ((double) SCM_INUM (arg1))));
+ }
+ else if (SCM_REALP (arg1))
+ {
+ RETURN (scm_make_real (SCM_DSUBRF (proc) (SCM_REAL_VALUE (arg1))));
+ }
+ else if (SCM_BIGP (arg1))
+ {
+ RETURN (scm_make_real (SCM_DSUBRF (proc) (scm_i_big2dbl (arg1))));
+ }
+ SCM_WTA_DISPATCH_1 (*SCM_SUBR_GENERIC (proc), arg1,
+ SCM_ARG1, SCM_SYMBOL_CHARS (SCM_SNAME (proc)));
+ }
+ proc = SCM_SNAME (proc);
{
- if (SCM_INUMP (t.arg1))
- {
- RETURN (scm_make_real (SCM_DSUBRF (proc) ((double) SCM_INUM (t.arg1))));
- }
- else if (SCM_REALP (t.arg1))
- {
- RETURN (scm_make_real (SCM_DSUBRF (proc) (SCM_REAL_VALUE (t.arg1))));
- }
-#ifdef SCM_BIGDIG
- else if (SCM_BIGP (t.arg1))
+ char *chrs = SCM_SYMBOL_CHARS (proc) + SCM_SYMBOL_LENGTH (proc) - 1;
+ while ('c' != *--chrs)
{
- RETURN (scm_make_real (SCM_DSUBRF (proc) (scm_i_big2dbl (t.arg1))));
+ SCM_ASSERT (SCM_CONSP (arg1),
+ arg1, SCM_ARG1, SCM_SYMBOL_CHARS (proc));
+ arg1 = ('a' == *chrs) ? SCM_CAR (arg1) : SCM_CDR (arg1);
}
-#endif
- SCM_WTA_DISPATCH_1 (*SCM_SUBR_GENERIC (proc), t.arg1,
- SCM_ARG1, SCM_SYMBOL_CHARS (SCM_SNAME (proc)));
+ RETURN (arg1);
}
- proc = SCM_SNAME (proc);
- {
- char *chrs = SCM_SYMBOL_CHARS (proc) + SCM_SYMBOL_LENGTH (proc) - 1;
- while ('c' != *--chrs)
- {
- SCM_ASSERT (SCM_CONSP (t.arg1),
- t.arg1, SCM_ARG1, SCM_SYMBOL_CHARS (proc));
- t.arg1 = ('a' == *chrs) ? SCM_CAR (t.arg1) : SCM_CDR (t.arg1);
- }
- RETURN (t.arg1);
- }
- case scm_tc7_rpsubr:
- RETURN (SCM_BOOL_T);
- case scm_tc7_asubr:
- RETURN (SCM_SUBRF (proc) (t.arg1, SCM_UNDEFINED));
- case scm_tc7_lsubr:
+ case scm_tc7_rpsubr:
+ RETURN (SCM_BOOL_T);
+ case scm_tc7_asubr:
+ RETURN (SCM_SUBRF (proc) (arg1, SCM_UNDEFINED));
+ case scm_tc7_lsubr:
#ifdef DEVAL
- RETURN (SCM_SUBRF (proc) (debug.info->a.args));
+ RETURN (SCM_SUBRF (proc) (debug.info->a.args));
#else
- RETURN (SCM_SUBRF (proc) (scm_list_1 (t.arg1)));
+ RETURN (SCM_SUBRF (proc) (scm_list_1 (arg1)));
#endif
- case scm_tc7_smob:
- if (!SCM_SMOB_APPLICABLE_P (proc))
- goto badfun;
- RETURN (SCM_SMOB_APPLY_1 (proc, t.arg1));
- case scm_tc7_cclo:
- arg2 = t.arg1;
- t.arg1 = proc;
- proc = SCM_CCLO_SUBR (proc);
+ case scm_tc7_smob:
+ if (!SCM_SMOB_APPLICABLE_P (proc))
+ goto badfun;
+ RETURN (SCM_SMOB_APPLY_1 (proc, arg1));
+ case scm_tc7_cclo:
+ arg2 = arg1;
+ arg1 = proc;
+ proc = SCM_CCLO_SUBR (proc);
#ifdef DEVAL
- debug.info->a.args = scm_cons (t.arg1, debug.info->a.args);
- debug.info->a.proc = proc;
+ debug.info->a.args = scm_cons (arg1, debug.info->a.args);
+ debug.info->a.proc = proc;
#endif
- goto evap2;
- case scm_tc7_pws:
- proc = SCM_PROCEDURE (proc);
+ goto evap2;
+ case scm_tc7_pws:
+ proc = SCM_PROCEDURE (proc);
#ifdef DEVAL
- debug.info->a.proc = proc;
+ debug.info->a.proc = proc;
#endif
- if (!SCM_CLOSUREP (proc))
- goto evap1;
- if (scm_badformalsp (proc, 1))
- goto umwrongnumargs;
- case scm_tcs_closures:
- /* clos1: */
- x = SCM_CLOSURE_BODY (proc);
+ if (!SCM_CLOSUREP (proc))
+ goto evap1;
+ if (scm_badformalsp (proc, 1))
+ goto umwrongnumargs;
+ case scm_tcs_closures:
+ /* clos1: */
+ x = SCM_CLOSURE_BODY (proc);
#ifdef DEVAL
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), debug.info->a.args, SCM_ENV (proc));
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ debug.info->a.args,
+ SCM_ENV (proc));
#else
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), scm_list_1 (t.arg1), SCM_ENV (proc));
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ scm_list_1 (arg1),
+ SCM_ENV (proc));
#endif
- goto nontoplevel_begin;
- case scm_tcs_struct:
- if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
- {
- x = SCM_ENTITY_PROCEDURE (proc);
+ goto nontoplevel_begin;
+ case scm_tcs_struct:
+ if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
+ {
+ x = SCM_ENTITY_PROCEDURE (proc);
#ifdef DEVAL
- t.arg1 = debug.info->a.args;
+ arg1 = debug.info->a.args;
#else
- t.arg1 = scm_list_1 (t.arg1);
+ arg1 = scm_list_1 (arg1);
#endif
- goto type_dispatch;
- }
- else if (!SCM_I_OPERATORP (proc))
- goto badfun;
- else
- {
- arg2 = t.arg1;
- t.arg1 = proc;
- proc = (SCM_I_ENTITYP (proc)
- ? SCM_ENTITY_PROCEDURE (proc)
- : SCM_OPERATOR_PROCEDURE (proc));
+ goto type_dispatch;
+ }
+ else if (!SCM_I_OPERATORP (proc))
+ goto badfun;
+ else
+ {
+ arg2 = arg1;
+ arg1 = proc;
+ proc = (SCM_I_ENTITYP (proc)
+ ? SCM_ENTITY_PROCEDURE (proc)
+ : SCM_OPERATOR_PROCEDURE (proc));
#ifdef DEVAL
- debug.info->a.args = scm_cons (t.arg1, debug.info->a.args);
- debug.info->a.proc = proc;
+ debug.info->a.args = scm_cons (arg1, debug.info->a.args);
+ debug.info->a.proc = proc;
#endif
- if (SCM_NIMP (proc))
- goto evap2;
- else
- goto badfun;
- }
- case scm_tc7_subr_2:
- case scm_tc7_subr_0:
- case scm_tc7_subr_3:
- case scm_tc7_lsubr_2:
- goto wrongnumargs;
- default:
- goto badfun;
- }
- }
-#ifdef SCM_CAUTIOUS
- if (SCM_IMP (x))
- goto wrongnumargs;
- else if (SCM_CONSP (x))
- {
- if (SCM_IMP (SCM_CAR (x)))
- arg2 = SCM_EVALIM (SCM_CAR (x), env);
- else
- arg2 = EVALCELLCAR (x, env);
- }
- else
- goto wrongnumargs;
-#else
- arg2 = EVALCAR (x, env);
+ if (SCM_NIMP (proc))
+ goto evap2;
+ else
+ goto badfun;
+ }
+ case scm_tc7_subr_2:
+ case scm_tc7_subr_0:
+ case scm_tc7_subr_3:
+ case scm_tc7_lsubr_2:
+ scm_wrong_num_args (proc);
+ default:
+ goto badfun;
+ }
+ }
+ if (SCM_CONSP (x))
+ arg2 = EVALCAR (x, env);
+ else
+ scm_wrong_num_args (proc);
+
+ { /* have two or more arguments */
+#ifdef DEVAL
+ debug.info->a.args = scm_list_2 (arg1, arg2);
#endif
- { /* have two or more arguments */
+ x = SCM_CDR (x);
+ if (SCM_NULLP (x)) {
+ ENTER_APPLY;
+ evap2:
+ switch (SCM_TYP7 (proc))
+ { /* have two arguments */
+ case scm_tc7_subr_2:
+ case scm_tc7_subr_2o:
+ RETURN (SCM_SUBRF (proc) (arg1, arg2));
+ case scm_tc7_lsubr:
#ifdef DEVAL
- debug.info->a.args = scm_list_2 (t.arg1, arg2);
+ RETURN (SCM_SUBRF (proc) (debug.info->a.args));
+#else
+ RETURN (SCM_SUBRF (proc) (scm_list_2 (arg1, arg2)));
#endif
- x = SCM_CDR (x);
- if (SCM_NULLP (x)) {
- ENTER_APPLY;
- evap2:
- switch (SCM_TYP7 (proc))
- { /* have two arguments */
- case scm_tc7_subr_2:
- case scm_tc7_subr_2o:
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2));
- case scm_tc7_lsubr:
+ case scm_tc7_lsubr_2:
+ RETURN (SCM_SUBRF (proc) (arg1, arg2, SCM_EOL));
+ case scm_tc7_rpsubr:
+ case scm_tc7_asubr:
+ RETURN (SCM_SUBRF (proc) (arg1, arg2));
+ case scm_tc7_smob:
+ if (!SCM_SMOB_APPLICABLE_P (proc))
+ goto badfun;
+ RETURN (SCM_SMOB_APPLY_2 (proc, arg1, arg2));
+ cclon:
+ case scm_tc7_cclo:
#ifdef DEVAL
- RETURN (SCM_SUBRF (proc) (debug.info->a.args));
+ RETURN (SCM_APPLY (SCM_CCLO_SUBR (proc),
+ scm_cons (proc, debug.info->a.args),
+ SCM_EOL));
#else
- RETURN (SCM_SUBRF (proc) (scm_list_2 (t.arg1, arg2)));
+ RETURN (SCM_APPLY (SCM_CCLO_SUBR (proc),
+ scm_cons2 (proc, arg1,
+ scm_cons (arg2,
+ scm_eval_args (x,
+ env,
+ proc))),
+ SCM_EOL));
#endif
- case scm_tc7_lsubr_2:
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2, SCM_EOL));
- case scm_tc7_rpsubr:
- case scm_tc7_asubr:
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2));
- case scm_tc7_smob:
- if (!SCM_SMOB_APPLICABLE_P (proc))
- goto badfun;
- RETURN (SCM_SMOB_APPLY_2 (proc, t.arg1, arg2));
- cclon:
- case scm_tc7_cclo:
+ case scm_tcs_struct:
+ if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
+ {
+ x = SCM_ENTITY_PROCEDURE (proc);
#ifdef DEVAL
- RETURN (SCM_APPLY (SCM_CCLO_SUBR (proc),
- scm_cons (proc, debug.info->a.args),
- SCM_EOL));
+ arg1 = debug.info->a.args;
#else
- RETURN (SCM_APPLY (SCM_CCLO_SUBR (proc),
- scm_cons2 (proc, t.arg1,
- scm_cons (arg2,
- scm_eval_args (x,
- env,
- proc))),
- SCM_EOL));
+ arg1 = scm_list_2 (arg1, arg2);
#endif
- case scm_tcs_struct:
- if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
- {
- x = SCM_ENTITY_PROCEDURE (proc);
+ goto type_dispatch;
+ }
+ else if (!SCM_I_OPERATORP (proc))
+ goto badfun;
+ else
+ {
+ operatorn:
#ifdef DEVAL
- t.arg1 = debug.info->a.args;
+ RETURN (SCM_APPLY (SCM_I_ENTITYP (proc)
+ ? SCM_ENTITY_PROCEDURE (proc)
+ : SCM_OPERATOR_PROCEDURE (proc),
+ scm_cons (proc, debug.info->a.args),
+ SCM_EOL));
#else
- t.arg1 = scm_list_2 (t.arg1, arg2);
+ RETURN (SCM_APPLY (SCM_I_ENTITYP (proc)
+ ? SCM_ENTITY_PROCEDURE (proc)
+ : SCM_OPERATOR_PROCEDURE (proc),
+ scm_cons2 (proc, arg1,
+ scm_cons (arg2,
+ scm_eval_args (x,
+ env,
+ proc))),
+ SCM_EOL));
#endif
- goto type_dispatch;
- }
- else if (!SCM_I_OPERATORP (proc))
+ }
+ case scm_tc7_subr_0:
+ case scm_tc7_cxr:
+ case scm_tc7_subr_1o:
+ case scm_tc7_subr_1:
+ case scm_tc7_subr_3:
+ scm_wrong_num_args (proc);
+ default:
goto badfun;
- else
- {
- operatorn:
+ case scm_tc7_pws:
+ proc = SCM_PROCEDURE (proc);
+#ifdef DEVAL
+ debug.info->a.proc = proc;
+#endif
+ if (!SCM_CLOSUREP (proc))
+ goto evap2;
+ if (scm_badformalsp (proc, 2))
+ goto umwrongnumargs;
+ case scm_tcs_closures:
+ /* clos2: */
#ifdef DEVAL
- RETURN (SCM_APPLY (SCM_I_ENTITYP (proc)
- ? SCM_ENTITY_PROCEDURE (proc)
- : SCM_OPERATOR_PROCEDURE (proc),
- scm_cons (proc, debug.info->a.args),
- SCM_EOL));
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ debug.info->a.args,
+ SCM_ENV (proc));
#else
- RETURN (SCM_APPLY (SCM_I_ENTITYP (proc)
- ? SCM_ENTITY_PROCEDURE (proc)
- : SCM_OPERATOR_PROCEDURE (proc),
- scm_cons2 (proc, t.arg1,
- scm_cons (arg2,
- scm_eval_args (x,
- env,
- proc))),
- SCM_EOL));
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ scm_list_2 (arg1, arg2),
+ SCM_ENV (proc));
#endif
- }
- case scm_tc7_subr_0:
- case scm_tc7_cxr:
- case scm_tc7_subr_1o:
- case scm_tc7_subr_1:
+ x = SCM_CLOSURE_BODY (proc);
+ goto nontoplevel_begin;
+ }
+ }
+ if (!SCM_CONSP (x))
+ scm_wrong_num_args (proc);
+#ifdef DEVAL
+ debug.info->a.args = scm_cons2 (arg1, arg2,
+ deval_args (x, env, proc,
+ SCM_CDRLOC (SCM_CDR (debug.info->a.args))));
+#endif
+ ENTER_APPLY;
+ evap3:
+ switch (SCM_TYP7 (proc))
+ { /* have 3 or more arguments */
+#ifdef DEVAL
case scm_tc7_subr_3:
- goto wrongnumargs;
- default:
- goto badfun;
+ if (!SCM_NULLP (SCM_CDR (x)))
+ scm_wrong_num_args (proc);
+ else
+ RETURN (SCM_SUBRF (proc) (arg1, arg2,
+ SCM_CADDR (debug.info->a.args)));
+ case scm_tc7_asubr:
+ arg1 = SCM_SUBRF(proc)(arg1, arg2);
+ arg2 = SCM_CDDR (debug.info->a.args);
+ do
+ {
+ arg1 = SCM_SUBRF(proc)(arg1, SCM_CAR (arg2));
+ arg2 = SCM_CDR (arg2);
+ }
+ while (SCM_NIMP (arg2));
+ RETURN (arg1);
+ case scm_tc7_rpsubr:
+ if (SCM_FALSEP (SCM_SUBRF (proc) (arg1, arg2)))
+ RETURN (SCM_BOOL_F);
+ arg1 = SCM_CDDR (debug.info->a.args);
+ do
+ {
+ if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, SCM_CAR (arg1))))
+ RETURN (SCM_BOOL_F);
+ arg2 = SCM_CAR (arg1);
+ arg1 = SCM_CDR (arg1);
+ }
+ while (SCM_NIMP (arg1));
+ RETURN (SCM_BOOL_T);
+ case scm_tc7_lsubr_2:
+ RETURN (SCM_SUBRF (proc) (arg1, arg2,
+ SCM_CDDR (debug.info->a.args)));
+ case scm_tc7_lsubr:
+ RETURN (SCM_SUBRF (proc) (debug.info->a.args));
+ case scm_tc7_smob:
+ if (!SCM_SMOB_APPLICABLE_P (proc))
+ goto badfun;
+ RETURN (SCM_SMOB_APPLY_3 (proc, arg1, arg2,
+ SCM_CDDR (debug.info->a.args)));
+ case scm_tc7_cclo:
+ goto cclon;
case scm_tc7_pws:
proc = SCM_PROCEDURE (proc);
-#ifdef DEVAL
debug.info->a.proc = proc;
-#endif
if (!SCM_CLOSUREP (proc))
- goto evap2;
- if (scm_badformalsp (proc, 2))
+ goto evap3;
+ if (scm_badargsp (SCM_CLOSURE_FORMALS (proc), debug.info->a.args))
goto umwrongnumargs;
case scm_tcs_closures:
- /* clos2: */
-#ifdef DEVAL
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
- debug.info->a.args,
- SCM_ENV (proc));
-#else
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
- scm_list_2 (t.arg1, arg2), SCM_ENV (proc));
-#endif
+ SCM_SET_ARGSREADY (debug);
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ debug.info->a.args,
+ SCM_ENV (proc));
x = SCM_CLOSURE_BODY (proc);
goto nontoplevel_begin;
- }
- }
-#ifdef SCM_CAUTIOUS
- if (SCM_IMP (x) || !SCM_CONSP (x))
- goto wrongnumargs;
-#endif
-#ifdef DEVAL
- debug.info->a.args = scm_cons2 (t.arg1, arg2,
- deval_args (x, env, proc, SCM_CDRLOC (SCM_CDR (debug.info->a.args))));
-#endif
- ENTER_APPLY;
- evap3:
- switch (SCM_TYP7 (proc))
- { /* have 3 or more arguments */
-#ifdef DEVAL
- case scm_tc7_subr_3:
- SCM_ASRTGO (SCM_NULLP (SCM_CDR (x)), wrongnumargs);
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2,
- SCM_CADDR (debug.info->a.args)));
- case scm_tc7_asubr:
-#ifdef BUILTIN_RPASUBR
- t.arg1 = SCM_SUBRF(proc)(t.arg1, arg2);
- arg2 = SCM_CDDR (debug.info->a.args);
- do
- {
- t.arg1 = SCM_SUBRF(proc)(t.arg1, SCM_CAR (arg2));
- arg2 = SCM_CDR (arg2);
- }
- while (SCM_NIMP (arg2));
- RETURN (t.arg1);
-#endif /* BUILTIN_RPASUBR */
- case scm_tc7_rpsubr:
-#ifdef BUILTIN_RPASUBR
- if (SCM_FALSEP (SCM_SUBRF (proc) (t.arg1, arg2)))
- RETURN (SCM_BOOL_F);
- t.arg1 = SCM_CDDR (debug.info->a.args);
- do
- {
- if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, SCM_CAR (t.arg1))))
- RETURN (SCM_BOOL_F);
- arg2 = SCM_CAR (t.arg1);
- t.arg1 = SCM_CDR (t.arg1);
- }
- while (SCM_NIMP (t.arg1));
- RETURN (SCM_BOOL_T);
-#else /* BUILTIN_RPASUBR */
- RETURN (SCM_APPLY (proc, t.arg1,
- scm_acons (arg2,
- SCM_CDDR (debug.info->a.args),
- SCM_EOL)));
-#endif /* BUILTIN_RPASUBR */
- case scm_tc7_lsubr_2:
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2,
- SCM_CDDR (debug.info->a.args)));
- case scm_tc7_lsubr:
- RETURN (SCM_SUBRF (proc) (debug.info->a.args));
- case scm_tc7_smob:
- if (!SCM_SMOB_APPLICABLE_P (proc))
- goto badfun;
- RETURN (SCM_SMOB_APPLY_3 (proc, t.arg1, arg2,
- SCM_CDDR (debug.info->a.args)));
- case scm_tc7_cclo:
- goto cclon;
- case scm_tc7_pws:
- proc = SCM_PROCEDURE (proc);
- debug.info->a.proc = proc;
- if (!SCM_CLOSUREP (proc))
- goto evap3;
- if (scm_badargsp (SCM_CLOSURE_FORMALS (proc), debug.info->a.args))
- goto umwrongnumargs;
- case scm_tcs_closures:
- SCM_SET_ARGSREADY (debug);
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
- debug.info->a.args,
- SCM_ENV (proc));
- x = SCM_CLOSURE_BODY (proc);
- goto nontoplevel_begin;
#else /* DEVAL */
- case scm_tc7_subr_3:
- SCM_ASRTGO (SCM_NULLP (SCM_CDR (x)), wrongnumargs);
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2, EVALCAR (x, env)));
- case scm_tc7_asubr:
-#ifdef BUILTIN_RPASUBR
- t.arg1 = SCM_SUBRF (proc) (t.arg1, arg2);
- do
- {
- t.arg1 = SCM_SUBRF(proc)(t.arg1, EVALCAR(x, env));
- x = SCM_CDR(x);
- }
- while (SCM_NIMP (x));
- RETURN (t.arg1);
-#endif /* BUILTIN_RPASUBR */
- case scm_tc7_rpsubr:
-#ifdef BUILTIN_RPASUBR
- if (SCM_FALSEP (SCM_SUBRF (proc) (t.arg1, arg2)))
- RETURN (SCM_BOOL_F);
- do
- {
- t.arg1 = EVALCAR (x, env);
- if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, t.arg1)))
- RETURN (SCM_BOOL_F);
- arg2 = t.arg1;
- x = SCM_CDR (x);
- }
- while (SCM_NIMP (x));
- RETURN (SCM_BOOL_T);
-#else /* BUILTIN_RPASUBR */
- RETURN (SCM_APPLY (proc, t.arg1,
- scm_acons (arg2,
- scm_eval_args (x, env, proc),
- SCM_EOL)));
-#endif /* BUILTIN_RPASUBR */
- case scm_tc7_lsubr_2:
- RETURN (SCM_SUBRF (proc) (t.arg1, arg2, scm_eval_args (x, env, proc)));
- case scm_tc7_lsubr:
- RETURN (SCM_SUBRF (proc) (scm_cons2 (t.arg1,
- arg2,
- scm_eval_args (x, env, proc))));
- case scm_tc7_smob:
- if (!SCM_SMOB_APPLICABLE_P (proc))
- goto badfun;
- RETURN (SCM_SMOB_APPLY_3 (proc, t.arg1, arg2,
- scm_eval_args (x, env, proc)));
- case scm_tc7_cclo:
- goto cclon;
- case scm_tc7_pws:
- proc = SCM_PROCEDURE (proc);
- if (!SCM_CLOSUREP (proc))
- goto evap3;
- {
- SCM formals = SCM_CLOSURE_FORMALS (proc);
- if (SCM_NULLP (formals)
- || (SCM_CONSP (formals)
- && (SCM_NULLP (SCM_CDR (formals))
- || (SCM_CONSP (SCM_CDR (formals))
- && scm_badargsp (SCM_CDDR (formals), x)))))
- goto umwrongnumargs;
- }
- case scm_tcs_closures:
+ case scm_tc7_subr_3:
+ if (!SCM_NULLP (SCM_CDR (x)))
+ scm_wrong_num_args (proc);
+ else
+ RETURN (SCM_SUBRF (proc) (arg1, arg2, EVALCAR (x, env)));
+ case scm_tc7_asubr:
+ arg1 = SCM_SUBRF (proc) (arg1, arg2);
+ do
+ {
+ arg1 = SCM_SUBRF(proc)(arg1, EVALCAR(x, env));
+ x = SCM_CDR(x);
+ }
+ while (SCM_NIMP (x));
+ RETURN (arg1);
+ case scm_tc7_rpsubr:
+ if (SCM_FALSEP (SCM_SUBRF (proc) (arg1, arg2)))
+ RETURN (SCM_BOOL_F);
+ do
+ {
+ arg1 = EVALCAR (x, env);
+ if (SCM_FALSEP (SCM_SUBRF (proc) (arg2, arg1)))
+ RETURN (SCM_BOOL_F);
+ arg2 = arg1;
+ x = SCM_CDR (x);
+ }
+ while (SCM_NIMP (x));
+ RETURN (SCM_BOOL_T);
+ case scm_tc7_lsubr_2:
+ RETURN (SCM_SUBRF (proc) (arg1, arg2, scm_eval_args (x, env, proc)));
+ case scm_tc7_lsubr:
+ RETURN (SCM_SUBRF (proc) (scm_cons2 (arg1,
+ arg2,
+ scm_eval_args (x, env, proc))));
+ case scm_tc7_smob:
+ if (!SCM_SMOB_APPLICABLE_P (proc))
+ goto badfun;
+ RETURN (SCM_SMOB_APPLY_3 (proc, arg1, arg2,
+ scm_eval_args (x, env, proc)));
+ case scm_tc7_cclo:
+ goto cclon;
+ case scm_tc7_pws:
+ proc = SCM_PROCEDURE (proc);
+ if (!SCM_CLOSUREP (proc))
+ goto evap3;
+ {
+ SCM formals = SCM_CLOSURE_FORMALS (proc);
+ if (SCM_NULLP (formals)
+ || (SCM_CONSP (formals)
+ && (SCM_NULLP (SCM_CDR (formals))
+ || (SCM_CONSP (SCM_CDR (formals))
+ && scm_badargsp (SCM_CDDR (formals), x)))))
+ goto umwrongnumargs;
+ }
+ case scm_tcs_closures:
#ifdef DEVAL
- SCM_SET_ARGSREADY (debug);
+ SCM_SET_ARGSREADY (debug);
#endif
- env = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
- scm_cons2 (t.arg1,
- arg2,
- scm_eval_args (x, env, proc)),
- SCM_ENV (proc));
- x = SCM_CLOSURE_BODY (proc);
- goto nontoplevel_begin;
+ env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ scm_cons2 (arg1,
+ arg2,
+ scm_eval_args (x, env, proc)),
+ SCM_ENV (proc));
+ x = SCM_CLOSURE_BODY (proc);
+ goto nontoplevel_begin;
#endif /* DEVAL */
- case scm_tcs_struct:
- if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
- {
+ case scm_tcs_struct:
+ if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
+ {
#ifdef DEVAL
- t.arg1 = debug.info->a.args;
+ arg1 = debug.info->a.args;
#else
- t.arg1 = scm_cons2 (t.arg1, arg2, scm_eval_args (x, env, proc));
+ arg1 = scm_cons2 (arg1, arg2, scm_eval_args (x, env, proc));
#endif
- x = SCM_ENTITY_PROCEDURE (proc);
- goto type_dispatch;
- }
- else if (!SCM_I_OPERATORP (proc))
+ x = SCM_ENTITY_PROCEDURE (proc);
+ goto type_dispatch;
+ }
+ else if (!SCM_I_OPERATORP (proc))
+ goto badfun;
+ else
+ goto operatorn;
+ case scm_tc7_subr_2:
+ case scm_tc7_subr_1o:
+ case scm_tc7_subr_2o:
+ case scm_tc7_subr_0:
+ case scm_tc7_cxr:
+ case scm_tc7_subr_1:
+ scm_wrong_num_args (proc);
+ default:
goto badfun;
- else
- goto operatorn;
- case scm_tc7_subr_2:
- case scm_tc7_subr_1o:
- case scm_tc7_subr_2o:
- case scm_tc7_subr_0:
- case scm_tc7_cxr:
- case scm_tc7_subr_1:
- goto wrongnumargs;
- default:
- goto badfun;
- }
+ }
+ }
}
#ifdef DEVAL
exit:
- if (CHECK_EXIT && SCM_TRAPS_P)
+ if (scm_check_exit_p && SCM_TRAPS_P)
if (SCM_EXIT_FRAME_P || (SCM_TRACE_P && SCM_TRACED_FRAME_P (debug)))
{
SCM_CLEAR_TRACED_FRAME (debug);
if (SCM_CHEAPTRAPS_P)
- t.arg1 = scm_make_debugobj (&debug);
+ arg1 = scm_make_debugobj (&debug);
else
{
int first;
SCM val = scm_make_continuation (&first);
-
+
if (first)
- t.arg1 = val;
+ arg1 = val;
else
{
proc = val;
}
}
SCM_TRAPS_P = 0;
- scm_call_3 (SCM_EXIT_FRAME_HDLR, scm_sym_exit_frame, t.arg1, proc);
+ scm_call_3 (SCM_EXIT_FRAME_HDLR, scm_sym_exit_frame, arg1, proc);
SCM_TRAPS_P = 1;
}
ret:
#ifndef DEVAL
\f
+
/* Simple procedure calls
*/
#define FUNC_NAME s_scm_nconc2last
{
SCM *lloc;
- SCM_VALIDATE_NONEMPTYLIST (1,lst);
+ SCM_VALIDATE_NONEMPTYLIST (1, lst);
lloc = &lst;
while (!SCM_NULLP (SCM_CDR (*lloc))) /* Perhaps should be
SCM_NULL_OR_NIL_P, but not
#if 0
SCM
scm_dapply (SCM proc, SCM arg1, SCM args)
-{ /* empty */ }
+{}
#endif
SCM
SCM_APPLY (SCM proc, SCM arg1, SCM args)
{
-#ifdef DEBUG_EXTENSIONS
#ifdef DEVAL
scm_t_debug_frame debug;
scm_t_debug_info debug_vect_body;
#else
if (SCM_DEBUGGINGP)
return scm_dapply (proc, arg1, args);
-#endif
#endif
SCM_ASRTGO (SCM_NIMP (proc), badproc);
args = SCM_NULLP (args) ? SCM_UNDEFINED : SCM_CAR (args);
RETURN (SCM_SUBRF (proc) (arg1, args));
case scm_tc7_subr_2:
- SCM_ASRTGO (!SCM_NULLP (args) && SCM_NULLP (SCM_CDR (args)),
- wrongnumargs);
+ if (SCM_NULLP (args) || !SCM_NULLP (SCM_CDR (args)))
+ scm_wrong_num_args (proc);
args = SCM_CAR (args);
RETURN (SCM_SUBRF (proc) (arg1, args));
case scm_tc7_subr_0:
- SCM_ASRTGO (SCM_UNBNDP (arg1), wrongnumargs);
- RETURN (SCM_SUBRF (proc) ());
+ if (!SCM_UNBNDP (arg1))
+ scm_wrong_num_args (proc);
+ else
+ RETURN (SCM_SUBRF (proc) ());
case scm_tc7_subr_1:
- SCM_ASRTGO (!SCM_UNBNDP (arg1), wrongnumargs);
+ if (SCM_UNBNDP (arg1))
+ scm_wrong_num_args (proc);
case scm_tc7_subr_1o:
- SCM_ASRTGO (SCM_NULLP (args), wrongnumargs);
- RETURN (SCM_SUBRF (proc) (arg1));
+ if (!SCM_NULLP (args))
+ scm_wrong_num_args (proc);
+ else
+ RETURN (SCM_SUBRF (proc) (arg1));
case scm_tc7_cxr:
- SCM_ASRTGO (!SCM_UNBNDP (arg1) && SCM_NULLP (args), wrongnumargs);
+ if (SCM_UNBNDP (arg1) || !SCM_NULLP (args))
+ scm_wrong_num_args (proc);
if (SCM_SUBRF (proc))
{
if (SCM_INUMP (arg1))
{
RETURN (scm_make_real (SCM_DSUBRF (proc) (SCM_REAL_VALUE (arg1))));
}
-#ifdef SCM_BIGDIG
else if (SCM_BIGP (arg1))
RETURN (scm_make_real (SCM_DSUBRF (proc) (scm_i_big2dbl (arg1))));
-#endif
SCM_WTA_DISPATCH_1 (*SCM_SUBR_GENERIC (proc), arg1,
SCM_ARG1, SCM_SYMBOL_CHARS (SCM_SNAME (proc)));
}
RETURN (arg1);
}
case scm_tc7_subr_3:
- SCM_ASRTGO (!SCM_NULLP (args)
- && !SCM_NULLP (SCM_CDR (args))
- && SCM_NULLP (SCM_CDDR (args)),
- wrongnumargs);
- RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CADR (args)));
+ if (SCM_NULLP (args)
+ || SCM_NULLP (SCM_CDR (args))
+ || !SCM_NULLP (SCM_CDDR (args)))
+ scm_wrong_num_args (proc);
+ else
+ RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CADR (args)));
case scm_tc7_lsubr:
#ifdef DEVAL
RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : debug.vect[0].a.args));
RETURN (SCM_SUBRF (proc) (SCM_UNBNDP (arg1) ? SCM_EOL : scm_cons (arg1, args)));
#endif
case scm_tc7_lsubr_2:
- SCM_ASRTGO (SCM_CONSP (args), wrongnumargs);
- RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CDR (args)));
+ if (!SCM_CONSP (args))
+ scm_wrong_num_args (proc);
+ else
+ RETURN (SCM_SUBRF (proc) (arg1, SCM_CAR (args), SCM_CDR (args)));
case scm_tc7_asubr:
if (SCM_NULLP (args))
RETURN (SCM_SUBRF (proc) (arg1, SCM_UNDEFINED));
#else
arg1 = (SCM_UNBNDP (arg1) ? SCM_EOL : scm_cons (arg1, args));
#endif
-#ifndef SCM_RECKLESS
if (scm_badargsp (SCM_CLOSURE_FORMALS (proc), arg1))
- goto wrongnumargs;
-#endif
+ scm_wrong_num_args (proc);
/* Copy argument list */
if (SCM_IMP (arg1))
else
{
SCM tl = args = scm_cons (SCM_CAR (arg1), SCM_UNSPECIFIED);
- while (arg1 = SCM_CDR (arg1), SCM_CONSP (arg1))
+ for (arg1 = SCM_CDR (arg1); SCM_CONSP (arg1); arg1 = SCM_CDR (arg1))
{
- SCM_SETCDR (tl, scm_cons (SCM_CAR (arg1),
- SCM_UNSPECIFIED));
+ SCM_SETCDR (tl, scm_cons (SCM_CAR (arg1), SCM_UNSPECIFIED));
tl = SCM_CDR (tl);
}
SCM_SETCDR (tl, arg1);
}
- args = EXTEND_ENV (SCM_CLOSURE_FORMALS (proc), args, SCM_ENV (proc));
+ args = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ args,
+ SCM_ENV (proc));
proc = SCM_CLOSURE_BODY (proc);
again:
- arg1 = proc;
- while (!SCM_NULLP (arg1 = SCM_CDR (arg1)))
+ arg1 = SCM_CDR (proc);
+ while (!SCM_NULLP (arg1))
{
if (SCM_IMP (SCM_CAR (proc)))
{
if (SCM_ISYMP (SCM_CAR (proc)))
{
- proc = scm_m_expand_body (proc, args);
+ scm_rec_mutex_lock (&source_mutex);
+ /* check for race condition */
+ if (SCM_ISYMP (SCM_CAR (proc)))
+ proc = scm_m_expand_body (proc, args);
+ scm_rec_mutex_unlock (&source_mutex);
goto again;
}
else
else
SCM_CEVAL (SCM_CAR (proc), args);
proc = arg1;
+ arg1 = SCM_CDR (proc);
}
RETURN (EVALCAR (proc, args));
case scm_tc7_smob:
goto badproc;
else
{
+ /* operator */
#ifdef DEVAL
args = (SCM_UNBNDP(arg1) ? SCM_EOL : debug.vect[0].a.args);
#else
else
goto badproc;
}
- wrongnumargs:
- scm_wrong_num_args (proc);
default:
badproc:
scm_wrong_type_arg ("apply", SCM_ARG1, proc);
- RETURN (arg1);
}
#ifdef DEVAL
exit:
- if (CHECK_EXIT && SCM_TRAPS_P)
+ if (scm_check_exit_p && SCM_TRAPS_P)
if (SCM_EXIT_FRAME_P || (SCM_TRACE_P && SCM_TRACED_FRAME_P (debug)))
{
SCM_CLEAR_TRACED_FRAME (debug);
#ifndef DEVAL
+/* Trampolines
+ *
+ * Trampolines make it possible to move procedure application dispatch
+ * outside inner loops. The motivation was clean implementation of
+ * efficient replacements of R5RS primitives in SRFI-1.
+ *
+ * The semantics is clear: scm_trampoline_N returns an optimized
+ * version of scm_call_N (or NULL if the procedure isn't applicable
+ * on N args).
+ *
+ * Applying the optimization to map and for-each increased efficiency
+ * noticeably. For example, (map abs ls) is now 8 times faster than
+ * before.
+ */
+
+static SCM
+call_subr0_0 (SCM proc)
+{
+ return SCM_SUBRF (proc) ();
+}
+
+static SCM
+call_subr1o_0 (SCM proc)
+{
+ return SCM_SUBRF (proc) (SCM_UNDEFINED);
+}
+
+static SCM
+call_lsubr_0 (SCM proc)
+{
+ return SCM_SUBRF (proc) (SCM_EOL);
+}
+
+SCM
+scm_i_call_closure_0 (SCM proc)
+{
+ const SCM env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ SCM_EOL,
+ SCM_ENV (proc));
+ const SCM result = scm_eval_body (SCM_CLOSURE_BODY (proc), env);
+ return result;
+}
+
+scm_t_trampoline_0
+scm_trampoline_0 (SCM proc)
+{
+ if (SCM_IMP (proc))
+ return NULL;
+ if (SCM_DEBUGGINGP)
+ return scm_call_0;
+ switch (SCM_TYP7 (proc))
+ {
+ case scm_tc7_subr_0:
+ return call_subr0_0;
+ case scm_tc7_subr_1o:
+ return call_subr1o_0;
+ case scm_tc7_lsubr:
+ return call_lsubr_0;
+ case scm_tcs_closures:
+ {
+ SCM formals = SCM_CLOSURE_FORMALS (proc);
+ if (SCM_NULLP (formals) || !SCM_CONSP (formals))
+ return scm_i_call_closure_0;
+ else
+ return NULL;
+ }
+ case scm_tcs_struct:
+ if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
+ return scm_call_generic_0;
+ else if (!SCM_I_OPERATORP (proc))
+ return NULL;
+ return scm_call_0;
+ case scm_tc7_smob:
+ if (SCM_SMOB_APPLICABLE_P (proc))
+ return SCM_SMOB_DESCRIPTOR (proc).apply_0;
+ else
+ return NULL;
+ case scm_tc7_asubr:
+ case scm_tc7_rpsubr:
+ case scm_tc7_cclo:
+ case scm_tc7_pws:
+ return scm_call_0;
+ default:
+ return NULL; /* not applicable on one arg */
+ }
+}
+
+static SCM
+call_subr1_1 (SCM proc, SCM arg1)
+{
+ return SCM_SUBRF (proc) (arg1);
+}
+
+static SCM
+call_subr2o_1 (SCM proc, SCM arg1)
+{
+ return SCM_SUBRF (proc) (arg1, SCM_UNDEFINED);
+}
+
+static SCM
+call_lsubr_1 (SCM proc, SCM arg1)
+{
+ return SCM_SUBRF (proc) (scm_list_1 (arg1));
+}
+
+static SCM
+call_dsubr_1 (SCM proc, SCM arg1)
+{
+ if (SCM_INUMP (arg1))
+ {
+ RETURN (scm_make_real (SCM_DSUBRF (proc) ((double) SCM_INUM (arg1))));
+ }
+ else if (SCM_REALP (arg1))
+ {
+ RETURN (scm_make_real (SCM_DSUBRF (proc) (SCM_REAL_VALUE (arg1))));
+ }
+ else if (SCM_BIGP (arg1))
+ RETURN (scm_make_real (SCM_DSUBRF (proc) (scm_i_big2dbl (arg1))));
+ SCM_WTA_DISPATCH_1 (*SCM_SUBR_GENERIC (proc), arg1,
+ SCM_ARG1, SCM_SYMBOL_CHARS (SCM_SNAME (proc)));
+}
+
+static SCM
+call_cxr_1 (SCM proc, SCM arg1)
+{
+ proc = SCM_SNAME (proc);
+ {
+ char *chrs = SCM_SYMBOL_CHARS (proc) + SCM_SYMBOL_LENGTH (proc) - 1;
+ while ('c' != *--chrs)
+ {
+ SCM_ASSERT (SCM_CONSP (arg1),
+ arg1, SCM_ARG1, SCM_SYMBOL_CHARS (proc));
+ arg1 = ('a' == *chrs) ? SCM_CAR (arg1) : SCM_CDR (arg1);
+ }
+ return (arg1);
+ }
+}
+
+static SCM
+call_closure_1 (SCM proc, SCM arg1)
+{
+ const SCM env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ scm_list_1 (arg1),
+ SCM_ENV (proc));
+ const SCM result = scm_eval_body (SCM_CLOSURE_BODY (proc), env);
+ return result;
+}
+
+scm_t_trampoline_1
+scm_trampoline_1 (SCM proc)
+{
+ if (SCM_IMP (proc))
+ return NULL;
+ if (SCM_DEBUGGINGP)
+ return scm_call_1;
+ switch (SCM_TYP7 (proc))
+ {
+ case scm_tc7_subr_1:
+ case scm_tc7_subr_1o:
+ return call_subr1_1;
+ case scm_tc7_subr_2o:
+ return call_subr2o_1;
+ case scm_tc7_lsubr:
+ return call_lsubr_1;
+ case scm_tc7_cxr:
+ if (SCM_SUBRF (proc))
+ return call_dsubr_1;
+ else
+ return call_cxr_1;
+ case scm_tcs_closures:
+ {
+ SCM formals = SCM_CLOSURE_FORMALS (proc);
+ if (!SCM_NULLP (formals)
+ && (!SCM_CONSP (formals) || !SCM_CONSP (SCM_CDR (formals))))
+ return call_closure_1;
+ else
+ return NULL;
+ }
+ case scm_tcs_struct:
+ if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
+ return scm_call_generic_1;
+ else if (!SCM_I_OPERATORP (proc))
+ return NULL;
+ return scm_call_1;
+ case scm_tc7_smob:
+ if (SCM_SMOB_APPLICABLE_P (proc))
+ return SCM_SMOB_DESCRIPTOR (proc).apply_1;
+ else
+ return NULL;
+ case scm_tc7_asubr:
+ case scm_tc7_rpsubr:
+ case scm_tc7_cclo:
+ case scm_tc7_pws:
+ return scm_call_1;
+ default:
+ return NULL; /* not applicable on one arg */
+ }
+}
+
+static SCM
+call_subr2_2 (SCM proc, SCM arg1, SCM arg2)
+{
+ return SCM_SUBRF (proc) (arg1, arg2);
+}
+
+static SCM
+call_lsubr2_2 (SCM proc, SCM arg1, SCM arg2)
+{
+ return SCM_SUBRF (proc) (arg1, arg2, SCM_EOL);
+}
+
+static SCM
+call_lsubr_2 (SCM proc, SCM arg1, SCM arg2)
+{
+ return SCM_SUBRF (proc) (scm_list_2 (arg1, arg2));
+}
+
+static SCM
+call_closure_2 (SCM proc, SCM arg1, SCM arg2)
+{
+ const SCM env = SCM_EXTEND_ENV (SCM_CLOSURE_FORMALS (proc),
+ scm_list_2 (arg1, arg2),
+ SCM_ENV (proc));
+ const SCM result = scm_eval_body (SCM_CLOSURE_BODY (proc), env);
+ return result;
+}
+
+scm_t_trampoline_2
+scm_trampoline_2 (SCM proc)
+{
+ if (SCM_IMP (proc))
+ return NULL;
+ if (SCM_DEBUGGINGP)
+ return scm_call_2;
+ switch (SCM_TYP7 (proc))
+ {
+ case scm_tc7_subr_2:
+ case scm_tc7_subr_2o:
+ case scm_tc7_rpsubr:
+ case scm_tc7_asubr:
+ return call_subr2_2;
+ case scm_tc7_lsubr_2:
+ return call_lsubr2_2;
+ case scm_tc7_lsubr:
+ return call_lsubr_2;
+ case scm_tcs_closures:
+ {
+ SCM formals = SCM_CLOSURE_FORMALS (proc);
+ if (!SCM_NULLP (formals)
+ && (!SCM_CONSP (formals)
+ || (!SCM_NULLP (SCM_CDR (formals))
+ && (!SCM_CONSP (SCM_CDR (formals))
+ || !SCM_CONSP (SCM_CDDR (formals))))))
+ return call_closure_2;
+ else
+ return NULL;
+ }
+ case scm_tcs_struct:
+ if (SCM_OBJ_CLASS_FLAGS (proc) & SCM_CLASSF_PURE_GENERIC)
+ return scm_call_generic_2;
+ else if (!SCM_I_OPERATORP (proc))
+ return NULL;
+ return scm_call_2;
+ case scm_tc7_smob:
+ if (SCM_SMOB_APPLICABLE_P (proc))
+ return SCM_SMOB_DESCRIPTOR (proc).apply_2;
+ else
+ return NULL;
+ case scm_tc7_cclo:
+ case scm_tc7_pws:
+ return scm_call_2;
+ default:
+ return NULL; /* not applicable on two args */
+ }
+}
+
/* Typechecking for multi-argument MAP and FOR-EACH.
Verify that each element of the vector ARGV, except for the first,
SCM args,
const char *who)
{
- SCM *ve = SCM_VELTS (argv);
+ SCM const *ve = SCM_VELTS (argv);
long i;
for (i = SCM_VECTOR_LENGTH (argv) - 1; i >= 1; i--)
}
if (elt_len != len)
- scm_out_of_range (who, ve[i]);
+ scm_out_of_range_pos (who, ve[i], SCM_MAKINUM (i + 2));
}
scm_remember_upto_here_1 (argv);
long i, len;
SCM res = SCM_EOL;
SCM *pres = &res;
- SCM *ve = &args; /* Keep args from being optimized away. */
+ SCM const *ve = &args; /* Keep args from being optimized away. */
len = scm_ilength (arg1);
SCM_GASSERTn (len >= 0,
SCM_VALIDATE_REST_ARGUMENT (args);
if (SCM_NULLP (args))
{
+ scm_t_trampoline_1 call = scm_trampoline_1 (proc);
+ SCM_GASSERT2 (call, g_map, proc, arg1, SCM_ARG1, s_map);
+ while (SCM_NIMP (arg1))
+ {
+ *pres = scm_list_1 (call (proc, SCM_CAR (arg1)));
+ pres = SCM_CDRLOC (*pres);
+ arg1 = SCM_CDR (arg1);
+ }
+ return res;
+ }
+ if (SCM_NULLP (SCM_CDR (args)))
+ {
+ SCM arg2 = SCM_CAR (args);
+ int len2 = scm_ilength (arg2);
+ scm_t_trampoline_2 call = scm_trampoline_2 (proc);
+ SCM_GASSERTn (call,
+ g_map, scm_cons2 (proc, arg1, args), SCM_ARG1, s_map);
+ SCM_GASSERTn (len2 >= 0,
+ g_map, scm_cons2 (proc, arg1, args), SCM_ARG3, s_map);
+ if (len2 != len)
+ SCM_OUT_OF_RANGE (3, arg2);
while (SCM_NIMP (arg1))
{
- *pres = scm_list_1 (scm_apply (proc, SCM_CAR (arg1), scm_listofnull));
+ *pres = scm_list_1 (call (proc, SCM_CAR (arg1), SCM_CAR (arg2)));
pres = SCM_CDRLOC (*pres);
arg1 = SCM_CDR (arg1);
+ arg2 = SCM_CDR (arg2);
}
return res;
}
- args = scm_vector (arg1 = scm_cons (arg1, args));
+ arg1 = scm_cons (arg1, args);
+ args = scm_vector (arg1);
ve = SCM_VELTS (args);
-#ifndef SCM_RECKLESS
check_map_args (args, len, g_map, proc, arg1, s_map);
-#endif
while (1)
{
arg1 = SCM_EOL;
if (SCM_IMP (ve[i]))
return res;
arg1 = scm_cons (SCM_CAR (ve[i]), arg1);
- ve[i] = SCM_CDR (ve[i]);
+ SCM_VECTOR_SET (args, i, SCM_CDR (ve[i]));
}
*pres = scm_list_1 (scm_apply (proc, arg1, SCM_EOL));
pres = SCM_CDRLOC (*pres);
scm_for_each (SCM proc, SCM arg1, SCM args)
#define FUNC_NAME s_for_each
{
- SCM *ve = &args; /* Keep args from being optimized away. */
+ SCM const *ve = &args; /* Keep args from being optimized away. */
long i, len;
len = scm_ilength (arg1);
SCM_GASSERTn (len >= 0, g_for_each, scm_cons2 (proc, arg1, args),
SCM_VALIDATE_REST_ARGUMENT (args);
if (SCM_NULLP (args))
{
+ scm_t_trampoline_1 call = scm_trampoline_1 (proc);
+ SCM_GASSERT2 (call, g_for_each, proc, arg1, SCM_ARG1, s_for_each);
+ while (SCM_NIMP (arg1))
+ {
+ call (proc, SCM_CAR (arg1));
+ arg1 = SCM_CDR (arg1);
+ }
+ return SCM_UNSPECIFIED;
+ }
+ if (SCM_NULLP (SCM_CDR (args)))
+ {
+ SCM arg2 = SCM_CAR (args);
+ int len2 = scm_ilength (arg2);
+ scm_t_trampoline_2 call = scm_trampoline_2 (proc);
+ SCM_GASSERTn (call, g_for_each,
+ scm_cons2 (proc, arg1, args), SCM_ARG1, s_for_each);
+ SCM_GASSERTn (len2 >= 0, g_for_each,
+ scm_cons2 (proc, arg1, args), SCM_ARG3, s_for_each);
+ if (len2 != len)
+ SCM_OUT_OF_RANGE (3, arg2);
while (SCM_NIMP (arg1))
{
- scm_apply (proc, SCM_CAR (arg1), scm_listofnull);
+ call (proc, SCM_CAR (arg1), SCM_CAR (arg2));
arg1 = SCM_CDR (arg1);
+ arg2 = SCM_CDR (arg2);
}
return SCM_UNSPECIFIED;
}
- args = scm_vector (arg1 = scm_cons (arg1, args));
+ arg1 = scm_cons (arg1, args);
+ args = scm_vector (arg1);
ve = SCM_VELTS (args);
-#ifndef SCM_RECKLESS
check_map_args (args, len, g_for_each, proc, arg1, s_for_each);
-#endif
while (1)
{
arg1 = SCM_EOL;
if (SCM_IMP (ve[i]))
return SCM_UNSPECIFIED;
arg1 = scm_cons (SCM_CAR (ve[i]), arg1);
- ve[i] = SCM_CDR (ve[i]);
+ SCM_VECTOR_SET (args, i, SCM_CDR (ve[i]));
}
scm_apply (proc, arg1, SCM_EOL);
}
SCM
scm_makprom (SCM code)
{
- SCM_RETURN_NEWSMOB (scm_tc16_promise, SCM_UNPACK (code));
+ SCM_RETURN_NEWSMOB2 (scm_tc16_promise,
+ SCM_UNPACK (code),
+ scm_make_rec_mutex ());
}
-
+static size_t
+promise_free (SCM promise)
+{
+ scm_rec_mutex_free (SCM_PROMISE_MUTEX (promise));
+ return 0;
+}
static int
promise_print (SCM exp, SCM port, scm_print_state *pstate)
int writingp = SCM_WRITINGP (pstate);
scm_puts ("#<promise ", port);
SCM_SET_WRITINGP (pstate, 1);
- scm_iprin1 (SCM_CELL_OBJECT_1 (exp), port, pstate);
+ scm_iprin1 (SCM_PROMISE_DATA (exp), port, pstate);
SCM_SET_WRITINGP (pstate, writingp);
scm_putc ('>', port);
return !0;
}
-
SCM_DEFINE (scm_force, "force", 1, 0, 0,
- (SCM x),
+ (SCM promise),
"If the promise @var{x} has not been computed yet, compute and\n"
"return @var{x}, otherwise just return the previously computed\n"
"value.")
#define FUNC_NAME s_scm_force
{
- SCM_VALIDATE_SMOB (1, x, promise);
- if (!((1L << 16) & SCM_CELL_WORD_0 (x)))
+ SCM_VALIDATE_SMOB (1, promise, promise);
+ scm_rec_mutex_lock (SCM_PROMISE_MUTEX (promise));
+ if (!SCM_PROMISE_COMPUTED_P (promise))
{
- SCM ans = scm_call_0 (SCM_CELL_OBJECT_1 (x));
- if (!((1L << 16) & SCM_CELL_WORD_0 (x)))
+ SCM ans = scm_call_0 (SCM_PROMISE_DATA (promise));
+ if (!SCM_PROMISE_COMPUTED_P (promise))
{
- SCM_DEFER_INTS;
- SCM_SET_CELL_OBJECT_1 (x, ans);
- SCM_SET_CELL_WORD_0 (x, SCM_CELL_WORD_0 (x) | (1L << 16));
- SCM_ALLOW_INTS;
+ SCM_SET_PROMISE_DATA (promise, ans);
+ SCM_SET_PROMISE_COMPUTED (promise);
}
}
- return SCM_CELL_OBJECT_1 (x);
+ scm_rec_mutex_unlock (SCM_PROMISE_MUTEX (promise));
+ return SCM_PROMISE_DATA (promise);
}
#undef FUNC_NAME
unsigned long i = SCM_VECTOR_LENGTH (obj);
ans = scm_c_make_vector (i, SCM_UNSPECIFIED);
while (i--)
- SCM_VELTS (ans)[i] = scm_copy_tree (SCM_VELTS (obj)[i]);
+ SCM_VECTOR_SET (ans, i, scm_copy_tree (SCM_VELTS (obj)[i]));
return ans;
}
if (!SCM_CONSP (obj))
ans = tl = scm_cons_source (obj,
scm_copy_tree (SCM_CAR (obj)),
SCM_UNSPECIFIED);
- while (obj = SCM_CDR (obj), SCM_CONSP (obj))
+ for (obj = SCM_CDR (obj); SCM_CONSP (obj); obj = SCM_CDR (obj))
{
SCM_SETCDR (tl, scm_cons (scm_copy_tree (SCM_CAR (obj)),
SCM_UNSPECIFIED));
/* At this point, scm_deval and scm_dapply are generated.
*/
-#ifdef DEBUG_EXTENSIONS
-# define DEVAL
-# include "eval.c"
-#endif
-
+#define DEVAL
+#include "eval.c"
void
scm_tc16_promise = scm_make_smob_type ("promise", 0);
scm_set_smob_mark (scm_tc16_promise, scm_markcdr);
+ scm_set_smob_free (scm_tc16_promise, promise_free);
scm_set_smob_print (scm_tc16_promise, promise_print);
- /* Dirk:Fixme:: make scm_undefineds local to eval.c: it's only used here. */
- scm_undefineds = scm_list_1 (SCM_UNDEFINED);
- SCM_SETCDR (scm_undefineds, scm_undefineds);
- scm_listofnull = scm_list_1 (SCM_EOL);
+ undefineds = scm_list_1 (SCM_UNDEFINED);
+ SCM_SETCDR (undefineds, undefineds);
+ scm_permanent_object (undefineds);
- scm_f_apply = scm_c_define_subr ("apply", scm_tc7_lsubr_2, scm_apply);
+ scm_listofnull = scm_list_1 (SCM_EOL);
- /* acros */
- /* end of acros */
+ f_apply = scm_c_define_subr ("apply", scm_tc7_lsubr_2, scm_apply);
+ scm_permanent_object (f_apply);
-#ifndef SCM_MAGIC_SNARFER
#include "libguile/eval.x"
-#endif
scm_add_feature ("delay");
}