Skip to content

Commit

Permalink
add: nameToString helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
G0nzal0zz committed Dec 10, 2024
1 parent 95044da commit 8279000
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Codegen/Utils.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Codegen.Utils where

import qualified Data.ByteString.Short as BS
import qualified LLVM.AST as AST

-- | Converts a string to a `ByteString`.
stringToByteString :: String -> BS.ShortByteString
Expand All @@ -9,3 +10,8 @@ stringToByteString = BS.pack . map (fromIntegral . fromEnum)
-- | Converts a `ByteString` to a string.
byteStringToString :: BS.ShortByteString -> String
byteStringToString = map (toEnum . fromIntegral) . BS.unpack

-- | Converts AST.Name to a string.
nameToString :: AST.Name -> String
nameToString (AST.Name n) = byteStringToString n
nameToString (AST.UnName n) = show n

0 comments on commit 8279000

Please # to comment.