summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/eolian/database_check.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/lib/eolian/database_check.c b/src/lib/eolian/database_check.c
index 75e4e8dcec..c1eb899e2e 100644
--- a/src/lib/eolian/database_check.c
+++ b/src/lib/eolian/database_check.c
@@ -5,6 +5,16 @@
5#include "eo_lexer.h" 5#include "eo_lexer.h"
6#include "eolian_priv.h" 6#include "eolian_priv.h"
7 7
8static Eina_Bool
9_check_cycle(Eina_Hash *chash, const Eolian_Object *obj)
10{
11 /* need to check this for classes, typedecls, vars (toplevel objects) */
12 if (eina_hash_find(chash, &obj))
13 return EINA_TRUE;
14 eina_hash_add(chash, &obj, obj);
15 return EINA_FALSE;
16}
17
8static void _check_class(const Eolian_Class *cl, Eina_Hash *depset, 18static void _check_class(const Eolian_Class *cl, Eina_Hash *depset,
9 Eina_Hash *chash); 19 Eina_Hash *chash);
10static void _check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, 20static void _check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset,
@@ -112,10 +122,8 @@ _check_function(const Eolian_Function *f, Eina_Hash *depset, Eina_Hash *chash)
112static void 122static void
113_check_class(const Eolian_Class *cl, Eina_Hash *depset, Eina_Hash *chash) 123_check_class(const Eolian_Class *cl, Eina_Hash *depset, Eina_Hash *chash)
114{ 124{
115 /* kill cyclic dependencies before stack overflow */ 125 if (_check_cycle(chash, &cl->base))
116 if (eina_hash_find(chash, &cl))
117 return; 126 return;
118 eina_hash_add(chash, &cl, cl);
119 127
120 if (!eina_hash_find(depset, &cl->base.unit)) 128 if (!eina_hash_find(depset, &cl->base.unit))
121 eina_hash_add(depset, &cl->base.unit, cl->base.unit); 129 eina_hash_add(depset, &cl->base.unit, cl->base.unit);
@@ -154,6 +162,9 @@ _check_class(const Eolian_Class *cl, Eina_Hash *depset, Eina_Hash *chash)
154static void 162static void
155_check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, Eina_Hash *chash) 163_check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, Eina_Hash *chash)
156{ 164{
165 if (_check_cycle(chash, &tp->base))
166 return;
167
157 if (!eina_hash_find(depset, &tp->base.unit)) 168 if (!eina_hash_find(depset, &tp->base.unit))
158 eina_hash_add(depset, &tp->base.unit, tp->base.unit); 169 eina_hash_add(depset, &tp->base.unit, tp->base.unit);
159 170
@@ -189,6 +200,9 @@ _check_typedecl(const Eolian_Typedecl *tp, Eina_Hash *depset, Eina_Hash *chash)
189static void 200static void
190_check_variable(const Eolian_Variable *v, Eina_Hash *depset, Eina_Hash *chash) 201_check_variable(const Eolian_Variable *v, Eina_Hash *depset, Eina_Hash *chash)
191{ 202{
203 if (_check_cycle(chash, &v->base))
204 return;
205
192 if (!eina_hash_find(depset, &v->base.unit)) 206 if (!eina_hash_find(depset, &v->base.unit))
193 eina_hash_add(depset, &v->base.unit, v->base.unit); 207 eina_hash_add(depset, &v->base.unit, v->base.unit);
194 208