github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/wazeroir/format.go (about) 1 package wazeroir 2 3 import ( 4 "bytes" 5 ) 6 7 const EntrypointLabel = ".entrypoint" 8 9 func Format(ops []UnionOperation) string { 10 buf := bytes.NewBuffer(nil) 11 12 _, _ = buf.WriteString(EntrypointLabel + "\n") 13 for i := range ops { 14 op := &ops[i] 15 str := op.String() 16 isLabel := op.Kind == OperationKindLabel 17 if !isLabel { 18 const indent = "\t" 19 str = indent + str 20 } 21 _, _ = buf.WriteString(str + "\n") 22 } 23 return buf.String() 24 }