printer: constraints formatting (#209)

Uses `buildtag.Format` to format constraints in the assembly and stub file
printers. This will ensure `// + build` and `//go:build` syntax are used
consistent with the current Go version.

Updates #183
This commit is contained in:
Michael McLoughlin
2021-10-29 01:08:02 -07:00
committed by GitHub
parent 55d98ccf77
commit 79bee1a316
4 changed files with 59 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"strconv"
"strings"
"github.com/mmcloughlin/avo/buildtags"
"github.com/mmcloughlin/avo/internal/prnt"
"github.com/mmcloughlin/avo/ir"
"github.com/mmcloughlin/avo/operand"
@@ -44,8 +45,12 @@ func (p *goasm) header(f *ir.File) {
p.Comment(p.cfg.GeneratedWarning())
if len(f.Constraints) > 0 {
constraints, err := buildtags.Format(f.Constraints)
if err != nil {
p.AddError(err)
}
p.NL()
p.Printf(f.Constraints.GoString())
p.Printf(constraints)
}
if len(f.Includes) > 0 {