Also support multi-prong branches

This commit is contained in:
Luuk de Gram 2021-05-20 16:21:11 +02:00
parent 81d8fe7558
commit f8d0501f50
No known key found for this signature in database
GPG Key ID: A002B174963DBB7D

View File

@ -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 {