on master help sign in
Rename functions implying Buffers have endianness

Buffers don't have endianness, though values stored in buffers do.

commitd6418d7c86ac96afc69887e87ff1c71f9ec1a5f5 authorShea Levy <shea@shealevy.com> dateThu 30 Jan 2014, 17:13 (13 years ago) parent5b70c05
5 files changed+20−46
libs/base/Data/Buffer.idr+11−37 src/IRTS/CodegenC.hs+2−2 src/IRTS/Lang.hs+2−2 src/Idris/Primitives.hs+4−4 test/buffer001/buffer001.idr+1−1
libs/base/Data/Buffer.idr+11−37
@@ -55,32 +55,20 @@ copy { n } = MkBuffer . prim__copy ( bitsFromNat n ) . realBuffer
5555-- (i.e. create a view of a subset of the Buffer)
5656%assert_total
5757public
58−peekBufferNative : Buffer ( m + n ) ->
59− ( offset : Fin ( S n ) ) ->
60− Buffer m
61−peekBufferNative ( MkBuffer real ) =
62− MkBuffer . prim__peekBufferNative real . bitsFromFin
63−
64−public
65−peekBufferLE : Buffer ( m + n ) ->
66− ( offset : Fin ( S n ) ) ->
67− Buffer m
68−peekBufferLE = peekBufferNative
69−
70−public
71−peekBufferBE : Buffer ( m + n ) ->
72− ( offset : Fin ( S n ) ) ->
73− Buffer m
74−peekBufferBE = peekBufferNative
58+peekBuffer : Buffer ( m + n ) ->
59+ ( offset : Fin ( S n ) ) ->
60+ Buffer m
61+peekBuffer ( MkBuffer real ) =
62+ MkBuffer . prim__peekBuffer real . bitsFromFin
7563
7664-- Append count repetitions of a Buffer to another Buffer
7765%assert_total
7866public
79−appendBufferNative : Buffer n ->
80− ( count : Nat ) ->
81− Buffer m ->
82− Buffer ( n + m * count )
83−appendBufferNative { n } { m } ( MkBuffer input ) count =
67+appendBuffer : Buffer n ->
68+ ( count : Nat ) ->
69+ Buffer m ->
70+ Buffer ( n + m * count )
71+appendBuffer { n } { m } ( MkBuffer input ) count =
8472 MkBuffer . app . realBuffer
8573 where
8674 nBits : Bits64
@@ -89,21 +77,7 @@ appendBufferNative { n } { m } ( MkBuffer input ) count =
8977 mBits = bitsFromNat m
9078 cBits : Bits64
9179 cBits = bitsFromNat count
92− app = prim__appendBufferNative input nBits cBits mBits
93−
94−public
95−appendBufferLE : Buffer n ->
96− ( count : Nat ) ->
97− Buffer m ->
98− Buffer ( n + m * count )
99−appendBufferLE = appendBufferNative
100−
101−public
102−appendBufferBE : Buffer n ->
103− ( count : Nat ) ->
104− Buffer m ->
105− Buffer ( n + m * count )
106−appendBufferBE = appendBufferNative
80+ app = prim__appendBuffer input nBits cBits mBits
10781
10882
10983peekBits : ( prim__UnsafeBuffer -> Bits64 -> a ) ->
src/IRTS/CodegenC.hs+2−2
@@ -459,8 +459,8 @@ doOp v LStrRev [x] = v ++ "idris_strRev(vm, " ++ creg x ++ ")"
459459
460460doOp v LAllocate [x] = v ++ "idris_allocate(vm, " ++ creg x ++ ")"
461461doOp v LCopy [x, y] = v ++ "idris_copy(vm, " ++ creg x ++ "," ++ creg y ++ ")"
462−doOp v LAppendBufferNative [a, b, c, d, e] = v ++ "idris_appendBuffer(vm, " ++ creg a ++ "," ++ creg b ++ "," ++ creg c ++ "," ++ creg d ++ "," ++ creg e ++ ")"
463−doOp v LPeekBufferNative [x, y] = v ++ "idris_peekBuffer(vm, " ++ creg x ++ "," ++ creg y ++ ")"
462+doOp v LAppendBuffer [a, b, c, d, e] = v ++ "idris_appendBuffer(vm, " ++ creg a ++ "," ++ creg b ++ "," ++ creg c ++ "," ++ creg d ++ "," ++ creg e ++ ")"
463+doOp v LPeekBuffer [x, y] = v ++ "idris_peekBuffer(vm, " ++ creg x ++ "," ++ creg y ++ ")"
464464doOp v (LAppend ity en) [a, b, c, d] = v ++ "idris_append" ++ intTyName ity ++ enName en ++ "(vm, " ++ creg a ++ "," ++ creg b ++ "," ++ creg c ++ "," ++ creg d ++ ")"
465465doOp v (LPeek ity en) [x, y] = v ++ "idris_peek" ++ intTyName ity ++ enName en ++ "(vm, " ++ creg x ++ "," ++ creg y ++ ")"
466466
src/IRTS/Lang.hs+2−2
@@ -60,8 +60,8 @@ data PrimFn = LPlus ArithTy | LMinus ArithTy | LTimes ArithTy
6060 -- Buffers
6161 | LAllocate
6262 | LCopy
63− | LAppendBufferNative
64− | LPeekBufferNative
63+ | LAppendBuffer
64+ | LPeekBuffer
6565 | LAppend IntTy Endianness
6666 | LPeek IntTy Endianness
6767
src/Idris/Primitives.hs+4−4
@@ -178,10 +178,10 @@ primitives =
178178 (1, LAllocate) total,
179179 Prim (sUN "prim__copy") (ty [AType (ATInt (ITFixed IT64)), BufferType] BufferType) 2 (p_cantreduce)
180180 (2, LCopy) partial,
181− Prim (sUN "prim__peekBufferNative") (ty [BufferType, AType (ATInt (ITFixed IT64))] BufferType) 2 (p_cantreduce)
182− (2, LPeekBufferNative) partial,
183− Prim (sUN "prim__appendBufferNative") (ty [BufferType, AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), BufferType] BufferType) 5 (p_cantreduce)
184− (5, LAppendBufferNative) partial
181+ Prim (sUN "prim__peekBuffer") (ty [BufferType, AType (ATInt (ITFixed IT64))] BufferType) 2 (p_cantreduce)
182+ (2, LPeekBuffer) partial,
183+ Prim (sUN "prim__appendBuffer") (ty [BufferType, AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), AType (ATInt (ITFixed IT64)), BufferType] BufferType) 5 (p_cantreduce)
184+ (5, LAppendBuffer) partial
185185 ] ++ concatMap intOps [ITFixed IT8, ITFixed IT16, ITFixed IT32, ITFixed IT64, ITBig, ITNative, ITChar]
186186 ++ concatMap vecOps vecTypes
187187 ++ concatMap fixedOps [ITFixed IT8, ITFixed IT16, ITFixed IT32, ITFixed IT64] -- ITNative, ITChar, ATFloat ] ++ vecTypes
test/buffer001/buffer001.idr+1−1
@@ -21,7 +21,7 @@ firstByte : Bits8
2121firstByte = peekBits8LE full 0
2222
2323firstHalfView : Buffer 4
24−firstHalfView = peekBufferLE full 0
24+firstHalfView = peekBuffer full 0
2525
2626firstHalfCopy : Buffer 4
2727firstHalfCopy = copy firstHalfView