aboutsummaryrefslogtreecommitdiff
path: root/src/json_parser.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-12-28 00:51:22 -0800
committerGravatar GitHub <noreply@github.com> 2022-12-28 00:51:22 -0800
commitc0dd2841362b67fdb5ede262b19688004a4eb9a4 (patch)
treea3cd6b353c25c30d66489de61b394af7d5568fed /src/json_parser.zig
parent504972fa5deb92f2d0510d42f11b085351915a32 (diff)
downloadbun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.tar.gz
bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.tar.zst
bun-c0dd2841362b67fdb5ede262b19688004a4eb9a4.zip
Upgrade to latest Zig (#1610)
* @min and @max * builtins and some trivial ones * Most of them * more * more! * More Progress * wip * Update tagged_pointer.zig * Update http_client_async.zig * Most of the iterable dir changes * alright * Remove usages of deprecated formatters * :camera: * fmt * Update shimmer.zig * wip * wip * wip * progress * more * Latest * stuck on error * latest * workaround stage2 * wip * Update string_immutable.zig * wip * Migrate `Dirent` and `require("fs')` to use JSC<>Zig bindings * Fix build errors * Fixup most of the test failures * Fix `make headers` * Fix "outside package path" error * Fixup aligned alloc * Add missing file * linux * More linux fixes * use latest peechy * Fix transpiler test failure * Forgot about these * Fixup test failure * Update node-timers.test.ts * [node:htt] Fix `undefined is not an object` error Fixes https://github.com/oven-sh/bun/issues/1618 * Update http.exports.js * Make this test less flaky * fix hashes * Fix hex formatting and zls issues * Download zig version * Update Dockerfile * Update Dockerfile * Update uws * Update Dockerfile * Set llvm version * Update README.md * Update uws * Update Dockerfile * Update io_linux.zig * Update bun.zig * Log output * workaround strange @cInclude error * Make ffi tests better * Don't use cImport * Update c.zig * Update c-bindings.cpp * call setOutputDir * Update Dockerfile * Use a longer name * latest * Update serve.test.ts Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Veikka Tuominen <git@vexu.eu>
Diffstat (limited to 'src/json_parser.zig')
-rw-r--r--src/json_parser.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/json_parser.zig b/src/json_parser.zig
index de9203893..619590c0f 100644
--- a/src/json_parser.zig
+++ b/src/json_parser.zig
@@ -85,7 +85,7 @@ const HashMapPool = struct {
};
// This hack fixes using LLDB
-fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
+fn JSONLikeParser(comptime opts: js_lexer.JSONOptions) type {
return JSONLikeParser_(
opts.is_json,
opts.allow_comments,
@@ -98,13 +98,13 @@ fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
}
fn JSONLikeParser_(
- opts_is_json: bool,
- opts_allow_comments: bool,
- opts_allow_trailing_commas: bool,
- opts_ignore_leading_escape_sequences: bool,
- opts_ignore_trailing_escape_sequences: bool,
- opts_json_warn_duplicate_keys: bool,
- opts_was_originally_macro: bool,
+ comptime opts_is_json: bool,
+ comptime opts_allow_comments: bool,
+ comptime opts_allow_trailing_commas: bool,
+ comptime opts_ignore_leading_escape_sequences: bool,
+ comptime opts_ignore_trailing_escape_sequences: bool,
+ comptime opts_json_warn_duplicate_keys: bool,
+ comptime opts_was_originally_macro: bool,
) type {
const opts = js_lexer.JSONOptions{
.is_json = opts_is_json,
@@ -305,7 +305,7 @@ fn JSONLikeParser_(
if (comptime Environment.isDebug) {
std.io.getStdErr().writer().print("\nThis range: {d} - {d} \n{s}", .{
p.lexer.range().loc.start,
- p.lexer.range().end(),
+ p.lexer.range().end().start,
p.lexer.range().in(p.lexer.source.contents),
}) catch {};
@@ -467,7 +467,7 @@ pub const PackageJSONVersionChecker = struct {
// first one wins
if (key.data == .e_string and value.data == .e_string) {
if (!p.has_found_name and strings.eqlComptime(key.data.e_string.data, "name")) {
- const len = @minimum(
+ const len = @min(
value.data.e_string.data.len,
p.found_name_buf.len,
);
@@ -476,7 +476,7 @@ pub const PackageJSONVersionChecker = struct {
p.found_name = p.found_name_buf[0..len];
p.has_found_name = true;
} else if (!p.has_found_version and strings.eqlComptime(key.data.e_string.data, "version")) {
- const len = @minimum(
+ const len = @min(
value.data.e_string.data.len,
p.found_version_buf.len,
);
@@ -524,7 +524,7 @@ pub fn toAST(
comptime Type: type,
value: Type,
) anyerror!js_ast.Expr {
- const type_info: std.builtin.TypeInfo = @typeInfo(Type);
+ const type_info: std.builtin.Type = @typeInfo(Type);
switch (type_info) {
.Bool => {
@@ -592,13 +592,13 @@ pub fn toAST(
return Expr.init(js_ast.E.Array, js_ast.E.Array{ .items = exprs }, logger.Loc.Empty);
},
.Struct => |Struct| {
- const fields: []const std.builtin.TypeInfo.StructField = Struct.fields;
+ const fields: []const std.builtin.Type.StructField = Struct.fields;
var properties = try allocator.alloc(js_ast.G.Property, fields.len);
var property_i: usize = 0;
inline for (fields) |field| {
properties[property_i] = G.Property{
.key = Expr.init(E.String, E.String{ .data = field.name }, logger.Loc.Empty),
- .value = try toAST(allocator, field.field_type, @field(value, field.name)),
+ .value = try toAST(allocator, field.type, @field(value, field.name)),
};
property_i += 1;
}
@@ -644,7 +644,7 @@ pub fn toAST(
.fields = &.{
.{
.name = u_field.name,
- .field_type = @TypeOf(
+ .type = @TypeOf(
@field(value, u_field.name),
),
.is_comptime = false,