diff --git a/src/main.zig b/src/main.zig index cd0c05632289ba89802c4d7f8ec40263555aa09f..332d4ad8200cc7b0b6a38028b961923c7404ca3e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -6,12 +6,19 @@ 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. +/// @param fast_exit - If true, exits the process immediately with code 1. +/// @returns 1 to indicate error condition. fn handleOutOfMemory(fast_exit: bool) u8 { std.debug.print("out of memory\n", .{}); if (fast_exit) process.exit(1); return 1; } +/// Dispatches error handling based on error type. +/// @param fast_exit - If true, exits the process immediately on fatal errors. +/// @param er - The error to handle. +/// @returns 1 if error was handled, otherwise 0. fn handleError(fast_exit: bool, er: anyerror) u8 { return switch (er) { error.OutOfMemory => handleOutOfMemory(fast_exit),