diff options
author | 2021-05-13 21:10:02 -0700 | |
---|---|---|
committer | 2021-05-13 21:10:02 -0700 | |
commit | 0666f8151a51ef96daeb8691459313d01730c014 (patch) | |
tree | f39ee057eef934bd72525472da4b404434740e87 /src/js_lexer.zig | |
parent | 1fba2dc20f1e194ec3aa1475919880fd4c725118 (diff) | |
download | bun-0666f8151a51ef96daeb8691459313d01730c014.tar.gz bun-0666f8151a51ef96daeb8691459313d01730c014.tar.zst bun-0666f8151a51ef96daeb8691459313d01730c014.zip |
more utf8
Former-commit-id: e1f996e1b8cf6fac650c075a812538c1cc620f99
Diffstat (limited to 'src/js_lexer.zig')
-rw-r--r-- | src/js_lexer.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/js_lexer.zig b/src/js_lexer.zig index fa161f2cd..ac575a062 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -279,7 +279,6 @@ pub const Lexer = struct { lexer.string_literal_slice = lexer.source.contents[lexer.start + 1 .. lexer.end - suffixLen]; lexer.string_literal_is_ascii = !needs_slow_path; lexer.string_literal_buffer.shrinkRetainingCapacity(0); - lexer.string_literal.len = lexer.string_literal_slice.len; if (needs_slow_path) { lexer.string_literal_buffer.ensureTotalCapacity(lexer.string_literal_slice.len) catch unreachable; var slice = lexer.string_literal_buffer.allocatedSlice(); @@ -1174,6 +1173,14 @@ pub const Lexer = struct { return lex; } + pub fn toEString(lexer: *LexerType) js_ast.E.String { + if (lexer.string_literal_is_ascii) { + return js_ast.E.String{ .utf8 = lexer.string_literal_slice }; + } else { + return js_ast.E.String{ .value = lexer.stringLiteralUTF16() }; + } + } + pub fn scanRegExp(lexer: *LexerType) !void { while (true) { switch (lexer.code_point) { |