EAPI Eolian_Value eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m) { Eolian_Value err; err.type = EOLIAN_EXPR_UNKNOWN; EINA_SAFETY_ON_NULL_RETURN_VAL(expr, err); return database_expr_eval(NULL, (Eolian_Expression *)expr, m, NULL, NULL); }
static Eolian_Value _eval_type(const Eolian_Expression *expr, const Eolian_Type *type) { Eolian_Value err; err.type = EOLIAN_EXPR_UNKNOWN; if (!type) return err; switch (type->type) { case EOLIAN_TYPE_ALIAS: return _eval_type(expr, eolian_type_base_type_get(type)); case EOLIAN_TYPE_POINTER: { int mask = EOLIAN_MASK_NULL; const Eolian_Type *base = eolian_type_base_type_get(type); int kw = base->name ? eo_lexer_keyword_str_to_id(base->name) : 0; if (kw == KW_char) mask |= EOLIAN_MASK_STRING; return database_expr_eval(expr, mask); } case EOLIAN_TYPE_CLASS: return database_expr_eval(expr, EOLIAN_MASK_NULL); case EOLIAN_TYPE_ENUM: return database_expr_eval(expr, EOLIAN_MASK_INT); case EOLIAN_TYPE_REGULAR: { int kw = eo_lexer_keyword_str_to_id(type->name); if (!kw || kw < KW_byte || kw >= KW_void) { const Eolian_Type *base = eolian_type_base_type_get(type); if (base) return _eval_type(expr, base); return err; } switch (kw) { case KW_byte: case KW_short: case KW_int: case KW_long: case KW_llong: case KW_int8: case KW_int16: case KW_int32: case KW_int64: case KW_int128: case KW_ssize: case KW_intptr: case KW_ptrdiff: return database_expr_eval(expr, EOLIAN_MASK_SINT); case KW_ubyte: case KW_ushort: case KW_uint: case KW_ulong: case KW_ullong: case KW_uint8: case KW_uint16: case KW_uint32: case KW_uint64: case KW_uint128: case KW_size: case KW_uintptr: case KW_time: return database_expr_eval(expr, EOLIAN_MASK_UINT); case KW_float: case KW_double: return database_expr_eval(expr, EOLIAN_MASK_FLOAT); case KW_bool: return database_expr_eval(expr, EOLIAN_MASK_BOOL); case KW_char: return database_expr_eval(expr, EOLIAN_MASK_CHAR); default: return err; } } default: return err; } }