2
reference.c -- Reference in Constants and Variables.
5
Copyright (c) 1984, Taiichi Yuasa and Masami Hagiya.
6
Copyright (c) 1990, Giuseppe Attardi.
7
Copyright (c) 2001, Juan Jose Garcia Ripoll.
9
ECL is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public
11
License as published by the Free Software Foundation; either
12
version 2 of the License, or (at your option) any later version.
14
See file '../Copyright' for full details.
18
#include <ecl/ecl-inl.h>
21
Symbol-function returns
22
function-closure for function
23
(macro . function-closure) for macros
24
special for special forms.
27
cl_symbol_function(cl_object sym)
31
assert_type_symbol(sym);
32
if (sym->symbol.isform)
34
else if (SYM_FUN(sym) == Cnil)
35
FEundefined_function(sym);
36
else if (sym->symbol.mflag)
37
output = CONS(@'si::macro', SYM_FUN(sym));
39
output = SYM_FUN(sym);
44
cl_fdefinition(cl_object fname)
46
@(return ((SYMBOLP(fname))? cl_symbol_function(fname) : ecl_fdefinition(fname)))
50
cl_fboundp(cl_object fname)
53
@(return ((fname->symbol.isform || SYM_FUN(fname) != Cnil)? Ct : Cnil))
54
} else if (CONSP(fname)) {
55
if (CAR(fname) == @'setf') {
56
cl_object sym = CDR(fname);
57
if (CONSP(sym) && CDR(sym) == Cnil) {
60
@(return si_get_sysprop(sym, @'si::setf-symbol'))
64
FEinvalid_function_name(fname);
68
ecl_fdefinition(cl_object fun)
70
cl_type t = type_of(fun);
74
output = SYM_FUN(fun);
76
FEundefined_function(fun);
77
if (fun->symbol.isform || fun->symbol.mflag)
78
FEundefined_function(fun);
79
} else if (t == t_cons) {
80
cl_object sym = CDR(fun);
82
FEinvalid_function_name(fun);
83
if (CAR(fun) == @'setf') {
85
FEinvalid_function_name(fun);
87
if (type_of(sym) != t_symbol)
88
FEinvalid_function_name(fun);
89
output = si_get_sysprop(sym, @'si::setf-symbol');
91
FEundefined_function(fun);
92
} else if (CAR(fun) == @'lambda') {
93
return si_make_lambda(Cnil, sym);
94
} else if (CAR(fun) == @'ext::lambda-block') {
95
return si_make_lambda(CAR(sym), CDR(sym));
97
FEinvalid_function_name(fun);
100
FEinvalid_function_name(fun);
106
si_coerce_to_function(cl_object fun)
108
cl_type t = type_of(fun);
109
if (!(t == t_cfun || t == t_cclosure || t == t_bytecodes
111
|| (t == t_instance && fun->instance.isgf)
114
fun = ecl_fdefinition(fun);
120
cl_symbol_value(cl_object sym)
123
FEtype_error_symbol(sym);
124
if (SYM_VAL(sym) == OBJNULL)
125
FEunbound_variable(sym);
126
@(return SYM_VAL(sym))
130
cl_boundp(cl_object sym)
133
FEtype_error_symbol(sym);
134
@(return ((SYM_VAL(sym) == OBJNULL)? Cnil : Ct))
137
@(defun macro_function (sym &optional env)
141
FEtype_error_symbol(sym);
145
fd = search_macro(sym, env);
146
if (!Null(fd)) @(return fd)
148
if (sym->symbol.mflag)
154
cl_special_operator_p(cl_object form)
157
FEtype_error_symbol(form);
158
@(return (form->symbol.isform? Ct : Cnil))