| ... | ... | @@ -2835,23 +2835,22 @@ fn identifier( |
| 2835 | 2835 | rl: ResultLoc, |
| 2836 | 2836 | ident: ast.Node.Index, |
| 2837 | 2837 | ) InnerError!zir.Inst.Ref { |
| 2838 | | if (true) @panic("TODO update for zir-memory-layout"); |
| 2839 | 2838 | const tracy = trace(@src()); |
| 2840 | 2839 | defer tracy.end(); |
| 2841 | 2840 | |
| 2842 | 2841 | const tree = scope.tree(); |
| 2843 | 2842 | const main_tokens = tree.nodes.items(.main_token); |
| 2844 | | const token_starts = tree.tokens.items(.start); |
| 2843 | |
| 2844 | const gz = scope.getGenZir(); |
| 2845 | 2845 | |
| 2846 | 2846 | const ident_token = main_tokens[ident]; |
| 2847 | 2847 | const ident_name = try mod.identifierTokenString(scope, ident_token); |
| 2848 | | const src = token_starts[ident_token]; |
| 2849 | 2848 | if (mem.eql(u8, ident_name, "_")) { |
| 2850 | 2849 | return mod.failNode(scope, ident, "TODO implement '_' identifier", .{}); |
| 2851 | 2850 | } |
| 2852 | 2851 | |
| 2853 | 2852 | if (simple_types.get(ident_name)) |zir_const_tag| { |
| 2854 | | return rvalue(mod, scope, rl, @enumToInt(zir_const_tag)); |
| 2853 | return rvalue(mod, scope, rl, @enumToInt(zir_const_tag), ident); |
| 2855 | 2854 | } |
| 2856 | 2855 | |
| 2857 | 2856 | if (ident_name.len >= 2) integer: { |
| ... | ... | @@ -2867,26 +2866,7 @@ fn identifier( |
| 2867 | 2866 | ), |
| 2868 | 2867 | error.InvalidCharacter => break :integer, |
| 2869 | 2868 | }; |
| 2870 | | const val = switch (bit_count) { |
| 2871 | | 8 => if (is_signed) Value.initTag(.i8_type) else Value.initTag(.u8_type), |
| 2872 | | 16 => if (is_signed) Value.initTag(.i16_type) else Value.initTag(.u16_type), |
| 2873 | | 32 => if (is_signed) Value.initTag(.i32_type) else Value.initTag(.u32_type), |
| 2874 | | 64 => if (is_signed) Value.initTag(.i64_type) else Value.initTag(.u64_type), |
| 2875 | | else => { |
| 2876 | | return rvalue(mod, scope, rl, try addZIRInstConst(mod, scope, src, .{ |
| 2877 | | .ty = Type.initTag(.type), |
| 2878 | | .val = try Value.Tag.int_type.create(scope.arena(), .{ |
| 2879 | | .signed = is_signed, |
| 2880 | | .bits = bit_count, |
| 2881 | | }), |
| 2882 | | })); |
| 2883 | | }, |
| 2884 | | }; |
| 2885 | | const result = try addZIRInstConst(mod, scope, src, .{ |
| 2886 | | .ty = Type.initTag(.type), |
| 2887 | | .val = val, |
| 2888 | | }); |
| 2889 | | return rvalue(mod, scope, rl, result); |
| 2869 | return rvalue(mod, scope, rl, try gz.addBin(.int_type, @boolToInt(is_signed), bit_count), ident); |
| 2890 | 2870 | } |
| 2891 | 2871 | } |
| 2892 | 2872 | |
| ... | ... | @@ -2897,7 +2877,7 @@ fn identifier( |
| 2897 | 2877 | .local_val => { |
| 2898 | 2878 | const local_val = s.cast(Scope.LocalVal).?; |
| 2899 | 2879 | if (mem.eql(u8, local_val.name, ident_name)) { |
| 2900 | | return rvalue(mod, scope, rl, local_val.inst); |
| 2880 | return rvalue(mod, scope, rl, local_val.inst, ident); |
| 2901 | 2881 | } |
| 2902 | 2882 | s = local_val.parent; |
| 2903 | 2883 | }, |
| ... | ... | @@ -2905,8 +2885,8 @@ fn identifier( |
| 2905 | 2885 | const local_ptr = s.cast(Scope.LocalPtr).?; |
| 2906 | 2886 | if (mem.eql(u8, local_ptr.name, ident_name)) { |
| 2907 | 2887 | if (rl == .ref) return local_ptr.ptr; |
| 2908 | | const loaded = try addZIRUnOp(mod, scope, src, .deref, local_ptr.ptr); |
| 2909 | | return rvalue(mod, scope, rl, loaded); |
| 2888 | const loaded = try gz.addUnNode(.deref_node, local_ptr.ptr, ident); |
| 2889 | return rvalue(mod, scope, rl, loaded, ident); |
| 2910 | 2890 | } |
| 2911 | 2891 | s = local_ptr.parent; |
| 2912 | 2892 | }, |
| ... | ... | @@ -2918,13 +2898,10 @@ fn identifier( |
| 2918 | 2898 | } |
| 2919 | 2899 | |
| 2920 | 2900 | if (mod.lookupDeclName(scope, ident_name)) |decl| { |
| 2921 | | if (rl == .ref) { |
| 2922 | | return addZIRInst(mod, scope, src, zir.Inst.DeclRef, .{ .decl = decl }, .{}); |
| 2923 | | } else { |
| 2924 | | return rvalue(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.DeclVal, .{ |
| 2925 | | .decl = decl, |
| 2926 | | }, .{})); |
| 2927 | | } |
| 2901 | return if (rl == .ref) |
| 2902 | gz.addDecl(.decl_ref, decl) |
| 2903 | else |
| 2904 | rvalue(mod, scope, rl, try gz.addDecl(.decl_val, decl), ident); |
| 2928 | 2905 | } |
| 2929 | 2906 | |
| 2930 | 2907 | return mod.failNode(scope, ident, "use of undeclared identifier '{s}'", .{ident_name}); |