Exemple #1
0
Tvalue *kp_table_set(ktap_State *ks, Table *t, const Tvalue *key)
{
	const Tvalue *p = kp_table_get(t, key);

	if (p != ktap_nilobject)
		return (Tvalue *)p;
	else
		return table_newkey(ks, t, key);
}
Exemple #2
0
static void gettable(ktap_state *ks, const ktap_value *t, ktap_value *key,
		     StkId val)
{
	if (ttistable(t)) {
		setobj(val, kp_table_get(hvalue(t), key));
	} else if (ttisaggrtable(t)) {
		kp_aggrtable_get(ks, ahvalue(t), key, val);
	} else {
		kp_error(ks, "get key from non-table\n");
	}
}
Exemple #3
0
static int cfunction_cache_getindex(ktap_state *ks, ktap_value *fname)
{
	const ktap_value *gt = kp_table_getint(hvalue(&G(ks)->registry),
				KTAP_RIDX_GLOBALS);
	const ktap_value *cfunc;
	int nr, i;

	nr = G(ks)->nr_builtin_cfunction;
	cfunc = kp_table_get(hvalue(gt), fname);

	for (i = 0; i < nr; i++) {
		if (rawequalobj(&G(ks)->cfunction_tbl[i], cfunc))
			return i;
	}

	return -1;
}
Exemple #4
0
const ktap_value *ktapc_table_get(ktap_table *t, const ktap_value *key)
{
	return kp_table_get(t, key);
}