Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Decking
GHC
Commits
3632b8d4
Commit
3632b8d4
authored
Feb 03, 1999
by
sof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[project @ 1999-02-03 20:26:26 by sof]
Drop uneccessary uses of lit-lits and primops
parent
3e1864d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
18 deletions
+9
-18
ghc/lib/misc/CString.lhs
ghc/lib/misc/CString.lhs
+9
-18
No files found.
ghc/lib/misc/CString.lhs
View file @
3632b8d4
...
...
@@ -55,6 +55,7 @@ import PrelPack
import GlaExts
import Addr
import PrelIOBase ( IO(..) )
import MutableArray
\end{code}
...
...
@@ -66,7 +67,7 @@ packStringIO str = stToIO (packStringST str)
\begin{code}
unpackCStringIO :: Addr -> IO String
unpackCStringIO addr
| addr ==
``NULL''
= return ""
| addr ==
nullAddr
= return ""
| otherwise = unpack 0#
where
unpack nh = do
...
...
@@ -119,8 +120,8 @@ Turn a NULL-terminated vector of null-terminated strings into a string list
\begin{code}
unvectorize :: Addr -> Int -> IO [String]
unvectorize ptr n
| str ==
``NULL''
= return []
| otherwise = do
| str ==
nullAddr
= return []
| otherwise
= do
x <- unpackCStringIO str
xs <- unvectorize ptr (n+1)
return (x : xs)
...
...
@@ -145,10 +146,9 @@ vectorize vs = do
fill :: MutableByteArray RealWorld Int -> Int -> [String] -> IO ()
fill arr n [] =
_casm_ ``((PP_)%0)[%1] = NULL;'' arr n
fill arr n (x:xs) =
packStringIO x >>= \ barr ->
fill arr n (x:xs) =
do
barr <- packStringIO x
_casm_ ``((PP_)%0)[%1] = (P_)%2;'' arr n barr
>>= \ () ->
fill arr (n+1) xs
\end{code}
...
...
@@ -159,23 +159,14 @@ out the bounds - use with care.
\begin{code}
-- Allocate a mutable array of characters with no indices.
allocChars :: Int -> IO (MutableByteArray RealWorld Int)
allocChars (I# size#) = IO $ \ s# ->
case newCharArray# size# s# of
(# s2#, barr# #) ->
(# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #)
allocChars size = stToIO (newCharArray (0,size))
allocWords :: Int -> IO (MutableByteArray RealWorld Int)
allocWords (I# size#) = IO $ \ s# ->
case newIntArray# size# s# of
(# s2#, barr# #) ->
(# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #)
allocWords size = stToIO (newIntArray (0,size))
-- Freeze these index-free mutable arrays
freeze :: MutableByteArray RealWorld Int -> IO (ByteArray Int)
freeze (MutableByteArray ixs arr#) = IO $ \ s# ->
case unsafeFreezeByteArray# arr# s# of
(# s2#, frozen# #) ->
(# s2#, (ByteArray ixs frozen#) #)
freeze mb = stToIO (unsafeFreezeByteArray mb)
-- Copy a null-terminated string from outside the heap to
-- Haskellized nonsense inside the heap
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment