diff --git a/eval.c b/eval.c index 1739e8bb..5de465ab 100644 --- a/eval.c +++ b/eval.c @@ -12,9 +12,9 @@ static sexp analyze (sexp ctx, sexp x); static void generate (sexp ctx, sexp name, sexp loc, sexp lam, sexp x); #if SEXP_USE_MODULES -sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sexp env); -sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file); -sexp sexp_current_environment (sexp ctx sexp_api_params(self, n)); +sexp sexp_load_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file, sexp env); +sexp sexp_find_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file); +sexp sexp_current_environment (sexp ctx, sexp self, sexp_sint_t n); #endif sexp sexp_compile_error (sexp ctx, const char *message, sexp o) { @@ -148,7 +148,7 @@ sexp sexp_env_rename (sexp ctx, sexp env, sexp key, sexp value) { } #endif -sexp sexp_env_exports_op (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_env_exports_op (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp ls; sexp_gc_var1(res); sexp_gc_preserve1(ctx, res); @@ -289,7 +289,7 @@ static void emit (sexp ctx, unsigned char c) { sexp_bytecode_data(sexp_context_bc(ctx))[sexp_context_pos(ctx)++] = c; } -sexp sexp_make_procedure_op (sexp ctx sexp_api_params(self, n), sexp flags, +sexp sexp_make_procedure_op (sexp ctx, sexp self, sexp_sint_t n, sexp flags, sexp num_args, sexp bc, sexp vars) { sexp proc = sexp_alloc_type(ctx, procedure, SEXP_PROCEDURE); sexp_procedure_flags(proc) = (char) (sexp_uint_t) flags; @@ -306,7 +306,7 @@ static sexp sexp_make_macro (sexp ctx, sexp p, sexp e) { return mac; } -sexp sexp_make_synclo_op (sexp ctx sexp_api_params(self, n), sexp env, sexp fv, sexp expr) { +sexp sexp_make_synclo_op (sexp ctx, sexp self, sexp_sint_t n, sexp env, sexp fv, sexp expr) { sexp res; if (! (sexp_symbolp(expr) || sexp_pairp(expr))) return expr; @@ -464,15 +464,15 @@ sexp sexp_make_child_context (sexp ctx, sexp lambda) { /**************************** identifiers *****************************/ -sexp sexp_identifierp_op (sexp ctx sexp_api_params(self, n), sexp x) { +sexp sexp_identifierp_op (sexp ctx, sexp self, sexp_sint_t n, sexp x) { return sexp_make_boolean(sexp_idp(x)); } -sexp sexp_syntactic_closure_expr_op (sexp ctx sexp_api_params(self, n), sexp x) { +sexp sexp_syntactic_closure_expr_op (sexp ctx, sexp self, sexp_sint_t n, sexp x) { return (sexp_synclop(x) ? sexp_synclo_expr(x) : x); } -sexp sexp_strip_synclos (sexp ctx sexp_api_params(self, n), sexp x) { +sexp sexp_strip_synclos (sexp ctx, sexp self, sexp_sint_t n, sexp x) { sexp_gc_var3(res, kar, kdr); sexp_gc_preserve3(ctx, res, kar, kdr); loop: @@ -480,8 +480,8 @@ sexp sexp_strip_synclos (sexp ctx sexp_api_params(self, n), sexp x) { x = sexp_synclo_expr(x); goto loop; } else if (sexp_pairp(x) && sexp_truep(sexp_length(ctx, x))) { - kar = sexp_strip_synclos(ctx sexp_api_pass(self, n), sexp_car(x)); - kdr = sexp_strip_synclos(ctx sexp_api_pass(self, n), sexp_cdr(x)); + kar = sexp_strip_synclos(ctx, self, n, sexp_car(x)); + kdr = sexp_strip_synclos(ctx, self, n, sexp_cdr(x)); res = sexp_cons(ctx, kar, kdr); sexp_pair_source(res) = sexp_pair_source(x); sexp_immutablep(res) = 1; @@ -492,7 +492,7 @@ sexp sexp_strip_synclos (sexp ctx sexp_api_params(self, n), sexp x) { return res; } -sexp sexp_identifier_eq_op (sexp ctx sexp_api_params(self, n), sexp e1, sexp id1, sexp e2, sexp id2) { +sexp sexp_identifier_eq_op (sexp ctx, sexp self, sexp_sint_t n, sexp e1, sexp id1, sexp e2, sexp id2) { sexp cell1, cell2; cell1 = sexp_env_cell(e1, id1, 0); if (!cell1 && sexp_synclop(id1)) { @@ -857,7 +857,7 @@ static sexp analyze (sexp ctx, sexp object) { else res = sexp_make_lit(ctx, (sexp_core_code(op) == SEXP_CORE_QUOTE) ? - sexp_strip_synclos(ctx sexp_api_pass(NULL, 1), sexp_cadr(x)) : + sexp_strip_synclos(ctx , NULL, 1, sexp_cadr(x)) : sexp_cadr(x)); break; case SEXP_CORE_DEFINE_SYNTAX: @@ -996,12 +996,12 @@ sexp sexp_free_vars (sexp ctx, sexp x, sexp fv) { /************************ library procedures **************************/ -sexp sexp_exception_type_op (sexp ctx sexp_api_params(self, n), sexp exn) { +sexp sexp_exception_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn) { sexp_assert_type(ctx, sexp_exceptionp, SEXP_EXCEPTION, exn); return sexp_exception_kind(exn); } -sexp sexp_open_input_file_op (sexp ctx sexp_api_params(self, n), sexp path) { +sexp sexp_open_input_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp path) { FILE *in; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path); in = fopen(sexp_string_data(path), "r"); @@ -1013,7 +1013,7 @@ sexp sexp_open_input_file_op (sexp ctx sexp_api_params(self, n), sexp path) { return sexp_make_input_port(ctx, in, path); } -sexp sexp_open_output_file_op (sexp ctx sexp_api_params(self, n), sexp path) { +sexp sexp_open_output_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp path) { FILE *out; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, path); out = fopen(sexp_string_data(path), "w"); @@ -1022,23 +1022,23 @@ sexp sexp_open_output_file_op (sexp ctx sexp_api_params(self, n), sexp path) { return sexp_make_output_port(ctx, out, path); } -sexp sexp_open_binary_input_file (sexp ctx sexp_api_params(self, n), sexp path) { +sexp sexp_open_binary_input_file (sexp ctx, sexp self, sexp_sint_t n, sexp path) { sexp res = sexp_open_input_file_op(ctx, self, n, path); if (sexp_portp(res)) sexp_port_binaryp(res) = 1; return res; } -sexp sexp_open_binary_output_file (sexp ctx sexp_api_params(self, n), sexp path) { +sexp sexp_open_binary_output_file (sexp ctx, sexp self, sexp_sint_t n, sexp path) { sexp res = sexp_open_output_file_op(ctx, self, n, path); if (sexp_portp(res)) sexp_port_binaryp(res) = 1; return res; } -sexp sexp_close_port_op (sexp ctx sexp_api_params(self, n), sexp port) { +sexp sexp_close_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) { sexp_assert_type(ctx, sexp_portp, SEXP_OPORT, port); if (! sexp_port_openp(port)) return sexp_user_exception(ctx, self, "port already closed", port); - return sexp_finalize_port(ctx sexp_api_pass(self, n), port); + return sexp_finalize_port(ctx, self, n, port); } #if SEXP_USE_STATIC_LIBS @@ -1063,7 +1063,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) { if (! entry) return sexp_compile_error(ctx, "couldn't find builtin library", file); - return entry->init(ctx sexp_api_pass(NULL, 1), env); + return entry->init(ctx, NULL, 1, env); } #else #define sexp_find_static_library(path) NULL @@ -1080,7 +1080,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) { FreeLibrary(handle); return sexp_compile_error(ctx, "dynamic library has no sexp_init_library", file); } - return init(ctx sexp_api_pass(NULL, 1), env); + return init(ctx, NULL, 1, env); } #else static sexp sexp_make_dl (sexp ctx, sexp file, void* handle) { @@ -1103,7 +1103,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) { sexp_gc_preserve2(ctx, res, old_dl); old_dl = sexp_context_dl(ctx); sexp_context_dl(ctx) = sexp_make_dl(ctx, file, handle); - res = init(ctx sexp_api_pass(NULL, 1), env); + res = init(ctx, NULL, 1, env); sexp_context_dl(ctx) = old_dl; sexp_gc_release2(ctx); return res; @@ -1112,7 +1112,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) { #endif #endif -sexp sexp_load_op (sexp ctx sexp_api_params(self, n), sexp source, sexp env) { +sexp sexp_load_op (sexp ctx, sexp self, sexp_sint_t n, sexp source, sexp env) { #if SEXP_USE_DL || SEXP_USE_STATIC_LIBS char *suffix; #endif @@ -1167,7 +1167,7 @@ sexp sexp_load_op (sexp ctx sexp_api_params(self, n), sexp source, sexp env) { return res; } -sexp sexp_register_optimization (sexp ctx sexp_api_params(self, n), sexp f, sexp priority) { +sexp sexp_register_optimization (sexp ctx, sexp self, sexp_sint_t n, sexp f, sexp priority) { sexp_assert_type(ctx, sexp_applicablep, SEXP_PROCEDURE, f); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, priority); sexp_push(ctx, sexp_global(ctx, SEXP_G_OPTIMIZATIONS), SEXP_VOID); @@ -1200,7 +1200,7 @@ sexp sexp_register_optimization (sexp ctx sexp_api_params(self, n), sexp f, sexp #endif #define define_math_op(name, cname, t, f) \ - sexp name (sexp ctx sexp_api_params(self, n), sexp z) { \ + sexp name (sexp ctx, sexp self, sexp_sint_t n, sexp z) { \ double d; \ if (sexp_flonump(z)) \ d = sexp_flonum_value(z); \ @@ -1227,7 +1227,7 @@ define_math_op(sexp_trunc, trunc, 0, sexp_complex_dummy) define_math_op(sexp_floor, floor, 0, sexp_complex_dummy) define_math_op(sexp_ceiling, ceil, 0, sexp_complex_dummy) -sexp sexp_sqrt (sexp ctx sexp_api_params(self, n), sexp z) { +sexp sexp_sqrt (sexp ctx, sexp self, sexp_sint_t n, sexp z) { #if SEXP_USE_COMPLEX int negativep = 0; #endif @@ -1278,7 +1278,7 @@ sexp sexp_generic_expt (sexp ctx, sexp x, sexp_sint_t e) { } #endif -sexp sexp_expt_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) { +sexp sexp_expt_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp e) { long double f, x1, e1; sexp res; #if SEXP_USE_COMPLEX @@ -1353,28 +1353,28 @@ sexp sexp_expt_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) { } #if SEXP_USE_RATIOS -sexp sexp_ratio_numerator_op (sexp ctx sexp_api_params(self, n), sexp rat) { +sexp sexp_ratio_numerator_op (sexp ctx, sexp self, sexp_sint_t n, sexp rat) { sexp_assert_type(ctx, sexp_ratiop, SEXP_RATIO, rat); return sexp_ratio_numerator(rat); } -sexp sexp_ratio_denominator_op (sexp ctx sexp_api_params(self, n), sexp rat) { +sexp sexp_ratio_denominator_op (sexp ctx, sexp self, sexp_sint_t n, sexp rat) { sexp_assert_type(ctx, sexp_ratiop, SEXP_RATIO, rat); return sexp_ratio_denominator(rat); } #endif #if SEXP_USE_COMPLEX -sexp sexp_complex_real_op (sexp ctx sexp_api_params(self, n), sexp cpx) { +sexp sexp_complex_real_op (sexp ctx, sexp self, sexp_sint_t n, sexp cpx) { sexp_assert_type(ctx, sexp_complexp, SEXP_COMPLEX, cpx); return sexp_complex_real(cpx); } -sexp sexp_complex_imag_op (sexp ctx sexp_api_params(self, n), sexp cpx) { +sexp sexp_complex_imag_op (sexp ctx, sexp self, sexp_sint_t n, sexp cpx) { sexp_assert_type(ctx, sexp_complexp, SEXP_COMPLEX, cpx); return sexp_complex_imag(cpx); } #endif -sexp sexp_string_cmp_op (sexp ctx sexp_api_params(self, n), sexp str1, sexp str2, sexp ci) { +sexp sexp_string_cmp_op (sexp ctx, sexp self, sexp_sint_t n, sexp str1, sexp str2, sexp ci) { sexp_sint_t len1, len2, len, diff; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str1); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str2); @@ -1433,11 +1433,11 @@ sexp sexp_string_utf8_ref (sexp ctx, sexp str, sexp i) { return sexp_make_character(((p[0]&0x0F)<<16) + ((p[1]&0x3F)<<6) + ((p[2]&0x3F)<<6) + (p[2]&0x3F)); } -sexp sexp_string_utf8_index_ref (sexp ctx sexp_api_params(self, n), sexp str, sexp i) { +sexp sexp_string_utf8_index_ref (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp i) { sexp off; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); - off = sexp_string_index_to_offset(ctx sexp_api_pass(self, n), str, i); + off = sexp_string_index_to_offset(ctx, self, n, str, i); if (sexp_exceptionp(off)) return off; return sexp_string_utf8_ref(ctx, str, off); } @@ -1493,12 +1493,12 @@ void sexp_string_utf8_set (sexp ctx, sexp str, sexp index, sexp ch) { sexp_utf8_encode_char(p, new_len, c); } -sexp sexp_string_utf8_index_set (sexp ctx sexp_api_params(self, n), sexp str, sexp i, sexp ch) { +sexp sexp_string_utf8_index_set (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp i, sexp ch) { sexp off; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, str); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); sexp_assert_type(ctx, sexp_charp, SEXP_CHAR, ch); - off = sexp_string_index_to_offset(ctx sexp_api_pass(self, n), str, i); + off = sexp_string_index_to_offset(ctx, self, n, str, i); if (sexp_exceptionp(off)) return off; sexp_string_utf8_set(ctx, str, off, ch); return SEXP_VOID; @@ -1508,7 +1508,7 @@ sexp sexp_string_utf8_index_set (sexp ctx sexp_api_params(self, n), sexp str, se #endif #if SEXP_USE_AUTO_FORCE -sexp sexp_make_promise (sexp ctx sexp_api_params(self, n), sexp done, sexp val) { +sexp sexp_make_promise (sexp ctx, sexp self, sexp_sint_t n, sexp done, sexp val) { sexp res = sexp_alloc_type(ctx, promise, SEXP_PROMISE); sexp_promise_donep(res) = sexp_unbox_boolean(done); sexp_promise_value(res) = val; @@ -1532,7 +1532,7 @@ sexp sexp_make_promise (sexp ctx sexp_api_params(self, n), sexp done, sexp val) #if SEXP_USE_TYPE_DEFS -sexp sexp_type_slot_offset_op (sexp ctx sexp_api_params(self, n), sexp type, sexp slot) { +sexp sexp_type_slot_offset_op (sexp ctx , sexp self, sexp_sint_t n, sexp type, sexp slot) { sexp cpl, slots, *v; int i, offset=0, len; sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, type); @@ -1552,7 +1552,7 @@ sexp sexp_type_slot_offset_op (sexp ctx sexp_api_params(self, n), sexp type, se return SEXP_FALSE; } -sexp sexp_make_type_predicate_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type) { +sexp sexp_make_type_predicate_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type) { if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, type); return sexp_make_opcode(ctx, self, name, sexp_make_fixnum(SEXP_OPC_TYPE_PREDICATE), @@ -1560,7 +1560,7 @@ sexp sexp_make_type_predicate_op (sexp ctx sexp_api_params(self, n), sexp name, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, type, NULL, NULL); } -sexp sexp_make_constructor_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type) { +sexp sexp_make_constructor_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type) { sexp_uint_t type_size; if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, type); @@ -1571,7 +1571,7 @@ sexp sexp_make_constructor_op (sexp ctx sexp_api_params(self, n), sexp name, sex sexp_make_fixnum(type_size), NULL); } -sexp sexp_make_getter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index) { +sexp sexp_make_getter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index) { if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); if ((! sexp_fixnump(type)) || (sexp_unbox_fixnum(type) < 0)) return sexp_type_exception(ctx, self, SEXP_FIXNUM, type); @@ -1583,7 +1583,7 @@ sexp sexp_make_getter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp typ type, SEXP_ZERO, SEXP_ZERO, type, index, NULL); } -sexp sexp_make_setter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index) { +sexp sexp_make_setter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index) { sexp res; if (sexp_typep(type)) type = sexp_make_fixnum(sexp_type_tag(type)); if ((! sexp_fixnump(type)) || (sexp_unbox_fixnum(type) < 0)) @@ -1601,8 +1601,8 @@ sexp sexp_make_setter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp typ #endif #if SEXP_USE_PROFILE_VM -static sexp sexp_reset_vm_profile (sexp ctx sexp_api_params(self, n)); -static sexp sexp_print_vm_profile (sexp ctx sexp_api_params(self, n)); +static sexp sexp_reset_vm_profile (sexp ctx, sexp self, sexp_sint_t n); +static sexp sexp_print_vm_profile (sexp ctx, sexp self, sexp_sint_t n); #endif #include "opcodes.c" @@ -1722,7 +1722,7 @@ static struct sexp_core_form_struct core_forms[] = { {SEXP_CORE_LETREC_SYNTAX, (sexp)"letrec-syntax"}, }; -sexp sexp_make_env_op (sexp ctx sexp_api_params(self, n)) { +sexp sexp_make_env_op (sexp ctx, sexp self, sexp_sint_t n) { sexp e = sexp_alloc_type(ctx, env, SEXP_ENV); sexp_env_lambda(e) = NULL; sexp_env_parent(e) = NULL; @@ -1733,7 +1733,7 @@ sexp sexp_make_env_op (sexp ctx sexp_api_params(self, n)) { return e; } -sexp sexp_make_null_env_op (sexp ctx sexp_api_params(self, n), sexp version) { +sexp sexp_make_null_env_op (sexp ctx, sexp self, sexp_sint_t n, sexp version) { sexp_uint_t i; sexp_gc_var2(e, core); sexp_gc_preserve2(ctx, e, core); @@ -1824,21 +1824,21 @@ sexp sexp_load_module_file (sexp ctx, const char *file, sexp env) { } #if SEXP_USE_MODULES -sexp sexp_find_module_file_op (sexp ctx sexp_api_params(self, n), sexp file) { +sexp sexp_find_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file) { sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file); return sexp_find_module_file(ctx, sexp_string_data(file)); } -sexp sexp_load_module_file_op (sexp ctx sexp_api_params(self, n), sexp file, sexp env) { +sexp sexp_load_module_file_op (sexp ctx, sexp self, sexp_sint_t n, sexp file, sexp env) { sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, file); sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env); return sexp_load_module_file(ctx, sexp_string_data(file), env); } -sexp sexp_current_environment (sexp ctx sexp_api_params(self, n)) { +sexp sexp_current_environment (sexp ctx, sexp self, sexp_sint_t n) { return sexp_context_env(ctx); } #endif -sexp sexp_add_module_directory_op (sexp ctx sexp_api_params(self, n), sexp dir, sexp appendp) { +sexp sexp_add_module_directory_op (sexp ctx, sexp self, sexp_sint_t n, sexp dir, sexp appendp) { sexp ls; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, dir); if (sexp_truep(appendp)) { @@ -1980,7 +1980,7 @@ sexp sexp_load_standard_env (sexp ctx, sexp e, sexp version) { return sexp_exceptionp(tmp) ? tmp : e; } -sexp sexp_make_standard_env_op (sexp ctx sexp_api_params(self, n), sexp version) { +sexp sexp_make_standard_env_op (sexp ctx, sexp self, sexp_sint_t n, sexp version) { sexp_gc_var1(env); sexp_gc_preserve1(ctx, env); env = sexp_make_primitive_env(ctx, version); @@ -1995,7 +1995,7 @@ sexp sexp_make_standard_env_op (sexp ctx sexp_api_params(self, n), sexp version) #define sexp_same_bindingp(x, y) (sexp_env_value(x) == sexp_env_value(y)) #endif -sexp sexp_env_import_op (sexp ctx sexp_api_params(self, n), sexp to, sexp from, sexp ls, sexp immutp) { +sexp sexp_env_import_op (sexp ctx, sexp self, sexp_sint_t n, sexp to, sexp from, sexp ls, sexp immutp) { sexp oldname, newname; sexp_gc_var2(value, oldcell); sexp_gc_preserve2(ctx, value, oldcell); @@ -2048,7 +2048,7 @@ sexp sexp_env_import_op (sexp ctx sexp_api_params(self, n), sexp to, sexp from, /************************** eval interface ****************************/ -sexp sexp_compile_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp env) { +sexp sexp_compile_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp env) { sexp_gc_var3(ast, vec, res); sexp ctx2; if (! env) env = sexp_context_env(ctx); @@ -2075,7 +2075,7 @@ sexp sexp_compile_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp env) { return res; } -sexp sexp_eval_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp env) { +sexp sexp_eval_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp env) { sexp_sint_t top; sexp ctx2; sexp_gc_var2(res, params); diff --git a/gc.c b/gc.c index 60b70147..8806cc8a 100644 --- a/gc.c +++ b/gc.c @@ -338,7 +338,7 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) { if (!sexp_markedp(p)) { /* free p */ finalizer = sexp_type_finalize(sexp_object_type(ctx, p)); - if (finalizer) finalizer(ctx sexp_api_pass(NULL, 1), p); + if (finalizer) finalizer(ctx, NULL, 1, p); sum_freed += size; if (((((char*)q) + q->size) == (char*)p) && (q != h->free_list)) { /* merge q with p */ diff --git a/include/chibi/eval.h b/include/chibi/eval.h index 44a6ff64..80251fb7 100644 --- a/include/chibi/eval.h +++ b/include/chibi/eval.h @@ -56,28 +56,28 @@ SEXP_API sexp sexp_analyze (sexp context, sexp x); SEXP_API void sexp_stack_trace (sexp ctx, sexp out); SEXP_API sexp sexp_free_vars (sexp context, sexp x, sexp fv); SEXP_API int sexp_param_index (sexp lambda, sexp name); -SEXP_API sexp sexp_compile_op (sexp context sexp_api_params(self, n), sexp obj, sexp env); -SEXP_API sexp sexp_eval_op (sexp context sexp_api_params(self, n), sexp obj, sexp env); +SEXP_API sexp sexp_compile_op (sexp context, sexp self, sexp_sint_t n, sexp obj, sexp env); +SEXP_API sexp sexp_eval_op (sexp context, sexp self, sexp_sint_t n, sexp obj, sexp env); SEXP_API sexp sexp_eval_string (sexp context, const char *str, sexp_sint_t len, sexp env); -SEXP_API sexp sexp_load_op (sexp context sexp_api_params(self, n), sexp expr, sexp env); -SEXP_API sexp sexp_make_env_op (sexp context sexp_api_params(self, n)); -SEXP_API sexp sexp_make_null_env_op (sexp context sexp_api_params(self, n), sexp version); +SEXP_API sexp sexp_load_op (sexp context, sexp self, sexp_sint_t n, sexp expr, sexp env); +SEXP_API sexp sexp_make_env_op (sexp context, sexp self, sexp_sint_t n); +SEXP_API sexp sexp_make_null_env_op (sexp context, sexp self, sexp_sint_t n, sexp version); SEXP_API sexp sexp_make_primitive_env (sexp context, sexp version); -SEXP_API sexp sexp_make_standard_env_op (sexp context sexp_api_params(self, n), sexp version); +SEXP_API sexp sexp_make_standard_env_op (sexp context, sexp self, sexp_sint_t n, sexp version); SEXP_API void sexp_set_parameter (sexp ctx, sexp env, sexp name, sexp value); SEXP_API sexp sexp_load_standard_ports (sexp context, sexp env, FILE* in, FILE* out, FILE* err, int no_close); SEXP_API sexp sexp_load_standard_env (sexp context, sexp env, sexp version); SEXP_API sexp sexp_find_module_file (sexp ctx, const char *file); SEXP_API sexp sexp_load_module_file (sexp ctx, const char *file, sexp env); -SEXP_API sexp sexp_add_module_directory_op (sexp ctx sexp_api_params(self, n), sexp dir, sexp appendp); +SEXP_API sexp sexp_add_module_directory_op (sexp ctx, sexp self, sexp_sint_t n, sexp dir, sexp appendp); SEXP_API sexp sexp_extend_env (sexp ctx, sexp env, sexp vars, sexp value); -SEXP_API sexp sexp_env_import_op (sexp ctx sexp_api_params(self, n), sexp to, sexp from, sexp ls, sexp immutp); -SEXP_API sexp sexp_identifier_op(sexp ctx sexp_api_params(self, n), sexp x); -SEXP_API sexp sexp_syntactic_closure_expr(sexp ctx sexp_api_params(self, n), sexp x); -SEXP_API sexp sexp_identifier_eq_op(sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp c, sexp d); -SEXP_API sexp sexp_open_input_file_op(sexp ctx sexp_api_params(self, n), sexp x); -SEXP_API sexp sexp_open_output_file_op(sexp ctx sexp_api_params(self, n), sexp x); -SEXP_API sexp sexp_close_port_op(sexp ctx sexp_api_params(self, n), sexp x); +SEXP_API sexp sexp_env_import_op (sexp ctx, sexp self, sexp_sint_t n, sexp to, sexp from, sexp ls, sexp immutp); +SEXP_API sexp sexp_identifier_op(sexp ctx, sexp self, sexp_sint_t n, sexp x); +SEXP_API sexp sexp_syntactic_closure_expr(sexp ctx, sexp self, sexp_sint_t n, sexp x); +SEXP_API sexp sexp_identifier_eq_op(sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp c, sexp d); +SEXP_API sexp sexp_open_input_file_op(sexp ctx, sexp self, sexp_sint_t n, sexp x); +SEXP_API sexp sexp_open_output_file_op(sexp ctx, sexp self, sexp_sint_t n, sexp x); +SEXP_API sexp sexp_close_port_op(sexp ctx, sexp self, sexp_sint_t n, sexp x); SEXP_API sexp sexp_env_define (sexp ctx, sexp env, sexp sym, sexp val); SEXP_API sexp sexp_env_cell (sexp env, sexp sym, int localp); SEXP_API sexp sexp_env_ref (sexp env, sexp sym, sexp dflt); @@ -85,18 +85,18 @@ SEXP_API sexp sexp_parameter_ref (sexp ctx, sexp param); SEXP_API void sexp_warn_undefs (sexp ctx, sexp from, sexp to); SEXP_API sexp sexp_make_lit (sexp ctx, sexp value); SEXP_API sexp sexp_make_opcode (sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc1); -SEXP_API sexp sexp_make_procedure_op (sexp ctx sexp_api_params(self, n), sexp flags, sexp num_args, sexp bc, sexp vars); +SEXP_API sexp sexp_make_procedure_op (sexp ctx, sexp self, sexp_sint_t n, sexp flags, sexp num_args, sexp bc, sexp vars); SEXP_API sexp sexp_define_foreign_aux (sexp ctx, sexp env, const char *name, int num_args, int flags, sexp_proc1 f, sexp data); #if SEXP_USE_NATIVE_X86 -SEXP_API sexp sexp_write_char_op(sexp ctx sexp_api_params(self, n), sexp ch, sexp out); -SEXP_API sexp sexp_newline_op(sexp ctx sexp_api_params(self, n), sexp out); -SEXP_API sexp sexp_read_char_op(sexp ctx sexp_api_params(self, n), sexp in); -SEXP_API sexp sexp_peek_char_op(sexp ctx sexp_api_params(self, n), sexp in); -SEXP_API sexp sexp_exact_to_inexact(sexp ctx sexp_api_params(self, n), sexp i); -SEXP_API sexp sexp_inexact_to_exact(sexp ctx sexp_api_params(self, n), sexp x); -SEXP_API sexp sexp_char_upcase(sexp ctx sexp_api_params(self, n), sexp ch); -SEXP_API sexp sexp_char_downcase(sexp ctx sexp_api_params(self, n), sexp ch); +SEXP_API sexp sexp_write_char_op(sexp ctx, sexp self, sexp_sint_t n, sexp ch, sexp out); +SEXP_API sexp sexp_newline_op(sexp ctx, sexp self, sexp_sint_t n, sexp out); +SEXP_API sexp sexp_read_char_op(sexp ctx, sexp self, sexp_sint_t n, sexp in); +SEXP_API sexp sexp_peek_char_op(sexp ctx, sexp self, sexp_sint_t n, sexp in); +SEXP_API sexp sexp_exact_to_inexact(sexp ctx, sexp self, sexp_sint_t n, sexp i); +SEXP_API sexp sexp_inexact_to_exact(sexp ctx, sexp self, sexp_sint_t n, sexp x); +SEXP_API sexp sexp_char_upcase(sexp ctx, sexp self, sexp_sint_t n, sexp ch); +SEXP_API sexp sexp_char_downcase(sexp ctx, sexp self, sexp_sint_t n, sexp ch); #endif #define sexp_define_foreign(c,e,s,n,f) sexp_define_foreign_aux(c,e,s,n,0,(sexp_proc1)f,NULL) @@ -111,32 +111,31 @@ SEXP_API sexp sexp_define_foreign_param (sexp ctx, sexp env, const char *name, i #define sexp_env_push_rename(ctx, env, tmp, name, value) (tmp=sexp_cons(ctx,name,value), sexp_env_next_cell(tmp)=sexp_env_renames(env), sexp_env_renames(env)=tmp) #if SEXP_USE_TYPE_DEFS -SEXP_API sexp sexp_make_type_predicate_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type); -SEXP_API sexp sexp_make_constructor_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type); -SEXP_API sexp sexp_make_getter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index); -SEXP_API sexp sexp_make_setter_op (sexp ctx sexp_api_params(self, n), sexp name, sexp type, sexp index); +SEXP_API sexp sexp_make_type_predicate_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type); +SEXP_API sexp sexp_make_constructor_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type); +SEXP_API sexp sexp_make_getter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index); +SEXP_API sexp sexp_make_setter_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp type, sexp index); #endif /* simplify primitive API interface */ -#define sexp_make_synclo(ctx, a, b, c) sexp_make_synclo_op(ctx sexp_api_pass(NULL, 3), a, b, c) -#define sexp_make_procedure(ctx, f, n, b, v) sexp_make_procedure_op(ctx sexp_api_pass(NULL, 4), f, n, b, v) -#define sexp_make_env(ctx) sexp_make_env_op(ctx sexp_api_pass(NULL, 0)) -#define sexp_make_null_env(ctx, v) sexp_make_null_env_op(ctx sexp_api_pass(NULL, 0), v) -#define sexp_make_standard_env(ctx) sexp_make_standard_env_op(ctx sexp_api_pass(NULL, 0)) -#define sexp_add_module_directory(ctx, d, a) sexp_add_module_directory_op(ctx sexp_api_pass(NULL, 1), d, a) -#define sexp_eval(ctx, x, e) sexp_eval_op(ctx sexp_api_pass(NULL, 2), x, e) -#define sexp_load(ctx, f, e) sexp_load_op(ctx sexp_api_pass(NULL, 2), f, e) -#define sexp_env_import(ctx, a, b, c, d) sexp_env_import_op(ctx sexp_api_pass(NULL, 4), a, b, c, d) -#define sexp_identifierp(ctx, x) sexp_identifierp_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_identifier_to_symbol(ctx, x) sexp_syntactic_closure_expr(ctx sexp_api_pass(NULL, 1), x) -#define sexp_identifier_eq(ctx, a, b, c, d) sexp_identifier_eq_op(ctx sexp_api_pass(NULL, 4), a, b, c, d) -#define sexp_open_input_file(ctx, x) sexp_open_input_file_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_open_output_file(ctx, x) sexp_open_output_file_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_close_port(ctx, x) sexp_close_port_op(ctx sexp_api_pass(NULL, 1), x) +#define sexp_make_synclo(ctx, a, b, c) sexp_make_synclo_op(ctx, NULL, 3, a, b, c) +#define sexp_make_procedure(ctx, f, n, b, v) sexp_make_procedure_op(ctx, NULL, 4, f, n, b, v) +#define sexp_make_env(ctx) sexp_make_env_op(ctx, NULL, 0) +#define sexp_make_null_env(ctx, v) sexp_make_null_env_op(ctx, NULL, 0, v) +#define sexp_make_standard_env(ctx) sexp_make_standard_env_op(ctx, NULL, 0) +#define sexp_add_module_directory(ctx, d, a) sexp_add_module_directory_op(ctx, NULL, 1, d, a) +#define sexp_eval(ctx, x, e) sexp_eval_op(ctx, NULL, 2, x, e) +#define sexp_load(ctx, f, e) sexp_load_op(ctx, NULL, 2, f, e) +#define sexp_env_import(ctx, a, b, c, d) sexp_env_import_op(ctx, NULL, 4, a, b, c, d) +#define sexp_identifierp(ctx, x) sexp_identifierp_op(ctx, NULL, 1, x) +#define sexp_identifier_to_symbol(ctx, x) sexp_syntactic_closure_expr(ctx, NULL, 1, x) +#define sexp_identifier_eq(ctx, a, b, c, d) sexp_identifier_eq_op(ctx, NULL, 4, a, b, c, d) +#define sexp_open_input_file(ctx, x) sexp_open_input_file_op(ctx, NULL, 1, x) +#define sexp_open_output_file(ctx, x) sexp_open_output_file_op(ctx, NULL, 1, x) +#define sexp_close_port(ctx, x) sexp_close_port_op(ctx, NULL, 1, x) #ifdef __cplusplus } /* extern "C" */ #endif #endif /* ! SEXP_EVAL_H */ - diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index c245de22..6db0facc 100755 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -1,5 +1,5 @@ /* sexp.h -- header for sexp library */ -/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #ifndef SEXP_H @@ -191,7 +191,7 @@ typedef struct sexp_struct *sexp; #define SEXP_MIN_FIXNUM (-SEXP_MAX_FIXNUM-1) #if SEXP_USE_SELF_PARAMETER -#define sexp_api_params(self, n) , sexp self, long n +#define sexp_api_params(self, n) , sexp self, sexp_sint_t n #define sexp_api_pass(self, n) , self, n #else #define sexp_api_params(self, n) @@ -199,13 +199,13 @@ typedef struct sexp_struct *sexp; #endif /* procedure types */ -typedef sexp (*sexp_proc1) (sexp sexp_api_params(self, n)); -typedef sexp (*sexp_proc2) (sexp sexp_api_params(self, n), sexp); -typedef sexp (*sexp_proc3) (sexp sexp_api_params(self, n), sexp, sexp); -typedef sexp (*sexp_proc4) (sexp sexp_api_params(self, n), sexp, sexp, sexp); -typedef sexp (*sexp_proc5) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc6) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc7) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc1) (sexp, sexp, sexp_sint_t); +typedef sexp (*sexp_proc2) (sexp, sexp, sexp_sint_t, sexp); +typedef sexp (*sexp_proc3) (sexp, sexp, sexp_sint_t, sexp, sexp); +typedef sexp (*sexp_proc4) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp); +typedef sexp (*sexp_proc5) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc6) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc7) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp); typedef struct sexp_free_list_t *sexp_free_list; struct sexp_free_list_t { @@ -1149,70 +1149,70 @@ SEXP_API sexp sexp_buffered_flush (sexp ctx, sexp p); SEXP_API sexp sexp_alloc_tagged_aux(sexp ctx, size_t size, sexp_uint_t tag sexp_current_source_param); SEXP_API sexp sexp_make_context(sexp ctx, size_t size, size_t max_size); -SEXP_API sexp sexp_cons_op(sexp ctx sexp_api_params(self, n), sexp head, sexp tail); +SEXP_API sexp sexp_cons_op(sexp ctx, sexp self, sexp_sint_t n, sexp head, sexp tail); SEXP_API sexp sexp_list2(sexp ctx, sexp a, sexp b); -SEXP_API sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp bound); -SEXP_API sexp sexp_equalp_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b); -SEXP_API sexp sexp_listp_op(sexp ctx sexp_api_params(self, n), sexp obj); -SEXP_API sexp sexp_reverse_op(sexp ctx sexp_api_params(self, n), sexp ls); -SEXP_API sexp sexp_nreverse_op(sexp ctx sexp_api_params(self, n), sexp ls); -SEXP_API sexp sexp_copy_list_op(sexp ctx sexp_api_params(self, n), sexp ls); -SEXP_API sexp sexp_append2_op(sexp ctx sexp_api_params(self, n), sexp a, sexp b); -SEXP_API sexp sexp_memq_op(sexp ctx sexp_api_params(self, n), sexp x, sexp ls); -SEXP_API sexp sexp_assq_op(sexp ctx sexp_api_params(self, n), sexp x, sexp ls); -SEXP_API sexp sexp_length_op(sexp ctx sexp_api_params(self, n), sexp ls); +SEXP_API sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp bound); +SEXP_API sexp sexp_equalp_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b); +SEXP_API sexp sexp_listp_op(sexp ctx, sexp self, sexp_sint_t n, sexp obj); +SEXP_API sexp sexp_reverse_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls); +SEXP_API sexp sexp_nreverse_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls); +SEXP_API sexp sexp_copy_list_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls); +SEXP_API sexp sexp_append2_op(sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b); +SEXP_API sexp sexp_memq_op(sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls); +SEXP_API sexp sexp_assq_op(sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls); +SEXP_API sexp sexp_length_op(sexp ctx, sexp self, sexp_sint_t n, sexp ls); SEXP_API sexp sexp_c_string(sexp ctx, const char *str, sexp_sint_t slen); -SEXP_API sexp sexp_make_bytes_op(sexp ctx sexp_api_params(self, n), sexp len, sexp i); -SEXP_API sexp sexp_make_string_op(sexp ctx sexp_api_params(self, n), sexp len, sexp ch); -SEXP_API sexp sexp_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp end); -SEXP_API sexp sexp_string_concatenate_op (sexp ctx sexp_api_params(self, n), sexp str_ls, sexp sep); +SEXP_API sexp sexp_make_bytes_op(sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp i); +SEXP_API sexp sexp_make_string_op(sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp ch); +SEXP_API sexp sexp_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp start, sexp end); +SEXP_API sexp sexp_string_concatenate_op (sexp ctx, sexp self, sexp_sint_t n, sexp str_ls, sexp sep); SEXP_API sexp sexp_intern (sexp ctx, const char *str, sexp_sint_t len); -SEXP_API sexp sexp_string_to_symbol_op (sexp ctx sexp_api_params(self, n), sexp str); -SEXP_API sexp sexp_string_to_number_op (sexp ctx sexp_api_params(self, n), sexp str, sexp b); -SEXP_API sexp sexp_flonump_op (sexp ctx sexp_api_params(self, n), sexp x); -SEXP_API sexp sexp_make_vector_op (sexp ctx sexp_api_params(self, n), sexp len, sexp dflt); -SEXP_API sexp sexp_list_to_vector_op (sexp ctx sexp_api_params(self, n), sexp ls); +SEXP_API sexp sexp_string_to_symbol_op (sexp ctx, sexp self, sexp_sint_t n, sexp str); +SEXP_API sexp sexp_string_to_number_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp b); +SEXP_API sexp sexp_flonump_op (sexp ctx, sexp self, sexp_sint_t n, sexp x); +SEXP_API sexp sexp_make_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp dflt); +SEXP_API sexp sexp_list_to_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls); SEXP_API sexp sexp_make_cpointer (sexp ctx, sexp_uint_t type_id, void* value, sexp parent, int freep); -SEXP_API sexp sexp_write_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out); -SEXP_API sexp sexp_display_op (sexp ctx sexp_api_params(self, n), sexp obj, sexp out); -SEXP_API sexp sexp_flush_output_op (sexp ctx sexp_api_params(self, n), sexp out); +SEXP_API sexp sexp_write_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out); +SEXP_API sexp sexp_display_op (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp out); +SEXP_API sexp sexp_flush_output_op (sexp ctx, sexp self, sexp_sint_t n, sexp out); SEXP_API sexp sexp_read_string (sexp ctx, sexp in, int sentinel); SEXP_API sexp sexp_read_symbol (sexp ctx, sexp in, int init, int internp); SEXP_API sexp sexp_read_number (sexp ctx, sexp in, int base); SEXP_API sexp sexp_read_raw (sexp ctx, sexp in); -SEXP_API sexp sexp_read_op (sexp ctx sexp_api_params(self, n), sexp in); +SEXP_API sexp sexp_read_op (sexp ctx, sexp self, sexp_sint_t n, sexp in); SEXP_API sexp sexp_read_from_string (sexp ctx, const char *str, sexp_sint_t len); SEXP_API sexp sexp_write_to_string (sexp ctx, sexp obj); -SEXP_API sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp writer, sexp out); -SEXP_API sexp sexp_finalize_port (sexp ctx sexp_api_params(self, n), sexp port); +SEXP_API sexp sexp_write_simple_object (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp writer, sexp out); +SEXP_API sexp sexp_finalize_port (sexp ctx, sexp self, sexp_sint_t n, sexp port); SEXP_API sexp sexp_make_input_port (sexp ctx, FILE* in, sexp name); SEXP_API sexp sexp_make_output_port (sexp ctx, FILE* out, sexp name); -SEXP_API sexp sexp_port_binaryp_op (sexp ctx sexp_api_params(self, n), sexp port); -SEXP_API sexp sexp_port_openp_op (sexp ctx sexp_api_params(self, n), sexp port); +SEXP_API sexp sexp_port_binaryp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port); +SEXP_API sexp sexp_port_openp_op (sexp ctx, sexp self, sexp_sint_t n, sexp port); #if SEXP_USE_FOLD_CASE_SYMS -SEXP_API sexp sexp_get_port_fold_case (sexp ctx sexp_api_params(self, n), sexp in); -SEXP_API sexp sexp_set_port_fold_case (sexp ctx sexp_api_params(self, n), sexp in, sexp x); +SEXP_API sexp sexp_get_port_fold_case (sexp ctx, sexp self, sexp_sint_t n, sexp in); +SEXP_API sexp sexp_set_port_fold_case (sexp ctx, sexp self, sexp_sint_t n, sexp in, sexp x); #endif #if SEXP_USE_OBJECT_BRACE_LITERALS -SEXP_API sexp sexp_lookup_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp id); +SEXP_API sexp sexp_lookup_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp id); #endif -SEXP_API sexp sexp_make_input_string_port_op (sexp ctx sexp_api_params(self, n), sexp str); -SEXP_API sexp sexp_make_output_string_port_op (sexp ctx sexp_api_params(self, n)); -SEXP_API sexp sexp_get_output_string_op (sexp ctx sexp_api_params(self, n), sexp port); +SEXP_API sexp sexp_make_input_string_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp str); +SEXP_API sexp sexp_make_output_string_port_op (sexp ctx, sexp self, sexp_sint_t n); +SEXP_API sexp sexp_get_output_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp port); SEXP_API sexp sexp_make_exception (sexp ctx, sexp kind, sexp message, sexp irritants, sexp procedure, sexp source); SEXP_API sexp sexp_user_exception (sexp ctx, sexp self, const char *msg, sexp x); SEXP_API sexp sexp_type_exception (sexp ctx, sexp self, sexp_uint_t type_id, sexp x); SEXP_API sexp sexp_xtype_exception (sexp ctx, sexp self, const char *msg, sexp x); SEXP_API sexp sexp_range_exception (sexp ctx, sexp obj, sexp start, sexp end); -SEXP_API sexp sexp_print_exception_op (sexp ctx sexp_api_params(self, n), sexp exn, sexp out); +SEXP_API sexp sexp_print_exception_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn, sexp out); SEXP_API sexp sexp_apply (sexp context, sexp proc, sexp args); SEXP_API sexp sexp_apply1 (sexp ctx, sexp f, sexp x); SEXP_API sexp sexp_make_foreign (sexp ctx, const char *name, int num_args, int flags, sexp_proc1 f, sexp data); SEXP_API void sexp_init(void); #if SEXP_USE_UTF8_STRINGS -SEXP_API sexp sexp_string_index_to_offset (sexp ctx sexp_api_params(self, n), sexp str, sexp index); -SEXP_API sexp sexp_utf8_substring_op (sexp ctx sexp_api_params(self, n), sexp str, sexp start, sexp end); +SEXP_API sexp sexp_string_index_to_offset (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp index); +SEXP_API sexp sexp_utf8_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp start, sexp end); SEXP_API void sexp_utf8_encode_char (unsigned char* p, int len, int c); #endif @@ -1258,9 +1258,9 @@ SEXP_API int sexp_valid_object_p(sexp ctx, sexp x); #endif #if SEXP_USE_TYPE_DEFS -SEXP_API sexp sexp_register_type_op (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc2); -SEXP_API sexp sexp_register_simple_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp parent, sexp slots); -SEXP_API sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj); +SEXP_API sexp sexp_register_type_op (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc2); +SEXP_API sexp sexp_register_simple_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp parent, sexp slots); +SEXP_API sexp sexp_finalize_c_type (sexp ctx, sexp self, sexp_sint_t n, sexp obj); #define sexp_register_c_type(ctx, name, finalizer) \ sexp_register_type(ctx, name, SEXP_FALSE, SEXP_FALSE, SEXP_ZERO, SEXP_ZERO, \ SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, \ @@ -1275,42 +1275,42 @@ SEXP_API sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj) /* simplify primitive API interface */ -#define sexp_read(ctx, in) sexp_read_op(ctx sexp_api_pass(NULL, 1), in) -#define sexp_write(ctx, obj, out) sexp_write_op(ctx sexp_api_pass(NULL, 2), obj, out) -#define sexp_display(ctx, obj, out) sexp_display_op(ctx sexp_api_pass(NULL, 2), obj, out) -#define sexp_print_exception(ctx, e, out) sexp_print_exception_op(ctx sexp_api_pass(NULL, 2), e, out) -#define sexp_flush_output(ctx, obj, out) sexp_flush_output_op(ctx sexp_api_pass(NULL, 1), out) -#define sexp_equalp(ctx, a, b) sexp_equalp_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_listp(ctx, x) sexp_listp_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_length(ctx, x) sexp_length_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_reverse(ctx, x) sexp_reverse_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_nreverse(ctx, x) sexp_nreverse_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_copy_list(ctx, x) sexp_copy_list_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_cons(ctx, a, b) sexp_cons_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_append2(ctx, a, b) sexp_append2_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_make_vector(ctx, a, b) sexp_make_vector_op(ctx sexp_api_pass(NULL, 2), a, b); -#define sexp_list_to_vector(ctx, x) sexp_list_to_vector_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_exception_type(ctx, x) sexp_exception_type_op(ctx sexp_api_pass(NULL, 1), x) -#define sexp_string_to_symbol(ctx, s) sexp_string_to_symbol_op(ctx sexp_api_pass(NULL, 1), s) -#define sexp_string_to_number(ctx, s, b) sexp_string_to_number_op(ctx sexp_api_pass(NULL, 2), s, b) -#define sexp_make_bytes(ctx, l, i) sexp_make_bytes_op(ctx sexp_api_pass(NULL, 2), l, i) -#define sexp_make_string(ctx, l, c) sexp_make_string_op(ctx sexp_api_pass(NULL, 2), l, c) -#define sexp_string_cmp(ctx, a, b, c) sexp_string_cmp_op(ctx sexp_api_pass(NULL, 3), a, b, c) -#define sexp_substring(ctx, a, b, c) sexp_substring_op(ctx sexp_api_pass(NULL, 3), a, b, c) -#define sexp_string_concatenate(ctx, ls, s) sexp_string_concatenate_op(ctx sexp_api_pass(NULL, 2), ls, s) -#define sexp_memq(ctx, a, b) sexp_memq_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_assq(ctx, a, b) sexp_assq_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_make_output_string_port(ctx) sexp_make_output_string_port_op(ctx sexp_api_pass(NULL, 0)) -#define sexp_make_input_string_port(ctx, s) sexp_make_input_string_port_op(ctx sexp_api_pass(NULL, 1), s) -#define sexp_get_output_string(ctx, out) sexp_get_output_string_op(ctx sexp_api_pass(NULL, 1), out) -#define sexp_expt(ctx, a, b) sexp_expt_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_register_simple_type(ctx, a, b, c) sexp_register_simple_type_op(ctx sexp_api_pass(NULL, 3), a, b, c) -#define sexp_register_type(ctx, a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) sexp_register_type_op(ctx sexp_api_pass(NULL, 18), a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) -#define sexp_make_type_predicate(ctx, a, b) sexp_make_type_predicate_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_make_constructor(ctx, a, b) sexp_make_constructor_op(ctx sexp_api_pass(NULL, 2), a, b) -#define sexp_make_getter(ctx, a, b, c) sexp_make_getter_op(ctx sexp_api_pass(NULL, 3), a, b, c) -#define sexp_make_setter(ctx, a, b, c) sexp_make_setter_op(ctx sexp_api_pass(NULL, 3), a, b, c) -#define sexp_lookup_type(ctx, name, id) sexp_lookup_type_op(ctx sexp_api_pass(NULL, 2), name, id) +#define sexp_read(ctx, in) sexp_read_op(ctx, NULL, 1, in) +#define sexp_write(ctx, obj, out) sexp_write_op(ctx, NULL, 2, obj, out) +#define sexp_display(ctx, obj, out) sexp_display_op(ctx, NULL, 2, obj, out) +#define sexp_print_exception(ctx, e, out) sexp_print_exception_op(ctx, NULL, 2, e, out) +#define sexp_flush_output(ctx, obj, out) sexp_flush_output_op(ctx, NULL, 1, out) +#define sexp_equalp(ctx, a, b) sexp_equalp_op(ctx, NULL, 2, a, b) +#define sexp_listp(ctx, x) sexp_listp_op(ctx, NULL, 1, x) +#define sexp_length(ctx, x) sexp_length_op(ctx, NULL, 1, x) +#define sexp_reverse(ctx, x) sexp_reverse_op(ctx, NULL, 1, x) +#define sexp_nreverse(ctx, x) sexp_nreverse_op(ctx, NULL, 1, x) +#define sexp_copy_list(ctx, x) sexp_copy_list_op(ctx, NULL, 1, x) +#define sexp_cons(ctx, a, b) sexp_cons_op(ctx, NULL, 2, a, b) +#define sexp_append2(ctx, a, b) sexp_append2_op(ctx, NULL, 2, a, b) +#define sexp_make_vector(ctx, a, b) sexp_make_vector_op(ctx, NULL, 2, a, b); +#define sexp_list_to_vector(ctx, x) sexp_list_to_vector_op(ctx, NULL, 1, x) +#define sexp_exception_type(ctx, x) sexp_exception_type_op(ctx, NULL, 1, x) +#define sexp_string_to_symbol(ctx, s) sexp_string_to_symbol_op(ctx, NULL, 1, s) +#define sexp_string_to_number(ctx, s, b) sexp_string_to_number_op(ctx, NULL, 2, s, b) +#define sexp_make_bytes(ctx, l, i) sexp_make_bytes_op(ctx, NULL, 2, l, i) +#define sexp_make_string(ctx, l, c) sexp_make_string_op(ctx, NULL, 2, l, c) +#define sexp_string_cmp(ctx, a, b, c) sexp_string_cmp_op(ctx, NULL, 3, a, b, c) +#define sexp_substring(ctx, a, b, c) sexp_substring_op(ctx, NULL, 3, a, b, c) +#define sexp_string_concatenate(ctx, ls, s) sexp_string_concatenate_op(ctx, NULL, 2, ls, s) +#define sexp_memq(ctx, a, b) sexp_memq_op(ctx, NULL, 2, a, b) +#define sexp_assq(ctx, a, b) sexp_assq_op(ctx, NULL, 2, a, b) +#define sexp_make_output_string_port(ctx) sexp_make_output_string_port_op(ctx, NULL, 0) +#define sexp_make_input_string_port(ctx, s) sexp_make_input_string_port_op(ctx, NULL, 1, s) +#define sexp_get_output_string(ctx, out) sexp_get_output_string_op(ctx, NULL, 1, out) +#define sexp_expt(ctx, a, b) sexp_expt_op(ctx, NULL, 2, a, b) +#define sexp_register_simple_type(ctx, a, b, c) sexp_register_simple_type_op(ctx, NULL, 3, a, b, c) +#define sexp_register_type(ctx, a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) sexp_register_type_op(ctx, NULL, 18, a, b, c, d, e, f, g, h, i, j, k, l, m, o, p, q, r, s) +#define sexp_make_type_predicate(ctx, a, b) sexp_make_type_predicate_op(ctx, NULL, 2, a, b) +#define sexp_make_constructor(ctx, a, b) sexp_make_constructor_op(ctx, NULL, 2, a, b) +#define sexp_make_getter(ctx, a, b, c) sexp_make_getter_op(ctx, NULL, 3, a, b, c) +#define sexp_make_setter(ctx, a, b, c) sexp_make_setter_op(ctx, NULL, 3, a, b, c) +#define sexp_lookup_type(ctx, name, id) sexp_lookup_type_op(ctx, NULL, 2, name, id) enum sexp_opcode_names { SEXP_OP_NOOP, @@ -1404,4 +1404,3 @@ enum sexp_opcode_names { #endif #endif /* ! SEXP_H */ - diff --git a/lib/chibi/ast.c b/lib/chibi/ast.c index cd997dd4..84e3382f 100644 --- a/lib/chibi/ast.c +++ b/lib/chibi/ast.c @@ -36,7 +36,7 @@ static void sexp_define_accessors (sexp ctx, sexp env, sexp_uint_t ctype, sexp_gc_release2(ctx); } -static sexp sexp_get_env_cell (sexp ctx sexp_api_params(self, n), sexp env, sexp id) { +static sexp sexp_get_env_cell (sexp ctx, sexp self, sexp_sint_t n, sexp env, sexp id) { sexp cell; sexp_assert_type(ctx, sexp_envp, SEXP_ENV, env); cell = sexp_env_cell(env, id, 0); @@ -47,7 +47,7 @@ static sexp sexp_get_env_cell (sexp ctx sexp_api_params(self, n), sexp env, sexp return cell ? cell : SEXP_FALSE; } -static sexp sexp_get_opcode_name (sexp ctx sexp_api_params(self, n), sexp op) { +static sexp sexp_get_opcode_name (sexp ctx, sexp self, sexp_sint_t n, sexp op) { if (! sexp_opcodep(op)) return sexp_type_exception(ctx, self, SEXP_OPCODE, op); else if (! sexp_opcode_name(op)) @@ -74,7 +74,7 @@ static sexp sexp_translate_opcode_type (sexp ctx, sexp type) { return res; } -static sexp sexp_get_opcode_ret_type (sexp ctx sexp_api_params(self, n), sexp op) { +static sexp sexp_get_opcode_ret_type (sexp ctx, sexp self, sexp_sint_t n, sexp op) { sexp res; if (! sexp_opcodep(op)) return sexp_type_exception(ctx, self, SEXP_OPCODE, op); @@ -86,7 +86,7 @@ static sexp sexp_get_opcode_ret_type (sexp ctx sexp_api_params(self, n), sexp op return sexp_translate_opcode_type(ctx, res); } -static sexp sexp_get_opcode_param_type (sexp ctx sexp_api_params(self, n), sexp op, sexp k) { +static sexp sexp_get_opcode_param_type (sexp ctx, sexp self, sexp_sint_t n, sexp op, sexp k) { sexp res; int p = sexp_unbox_fixnum(k); if (! sexp_opcodep(op)) @@ -115,31 +115,31 @@ static sexp sexp_get_opcode_param_type (sexp ctx sexp_api_params(self, n), sexp return sexp_translate_opcode_type(ctx, res); } -static sexp sexp_get_opcode_num_params (sexp ctx sexp_api_params(self, n), sexp op) { +static sexp sexp_get_opcode_num_params (sexp ctx, sexp self, sexp_sint_t n, sexp op) { if (! sexp_opcodep(op)) return sexp_type_exception(ctx, self, SEXP_OPCODE, op); return sexp_make_fixnum(sexp_opcode_num_args(op)); } -static sexp sexp_get_opcode_variadic_p (sexp ctx sexp_api_params(self, n), sexp op) { +static sexp sexp_get_opcode_variadic_p (sexp ctx, sexp self, sexp_sint_t n, sexp op) { if (! sexp_opcodep(op)) return sexp_type_exception(ctx, self, SEXP_OPCODE, op); return sexp_make_boolean(sexp_opcode_variadic_p(op)); } -static sexp sexp_get_port_line (sexp ctx sexp_api_params(self, n), sexp p) { +static sexp sexp_get_port_line (sexp ctx, sexp self, sexp_sint_t n, sexp p) { sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, p); return sexp_make_fixnum(sexp_port_line(p)); } -static sexp sexp_set_port_line (sexp ctx sexp_api_params(self, n), sexp p, sexp i) { +static sexp sexp_set_port_line (sexp ctx, sexp self, sexp_sint_t n, sexp p, sexp i) { sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, p); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); sexp_port_line(p) = sexp_unbox_fixnum(i); return SEXP_VOID; } -static sexp sexp_type_of (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_type_of (sexp ctx, sexp self, sexp_sint_t n, sexp x) { if (sexp_pointerp(x)) return sexp_object_type(ctx, x); else if (sexp_fixnump(x)) @@ -160,33 +160,33 @@ static sexp sexp_type_of (sexp ctx sexp_api_params(self, n), sexp x) { return sexp_type_by_index(ctx, SEXP_OBJECT); } -static sexp sexp_type_name_op (sexp ctx sexp_api_params(self, n), sexp t) { +static sexp sexp_type_name_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) { sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); return sexp_type_name(t); } -static sexp sexp_type_cpl_op (sexp ctx sexp_api_params(self, n), sexp t) { +static sexp sexp_type_cpl_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) { sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); return sexp_type_cpl(t); } -static sexp sexp_type_slots_op (sexp ctx sexp_api_params(self, n), sexp t) { +static sexp sexp_type_slots_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) { sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); return sexp_type_slots(t); } -static sexp sexp_type_num_slots_op (sexp ctx sexp_api_params(self, n), sexp t) { +static sexp sexp_type_num_slots_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) { sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); return sexp_truep(sexp_type_slots(t)) ? sexp_length(ctx, sexp_type_slots(t)) : sexp_make_fixnum(sexp_type_field_eq_len_base(t)); } -static sexp sexp_type_printer_op (sexp ctx sexp_api_params(self, n), sexp t) { +static sexp sexp_type_printer_op (sexp ctx, sexp self, sexp_sint_t n, sexp t) { sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); return sexp_type_print(t) ? sexp_type_print(t) : SEXP_FALSE; } -static sexp sexp_object_size (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_object_size (sexp ctx, sexp self, sexp_sint_t n, sexp x) { sexp t; if ((! sexp_pointerp(x)) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx))) return SEXP_ZERO; @@ -194,7 +194,7 @@ static sexp sexp_object_size (sexp ctx sexp_api_params(self, n), sexp x) { return sexp_make_fixnum(sexp_type_size_of_object(t, x)); } -static sexp sexp_integer_to_immediate (sexp ctx sexp_api_params(self, n), sexp i, sexp dflt) { +static sexp sexp_integer_to_immediate (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp dflt) { sexp x = (sexp)sexp_unbox_fixnum(i); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, i); if (sexp_pointerp(x)) @@ -202,7 +202,7 @@ static sexp sexp_integer_to_immediate (sexp ctx sexp_api_params(self, n), sexp i return x; } -static sexp sexp_make_lambda_op (sexp ctx sexp_api_params(self, n), sexp name, sexp params, sexp body, sexp locals) { +static sexp sexp_make_lambda_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp params, sexp body, sexp locals) { sexp res = sexp_alloc_type(ctx, lambda, SEXP_LAMBDA); sexp_lambda_name(res) = name; sexp_lambda_params(res) = params; @@ -216,7 +216,7 @@ static sexp sexp_make_lambda_op (sexp ctx sexp_api_params(self, n), sexp name, s return res; } -static sexp sexp_copy_lambda (sexp ctx sexp_api_params(self, n), sexp lambda) { +static sexp sexp_copy_lambda (sexp ctx, sexp self, sexp_sint_t n, sexp lambda) { sexp res = sexp_alloc_type(ctx, lambda, SEXP_LAMBDA); sexp_lambda_name(res) = sexp_lambda_name(lambda); sexp_lambda_params(res) = sexp_lambda_params(lambda); @@ -230,21 +230,21 @@ static sexp sexp_copy_lambda (sexp ctx sexp_api_params(self, n), sexp lambda) { return res; } -static sexp sexp_make_set_op (sexp ctx sexp_api_params(self, n), sexp var, sexp value) { +static sexp sexp_make_set_op (sexp ctx, sexp self, sexp_sint_t n, sexp var, sexp value) { sexp res = sexp_alloc_type(ctx, set, SEXP_SET); sexp_set_var(res) = var; sexp_set_value(res) = value; return res; } -static sexp sexp_make_ref_op (sexp ctx sexp_api_params(self, n), sexp name, sexp cell) { +static sexp sexp_make_ref_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp cell) { sexp res = sexp_alloc_type(ctx, ref, SEXP_REF); sexp_ref_name(res) = name; sexp_ref_cell(res) = cell; return res; } -static sexp sexp_make_cnd_op (sexp ctx sexp_api_params(self, n), sexp test, sexp pass, sexp fail) { +static sexp sexp_make_cnd_op (sexp ctx, sexp self, sexp_sint_t n, sexp test, sexp pass, sexp fail) { sexp res = sexp_alloc_type(ctx, cnd, SEXP_CND); sexp_cnd_test(res) = test; sexp_cnd_pass(res) = pass; @@ -252,19 +252,19 @@ static sexp sexp_make_cnd_op (sexp ctx sexp_api_params(self, n), sexp test, sexp return res; } -static sexp sexp_make_seq (sexp ctx sexp_api_params(self, n), sexp ls) { +static sexp sexp_make_seq (sexp ctx, sexp self, sexp_sint_t n, sexp ls) { sexp res = sexp_alloc_type(ctx, seq, SEXP_SEQ); sexp_seq_ls(res) = ls; return res; } -static sexp sexp_make_lit_op (sexp ctx sexp_api_params(self, n), sexp value) { +static sexp sexp_make_lit_op (sexp ctx, sexp self, sexp_sint_t n, sexp value) { sexp res = sexp_alloc_type(ctx, lit, SEXP_LIT); sexp_lit_value(res) = value; return res; } -static sexp sexp_analyze_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) { +static sexp sexp_analyze_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp e) { sexp ctx2 = ctx; if (sexp_envp(e)) { ctx2 = sexp_make_child_context(ctx, NULL); @@ -273,7 +273,7 @@ static sexp sexp_analyze_op (sexp ctx sexp_api_params(self, n), sexp x, sexp e) return sexp_analyze(ctx2, x); } -static sexp sexp_optimize (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_optimize (sexp ctx, sexp self, sexp_sint_t n, sexp x) { sexp_gc_var2(ls, res); sexp_gc_preserve2(ctx, ls, res); res = x; @@ -285,7 +285,7 @@ static sexp sexp_optimize (sexp ctx sexp_api_params(self, n), sexp x) { return res; } -static sexp sexp_gc_op (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_gc_op (sexp ctx, sexp self, sexp_sint_t n) { size_t sum_freed=0; #if SEXP_USE_BOEHM GC_gcollect(); @@ -295,7 +295,7 @@ static sexp sexp_gc_op (sexp ctx sexp_api_params(self, n)) { return sexp_make_unsigned_integer(ctx, sum_freed); } -static sexp sexp_string_contains (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { +static sexp sexp_string_contains (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) { const char *res; sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, x); sexp_assert_type(ctx, sexp_stringp, SEXP_STRING, y); @@ -303,7 +303,7 @@ static sexp sexp_string_contains (sexp ctx sexp_api_params(self, n), sexp x, sex return res ? sexp_make_fixnum(res-sexp_string_data(x)) : SEXP_FALSE; } -static sexp sexp_error_string (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_error_string (sexp ctx, sexp self, sexp_sint_t n, sexp x) { int err; if (x == SEXP_FALSE) { err = errno; @@ -314,14 +314,14 @@ static sexp sexp_error_string (sexp ctx sexp_api_params(self, n), sexp x) { return sexp_c_string(ctx, strerror(err), -1); } -static sexp sexp_update_free_vars (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_update_free_vars (sexp ctx, sexp self, sexp_sint_t n, sexp x) { return sexp_free_vars(ctx, x, SEXP_NULL); } #define sexp_define_type(ctx, name, tag) \ sexp_env_define(ctx, env, sexp_intern(ctx, name, -1), sexp_type_by_index(ctx, tag)); -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_type(ctx, "Object", SEXP_OBJECT); sexp_define_type(ctx, "Number", SEXP_NUMBER); sexp_define_type(ctx, "Bignum", SEXP_BIGNUM); diff --git a/lib/chibi/disasm.c b/lib/chibi/disasm.c index fe38d84a..5e85b6b4 100644 --- a/lib/chibi/disasm.c +++ b/lib/chibi/disasm.c @@ -185,11 +185,11 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) { return SEXP_VOID; } -static sexp sexp_disasm (sexp ctx sexp_api_params(self, n), sexp bc, sexp out) { +static sexp sexp_disasm (sexp ctx, sexp self, sexp_sint_t n, sexp bc, sexp out) { return disasm(ctx, self, bc, out, 0); } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign_param(ctx, env, "disasm", 2, (sexp_proc1)sexp_disasm, "current-output-port"); return SEXP_VOID; } diff --git a/lib/chibi/heap-stats.c b/lib/chibi/heap-stats.c index 145559e3..00a48a74 100644 --- a/lib/chibi/heap-stats.c +++ b/lib/chibi/heap-stats.c @@ -105,11 +105,11 @@ static sexp sexp_heap_walk (sexp ctx, int depth, int printp) { return res; } -static sexp sexp_heap_stats (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_heap_stats (sexp ctx, sexp self, sexp_sint_t n) { return sexp_heap_walk(ctx, 0, 0); } -static sexp sexp_heap_dump (sexp ctx sexp_api_params(self, n), sexp depth) { +static sexp sexp_heap_dump (sexp ctx, sexp self, sexp_sint_t n, sexp depth) { if (! sexp_fixnump(depth) || (sexp_unbox_fixnum(depth) < 0)) return sexp_xtype_exception(ctx, self, "bad heap-dump depth", depth); return sexp_heap_walk(ctx, sexp_unbox_fixnum(depth), 1); @@ -117,17 +117,17 @@ static sexp sexp_heap_dump (sexp ctx sexp_api_params(self, n), sexp depth) { #else -static sexp sexp_heap_stats (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_heap_stats (sexp ctx, sexp self, sexp_sint_t n) { return SEXP_NULL; } -static sexp sexp_heap_dump (sexp ctx sexp_api_params(self, n), sexp depth) { +static sexp sexp_heap_dump (sexp ctx, sexp self, sexp_sint_t n, sexp depth) { return SEXP_NULL; } #endif -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "heap-stats", 0, sexp_heap_stats); sexp_define_foreign_opt(ctx, env, "heap-dump", 1, sexp_heap_dump, SEXP_ONE); return SEXP_VOID; diff --git a/lib/chibi/optimize/profile.c b/lib/chibi/optimize/profile.c index 350ad934..95de0cff 100644 --- a/lib/chibi/optimize/profile.c +++ b/lib/chibi/optimize/profile.c @@ -4,13 +4,13 @@ #include -static sexp sexp_increment_cdr (sexp ctx sexp_api_params(self, n), sexp pair) { +static sexp sexp_increment_cdr (sexp ctx, sexp self, sexp_sint_t n, sexp pair) { sexp_assert_type(ctx, sexp_pairp, SEXP_PAIR, pair); sexp_cdr(pair) = sexp_make_fixnum(1 + sexp_unbox_fixnum(sexp_cdr(pair))); return SEXP_VOID; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "increment-cdr!", 1, sexp_increment_cdr); return SEXP_VOID; } diff --git a/lib/chibi/optimize/rest.c b/lib/chibi/optimize/rest.c index daa1b198..f8352e11 100644 --- a/lib/chibi/optimize/rest.c +++ b/lib/chibi/optimize/rest.c @@ -4,7 +4,7 @@ #include -static sexp sexp_num_parameters (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_num_parameters (sexp ctx, sexp self, sexp_sint_t n) { return sexp_stack_data(sexp_context_stack(ctx))[sexp_context_last_fp(ctx)]; } @@ -19,7 +19,7 @@ static sexp copy_opcode (sexp ctx, struct sexp_opcode_struct *op) { return res; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_gc_var2(name, op); sexp_gc_preserve2(ctx, name, op); sexp_define_foreign(ctx, env, "num-parameters", 0, sexp_num_parameters); diff --git a/lib/chibi/weak.c b/lib/chibi/weak.c index 574c36cf..d3d14372 100644 --- a/lib/chibi/weak.c +++ b/lib/chibi/weak.c @@ -1,6 +1,6 @@ -/* weak.c -- weak pointers and ephemerons */ -/* Copyright (c) 2010 Alex Shinn. All rights reserved. */ -/* BSD-style license: http://synthcode.com/license.txt */ +/* weak.c -- weak pointers and ephemerons */ +/* Copyright (c) 2010-2011 Alex Shinn. All rights reserved. */ +/* BSD-style license: http://synthcode.com/license.txt */ #include @@ -12,7 +12,7 @@ static int sexp_ephemeron_id, sexp_weak_vector_id; #define sexp_weak_vector_p(x) sexp_check_tag(x, sexp_weak_vector_id) -sexp sexp_make_ephemeron (sexp ctx sexp_api_params(self, n), sexp key, sexp value) { +sexp sexp_make_ephemeron (sexp ctx, sexp self, sexp_sint_t n, sexp key, sexp value) { sexp res = sexp_alloc_type(ctx, pair, sexp_ephemeron_id); if (! sexp_exceptionp(res)) { sexp_ephemeron_key(res) = key; @@ -21,11 +21,11 @@ sexp sexp_make_ephemeron (sexp ctx sexp_api_params(self, n), sexp key, sexp valu return res; } -sexp sexp_ephemeron_brokenp_op (sexp ctx sexp_api_params(self, n), sexp eph) { +sexp sexp_ephemeron_brokenp_op (sexp ctx, sexp self, sexp_sint_t n, sexp eph) { return sexp_make_boolean(sexp_brokenp(eph)); } -sexp sexp_make_weak_vector (sexp ctx sexp_api_params(self, n), sexp len) { +sexp sexp_make_weak_vector (sexp ctx, sexp self, sexp_sint_t n, sexp len) { sexp vec, *x; int i, clen = sexp_unbox_fixnum(len); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len); @@ -39,25 +39,25 @@ sexp sexp_make_weak_vector (sexp ctx sexp_api_params(self, n), sexp len) { return vec; } -sexp sexp_weak_vector_length (sexp ctx sexp_api_params(self, n), sexp v) { +sexp sexp_weak_vector_length (sexp ctx, sexp self, sexp_sint_t n, sexp v) { sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v); return sexp_make_fixnum(sexp_vector_length(v)); } -sexp sexp_weak_vector_ref (sexp ctx sexp_api_params(self, n), sexp v, sexp k) { +sexp sexp_weak_vector_ref (sexp ctx, sexp self, sexp_sint_t n, sexp v, sexp k) { sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, k); return sexp_vector_ref(v, k); } -sexp sexp_weak_vector_set (sexp ctx sexp_api_params(self, n), sexp v, sexp k, sexp x) { +sexp sexp_weak_vector_set (sexp ctx, sexp self, sexp_sint_t n, sexp v, sexp k, sexp x) { sexp_assert_type(ctx, sexp_weak_vector_p, sexp_weak_vector_id, v); sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, k); sexp_vector_set(v, k, x); return SEXP_VOID; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp v; sexp_gc_var3(name, t, op); sexp_gc_preserve3(ctx, name, t, op); diff --git a/lib/scheme/time.c b/lib/scheme/time.c index 62294f66..406049c8 100644 --- a/lib/scheme/time.c +++ b/lib/scheme/time.c @@ -8,12 +8,12 @@ /* TODO: Check a leap second table file at appropriate intervals. */ static time_t leap_seconds_since_epoch = 34; -static sexp sexp_current_second (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_current_second (sexp ctx, sexp self, sexp_sint_t n) { time_t res = time(NULL); return sexp_make_flonum(ctx, res + leap_seconds_since_epoch); } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "current-second", 0, sexp_current_second); return SEXP_VOID; } diff --git a/lib/srfi/18/threads.c b/lib/srfi/18/threads.c index 74e8da43..bb4fe6dd 100644 --- a/lib/srfi/18/threads.c +++ b/lib/srfi/18/threads.c @@ -46,31 +46,31 @@ static void sexp_define_type_predicate_by_tag (sexp ctx, sexp env, char *cname, sexp_gc_release2(ctx); } -sexp sexp_thread_timeoutp (sexp ctx sexp_api_params(self, n)) { +sexp sexp_thread_timeoutp (sexp ctx, sexp self, sexp_sint_t n) { return sexp_make_boolean(sexp_context_timeoutp(ctx)); } -sexp sexp_thread_name (sexp ctx sexp_api_params(self, n), sexp thread) { +sexp sexp_thread_name (sexp ctx, sexp self, sexp_sint_t n, sexp thread) { sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); return sexp_context_name(thread); } -sexp sexp_thread_specific (sexp ctx sexp_api_params(self, n), sexp thread) { +sexp sexp_thread_specific (sexp ctx, sexp self, sexp_sint_t n, sexp thread) { sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); return sexp_context_specific(thread); } -sexp sexp_thread_specific_set (sexp ctx sexp_api_params(self, n), sexp thread, sexp val) { +sexp sexp_thread_specific_set (sexp ctx, sexp self, sexp_sint_t n, sexp thread, sexp val) { sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); sexp_context_specific(thread) = val; return SEXP_VOID; } -sexp sexp_current_thread (sexp ctx sexp_api_params(self, n)) { +sexp sexp_current_thread (sexp ctx, sexp self, sexp_sint_t n) { return ctx; } -sexp sexp_make_thread (sexp ctx sexp_api_params(self, n), sexp thunk, sexp name) { +sexp sexp_make_thread (sexp ctx, sexp self, sexp_sint_t n, sexp thunk, sexp name) { sexp res, *stack; sexp_assert_type(ctx, sexp_procedurep, SEXP_PROCEDURE, thunk); res = sexp_make_eval_context(ctx, SEXP_FALSE, sexp_context_env(ctx), 0, 0); @@ -85,7 +85,7 @@ sexp sexp_make_thread (sexp ctx sexp_api_params(self, n), sexp thunk, sexp name) return res; } -sexp sexp_thread_start (sexp ctx sexp_api_params(self, n), sexp thread) { +sexp sexp_thread_start (sexp ctx, sexp self, sexp_sint_t n, sexp thread) { sexp cell; sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); cell = sexp_cons(ctx, thread, SEXP_NULL); @@ -98,7 +98,7 @@ sexp sexp_thread_start (sexp ctx sexp_api_params(self, n), sexp thread) { return thread; } -sexp sexp_thread_terminate (sexp ctx sexp_api_params(self, n), sexp thread) { +sexp sexp_thread_terminate (sexp ctx, sexp self, sexp_sint_t n, sexp thread) { sexp res = sexp_make_boolean(ctx == thread); for ( ; thread && sexp_contextp(thread); thread=sexp_context_child(thread)) sexp_context_refuel(thread) = 0; @@ -160,7 +160,7 @@ static void sexp_insert_timed (sexp ctx, sexp thread, sexp timeout) { sexp_cdr(ls1) = sexp_cons(ctx, thread, ls2); } -sexp sexp_thread_join (sexp ctx sexp_api_params(self, n), sexp thread, sexp timeout) { +sexp sexp_thread_join (sexp ctx, sexp self, sexp_sint_t n, sexp thread, sexp timeout) { sexp_assert_type(ctx, sexp_contextp, SEXP_CONTEXT, thread); if (sexp_context_refuel(thread) <= 0) /* return true if already terminated */ { return SEXP_TRUE; @@ -172,7 +172,7 @@ sexp sexp_thread_join (sexp ctx sexp_api_params(self, n), sexp thread, sexp time return SEXP_FALSE; } -sexp sexp_thread_sleep (sexp ctx sexp_api_params(self, n), sexp timeout) { +sexp sexp_thread_sleep (sexp ctx, sexp self, sexp_sint_t n, sexp timeout) { sexp_context_waitp(ctx) = 1; if (timeout != SEXP_TRUE) { sexp_assert_type(ctx, sexp_numberp, SEXP_NUMBER, timeout); @@ -184,7 +184,7 @@ sexp sexp_thread_sleep (sexp ctx sexp_api_params(self, n), sexp timeout) { /**************************** mutexes *************************************/ -sexp sexp_mutex_state (sexp ctx sexp_api_params(self, n), sexp mutex) { +sexp sexp_mutex_state (sexp ctx, sexp self, sexp_sint_t n, sexp mutex) { if (!sexp_mutexp(ctx, mutex)) return sexp_type_exception(ctx, self, sexp_unbox_fixnum(sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID)), mutex); if (sexp_truep(sexp_mutex_lockp(mutex))) { @@ -197,7 +197,7 @@ sexp sexp_mutex_state (sexp ctx sexp_api_params(self, n), sexp mutex) { } } -sexp sexp_mutex_lock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp timeout, sexp thread) { +sexp sexp_mutex_lock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp timeout, sexp thread) { if (thread == SEXP_TRUE) thread = ctx; if (sexp_not(sexp_mutex_lockp(mutex))) { @@ -212,7 +212,7 @@ sexp sexp_mutex_lock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp timeou } } -sexp sexp_mutex_unlock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp condvar, sexp timeout) { +sexp sexp_mutex_unlock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp condvar, sexp timeout) { sexp ls1, ls2; if (sexp_not(condvar)) { /* normal unlock - always succeeds, just need to unblock threads */ @@ -248,7 +248,7 @@ sexp sexp_mutex_unlock (sexp ctx sexp_api_params(self, n), sexp mutex, sexp cond /**************************** condition variables *************************/ -sexp sexp_condition_variable_signal (sexp ctx sexp_api_params(self, n), sexp condvar) { +sexp sexp_condition_variable_signal (sexp ctx, sexp self, sexp_sint_t n, sexp condvar) { sexp ls1=SEXP_NULL, ls2=sexp_global(ctx, SEXP_G_THREADS_PAUSED); for ( ; sexp_pairp(ls2); ls1=ls2, ls2=sexp_cdr(ls2)) if (sexp_context_event(sexp_car(ls2)) == condvar) { @@ -266,7 +266,7 @@ sexp sexp_condition_variable_signal (sexp ctx sexp_api_params(self, n), sexp con return SEXP_FALSE; } -sexp sexp_condition_variable_broadcast (sexp ctx sexp_api_params(self, n), sexp condvar) { +sexp sexp_condition_variable_broadcast (sexp ctx, sexp self, sexp_sint_t n, sexp condvar) { sexp res = SEXP_FALSE; while (sexp_truep(sexp_condition_variable_signal(ctx, self, n, condvar))) res = SEXP_TRUE; @@ -285,7 +285,7 @@ static sexp_uint_t sexp_log2_of_pow2 (sexp_uint_t n) { return sexp_log2_lookup[((unsigned)n * 0x077CB531U) >> 27]; } -static sexp sexp_pop_signal (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_pop_signal (sexp ctx, sexp self, sexp_sint_t n) { int allsigs, restsigs, signum; if (sexp_global(ctx, SEXP_G_THREADS_SIGNALS) == SEXP_ZERO) { return SEXP_FALSE; @@ -298,7 +298,7 @@ static sexp sexp_pop_signal (sexp ctx sexp_api_params(self, n)) { } } -static sexp sexp_get_signal_handler (sexp ctx sexp_api_params(self, n), sexp signum) { +static sexp sexp_get_signal_handler (sexp ctx, sexp self, sexp_sint_t n, sexp signum) { sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, signum); return sexp_vector_ref(sexp_global(ctx, SEXP_G_SIGNAL_HANDLERS), signum); } @@ -311,7 +311,7 @@ static sexp sexp_make_pollfds (sexp ctx) { return res; } -static sexp sexp_free_pollfds (sexp ctx sexp_api_params(self, n), sexp pollfds) { +static sexp sexp_free_pollfds (sexp ctx, sexp self, sexp_sint_t n, sexp pollfds) { if (sexp_pollfds_fds(pollfds)) { free(sexp_pollfds_fds(pollfds)); sexp_pollfds_fds(pollfds) = NULL; @@ -350,7 +350,7 @@ static sexp sexp_insert_pollfd (sexp ctx, int fd, int events) { } /* block the current thread on the specified port */ -static sexp sexp_blocker (sexp ctx sexp_api_params(self, n), sexp port) { +static sexp sexp_blocker (sexp ctx, sexp self, sexp_sint_t n, sexp port) { int fd; sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port); /* register the fd */ @@ -364,7 +364,7 @@ static sexp sexp_blocker (sexp ctx sexp_api_params(self, n), sexp port) { return SEXP_VOID; } -sexp sexp_scheduler (sexp ctx sexp_api_params(self, n), sexp root_thread) { +sexp sexp_scheduler (sexp ctx, sexp self, sexp_sint_t n, sexp root_thread) { int i, k; struct timeval tval; struct pollfd *pfds; @@ -555,7 +555,7 @@ sexp sexp_lookup_named_type (sexp ctx, sexp env, const char *name) { return sexp_make_fixnum((sexp_typep(t)) ? sexp_type_tag(t) : -1); } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp t; sexp_gc_var1(name); sexp_gc_preserve1(ctx, name); @@ -566,8 +566,8 @@ sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, sexp_make_fixnum(sexp_sizeof_pollfds), SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, - SEXP_ZERO, SEXP_ZERO, (sexp_proc2)sexp_free_pollfds, - NULL); + SEXP_ZERO, SEXP_ZERO, NULL, + (sexp_proc2)sexp_free_pollfds); if (sexp_typep(t)) { sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID) = sexp_make_fixnum(sexp_type_tag(t)); } diff --git a/lib/srfi/27/rand.c b/lib/srfi/27/rand.c index f781eaee..977ee4fe 100644 --- a/lib/srfi/27/rand.c +++ b/lib/srfi/27/rand.c @@ -1,5 +1,5 @@ /* rand.c -- rand_r/random_r interface */ -/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #include @@ -37,7 +37,7 @@ typedef struct random_data sexp_random_t; static sexp_uint_t rs_type_id = 0; static sexp default_random_source; -static sexp sexp_rs_random_integer (sexp ctx sexp_api_params(self, n), sexp rs, sexp bound) { +static sexp sexp_rs_random_integer (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp bound) { sexp res; int32_t m; #if SEXP_USE_BIGNUMS @@ -69,11 +69,11 @@ static sexp sexp_rs_random_integer (sexp ctx sexp_api_params(self, n), sexp rs, return res; } -static sexp sexp_random_integer (sexp ctx sexp_api_params(self, n), sexp bound) { - return sexp_rs_random_integer(ctx sexp_api_pass(self, n), default_random_source, bound); +static sexp sexp_random_integer (sexp ctx, sexp self, sexp_sint_t n, sexp bound) { + return sexp_rs_random_integer(ctx, self, n, default_random_source, bound); } -static sexp sexp_rs_random_real (sexp ctx sexp_api_params(self, n), sexp rs) { +static sexp sexp_rs_random_real (sexp ctx, sexp self, sexp_sint_t n, sexp rs) { int32_t res; if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); @@ -81,27 +81,27 @@ static sexp sexp_rs_random_real (sexp ctx sexp_api_params(self, n), sexp rs) { return sexp_make_flonum(ctx, (double)res / (double)RAND_MAX); } -static sexp sexp_random_real (sexp ctx sexp_api_params(self, n)) { - return sexp_rs_random_real(ctx sexp_api_pass(self, n), default_random_source); +static sexp sexp_random_real (sexp ctx, sexp self, sexp_sint_t n) { + return sexp_rs_random_real(ctx, self, n, default_random_source); } #if SEXP_BSD || defined(__CYGWIN__) -static sexp sexp_make_random_source (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_make_random_source (sexp ctx, sexp self, sexp_sint_t n) { sexp res; res = sexp_alloc_tagged(ctx, sexp_sizeof_random, rs_type_id); *sexp_random_data(res) = 1; return res; } -static sexp sexp_random_source_state_ref (sexp ctx sexp_api_params(self, n), sexp rs) { +static sexp sexp_random_source_state_ref (sexp ctx, sexp self, sexp_sint_t n, sexp rs) { if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); else return sexp_make_integer(ctx, *sexp_random_data(rs)); } -static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sexp rs, sexp state) { +static sexp sexp_random_source_state_set (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp state) { if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); else if (sexp_fixnump(state)) @@ -118,7 +118,7 @@ static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sex #else -static sexp sexp_make_random_source (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_make_random_source (sexp ctx, sexp self, sexp_sint_t n) { sexp res; sexp_gc_var1(state); sexp_gc_preserve1(ctx, state); @@ -131,14 +131,14 @@ static sexp sexp_make_random_source (sexp ctx sexp_api_params(self, n)) { return res; } -static sexp sexp_random_source_state_ref (sexp ctx sexp_api_params(self, n), sexp rs) { +static sexp sexp_random_source_state_ref (sexp ctx, sexp self, sexp_sint_t n, sexp rs) { if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); else return sexp_substring(ctx, sexp_random_state(rs), ZERO, STATE_SIZE); } -static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sexp rs, sexp state) { +static sexp sexp_random_source_state_set (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp state) { if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); else if (! (sexp_stringp(state) @@ -151,14 +151,14 @@ static sexp sexp_random_source_state_set (sexp ctx sexp_api_params(self, n), sex #endif -static sexp sexp_random_source_randomize (sexp ctx sexp_api_params(self, n), sexp rs) { +static sexp sexp_random_source_randomize (sexp ctx, sexp self, sexp_sint_t n, sexp rs) { if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); sexp_seed_random(time(NULL), rs); return SEXP_VOID; } -static sexp sexp_random_source_pseudo_randomize (sexp ctx sexp_api_params(self, n), sexp rs, sexp seed) { +static sexp sexp_random_source_pseudo_randomize (sexp ctx, sexp self, sexp_sint_t n, sexp rs, sexp seed) { if (! sexp_random_source_p(rs)) return sexp_type_exception(ctx, self, rs_type_id, rs); if (! sexp_fixnump(seed)) @@ -167,7 +167,7 @@ static sexp sexp_random_source_pseudo_randomize (sexp ctx sexp_api_params(self, return SEXP_VOID; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_gc_var2(name, op); sexp_gc_preserve2(ctx, name, op); @@ -196,10 +196,10 @@ sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { sexp_define_foreign(ctx, env, "random-source-randomize!", 1, sexp_random_source_randomize); sexp_define_foreign(ctx, env, "random-source-pseudo-randomize!", 2, sexp_random_source_pseudo_randomize); - default_random_source = op = sexp_make_random_source(ctx sexp_api_pass(NULL, 0)); + default_random_source = op = sexp_make_random_source(ctx, NULL, 0); name = sexp_intern(ctx, "default-random-source", -1); sexp_env_define(ctx, env, name, default_random_source); - sexp_random_source_randomize(ctx sexp_api_pass(NULL, 0), default_random_source); + sexp_random_source_randomize(ctx, NULL, 0, default_random_source); sexp_gc_release2(ctx); return SEXP_VOID; diff --git a/lib/srfi/33/bit.c b/lib/srfi/33/bit.c index c7a8f843..10993348 100644 --- a/lib/srfi/33/bit.c +++ b/lib/srfi/33/bit.c @@ -1,5 +1,5 @@ /* bit.c -- bitwise operators */ -/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #include @@ -11,7 +11,7 @@ #define sexp_bignum_normalize(x) x #endif -static sexp sexp_bit_and (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { +static sexp sexp_bit_and (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) { sexp res; #if SEXP_USE_BIGNUMS sexp_sint_t len, i; @@ -21,7 +21,7 @@ static sexp sexp_bit_and (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { res = (sexp) ((sexp_uint_t)x & (sexp_uint_t)y); #if SEXP_USE_BIGNUMS else if (sexp_bignump(y)) - res = sexp_bit_and(ctx sexp_api_pass(self, n), y, x); + res = sexp_bit_and(ctx, self, n, y, x); #endif else res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y); @@ -47,7 +47,7 @@ static sexp sexp_bit_and (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { return sexp_bignum_normalize(res); } -static sexp sexp_bit_ior (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { +static sexp sexp_bit_ior (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) { sexp res; #if SEXP_USE_BIGNUMS sexp_sint_t len, i; @@ -57,7 +57,7 @@ static sexp sexp_bit_ior (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { res = (sexp) ((sexp_uint_t)x | (sexp_uint_t)y); #if SEXP_USE_BIGNUMS else if (sexp_bignump(y)) - res = sexp_bit_ior(ctx sexp_api_pass(self, n), y, x); + res = sexp_bit_ior(ctx, self, n, y, x); #endif else res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y); @@ -87,7 +87,7 @@ static sexp sexp_bit_ior (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { return sexp_bignum_normalize(res); } -static sexp sexp_bit_xor (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { +static sexp sexp_bit_xor (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp y) { sexp res; #if SEXP_USE_BIGNUMS sexp_sint_t len, i; @@ -97,7 +97,7 @@ static sexp sexp_bit_xor (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { res = sexp_make_fixnum(sexp_unbox_fixnum(x) ^ sexp_unbox_fixnum(y)); #if SEXP_USE_BIGNUMS else if (sexp_bignump(y)) - res = sexp_bit_xor(ctx sexp_api_pass(self, n), y, x); + res = sexp_bit_xor(ctx, self, n, y, x); #endif else res = sexp_type_exception(ctx, self, SEXP_FIXNUM, y); @@ -129,7 +129,7 @@ static sexp sexp_bit_xor (sexp ctx sexp_api_params(self, n), sexp x, sexp y) { /* should probably split into left and right shifts, that's a better */ /* interface anyway */ -static sexp sexp_arithmetic_shift (sexp ctx sexp_api_params(self, n), sexp i, sexp count) { +static sexp sexp_arithmetic_shift (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp count) { sexp_uint_t tmp; sexp_sint_t c; #if SEXP_USE_BIGNUMS @@ -156,7 +156,7 @@ static sexp sexp_arithmetic_shift (sexp ctx sexp_api_params(self, n), sexp i, se } else { sexp_gc_preserve1(ctx, res); res = sexp_fixnum_to_bignum(ctx, i); - res = sexp_arithmetic_shift(ctx sexp_api_pass(self, n), res, count); + res = sexp_arithmetic_shift(ctx, self, n, res, count); sexp_gc_release1(ctx); } #endif @@ -208,7 +208,7 @@ static sexp_uint_t bit_count (sexp_uint_t i) { >> (sizeof(i) - 1) * CHAR_BIT); } -static sexp sexp_bit_count (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_bit_count (sexp ctx, sexp self, sexp_sint_t n, sexp x) { sexp res; sexp_sint_t i; #if SEXP_USE_BIGNUMS @@ -250,7 +250,7 @@ static sexp_uint_t integer_log2 (sexp_uint_t x) { return (t = x >> 8) ? 8 + log_table_256[t] : log_table_256[x]; } -static sexp sexp_integer_length (sexp ctx sexp_api_params(self, n), sexp x) { +static sexp sexp_integer_length (sexp ctx, sexp self, sexp_sint_t n, sexp x) { sexp_sint_t tmp; #if SEXP_USE_BIGNUMS sexp_sint_t hi; @@ -269,7 +269,7 @@ static sexp sexp_integer_length (sexp ctx sexp_api_params(self, n), sexp x) { } } -static sexp sexp_bit_set_p (sexp ctx sexp_api_params(self, n), sexp i, sexp x) { +static sexp sexp_bit_set_p (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp x) { #if SEXP_USE_BIGNUMS sexp_uint_t pos; #endif @@ -290,7 +290,7 @@ static sexp sexp_bit_set_p (sexp ctx sexp_api_params(self, n), sexp i, sexp x) { } } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "bit-and", 2, sexp_bit_and); sexp_define_foreign(ctx, env, "bit-ior", 2, sexp_bit_ior); sexp_define_foreign(ctx, env, "bit-xor", 2, sexp_bit_xor); diff --git a/lib/srfi/39/param.c b/lib/srfi/39/param.c index 2cad3d59..3fb1116a 100644 --- a/lib/srfi/39/param.c +++ b/lib/srfi/39/param.c @@ -1,12 +1,12 @@ /* param.c -- low-level parameter utilities */ -/* Copyright (c) 2010 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2010-2011 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #include #define _I(x) sexp_make_fixnum(x) -static sexp sexp_make_parameter (sexp ctx sexp_api_params(self, n), sexp init, sexp conv) { +static sexp sexp_make_parameter (sexp ctx, sexp self, sexp_sint_t n, sexp init, sexp conv) { sexp res; sexp_gc_var1(cell); sexp_gc_preserve1(ctx, cell); @@ -19,24 +19,24 @@ static sexp sexp_make_parameter (sexp ctx sexp_api_params(self, n), sexp init, s return res; } -static sexp sexp_parameter_converter (sexp ctx sexp_api_params(self, n), sexp param) { +static sexp sexp_parameter_converter (sexp ctx, sexp self, sexp_sint_t n, sexp param) { sexp res; sexp_assert_type(ctx, sexp_opcodep, SEXP_OPCODE, param); res = sexp_opcode_data2(param); return res ? res : SEXP_FALSE; } -static sexp sexp_thread_parameters (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_thread_parameters (sexp ctx, sexp self, sexp_sint_t n) { sexp res = sexp_context_params(ctx); return res ? res : SEXP_NULL; } -static sexp sexp_thread_parameters_set (sexp ctx sexp_api_params(self, n), sexp new) { +static sexp sexp_thread_parameters_set (sexp ctx, sexp self, sexp_sint_t n, sexp new) { sexp_context_params(ctx) = new; return SEXP_VOID; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "%make-parameter", 2, sexp_make_parameter); sexp_define_foreign(ctx, env, "parameter-converter", 1, sexp_parameter_converter); diff --git a/lib/srfi/69/hash.c b/lib/srfi/69/hash.c index 3b4ed788..9c756027 100644 --- a/lib/srfi/69/hash.c +++ b/lib/srfi/69/hash.c @@ -23,7 +23,7 @@ static sexp_uint_t string_hash (char *str, sexp_uint_t bound) { return acc % bound; } -static sexp sexp_string_hash (sexp ctx sexp_api_params(self, n), sexp str, sexp bound) { +static sexp sexp_string_hash (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp bound) { if (! sexp_stringp(str)) return sexp_type_exception(ctx, self, SEXP_STRING, str); else if (! sexp_fixnump(bound)) @@ -38,7 +38,7 @@ static sexp_uint_t string_ci_hash (char *str, sexp_uint_t bound) { return acc % bound; } -static sexp sexp_string_ci_hash (sexp ctx sexp_api_params(self, n), sexp str, sexp bound) { +static sexp sexp_string_ci_hash (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp bound) { if (! sexp_stringp(str)) return sexp_type_exception(ctx, self, SEXP_STRING, str); else if (! sexp_fixnump(bound)) @@ -91,13 +91,13 @@ static sexp_uint_t hash_one (sexp ctx, sexp obj, sexp_uint_t bound, sexp_sint_t return (bound ? acc % bound : acc); } -static sexp sexp_hash (sexp ctx sexp_api_params(self, n), sexp obj, sexp bound) { +static sexp sexp_hash (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp bound) { if (! sexp_exact_integerp(bound)) return sexp_type_exception(ctx, self, SEXP_FIXNUM, bound); return sexp_make_fixnum(hash_one(ctx, obj, sexp_unbox_fixnum(bound), HASH_DEPTH)); } -static sexp sexp_hash_by_identity (sexp ctx sexp_api_params(self, n), sexp obj, sexp bound) { +static sexp sexp_hash_by_identity (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp bound) { if (! sexp_exact_integerp(bound)) return sexp_type_exception(ctx, self, SEXP_FIXNUM, bound); return sexp_make_fixnum((sexp_uint_t)obj % sexp_unbox_fixnum(bound)); @@ -108,9 +108,9 @@ static sexp sexp_get_bucket (sexp ctx, sexp buckets, sexp hash_fn, sexp obj) { sexp res; sexp_uint_t len = sexp_vector_length(buckets); if (hash_fn == SEXP_ONE) - res = sexp_hash_by_identity(ctx sexp_api_pass(NULL, 2), obj, sexp_make_fixnum(len)); + res = sexp_hash_by_identity(ctx, NULL, 2, obj, sexp_make_fixnum(len)); else if (hash_fn == SEXP_TWO) - res = sexp_hash(ctx sexp_api_pass(NULL, 2), obj, sexp_make_fixnum(len)); + res = sexp_hash(ctx, NULL, 2, obj, sexp_make_fixnum(len)); else { sexp_gc_preserve1(ctx, args); args = sexp_list2(ctx, obj, sexp_make_fixnum(len)); @@ -184,7 +184,7 @@ static void sexp_regrow_hash_table (sexp ctx, sexp ht, sexp oldbuckets, sexp has sexp_gc_release1(ctx); } -static sexp sexp_hash_table_cell (sexp ctx sexp_api_params(self, n), sexp ht, sexp obj, sexp createp) { +static sexp sexp_hash_table_cell (sexp ctx, sexp self, sexp_sint_t n, sexp ht, sexp obj, sexp createp) { sexp buckets, eq_fn, hash_fn, i; sexp_uint_t size; sexp_gc_var1(res); @@ -214,7 +214,7 @@ static sexp sexp_hash_table_cell (sexp ctx sexp_api_params(self, n), sexp ht, se return res; } -static sexp sexp_hash_table_delete (sexp ctx sexp_api_params(self, n), sexp ht, sexp obj) { +static sexp sexp_hash_table_delete (sexp ctx, sexp self, sexp_sint_t n, sexp ht, sexp obj) { sexp buckets=sexp_hash_table_buckets(ht), eq_fn=sexp_hash_table_eq_fn(ht), hash_fn=sexp_hash_table_hash_fn(ht), i, p, res; i = sexp_get_bucket(ctx, buckets, hash_fn, obj); @@ -232,7 +232,7 @@ static sexp sexp_hash_table_delete (sexp ctx sexp_api_params(self, n), sexp ht, return SEXP_VOID; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign_opt(ctx, env, "string-hash", 2, sexp_string_hash, HASH_BOUND); sexp_define_foreign_opt(ctx, env, "string-ci-hash", 2, sexp_string_ci_hash, HASH_BOUND); diff --git a/lib/srfi/95/qsort.c b/lib/srfi/95/qsort.c index 14cf71c5..5aae1506 100644 --- a/lib/srfi/95/qsort.c +++ b/lib/srfi/95/qsort.c @@ -116,7 +116,7 @@ static int sexp_object_compare (sexp ctx, sexp a, sexp b) { return res; } -static sexp sexp_object_compare_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) { +static sexp sexp_object_compare_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) { return sexp_make_fixnum(sexp_object_compare(ctx, a, b)); } @@ -190,7 +190,7 @@ static sexp sexp_qsort_less (sexp ctx, sexp *vec, return res; } -static sexp sexp_sort_x (sexp ctx sexp_api_params(self, n), sexp seq, +static sexp sexp_sort_x (sexp ctx, sexp self, sexp_sint_t n, sexp seq, sexp less, sexp key) { sexp_sint_t len; sexp res, *data; @@ -228,7 +228,7 @@ static sexp sexp_sort_x (sexp ctx sexp_api_params(self, n), sexp seq, return res; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "object-cmp", 2, sexp_object_compare_op); sexp_define_foreign_opt(ctx, env, "sort!", 3, sexp_sort_x, SEXP_FALSE); return SEXP_VOID; diff --git a/lib/srfi/98/env.c b/lib/srfi/98/env.c index f8e519f3..6ed567dc 100644 --- a/lib/srfi/98/env.c +++ b/lib/srfi/98/env.c @@ -1,5 +1,5 @@ /* env.c -- SRFI-98 environment interface */ -/* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #ifdef __APPLE__ @@ -11,7 +11,7 @@ extern char **environ; #include -sexp sexp_get_environment_variable (sexp ctx sexp_api_params(self, n), sexp str) { +sexp sexp_get_environment_variable (sexp ctx, sexp self, sexp_sint_t n, sexp str) { char *cstr; if (! sexp_stringp(str)) return sexp_type_exception(ctx, self, SEXP_STRING, str); @@ -19,7 +19,7 @@ sexp sexp_get_environment_variable (sexp ctx sexp_api_params(self, n), sexp str) return cstr ? sexp_c_string(ctx, cstr, -1) : SEXP_FALSE; } -sexp sexp_get_environment_variables (sexp ctx sexp_api_params(self, n)) { +sexp sexp_get_environment_variables (sexp ctx, sexp self, sexp_sint_t n) { int i; char **env, *cname, *cval; sexp_gc_var3(res, name, val); @@ -40,7 +40,7 @@ sexp sexp_get_environment_variables (sexp ctx sexp_api_params(self, n)) { return res; } -sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) { +sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) { sexp_define_foreign(ctx, env, "get-environment-variable", 1, sexp_get_environment_variable); sexp_define_foreign(ctx, env, "get-environment-variables", 0, sexp_get_environment_variables); return SEXP_VOID; diff --git a/opt/fcall.c b/opt/fcall.c index ca20f0c0..051c4c76 100644 --- a/opt/fcall.c +++ b/opt/fcall.c @@ -1,16 +1,16 @@ -typedef sexp (*sexp_proc8) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc9) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc10) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc11) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc12) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc13) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc14) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc15) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc16) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc17) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc18) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); -typedef sexp (*sexp_proc19) (sexp sexp_api_params(self, n), sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc8) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc9) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc10) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc11) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc12) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc13) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc14) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc15) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc16) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc17) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc18) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); +typedef sexp (*sexp_proc19) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp); #define _A(i) stack[top-i] diff --git a/opt/plan9.c b/opt/plan9.c index c5e233a1..23ff33ce 100644 --- a/opt/plan9.c +++ b/opt/plan9.c @@ -2,16 +2,16 @@ /* Copyright (c) 2009-2010 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ -sexp sexp_rand (sexp ctx sexp_api_params(self, n)) { +sexp sexp_rand (sexp ctx, sexp self, sexp_sint_t n) { return sexp_make_fixnum(rand()); } -sexp sexp_srand (sexp ctx sexp_api_params(self, n), sexp seed) { +sexp sexp_srand (sexp ctx, sexp self, sexp_sint_t n, sexp seed) { srand(sexp_unbox_fixnum(seed)); return SEXP_VOID; } -sexp sexp_file_exists_p (sexp ctx sexp_api_params(self, n), sexp path) { +sexp sexp_file_exists_p (sexp ctx, sexp self, sexp_sint_t n, sexp path) { int res; uchar statbuf[STATMAX]; if (! sexp_stringp(path)) @@ -20,7 +20,7 @@ sexp sexp_file_exists_p (sexp ctx sexp_api_params(self, n), sexp path) { return (res < 0) ? SEXP_FALSE : SEXP_TRUE; } -sexp sexp_fdopen (sexp ctx sexp_api_params(self, n), sexp fd, sexp mode) { +sexp sexp_fdopen (sexp ctx, sexp self, sexp_sint_t n, sexp fd, sexp mode) { FILE *f; if (! sexp_integerp(fd)) return sexp_type_exception(ctx, self, SEXP_FIXNUM, fd); @@ -36,17 +36,17 @@ sexp sexp_fdopen (sexp ctx sexp_api_params(self, n), sexp fd, sexp mode) { return sexp_make_input_port(ctx, f, SEXP_FALSE); } -sexp sexp_fileno (sexp ctx sexp_api_params(self, n), sexp port) { +sexp sexp_fileno (sexp ctx, sexp self, sexp_sint_t n, sexp port) { if (! sexp_portp(port)) return sexp_type_exception(ctx, self, SEXP_IPORT, port); return sexp_make_fixnum(fileno(sexp_port_stream(port))); } -sexp sexp_fork (sexp ctx sexp_api_params(self, n)) { +sexp sexp_fork (sexp ctx, sexp self, sexp_sint_t n) { return sexp_make_fixnum(fork()); } -sexp sexp_exec (sexp ctx sexp_api_params(self, n), sexp name, sexp args) { +sexp sexp_exec (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp args) { int i, len = sexp_unbox_fixnum(sexp_length(ctx, args)); char **argv = malloc((len+1)*sizeof(char*)); for (i=0; iifcall.offset); } -sexp sexp_9p_req_count (sexp ctx sexp_api_params(self, n), sexp req) { +sexp sexp_9p_req_count (sexp ctx, sexp self, sexp_sint_t n, sexp req) { return sexp_make_integer(ctx, ((Req*)sexp_cpointer_value(req))->ifcall.count); } #if 0 -sexp sexp_9p_req_path (sexp ctx sexp_api_params(self, n), sexp req) { +sexp sexp_9p_req_path (sexp ctx, sexp self, sexp_sint_t n, sexp req) { return sexp_c_string(ctx, ((Req*)sexp_cpointer_value(req))->fid->qid.path, -1); } #endif -sexp sexp_9p_req_fid (sexp ctx sexp_api_params(self, n), sexp req) { +sexp sexp_9p_req_fid (sexp ctx, sexp self, sexp_sint_t n, sexp req) { return sexp_make_cpointer(ctx, SEXP_CPOINTER, ((Req*)sexp_cpointer_value(req))->fid, SEXP_FALSE, 0); } -sexp sexp_9p_req_newfid (sexp ctx sexp_api_params(self, n), sexp req) { +sexp sexp_9p_req_newfid (sexp ctx, sexp self, sexp_sint_t n, sexp req) { return sexp_make_cpointer(ctx, SEXP_CPOINTER, ((Req*)sexp_cpointer_value(req))->newfid, SEXP_FALSE, 0); } -sexp sexp_9p_respond (sexp ctx sexp_api_params(self, n), sexp req, sexp err) { +sexp sexp_9p_respond (sexp ctx, sexp self, sexp_sint_t n, sexp req, sexp err) { char *cerr = sexp_stringp(err) ? sexp_string_data(err) : nil; respond(sexp_cpointer_value(req), cerr); return SEXP_VOID; } -sexp sexp_9p_responderror (sexp ctx sexp_api_params(self, n), sexp req) { +sexp sexp_9p_responderror (sexp ctx, sexp self, sexp_sint_t n, sexp req) { responderror(sexp_cpointer_value(req)); return SEXP_VOID; } diff --git a/opt/simplify.c b/opt/simplify.c index ccbfad87..9fd88ab8 100644 --- a/opt/simplify.c +++ b/opt/simplify.c @@ -139,7 +139,7 @@ static sexp simplify (sexp ctx, sexp ast, sexp init_substs, sexp lambda) { return res; } -sexp sexp_simplify (sexp ctx sexp_api_params(self, n), sexp ast) { +sexp sexp_simplify (sexp ctx, sexp self, sexp_sint_t n, sexp ast) { return simplify(ctx, ast, SEXP_NULL, NULL); } diff --git a/sexp.c b/sexp.c index 8bf65477..2b9d5cea 100644 --- a/sexp.c +++ b/sexp.c @@ -64,7 +64,7 @@ sexp sexp_alloc_tagged_aux(sexp ctx, size_t size, sexp_uint_t tag sexp_current_s } #if SEXP_USE_OBJECT_BRACE_LITERALS -sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp writer, sexp out) { +sexp sexp_write_simple_object (sexp ctx, sexp self, sexp_sint_t n, sexp obj, sexp writer, sexp out) { sexp t, x, *elts; sexp_gc_var1(args); sexp_sint_t i, len, nulls=0; @@ -112,7 +112,7 @@ sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp #define sexp_write_simple_object NULL #endif -sexp sexp_finalize_port (sexp ctx sexp_api_params(self, n), sexp port) { +sexp sexp_finalize_port (sexp ctx, sexp self, sexp_sint_t n, sexp port) { if (sexp_port_openp(port)) { sexp_port_openp(port) = 0; if (sexp_port_stream(port) && ! sexp_port_no_closep(port)) { @@ -131,7 +131,7 @@ sexp sexp_finalize_port (sexp ctx sexp_api_params(self, n), sexp port) { #endif #if SEXP_USE_DL -sexp sexp_finalize_dl (sexp ctx sexp_api_params(self, n), sexp dl) { +sexp sexp_finalize_dl (sexp ctx, sexp self, sexp_sint_t n, sexp dl) { dlclose(sexp_dl_handle(dl)); return SEXP_VOID; } @@ -195,7 +195,7 @@ static struct sexp_type_struct _sexp_type_specs[] = { #if SEXP_USE_TYPE_DEFS -sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name, +sexp sexp_register_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp parent, sexp slots, sexp fb, sexp felb, sexp flb, sexp flo, sexp fls, sexp sb, sexp so, sexp sc, sexp w, sexp wb, sexp wo, @@ -273,7 +273,7 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name, return res; } -sexp sexp_register_simple_type_op (sexp ctx sexp_api_params(self, n), sexp name, sexp parent, sexp slots) { +sexp sexp_register_simple_type_op (sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp parent, sexp slots) { short i, num_slots = sexp_unbox_fixnum(sexp_length(ctx, slots)); sexp type_size, num_slots_obj, cpl, tmp; if (parent && sexp_typep(parent)) { @@ -297,7 +297,7 @@ sexp sexp_register_simple_type_op (sexp ctx sexp_api_params(self, n), sexp name, } #if SEXP_USE_OBJECT_BRACE_LITERALS -sexp sexp_lookup_type_op(sexp ctx sexp_api_params(self, n), sexp name, sexp id) { +sexp sexp_lookup_type_op(sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp id) { int i; sexp res; const char* str = sexp_string_data(name); @@ -322,7 +322,7 @@ sexp sexp_lookup_type_op(sexp ctx sexp_api_params(self, n), sexp name, sexp id) } #endif -sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj) { +sexp sexp_finalize_c_type (sexp ctx, sexp self, sexp_sint_t n, sexp obj) { if (sexp_cpointer_freep(obj)) free(sexp_cpointer_value(obj)); return SEXP_VOID; @@ -544,7 +544,7 @@ sexp sexp_range_exception (sexp ctx, sexp obj, sexp start, sexp end) { return res; } -sexp sexp_print_exception_op (sexp ctx sexp_api_params(self, n), sexp exn, sexp out) { +sexp sexp_print_exception_op (sexp ctx, sexp self, sexp_sint_t n, sexp exn, sexp out) { sexp ls; if (! sexp_oportp(out)) out = sexp_make_output_port(ctx, stderr, SEXP_FALSE); @@ -628,7 +628,7 @@ static sexp sexp_read_error (sexp ctx, const char *msg, sexp ir, sexp port) { /*************************** list utilities ***************************/ -sexp sexp_cons_op (sexp ctx sexp_api_params(self, n), sexp head, sexp tail) { +sexp sexp_cons_op (sexp ctx, sexp self, sexp_sint_t n, sexp head, sexp tail) { sexp pair = sexp_alloc_type(ctx, pair, SEXP_PAIR); if (sexp_exceptionp(pair)) return pair; sexp_car(pair) = head; @@ -646,7 +646,7 @@ sexp sexp_list2 (sexp ctx, sexp a, sexp b) { return res; } -sexp sexp_listp_op (sexp ctx sexp_api_params(self, n), sexp hare) { +sexp sexp_listp_op (sexp ctx, sexp self, sexp_sint_t n, sexp hare) { sexp turtle; if (! sexp_pairp(hare)) return sexp_make_boolean(sexp_nullp(hare)); @@ -660,7 +660,7 @@ sexp sexp_listp_op (sexp ctx sexp_api_params(self, n), sexp hare) { return sexp_make_boolean(sexp_nullp(hare)); } -sexp sexp_memq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) { +sexp sexp_memq_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls) { while (sexp_pairp(ls)) if (x == sexp_car(ls)) return ls; @@ -669,7 +669,7 @@ sexp sexp_memq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) { return SEXP_FALSE; } -sexp sexp_assq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) { +sexp sexp_assq_op (sexp ctx, sexp self, sexp_sint_t n, sexp x, sexp ls) { while (sexp_pairp(ls)) if (sexp_pairp(sexp_car(ls)) && (x == sexp_caar(ls))) return sexp_car(ls); @@ -678,7 +678,7 @@ sexp sexp_assq_op (sexp ctx sexp_api_params(self, n), sexp x, sexp ls) { return SEXP_FALSE; } -sexp sexp_reverse_op (sexp ctx sexp_api_params(self, n), sexp ls) { +sexp sexp_reverse_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) { sexp_gc_var1(res); sexp_gc_preserve1(ctx, res); for (res=SEXP_NULL; sexp_pairp(ls); ls=sexp_cdr(ls)) @@ -687,7 +687,7 @@ sexp sexp_reverse_op (sexp ctx sexp_api_params(self, n), sexp ls) { return res; } -sexp sexp_nreverse_op (sexp ctx sexp_api_params(self, n), sexp ls) { +sexp sexp_nreverse_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) { sexp a, b, tmp; if (ls == SEXP_NULL) return ls; sexp_assert_type(ctx, sexp_pairp, SEXP_PAIR, ls); @@ -701,7 +701,7 @@ sexp sexp_nreverse_op (sexp ctx sexp_api_params(self, n), sexp ls) { return b; } -sexp sexp_copy_list_op (sexp ctx sexp_api_params(self, n), sexp ls) { +sexp sexp_copy_list_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls) { sexp tmp; sexp_gc_var1(res); if (! sexp_pairp(ls)) return ls; @@ -713,7 +713,7 @@ sexp sexp_copy_list_op (sexp ctx sexp_api_params(self, n), sexp ls) { return res; } -sexp sexp_append2_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) { +sexp sexp_append2_op (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b) { sexp_gc_var2(a1, b1); sexp_gc_preserve2(ctx, a1, b1); b1 = b; @@ -723,7 +723,7 @@ sexp sexp_append2_op (sexp ctx sexp_api_params(self, n), sexp a, sexp b) { return b1; } -sexp sexp_length_op (sexp ctx sexp_api_params(self, n), sexp ls1) { +sexp sexp_length_op (sexp ctx, sexp self, sexp_sint_t n, sexp ls1) { sexp ls2; sexp_uint_t res = 1; if (!sexp_pairp(ls1)) @@ -735,7 +735,7 @@ sexp sexp_length_op (sexp ctx sexp_api_params(self, n), sexp ls1) { return sexp_make_fixnum(res + (sexp_pairp(ls2) ? 1 : 0)); } -sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp bound) { +sexp sexp_equalp_bound (sexp ctx, sexp self, sexp_sint_t n, sexp a, sexp b, sexp bound) { sexp_uint_t size; sexp_sint_t i, len; sexp t, *p, *q; @@ -783,7 +783,7 @@ sexp sexp_equalp_bound (sexp ctx sexp_api_params(self, n), sexp a, sexp b, sexp len = sexp_type_num_eq_slots_of_object(t, a); if (len > 0) { for (i=0; i= 0x80)) { sexp_assert_type(ctx, sexp_fixnump, SEXP_FIXNUM, len); clen = sexp_utf8_char_byte_count(sexp_unbox_character(ch)); - b = sexp_make_bytes_op(ctx sexp_api_pass(self, n), + b = sexp_make_bytes_op(ctx, self, n, sexp_fx_mul(len, sexp_make_fixnum(clen)), SEXP_VOID); if (sexp_exceptionp(b)) return b; for (j=0; j (lambda (x) (cat "static sexp " (generate-stub-name (cadr x)) - " (sexp ctx sexp_api_params(self, n), sexp x) {\n" + " (sexp ctx, sexp self, sexp_sint_t n, sexp x) {\n" " if (sexp_cpointer_freep(x))\n" " " (cadr x) "(sexp_cpointer_value(x));\n" " return SEXP_VOID;\n" @@ -1088,7 +1088,7 @@ (let ((make (caadr x)) (args (cdadr x))) (cat "static sexp " (generate-stub-name make) - " (sexp ctx sexp_api_params(self, n)" + " (sexp ctx, sexp self, sexp_sint_t n" (lambda () (let lp ((ls args) (i 0)) (cond ((pair? ls) @@ -1194,7 +1194,7 @@ (write-utilities) (for-each write-func *funcs*) (for-each write-type-funcs *types*) - (cat "sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {\n" + (cat "sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env) {\n" " sexp_gc_var2(name, tmp);\n" " sexp_gc_preserve2(ctx, name, tmp);\n") (for-each write-const *consts*) diff --git a/tools/chibi-genstatic b/tools/chibi-genstatic index dd457a60..c50be031 100755 --- a/tools/chibi-genstatic +++ b/tools/chibi-genstatic @@ -131,7 +131,7 @@ (newline) (display "typedef struct {\n") (display " const char *name;\n") - (display " sexp (*init)(sexp ctx sexp_api_params(self, n), sexp env);\n") + (display " sexp (*init)(sexp ctx, sexp self, sexp_sint_t n, sexp env);\n") (display "} sexp_library_entry_t;\n") (newline) (display "static sexp_library_entry_t sexp_static_libraries[] = {\n") diff --git a/vm.c b/vm.c index 2b2c0390..2939b77e 100644 --- a/vm.c +++ b/vm.c @@ -791,7 +791,7 @@ static int sexp_check_type(sexp ctx, sexp a, sexp b) { sexp_uint_t profile1[SEXP_OP_NUM_OPCODES]; sexp_uint_t profile2[SEXP_OP_NUM_OPCODES][SEXP_OP_NUM_OPCODES]; -static sexp sexp_reset_vm_profile (sexp ctx sexp_api_params(self, n)) { +static sexp sexp_reset_vm_profile (sexp ctx, sexp self, sexp_sint_t n) { int i, j; for (i=0; i