mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Merge branch 'master' into comment-in-array
This commit is contained in:
commit
22194efe68
@ -998,7 +998,7 @@ fn printCharValues(out: var, bytes: []const u8) !void {
|
||||
|
||||
fn printUnderstandableChar(out: var, char: u8) !void {
|
||||
if (!std.ascii.isPrint(char) or char == ' ') {
|
||||
std.fmt.format(out.context, anyerror, out.output, "\\x{X2}", char) catch {};
|
||||
std.fmt.format(out.context, anyerror, out.output, "\\x{X:2}", char) catch {};
|
||||
} else {
|
||||
try out.write("'");
|
||||
try out.write([_]u8{printable_char_tab[char]});
|
||||
|
||||
10
src/ir.cpp
10
src/ir.cpp
@ -23280,10 +23280,16 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr,
|
||||
BuiltinFnId fop = source_instr->op;
|
||||
unsigned bits;
|
||||
|
||||
if (float_type->id == ZigTypeIdComptimeFloat) {
|
||||
switch (float_type->id) {
|
||||
case ZigTypeIdComptimeFloat:
|
||||
bits = 128;
|
||||
} else if (float_type->id == ZigTypeIdFloat)
|
||||
break;
|
||||
case ZigTypeIdFloat:
|
||||
bits = float_type->data.floating.bit_count;
|
||||
break;
|
||||
default:
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
switch (bits) {
|
||||
case 16: {
|
||||
|
||||
762
std/fmt.zig
762
std/fmt.zig
File diff suppressed because it is too large
Load Diff
@ -519,6 +519,7 @@ pub const Int = struct {
|
||||
pub fn format(
|
||||
self: Int,
|
||||
comptime fmt: []const u8,
|
||||
comptime options: std.fmt.FormatOptions,
|
||||
context: var,
|
||||
comptime FmtError: type,
|
||||
output: fn (@typeOf(context), []const u8) FmtError!void,
|
||||
|
||||
@ -167,7 +167,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
|
||||
|
||||
const allocator = builder.allocator;
|
||||
for (builder.top_level_steps.toSliceConst()) |top_level_step| {
|
||||
try out_stream.print(" {s22} {}\n", top_level_step.step.name, top_level_step.description);
|
||||
try out_stream.print(" {s:22} {}\n", top_level_step.step.name, top_level_step.description);
|
||||
}
|
||||
|
||||
try out_stream.write(
|
||||
@ -188,7 +188,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
|
||||
for (builder.available_options_list.toSliceConst()) |option| {
|
||||
const name = try fmt.allocPrint(allocator, " -D{}=[{}]", option.name, Builder.typeIdName(option.type_id));
|
||||
defer allocator.free(name);
|
||||
try out_stream.print("{s24} {}\n", name, option.description);
|
||||
try out_stream.print("{s:24} {}\n", name, option.description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -405,15 +405,15 @@ const use_thumb_1 = usesThumb1(builtin.arch);
|
||||
|
||||
fn usesThumb1(arch: builtin.Arch) bool {
|
||||
return switch (arch) {
|
||||
.arm => switch (arch.arm) {
|
||||
.arm => |sub_arch| switch (sub_arch) {
|
||||
.v6m => true,
|
||||
else => false,
|
||||
},
|
||||
.armeb => switch (arch.armeb) {
|
||||
.armeb => |sub_arch| switch (sub_arch) {
|
||||
.v6m => true,
|
||||
else => false,
|
||||
},
|
||||
.thumb => switch (arch.thumb) {
|
||||
.thumb => |sub_arch| switch (sub_arch) {
|
||||
.v5,
|
||||
.v5te,
|
||||
.v4t,
|
||||
@ -423,7 +423,7 @@ fn usesThumb1(arch: builtin.Arch) bool {
|
||||
=> true,
|
||||
else => false,
|
||||
},
|
||||
.thumbeb => switch (arch.thumbeb) {
|
||||
.thumbeb => |sub_arch| switch (sub_arch) {
|
||||
.v5,
|
||||
.v5te,
|
||||
.v4t,
|
||||
@ -471,6 +471,22 @@ test "usesThumb1" {
|
||||
//etc.
|
||||
}
|
||||
|
||||
const use_thumb_1_pre_armv6 = usesThumb1PreArmv6(builtin.arch);
|
||||
|
||||
fn usesThumb1PreArmv6(arch: builtin.Arch) bool {
|
||||
return switch (arch) {
|
||||
.thumb => |sub_arch| switch (sub_arch) {
|
||||
.v5, .v5te, .v4t => true,
|
||||
else => false,
|
||||
},
|
||||
.thumbeb => |sub_arch| switch (sub_arch) {
|
||||
.v5, .v5te, .v4t => true,
|
||||
else => false,
|
||||
},
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
|
||||
nakedcc fn __aeabi_memcpy() noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1) {
|
||||
@ -505,7 +521,16 @@ nakedcc fn __aeabi_memmove() noreturn {
|
||||
|
||||
nakedcc fn __aeabi_memset() noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1) {
|
||||
if (use_thumb_1_pre_armv6) {
|
||||
asm volatile (
|
||||
\\ eors r1, r2
|
||||
\\ eors r2, r1
|
||||
\\ eors r1, r2
|
||||
\\ push {r7, lr}
|
||||
\\ b memset
|
||||
\\ pop {r7, pc}
|
||||
);
|
||||
} else if (use_thumb_1) {
|
||||
asm volatile (
|
||||
\\ mov r3, r1
|
||||
\\ mov r1, r2
|
||||
@ -527,7 +552,15 @@ nakedcc fn __aeabi_memset() noreturn {
|
||||
|
||||
nakedcc fn __aeabi_memclr() noreturn {
|
||||
@setRuntimeSafety(false);
|
||||
if (use_thumb_1) {
|
||||
if (use_thumb_1_pre_armv6) {
|
||||
asm volatile (
|
||||
\\ adds r2, r1, #0
|
||||
\\ movs r1, #0
|
||||
\\ push {r7, lr}
|
||||
\\ bl memset
|
||||
\\ pop {r7, pc}
|
||||
);
|
||||
} else if (use_thumb_1) {
|
||||
asm volatile (
|
||||
\\ mov r2, r1
|
||||
\\ movs r1, #0
|
||||
|
||||
@ -2833,8 +2833,8 @@ fn parseIf(arena: *Allocator, it: *TokenIterator, tree: *Tree, bodyParseFn: Node
|
||||
|
||||
const else_token = eatToken(it, .Keyword_else) orelse return node;
|
||||
const payload = try parsePayload(arena, it, tree);
|
||||
const else_expr = try expectNode(arena, it, tree, parseExpr, AstError{
|
||||
.ExpectedExpr = AstError.ExpectedExpr{ .token = it.index },
|
||||
const else_expr = try expectNode(arena, it, tree, bodyParseFn, AstError{
|
||||
.InvalidToken = AstError.InvalidToken{ .token = it.index },
|
||||
});
|
||||
const else_node = try arena.create(Node.Else);
|
||||
else_node.* = Node.Else{
|
||||
|
||||
@ -2234,6 +2234,18 @@ test "zig fmt: multiline string in array" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: if type expr" {
|
||||
try testCanonical(
|
||||
\\const mycond = true;
|
||||
\\pub fn foo() if (mycond) i32 else void {
|
||||
\\ if (mycond) {
|
||||
\\ return 42;
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: line comment in array" {
|
||||
try testTransform(
|
||||
\\test "a" {
|
||||
|
||||
@ -122,7 +122,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
|
||||
\\
|
||||
\\pub fn main() void {
|
||||
\\ const stdout = &(io.getStdOut() catch unreachable).outStream().stream;
|
||||
\\ stdout.print("Hello, world!\n{d4} {x3} {c}\n", u32(12), u16(0x12), u8('a')) catch unreachable;
|
||||
\\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", u32(12), u16(0x12), u8('a')) catch unreachable;
|
||||
\\}
|
||||
, "Hello, world!\n0012 012 a\n");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user