Example #1
0
// typeof
void buildin_typeof(fake * fk, interpreter * inter)
{
	bool err = false;
	variant * v = 0;
	PS_POP_AND_GET(fk->ps, v);
	const char * name = vartypetostring(v->type);
	fkpspush<const char *>(fk, name);
}
Example #2
0
variant * interpreter::get_container_variant(const func_binary & fb, int conpos)
{
	variant * v = 0;
	assert(conpos >= 0 && conpos < (int)fb.m_container_addr_list_num);
	const container_addr & ca = fb.m_container_addr_list[conpos];
	bool & err = m_isend;
	USE(err);
	variant * conv = 0;
	do {GET_VARIANT_BY_CMD(fb, m_bp, conv, ca.con);}while(0);
	const variant * keyv = 0;
	do {GET_VARIANT_BY_CMD(fb, m_bp, keyv, ca.key);}while(0);

	if (UNLIKE(m_isend))
	{	
		return 0;
	}

	if (UNLIKE(!(conv->type == variant::ARRAY || conv->type == variant::MAP)))
	{
		m_isend = true;
		seterror(m_fk, efk_run_inter_error, fkgetcurfile(m_fk), fkgetcurline(m_fk), fkgetcurfunc(m_fk), "interpreter get container variant fail, container type error, type %s", vartypetostring(conv->type));
		return 0;
	}
	
	if (conv->type == variant::MAP)
	{
		v = con_map_get(m_fk, conv->data.vm, keyv);
	}
	else if (conv->type == variant::ARRAY)
	{
		v = con_array_get(m_fk, conv->data.va, keyv);
	}

	return v;
}