Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com> Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
25 lines
429 B
Go
25 lines
429 B
Go
package wazeroir
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
const EntrypointLabel = ".entrypoint"
|
|
|
|
func Format(ops []UnionOperation) string {
|
|
buf := bytes.NewBuffer(nil)
|
|
|
|
_, _ = buf.WriteString(EntrypointLabel + "\n")
|
|
for i := range ops {
|
|
op := &ops[i]
|
|
str := op.String()
|
|
isLabel := op.Kind == OperationKindLabel
|
|
if !isLabel {
|
|
const indent = "\t"
|
|
str = indent + str
|
|
}
|
|
_, _ = buf.WriteString(str + "\n")
|
|
}
|
|
return buf.String()
|
|
}
|