summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-16 15:30:58 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-16 16:37:52 +0100
commit29a9b9ad44ee7ec34f288d623542fc624d9fa410 (patch)
tree32f8af8914c49cdb35228a54179ed6191809c1a7
parent5555726fef16e8e1c5ec907e0fcdcadeecea694c (diff)
eolian: expose _eval_type to internals
-rw-r--r--src/lib/eolian/database_expr.c75
-rw-r--r--src/lib/eolian/database_expr_api.c79
-rw-r--r--src/lib/eolian/eolian_database.h1
3 files changed, 79 insertions, 76 deletions
diff --git a/src/lib/eolian/database_expr.c b/src/lib/eolian/database_expr.c
index f22a09e308..eb2dc17e37 100644
--- a/src/lib/eolian/database_expr.c
+++ b/src/lib/eolian/database_expr.c
@@ -7,6 +7,7 @@
7#include <Eina.h> 7#include <Eina.h>
8#include "eolian_database.h" 8#include "eolian_database.h"
9#include "eolian_priv.h" 9#include "eolian_priv.h"
10#include "eo_lexer.h"
10 11
11static Eina_Bool 12static Eina_Bool
12node_error(const Eolian_Object *obj, const char *msg) 13node_error(const Eolian_Object *obj, const char *msg)
@@ -575,6 +576,80 @@ database_expr_eval(const Eolian_Unit *unit, const Eolian_Expression *expr,
575 return ret; 576 return ret;
576} 577}
577 578
579Eolian_Value
580database_expr_eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr,
581 const Eolian_Type *type)
582{
583 Eolian_Value err;
584 err.type = EOLIAN_EXPR_UNKNOWN;
585 if (!type)
586 return err;
587 switch (type->type)
588 {
589 case EOLIAN_TYPE_CLASS:
590 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
591 case EOLIAN_TYPE_REGULAR:
592 {
593 if (database_type_is_ownable(unit, type))
594 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
595 int kw = eo_lexer_keyword_str_to_id(type->name);
596 if (!kw || kw < KW_byte || kw >= KW_void)
597 {
598 const Eolian_Typedecl *base = database_type_decl_find(unit, type);
599 if (!base)
600 return err;
601 if (base->type == EOLIAN_TYPEDECL_ALIAS)
602 return database_expr_eval_type(unit, expr, eolian_typedecl_base_type_get(base));
603 else if (base->type == EOLIAN_TYPEDECL_ENUM)
604 return database_expr_eval(unit, expr, EOLIAN_MASK_INT);
605 return err;
606 }
607 switch (kw)
608 {
609 case KW_byte:
610 case KW_short:
611 case KW_int:
612 case KW_long:
613 case KW_llong:
614 case KW_int8:
615 case KW_int16:
616 case KW_int32:
617 case KW_int64:
618 case KW_int128:
619 case KW_ssize:
620 case KW_intptr:
621 case KW_ptrdiff:
622 return database_expr_eval(unit, expr, EOLIAN_MASK_SINT);
623 case KW_ubyte:
624 case KW_ushort:
625 case KW_uint:
626 case KW_ulong:
627 case KW_ullong:
628 case KW_uint8:
629 case KW_uint16:
630 case KW_uint32:
631 case KW_uint64:
632 case KW_uint128:
633 case KW_size:
634 case KW_uintptr:
635 case KW_time:
636 return database_expr_eval(unit, expr, EOLIAN_MASK_UINT);
637 case KW_float:
638 case KW_double:
639 return database_expr_eval(unit, expr, EOLIAN_MASK_FLOAT);
640 case KW_bool:
641 return database_expr_eval(unit, expr, EOLIAN_MASK_BOOL);
642 case KW_char:
643 return database_expr_eval(unit, expr, EOLIAN_MASK_CHAR);
644 default:
645 return err;
646 }
647 }
648 default:
649 return err;
650 }
651}
652
578void 653void
579database_expr_del(Eolian_Expression *expr) 654database_expr_del(Eolian_Expression *expr)
580{ 655{
diff --git a/src/lib/eolian/database_expr_api.c b/src/lib/eolian/database_expr_api.c
index 791d59e104..b1fadcb6ce 100644
--- a/src/lib/eolian/database_expr_api.c
+++ b/src/lib/eolian/database_expr_api.c
@@ -3,7 +3,8 @@
3#endif 3#endif
4 4
5#include <Eina.h> 5#include <Eina.h>
6#include "eo_lexer.h" 6
7#include "eolian_database.h"
7 8
8EAPI Eolian_Value 9EAPI Eolian_Value
9eolian_expression_eval(const Eolian_Unit *unit, const Eolian_Expression *expr, 10eolian_expression_eval(const Eolian_Unit *unit, const Eolian_Expression *expr,
@@ -15,80 +16,6 @@ eolian_expression_eval(const Eolian_Unit *unit, const Eolian_Expression *expr,
15 return database_expr_eval(unit, expr, m); 16 return database_expr_eval(unit, expr, m);
16} 17}
17 18
18static Eolian_Value
19_eval_type(const Eolian_Unit *unit, const Eolian_Expression *expr,
20 const Eolian_Type *type)
21{
22 Eolian_Value err;
23 err.type = EOLIAN_EXPR_UNKNOWN;
24 if (!type)
25 return err;
26 switch (type->type)
27 {
28 case EOLIAN_TYPE_CLASS:
29 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
30 case EOLIAN_TYPE_REGULAR:
31 {
32 if (database_type_is_ownable(unit, type))
33 return database_expr_eval(unit, expr, EOLIAN_MASK_NULL);
34 int kw = eo_lexer_keyword_str_to_id(type->name);
35 if (!kw || kw < KW_byte || kw >= KW_void)
36 {
37 const Eolian_Typedecl *base = database_type_decl_find(unit, type);
38 if (!base)
39 return err;
40 if (base->type == EOLIAN_TYPEDECL_ALIAS)
41 return _eval_type(unit, expr, eolian_typedecl_base_type_get(base));
42 else if (base->type == EOLIAN_TYPEDECL_ENUM)
43 return database_expr_eval(unit, expr, EOLIAN_MASK_INT);
44 return err;
45 }
46 switch (kw)
47 {
48 case KW_byte:
49 case KW_short:
50 case KW_int:
51 case KW_long:
52 case KW_llong:
53 case KW_int8:
54 case KW_int16:
55 case KW_int32:
56 case KW_int64:
57 case KW_int128:
58 case KW_ssize:
59 case KW_intptr:
60 case KW_ptrdiff:
61 return database_expr_eval(unit, expr, EOLIAN_MASK_SINT);
62 case KW_ubyte:
63 case KW_ushort:
64 case KW_uint:
65 case KW_ulong:
66 case KW_ullong:
67 case KW_uint8:
68 case KW_uint16:
69 case KW_uint32:
70 case KW_uint64:
71 case KW_uint128:
72 case KW_size:
73 case KW_uintptr:
74 case KW_time:
75 return database_expr_eval(unit, expr, EOLIAN_MASK_UINT);
76 case KW_float:
77 case KW_double:
78 return database_expr_eval(unit, expr, EOLIAN_MASK_FLOAT);
79 case KW_bool:
80 return database_expr_eval(unit, expr, EOLIAN_MASK_BOOL);
81 case KW_char:
82 return database_expr_eval(unit, expr, EOLIAN_MASK_CHAR);
83 default:
84 return err;
85 }
86 }
87 default:
88 return err;
89 }
90}
91
92EAPI Eolian_Value 19EAPI Eolian_Value
93eolian_expression_eval_type(const Eolian_Unit *unit, 20eolian_expression_eval_type(const Eolian_Unit *unit,
94 const Eolian_Expression *expr, 21 const Eolian_Expression *expr,
@@ -97,7 +24,7 @@ eolian_expression_eval_type(const Eolian_Unit *unit,
97 Eolian_Value err; 24 Eolian_Value err;
98 err.type = EOLIAN_EXPR_UNKNOWN; 25 err.type = EOLIAN_EXPR_UNKNOWN;
99 EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err); 26 EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err);
100 return _eval_type(unit, expr, type); 27 return database_expr_eval_type(unit, expr, type);
101} 28}
102 29
103static void 30static void
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 5f804a5aa9..23a569206a 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -348,6 +348,7 @@ Eina_Bool database_type_is_ownable(const Eolian_Unit *unit, const Eolian_Type *t
348/* expressions */ 348/* expressions */
349 349
350Eolian_Value database_expr_eval(const Eolian_Unit *unit, const Eolian_Expression *expr, Eolian_Expression_Mask mask); 350Eolian_Value database_expr_eval(const Eolian_Unit *unit, const 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);
351void database_expr_del(Eolian_Expression *expr); 352void database_expr_del(Eolian_Expression *expr);
352void database_expr_print(Eolian_Expression *expr); 353void database_expr_print(Eolian_Expression *expr);
353 354