From dd49eca34274cd2396cbe06a199fe8db9e8faf79 Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Sun, 28 Nov 2021 20:25:33 +0100 Subject: wasm: Implement 'zig test' - This implements the required codegen for decl types such as pointers, arrays, structs and more. - Wasm's start function can now use both a 'u8' and 'void' as return type. This will help us with writing tests using the stage2 testing backend. (Until all tests of behavioural tests pass). - Now correctly generates relocations for function pointers. - Also implements unwrapping error union error, as well as return pointers. --- lib/std/start.zig | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/std/start.zig') diff --git a/lib/std/start.zig b/lib/std/start.zig index 39f0fd3525..ed4b4fc3c8 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -101,8 +101,19 @@ fn callMain2() noreturn { } fn wasmMain2() u8 { - root.main(); - return 0; + switch (@typeInfo(@typeInfo(@TypeOf(root.main)).Fn.return_type.?)) { + .Void => { + root.main(); + return 0; + }, + .Int => |info| { + if (info.bits != 8 or info.signedness == .signed) { + @compileError(bad_main_ret); + } + return root.main(); + }, + else => @compileError("Bad return type main"), + } } fn wWinMainCRTStartup2() callconv(.C) noreturn { -- cgit v1.2.3