std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
This commit is contained in:
@@ -493,7 +493,7 @@ pub fn WriteStream(
|
||||
if (build_mode_has_safety) assert(self.raw_streaming_mode == .none);
|
||||
const T = @TypeOf(value);
|
||||
switch (@typeInfo(T)) {
|
||||
.Int => {
|
||||
.int => {
|
||||
try self.valueStart();
|
||||
if (self.options.emit_nonportable_numbers_as_strings and
|
||||
(value <= -(1 << 53) or value >= (1 << 53)))
|
||||
@@ -505,10 +505,10 @@ pub fn WriteStream(
|
||||
self.valueDone();
|
||||
return;
|
||||
},
|
||||
.ComptimeInt => {
|
||||
.comptime_int => {
|
||||
return self.write(@as(std.math.IntFittingRange(value, value), value));
|
||||
},
|
||||
.Float, .ComptimeFloat => {
|
||||
.float, .comptime_float => {
|
||||
if (@as(f64, @floatCast(value)) == value) {
|
||||
try self.valueStart();
|
||||
try self.stream.print("{}", .{@as(f64, @floatCast(value))});
|
||||
@@ -521,38 +521,38 @@ pub fn WriteStream(
|
||||
return;
|
||||
},
|
||||
|
||||
.Bool => {
|
||||
.bool => {
|
||||
try self.valueStart();
|
||||
try self.stream.writeAll(if (value) "true" else "false");
|
||||
self.valueDone();
|
||||
return;
|
||||
},
|
||||
.Null => {
|
||||
.null => {
|
||||
try self.valueStart();
|
||||
try self.stream.writeAll("null");
|
||||
self.valueDone();
|
||||
return;
|
||||
},
|
||||
.Optional => {
|
||||
.optional => {
|
||||
if (value) |payload| {
|
||||
return try self.write(payload);
|
||||
} else {
|
||||
return try self.write(null);
|
||||
}
|
||||
},
|
||||
.Enum, .EnumLiteral => {
|
||||
.@"enum", .enum_literal => {
|
||||
if (std.meta.hasFn(T, "jsonStringify")) {
|
||||
return value.jsonStringify(self);
|
||||
}
|
||||
|
||||
return self.stringValue(@tagName(value));
|
||||
},
|
||||
.Union => {
|
||||
.@"union" => {
|
||||
if (std.meta.hasFn(T, "jsonStringify")) {
|
||||
return value.jsonStringify(self);
|
||||
}
|
||||
|
||||
const info = @typeInfo(T).Union;
|
||||
const info = @typeInfo(T).@"union";
|
||||
if (info.tag_type) |UnionTagType| {
|
||||
try self.beginObject();
|
||||
inline for (info.fields) |u_field| {
|
||||
@@ -576,7 +576,7 @@ pub fn WriteStream(
|
||||
@compileError("Unable to stringify untagged union '" ++ @typeName(T) ++ "'");
|
||||
}
|
||||
},
|
||||
.Struct => |S| {
|
||||
.@"struct" => |S| {
|
||||
if (std.meta.hasFn(T, "jsonStringify")) {
|
||||
return value.jsonStringify(self);
|
||||
}
|
||||
@@ -593,7 +593,7 @@ pub fn WriteStream(
|
||||
var emit_field = true;
|
||||
|
||||
// don't include optional fields that are null when emit_null_optional_fields is set to false
|
||||
if (@typeInfo(Field.type) == .Optional) {
|
||||
if (@typeInfo(Field.type) == .optional) {
|
||||
if (self.options.emit_null_optional_fields == false) {
|
||||
if (@field(value, Field.name) == null) {
|
||||
emit_field = false;
|
||||
@@ -615,10 +615,10 @@ pub fn WriteStream(
|
||||
}
|
||||
return;
|
||||
},
|
||||
.ErrorSet => return self.stringValue(@errorName(value)),
|
||||
.Pointer => |ptr_info| switch (ptr_info.size) {
|
||||
.error_set => return self.stringValue(@errorName(value)),
|
||||
.pointer => |ptr_info| switch (ptr_info.size) {
|
||||
.One => switch (@typeInfo(ptr_info.child)) {
|
||||
.Array => {
|
||||
.array => {
|
||||
// Coerce `*[N]T` to `[]const T`.
|
||||
const Slice = []const std.meta.Elem(ptr_info.child);
|
||||
return self.write(@as(Slice, value));
|
||||
@@ -648,11 +648,11 @@ pub fn WriteStream(
|
||||
},
|
||||
else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
|
||||
},
|
||||
.Array => {
|
||||
.array => {
|
||||
// Coerce `[N]T` to `*const [N]T` (and then to `[]const T`).
|
||||
return self.write(&value);
|
||||
},
|
||||
.Vector => |info| {
|
||||
.vector => |info| {
|
||||
const array: [info.len]info.child = value;
|
||||
return self.write(&array);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user