| ... | @@ -62,8 +62,6 @@ const LazySrcLoc = Module.LazySrcLoc; | ... | @@ -62,8 +62,6 @@ const LazySrcLoc = Module.LazySrcLoc; |
| 62 | const RangeSet = @import("RangeSet.zig"); | 62 | const RangeSet = @import("RangeSet.zig"); |
| 63 | const AstGen = @import("AstGen.zig"); | 63 | const AstGen = @import("AstGen.zig"); |
| 64 | | 64 | |
| 65 | const ValueSrcMap = std.HashMap(Value, LazySrcLoc, Value.hash, Value.eql, std.hash_map.DefaultMaxLoadPercentage); | | |
| 66 | | | |
| 67 | pub fn root(sema: *Sema, root_block: *Scope.Block) !zir.Inst.Index { | 65 | pub fn root(sema: *Sema, root_block: *Scope.Block) !zir.Inst.Index { |
| 68 | const inst_data = sema.code.instructions.items(.data)[0].pl_node; | 66 | const inst_data = sema.code.instructions.items(.data)[0].pl_node; |
| 69 | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); | 67 | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| ... | @@ -2557,7 +2555,7 @@ fn analyzeSwitch( | ... | @@ -2557,7 +2555,7 @@ fn analyzeSwitch( |
| 2557 | | 2555 | |
| 2558 | var extra_index: usize = special.end; | 2556 | var extra_index: usize = special.end; |
| 2559 | { | 2557 | { |
| 2560 | var scalar_i: usize = 0; | 2558 | var scalar_i: u32 = 0; |
| 2561 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 2559 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 2562 | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); | 2560 | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 2563 | extra_index += 1; | 2561 | extra_index += 1; |
| ... | @@ -2571,11 +2569,12 @@ fn analyzeSwitch( | ... | @@ -2571,11 +2569,12 @@ fn analyzeSwitch( |
| 2571 | &seen_values, | 2569 | &seen_values, |
| 2572 | item_ref, | 2570 | item_ref, |
| 2573 | src_node_offset, | 2571 | src_node_offset, |
| | 2572 | .{ .scalar = scalar_i }, |
| 2574 | ); | 2573 | ); |
| 2575 | } | 2574 | } |
| 2576 | } | 2575 | } |
| 2577 | { | 2576 | { |
| 2578 | var multi_i: usize = 0; | 2577 | var multi_i: u32 = 0; |
| 2579 | while (multi_i < multi_cases_len) : (multi_i += 1) { | 2578 | while (multi_i < multi_cases_len) : (multi_i += 1) { |
| 2580 | const items_len = sema.code.extra[extra_index]; | 2579 | const items_len = sema.code.extra[extra_index]; |
| 2581 | extra_index += 1; | 2580 | extra_index += 1; |
| ... | @@ -2586,12 +2585,13 @@ fn analyzeSwitch( | ... | @@ -2586,12 +2585,13 @@ fn analyzeSwitch( |
| 2586 | const items = sema.code.refSlice(extra_index, items_len); | 2585 | const items = sema.code.refSlice(extra_index, items_len); |
| 2587 | extra_index += items_len + body_len; | 2586 | extra_index += items_len + body_len; |
| 2588 | | 2587 | |
| 2589 | for (items) |item_ref| { | 2588 | for (items) |item_ref, item_i| { |
| 2590 | try sema.validateSwitchItemSparse( | 2589 | try sema.validateSwitchItemSparse( |
| 2591 | block, | 2590 | block, |
| 2592 | &seen_values, | 2591 | &seen_values, |
| 2593 | item_ref, | 2592 | item_ref, |
| 2594 | src_node_offset, | 2593 | src_node_offset, |
| | 2594 | .{ .multi = .{ .prong = multi_i, .item = @intCast(u32, item_i) } }, |
| 2595 | ); | 2595 | ); |
| 2596 | } | 2596 | } |
| 2597 | | 2597 | |
| ... | @@ -2981,14 +2981,19 @@ fn validateSwitchItemBool( | ... | @@ -2981,14 +2981,19 @@ fn validateSwitchItemBool( |
| 2981 | } | 2981 | } |
| 2982 | } | 2982 | } |
| 2983 | | 2983 | |
| | 2984 | const ValueSrcMap = std.HashMap(Value, AstGen.SwitchProngSrc, Value.hash, Value.eql, std.hash_map.DefaultMaxLoadPercentage); |
| | 2985 | |
| 2984 | fn validateSwitchItemSparse( | 2986 | fn validateSwitchItemSparse( |
| 2985 | sema: *Sema, | 2987 | sema: *Sema, |
| 2986 | block: *Scope.Block, | 2988 | block: *Scope.Block, |
| 2987 | seen_values: *ValueSrcMap, | 2989 | seen_values: *ValueSrcMap, |
| 2988 | item_ref: zir.Inst.Ref, | 2990 | item_ref: zir.Inst.Ref, |
| 2989 | src_node_offset: i32, | 2991 | src_node_offset: i32, |
| | 2992 | switch_prong_src: AstGen.SwitchProngSrc, |
| 2990 | ) InnerError!void { | 2993 | ) InnerError!void { |
| 2991 | @panic("TODO"); | 2994 | const item_val = try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none); |
| | 2995 | const entry = (try seen_values.fetchPut(item_val, switch_prong_src)) orelse return; |
| | 2996 | return sema.validateSwitchDupe(block, entry.value, switch_prong_src, src_node_offset); |
| 2992 | } | 2997 | } |
| 2993 | | 2998 | |
| 2994 | fn validateSwitchNoRange( | 2999 | fn validateSwitchNoRange( |