diff options
author | 2021-05-26 18:15:49 -0700 | |
---|---|---|
committer | 2021-05-26 18:15:49 -0700 | |
commit | 6e46883ca7b901d56e4bbdb24fa900bbdb732379 (patch) | |
tree | 129402dc450ab7f75d5e8ccad27f760daa7255ba /src | |
parent | 6a69c971d46bf4cc59221c8adcd41d12b04e5a14 (diff) | |
download | bun-6e46883ca7b901d56e4bbdb24fa900bbdb732379.tar.gz bun-6e46883ca7b901d56e4bbdb24fa900bbdb732379.tar.zst bun-6e46883ca7b901d56e4bbdb24fa900bbdb732379.zip |
Use a normal string to represent template literal content for easier UTF8/UTF16 mixing
Former-commit-id: 7337f27a7ebdae35232de4d5e52f1a0d711ff998
Diffstat (limited to 'src')
-rw-r--r-- | src/js_ast.zig | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig index 7c92a9f74..7c94b9872 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -912,6 +912,14 @@ pub const E = struct { return s.utf8.len > 0; } + pub fn isBlank(s: *const String) bool { + return std.math.max(s.utf8.len, s.value.len) == 0; + } + + pub fn isPresent(s: *const String) bool { + return std.math.max(s.utf8.len, s.value.len) > 0; + } + pub fn eql(s: *const String, comptime _t: type, other: anytype) bool { if (s.isUTF8()) { switch (_t) { @@ -981,14 +989,12 @@ pub const E = struct { pub const TemplatePart = struct { value: ExprNodeIndex, tail_loc: logger.Loc, - tail: JavascriptString, - tail_raw: string, + tail: E.String, }; pub const Template = struct { tag: ?ExprNodeIndex = null, - head: JavascriptString, - head_raw: string, // This is only filled out for tagged template literals + head: E.String, parts: []TemplatePart = &([_]TemplatePart{}), legacy_octal_loc: logger.Loc = logger.Loc.Empty, }; @@ -2985,7 +2991,7 @@ pub const Ast = struct { }; } - pub fn toJSON(self: *Ast, allocator: *std.mem.Allocator, stream: anytype) !void { + pub fn toJSON(self: *const Ast, allocator: *std.mem.Allocator, stream: anytype) !void { const opts = std.json.StringifyOptions{ .whitespace = std.json.StringifyOptions.Whitespace{ .separator = true, } }; |