mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Allow implicit selector expressions in switch statements
This commit is contained in:
+6
-8
@@ -468,11 +468,10 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d
|
|||||||
buf: [256]byte;
|
buf: [256]byte;
|
||||||
start := 0;
|
start := 0;
|
||||||
|
|
||||||
using strconv.Int_Flag;
|
|
||||||
flags: strconv.Int_Flags;
|
flags: strconv.Int_Flags;
|
||||||
if fi.hash && !fi.zero do flags |= {Prefix};
|
if fi.hash && !fi.zero do flags |= {.Prefix};
|
||||||
if fi.plus do flags |= {Plus};
|
if fi.plus do flags |= {.Plus};
|
||||||
if fi.space do flags |= {Space};
|
if fi.space do flags |= {.Space};
|
||||||
s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags);
|
s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags);
|
||||||
|
|
||||||
if fi.hash && fi.zero {
|
if fi.hash && fi.zero {
|
||||||
@@ -746,11 +745,10 @@ fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") {
|
|||||||
ti = runtime.type_info_base(ti);
|
ti = runtime.type_info_base(ti);
|
||||||
switch info in ti.variant {
|
switch info in ti.variant {
|
||||||
case runtime.Type_Info_Integer:
|
case runtime.Type_Info_Integer:
|
||||||
using runtime.Type_Info_Endianness;
|
|
||||||
switch info.endianness {
|
switch info.endianness {
|
||||||
case Platform: return false;
|
case .Platform: return false;
|
||||||
case Little: return ODIN_ENDIAN != "little";
|
case .Little: return ODIN_ENDIAN != "little";
|
||||||
case Big: return ODIN_ENDIAN != "big";
|
case .Big: return ODIN_ENDIAN != "big";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-3
@@ -686,14 +686,14 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
|
|||||||
ast_node(ie, BinaryExpr, expr);
|
ast_node(ie, BinaryExpr, expr);
|
||||||
Operand lhs = {};
|
Operand lhs = {};
|
||||||
Operand rhs = {};
|
Operand rhs = {};
|
||||||
check_expr(ctx, &lhs, ie->left);
|
check_expr_with_type_hint(ctx, &lhs, ie->left, x.type);
|
||||||
if (x.mode == Addressing_Invalid) {
|
if (x.mode == Addressing_Invalid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (lhs.mode == Addressing_Invalid) {
|
if (lhs.mode == Addressing_Invalid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
check_expr(ctx, &rhs, ie->right);
|
check_expr_with_type_hint(ctx, &rhs, ie->right, x.type);
|
||||||
if (rhs.mode == Addressing_Invalid) {
|
if (rhs.mode == Addressing_Invalid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -732,7 +732,7 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
|
|||||||
if (is_type_typeid(x.type)) {
|
if (is_type_typeid(x.type)) {
|
||||||
check_expr_or_type(ctx, &y, expr, x.type);
|
check_expr_or_type(ctx, &y, expr, x.type);
|
||||||
} else {
|
} else {
|
||||||
check_expr(ctx, &y, expr);
|
check_expr_with_type_hint(ctx, &y, expr, x.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.mode == Addressing_Invalid ||
|
if (x.mode == Addressing_Invalid ||
|
||||||
|
|||||||
Reference in New Issue
Block a user