diff --git a/bootstrap/main.zig b/bootstrap/main.zig index da21ed7..7fb0578 100644 --- a/bootstrap/main.zig +++ b/bootstrap/main.zig @@ -22,29 +22,6 @@ fn todo() noreturn { } var my_allocator = PageAllocator{}; -// pub export fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) callconv(.C) c_int { -// _ = c_envp; // autofix -// // const argument_count: usize = @intCast(c_argc); -// // const argument_values: [*][*:0]u8 = @ptrCast(c_argv); -// if (entry_point(arguments)) |_| { -// return 0; -// } else |err| { -// const print_stack_trace = @import("configuration").print_stack_trace; -// switch (print_stack_trace) { -// true => if (@errorReturnTrace()) |trace| { -// std.debug.dumpStackTrace(trace.*); -// }, -// false => { -// const error_name: []const u8 = @errorName(err); -// Compilation.write(.panic, "Error: ") catch {}; -// Compilation.write(.panic, error_name) catch {}; -// Compilation.write(.panic, "\n") catch {}; -// }, -// } -// -// return 1; -// } -// } pub fn main() !void { var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); diff --git a/build/test_runner.zig b/build/test_runner.zig index f753297..8e422b6 100644 --- a/build/test_runner.zig +++ b/build/test_runner.zig @@ -515,7 +515,18 @@ fn compile_self_hosted(allocator: Allocator, args: struct { .Unknown => error.unknown, }; - _ = try compilation_result; + + + _ = compilation_result catch |err| { + std.debug.print("Compiling the self-hosted compiler failed!\n", .{}); + if (compile_run.stdout.len > 0) { + std.debug.print("{s}\n", .{compile_run.stdout}); + } + if (compile_run.stderr.len > 0) { + std.debug.print("{s}\n", .{compile_run.stderr}); + } + return err; + }; } fn run_test_suite(allocator: Allocator, args: struct { diff --git a/lib/std/std.nat b/lib/std/std.nat index 23010cd..4aa62fd 100644 --- a/lib/std/std.nat +++ b/lib/std/std.nat @@ -156,6 +156,15 @@ const copy_bytes = fn(destination: []u8, source: []const u8) void { } } +const c_len = fn (string: [&:0]const u8) usize { + var i: usize = 0; + while (string[i] != 0) { + i += 1; + } + + return i; +} + const Target = struct { cpu: builtin.Cpu, os: builtin.Os, diff --git a/src/main.nat b/src/main.nat index f4515eb..a41df8d 100644 --- a/src/main.nat +++ b/src/main.nat @@ -1,4 +1,17 @@ const std = #import("std"); +const Arena = std.Arena; const main = fn() *!void { + const arena = try Arena.allocate(std.megabytes(64)); + const argument_count = std.start.argument_count; + const argument_values = std.start.argument_values; + const arguments = argument_values[0..argument_count]; + + for (arguments) |c_argument| { + const argument_len = std.c_len(c_argument); + const argument = c_argument[0..argument_len]; + std.print("Argument: "); + std.print(argument); + std.print("\n"); + } }