示例#1
0
文件: symtable.c 项目: amjith/chimp
static ChimpRef *
_chimp_symtable_init (ChimpRef *self, ChimpRef *args)
{
    ChimpRef *filename;
    ChimpRef *ast;

    if (!chimp_method_parse_args (args, "oo", &filename, &ast)) {
        return NULL;
    }

    CHIMP_ANY(self)->klass = chimp_symtable_class;
    CHIMP_SYMTABLE(self)->filename = filename;
    CHIMP_SYMTABLE(self)->ste = chimp_nil;
    CHIMP_SYMTABLE(self)->lookup = chimp_hash_new ();
    if (CHIMP_SYMTABLE(self)->lookup == NULL) {
        return NULL;
    }
    CHIMP_SYMTABLE(self)->stack = chimp_array_new ();
    if (CHIMP_SYMTABLE(self)->stack == NULL) {
        return NULL;
    }

    if (CHIMP_ANY_CLASS(ast) == chimp_ast_mod_class) {
        if (!chimp_symtable_visit_mod (self, ast))
            return NULL;
    }
    else {
        CHIMP_BUG ("unknown top-level AST node type: %s",
                    CHIMP_STR_DATA(CHIMP_CLASS(CHIMP_ANY_CLASS(ast))->name));
        return NULL;
    }

    return self;
}
示例#2
0
文件: symtable.c 项目: amjith/chimp
static ChimpRef *
_chimp_symtable_entry_init (ChimpRef *self, ChimpRef *args)
{
    int64_t flags;
    ChimpRef *symtable;
    ChimpRef *scope;
    ChimpRef *parent;

    if (!chimp_method_parse_args (
            args, "oooI", &symtable, &parent, &scope, &flags)) {
        return NULL;
    }

    CHIMP_SYMTABLE_ENTRY(self)->flags = flags;
    CHIMP_SYMTABLE_ENTRY(self)->symtable = symtable;
    CHIMP_SYMTABLE_ENTRY(self)->scope = scope;
    CHIMP_SYMTABLE_ENTRY(self)->parent = parent;
    CHIMP_SYMTABLE_ENTRY(self)->symbols = chimp_hash_new ();
    if (CHIMP_SYMTABLE_ENTRY(self)->symbols == NULL) {
        return NULL;
    }
    CHIMP_SYMTABLE_ENTRY(self)->children = chimp_array_new ();
    if (CHIMP_SYMTABLE_ENTRY(self)->children == NULL) {
        return NULL;
    }
    return self;
}
示例#3
0
文件: task.c 项目: eax/chimp
static ChimpRef *
_chimp_task_send (ChimpRef *self, ChimpRef *args)
{
    ChimpRef *arg;
    if (!chimp_method_parse_args (args, "o", &arg)) {
        return CHIMP_FALSE;
    }
    return chimp_task_send (self, CHIMP_ARRAY_ITEM(args, 0)) ? chimp_true : chimp_false;
}