Skip to content

Commit

Permalink
all: remove support for stage1
Browse files Browse the repository at this point in the history
With almost all tests/examples working on all platforms now with the new compiler,
hexops/mach#180, it's time to remove stage1 support.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
  • Loading branch information
slimsag committed Sep 10, 2022
1 parent 00df04e commit 321a994
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,8 @@ export fn wasmCallFunction(id: *anyopaque, args: u32, len: u32, captures: [*]Val
captures_slice.len = captures_len;

const obj = Object{ .ref = args };
if (builtin.zig_backend == .stage1) {
obj.set("return_value", functions.items[@ptrToInt(id) - 1](obj, len, captures_slice));
} else {
var func = @ptrCast(FunType, @alignCast(std.meta.alignment(FunType), id));
obj.set("return_value", func(obj, len, captures_slice));
}
var func = @ptrCast(FunType, @alignCast(std.meta.alignment(FunType), id));
obj.set("return_value", func(obj, len, captures_slice));
}

pub fn global() Object {
Expand Down Expand Up @@ -248,18 +244,9 @@ pub fn createUndefined() Value {
return .{ .tag = .undef, .val = undefined };
}

const FunType = if (@import("builtin").zig_backend == .stage1)
fn (args: Object, args_len: u32, captures: []Value) Value
else
*const fn (args: Object, args_len: u32, captures: []Value) Value;

var functions: std.ArrayListUnmanaged(FunType) = .{};
const FunType = *const fn (args: Object, args_len: u32, captures: []Value) Value;

pub fn createFunction(fun: FunType, captures: []Value) Function {
if (builtin.zig_backend == .stage1) {
functions.append(std.heap.page_allocator, fun) catch unreachable;
return .{ .ref = js.zigCreateFunction(@intToPtr(*anyopaque, functions.items.len), captures.ptr, @intCast(u32, captures.len)) };
}
return .{ .ref = js.zigCreateFunction(fun, captures.ptr, captures.len) };
}

Expand Down

0 comments on commit 321a994

Please sign in to comment.