示例#1
0
文件: string.c 项目: richo/slash
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);
}
示例#2
0
文件: method.c 项目: Hmaal/slash
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);
}
示例#3
0
文件: string.c 项目: richo/slash
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);
}
示例#4
0
文件: float.c 项目: Hmaal/slash
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));
}
示例#5
0
文件: float.c 项目: Hmaal/slash
static SLVAL
sl_float_infinite(sl_vm_t* vm, SLVAL self)
{
    return sl_make_bool(vm, !isfinite(sl_get_float(vm, self)));
}
示例#6
0
文件: float.c 项目: Hmaal/slash
static SLVAL
sl_float_nan(sl_vm_t* vm, SLVAL self)
{
    return sl_make_bool(vm, isnan(sl_get_float(vm, self)));
}
示例#7
0
文件: true.c 项目: Hmaal/slash
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));
}
示例#8
0
文件: response.c 项目: richo/slash
static SLVAL
response_descriptive_error_pages(sl_vm_t* vm)
{
    return sl_make_bool(vm, response(vm)->descriptive_error_pages);
}