提交 bc13e5ae 编写于 作者: 3 3dgen

修正接口互查

上级 6b88c184
......@@ -6,6 +6,7 @@ func main {
println("ok:", ok) // BUG: OK 始终返回 false
println("xerr:", xerr)
println("err.MyError():", err.MyError())
}
type myIface interface {
......
......@@ -167,17 +167,20 @@ func (v *aInterface) emitQueryInterface(destType ValueType, commaOk bool) (insts
insts = append(insts, wat.NewInstCall("$wa.runtime.getItab")) //itab
insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32"))
ifBlock := wat.NewInstIf(nil, nil, nil)
insts = append(insts, ifBlock)
ifs := wat.NewInstIf(nil, nil, nil)
insts = append(insts, ifs)
if commaOk {
ifBlock.Ret = append(ifBlock.Ret, wat.I32{})
ifBlock.True = append(ifBlock.True, wat.NewInstConst(wat.I32{}, "1"))
ifBlock.False = append(ifBlock.False, wat.NewInstConst(wat.I32{}, "0"))
ifs.Ret = []wat.ValueType{wat.I32{}, wat.I32{}}
ifs.True = append(ifs.True, v.Extract("eq").EmitPush()...) //eq
ifs.True = append(ifs.True, wat.NewInstConst(wat.I32{}, "1")) //ok:true
ifs.False = append(ifs.False, v.Extract("eq").EmitPush()...) //eq
ifs.False = append(ifs.False, wat.NewInstConst(wat.I32{}, "0")) //ok:false
} else {
ifBlock.False = append(ifBlock.False, wat.NewInstUnreachable())
ifs.False = append(ifs.False, wat.NewInstUnreachable())
insts = append(insts, v.Extract("eq").EmitPush()...) //eq
}
insts = append(insts, v.Extract("eq").EmitPush()...)
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册