Function writeSleb128 [src]
Write a single signed integer as LEB128 to the given writer.
Prototype
pub fn writeSleb128(w: *Writer, value: anytype) Error!void
Parameters
w: *Writer
Possible Errors
See the Writer
implementation for detailed diagnostics.
Source
pub fn writeSleb128(w: *Writer, value: anytype) Error!void {
try w.writeLeb128(switch (@typeInfo(@TypeOf(value))) {
.comptime_int => @as(std.math.IntFittingRange(@min(value, -1), @max(0, value)), value),
.int => |value_info| switch (value_info.signedness) {
.signed => value,
.unsigned => @as(@Type(.{ .int = .{ .signedness = .signed, .bits = value_info.bits + 1 } }), value),
},
else => comptime unreachable,
});
}