Ejemplo n.º 1
0
static IJsSymbol*
node_symbol_get_member (IJsSymbol *obj, const gchar * name)
{
	NodeSymbol* self = NODE_SYMBOL (obj);
	NodeSymbolPrivate *priv = NODE_SYMBOL_PRIVATE(self);

	gchar *tname = get_complex_node_type (priv->node, priv->my_cx);
	if (!tname)
		return NULL;

	if (js_context_get_member_list (priv->my_cx, tname)) //TODO:Fix mem leak
	{
			return IJS_SYMBOL (
				node_symbol_new (js_context_get_member (priv->my_cx, tname, name),
									name, priv->my_cx));
	}
	IJsSymbol *t = global_search (tname);
	if (t)
		return ijs_symbol_get_member (t, name);

	return NULL;
}
Ejemplo n.º 2
0
static IJsSymbol*
find (const gchar* name, IJsSymbol *sym)
{
	gchar *vname = NULL, *left = NULL;
	if (!sym)
		return NULL;
	if (!name)
		return NULL;
	int i;
	for (i = 0; i < strlen (name); i++)
	{
		if (name[i] != '.')
			continue;
		vname = g_strndup (name, i);
		left = g_strdup (name + i + 1);
		break;
	}
	if (!vname)
		vname = g_strdup (name);
	if (strlen (vname) == 0)
	{
		g_free (vname);
		g_free (left);
		return NULL;
	}
	gboolean is_func_call = *((vname + strlen (vname)) - 1) == ')';
	if (is_func_call)
		vname [strlen (vname) - 2] = '\0';
	GList *j;////TODO
	for (j = ijs_symbol_list_member (sym); j; j = g_list_next (j))
	{
		gchar *t = (gchar*)j->data;
//puts (t);
		if (strcmp (vname, t) != 0 )
			continue;
		if (!is_func_call)
		{
			if (!left)
				return ijs_symbol_get_member (sym, t);
			IJsSymbol *tjs = ijs_symbol_get_member (sym, t);
			IJsSymbol *ret = find (left, tjs);
			g_object_unref (tjs);
			return ret;
		}
		else
		{
			IJsSymbol *s = ijs_symbol_get_member (sym, t);
			if (!s)
				return NULL;
			if (ijs_symbol_get_base_type (s) != BASE_FUNC)
			{
				g_object_unref (s);
				return NULL;
			}
			GList* rets = ijs_symbol_get_func_ret_type (s);
			g_object_unref (s);
			if (rets == NULL)
			{
				return NULL;
			}
			//TODO: Fix
			IJsSymbol *ret = global_search (rets->data);
			if (!ret)
				return NULL;
			if (!left)
				return ret;
			s = find (left, ret);
			g_object_unref (ret);
			return s;
		}
	}
	return NULL;
}