diff --git a/src/c/clos/accessor.d b/src/c/clos/accessor.d index da2bf6207..927e83e54 100644 --- a/src/c/clos/accessor.d +++ b/src/c/clos/accessor.d @@ -22,7 +22,7 @@ static void no_applicable_method(cl_env_ptr env, cl_object gfun, cl_object args) { - env->values[0] = cl_funcall(3, @'no-applicable-method', gfun, args); + env->values[0] = _ecl_funcall3(@'no-applicable-method', gfun, args); } static cl_object @@ -38,15 +38,15 @@ fill_spec_vector(cl_object vector, cl_object gfun, cl_object instance) static cl_object slot_method_name(cl_object gfun, cl_object args) { - cl_object methods = cl_funcall(3, @'compute-applicable-methods', - gfun, args); + cl_object methods = _ecl_funcall3(@'compute-applicable-methods', + gfun, args); unlikely_if (Null(methods)) { return OBJNULL; } else { cl_object first = ECL_CONS_CAR(methods); - cl_object slotd = cl_funcall(3, @'slot-value', first, - @'clos::slot-definition'); - return cl_funcall(2, @'clos::slot-definition-name', slotd); + cl_object slotd = _ecl_funcall3(@'slot-value', first, + @'clos::slot-definition'); + return _ecl_funcall2(@'clos::slot-definition-name', slotd); } } @@ -57,11 +57,11 @@ slot_method_index(cl_object gfun, cl_object instance, cl_object args) unlikely_if (slot_name == OBJNULL) return OBJNULL; else { - cl_object table = cl_funcall(3, @'slot-value', - CLASS_OF(instance), - @'clos::slot-table'); + cl_object table = _ecl_funcall3(@'slot-value', + CLASS_OF(instance), + @'clos::slot-table'); cl_object slotd = ecl_gethash_safe(slot_name, table, OBJNULL); - return cl_funcall(2, @'clos::slot-definition-location', slotd); + return _ecl_funcall2(@'clos::slot-definition-location', slotd); } } @@ -131,10 +131,10 @@ ecl_slot_reader_dispatch(cl_narg narg, cl_object instance) } unlikely_if (value == ECL_UNBOUND) { cl_object slot_name = slot_method_name(gfun, ecl_list1(instance)); - value = cl_funcall(4, @'slot-unbound', - CLASS_OF(instance), - instance, - slot_name); + value = _ecl_funcall4(@'slot-unbound', + CLASS_OF(instance), + instance, + slot_name); } @(return value) } diff --git a/src/c/file.d b/src/c/file.d index 1c89d6899..f5a2b1aa0 100755 --- a/src/c/file.d +++ b/src/c/file.d @@ -1126,7 +1126,7 @@ clos_stream_read_byte8(cl_object strm, unsigned char *c, cl_index n) { cl_index i; for (i = 0; i < n; i++) { - cl_object byte = funcall(2, @'gray::stream-read-byte', strm); + cl_object byte = _ecl_funcall2(@'gray::stream-read-byte', strm); if (!FIXNUMP(byte)) break; c[i] = fix(byte); @@ -1139,7 +1139,7 @@ clos_stream_write_byte8(cl_object strm, unsigned char *c, cl_index n) { cl_index i; for (i = 0; i < n; i++) { - cl_object byte = funcall(3, @'gray::stream-write-byte', strm, + cl_object byte = _ecl_funcall3(@'gray::stream-write-byte', strm, MAKE_FIXNUM(c[i])); if (!FIXNUMP(byte)) break; @@ -1150,7 +1150,7 @@ clos_stream_write_byte8(cl_object strm, unsigned char *c, cl_index n) static cl_object clos_stream_read_byte(cl_object strm) { - cl_object b = funcall(2, @'gray::stream-read-byte', strm); + cl_object b = _ecl_funcall2(@'gray::stream-read-byte', strm); if (b == @':eof') b = Cnil; return b; } @@ -1158,13 +1158,13 @@ clos_stream_read_byte(cl_object strm) static void clos_stream_write_byte(cl_object c, cl_object strm) { - funcall(3, @'gray::stream-write-byte', strm, c); + _ecl_funcall3(@'gray::stream-write-byte', strm, c); } static ecl_character clos_stream_read_char(cl_object strm) { - cl_object output = funcall(2, @'gray::stream-read-char', strm); + cl_object output = _ecl_funcall2(@'gray::stream-read-char', strm); cl_fixnum value; if (CHARACTERP(output)) value = CHAR_CODE(output); @@ -1182,20 +1182,20 @@ clos_stream_read_char(cl_object strm) static ecl_character clos_stream_write_char(cl_object strm, ecl_character c) { - funcall(3, @'gray::stream-write-char', strm, CODE_CHAR(c)); + _ecl_funcall3(@'gray::stream-write-char', strm, CODE_CHAR(c)); return c; } static void clos_stream_unread_char(cl_object strm, ecl_character c) { - funcall(3, @'gray::stream-unread-char', strm, CODE_CHAR(c)); + _ecl_funcall3(@'gray::stream-unread-char', strm, CODE_CHAR(c)); } static int clos_stream_peek_char(cl_object strm) { - cl_object out = funcall(2, @'gray::stream-peek-char', strm); + cl_object out = _ecl_funcall2(@'gray::stream-peek-char', strm); if (out == @':eof') return EOF; return ecl_char_code(out); } @@ -1203,57 +1203,57 @@ clos_stream_peek_char(cl_object strm) static int clos_stream_listen(cl_object strm) { - return !Null(funcall(2, @'gray::stream-listen', strm)); + return !Null(_ecl_funcall2(@'gray::stream-listen', strm)); } static void clos_stream_clear_input(cl_object strm) { - funcall(2, @'gray::stream-clear-input', strm); + _ecl_funcall2(@'gray::stream-clear-input', strm); } static void clos_stream_clear_output(cl_object strm) { - funcall(2, @'gray::stream-clear-output', strm); + _ecl_funcall2(@'gray::stream-clear-output', strm); return; } static void clos_stream_force_output(cl_object strm) { - funcall(2, @'gray::stream-force-output', strm); + _ecl_funcall2(@'gray::stream-force-output', strm); } static void clos_stream_finish_output(cl_object strm) { - funcall(2, @'gray::stream-finish-output', strm); + _ecl_funcall2(@'gray::stream-finish-output', strm); } static int clos_stream_input_p(cl_object strm) { - return !Null(funcall(2, @'gray::input-stream-p', strm)); + return !Null(_ecl_funcall2(@'gray::input-stream-p', strm)); } static int clos_stream_output_p(cl_object strm) { - return !Null(funcall(2, @'gray::output-stream-p', strm)); + return !Null(_ecl_funcall2(@'gray::output-stream-p', strm)); } static int clos_stream_interactive_p(cl_object strm) { - return !Null(funcall(2, @'gray::stream-interactive-p', strm)); + return !Null(_ecl_funcall2(@'gray::stream-interactive-p', strm)); } static cl_object clos_stream_element_type(cl_object strm) { - return funcall(2, @'gray::stream-element-type', strm); + return _ecl_funcall2(@'gray::stream-element-type', strm); } #define clos_stream_length not_a_file_stream @@ -1261,19 +1261,19 @@ clos_stream_element_type(cl_object strm) static cl_object clos_stream_get_position(cl_object strm) { - return funcall(2, @'gray::stream-file-position', strm); + return _ecl_funcall2(@'gray::stream-file-position', strm); } static cl_object clos_stream_set_position(cl_object strm, cl_object pos) { - return funcall(3, @'gray::stream-file-position', strm, pos); + return _ecl_funcall3(@'gray::stream-file-position', strm, pos); } static int clos_stream_column(cl_object strm) { - cl_object col = funcall(2, @'gray::stream-line-column', strm); + cl_object col = _ecl_funcall2(@'gray::stream-line-column', strm); /* FIXME! The Gray streams specifies NIL is a valid * value but means "unknown". Should we make it * zero? */ @@ -1283,7 +1283,7 @@ clos_stream_column(cl_object strm) static cl_object clos_stream_close(cl_object strm) { - return funcall(2, @'gray::close', strm); + return _ecl_funcall2(@'gray::close', strm); } const struct ecl_file_ops clos_stream_ops = { @@ -1463,9 +1463,9 @@ ecl_make_string_output_stream(cl_index line_length, int extended) #ifdef ECL_UNICODE extended = 1; #endif - } else if (!Null(funcall(3, @'subtypep', element_type, @'base-char'))) { + } else if (!Null(_ecl_funcall3(@'subtypep', element_type, @'base-char'))) { (void)0; - } else if (!Null(funcall(3, @'subtypep', element_type, @'character'))) { + } else if (!Null(_ecl_funcall3(@'subtypep', element_type, @'character'))) { #ifdef ECL_UNICODE extended = 1; #endif @@ -2973,7 +2973,7 @@ parse_external_format(cl_object stream, cl_object format, int flags) return (flags & ~ECL_STREAM_FORMAT) | ECL_STREAM_USER_FORMAT; } if (SYMBOLP(format)) { - stream->stream.format_table = cl_funcall(2, @'ext::make-encoding', + stream->stream.format_table = _ecl_funcall2(@'ext::make-encoding', format); return (flags & ~ECL_STREAM_FORMAT) | ECL_STREAM_USER_FORMAT; } @@ -4130,7 +4130,7 @@ seq_out_write_byte8(cl_object strm, unsigned char *c, cl_index n) if (delta < n) { /* Not enough space, enlarge */ cl_object dim = cl_array_total_size(vector); - vector = cl_funcall(3, @'adjust-array', vector, ecl_ash(dim, 1)); + vector = _ecl_funcall3(@'adjust-array', vector, ecl_ash(dim, 1)); SEQ_OUTPUT_VECTOR(strm) = vector; SEQ_OUTPUT_LIMIT(strm) = vector->vector.dim * size; goto AGAIN; @@ -4687,7 +4687,7 @@ cl_open_stream_p(cl_object strm) when #'close has been applied on it */ #ifdef ECL_CLOS_STREAMS if (ECL_INSTANCEP(strm)) { - return funcall(2, @'gray::open-stream-p', strm); + return _ecl_funcall2(@'gray::open-stream-p', strm); } #endif unlikely_if (!ECL_ANSI_STREAM_P(strm)) @@ -4728,7 +4728,7 @@ cl_streamp(cl_object strm) { #ifdef ECL_CLOS_STREAMS if (ECL_INSTANCEP(strm)) { - return funcall(2, @'gray::streamp', strm); + return _ecl_funcall2(@'gray::streamp', strm); } #endif @(return (ECL_ANSI_STREAM_P(strm) ? Ct : Cnil)) @@ -4767,11 +4767,11 @@ ecl_normalize_stream_element_type(cl_object element_type) return 0; } else if (element_type == @'base-char' || element_type == @'character') { return 0; - } else if (funcall(3, @'subtypep', element_type, @'character') != Cnil) { + } else if (_ecl_funcall3(@'subtypep', element_type, @'character') != Cnil) { return 0; - } else if (funcall(3, @'subtypep', element_type, @'unsigned-byte') != Cnil) { + } else if (_ecl_funcall3(@'subtypep', element_type, @'unsigned-byte') != Cnil) { sign = +1; - } else if (funcall(3, @'subtypep', element_type, @'signed-byte') != Cnil) { + } else if (_ecl_funcall3(@'subtypep', element_type, @'signed-byte') != Cnil) { sign = -1; } else { FEerror("Not a valid stream element type: ~A", 1, element_type); @@ -4786,7 +4786,7 @@ ecl_normalize_stream_element_type(cl_object element_type) cl_object type; type = cl_list(2, sign>0? @'unsigned-byte' : @'signed-byte', MAKE_FIXNUM(size)); - if (funcall(3, @'subtypep', element_type, type) != Cnil) { + if (_ecl_funcall3(@'subtypep', element_type, type) != Cnil) { return size * sign; } } @@ -5304,9 +5304,9 @@ wrong_file_handler(cl_object strm) static cl_index encoding_error(cl_object stream, unsigned char *buffer, ecl_character c) { - cl_object code = cl_funcall(4, @'ext::encoding-error', stream, - cl_stream_external_format(stream), - ecl_make_integer(c)); + cl_object code = _ecl_funcall4(@'ext::encoding-error', stream, + cl_stream_external_format(stream), + ecl_make_integer(c)); if (Null(code)) { /* Output nothing */ return 0; @@ -5323,9 +5323,9 @@ decoding_error(cl_object stream, unsigned char *buffer, int length) while (length > 0) { octets = CONS(MAKE_FIXNUM(buffer[--length]), octets); } - code = cl_funcall(4, @'ext::decoding-error', stream, - cl_stream_external_format(stream), - octets); + code = _ecl_funcall4(@'ext::decoding-error', stream, + cl_stream_external_format(stream), + octets); if (Null(code)) { /* Go for next character */ return stream->stream.decoder(stream); diff --git a/src/c/gfun.d b/src/c/gfun.d index 1ae5e3501..260df9bb6 100644 --- a/src/c/gfun.d +++ b/src/c/gfun.d @@ -144,14 +144,14 @@ compute_applicable_method(cl_object frame, cl_object gf) p != frame->frame.base; ) { arglist = CONS(*(--p), arglist); } - methods = funcall(3, @'compute-applicable-methods', gf, arglist); + methods = _ecl_funcall3(@'compute-applicable-methods', gf, arglist); if (methods == Cnil) { - func = funcall(3, @'no-applicable-method', gf, arglist); + func = _ecl_funcall3(@'no-applicable-method', gf, arglist); frame->frame.base[0] = OBJNULL; return func; } else { - return funcall(4, @'clos::compute-effective-method', gf, - GFUN_COMB(gf), methods); + return _ecl_funcall4(@'clos::compute-effective-method', gf, + GFUN_COMB(gf), methods); } } @@ -196,7 +196,7 @@ _ecl_standard_dispatch(cl_object frame, cl_object gf) e->value = func; } } - func = cl_funcall(3, func, frame, Cnil); + func = _ecl_funcall3(func, frame, Cnil); /* Only need to close the copy */ #if !defined(ECL_USE_VARARG_AS_POINTER) if (frame == (cl_object)&frame_aux) diff --git a/src/c/macros.d b/src/c/macros.d index 9a6dbd78e..2e74b8311 100644 --- a/src/c/macros.d +++ b/src/c/macros.d @@ -108,9 +108,9 @@ search_macro_function(cl_object name, cl_object env) if (!Null(exp_fun)) { cl_object hook = ecl_symbol_value(@'*macroexpand-hook*'); if (hook == @'funcall') - form = funcall(3, exp_fun, form, env); + form = _ecl_funcall3(exp_fun, form, env); else - form = funcall(4, hook, exp_fun, form, env); + form = _ecl_funcall4(hook, exp_fun, form, env); } @(return form exp_fun) @) diff --git a/src/c/package.d b/src/c/package.d index e03c3830e..27f0c01b9 100644 --- a/src/c/package.d +++ b/src/c/package.d @@ -17,7 +17,6 @@ #include #include -#include /******************************* ------- ******************************/ /* @@ -155,8 +154,8 @@ find_pending_package(cl_env_ptr env, cl_object name, cl_object nicknames) cl_object pair = ECL_CONS_CAR(l); cl_object other_name = ECL_CONS_CAR(pair); if (ecl_equal(other_name, name) || - funcall(5, @'member', other_name, nicknames, - @':test', @'string=') != Cnil) + _ecl_funcall5(@'member', other_name, nicknames, + @':test', @'string=') != Cnil) { cl_object x = ECL_CONS_CDR(pair); env->packages_to_be_created = diff --git a/src/c/print.d b/src/c/print.d index 762208cd5..c7761a15c 100644 --- a/src/c/print.d +++ b/src/c/print.d @@ -226,7 +226,7 @@ ecl_print_circle(void) strm = _ecl_stream_or_default_output(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) - funcall(5, @'gray::stream-write-string', strm, strng, start, end); + _ecl_funcall5(@'gray::stream-write-string', strm, strng, start, end); else #endif si_do_write_sequence(strng, strm, start, end); @@ -240,8 +240,8 @@ ecl_print_circle(void) strm = _ecl_stream_or_default_output(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) - funcall(5, @'gray::stream-write-string', strm, strng, - start, end); + _ecl_funcall5(@'gray::stream-write-string', strm, strng, + start, end); else #endif si_do_write_sequence(strng, strm, start, end); @@ -260,7 +260,7 @@ ecl_print_circle(void) strm = _ecl_stream_or_default_output(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) { - return funcall(2, @'gray::stream-fresh-line', strm); + return _ecl_funcall2(@'gray::stream-fresh-line', strm); } #endif if (ecl_file_column(strm) == 0) @@ -275,7 +275,7 @@ ecl_print_circle(void) strm = _ecl_stream_or_default_output(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) { - return funcall(2, @'gray::stream-finish-output', strm); + return _ecl_funcall2(@'gray::stream-finish-output', strm); } #endif ecl_force_output(strm); @@ -306,9 +306,10 @@ cl_write_byte(cl_object integer, cl_object binary_output_stream) @(defun write-sequence (sequence stream &key (start MAKE_FIXNUM(0)) end) @ #ifdef ECL_CLOS_STREAMS - if (!ECL_ANSI_STREAM_P(stream)) - return funcall(5, @'gray::stream-write-sequence', stream, sequence, start, end); - else + if (!ECL_ANSI_STREAM_P(stream)) { + return _ecl_funcall5(@'gray::stream-write-sequence', + stream, sequence, start, end); + } else #endif return si_do_write_sequence(sequence, stream, start, end); @) @@ -353,7 +354,7 @@ ecl_terpri(cl_object strm) strm = _ecl_stream_or_default_output(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) { - return funcall(2, @'gray::stream-terpri', strm); + return _ecl_funcall2(@'gray::stream-terpri', strm); } #endif ecl_write_char('\n', strm); diff --git a/src/c/printer/write_object.d b/src/c/printer/write_object.d index 4ebd56a65..16c1ac288 100644 --- a/src/c/printer/write_object.d +++ b/src/c/printer/write_object.d @@ -90,9 +90,9 @@ si_write_object(cl_object x, cl_object stream) bool circle; #ifdef ECL_CMU_FORMAT if (ecl_symbol_value(@'*print-pretty*') != Cnil) { - cl_object f = funcall(2, @'pprint-dispatch', x); + cl_object f = _ecl_funcall2(@'pprint-dispatch', x); if (VALUES(1) != Cnil) { - funcall(3, f, stream, x); + _ecl_funcall3(f, stream, x); goto OUTPUT; } } diff --git a/src/c/read.d b/src/c/read.d index 8b8db42fa..fe2d9742b 100644 --- a/src/c/read.d +++ b/src/c/read.d @@ -198,7 +198,7 @@ BEGIN: if (ECL_HASH_TABLE_P(x)) { o = dispatch_macro_character(x, in, c); } else { - o = funcall(3, x, in, CODE_CHAR(c)); + o = _ecl_funcall3(x, in, CODE_CHAR(c)); } if (the_env->nvalues == 0) { if (flags == ECL_READ_RETURN_IGNORABLE) @@ -580,7 +580,7 @@ dispatch_macro_character(cl_object table, cl_object in, int c) "for character ~S", in, 1, dc); } - return funcall(4, fun, in, dc, arg); + return _ecl_funcall4(fun, in, dc, arg); } } @@ -800,7 +800,7 @@ sharp_left_parenthesis_reader(cl_object in, cl_object c, cl_object d) in, 0); } if (a == QUOTE) { - v = funcall(4, @'make-array', cl_list(1, cl_length(x)), + v = _ecl_funcall4(@'make-array', cl_list(1, cl_length(x)), @':initial-contents', x); } else { v = cl_list(2, @'si::unquote', @@ -815,7 +815,7 @@ sharp_left_parenthesis_reader(cl_object in, cl_object c, cl_object d) /* Third case: no dimension provided. Read a list and coerce it to vector. */ cl_object x = do_read_delimited_list(')', in, 1); - v = funcall(4, @'make-array', cl_list(1, cl_length(x)), + v = _ecl_funcall4(@'make-array', cl_list(1, cl_length(x)), @':initial-contents', x); } else { /* Finally: Both dimension and data are provided. The @@ -1498,7 +1498,7 @@ do_read_delimited_list(int d, cl_object in, bool proper_list) strm = stream_or_default_input(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) { - value0 = funcall(2, @'gray::stream-read-line', strm); + value0 = _ecl_funcall2(@'gray::stream-read-line', strm); value1 = VALUES(1); if (!Null(value1)) { if (!Null(eof_errorp)) @@ -1611,7 +1611,8 @@ do_read_delimited_list(int d, cl_object in, bool proper_list) strm = stream_or_default_input(strm); #ifdef ECL_CLOS_STREAMS if (!ECL_ANSI_STREAM_P(strm)) { - cl_object output = funcall(2,@'gray::stream-read-char-no-hang', strm); + cl_object output = + _ecl_funcall2(@'gray::stream-read-char-no-hang', strm); if (output == @':eof') goto END_OF_FILE; @(return output); diff --git a/src/c/string.d b/src/c/string.d index 7ab451bdb..6dd339cae 100644 --- a/src/c/string.d +++ b/src/c/string.d @@ -60,10 +60,10 @@ do_make_string(cl_index s, ecl_character code) } else if (element_type == @'character') { cl_index code = ecl_char_code(initial_element); x = do_make_string(s, code); - } else if (funcall(3, @'subtypep', element_type, @'base-char') == Ct) { + } else if (_ecl_funcall3(@'subtypep', element_type, @'base-char') == Ct) { int code = ecl_base_char_code(initial_element); x = do_make_base_string(s, code); - } else if (funcall(3, @'subtypep', element_type, @'character') == Ct) { + } else if (_ecl_funcall3(@'subtypep', element_type, @'character') == Ct) { cl_index code = ecl_char_code(initial_element); x = do_make_string(s, code); } else { diff --git a/src/h/internal.h b/src/h/internal.h index b116aeea5..c721ba7f6 100644 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -134,6 +134,19 @@ typedef struct cl_compiler_env *cl_compiler_env_ptr; extern void _ecl_unexpected_return() ecl_attr_noreturn; +/* eval.d */ + +#define _ecl_funcall5(fun, a, b, c, d) \ + ecl_function_dispatch(ecl_process_env(), (fun))(3, (a),(b),(c),(d)) +#define _ecl_funcall4(fun, a, b, c) \ + ecl_function_dispatch(ecl_process_env(), (fun))(3, (a),(b),(c)) +#define _ecl_funcall3(fun, a, b) \ + ecl_function_dispatch(ecl_process_env(), (fun))(2, (a),(b)) +#define _ecl_funcall2(fun, a) \ + ecl_function_dispatch(ecl_process_env(), (fun))(1, (a)) +#define _ecl_funcall1(fun) \ + ecl_function_dispatch(ecl_process_env(), (fun))(0) + /* interpreter.d */ #define ECL_BUILD_STACK_FRAME(env,name,frame) \