Skip to content
Snippets Groups Projects
Commit 042cded1 authored by sof's avatar sof
Browse files

[project @ 1998-04-30 19:24:21 by sof]

NCG support sizeof(Mutable)ByteArray# primops
parent 0d760962
No related merge requests found
......@@ -212,6 +212,30 @@ primCode [lhs] UnsafeFreezeByteArrayOp [rhs]
= simpleCoercion PtrRep lhs rhs
\end{code}
Returning the size of (mutable) byte arrays is just
an indexing operation.
\begin{code}
primCode [lhs] SizeofByteArrayOp [rhs]
= let
lhs' = amodeToStix lhs
rhs' = amodeToStix rhs
sz = StIndex IntRep rhs' fixedHS
assign = StAssign IntRep lhs' (StInd IntRep sz)
in
returnUs (\xs -> assign : xs)
primCode [lhs] SizeofMutableByteArrayOp [rhs]
= let
lhs' = amodeToStix lhs
rhs' = amodeToStix rhs
sz = StIndex IntRep rhs' fixedHS
assign = StAssign IntRep lhs' (StInd IntRep sz)
in
returnUs (\xs -> assign : xs)
\end{code}
Most other array primitives translate to simple indexing.
\begin{code}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment