printing: commit some refactors (probably broken)

This commit is contained in:
Michael McLoughlin
2018-12-11 00:18:22 -08:00
parent 4dc909a81e
commit c882e52510
21 changed files with 398 additions and 222 deletions

View File

@@ -2,13 +2,9 @@ package build
import (
"errors"
"io"
"log"
"github.com/mmcloughlin/avo/gotypes"
"github.com/mmcloughlin/avo/pass"
"github.com/mmcloughlin/avo"
"github.com/mmcloughlin/avo/gotypes"
"github.com/mmcloughlin/avo/reg"
)
@@ -73,28 +69,3 @@ func (c *Context) AddErrorMessage(msg string) {
func (c *Context) Result() (*avo.File, []error) {
return c.file, c.errs
}
func (c *Context) Main(wout, werr io.Writer) int {
diag := log.New(werr, "", 0)
f, errs := c.Result()
if errs != nil {
for _, err := range errs {
diag.Println(err)
}
return 1
}
if err := pass.Compile.Execute(f); err != nil {
diag.Println(err)
return 1
}
p := avo.NewGoPrinter(wout)
if err := p.Print(f); err != nil {
diag.Println(err)
return 1
}
return 0
}