SLVAL sl_string_is_match(sl_vm_t* vm, SLVAL self, SLVAL other) { if(sl_is_a(vm, other, vm->lib.String)) { SLVAL idx = sl_string_index(vm, self, other); return sl_make_bool(vm, sl_get_ptr(idx) != sl_get_ptr(vm->lib.nil)); } return sl_regexp_is_match(vm, other, self); }
static SLVAL method_eq(sl_vm_t* vm, SLVAL method, SLVAL other) { if(sl_get_ptr(sl_class_of(vm, other)) != sl_get_ptr(vm->lib.Method)) { return vm->lib._false; } sl_method_t* methp = (sl_method_t*)sl_get_ptr(method); sl_method_t* othp = (sl_method_t*)sl_get_ptr(other); return sl_make_bool(vm, memcmp(methp, othp, sizeof(sl_method_t)) == 0); }
SLVAL sl_string_eq(sl_vm_t* vm, SLVAL self, SLVAL other) { if(!sl_is_a(vm, other, vm->lib.String)) { return vm->lib._false; } sl_string_t* a = sl_get_string(vm, self); sl_string_t* b = sl_get_string(vm, other); return sl_make_bool(vm, str_cmp(vm, a, b) == 0); }
SLVAL sl_float_eq(sl_vm_t* vm, SLVAL self, SLVAL other) { if(sl_is_a(vm, other, vm->lib.Int)) { return sl_float_eq(vm, self, sl_make_float(vm, sl_get_int(other))); } if(sl_is_a(vm, other, vm->lib.Bignum)) { if(fmod(sl_get_float(vm, self), 1.0) == 0.0) { return sl_bignum_eq(vm, sl_make_bignum_f(vm, sl_get_float(vm, self)), other); } else { return vm->lib._false; } } if(!sl_is_a(vm, other, vm->lib.Float)) { return vm->lib._false; } return sl_make_bool(vm, sl_get_float(vm, self) == sl_get_float(vm, other)); }
static SLVAL sl_float_infinite(sl_vm_t* vm, SLVAL self) { return sl_make_bool(vm, !isfinite(sl_get_float(vm, self))); }
static SLVAL sl_float_nan(sl_vm_t* vm, SLVAL self) { return sl_make_bool(vm, isnan(sl_get_float(vm, self))); }
static SLVAL true_eq(sl_vm_t* vm, SLVAL self, SLVAL other) { (void)self; return sl_make_bool(vm, sl_is_a(vm, other, vm->lib.True)); }
static SLVAL response_descriptive_error_pages(sl_vm_t* vm) { return sl_make_bool(vm, response(vm)->descriptive_error_pages); }