Пример #1
0
static chimp_bool_t
chimp_symtable_add (ChimpRef *self, ChimpRef *name, int64_t flags)
{
    ChimpRef *ste = CHIMP_SYMTABLE_GET_CURRENT_ENTRY(self);
    ChimpRef *symbols = CHIMP_SYMTABLE_ENTRY(ste)->symbols;
    ChimpRef *fl = chimp_int_new (flags);
    if (fl == NULL) {
        return CHIMP_FALSE;
    }
    if (!chimp_hash_put (symbols, name, fl)) {
        return CHIMP_FALSE;
    }
    return CHIMP_TRUE;
}
Пример #2
0
static ChimpRef *
chimp_symtable_entry_new (
    ChimpRef *symtable, ChimpRef *parent, ChimpRef *scope, int flags)
{
    ChimpRef *flags_obj = chimp_int_new (flags);
    if (flags_obj == NULL) {
        return NULL;
    }
    symtable = symtable ? symtable : chimp_nil;
    parent = parent ? parent : chimp_nil;
    scope = scope ? scope : chimp_nil;
    return chimp_class_new_instance (
        chimp_symtable_entry_class, symtable, parent, scope, flags_obj, NULL);
}
Пример #3
0
Файл: chasm.c Проект: eax/chimp
static chimp_bool_t
_parse_const_int (const char **ptr, ChimpRef **value)
{
    int64_t i = 0;
    const char *p = *ptr;
    chimp_bool_t neg;
    _skip_whitespace (&p);
    neg = (*p == '-');
    if (*p == '-' || *p == '+') p++;
    while (*p && isdigit (*p)) {
        i *= (int64_t) 10;
        i += (*p) - '0';
        p++;
    }
    *value = chimp_int_new (i);
    *ptr = p;
    return *value != NULL;
}
Пример #4
0
Файл: hash.c Проект: eax/chimp
static ChimpRef *
_chimp_hash_size (ChimpRef *self, ChimpRef *args)
{
    return chimp_int_new (CHIMP_HASH_SIZE (self));
}