zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit f8d0501f50985b2953dc0eec6a555e7bc91f7798 (tree)
parent 81d8fe7558cdae829c30cba3c92dfc373336929c
Author: Luuk de Gram <Luukdegram@users.noreply.github.com>
Date:   Thu, 20 May 2021 16:21:11 +0200

Also support multi-prong branches

Diffstat:
Msrc/codegen/wasm.zig | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig @@ -862,6 +862,14 @@ pub const Context = struct { const lhs = self.resolveInst(inst.lhs); const rhs = self.resolveInst(inst.rhs); + // it's possible for both lhs and/or rhs to return an offset as well, + // in which case we return the first offset occurance we find. + const offset = blk: { + if (lhs == .code_offset) break :blk lhs.code_offset; + if (rhs == .code_offset) break :blk rhs.code_offset; + break :blk self.code.items.len; + }; + try self.emitWValue(lhs); try self.emitWValue(rhs); @@ -871,7 +879,7 @@ pub const Context = struct { .signedness = if (inst.base.ty.isSignedInt()) .signed else .unsigned, }); try self.code.append(wasm.opcode(opcode)); - return .none; + return WValue{ .code_offset = offset }; } fn emitConstant(self: *Context, src: LazySrcLoc, value: Value, ty: Type) InnerError!void {