| ... | @@ -738,18 +738,6 @@ fn walkInstruction( | ... | @@ -738,18 +738,6 @@ fn walkInstruction( |
| 738 | ); | 738 | ); |
| 739 | return self.cteTodo(@tagName(tags[inst_index])); | 739 | return self.cteTodo(@tagName(tags[inst_index])); |
| 740 | }, | 740 | }, |
| 741 | .ret_node => { | | |
| 742 | const un_node = data[inst_index].un_node; | | |
| 743 | return self.walkRef(file, parent_scope, un_node.operand, false); | | |
| 744 | }, | | |
| 745 | .closure_get => { | | |
| 746 | const inst_node = data[inst_index].inst_node; | | |
| 747 | return try self.walkInstruction(file, parent_scope, inst_node.inst, need_type); | | |
| 748 | }, | | |
| 749 | .closure_capture => { | | |
| 750 | const un_tok = data[inst_index].un_tok; | | |
| 751 | return try self.walkRef(file, parent_scope, un_tok.operand, need_type); | | |
| 752 | }, | | |
| 753 | .import => { | 741 | .import => { |
| 754 | const str_tok = data[inst_index].str_tok; | 742 | const str_tok = data[inst_index].str_tok; |
| 755 | var path = str_tok.get(file.zir); | 743 | var path = str_tok.get(file.zir); |
| ... | @@ -848,6 +836,54 @@ fn walkInstruction( | ... | @@ -848,6 +836,54 @@ fn walkInstruction( |
| 848 | need_type, | 836 | need_type, |
| 849 | ); | 837 | ); |
| 850 | }, | 838 | }, |
| | 839 | .ret_node => { |
| | 840 | const un_node = data[inst_index].un_node; |
| | 841 | return self.walkRef(file, parent_scope, un_node.operand, false); |
| | 842 | }, |
| | 843 | .ret_load => { |
| | 844 | const un_node = data[inst_index].un_node; |
| | 845 | const res_ptr_ref = un_node.operand; |
| | 846 | const res_ptr_inst = @enumToInt(res_ptr_ref) - Ref.typed_value_map.len; |
| | 847 | // TODO: this instruction doesn't let us know trivially if there's |
| | 848 | // branching involved or not. For now here's the strat: |
| | 849 | // We search backwarts until `ret_ptr` for `store_node`, |
| | 850 | // if we find only one, then that's our value, if we find more |
| | 851 | // than one, then it means that there's branching involved. |
| | 852 | // Maybe. |
| | 853 | |
| | 854 | var i = inst_index - 1; |
| | 855 | var result_ref: ?Ref = null; |
| | 856 | while (i > res_ptr_inst) : (i -= 1) { |
| | 857 | if (tags[i] == .store_node) { |
| | 858 | const pl_node = data[i].pl_node; |
| | 859 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); |
| | 860 | if (extra.data.lhs == res_ptr_ref) { |
| | 861 | // this store_load instruction is indeed pointing at |
| | 862 | // the result location that we care about! |
| | 863 | if (result_ref != null) return DocData.WalkResult{ |
| | 864 | .expr = .{ .comptimeExpr = 0 }, |
| | 865 | }; |
| | 866 | result_ref = extra.data.rhs; |
| | 867 | } |
| | 868 | } |
| | 869 | } |
| | 870 | |
| | 871 | if (result_ref) |rr| { |
| | 872 | return self.walkRef(file, parent_scope, rr, need_type); |
| | 873 | } |
| | 874 | |
| | 875 | return DocData.WalkResult{ |
| | 876 | .expr = .{ .comptimeExpr = 0 }, |
| | 877 | }; |
| | 878 | }, |
| | 879 | .closure_get => { |
| | 880 | const inst_node = data[inst_index].inst_node; |
| | 881 | return try self.walkInstruction(file, parent_scope, inst_node.inst, need_type); |
| | 882 | }, |
| | 883 | .closure_capture => { |
| | 884 | const un_tok = data[inst_index].un_tok; |
| | 885 | return try self.walkRef(file, parent_scope, un_tok.operand, need_type); |
| | 886 | }, |
| 851 | .cmpxchg_strong, .cmpxchg_weak => { | 887 | .cmpxchg_strong, .cmpxchg_weak => { |
| 852 | const pl_node = data[inst_index].pl_node; | 888 | const pl_node = data[inst_index].pl_node; |
| 853 | const extra = file.zir.extraData(Zir.Inst.Cmpxchg, pl_node.payload_index); | 889 | const extra = file.zir.extraData(Zir.Inst.Cmpxchg, pl_node.payload_index); |