Files
avo/internal/gen/gen.go
Michael McLoughlin 59e6af7d36 wip
2018-11-21 13:02:18 -06:00

35 lines
545 B
Go

package gen
import (
"fmt"
"io"
"github.com/mmcloughlin/avo/internal/inst"
)
type Interface interface {
Generate(io.Writer, []*inst.Instruction) error
}
type Func func(io.Writer, []*inst.Instruction) error
func (f Func) Generate(w io.Writer, is []*inst.Instruction) error {
return f(w, is)
}
type printer struct {
w io.Writer
err error
}
func (p *printer) printf(format string, args ...interface{}) {
if p.err != nil {
return
}
_, p.err = fmt.Fprintf(p.w, format, args...)
}
func (p *printer) Err() error {
return p.err
}