mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-08 22:13:17 +00:00
bit_set['A'..'Z'], bit_set[0..8]
This commit is contained in:
@@ -2047,14 +2047,23 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, bool use_lhs_as
|
||||
ExactValue v = exact_value_to_integer(y->value);
|
||||
GB_ASSERT(k.kind == ExactValue_Integer);
|
||||
GB_ASSERT(v.kind == ExactValue_Integer);
|
||||
i64 bit = 1ll<<big_int_to_i64(&k.value_integer);
|
||||
i64 bits = big_int_to_i64(&v.value_integer);
|
||||
i64 key = big_int_to_i64(&k.value_integer);
|
||||
i64 lower = yt->BitSet.lower;
|
||||
i64 upper = yt->BitSet.upper;
|
||||
|
||||
x->mode = Addressing_Constant;
|
||||
x->type = t_untyped_bool;
|
||||
x->value = exact_value_bool((bit & bits) != 0);
|
||||
x->expr = node;
|
||||
return;
|
||||
if (lower <= key && key <= upper) {
|
||||
i64 bit = 1ll<<key;
|
||||
i64 bits = big_int_to_i64(&v.value_integer);
|
||||
|
||||
x->mode = Addressing_Constant;
|
||||
x->type = t_untyped_bool;
|
||||
x->value = exact_value_bool((bit & bits) != 0);
|
||||
x->expr = node;
|
||||
return;
|
||||
} else {
|
||||
error(x->expr, "key '%lld' out of range of bit set, %lld..%lld", key, lower, upper);
|
||||
x->mode = Addressing_Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -5591,7 +5600,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
|
||||
if (is_type_bit_set(type)) {
|
||||
// NOTE(bill): Encode as an integer
|
||||
|
||||
i64 lower = base_type(type)->BitSet.min;
|
||||
i64 lower = base_type(type)->BitSet.lower;
|
||||
|
||||
u64 bits = 0;
|
||||
for_array(index, cl->elems) {
|
||||
|
||||
Reference in New Issue
Block a user