NODE *
builtin_check(struct symtab *sp, NODE *a)
{
    const struct bitable *bt;

    if (sp->soffset < 0 ||
            sp->soffset >= (int)(sizeof(bitable)/sizeof(bitable[0])))
        cerror("builtin_check");

    bt = &bitable[sp->soffset];
    if ((bt->flags & BTNOEVE) == 0 && a != NIL)
        a = eve(a);
    if (((bt->flags & BTNOPROTO) == 0) && acnt(a, bt->narg, bt->tp)) {
        uerror("wrong argument count to %s", bt->name);
        return bcon(0);
    }
    return (*bt->fun)(bt, a);
}
Exemple #2
0
NODE *
builtin_check(NODE *f, NODE *a)
{
	const struct bitable *bt;
	int i;

	for (i = 0; i < (int)(sizeof(bitable)/sizeof(bitable[0])); i++) {
		bt = &bitable[i];
		if (strcmp(bt->name, f->n_sp->sname))
			continue;
		if (bt->narg >= 0 && acnt(a, bt->narg, bt->tp)) {
			uerror("wrong argument count to %s", bt->name);
			return bcon(0);
		}
		return (*bt->fun)(f, a, bt->rt);
	}
	return NIL;
}