* Minor cleanups to hashtable implementation.
* Minor code beautifications.
-/* Copyright (C) 1995, 96, 97, 98, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001 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
{
SCM pos;
pos = scm_asyncs;
- while (pos != SCM_EOL)
+ while (!SCM_NULLP (pos))
{
SCM a = SCM_CAR (pos);
if (ASYNC_GOT_IT (a))
"add it to the system's list of active async objects.")
#define FUNC_NAME s_scm_system_async
{
- SCM it;
- SCM list;
-
- it = scm_async (thunk);
- SCM_NEWCELL (list);
- SCM_SETCAR (list, it);
- SCM_SETCDR (list, scm_asyncs);
- scm_asyncs = list;
+ SCM it = scm_async (thunk);
+ scm_asyncs = scm_cons (it, scm_asyncs);
return it;
}
#undef FUNC_NAME
SCM
scm_reverse_lookup (SCM env, SCM data)
{
- SCM names, values;
- while (SCM_NIMP (env) && SCM_SLOPPY_CONSP (SCM_CAR (env)))
+ while (SCM_CONSP (env) && SCM_CONSP (SCM_CAR (env)))
{
- names = SCM_CAAR (env);
- values = SCM_CDAR (env);
+ SCM names = SCM_CAAR (env);
+ SCM values = SCM_CDAR (env);
while (SCM_CONSP (names))
{
if (SCM_EQ_P (SCM_CAR (values), data))
names = SCM_CDR (names);
values = SCM_CDR (values);
}
- if (! SCM_NULLP (names) && SCM_EQ_P (values, data))
+ if (!SCM_NULLP (names) && SCM_EQ_P (values, data))
return names;
env = SCM_CDR (env);
}
-/* Copyright (C) 1995,1996,1997,1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001 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
return SCM_BOOL_F;
if (SCM_IMP (y))
return SCM_BOOL_F;
- if (SCM_SLOPPY_CONSP (x) && SCM_SLOPPY_CONSP (y))
+ if (SCM_CONSP (x) && SCM_CONSP (y))
{
if (SCM_FALSEP (scm_equal_p (SCM_CAR (x), SCM_CAR (y))))
return SCM_BOOL_F;
-/* Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 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
? *scm_lookupcar (x, env, 1) \
: SCM_CEVAL (SCM_CAR (x), env))
-#define EVALCAR(x, env) (SCM_NCELLP (SCM_CAR (x)) \
+#define EVALCAR(x, env) (!SCM_CELLP (SCM_CAR (x)) \
? (SCM_IMP (SCM_CAR (x)) \
? SCM_EVALIM (SCM_CAR (x), env) \
: SCM_GLOC_VAL (SCM_CAR (x))) \
static SCM
-iqq (SCM form,SCM env,int depth)
+iqq (SCM form, SCM env, int depth)
{
SCM tmp;
int edepth = depth;
- if (SCM_IMP(form))
+ if (SCM_IMP (form))
return form;
if (SCM_VECTORP (form))
{
tmp = scm_cons (data[i], tmp);
return scm_vector (iqq (tmp, env, depth));
}
- if (SCM_NCONSP(form))
+ if (!SCM_CONSP (form))
return form;
tmp = SCM_CAR (form);
if (SCM_EQ_P (scm_sym_quasiquote, tmp))
return evalcar (form, env);
return scm_cons2 (tmp, iqq (SCM_CAR (form), env, depth), SCM_EOL);
}
- if (SCM_NIMP (tmp) && (SCM_EQ_P (scm_sym_uq_splicing, SCM_CAR (tmp))))
+ if (SCM_CONSP (tmp) && (SCM_EQ_P (scm_sym_uq_splicing, SCM_CAR (tmp))))
{
tmp = SCM_CDR (tmp);
if (0 == --edepth)
/* Only the first definition determines the name. */
&& SCM_FALSEP (scm_procedure_property (arg1, scm_sym_name)))
scm_set_procedure_property_x (arg1, scm_sym_name, proc);
- else if (SCM_TYP16 (arg1) == scm_tc16_macro
- && !SCM_EQ_P (SCM_CDR (arg1), arg1))
+ else if (SCM_MACROP (arg1)
+ /* Dirk::FIXME: Does the following test make sense? */
+ && !SCM_EQ_P (SCM_MACRO_CODE (arg1), arg1))
{
- arg1 = SCM_CDR (arg1);
+ arg1 = SCM_MACRO_CODE (arg1);
goto proc;
}
}
SCM
scm_m_expand_body (SCM xorig, SCM env)
{
- SCM form, x = SCM_CDR (xorig), defs = SCM_EOL;
+ SCM x = SCM_CDR (xorig), defs = SCM_EOL;
char *what = SCM_ISYMCHARS (SCM_CAR (xorig)) + 2;
while (SCM_NIMP (x))
{
- form = SCM_CAR (x);
- if (SCM_IMP (form) || SCM_NCONSP (form))
- break;
- if (SCM_IMP (SCM_CAR (form)))
+ SCM form = SCM_CAR (x);
+ if (!SCM_CONSP (form))
break;
if (!SCM_SYMBOLP (SCM_CAR (form)))
break;
-
+
form = scm_macroexp (scm_cons_source (form,
SCM_CAR (form),
SCM_CDR (form)),
if (SCM_EQ_P (SCM_IM_DEFINE, SCM_CAR (form)))
{
defs = scm_cons (SCM_CDR (form), defs);
- x = SCM_CDR(x);
+ x = SCM_CDR (x);
}
- else if (SCM_NIMP(defs))
+ else if (!SCM_IMP (defs))
{
break;
}
}
else
{
- x = scm_cons (form, SCM_CDR(x));
+ x = scm_cons (form, SCM_CDR (x));
break;
}
}
/* Only handle memoizing macros. `Acros' and `macros' are really
special forms and should not be evaluated here. */
- if (SCM_IMP (proc)
- || scm_tc16_macro != SCM_TYP16 (proc)
- || (SCM_CELL_WORD_0 (proc) >> 16) != 2)
+ if (!SCM_MACROP (proc) || SCM_MACRO_TYPE (proc) != 2)
return x;
unmemocar (x, env);
- res = scm_apply (SCM_CDR (proc), x, scm_cons (env, scm_listofnull));
+ res = scm_apply (SCM_MACRO_CODE (proc), x, scm_cons (env, scm_listofnull));
if (scm_ilength (res) <= 0)
res = scm_cons2 (SCM_IM_BEGIN, res, SCM_EOL);
scm_eval_args (SCM l, SCM env, SCM proc)
{
SCM results = SCM_EOL, *lloc = &results, res;
- while (SCM_NIMP (l))
+ while (!SCM_IMP (l))
{
#ifdef SCM_CAUTIOUS
if (SCM_CONSP (l))
l = SCM_CDR (l);
}
#ifdef SCM_CAUTIOUS
- if (SCM_NNULLP (l))
+ if (!SCM_NULLP (l))
{
wrongnumargs:
scm_wrong_num_args (proc);
scm_deval_args (SCM l, SCM env, SCM proc, SCM *lloc)
{
SCM *results = lloc, res;
- while (SCM_NIMP (l))
+ while (!SCM_IMP (l))
{
#ifdef SCM_CAUTIOUS
if (SCM_CONSP (l))
l = SCM_CDR (l);
}
#ifdef SCM_CAUTIOUS
- if (SCM_NNULLP (l))
+ if (!SCM_NULLP (l))
{
wrongnumargs:
scm_wrong_num_args (proc);
begin:
/* If we are on toplevel with a lookup closure, we need to sync
with the current module. */
- if (SCM_CONSP(env) && !SCM_CONSP(SCM_CAR(env)))
+ if (SCM_CONSP (env) && !SCM_CONSP (SCM_CAR (env)))
{
t.arg1 = x;
UPDATE_TOPLEVEL_ENV (env);
- while (SCM_NNULLP (t.arg1 = SCM_CDR (t.arg1)))
+ while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1)))
{
EVALCAR (x, env);
x = t.arg1;
x = SCM_CDR (x);
nontoplevel_begin:
t.arg1 = x;
- while (SCM_NNULLP (t.arg1 = SCM_CDR (t.arg1)))
+ while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1)))
{
if (SCM_IMP (SCM_CAR (x)))
{
goto nontoplevel_begin;
}
else
- SCM_EVALIM2 (SCM_CAR(x));
+ SCM_EVALIM2 (SCM_CAR (x));
}
else
SCM_CEVAL (SCM_CAR (x), env);
}
carloop: /* scm_eval car of last form in list */
- if (SCM_NCELLP (SCM_CAR (x)))
+ if (!SCM_CELLP (SCM_CAR (x)))
{
x = SCM_CAR (x);
RETURN (SCM_IMP (x) ? SCM_EVALIM (x, env) : SCM_GLOC_VAL (x))
case SCM_BIT8(SCM_IM_COND):
- while (SCM_NIMP (x = SCM_CDR (x)))
+ while (!SCM_IMP (x = SCM_CDR (x)))
{
proc = SCM_CAR (x);
t.arg1 = EVALCAR (proc, env);
if (SCM_NFALSEP (t.arg1))
{
x = SCM_CDR (proc);
- if SCM_NULLP (x)
+ if (SCM_NULLP (x))
{
RETURN (t.arg1)
}
- if (! SCM_EQ_P (scm_sym_arrow, SCM_CAR (x)))
+ if (!SCM_EQ_P (scm_sym_arrow, SCM_CAR (x)))
{
PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
goto begin;
case SCM_BIT8(SCM_IM_OR):
x = SCM_CDR (x);
t.arg1 = x;
- while (SCM_NNULLP (t.arg1 = SCM_CDR (t.arg1)))
+ while (!SCM_NULLP (t.arg1 = SCM_CDR (t.arg1)))
{
x = EVALCAR (x, env);
- if (SCM_NFALSEP (x))
+ if (!SCM_FALSEP (x))
{
RETURN (x);
}
unmemocar (x, env);
goto badfun;
}
- if (scm_tc16_macro == SCM_TYP16 (proc))
+ if (SCM_MACROP (proc))
{
unmemocar (x, env);
application frames can be deleted from the backtrace. */
SCM_SET_MACROEXP (debug);
#endif
- t.arg1 = SCM_APPLY (SCM_CDR (proc), x,
+ t.arg1 = SCM_APPLY (SCM_MACRO_CODE (proc), x,
scm_cons (env, scm_listofnull));
#ifdef DEVAL
SCM_CLEAR_MACROEXP (debug);
#endif
- switch (SCM_CELL_WORD_0 (proc) >> 16)
+ switch (SCM_MACRO_TYPE (proc))
{
case 2:
if (scm_ilength (t.arg1) <= 0)
t.arg1 = scm_cons2 (SCM_IM_BEGIN, t.arg1, SCM_EOL);
#ifdef DEVAL
- if (!SCM_CLOSUREP (SCM_CDR (proc)))
+ if (!SCM_CLOSUREP (SCM_MACRO_CODE (proc)))
{
SCM_DEFER_INTS;
SCM_SETCAR (x, SCM_CAR (t.arg1));
}
else
proc = SCM_CEVAL (SCM_CAR (x), env);
- SCM_ASRTGO (SCM_NIMP (proc), badfun);
+ SCM_ASRTGO (!SCM_IMP (proc), badfun);
#ifndef SCM_RECKLESS
#ifdef SCM_CAUTIOUS
checkargs:
{
arg2 = SCM_CAR (SCM_CODE (proc));
t.arg1 = SCM_CDR (x);
- while (SCM_NIMP (arg2))
+ while (!SCM_IMP (arg2))
{
- if (SCM_NCONSP (arg2))
+ if (!SCM_CONSP (arg2))
goto evapply;
if (SCM_IMP (t.arg1))
goto umwrongnumargs;
arg2 = SCM_CDR (arg2);
t.arg1 = SCM_CDR (t.arg1);
}
- if (SCM_NNULLP (t.arg1))
+ if (!SCM_NULLP (t.arg1))
goto umwrongnumargs;
}
- else if (scm_tc16_macro == SCM_TYP16 (proc))
+ else if (SCM_MACROP (proc))
goto handle_a_macro;
#endif
}
int writingp = SCM_WRITINGP (pstate);
scm_puts ("#<promise ", port);
SCM_SET_WRITINGP (pstate, 1);
- scm_iprin1 (SCM_CDR (exp), port, pstate);
+ scm_iprin1 (SCM_CELL_WORD_1 (exp), port, pstate);
SCM_SET_WRITINGP (pstate, writingp);
scm_putc ('>', port);
return !0;
/* classes: h_files */
-#ifndef EVALH
-#define EVALH
-/* Copyright (C) 1995, 1996 ,1998, 1999, 2000 Free Software Foundation, Inc.
+#ifndef SCM_EVAL_H
+#define SCM_EVAL_H
+/* Copyright (C) 1995,1996,1998,1999,2000,2001 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
extern SCM scm_f_apply;
-extern scm_bits_t scm_tc16_macro;
-
/* A resolved global variable reference in the CAR position
* of a list is stored (in code only) as a pointer to a pair with a
* tag of 1. This is called a "gloc".
extern void scm_init_eval (void);
-#endif /* EVALH */
+#endif /* SCM_EVAL_H */
/*
Local Variables:
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,2000,2001 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
void
scm_swap_fluids (SCM fluids, SCM vals)
{
- while (SCM_NIMP (fluids))
+ while (!SCM_NULLP (fluids))
{
SCM fl = SCM_CAR (fluids);
SCM old_val = scm_fluid_ref (fl);
void
scm_swap_fluids_reverse (SCM fluids, SCM vals)
{
- if (SCM_NIMP (fluids))
+ if (!SCM_NULLP (fluids))
{
SCM fl, old_val;
-/* Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 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
ptr = SCM_CDR (ptr);
goto gc_mark_loop;
case scm_tc7_pws:
- RECURSE (SCM_CELL_OBJECT_2 (ptr));
- ptr = SCM_CDR (ptr);
+ RECURSE (SCM_SETTER (ptr));
+ ptr = SCM_PROCEDURE (ptr);
goto gc_mark_loop;
case scm_tcs_cons_gloc:
{
}
break;
case scm_tcs_closures:
- if (SCM_IMP (SCM_CDR (ptr)))
+ if (SCM_IMP (SCM_ENV (ptr)))
{
ptr = SCM_CLOSCAR (ptr);
goto gc_mark_nimp;
}
RECURSE (SCM_CLOSCAR (ptr));
- ptr = SCM_CDR (ptr);
+ ptr = SCM_ENV (ptr);
goto gc_mark_nimp;
case scm_tc7_vector:
i = SCM_VECTOR_LENGTH (ptr);
if (!SCM_NULLP (freelist->cells))
{
SCM c = freelist->cells;
- SCM_SETCAR (c, SCM_CDR (c));
- SCM_SETCDR (c, SCM_EOL);
+ SCM_SET_CELL_WORD_0 (c, SCM_FREE_CELL_CDR (c));
+ SCM_SET_CELL_WORD_1 (c, SCM_EOL);
freelist->collected +=
freelist->span * (freelist->cluster_size - freelist->left_to_collect);
}
SCM_SETSTREAM (scmptr, 0);
scm_remove_from_port_table (scmptr);
scm_gc_ports_collected++;
- SCM_SETAND_CAR (scmptr, ~SCM_OPN);
+ SCM_CLR_PORT_OPEN_FLAG (scmptr);
}
break;
case scm_tc7_smob:
if (!--left_to_collect)
{
- SCM_SETCAR (scmptr, nfreelist);
+ SCM_SET_CELL_WORD_0 (scmptr, nfreelist);
*freelist->clustertail = scmptr;
freelist->clustertail = SCM_CDRLOC (scmptr);
}
SCM_SET_CELL_TYPE (scmptr, scm_tc_free_cell);
- SCM_SETCDR (scmptr, PTR2SCM (nxt));
+ SCM_SET_FREE_CELL_CDR (scmptr, PTR2SCM (nxt));
ptr = nxt;
}
handle = scm_hashq_get_handle (scm_protects, obj);
- if (SCM_IMP (handle))
+ if (SCM_FALSEP (handle))
{
fprintf (stderr, "scm_unprotect_object called on unprotected object\n");
abort ();
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998,1999,2000,2001 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
#define TCONC_IN(tc, obj, pair) \
do { \
SCM_SETCAR ((tc).tail, obj); \
- SCM_SETCAR (pair, SCM_BOOL_F); \
- SCM_SETCDR (pair, SCM_EOL); \
+ SCM_SET_CELL_WORD_0 (pair, SCM_BOOL_F); \
+ SCM_SET_CELL_WORD_1 (pair, SCM_EOL); \
SCM_SETCDR ((tc).tail, pair); \
(tc).tail = pair; \
} while (0)
if (GREEDY_P (g))
{
- if (SCM_NFALSEP (scm_hashq_get_handle
+ if (!SCM_FALSEP (scm_hashq_get_handle
(greedily_guarded_whash, obj)))
{
SCM_ALLOW_INTS;
-/* Copyright (C) 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001 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
return scm_c_make_vector (k, SCM_EOL);
}
+
SCM
scm_hash_fn_get_handle (SCM table,SCM obj,unsigned int (*hash_fn)(),SCM (*assoc_fn)(),void * closure)
+#define FUNC_NAME "scm_hash_fn_get_handle"
{
unsigned int k;
SCM h;
- SCM_ASSERT (SCM_VECTORP (table), table, SCM_ARG1, "hash_fn_get_handle");
+ SCM_VALIDATE_VECTOR (1, table);
if (SCM_VECTOR_LENGTH (table) == 0)
- return SCM_EOL;
+ return SCM_BOOL_F;
k = hash_fn (obj, SCM_VECTOR_LENGTH (table), closure);
if (k >= SCM_VECTOR_LENGTH (table))
scm_out_of_range ("hash_fn_get_handle", scm_ulong2num (k));
h = assoc_fn (obj, SCM_VELTS (table)[k], closure);
return h;
}
+#undef FUNC_NAME
SCM
scm_hash_fn_ref (SCM table,SCM obj,SCM dflt,unsigned int (*hash_fn)(),
SCM (*assoc_fn)(),void * closure)
{
- SCM it;
-
- it = scm_hash_fn_get_handle (table, obj, hash_fn, assoc_fn, closure);
- if (SCM_IMP (it))
- return dflt;
- else
+ SCM it = scm_hash_fn_get_handle (table, obj, hash_fn, assoc_fn, closure);
+ if (SCM_CONSP (it))
return SCM_CDR (it);
+ else
+ return dflt;
}
\f
SCM_DEFINE (scm_hashq_get_handle, "hashq-get-handle", 2, 0, 0,
- (SCM table, SCM obj),
- "This procedure is similar to its @code{-ref} cousin, but returns a\n"
- "@dfn{handle} from the hash table rather than the value associated with\n"
- "@var{key}. By convention, a handle in a hash table is the pair which\n"
- "associates a key with a value. Where @code{hashq-ref table key} returns\n"
- "only a @code{value}, @code{hashq-get-handle table key} returns the pair\n"
- "@code{(key . value)}.")
+ (SCM table, SCM key),
+ "This procedure returns the @code{(key . value)} pair from the\n"
+ "hash table @var{table}. If @var{table} does not hold an\n"
+ "associated value for @var{key}, @code{#f} is returned.\n"
+ "Uses @code{eq?} for equality testing.")
#define FUNC_NAME s_scm_hashq_get_handle
{
- return scm_hash_fn_get_handle (table, obj, scm_ihashq, scm_sloppy_assq, 0);
+ return scm_hash_fn_get_handle (table, key, scm_ihashq, scm_sloppy_assq, 0);
}
#undef FUNC_NAME
\f
SCM_DEFINE (scm_hashv_get_handle, "hashv-get-handle", 2, 0, 0,
- (SCM table, SCM obj),
- "This procedure is similar to its @code{-ref} cousin, but returns a\n"
- "@dfn{handle} from the hash table rather than the value associated with\n"
- "@var{key}. By convention, a handle in a hash table is the pair which\n"
- "associates a key with a value. Where @code{hashv-ref table key} returns\n"
- "only a @code{value}, @code{hashv-get-handle table key} returns the pair\n"
- "@code{(key . value)}.")
+ (SCM table, SCM key),
+ "This procedure returns the @code{(key . value)} pair from the\n"
+ "hash table @var{table}. If @var{table} does not hold an\n"
+ "associated value for @var{key}, @code{#f} is returned.\n"
+ "Uses @code{eqv?} for equality testing.")
#define FUNC_NAME s_scm_hashv_get_handle
{
- return scm_hash_fn_get_handle (table, obj, scm_ihashv, scm_sloppy_assv, 0);
+ return scm_hash_fn_get_handle (table, key, scm_ihashv, scm_sloppy_assv, 0);
}
#undef FUNC_NAME
\f
SCM_DEFINE (scm_hash_get_handle, "hash-get-handle", 2, 0, 0,
- (SCM table, SCM obj),
- "This procedure is similar to its @code{-ref} cousin, but returns a\n"
- "@dfn{handle} from the hash table rather than the value associated with\n"
- "@var{key}. By convention, a handle in a hash table is the pair which\n"
- "associates a key with a value. Where @code{hash-ref table key} returns\n"
- "only a @code{value}, @code{hash-get-handle table key} returns the pair\n"
- "@code{(key . value)}.")
+ (SCM table, SCM key),
+ "This procedure returns the @code{(key . value)} pair from the\n"
+ "hash table @var{table}. If @var{table} does not hold an\n"
+ "associated value for @var{key}, @code{#f} is returned.\n"
+ "Uses @code{equal?} for equality testing.")
#define FUNC_NAME s_scm_hash_get_handle
{
- return scm_hash_fn_get_handle (table, obj, scm_ihash, scm_sloppy_assoc, 0);
+ return scm_hash_fn_get_handle (table, key, scm_ihash, scm_sloppy_assoc, 0);
}
#undef FUNC_NAME
for (i = 0; i < n; ++i)
{
SCM ls = SCM_VELTS (table)[i], handle;
- while (SCM_NNULLP (ls))
+ while (!SCM_NULLP (ls))
{
SCM_ASSERT (SCM_CONSP (ls),
table, SCM_ARG1, s_scm_hash_fold);
-/* Copyright (C) 1995,1996,1997,1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 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
"Returns @code{#t} if the argument @var{obj} is a keyword, else @code{#f}.")
#define FUNC_NAME s_scm_keyword_p
{
- return SCM_BOOL(SCM_KEYWORDP (obj));
+ return SCM_BOOL (SCM_KEYWORDP (obj));
}
#undef FUNC_NAME
"This is the inverse of @code{make-keyword-from-dash-symbol}.")
#define FUNC_NAME s_scm_keyword_dash_symbol
{
- SCM_VALIDATE_KEYWORD (1,keyword);
- return SCM_CDR (keyword);
+ SCM_VALIDATE_KEYWORD (1, keyword);
+ return SCM_KEYWORDSYM (keyword);
}
#undef FUNC_NAME
/* classes: h_files */
-#ifndef MACROSH
-#define MACROSH
-/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+#ifndef SCM_MACROS_H
+#define SCM_MACROS_H
+/* Copyright (C) 1998,2000,2001 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
#define SCM_ASSYNT(_cond, _msg, _subr) \
if (!(_cond)) scm_misc_error (_subr, _msg, SCM_EOL);
+#define SCM_MACROP(x) SCM_TYP16_PREDICATE (scm_tc16_macro, (x))
+#define SCM_MACRO_TYPE(m) (SCM_CELL_WORD_0 (m) >> 16)
+#define SCM_MACRO_CODE(m) SCM_CELL_OBJECT_1 (m)
+
extern scm_bits_t scm_tc16_macro;
extern SCM scm_makacro (SCM code);
SCM (*fcn) ());
extern void scm_init_macros (void);
-#endif /* MACROSH */
+#endif /* SCM_MACROS_H */
/*
Local Variables:
else
rv = 0;
scm_remove_from_port_table (port);
- SCM_SETAND_CAR (port, ~SCM_OPN);
+ SCM_CLR_PORT_OPEN_FLAG (port);
return SCM_NEGATE_BOOL (rv < 0);
}
#undef FUNC_NAME
/* classes: h_files */
-#ifndef PORTSH
-#define PORTSH
-/* Copyright (C) 1995,1996,1997,1998,1999, 2000, 2001 Free Software Foundation, Inc.
+#ifndef SCM_PORTS_H
+#define SCM_PORTS_H
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 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
#define SCM_BUF0 (8L<<16) /* Is it unbuffered? */
#define SCM_BUFLINE (64L<<16) /* Is it line-buffered? */
-#define SCM_PORTP(x) (SCM_NIMP(x) && (SCM_TYP7(x)==scm_tc7_port))
+#define SCM_PORTP(x) (SCM_NIMP (x) && (SCM_TYP7 (x) == scm_tc7_port))
#define SCM_OPPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_OPN)))
#define SCM_OPINPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_RDNG) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG)))
#define SCM_OPOUTPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_WRTNG) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG)))
&& (((0x7f | SCM_WRTNG) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_WRTNG)))
#define SCM_OPENP(x) (SCM_NIMP(x) && (SCM_OPN & SCM_CELL_WORD_0 (x)))
#define SCM_CLOSEDP(x) (!SCM_OPENP(x))
+#define SCM_CLR_PORT_OPEN_FLAG(p) \
+ SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) & ~SCM_OPN)
#define SCM_PTAB_ENTRY(x) ((scm_port *) SCM_CELL_WORD_1 (x))
#define SCM_SETPTAB_ENTRY(x,ent) (SCM_SET_CELL_WORD_1 ((x), (scm_bits_t) (ent)))
#endif /* SCM_DEBUG_DEPRECATED == 0 */
-#endif /* PORTSH */
+#endif /* SCM_PORTS_H */
/*
Local Variables:
-/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1999,2000,2001 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
pstate->revealed = 0;
SCM_NEWCELL (handle);
SCM_DEFER_INTS;
- SCM_SETCAR (handle, print_state);
- SCM_SETCDR (handle, SCM_CDR (print_state_pool));
+ SCM_SET_CELL_WORD_0 (handle, print_state);
+ SCM_SET_CELL_WORD_1 (handle, SCM_CDR (print_state_pool));
SCM_SETCDR (print_state_pool, handle);
SCM_ALLOW_INTS;
}
exp, port, pstate)))
{
SCM name, code, env;
- if (SCM_TYP16 (exp) == scm_tc16_macro)
+ if (SCM_MACROP (exp))
{
/* Printing a macro. */
prinmacro:
scm_putc ('>', port);
}
-/* Print a list.
- */
-
+/* Print a list. The list may be either a list of ordinary data, or it may be
+ a list that represents code. Lists that represent code may contain gloc
+ cells.
+ */
void
scm_iprlist (char *hdr,SCM exp,int tlr,SCM port,scm_print_state *pstate)
{
/* No cdr cycles intrinsic to this list */
scm_iprin1 (SCM_CAR (exp), port, pstate);
- exp = SCM_CDR (exp);
- for (; SCM_NIMP (exp); exp = SCM_CDR (exp))
+ for (exp = SCM_CDR (exp); SCM_ECONSP (exp); exp = SCM_CDR (exp))
{
register int i;
- if (SCM_NECONSP (exp))
- break;
for (i = floor; i >= 0; --i)
if (SCM_EQ_P (pstate->ref_stack[i], exp))
goto circref;
/* CHECK_INTS; */
scm_iprin1 (SCM_CAR (exp), port, pstate);
}
- if (SCM_NNULLP (exp))
+ if (!SCM_NULLP (exp))
{
scm_puts (" . ", port);
scm_iprin1 (exp, port, pstate);
scm_iprin1 (SCM_CAR (exp), port, pstate);
exp = SCM_CDR (exp); --n;
- for (; SCM_NIMP (exp); exp = SCM_CDR (exp))
+ for (; SCM_ECONSP (exp); exp = SCM_CDR (exp))
{
register unsigned long i;
- if (SCM_NECONSP (exp))
- break;
for (i = 0; i < pstate->top; ++i)
if (SCM_EQ_P (pstate->ref_stack[i], exp))
goto fancy_circref;
/* classes: h_files */
-#ifndef PROCSH
-#define PROCSH
-/* Copyright (C) 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
+#ifndef SCM_PROCS_H
+#define SCM_PROCS_H
+/* Copyright (C) 1995,1996,1998,1999,2000,2001 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
#define SCM_SETPROCPROPS(x, p) SCM_SETCDR (SCM_CLOSCAR (x), p)
#define SCM_SETCODE(x, e) (SCM_SET_CELL_WORD_0 (x, SCM_UNPACK (scm_cons ((e), SCM_EOL)) \
+ scm_tc3_closure))
-#define SCM_ENV(x) SCM_CDR(x)
-#define SCM_SETENV(x, e) SCM_SETCDR (x, e)
+#define SCM_ENV(x) SCM_CELL_OBJECT_1 (x)
+#define SCM_SETENV(x, e) SCM_SET_CELL_OBJECT_1 ((x), (e))
#define SCM_TOP_LEVEL(ENV) (SCM_NULLP (ENV) || (SCM_EQ_P (scm_procedure_p (SCM_CAR (ENV)), SCM_BOOL_T)))
/* Procedure-with-setter
#endif /* SCM_DEBUG_DEPRECATED == 0 */
-#endif /* PROCSH */
+#endif /* SCM_PROCS_H */
/*
Local Variables:
-/* Copyright (C) 1995,1996, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,2000,2001 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
}
#undef FUNC_NAME
+
SCM_DEFINE (scm_primitive_property_ref, "primitive-property-ref", 2, 0, 0,
(SCM prop, SCM obj),
"Return the property @var{prop} of @var{obj}. When no value\n"
"default value of @var{prop}.")
#define FUNC_NAME s_scm_primitive_property_ref
{
- SCM h, assoc;
+ SCM h;
SCM_VALIDATE_CONS (SCM_ARG1, prop);
h = scm_hashq_get_handle (scm_properties_whash, obj);
- assoc = (SCM_NIMP (h) ? scm_assq (prop, SCM_CDR (h)) : SCM_BOOL_F);
- if (SCM_NIMP (assoc))
- return SCM_CDR (assoc);
+ if (!SCM_FALSEP (h))
+ {
+ SCM assoc = scm_assq (prop, SCM_CDR (h));
+ if (!SCM_FALSEP (assoc))
+ return SCM_CDR (assoc);
+ }
if (SCM_FALSEP (SCM_CAR (prop)))
return SCM_BOOL_F;
else
{
- SCM val = scm_apply (SCM_CAR (prop),
- SCM_LIST2 (prop, obj), SCM_EOL);
- if (SCM_IMP (h))
+ SCM val = scm_apply (SCM_CAR (prop), SCM_LIST2 (prop, obj), SCM_EOL);
+ if (SCM_FALSEP (h))
h = scm_hashq_create_handle_x (scm_properties_whash, obj, SCM_EOL);
SCM_SETCDR (h, scm_acons (prop, val, SCM_CDR (h)));
return val;
}
#undef FUNC_NAME
+
SCM_DEFINE (scm_primitive_property_set_x, "primitive-property-set!", 3, 0, 0,
(SCM prop, SCM obj, SCM val),
"Associate @var{code} with @var{prop} and @var{obj}.")
}
#undef FUNC_NAME
+
SCM_DEFINE (scm_primitive_property_del_x, "primitive-property-del!", 2, 0, 0,
(SCM prop, SCM obj),
"Remove any value associated with @var{prop} and @var{obj}.")
SCM h;
SCM_VALIDATE_CONS (SCM_ARG1, prop);
h = scm_hashq_get_handle (scm_properties_whash, obj);
- if (SCM_NIMP (h))
+ if (!SCM_FALSEP (h))
SCM_SETCDR (h, scm_assq_remove_x (SCM_CDR (h), prop));
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
+
void
scm_init_properties ()
{
}
SCM
+/* Dirk::FIXME: The name markcdr is misleading, since the term cdr should only
+ be used for real pairs. */
scm_markcdr (SCM ptr)
{
- return SCM_CDR (ptr);
+ return SCM_CELL_OBJECT_1 (ptr);
}
/* {Free}
/* classes: h_files */
-#ifndef TAGSH
-#define TAGSH
-/* Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+#ifndef SCM_TAGS_H
+#define SCM_TAGS_H
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 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
* stored in the SCM_CAR of a non-immediate object have a 1 in bit 1:
*/
-#define SCM_SLOPPY_CONSP(x) ((1 & SCM_CELL_TYPE (x)) == 0)
-#define SCM_SLOPPY_NCONSP(x) (!SCM_SLOPPY_CONSP(x))
-
-#define SCM_CONSP(x) (!SCM_IMP (x) && SCM_SLOPPY_CONSP (x))
+#define SCM_CONSP(x) (!SCM_IMP (x) && ((1 & SCM_CELL_TYPE (x)) == 0))
#define SCM_NCONSP(x) (!SCM_CONSP (x))
*/
#define SCM_ECONSP(x) \
(!SCM_IMP (x) \
- && (SCM_SLOPPY_CONSP (x) \
+ && (SCM_CONSP (x) \
|| (SCM_TYP3 (x) == 1 \
&& (SCM_STRUCT_VTABLE_DATA (x)[scm_vtable_index_vcell] != 0))))
#define SCM_NECONSP(x) (!SCM_ECONSP (x))
#if (SCM_DEBUG_DEPRECATED == 0)
+#define SCM_SLOPPY_CONSP(x) ((1 & SCM_CELL_TYPE (x)) == 0)
+#define SCM_SLOPPY_NCONSP(x) (!SCM_SLOPPY_CONSP(x))
+
#define scm_tc7_ssymbol scm_tc7_symbol
#define scm_tc7_msymbol scm_tc7_symbol
#define scm_tcs_symbols scm_tc7_symbol
#endif /* SCM_DEBUG_DEPRECATED == 0 */
-#endif /* TAGSH */
+#endif /* SCM_TAGS_H */
/*
Local Variables:
-/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001 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
#define SCM_JMPBUFP(OBJ) SCM_TYP16_PREDICATE (tc16_jmpbuffer, OBJ)
#define JBACTIVE(OBJ) (SCM_CELL_WORD_0 (OBJ) & (1L << 16L))
-#define ACTIVATEJB(OBJ) (SCM_SETOR_CAR (OBJ, (1L << 16L)))
-#define DEACTIVATEJB(OBJ) (SCM_SETAND_CAR (OBJ, ~(1L << 16L)))
+#define ACTIVATEJB(x) \
+ (SCM_SET_CELL_WORD_0 ((x), (SCM_CELL_WORD_0 (x) | (1L << 16L))))
+#define DEACTIVATEJB(x) \
+ (SCM_SET_CELL_WORD_0 ((x), (SCM_CELL_WORD_0 (x) & ~(1L << 16L))))
#define JBJMPBUF(OBJ) ((jmp_buf *) SCM_CELL_WORD_1 (OBJ))
#define SETJBJMPBUF(x,v) (SCM_SET_CELL_WORD_1 ((x), (v)))
-/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001 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
variable_print (SCM exp, SCM port, scm_print_state *pstate)
{
scm_puts ("#<variable ", port);
- scm_intprint(SCM_UNPACK (exp), 16, port);
+ scm_intprint (SCM_UNPACK (exp), 16, port);
{
- SCM val_cell;
- val_cell = SCM_CDR(exp);
- if (!SCM_UNBNDP (SCM_CAR (val_cell)))
+ SCM vcell = SCM_VARVCELL (exp);
+ if (!SCM_UNBNDP (SCM_CAR (vcell)))
{
scm_puts (" name: ", port);
- scm_iprin1 (SCM_CAR (val_cell), port, pstate);
+ scm_iprin1 (SCM_CAR (vcell), port, pstate);
}
scm_puts (" binding: ", port);
- scm_iprin1 (SCM_CDR (val_cell), port, pstate);
+ scm_iprin1 (SCM_CDR (vcell), port, pstate);
}
scm_putc('>', port);
return 1;
static SCM
variable_equalp (SCM var1, SCM var2)
{
- return scm_equal_p (SCM_CDR (var1), SCM_CDR (var2));
+ return scm_equal_p (SCM_VARVCELL (var1), SCM_VARVCELL (var2));
}
\f
"variable may exist, so @var{name-hint} is just that---a hint.\n")
#define FUNC_NAME s_scm_make_variable
{
- SCM val_cell;
+ SCM vcell;
if (SCM_UNBNDP (name_hint))
name_hint = anonymous_variable_sym;
- SCM_NEWCELL(val_cell);
- SCM_DEFER_INTS;
- SCM_SETCAR (val_cell, name_hint);
- SCM_SETCDR (val_cell, init);
- SCM_ALLOW_INTS;
- return make_vcell_variable (val_cell);
+ vcell = scm_cons (name_hint, init);
+ return make_vcell_variable (vcell);
}
#undef FUNC_NAME
if (SCM_UNBNDP (name_hint))
name_hint = anonymous_variable_sym;
- SCM_NEWCELL (vcell);
- SCM_DEFER_INTS;
- SCM_SETCAR (vcell, name_hint);
- SCM_SETCDR (vcell, SCM_UNDEFINED);
- SCM_ALLOW_INTS;
+ vcell = scm_cons (name_hint, SCM_UNDEFINED);
return make_vcell_variable (vcell);
}
#undef FUNC_NAME
#define FUNC_NAME s_scm_variable_ref
{
SCM_VALIDATE_VARIABLE (1, var);
- return SCM_CDR (SCM_CDR (var));
+ return SCM_CDR (SCM_VARVCELL (var));
}
#undef FUNC_NAME
"value. Return an unspecified value.\n")
#define FUNC_NAME s_scm_variable_set_x
{
- SCM_VALIDATE_VARIABLE (1,var);
- SCM_SETCDR (SCM_CDR (var), val);
+ SCM_VALIDATE_VARIABLE (1, var);
+ SCM_SETCDR (SCM_VARVCELL (var), val);
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
"Throws an error if @var{var} is not a variable object.\n")
#define FUNC_NAME s_scm_variable_bound_p
{
- SCM_VALIDATE_VARIABLE (1,var);
- return SCM_NEGATE_BOOL(SCM_UNBNDP (SCM_CDR (SCM_VARVCELL (var))));
+ SCM_VALIDATE_VARIABLE (1, var);
+ return SCM_BOOL (!SCM_UNBNDP (SCM_CDR (SCM_VARVCELL (var))));
}
#undef FUNC_NAME
/* classes: h_files */
-#ifndef VARIABLEH
-#define VARIABLEH
-/* Copyright (C) 1995,1996, 2000 Free Software Foundation, Inc.
+#ifndef SCM_VARIABLE_H
+#define SCM_VARIABLE_H
+/* Copyright (C) 1995,1996,2000,2001 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
*/
extern scm_bits_t scm_tc16_variable;
-#define SCM_VARVCELL(V) SCM_CDR(V)
+#define SCM_VARVCELL(V) SCM_CELL_OBJECT_1 (V)
#define SCM_VARIABLEP(X) (!SCM_IMP (X) && SCM_CELL_TYPE (X) == scm_tc16_variable)
#define SCM_UDVARIABLEP(X) (SCM_VARIABLEP(X) && SCM_UNBNDP (SCM_CDR (SCM_VARVCELL (X))))
#define SCM_DEFVARIABLEP(X) (SCM_VARIABLEP(X) && !SCM_UNBNDP (SCM_CDR (SCM_VARVCELL (X))))
extern SCM scm_variable_bound_p (SCM var);
extern void scm_init_variable (void);
-#endif /* VARIABLEH */
+#endif /* SCM_VARIABLE_H */
/*
Local Variables:
-/* Copyright (C) 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001 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
#define FUNC_NAME s_scm_vector
{
SCM res;
- register SCM *data;
- int i;
- SCM_VALIDATE_LIST_COPYLEN (1,l,i);
+ SCM *data;
+ long i;
+
+ /* Dirk:FIXME:: In case of multiple threads, the list might get corrupted
+ while the vector is being created. */
+ SCM_VALIDATE_LIST_COPYLEN (1, l, i);
res = scm_c_make_vector (i, SCM_UNSPECIFIED);
data = SCM_VELTS (res);
- for(; i && SCM_NIMP(l); --i, l = SCM_CDR (l))
- *data++ = SCM_CAR (l);
+ while (!SCM_NULLP (l))
+ {
+ *data++ = SCM_CAR (l);
+ l = SCM_CDR (l);
+ }
+
return res;
}
#undef FUNC_NAME
-/* Copyright (C) 1995,1996,1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000,2001 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
#define FUNC_NAME s_scm_weak_vector
{
SCM res;
- register SCM *data;
+ SCM *data;
long i;
+ /* Dirk:FIXME:: In case of multiple threads, the list might get corrupted
+ while the vector is being created. */
i = scm_ilength (l);
SCM_ASSERT (i >= 0, l, SCM_ARG1, FUNC_NAME);
res = scm_make_weak_vector (SCM_MAKINUM (i), SCM_UNSPECIFIED);
data = SCM_VELTS (res);
- for (;
- i && SCM_CONSP (l);
- --i, l = SCM_CDR (l))
- *data++ = SCM_CAR (l);
+
+ while (!SCM_NULLP (l))
+ {
+ *data++ = SCM_CAR (l);
+ l = SCM_CDR (l);
+ }
+
return res;
}
#undef FUNC_NAME