diff --git a/src/main.zig b/src/main.zig index cd0c05632289ba89802c4d7f8ec40263555aa09f..b95ee14ee066b8b8ca25f112505fbc734248f4f5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -6,12 +6,18 @@ const Driver = aro.Driver; const Toolchain = aro.Toolchain; const assembly_backend = @import("assembly_backend"); +/// Handles out of memory error by printing a message and optionally exiting. +/// If fast_exit is true, terminates the process immediately; otherwise returns exit code 1. +/// Returns: Exit code (0 on successful handling with fast_exit=false, 1 otherwise) fn handleOutOfMemory(fast_exit: bool) u8 { std.debug.print("out of memory\n", .{}); if (fast_exit) process.exit(1); return 1; } +/// Handles generic errors by dispatching to appropriate handlers based on error type. +/// Currently handles OutOfMemory errors by calling handleOutOfMemory. +/// Returns: Exit code from the specific error handler (typically 0 on success, 1 on failure) fn handleError(fast_exit: bool, er: anyerror) u8 { return switch (er) { error.OutOfMemory => handleOutOfMemory(fast_exit),