| ... | ... | @@ -1314,16 +1314,19 @@ fn astGenStringLiteral(self: *Module, scope: *Scope, str_lit: *ast.Node.StringLi |
| 1314 | 1314 | fn astGenIntegerLiteral(self: *Module, scope: *Scope, int_lit: *ast.Node.IntegerLiteral) InnerError!*zir.Inst { |
| 1315 | 1315 | const arena = scope.arena(); |
| 1316 | 1316 | const tree = scope.tree(); |
| 1317 | | const bytes = tree.tokenSlice(int_lit.token); |
| 1317 | var bytes = tree.tokenSlice(int_lit.token); |
| 1318 | const base = if (mem.startsWith(u8, bytes, "0x")) |
| 1319 | 16 |
| 1320 | else if (mem.startsWith(u8, bytes, "0o")) |
| 1321 | 8 |
| 1322 | else if (mem.startsWith(u8, bytes, "0b")) |
| 1323 | 2 |
| 1324 | else |
| 1325 | @as(u8, 10); |
| 1318 | 1326 | |
| 1319 | | if (mem.startsWith(u8, bytes, "0x")) { |
| 1320 | | return self.failTok(scope, int_lit.token, "TODO implement 0x int prefix", .{}); |
| 1321 | | } else if (mem.startsWith(u8, bytes, "0o")) { |
| 1322 | | return self.failTok(scope, int_lit.token, "TODO implement 0o int prefix", .{}); |
| 1323 | | } else if (mem.startsWith(u8, bytes, "0b")) { |
| 1324 | | return self.failTok(scope, int_lit.token, "TODO implement 0b int prefix", .{}); |
| 1325 | | } |
| 1326 | | if (std.fmt.parseInt(u64, bytes, 10)) |small_int| { |
| 1327 | if (base != 10) bytes = bytes[2..]; |
| 1328 | |
| 1329 | if (std.fmt.parseInt(u64, bytes, base)) |small_int| { |
| 1327 | 1330 | const int_payload = try arena.create(Value.Payload.Int_u64); |
| 1328 | 1331 | int_payload.* = .{ .int = small_int }; |
| 1329 | 1332 | const src = tree.token_locs[int_lit.token].start; |