diff options
| author | Luuk de Gram <luuk@degram.dev> | 2021-11-28 20:25:33 +0100 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2021-11-28 20:25:33 +0100 |
| commit | dd49eca34274cd2396cbe06a199fe8db9e8faf79 (patch) | |
| tree | 928ab49cdd2021db17a83f7bb5c5f3cb19e10bef /lib/std | |
| parent | 7226ad2670f267b4d90b84d0e104fbb1fa41fe49 (diff) | |
| download | zig-dd49eca34274cd2396cbe06a199fe8db9e8faf79.tar.gz zig-dd49eca34274cd2396cbe06a199fe8db9e8faf79.zip | |
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.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/start.zig | 15 |
1 files changed, 13 insertions, 2 deletions
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 { |
