wip: adding instruction inputs and outputs

This commit is contained in:
Michael McLoughlin
2018-12-02 17:57:12 -08:00
parent f18271ada5
commit 82b31fa0da
15 changed files with 18157 additions and 7650 deletions

View File

@@ -50,18 +50,26 @@ func GoFmt(i Interface) Interface {
})
}
type printer struct {
type generator struct {
buf bytes.Buffer
err error
}
func (p *printer) Printf(format string, args ...interface{}) {
if p.err != nil {
func (g *generator) Printf(format string, args ...interface{}) {
if g.err != nil {
return
}
_, p.err = fmt.Fprintf(&p.buf, format, args...)
if _, err := fmt.Fprintf(&g.buf, format, args...); err != nil {
g.AddError(err)
}
}
func (p *printer) Result() ([]byte, error) {
return p.buf.Bytes(), p.err
func (g *generator) AddError(err error) {
if err != nil && g.err == nil {
g.err = err
}
}
func (g *generator) Result() ([]byte, error) {
return g.buf.Bytes(), g.err
}