aboutsummaryrefslogtreecommitdiff
path: root/src/js_lexer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/js_lexer.zig28
-rw-r--r--src/js_lexer/identifier.zig16
-rw-r--r--src/js_lexer_tables.zig7
3 files changed, 25 insertions, 26 deletions
diff --git a/src/js_lexer.zig b/src/js_lexer.zig
index f87d28694..5d41aec4b 100644
--- a/src/js_lexer.zig
+++ b/src/js_lexer.zig
@@ -274,7 +274,7 @@ fn NewLexer_(
}
pub inline fn isIdentifierOrKeyword(lexer: LexerType) bool {
- return @enumToInt(lexer.token) >= @enumToInt(T.t_identifier);
+ return @intFromEnum(lexer.token) >= @intFromEnum(T.t_identifier);
}
pub fn deinit(this: *LexerType) void {
@@ -304,7 +304,7 @@ fn NewLexer_(
// Convert '\r\n' into '\n'
const next_i: usize = iter.i + 1;
- iter.i += @as(u32, @boolToInt(next_i < text.len and text[next_i] == '\n'));
+ iter.i += @as(u32, @intFromBool(next_i < text.len and text[next_i] == '\n'));
// Convert '\r' into '\n'
buf.append('\n') catch unreachable;
@@ -572,7 +572,7 @@ fn NewLexer_(
// Make sure Windows CRLF counts as a single newline
const next_i: usize = iter.i + 1;
- iter.i += @as(u32, @boolToInt(next_i < text.len and text[next_i] == '\n'));
+ iter.i += @as(u32, @intFromBool(next_i < text.len and text[next_i] == '\n'));
// Ignore line continuations. A line continuation is not an escaped newline.
continue;
@@ -819,7 +819,7 @@ fn NewLexer_(
// This count is approximate because it handles "\n" and "\r\n" (the common
// cases) but not "\r" or "\u2028" or "\u2029". Getting this wrong is harmless
// because it's only a preallocation. The array will just grow if it's too small.
- lexer.approximate_newline_count += @boolToInt(lexer.code_point == '\n');
+ lexer.approximate_newline_count += @intFromBool(lexer.code_point == '\n');
}
pub inline fn expect(self: *LexerType, comptime token: T) !void {
@@ -1784,7 +1784,7 @@ fn NewLexer_(
pub fn unexpected(lexer: *LexerType) !void {
const found = finder: {
- lexer.start = std.math.min(lexer.start, lexer.end);
+ lexer.start = @min(lexer.start, lexer.end);
if (lexer.start == lexer.source.contents.len) {
break :finder "end of file";
@@ -1868,7 +1868,7 @@ fn NewLexer_(
const at = @bitCast(strings.AsciiVectorU1, vec == @splat(strings.ascii_vector_size, @as(u8, '@')));
if (@reduce(.Max, hashtag + at) == 1) {
- rest.len = @ptrToInt(end) - @ptrToInt(rest.ptr);
+ rest.len = @intFromPtr(end) - @intFromPtr(rest.ptr);
if (comptime Environment.allow_assert) {
std.debug.assert(
strings.containsChar(&@as([strings.ascii_vector_size]u8, vec), '#') or
@@ -1918,7 +1918,7 @@ fn NewLexer_(
rest.ptr += strings.ascii_vector_size;
}
- rest.len = @ptrToInt(end) - @ptrToInt(rest.ptr);
+ rest.len = @intFromPtr(end) - @intFromPtr(rest.ptr);
}
if (comptime Environment.allow_assert)
@@ -1930,7 +1930,7 @@ fn NewLexer_(
switch (c) {
'@', '#' => {
const chunk = rest;
- const i = @ptrToInt(chunk.ptr) - @ptrToInt(text.ptr);
+ const i = @intFromPtr(chunk.ptr) - @intFromPtr(text.ptr);
if (!lexer.has_pure_comment_before) {
if (strings.hasPrefixWithWordBoundary(chunk, "__PURE__")) {
lexer.has_pure_comment_before = true;
@@ -2952,7 +2952,7 @@ fn NewLexer_(
for (text) |c| {
number = number * 10 + @intCast(u32, c - '0');
}
- lexer.number = @intToFloat(f64, number);
+ lexer.number = @floatFromInt(f64, number);
} else {
// Parse a double-precision floating-point number
if (bun.parseDouble(text)) |num| {
@@ -3155,7 +3155,7 @@ pub fn rangeOfIdentifier(source: *const Source, loc: logger.Loc) logger.Range {
}
inline fn float64(num: anytype) f64 {
- return @intToFloat(f64, num);
+ return @floatFromInt(f64, num);
}
pub fn isLatin1Identifier(comptime Buffer: type, name: Buffer) bool {
@@ -3226,7 +3226,7 @@ fn latin1IdentifierContinueLength(name: []const u8) usize {
}
return @as(usize, first) +
- @ptrToInt(wrapped.ptr) - @ptrToInt(name.ptr);
+ @intFromPtr(wrapped.ptr) - @intFromPtr(name.ptr);
}
}
}
@@ -3330,12 +3330,12 @@ fn skipToInterestingCharacterInMultilineComment(text_: []const u8) ?u32 {
const first = @ctz(bitmask);
std.debug.assert(first < strings.ascii_vector_size);
std.debug.assert(text.ptr[first] == '*' or text.ptr[first] == '\r' or text.ptr[first] == '\n' or text.ptr[first] > 127);
- return @truncate(u32, first + (@ptrToInt(text.ptr) - @ptrToInt(text_.ptr)));
+ return @truncate(u32, first + (@intFromPtr(text.ptr) - @intFromPtr(text_.ptr)));
}
text.ptr += strings.ascii_vector_size;
}
- return @truncate(u32, @ptrToInt(text.ptr) - @ptrToInt(text_.ptr));
+ return @truncate(u32, @intFromPtr(text.ptr) - @intFromPtr(text_.ptr));
}
fn indexOfInterestingCharacterInStringLiteral(text_: []const u8, quote: u8) ?usize {
@@ -3357,7 +3357,7 @@ fn indexOfInterestingCharacterInStringLiteral(text_: []const u8, quote: u8) ?usi
const bitmask = @bitCast(u16, any_significant);
const first = @ctz(bitmask);
std.debug.assert(first < strings.ascii_vector_size);
- return first + (@ptrToInt(text.ptr) - @ptrToInt(text_.ptr));
+ return first + (@intFromPtr(text.ptr) - @intFromPtr(text_.ptr));
}
text = text[strings.ascii_vector_size..];
}
diff --git a/src/js_lexer/identifier.zig b/src/js_lexer/identifier.zig
index 4a48b5d17..8c1a59c2b 100644
--- a/src/js_lexer/identifier.zig
+++ b/src/js_lexer/identifier.zig
@@ -1800,7 +1800,7 @@ pub const JumpTableInline = struct {
// iter = std.unicode.Utf8Iterator{ .bytes = code, .i = 0 };
// hash_table_count = 0;
// while (iter.nextCodepoint()) |cp| {
-// hash_table_count += @as(usize, @boolToInt(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp)));
+// hash_table_count += @as(usize, @intFromBool(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp)));
// }
// }
// hash_table_elapsed += timer.read();
@@ -1816,7 +1816,7 @@ pub const JumpTableInline = struct {
// while (iter.nextCodepoint()) |cp| {
// jump_table_count += @as(
// usize,
-// @boolToInt(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)),
+// @intFromBool(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)),
// );
// }
// }
@@ -1833,7 +1833,7 @@ pub const JumpTableInline = struct {
// while (iter.nextCodepoint()) |cp| {
// binary_search_count += @as(
// usize,
-// @boolToInt(
+// @intFromBool(
// BinarySearch.isIdentifierStart(
// cp,
// ) or BinarySearch.isIdentifierPart(
@@ -1856,7 +1856,7 @@ pub const JumpTableInline = struct {
// while (iter.nextCodepoint()) |cp| {
// bitset_count += @as(
// usize,
-// @boolToInt(
+// @intFromBool(
// Bitset.isIdentifierStart(
// cp,
// ) or Bitset.isIdentifierPart(
@@ -1930,7 +1930,7 @@ pub const JumpTableInline = struct {
// iter = std.unicode.Utf8Iterator{ .bytes = code, .i = 0 };
// hash_table_count = 0;
// while (iter.nextCodepoint()) |cp| {
-// hash_table_count += @as(usize, @boolToInt(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp)));
+// hash_table_count += @as(usize, @intFromBool(HashTable.isIdentifierStart(cp) or HashTable.isIdentifierPart(cp)));
// }
// }
// hash_table_elapsed += timer.read();
@@ -1946,7 +1946,7 @@ pub const JumpTableInline = struct {
// while (iter.nextCodepoint()) |cp| {
// jump_table_count += @as(
// usize,
-// @boolToInt(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)),
+// @intFromBool(JumpTable.isIdentifierStart(cp) or JumpTable.isIdentifierPart(cp)),
// );
// }
// }
@@ -1963,7 +1963,7 @@ pub const JumpTableInline = struct {
// while (iter.nextCodepoint()) |cp| {
// binary_search_count += @as(
// usize,
-// @boolToInt(
+// @intFromBool(
// BinarySearch.isIdentifierStart(
// cp,
// ) or BinarySearch.isIdentifierPart(
@@ -1986,7 +1986,7 @@ pub const JumpTableInline = struct {
// while (iter.nextCodepoint()) |cp| {
// bitset_count += @as(
// usize,
-// @boolToInt(
+// @intFromBool(
// Bitset.isIdentifierStart(
// cp,
// ) or Bitset.isIdentifierPart(
diff --git a/src/js_lexer_tables.zig b/src/js_lexer_tables.zig
index dcf04573f..8256ff79d 100644
--- a/src/js_lexer_tables.zig
+++ b/src/js_lexer_tables.zig
@@ -136,11 +136,11 @@ pub const T = enum(u8) {
t_with,
pub fn isAssign(self: T) bool {
- return @enumToInt(self) >= @enumToInt(T.t_ampersand_ampersand_equals) and @enumToInt(self) <= @enumToInt(T.t_slash_equals);
+ return @intFromEnum(self) >= @intFromEnum(T.t_ampersand_ampersand_equals) and @intFromEnum(self) <= @intFromEnum(T.t_slash_equals);
}
pub fn isReservedWord(self: T) bool {
- return @enumToInt(self) >= @enumToInt(T.t_break) and @enumToInt(self) <= @enumToInt(T.t_with);
+ return @intFromEnum(self) >= @intFromEnum(T.t_break) and @intFromEnum(self) <= @intFromEnum(T.t_with);
}
pub fn isString(self: T) bool {
@@ -155,7 +155,7 @@ pub const T = enum(u8) {
}
pub fn isCloseBraceOrEOF(self: T) bool {
- return @enumToInt(self) <= @enumToInt(T.t_close_brace);
+ return @intFromEnum(self) <= @intFromEnum(T.t_close_brace);
}
};
@@ -842,4 +842,3 @@ test "tokenToString" {
// expect(v == 0x223C);
// }
// }
-