@@ -15,6 +15,10 @@ data CPtr = CPt Ptr Int
15implicit toCPtr : Ptr -> CPtr
15implicit toCPtr : Ptr -> CPtr
16toCPtr p = CPt p 0
16toCPtr p = CPt p 0
18+implicit toPtr : CPtr -> Ptr
20+toPtr (CPt p o) = prim__ptrOffset p o
18||| Import of malloc from the C standard library.
22||| Import of malloc from the C standard library.
19malloc : Int -> IO Ptr
23malloc : Int -> IO Ptr
20malloc size = foreign FFI_C "malloc" (Int -> IO Ptr) size
24malloc size = foreign FFI_C "malloc" (Int -> IO Ptr) size
@@ -77,10 +81,10 @@ update ty cp f = do val <- peek ty cp
78||| Get a pointer to a field in a composite value
82||| Get a pointer to a field in a composite value
79field : Composite -> Nat -> CPtr -> CPtr
83field : Composite -> Nat -> CPtr -> CPtr
80−field arr@(ARRAY n t) i (CPt p o ) = CPt p (o + offset arr i)
84+field arr@(ARRAY n t) i (CPt p o) = CPt p (o + offset arr i)
81−field un@(UNION xs) i (CPt p o ) = CPt p o
85+field un@(UNION xs) i (CPt p o) = CPt p o
82−field st@(STRUCT xs) i (CPt p o ) = CPt p (o + offset st i)
86+field st@(STRUCT xs) i (CPt p o) = CPt p (o + offset st i)
83−field ps@(PACKEDSTRUCT xs) i (CPt p o ) = CPt p (o + offset ps i)
87+field ps@(PACKEDSTRUCT xs) i (CPt p o) = CPt p (o + offset ps i)
84field (T t) Z p = p
88field (T t) Z p = p
86infixl 10 #
90infixl 10 #