| ... | ... | @@ -2959,26 +2959,32 @@ fn floatLiteral( |
| 2959 | 2959 | mod: *Module, |
| 2960 | 2960 | scope: *Scope, |
| 2961 | 2961 | rl: ResultLoc, |
| 2962 | | float_lit: ast.Node.Index, |
| 2962 | node: ast.Node.Index, |
| 2963 | 2963 | ) InnerError!zir.Inst.Ref { |
| 2964 | | if (true) @panic("TODO update for zir-memory-layout"); |
| 2965 | 2964 | const arena = scope.arena(); |
| 2966 | 2965 | const tree = scope.tree(); |
| 2967 | 2966 | const main_tokens = tree.nodes.items(.main_token); |
| 2967 | const gz = scope.getGenZir(); |
| 2968 | 2968 | |
| 2969 | | const main_token = main_tokens[float_lit]; |
| 2969 | const main_token = main_tokens[node]; |
| 2970 | 2970 | const bytes = tree.tokenSlice(main_token); |
| 2971 | 2971 | if (bytes.len > 2 and bytes[1] == 'x') { |
| 2972 | assert(bytes[0] == '0'); // validated by tokenizer |
| 2972 | 2973 | return mod.failTok(scope, main_token, "TODO implement hex floats", .{}); |
| 2973 | 2974 | } |
| 2974 | 2975 | const float_number = std.fmt.parseFloat(f128, bytes) catch |e| switch (e) { |
| 2975 | 2976 | error.InvalidCharacter => unreachable, // validated by tokenizer |
| 2976 | 2977 | }; |
| 2977 | | const result = try addZIRInstConst(mod, scope, src, .{ |
| 2978 | const typed_value = try arena.create(TypedValue); |
| 2979 | typed_value.* = .{ |
| 2978 | 2980 | .ty = Type.initTag(.comptime_float), |
| 2979 | 2981 | .val = try Value.Tag.float_128.create(arena, float_number), |
| 2982 | }; |
| 2983 | const result = try gz.add(.{ |
| 2984 | .tag = .@"const", |
| 2985 | .data = .{ .@"const" = typed_value }, |
| 2980 | 2986 | }); |
| 2981 | | return rvalue(mod, scope, rl, result); |
| 2987 | return rvalue(mod, scope, rl, result, node); |
| 2982 | 2988 | } |
| 2983 | 2989 | |
| 2984 | 2990 | fn asmExpr( |