feat(go): add format-symbols command

This commit is contained in:
phaneron 2025-04-17 16:26:20 -04:00
parent b8b0b5076f
commit 0eec0219f9
7 changed files with 269 additions and 142 deletions

View file

@ -1,7 +1,9 @@
package symfile
import (
"fmt"
"io"
"strings"
)
// What kind of Entry is this?
@ -36,6 +38,21 @@ type Entry struct {
DataType string
}
func (entry *Entry) String() string {
var b strings.Builder
fmt.Fprintf(&b, "%s %08X %c", entry.Name, entry.StartAddress, entry.Kind)
if entry.EndAddress != 0 {
fmt.Fprintf(&b, " end=%08X", entry.EndAddress)
}
if entry.DataType != "" {
fmt.Fprintf(&b, " type=\"%s\"", entry.DataType)
}
if entry.Comment != "" {
fmt.Fprintf(&b, " ; %s", entry.Comment)
}
return b.String()
}
type Table interface {
Insert(entry *Entry) (err error)
}