mes/type.c

103 lines
1.7 KiB
C
Raw Normal View History

/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* Mes 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 3 of the License, or (at
* your option) any later version.
*
* Mes 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#if !TYPE0
SCM
char_p (SCM x)
{
return type (x) == CHAR ? cell_t : cell_f;
}
SCM
macro_p (SCM x)
{
return type (x) == MACRO ? cell_t : cell_f;
}
SCM
number_p (SCM x)
{
return type (x) == NUMBER ? cell_t : cell_f;
}
SCM
pair_p (SCM x)
{
return type (x) == PAIR ? cell_t : cell_f;
}
SCM
ref_p (SCM x)
{
return type (x) == REF ? cell_t : cell_f;
}
SCM
string_p (SCM x)
{
return type (x) == STRING ? cell_t : cell_f;
}
SCM
symbol_p (SCM x)
{
return type (x) == SYMBOL ? cell_t : cell_f;
}
SCM
vector_p (SCM x)
{
return type (x) == VECTOR ? cell_t : cell_f;
}
SCM
builtin_p (SCM x)
{
return type (x) == FUNCTION ? cell_t : cell_f;
}
// Non-types
SCM
null_p (SCM x)
{
return x == cell_nil ? cell_t : cell_f;
}
SCM
atom_p (SCM x)
{
return (type (x) == PAIR ? cell_f : cell_t);
}
SCM
boolean_p (SCM x)
{
return (x == cell_t || x == cell_f) ? cell_t : cell_f;
}
#endif
SCM make_number (int);
SCM
mes_type_of (SCM x)
{
return make_number (type (x));
}