From 28981da3a4105172fd71c7ee9f7a371f0a13baba Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Fri, 27 Feb 2026 11:21:57 +0000 Subject: [PATCH] docs: add documentation for functions in Assembly.zig (PR #59604) --- src/backend/Assembly.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/backend/Assembly.zig b/src/backend/Assembly.zig index 914bffb..424a0c1 100644 --- a/src/backend/Assembly.zig +++ b/src/backend/Assembly.zig @@ -4,13 +4,31 @@ const Allocator = std.mem.Allocator; data: []const u8, text: []const u8, +/// Represents compiled assembly output containing data and text sections. +/// +/// **Fields:** +/// - `data`: The data section bytes (typically read-only data). +/// - `text`: The text section bytes (executable code). const Assembly = @This(); +/// Frees the memory allocated for the assembly data and text sections. +/// Uses the provided allocator to free both the data and text buffers. pub fn deinit(self: *const Assembly, gpa: Allocator) void { gpa.free(self.data); gpa.free(self.text); } +/// Writes both the data and text sections to the specified file using writev. +/// This function performs a vectored write operation, writing both sections +/// in a single system call for efficiency. +/// +/// **Parameters:** +/// - `self`: The Assembly instance containing data and text sections to write. +/// - `file`: The target file to write to. +/// +/// **Returns:** `void` on success, or an error if the write operation fails. +/// +/// **Errors:** Returns an error from `std.fs.File.writevAll` if the write fails. pub fn writeToAllFile(self: Assembly, file: std.fs.File) !void { var vec: [2]std.posix.iovec_const = .{ .{ .base = self.data.ptr, .len = self.data.len }, -- Gitee