Extract some label-related stuff
This commit is contained in:
parent
23bd495521
commit
81fee29490
3 changed files with 25 additions and 13 deletions
|
|
@ -10,24 +10,16 @@ import qualified Data.Text as T
|
|||
|
||||
import Mima.Format.Common
|
||||
import Mima.Word
|
||||
import Mima.Label
|
||||
|
||||
fAddress :: MimaAddress -> T.Text
|
||||
fAddress = fixWidthHex 5 . toHex
|
||||
|
||||
type LabelName = T.Text
|
||||
|
||||
combineByAddress :: Map.Map LabelName MimaAddress -> Map.Map MimaAddress (Set.Set LabelName)
|
||||
combineByAddress = ($ Map.empty )
|
||||
. mconcat
|
||||
. reverse
|
||||
. map (\(l, a) -> Map.insertWith Set.union a (Set.singleton l))
|
||||
. Map.assocs
|
||||
|
||||
fLabels :: Set.Set LabelName -> T.Text
|
||||
fLabels = T.intercalate " " . Set.toAscList
|
||||
|
||||
fLine :: (MimaAddress, Set.Set LabelName) -> T.Text
|
||||
fLine (a, s) = fAddress a <> ": " <> fLabels s <> "\n"
|
||||
|
||||
formatSymbolFile :: Map.Map LabelName MimaAddress -> T.Text
|
||||
formatSymbolFile = mconcat . map fLine . Map.assocs . combineByAddress
|
||||
formatSymbolFile :: LabelSpec -> T.Text
|
||||
formatSymbolFile = mconcat . map fLine . Map.assocs . labelsByAddress
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue