summaryrefslogtreecommitdiff
path: root/src/zisp/value/array.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/zisp/value/array.zig')
-rw-r--r--src/zisp/value/array.zig20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/zisp/value/array.zig b/src/zisp/value/array.zig
index 6be3c9c..ad04ce2 100644
--- a/src/zisp/value/array.zig
+++ b/src/zisp/value/array.zig
@@ -81,22 +81,24 @@ pub const ArrayHeader = packed struct(u64) {
},
},
- fn bufU64(self: *@This()) [*]u64 {
+ const Self = @This();
+
+ fn bufU64(self: *Self) [*]u64 {
return @ptrCast(self);
}
- fn bufContent(self: *@This()) [*]u8 {
+ fn bufContent(self: *Self) [*]u8 {
std.debug.assert(!self.is_ptr);
return @ptrCast(self.bufU64() + 1);
}
- fn bufPointer(self: *@This()) [*]u8 {
+ fn bufPointer(self: *Self) [*]u8 {
std.debug.assert(self.is_ptr);
std.debug.assert(self.len_or_ptr == 0);
return @ptrFromInt(self.bufU64()[1]);
}
- fn eltSize(self: *@This()) u16 {
+ fn eltSize(self: *Self) u16 {
std.debug.assert(!self.is_ptr);
return switch (self.type) {
.str => 1,
@@ -104,18 +106,18 @@ pub const ArrayHeader = packed struct(u64) {
};
}
- fn size(self: *@This()) usize {
+ fn size(self: *Self) usize {
std.debug.assert(!self.is_ptr);
return self.len_or_ptr * self.eltSize();
}
- fn arrPointer(self: *@This()) ?ArrayPtr {
+ fn arrPointer(self: *Self) ?ArrayPtr {
std.debug.assert(self.is_ptr);
const p = self.len_or_ptr;
return if (p != 0) @ptrFromInt(p) else null;
}
- fn sliceInfo(self: *@This()) [2]u64 {
+ fn sliceInfo(self: *Self) [2]u64 {
std.debug.assert(self.is_slice);
const ptr = self.len_or_ptr;
const buf = self.bufU64();
@@ -126,7 +128,7 @@ pub const ArrayHeader = packed struct(u64) {
}
}
- pub fn bufU8(self: *@This()) [*]u8 {
+ pub fn bufU8(self: *Self) [*]u8 {
if (self.is_ptr) {
if (self.arrPointer()) |a| {
return a.bufContent();
@@ -138,7 +140,7 @@ pub const ArrayHeader = packed struct(u64) {
}
}
- pub fn str(self: *@This()) []const u8 {
+ pub fn str(self: *Self) []const u8 {
if (self.is_slice) {
const buf = self.bufU8();
const start, const end = self.sliceInfo();