adding type-num-slots

This commit is contained in:
Alex Shinn 2011-11-07 01:01:26 +09:00
parent 0a22de0e12
commit 742d96af8b
2 changed files with 9 additions and 2 deletions

View file

@ -175,9 +175,15 @@ static sexp sexp_type_slots_op (sexp ctx sexp_api_params(self, n), sexp t) {
return sexp_type_slots(t); return sexp_type_slots(t);
} }
static sexp sexp_type_num_slots_op (sexp ctx sexp_api_params(self, 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_api_params(self, n), sexp t) {
sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t); sexp_assert_type(ctx, sexp_typep, SEXP_TYPE, t);
return sexp_type_print(t) ? sexp_make_foreign(ctx, "print", 3, 0, (sexp_proc1)sexp_type_print(t), NULL) : SEXP_FALSE; 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_api_params(self, n), sexp x) {
@ -413,6 +419,7 @@ sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {
sexp_define_foreign(ctx, env, "type-name", 1, sexp_type_name_op); sexp_define_foreign(ctx, env, "type-name", 1, sexp_type_name_op);
sexp_define_foreign(ctx, env, "type-cpl", 1, sexp_type_cpl_op); sexp_define_foreign(ctx, env, "type-cpl", 1, sexp_type_cpl_op);
sexp_define_foreign(ctx, env, "type-slots", 1, sexp_type_slots_op); sexp_define_foreign(ctx, env, "type-slots", 1, sexp_type_slots_op);
sexp_define_foreign(ctx, env, "type-num-slots", 1, sexp_type_num_slots_op);
sexp_define_foreign(ctx, env, "type-printer", 1, sexp_type_printer_op); sexp_define_foreign(ctx, env, "type-printer", 1, sexp_type_printer_op);
sexp_define_foreign(ctx, env, "object-size", 1, sexp_object_size); sexp_define_foreign(ctx, env, "object-size", 1, sexp_object_size);
sexp_define_foreign_opt(ctx, env, "integer->immediate", 2, sexp_integer_to_immediate, SEXP_FALSE); sexp_define_foreign_opt(ctx, env, "integer->immediate", 2, sexp_integer_to_immediate, SEXP_FALSE);

View file

@ -30,7 +30,7 @@
bytecode-name bytecode-literals bytecode-source bytecode-name bytecode-literals bytecode-source
pair-source pair-source-set! pair-source pair-source-set!
port-line port-line-set! port-line port-line-set!
type-name type-cpl type-parent type-slots type-printer type-name type-cpl type-parent type-slots type-num-slots type-printer
object-size integer->immediate gc object-size integer->immediate gc
string-contains integer->error-string string-contains integer->error-string
flatten-dot update-free-vars!) flatten-dot update-free-vars!)