提交 41c66eb1 编写于 作者: 3 3dgen

多参数打印加空格分隔

上级 6ce77e2a
func main() {
println("a:", 42)
str := "hello"
bytes := []byte(str)
for _, c := range bytes {
......
......@@ -594,13 +594,18 @@ func (g *functionGenerator) genBuiltin(call *ssa.CallCommon) (insts []wat.Inst,
}
case "print", "println":
for _, arg := range call.Args {
for i, arg := range call.Args {
av := g.getValue(arg).value
avt := av.Type()
if ut, ok := avt.(*wir.Dup); ok {
avt = ut.Base
}
if i > 0 {
insts = append(insts, wat.NewInstConst(wat.I32{}, "32"))
insts = append(insts, wat.NewInstCall("$runtime.waPrintRune"))
}
if avt.Equal(g.module.U8) || avt.Equal(g.module.I8) ||
avt.Equal(g.module.U16) || avt.Equal(g.module.I16) ||
avt.Equal(g.module.I32) || avt.Equal(g.module.U32) {
......@@ -620,7 +625,6 @@ func (g *functionGenerator) genBuiltin(call *ssa.CallCommon) (insts []wat.Inst,
} else {
logger.Fatalf("Todo: print(%T)", avt)
}
}
if call.Value.Name() == "println" {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册