diff --git a/format/elf/elf.go b/format/elf/elf.go index 5a972549..b7b5b4f5 100644 --- a/format/elf/elf.go +++ b/format/elf/elf.go @@ -353,11 +353,7 @@ func strIndexNull(idx int, s string) string { type strTable string func (m strTable) MapScalar(s scalar.S) (scalar.S, error) { - uv, ok := s.Actual.(uint64) - if !ok { - return s, nil - } - s.Sym = strIndexNull(int(uv), string(m)) + s.Sym = strIndexNull(int(s.ActualU()), string(m)) return s, nil } diff --git a/format/json/json.go b/format/json/json.go index b93f3d3e..04ea9753 100644 --- a/format/json/json.go +++ b/format/json/json.go @@ -49,14 +49,6 @@ func decodeJSON(d *decode.D, _ any) any { } s.Actual = gojq.NormalizeNumbers(s.Actual) - - // switch s.Actual.(type) { - // case map[string]any, - // []any: - // default: - // d.Fatalf("top-level not object or array") - // } - d.Value.V = &s d.Value.Range.Len = d.Len() diff --git a/format/macho/macho.go b/format/macho/macho.go index 1a986c1a..51746512 100644 --- a/format/macho/macho.go +++ b/format/macho/macho.go @@ -819,11 +819,7 @@ func parseSectionFlags(d *decode.D) { } var timestampMapper = scalar.Fn(func(s scalar.S) (scalar.S, error) { - ts, ok := s.Actual.(uint64) - if !ok { - return s, nil - } - s.Sym = time.UnixMilli(int64(ts)).UTC().String() + s.Sym = time.UnixMilli(int64(s.ActualU())).UTC().String() return s, nil }) diff --git a/pkg/decode/scalar.go b/pkg/decode/scalar.go index 62cc3df9..99c3e6f5 100644 --- a/pkg/decode/scalar.go +++ b/pkg/decode/scalar.go @@ -11,10 +11,7 @@ import ( ) func bitBufIsZero(s scalar.S, isValidate bool) (scalar.S, error) { - br, ok := s.Actual.(bitio.ReaderAtSeeker) - if !ok { - return s, nil - } + br := s.ActualBitBuf() isZero := true // TODO: shared diff --git a/pkg/scalar/scalar.go b/pkg/scalar/scalar.go index 562777fb..e9e21a31 100644 --- a/pkg/scalar/scalar.go +++ b/pkg/scalar/scalar.go @@ -136,10 +136,7 @@ type URangeEntry struct { type URangeToScalar []URangeEntry func (rs URangeToScalar) MapScalar(s S) (S, error) { - n, ok := s.Actual.(uint64) - if !ok { - return s, nil - } + n := s.ActualU() for _, re := range rs { if n >= re.Range[0] && n <= re.Range[1] { ns := re.S @@ -161,10 +158,7 @@ type SRangeEntry struct { type SRangeToScalar []SRangeEntry func (rs SRangeToScalar) MapScalar(s S) (S, error) { - n, ok := s.Actual.(int64) - if !ok { - return s, nil - } + n := s.ActualS() for _, re := range rs { if n >= re.Range[0] && n <= re.Range[1] { ns := re.S @@ -177,10 +171,7 @@ func (rs SRangeToScalar) MapScalar(s S) (S, error) { } func RawSym(s S, nBytes int, fn func(b []byte) string) (S, error) { - br, ok := s.Actual.(bitio.ReadAtSeeker) - if !ok { - return s, nil - } + br := s.ActualBitBuf() brLen, err := bitioextra.Len(br) if err != nil { return S{}, err