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

打印接口地址

上级 7e5593b3
......@@ -640,6 +640,8 @@ func (g *functionGenerator) genBuiltin(call *ssa.CallCommon) (insts []wat.Inst,
insts = append(insts, wat.NewInstCall("$runtime.waPrintRune"))
} else if avt.Equal(g.module.STRING) {
insts = append(insts, g.module.EmitPrintString(av)...)
} else if _, ok := avt.(*wir.Interface); ok {
insts = append(insts, g.module.EmitPrintInterface(av)...)
} else {
logger.Fatalf("Todo: print(%T)", avt)
}
......
......@@ -834,6 +834,13 @@ func (m *Module) EmitPrintString(v Value) (insts []wat.Inst) {
return
}
func (m *Module) EmitPrintInterface(v Value) (insts []wat.Inst) {
i := v.(*aInterface)
insts = append(insts, i.Extract("data").EmitPush()...)
insts = append(insts, wat.NewInstCall("$runtime.waPrintI32"))
return
}
func (m *Module) EmitStringValue(v Value) (insts []wat.Inst) {
s := v.(*aString)
insts = append(insts, s.Extract("data").EmitPush()...)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册