summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-16 15:50:58 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-16 16:37:52 +0100
commitb70604d018366cf1e825668643916a2c3cc4a88b (patch)
treeb1f45092328e7be250c16260de782e9d7176e796
parent29a9b9ad44ee7ec34f288d623542fc624d9fa410 (diff)
eolian: cache enum expr in the database
-rw-r--r--src/lib/eolian/database_expr.c28
-rw-r--r--src/lib/eolian/database_expr_api.c4
-rw-r--r--src/lib/eolian/database_validate.c4
-rw-r--r--src/lib/eolian/eolian_database.h11
4 files changed, 29 insertions, 18 deletions
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index eb2dc17e37..ffe96f511a 100644
--- a/src/lib/eolian/database_expr.c
+++ b/src/lib/eolian/database_expr.c
@@ -183,11 +183,11 @@ promote(Eolian_Expression *a, Eolian_Expression *b)
183} 183}
184 184
185static Eina_Bool eval_exp(const Eolian_Unit *unit, 185static Eina_Bool eval_exp(const Eolian_Unit *unit,
186 const Eolian_Expression *expr, 186 Eolian_Expression *expr,
187 Eolian_Expression_Mask mask, Eolian_Expression *out); 187 Eolian_Expression_Mask mask, Eolian_Expression *out);
188 188
189static Eina_Bool 189static Eina_Bool
190eval_unary(const Eolian_Unit *unit, const Eolian_Expression *expr, 190eval_unary(const Eolian_Unit *unit, Eolian_Expression *expr,
191 Eolian_Expression_Mask mask, Eolian_Expression *out) 191 Eolian_Expression_Mask mask, Eolian_Expression *out)
192{ 192{
193 switch (expr->unop) 193 switch (expr->unop)
@@ -273,7 +273,7 @@ eval_unary(const Eolian_Unit *unit, const Eolian_Expression *expr,
273} 273}
274 274
275static Eina_Bool 275static Eina_Bool
276eval_promote_num(const Eolian_Unit *unit, const Eolian_Expression *expr, 276eval_promote_num(const Eolian_Unit *unit, Eolian_Expression *expr,
277 Eolian_Expression *lhs, Eolian_Expression *rhs, int mask, 277 Eolian_Expression *lhs, Eolian_Expression *rhs, int mask,
278 int emask) 278 int emask)
279{ 279{
@@ -296,7 +296,7 @@ eval_promote_num(const Eolian_Unit *unit, const Eolian_Expression *expr,
296} 296}
297 297
298static Eina_Bool 298static Eina_Bool
299eval_binary(const Eolian_Unit *unit, const Eolian_Expression *expr, 299eval_binary(const Eolian_Unit *unit, Eolian_Expression *expr,
300 Eolian_Expression_Mask mask, Eolian_Expression *out) 300 Eolian_Expression_Mask mask, Eolian_Expression *out)
301{ 301{
302#define APPLY_CASE(id, expr, lhs, rhs, fnm, op) \ 302#define APPLY_CASE(id, expr, lhs, rhs, fnm, op) \
@@ -437,7 +437,7 @@ split_enum_name(const char *str, char **ename, char **memb)
437} 437}
438 438
439static Eina_Bool 439static Eina_Bool
440eval_exp(const Eolian_Unit *unit, const Eolian_Expression *expr, 440eval_exp(const Eolian_Unit *unit, Eolian_Expression *expr,
441 Eolian_Expression_Mask mask, Eolian_Expression *out) 441 Eolian_Expression_Mask mask, Eolian_Expression *out)
442{ 442{
443 switch (expr->type) 443 switch (expr->type)
@@ -498,9 +498,16 @@ eval_exp(const Eolian_Unit *unit, const Eolian_Expression *expr,
498 } 498 }
499 case EOLIAN_EXPR_NAME: 499 case EOLIAN_EXPR_NAME:
500 { 500 {
501 if (!unit)
502 {
503 if (!expr->expr)
504 return expr_error(expr, "undefined value");
505 return eval_exp(NULL, expr->expr, mask, out);
506 }
507
501 const Eolian_Variable *var = eolian_variable_constant_get_by_name 508 const Eolian_Variable *var = eolian_variable_constant_get_by_name
502 (unit, expr->value.s); 509 (unit, expr->value.s);
503 const Eolian_Expression *exp = NULL; 510 Eolian_Expression *exp = NULL;
504 511
505 if (!var) 512 if (!var)
506 { 513 {
@@ -534,18 +541,19 @@ eval_exp(const Eolian_Unit *unit, const Eolian_Expression *expr,
534 } 541 }
535 542
536 fl = eolian_typedecl_enum_field_get(etpd, memb); 543 fl = eolian_typedecl_enum_field_get(etpd, memb);
537 if (fl) exp = eolian_typedecl_enum_field_value_get(fl, EINA_TRUE); 544 if (fl) exp = (Eolian_Expression *)eolian_typedecl_enum_field_value_get(fl, EINA_TRUE);
538 free(fulln); 545 free(fulln);
539 546
540 if (!exp) 547 if (!exp)
541 return expr_error(expr, "invalid enum field"); 548 return expr_error(expr, "invalid enum field");
542 } 549 }
543 else 550 else
544 exp = var->value; 551 exp = (Eolian_Expression *)var->value;
545 552
546 if (!exp) 553 if (!exp)
547 return expr_error(expr, "undefined variable"); 554 return expr_error(expr, "undefined variable");
548 555
556 expr->expr = exp;
549 return eval_exp(unit, exp, mask, out); 557 return eval_exp(unit, exp, mask, out);
550 } 558 }
551 case EOLIAN_EXPR_UNARY: 559 case EOLIAN_EXPR_UNARY:
@@ -561,7 +569,7 @@ eval_exp(const Eolian_Unit *unit, const Eolian_Expression *expr,
561} 569}
562 570
563Eolian_Value 571Eolian_Value
564database_expr_eval(const Eolian_Unit *unit, const Eolian_Expression *expr, 572database_expr_eval(const Eolian_Unit *unit, Eolian_Expression *expr,
565 Eolian_Expression_Mask mask) 573 Eolian_Expression_Mask mask)
566{ 574{
567 Eolian_Expression out; 575 Eolian_Expression out;
@@ -577,7 +585,7 @@ database_expr_eval(const Eolian_Unit *unit, const Eolian_Expression *expr,
577} 585}
578 586
579Eolian_Value 587Eolian_Value
580database_expr_eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr, 588database_expr_eval_type(const Eolian_Unit *unit, Eolian_Expression *expr,
581 const Eolian_Type *type) 589 const Eolian_Type *type)
582{ 590{
583 Eolian_Value err; 591 Eolian_Value err;
diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c
index b1fadcb6ce..a8994cc50b 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -13,7 +13,7 @@ eolian_expression_eval(const Eolian_Unit *unit, const Eolian_Expression *expr,
13 Eolian_Value err; 13 Eolian_Value err;
14 err.type = EOLIAN_EXPR_UNKNOWN; 14 err.type = EOLIAN_EXPR_UNKNOWN;
15 EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err); 15 EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err);
16 return database_expr_eval(unit, expr, m); 16 return database_expr_eval(unit, (Eolian_Expression *)expr, m);
17} 17}
18 18
19EAPI Eolian_Value 19EAPI Eolian_Value
@@ -24,7 +24,7 @@ eolian_expression_eval_type(const Eolian_Unit *unit,
24 Eolian_Value err; 24 Eolian_Value err;
25 err.type = EOLIAN_EXPR_UNKNOWN; 25 err.type = EOLIAN_EXPR_UNKNOWN;
26 EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err); 26 EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err);
27 return database_expr_eval_type(unit, expr, type); 27 return database_expr_eval_type(unit, (Eolian_Expression *)expr, type);
28} 28}
29 29
30static void 30static void
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index c3e7887a37..41ac2a206e 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -292,9 +292,9 @@ _validate_expr(const Eolian_Unit *src, Eolian_Expression *expr,
292{ 292{
293 Eolian_Value val; 293 Eolian_Value val;
294 if (tp) 294 if (tp)
295 val = eolian_expression_eval_type(src, expr, tp); 295 val = database_expr_eval_type(src, expr, tp);
296 else 296 else
297 val = eolian_expression_eval(src, expr, msk); 297 val = database_expr_eval(src, expr, msk);
298 298
299 if (val.type == EOLIAN_EXPR_UNKNOWN) 299 if (val.type == EOLIAN_EXPR_UNKNOWN)
300 return EINA_FALSE; 300 return EINA_FALSE;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 23a569206a..166511a264 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -296,10 +296,13 @@ struct _Eolian_Expression
296 }; 296 };
297 struct 297 struct
298 { 298 {
299 Eolian_Unary_Operator unop; 299 union
300 {
301 Eolian_Unary_Operator unop;
302 Eolian_Value_Union value;
303 };
300 Eolian_Expression *expr; 304 Eolian_Expression *expr;
301 }; 305 };
302 Eolian_Value_Union value;
303 }; 306 };
304 Eina_Bool weak_lhs :1; 307 Eina_Bool weak_lhs :1;
305 Eina_Bool weak_rhs :1; 308 Eina_Bool weak_rhs :1;
@@ -347,8 +350,8 @@ Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *t
347 350
348/* expressions */ 351/* expressions */
349 352
350Eolian_Value database_expr_eval(const Eolian_Unit *unit, const Eolian_Expression *expr, Eolian_Expression_Mask mask); 353Eolian_Value database_expr_eval(const Eolian_Unit *unit, Eolian_Expression *expr, Eolian_Expression_Mask mask);
351Eolian_Value database_expr_eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr, const Eolian_Type *type); 354Eolian_Value database_expr_eval_type(const Eolian_Unit *unit, Eolian_Expression *expr, const Eolian_Type *type);
352void database_expr_del(Eolian_Expression *expr); 355void database_expr_del(Eolian_Expression *expr);
353void database_expr_print(Eolian_Expression *expr); 356void database_expr_print(Eolian_Expression *expr);
354 357