| ... | @@ -669,7 +669,7 @@ const DocData = struct { | ... | @@ -669,7 +669,7 @@ const DocData = struct { |
| 669 | rhs: usize, // index in `exprs` | 669 | rhs: usize, // index in `exprs` |
| 670 | // opKind | 670 | // opKind |
| 671 | // Identify the operator in js | 671 | // Identify the operator in js |
| 672 | // 0: add, 1: sub, 2: mul, 3: div, 4: mod, 5: rem, 6: rem_mod, 7: shl, 8: shr | 672 | // 0: add, 1: sub, 2: mul, 3: div, 4: mod, 5: rem, 6: rem_mod, 7: shl, 8: shr, 9: bitcast |
| 673 | // Others binOp are not handled yet | 673 | // Others binOp are not handled yet |
| 674 | opKind: usize = 0, | 674 | opKind: usize = 0, |
| 675 | // flags to operations | 675 | // flags to operations |
| ... | @@ -969,6 +969,37 @@ fn walkInstruction( | ... | @@ -969,6 +969,37 @@ fn walkInstruction( |
| 969 | .expr = .{ .int = .{ .value = int } }, | 969 | .expr = .{ .int = .{ .value = int } }, |
| 970 | }; | 970 | }; |
| 971 | }, | 971 | }, |
| | 972 | .bitcast => { |
| | 973 | const pl_node = data[inst_index].pl_node; |
| | 974 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); |
| | 975 | |
| | 976 | const binop_index = self.exprs.items.len; |
| | 977 | try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } }); |
| | 978 | |
| | 979 | var lhs: DocData.WalkResult = try self.walkRef( |
| | 980 | file, |
| | 981 | parent_scope, |
| | 982 | extra.data.lhs, |
| | 983 | false, |
| | 984 | ); |
| | 985 | var rhs: DocData.WalkResult = try self.walkRef( |
| | 986 | file, |
| | 987 | parent_scope, |
| | 988 | extra.data.rhs, |
| | 989 | false, |
| | 990 | ); |
| | 991 | |
| | 992 | const lhs_index = self.exprs.items.len; |
| | 993 | try self.exprs.append(self.arena, lhs.expr); |
| | 994 | const rhs_index = self.exprs.items.len; |
| | 995 | try self.exprs.append(self.arena, rhs.expr); |
| | 996 | self.exprs.items[binop_index] = .{ .binOp = .{ .lhs = lhs_index, .rhs = rhs_index, .opKind = 9 } }; |
| | 997 | |
| | 998 | return DocData.WalkResult{ |
| | 999 | .typeRef = .{ .type = @enumToInt(Ref.type_type) }, |
| | 1000 | .expr = .{ .binOpIndex = binop_index }, |
| | 1001 | }; |
| | 1002 | }, |
| 972 | .add => { | 1003 | .add => { |
| 973 | const pl_node = data[inst_index].pl_node; | 1004 | const pl_node = data[inst_index].pl_node; |
| 974 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); | 1005 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); |