all: upgrade golangci-lint and formatters (#240)

This commit is contained in:
Michael McLoughlin
2022-03-27 15:31:26 -07:00
committed by GitHub
parent 553930530f
commit 72b8db9c80
24 changed files with 179 additions and 118 deletions

View File

@@ -187,11 +187,17 @@ func (t *Table) SuffixesTypeName() string {
// SuffixesConst returns the constant for a list of suffixes. Suffixes is a
// generated array type, so the list is a value not slice type.
func (t *Table) SuffixesConst(suffixes inst.Suffixes) string {
return t.SuffixesTypeName() + t.SuffixesList(suffixes)
}
// SuffixesList returns the constant literal for a list of suffixes, type name
// not included. Use SuffxesConst if the type is required.
func (t *Table) SuffixesList(suffixes inst.Suffixes) string {
var parts []string
for _, suffix := range suffixes {
parts = append(parts, t.SuffixConst(suffix))
}
return t.SuffixesTypeName() + "{" + strings.Join(parts, ", ") + "}"
return "{" + strings.Join(parts, ", ") + "}"
}
// SuffixesClass returns the enumeration representing all suffixes classes.

View File

@@ -6,10 +6,9 @@ import (
"strings"
"github.com/mmcloughlin/avo/internal/api"
"github.com/mmcloughlin/avo/internal/inst"
"github.com/mmcloughlin/avo/internal/prnt"
"github.com/mmcloughlin/avo/printer"
"github.com/mmcloughlin/avo/internal/inst"
)
type ctorstest struct {

View File

@@ -134,7 +134,7 @@ func (t *optab) suffixesType(is []inst.Instruction) {
var entries []string
for _, class := range inst.SuffixesClasses(is) {
for _, suffixes := range class {
entry := fmt.Sprintf("%s: %#v", t.table.SuffixesConst(suffixes), suffixes.Strings())
entry := fmt.Sprintf("%s: %s", t.table.SuffixesList(suffixes), stringsliteral(suffixes.Strings()))
entries = append(entries, entry)
}
}
@@ -177,7 +177,7 @@ func (t *optab) isasEnum(is []inst.Instruction) {
// Mapping method to produce the list of ISAs.
lists := map[string]string{}
for _, isas := range inst.ISACombinations(is) {
lists[api.ISAsIdentifier(isas)] = fmt.Sprintf("%#v", isas)
lists[api.ISAsIdentifier(isas)] = stringsliteral(isas)
}
t.mapping(e, "List", "[]string", "nil", lists)
}
@@ -286,3 +286,14 @@ func (t *optab) stringmethod(e *Enum) {
}
t.mapping(e, "String", "string", `""`, s)
}
func stringsliteral(ss []string) string {
if ss == nil {
return "nil"
}
var quoted []string
for _, s := range ss {
quoted = append(quoted, strconv.Quote(s))
}
return "{" + strings.Join(quoted, ", ") + "}"
}