2
cfun.c -- Compiled functions.
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 <string.h> /* for memmove() */
21
cl_make_cfun(void *c_function, cl_object name, cl_object cblock, int narg)
25
cf = cl_alloc_object(t_cfun);
26
cf->cfun.entry = c_function;
28
cf->cfun.block = cblock;
30
if (narg < 0 || narg >= C_ARGUMENTS_LIMIT)
31
FEprogram_error("cl_make_cfun: function requires too many arguments.",0);
36
cl_make_cfun_va(void *c_function, cl_object name, cl_object cblock)
40
cf = cl_alloc_object(t_cfun);
41
cf->cfun.entry = c_function;
43
cf->cfun.block = cblock;
49
cl_make_cclosure_va(void *c_function, cl_object env, cl_object block)
53
cc = cl_alloc_object(t_cclosure);
54
cc->cclosure.entry = c_function;
55
cc->cclosure.env = env;
56
cc->cclosure.block = block;
61
cl_def_c_function(cl_object sym, void *c_function, int narg)
64
cl_make_cfun(c_function, sym, symbol_value(@'si::*cblock*'), narg));
68
cl_def_c_macro(cl_object sym, void *c_function, int narg)
72
cl_make_cfun(c_function, sym, symbol_value(@'si::*cblock*'), 2):
73
cl_make_cfun_va(c_function, sym, symbol_value(@'si::*cblock*')),
78
cl_def_c_function_va(cl_object sym, void *c_function)
81
cl_make_cfun_va(c_function, sym, symbol_value(@'si::*cblock*')));
85
si_compiled_function_name(cl_object fun)
89
switch(type_of(fun)) {
91
output = fun->bytecodes.name; break;
93
output = fun->cfun.name; break;
97
FEinvalid_function(fun);
103
cl_function_lambda_expression(cl_object fun)
105
cl_object output, name = Cnil, lex = Cnil;
107
switch(type_of(fun)) {
109
lex = fun->bytecodes.lex;
110
name = fun->bytecodes.name;
111
output = fun->bytecodes.definition;
114
else if (name == Cnil)
115
output = cl_cons(@'lambda', output);
117
output = @list*(3, @'ext::lambda-block', name, output);
120
name = fun->cfun.name;
131
if (fun->instance.isgf) {
139
FEinvalid_function(fun);
141
@(return output lex name)
145
si_compiled_function_block(cl_object fun)
149
switch(type_of(fun)) {
151
output = fun->cfun.block; break;
153
output = fun->cclosure.block; break;
155
FEerror("~S is not a compiled-function.", 1, fun);