Skip to content

Commit

Permalink
base: Improve Show instance for Memory
Browse files Browse the repository at this point in the history
Previously:

    [  base   = 1
      offset = 0x0
      flags  = r
      size   = 0x798,  base   = 1
      offset = 0x1000
      flags  = rx
      size   = 0x2e5,  base   = 1
      offset = 0x2000
      flags  = r
      size   = 0x17c,  base   = 1
      offset = 0x3da0
      flags  = rw
      size   = 0x340]

Now:

    [ base   = 1
      offset = 0x0
      flags  = r
      size   = 0x798
    , base   = 1
      offset = 0x1000
      flags  = rx
      size   = 0x2e5
    , base   = 1
      offset = 0x2000
      flags  = r
      size   = 0x17c
    , base   = 1
      offset = 0x3da0
      flags  = rw
      size   = 0x340 ]
  • Loading branch information
langston-barrett committed Dec 19, 2024
1 parent 7cbeacb commit 89fa17a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions base/src/Data/Macaw/Memory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,11 @@ segmentSize = contentsSize . segmentContents
-- | Pretty print a memory segment.
ppMemSegment :: MemWidth w => MemSegment w -> Doc ann
ppMemSegment s =
indent 2 $ vcat [ "base =" <+> viaShow (segmentBase s)
, "offset =" <+> viaShow (segmentOffset s)
, "flags =" <+> viaShow (segmentFlags s)
, "size =" <+> viaShow (segmentSize s)
]
align $ vcat [ "base =" <+> viaShow (segmentBase s)
, "offset =" <+> viaShow (segmentOffset s)
, "flags =" <+> viaShow (segmentFlags s)
, "size =" <+> viaShow (segmentSize s)
]

instance MemWidth w => Show (MemSegment w) where
show = show . ppMemSegment
Expand Down Expand Up @@ -961,7 +961,7 @@ memSegments :: Memory w -> [MemSegment w]
memSegments m = concatMap Map.elems (Map.elems (memSegmentMap m))

instance MemWidth w => Show (Memory w) where
show = show . memSegments
show = show . list . map ppMemSegment . memSegments

-- | Return the number of bytes in an address.
memWidth :: Memory w -> NatRepr w
Expand Down

0 comments on commit 89fa17a

Please sign in to comment.