| ... | @@ -789,6 +789,9 @@ const DocData = struct { | ... | @@ -789,6 +789,9 @@ const DocData = struct { |
| 789 | builtinIndex: usize, | 789 | builtinIndex: usize, |
| 790 | builtinBin: BuiltinBin, | 790 | builtinBin: BuiltinBin, |
| 791 | builtinBinIndex: usize, | 791 | builtinBinIndex: usize, |
| | 792 | unionInit: UnionInit, |
| | 793 | builtinCall: BuiltinCall, |
| | 794 | mulAdd: MulAdd, |
| 792 | switchIndex: usize, // index in `exprs` | 795 | switchIndex: usize, // index in `exprs` |
| 793 | switchOp: SwitchOp, | 796 | switchOp: SwitchOp, |
| 794 | binOp: BinOp, | 797 | binOp: BinOp, |
| ... | @@ -810,10 +813,26 @@ const DocData = struct { | ... | @@ -810,10 +813,26 @@ const DocData = struct { |
| 810 | lhs: usize, // index in `exprs` | 813 | lhs: usize, // index in `exprs` |
| 811 | rhs: usize, // index in `exprs` | 814 | rhs: usize, // index in `exprs` |
| 812 | }; | 815 | }; |
| | 816 | const UnionInit = struct { |
| | 817 | type: usize, // index in `exprs` |
| | 818 | field: usize, // index in `exprs` |
| | 819 | init: usize, // index in `exprs` |
| | 820 | }; |
| 813 | const Builtin = struct { | 821 | const Builtin = struct { |
| 814 | name: []const u8 = "", // fn name | 822 | name: []const u8 = "", // fn name |
| 815 | param: usize, // index in `exprs` | 823 | param: usize, // index in `exprs` |
| 816 | }; | 824 | }; |
| | 825 | const BuiltinCall = struct { |
| | 826 | modifier: usize, // index in `exprs` |
| | 827 | function: usize, // index in `exprs` |
| | 828 | args: usize, // index in `exprs` |
| | 829 | }; |
| | 830 | const MulAdd = struct { |
| | 831 | mulend1: usize, // index in `exprs` |
| | 832 | mulend2: usize, // index in `exprs` |
| | 833 | addend: usize, // index in `exprs` |
| | 834 | type: usize, // index in `exprs` |
| | 835 | }; |
| 817 | const Slice = struct { | 836 | const Slice = struct { |
| 818 | lhs: usize, // index in `exprs` | 837 | lhs: usize, // index in `exprs` |
| 819 | start: usize, | 838 | start: usize, |
| ... | @@ -1519,6 +1538,7 @@ fn walkInstruction( | ... | @@ -1519,6 +1538,7 @@ fn walkInstruction( |
| 1519 | .shr, | 1538 | .shr, |
| 1520 | .bit_or, | 1539 | .bit_or, |
| 1521 | .bit_and, | 1540 | .bit_and, |
| | 1541 | .xor, |
| 1522 | // @check still not working when applied in std | 1542 | // @check still not working when applied in std |
| 1523 | // .array_cat, | 1543 | // .array_cat, |
| 1524 | // .array_mul, | 1544 | // .array_mul, |
| ... | @@ -1798,6 +1818,152 @@ fn walkInstruction( | ... | @@ -1798,6 +1818,152 @@ fn walkInstruction( |
| 1798 | .expr = .{ .builtinBinIndex = binop_index }, | 1818 | .expr = .{ .builtinBinIndex = binop_index }, |
| 1799 | }; | 1819 | }; |
| 1800 | }, | 1820 | }, |
| | 1821 | .mul_add => { |
| | 1822 | const pl_node = data[inst_index].pl_node; |
| | 1823 | const extra = file.zir.extraData(Zir.Inst.MulAdd, pl_node.payload_index); |
| | 1824 | |
| | 1825 | var mul1: DocData.WalkResult = try self.walkRef( |
| | 1826 | file, |
| | 1827 | parent_scope, |
| | 1828 | parent_src, |
| | 1829 | extra.data.mulend1, |
| | 1830 | false, |
| | 1831 | call_ctx, |
| | 1832 | ); |
| | 1833 | var mul2: DocData.WalkResult = try self.walkRef( |
| | 1834 | file, |
| | 1835 | parent_scope, |
| | 1836 | parent_src, |
| | 1837 | extra.data.mulend2, |
| | 1838 | false, |
| | 1839 | call_ctx, |
| | 1840 | ); |
| | 1841 | var add: DocData.WalkResult = try self.walkRef( |
| | 1842 | file, |
| | 1843 | parent_scope, |
| | 1844 | parent_src, |
| | 1845 | extra.data.addend, |
| | 1846 | false, |
| | 1847 | call_ctx, |
| | 1848 | ); |
| | 1849 | |
| | 1850 | const mul1_index = self.exprs.items.len; |
| | 1851 | try self.exprs.append(self.arena, mul1.expr); |
| | 1852 | const mul2_index = self.exprs.items.len; |
| | 1853 | try self.exprs.append(self.arena, mul2.expr); |
| | 1854 | const add_index = self.exprs.items.len; |
| | 1855 | try self.exprs.append(self.arena, add.expr); |
| | 1856 | |
| | 1857 | var type_index: usize = self.exprs.items.len; |
| | 1858 | try self.exprs.append(self.arena, add.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) }); |
| | 1859 | |
| | 1860 | return DocData.WalkResult{ |
| | 1861 | .typeRef = add.typeRef, |
| | 1862 | .expr = .{ |
| | 1863 | .mulAdd = .{ |
| | 1864 | .mulend1 = mul1_index, |
| | 1865 | .mulend2 = mul2_index, |
| | 1866 | .addend = add_index, |
| | 1867 | .type = type_index, |
| | 1868 | }, |
| | 1869 | }, |
| | 1870 | }; |
| | 1871 | }, |
| | 1872 | .union_init => { |
| | 1873 | const pl_node = data[inst_index].pl_node; |
| | 1874 | const extra = file.zir.extraData(Zir.Inst.UnionInit, pl_node.payload_index); |
| | 1875 | |
| | 1876 | var union_type: DocData.WalkResult = try self.walkRef( |
| | 1877 | file, |
| | 1878 | parent_scope, |
| | 1879 | parent_src, |
| | 1880 | extra.data.union_type, |
| | 1881 | false, |
| | 1882 | call_ctx, |
| | 1883 | ); |
| | 1884 | var field_name: DocData.WalkResult = try self.walkRef( |
| | 1885 | file, |
| | 1886 | parent_scope, |
| | 1887 | parent_src, |
| | 1888 | extra.data.field_name, |
| | 1889 | false, |
| | 1890 | call_ctx, |
| | 1891 | ); |
| | 1892 | var init: DocData.WalkResult = try self.walkRef( |
| | 1893 | file, |
| | 1894 | parent_scope, |
| | 1895 | parent_src, |
| | 1896 | extra.data.init, |
| | 1897 | false, |
| | 1898 | call_ctx, |
| | 1899 | ); |
| | 1900 | |
| | 1901 | const union_type_index = self.exprs.items.len; |
| | 1902 | try self.exprs.append(self.arena, union_type.expr); |
| | 1903 | const field_name_index = self.exprs.items.len; |
| | 1904 | try self.exprs.append(self.arena, field_name.expr); |
| | 1905 | const init_index = self.exprs.items.len; |
| | 1906 | try self.exprs.append(self.arena, init.expr); |
| | 1907 | |
| | 1908 | return DocData.WalkResult{ |
| | 1909 | .typeRef = union_type.expr, |
| | 1910 | .expr = .{ |
| | 1911 | .unionInit = .{ |
| | 1912 | .type = union_type_index, |
| | 1913 | .field = field_name_index, |
| | 1914 | .init = init_index, |
| | 1915 | }, |
| | 1916 | }, |
| | 1917 | }; |
| | 1918 | }, |
| | 1919 | .builtin_call => { |
| | 1920 | const pl_node = data[inst_index].pl_node; |
| | 1921 | const extra = file.zir.extraData(Zir.Inst.BuiltinCall, pl_node.payload_index); |
| | 1922 | |
| | 1923 | var modifier: DocData.WalkResult = try self.walkRef( |
| | 1924 | file, |
| | 1925 | parent_scope, |
| | 1926 | parent_src, |
| | 1927 | extra.data.modifier, |
| | 1928 | false, |
| | 1929 | call_ctx, |
| | 1930 | ); |
| | 1931 | |
| | 1932 | var callee: DocData.WalkResult = try self.walkRef( |
| | 1933 | file, |
| | 1934 | parent_scope, |
| | 1935 | parent_src, |
| | 1936 | extra.data.callee, |
| | 1937 | false, |
| | 1938 | call_ctx, |
| | 1939 | ); |
| | 1940 | |
| | 1941 | var args: DocData.WalkResult = try self.walkRef( |
| | 1942 | file, |
| | 1943 | parent_scope, |
| | 1944 | parent_src, |
| | 1945 | extra.data.args, |
| | 1946 | false, |
| | 1947 | call_ctx, |
| | 1948 | ); |
| | 1949 | |
| | 1950 | const modifier_index = self.exprs.items.len; |
| | 1951 | try self.exprs.append(self.arena, modifier.expr); |
| | 1952 | const function_index = self.exprs.items.len; |
| | 1953 | try self.exprs.append(self.arena, callee.expr); |
| | 1954 | const args_index = self.exprs.items.len; |
| | 1955 | try self.exprs.append(self.arena, args.expr); |
| | 1956 | |
| | 1957 | return DocData.WalkResult{ |
| | 1958 | .expr = .{ |
| | 1959 | .builtinCall = .{ |
| | 1960 | .modifier = modifier_index, |
| | 1961 | .function = function_index, |
| | 1962 | .args = args_index, |
| | 1963 | }, |
| | 1964 | }, |
| | 1965 | }; |
| | 1966 | }, |
| 1801 | .error_union_type => { | 1967 | .error_union_type => { |
| 1802 | const pl_node = data[inst_index].pl_node; | 1968 | const pl_node = data[inst_index].pl_node; |
| 1803 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); | 1969 | const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index); |