#define SCM_VALIDATE_NON_EMPTY_COMBINATION(x) \
do { \
if (SCM_EQ_P ((x), SCM_EOL)) \
- scm_misc_error (NULL, scm_s_expression, SCM_EOL); \
+ scm_misc_error (NULL, s_expression, SCM_EOL); \
} while (0)
\f
#define SCM_CEVAL scm_ceval
+#define SCM_EVALIM2(x) \
+ ((SCM_EQ_P ((x), SCM_EOL) \
+ ? scm_misc_error (NULL, s_expression, SCM_EOL), 0 \
+ : 0), \
+ (x))
+
+#define SCM_EVALIM(x, env) (SCM_ILOCP (x) \
+ ? *scm_ilookup ((x), env) \
+ : SCM_EVALIM2(x))
+
+#define SCM_XEVAL(x, env) (SCM_IMP (x) \
+ ? SCM_EVALIM2(x) \
+ : (*scm_ceval_ptr) ((x), (env)))
+
+#define SCM_XEVALCAR(x, env) (SCM_IMP (SCM_CAR (x)) \
+ ? SCM_EVALIM (SCM_CAR (x), env) \
+ : (SCM_SYMBOLP (SCM_CAR (x)) \
+ ? *scm_lookupcar (x, env, 1) \
+ : (*scm_ceval_ptr) (SCM_CAR (x), env)))
+
#define EVALCAR(x, env) (SCM_IMP (SCM_CAR (x)) \
? SCM_EVALIM (SCM_CAR (x), env) \
: (SCM_SYMBOLP (SCM_CAR (x)) \
SCM_REC_MUTEX (source_mutex);
+static const char s_expression[] = "missing or extra expression";
+static const char s_test[] = "bad test";
+static const char s_body[] = "bad body";
+static const char s_bindings[] = "bad bindings";
+static const char s_duplicate_bindings[] = "duplicate bindings";
+static const char s_variable[] = "bad variable";
+static const char s_clauses[] = "bad or missing clauses";
+static const char s_formals[] = "bad formals";
+static const char s_duplicate_formals[] = "duplicate formals";
+static const char s_splicing[] = "bad (non-list) result for unquote-splicing";
+
+
/* 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
* some memoized forms have different syntax
*/
-const char scm_s_expression[] = "missing or extra expression";
-const char scm_s_test[] = "bad test";
-const char scm_s_body[] = "bad body";
-const char scm_s_bindings[] = "bad bindings";
-const char scm_s_duplicate_bindings[] = "duplicate bindings";
-const char scm_s_variable[] = "bad variable";
-const char scm_s_clauses[] = "bad or missing clauses";
-const char scm_s_formals[] = "bad formals";
-const char scm_s_duplicate_formals[] = "duplicate formals";
-static const char s_splicing[] = "bad (non-list) result for unquote-splicing";
-
SCM_GLOBAL_SYMBOL (scm_sym_arrow, "=>");
SCM_GLOBAL_SYMBOL (scm_sym_else, "else");
SCM_GLOBAL_SYMBOL (scm_sym_unquote, "unquote");
static SCM
scm_m_body (SCM op, SCM xorig, const char *what)
{
- SCM_ASSYNT (scm_ilength (xorig) >= 1, scm_s_body, what);
+ SCM_ASSYNT (scm_ilength (xorig) >= 1, s_body, what);
/* Don't add another ISYM if one is present already. */
if (SCM_ISYMP (SCM_CAR (xorig)))
scm_m_and (SCM xorig, SCM env SCM_UNUSED)
{
long len = scm_ilength (SCM_CDR (xorig));
- SCM_ASSYNT (len >= 0, scm_s_test, s_and);
+ SCM_ASSYNT (len >= 0, s_test, s_and);
if (len >= 1)
return scm_cons (SCM_IM_AND, SCM_CDR (xorig));
else
SCM
scm_m_begin (SCM xorig, SCM env SCM_UNUSED)
{
- SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 0, scm_s_expression, s_begin);
+ SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) >= 0, s_expression, s_begin);
return scm_cons (SCM_IM_BEGIN, SCM_CDR (xorig));
}
{
SCM clauses;
SCM cdrx = SCM_CDR (xorig);
- SCM_ASSYNT (scm_ilength (cdrx) >= 2, scm_s_clauses, s_case);
+ SCM_ASSYNT (scm_ilength (cdrx) >= 2, s_clauses, s_case);
clauses = SCM_CDR (cdrx);
while (!SCM_NULLP (clauses))
{
SCM clause = SCM_CAR (clauses);
- SCM_ASSYNT (scm_ilength (clause) >= 2, scm_s_clauses, s_case);
+ SCM_ASSYNT (scm_ilength (clause) >= 2, s_clauses, s_case);
SCM_ASSYNT (scm_ilength (SCM_CAR (clause)) >= 0
|| (SCM_EQ_P (scm_sym_else, SCM_CAR (clause))
&& SCM_NULLP (SCM_CDR (clauses))),
- scm_s_clauses, s_case);
+ s_clauses, s_case);
clauses = SCM_CDR (clauses);
}
return scm_cons (SCM_IM_CASE, cdrx);
{
SCM cdrx = SCM_CDR (xorig);
SCM clauses = cdrx;
- SCM_ASSYNT (scm_ilength (clauses) >= 1, scm_s_clauses, s_cond);
+ SCM_ASSYNT (scm_ilength (clauses) >= 1, s_clauses, s_cond);
while (!SCM_NULLP (clauses))
{
SCM clause = SCM_CAR (clauses);
long len = scm_ilength (clause);
- SCM_ASSYNT (len >= 1, scm_s_clauses, s_cond);
+ SCM_ASSYNT (len >= 1, s_clauses, s_cond);
if (SCM_EQ_P (scm_sym_else, SCM_CAR (clause)))
{
int last_clause_p = SCM_NULLP (SCM_CDR (clauses));
{
SCM name;
x = SCM_CDR (x);
- SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_expression, s_define);
+ SCM_ASSYNT (scm_ilength (x) >= 2, s_expression, s_define);
name = SCM_CAR (x);
x = SCM_CDR (x);
while (SCM_CONSP (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);
+ SCM_ASSYNT (SCM_SYMBOLP (name), s_variable, s_define);
+ SCM_ASSYNT (scm_ilength (x) == 1, s_expression, s_define);
if (SCM_TOP_LEVEL (env))
{
SCM var;
SCM
scm_m_delay (SCM xorig, SCM env SCM_UNUSED)
{
- SCM_ASSYNT (scm_ilength (xorig) == 2, scm_s_expression, s_delay);
+ SCM_ASSYNT (scm_ilength (xorig) == 2, s_expression, s_delay);
return scm_cons2 (SCM_IM_DELAY, SCM_EOL, SCM_CDR (xorig));
}
SCM *initloc = &inits;
SCM steps = SCM_EOL;
SCM *steploc = &steps;
- SCM_ASSYNT (scm_ilength (x) >= 2, scm_s_test, "do");
+ SCM_ASSYNT (scm_ilength (x) >= 2, s_test, "do");
bindings = SCM_CAR (x);
- SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, "do");
+ SCM_ASSYNT (scm_ilength (bindings) >= 0, s_bindings, "do");
while (!SCM_NULLP (bindings))
{
SCM binding = SCM_CAR (bindings);
long len = scm_ilength (binding);
- SCM_ASSYNT (len == 2 || len == 3, scm_s_bindings, "do");
+ SCM_ASSYNT (len == 2 || len == 3, s_bindings, "do");
{
SCM name = SCM_CAR (binding);
SCM init = SCM_CADR (binding);
SCM step = (len == 2) ? name : SCM_CADDR (binding);
- SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_variable, "do");
+ SCM_ASSYNT (SCM_SYMBOLP (name), s_variable, "do");
vars = scm_cons (name, vars);
*initloc = scm_list_1 (init);
initloc = SCM_CDRLOC (*initloc);
}
}
x = SCM_CDR (x);
- SCM_ASSYNT (scm_ilength (SCM_CAR (x)) >= 1, scm_s_test, "do");
+ SCM_ASSYNT (scm_ilength (SCM_CAR (x)) >= 1, s_test, "do");
x = scm_cons2 (SCM_CAR (x), SCM_CDR (x), steps);
x = scm_cons2 (inits, vars, x);
return scm_cons (SCM_IM_DO, x);
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);
+ SCM_ASSYNT (len >= 2 && len <= 3, s_expression, s_if);
return scm_cons (SCM_IM_IF, SCM_CDR (xorig));
}
SCM formals;
SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (SCM_CONSP (x), scm_s_formals, s_lambda);
+ SCM_ASSYNT (SCM_CONSP (x), s_formals, s_lambda);
formals = SCM_CAR (x);
while (SCM_CONSP (formals))
{
SCM formal = SCM_CAR (formals);
- SCM_ASSYNT (SCM_SYMBOLP (formal), scm_s_formals, s_lambda);
+ SCM_ASSYNT (SCM_SYMBOLP (formal), s_formals, s_lambda);
if (scm_c_improper_memq (formal, SCM_CDR (formals)))
- scm_misc_error (s_lambda, scm_s_duplicate_formals, SCM_EOL);
+ scm_misc_error (s_lambda, s_duplicate_formals, SCM_EOL);
formals = SCM_CDR (formals);
}
if (!SCM_NULLP (formals) && !SCM_SYMBOLP (formals))
- scm_misc_error (s_lambda, scm_s_formals, SCM_EOL);
+ scm_misc_error (s_lambda, s_formals, SCM_EOL);
return scm_cons2 (SCM_IM_LAMBDA, SCM_CAR (x),
scm_m_body (SCM_IM_LAMBDA, SCM_CDR (x), s_lambda));
*rvarloc = SCM_EOL;
*initloc = SCM_EOL;
- SCM_ASSYNT (scm_ilength (bindings) >= 1, scm_s_bindings, what);
+ SCM_ASSYNT (scm_ilength (bindings) >= 1, s_bindings, what);
do
{
SCM binding = SCM_CAR (bindings);
- SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, what);
- SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, what);
+ SCM_ASSYNT (scm_ilength (binding) == 2, s_bindings, what);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), s_variable, what);
if (scm_c_improper_memq (SCM_CAR (binding), rvars))
- scm_misc_error (what, scm_s_duplicate_bindings, SCM_EOL);
+ scm_misc_error (what, s_duplicate_bindings, SCM_EOL);
rvars = scm_cons (SCM_CAR (binding), rvars);
*initloc = scm_list_1 (SCM_CADR (binding));
initloc = SCM_CDRLOC (*initloc);
SCM x = SCM_CDR (xorig);
SCM temp;
- SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_let);
+ SCM_ASSYNT (SCM_CONSP (x), s_bindings, s_let);
temp = SCM_CAR (x);
if (SCM_NULLP (temp)
|| (scm_ilength (temp) == 1 && SCM_CONSP (SCM_CAR (temp))))
SCM *initloc = &inits;
SCM bindings;
- SCM_ASSYNT (SCM_SYMBOLP (name), scm_s_bindings, s_let);
+ SCM_ASSYNT (SCM_SYMBOLP (name), s_bindings, s_let);
x = SCM_CDR (x);
- SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_let);
+ SCM_ASSYNT (SCM_CONSP (x), s_bindings, s_let);
bindings = SCM_CAR (x);
- SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_let);
+ SCM_ASSYNT (scm_ilength (bindings) >= 0, s_bindings, s_let);
while (!SCM_NULLP (bindings))
{ /* vars and inits both in order */
SCM binding = SCM_CAR (bindings);
- SCM_ASSYNT (scm_ilength (binding) == 2, scm_s_bindings, s_let);
- SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), scm_s_variable, s_let);
+ SCM_ASSYNT (scm_ilength (binding) == 2, s_bindings, s_let);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), s_variable, s_let);
*varloc = scm_list_1 (SCM_CAR (binding));
varloc = SCM_CDRLOC (*varloc);
*initloc = scm_list_1 (SCM_CADR (binding));
SCM vars = SCM_EOL;
SCM *varloc = &vars;
- SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letstar);
+ SCM_ASSYNT (SCM_CONSP (x), s_bindings, s_letstar);
bindings = SCM_CAR (x);
- SCM_ASSYNT (scm_ilength (bindings) >= 0, scm_s_bindings, s_letstar);
+ SCM_ASSYNT (scm_ilength (bindings) >= 0, 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);
+ SCM_ASSYNT (scm_ilength (binding) == 2, s_bindings, s_letstar);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (binding)), s_variable, s_letstar);
*varloc = scm_list_2 (SCM_CAR (binding), SCM_CADR (binding));
varloc = SCM_CDRLOC (SCM_CDR (*varloc));
bindings = SCM_CDR (bindings);
scm_m_letrec (SCM xorig, SCM env)
{
SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (SCM_CONSP (x), scm_s_bindings, s_letrec);
+ SCM_ASSYNT (SCM_CONSP (x), s_bindings, s_letrec);
if (SCM_NULLP (SCM_CAR (x)))
{
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);
+ SCM_ASSYNT (len >= 0, s_test, s_or);
if (len >= 1)
return scm_cons (SCM_IM_OR, SCM_CDR (xorig));
else
if (SCM_EQ_P (tmp, scm_sym_quasiquote))
{
SCM args = SCM_CDR (form);
- SCM_ASSYNT (scm_ilength (args) == 1, scm_s_expression, s_quasiquote);
+ SCM_ASSYNT (scm_ilength (args) == 1, 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);
+ SCM_ASSYNT (scm_ilength (args) == 1, s_expression, s_quasiquote);
if (depth - 1 == 0)
return scm_eval_car (args, env);
else
&& 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);
+ SCM_ASSYNT (scm_ilength (args) == 1, s_expression, s_quasiquote);
if (depth - 1 == 0)
{
SCM list = scm_eval_car (args, env);
scm_m_quasiquote (SCM xorig, SCM env)
{
SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (scm_ilength (x) == 1, scm_s_expression, s_quasiquote);
+ SCM_ASSYNT (scm_ilength (x) == 1, s_expression, s_quasiquote);
return iqq (SCM_CAR (x), env, 1);
}
SCM
scm_m_quote (SCM xorig, SCM env SCM_UNUSED)
{
- SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 1, scm_s_expression, s_quote);
+ SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 1, s_expression, s_quote);
return scm_cons (SCM_IM_QUOTE, SCM_CDR (xorig));
}
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);
+ SCM_ASSYNT (scm_ilength (x) == 2, s_expression, s_set_x);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (x)), s_variable, s_set_x);
return scm_cons (SCM_IM_SET_X, x);
}
SCM
scm_m_apply (SCM xorig, SCM env SCM_UNUSED)
{
- SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 2, scm_s_expression, s_atapply);
+ SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 2, s_expression, s_atapply);
return scm_cons (SCM_IM_APPLY, SCM_CDR (xorig));
}
SCM vars = SCM_EOL, var;
SCM exps = SCM_EOL;
- SCM_ASSYNT (scm_ilength (x) > 1, scm_s_expression, s_atbind);
+ SCM_ASSYNT (scm_ilength (x) > 1, 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);
+ SCM_ASSYNT (scm_ilength (sym_exp) == 2, s_bindings, s_atbind);
+ SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (sym_exp)), 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);
+ scm_misc_error (s_atbind, 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);
scm_m_cont (SCM xorig, SCM env SCM_UNUSED)
{
SCM_ASSYNT (scm_ilength (SCM_CDR (xorig)) == 1,
- scm_s_expression, s_atcall_cc);
+ s_expression, s_atcall_cc);
return scm_cons (SCM_IM_CONT, SCM_CDR (xorig));
}
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);
+ s_expression, s_at_call_with_values);
return scm_cons (SCM_IM_CALL_WITH_VALUES, SCM_CDR (xorig));
}
SCM
scm_m_future (SCM xorig, SCM env SCM_UNUSED)
{
- SCM_ASSYNT (scm_ilength (xorig) == 2, scm_s_expression, s_future);
+ SCM_ASSYNT (scm_ilength (xorig) == 2, s_expression, s_future);
return scm_cons2 (SCM_IM_FUTURE, SCM_EOL, SCM_CDR (xorig));
}
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);
+ SCM_ASSYNT (2 == scm_ilength (x), 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);
+ scm_misc_error (s_set_x, s_variable, SCM_EOL);
}
#define FUNC_NAME s_atslot_ref
{
SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (scm_ilength (x) == 2, scm_s_expression, FUNC_NAME);
+ SCM_ASSYNT (scm_ilength (x) == 2, s_expression, FUNC_NAME);
SCM_VALIDATE_INUM (SCM_ARG2, SCM_CADR (x));
return scm_cons (SCM_IM_SLOT_REF, x);
}
#define FUNC_NAME s_atslot_set_x
{
SCM x = SCM_CDR (xorig);
- SCM_ASSYNT (scm_ilength (x) == 3, scm_s_expression, FUNC_NAME);
+ SCM_ASSYNT (scm_ilength (x) == 3, s_expression, FUNC_NAME);
SCM_VALIDATE_INUM (SCM_ARG2, SCM_CADR (x));
return scm_cons (SCM_IM_SLOT_SET_X, x);
}
scm_m_nil_cond (SCM xorig, SCM env SCM_UNUSED)
{
long len = scm_ilength (SCM_CDR (xorig));
- SCM_ASSYNT (len >= 1 && (len & 1) == 1, scm_s_expression, "nil-cond");
+ SCM_ASSYNT (len >= 1 && (len & 1) == 1, s_expression, "nil-cond");
return scm_cons (SCM_IM_NIL_COND, SCM_CDR (xorig));
}
scm_m_atfop (SCM xorig, SCM env SCM_UNUSED)
{
SCM x = SCM_CDR (xorig), var;
- SCM_ASSYNT (scm_ilength (x) >= 1, scm_s_expression, "@fop");
+ SCM_ASSYNT (scm_ilength (x) >= 1, s_expression, "@fop");
var = scm_symbol_fref (SCM_CAR (x));
/* Passing the symbol name as the `subr' arg here isn't really
right, but without it it can be very difficult to work out from
x = SCM_CDR (x);
SCM_ASSYNT (SCM_TOP_LEVEL (env), "bad placement ", s_undefine);
SCM_ASSYNT (SCM_CONSP (x) && SCM_NULLP (SCM_CDR (x)),
- scm_s_expression, s_undefine);
+ s_expression, s_undefine);
x = SCM_CAR (x);
- SCM_ASSYNT (SCM_SYMBOLP (x), scm_s_variable, s_undefine);
+ SCM_ASSYNT (SCM_SYMBOLP (x), s_variable, s_undefine);
arg1 = scm_sym2var (x, scm_env_top_level (env), SCM_BOOL_F);
SCM_ASSYNT (!SCM_FALSEP (arg1) && !SCM_UNBNDP (SCM_VARIABLE_REF (arg1)),
"variable already unbound ", s_undefine);
}
else
{
- SCM_ASSYNT (SCM_CONSP (x), scm_s_body, what);
+ SCM_ASSYNT (SCM_CONSP (x), s_body, what);
SCM_SETCAR (xorig, SCM_CAR (x));
SCM_SETCDR (xorig, SCM_CDR (x));
}