@@ -33,6 +33,9 @@ doubleType = PrimType DoubleT
33array :: J.Type -> J.Type
33array :: J.Type -> J.Type
34array t = RefType . ArrayType $ t
34array t = RefType . ArrayType $ t
37+addressType = longType
36-----------------------------------------------------------------------
39-----------------------------------------------------------------------
37-- Boxed types
40-- Boxed types
@@ -48,6 +51,10 @@ stringType :: J.Type
48stringType =
51stringType =
49 RefType . ClassRefType $ ClassType [(Ident "String", [])]
52 RefType . ClassRefType $ ClassType [(Ident "String", [])]
56+ RefType . ClassRefType $ ClassType [(Ident "ByteBuffer", [])]
51threadType :: J.Type
58threadType :: J.Type
52threadType =
59threadType =
53 RefType . ClassRefType $ ClassType [(Ident "Thread", [])]
60 RefType . ClassRefType $ ClassType [(Ident "Thread", [])]
@@ -132,6 +139,9 @@ runtimeExceptionType :: J.Type
132runtimeExceptionType =
139runtimeExceptionType =
133 RefType . ClassRefType $ ClassType [(Ident "RuntimeException", [])]
140 RefType . ClassRefType $ ClassType [(Ident "RuntimeException", [])]
142+-----------------------------------------------------------------------
135nativeTyToJType :: NativeTy -> J.Type
145nativeTyToJType :: NativeTy -> J.Type
136nativeTyToJType IT8 = byteType
146nativeTyToJType IT8 = byteType
137nativeTyToJType IT16 = shortType
147nativeTyToJType IT16 = shortType
@@ -219,6 +229,7 @@ opName x
219 | (LFloatInt to) <- x = "LFloatInt" ++ (suffixFor to)
229 | (LFloatInt to) <- x = "LFloatInt" ++ (suffixFor to)
220 | (LStrInt to) <- x = "LStrInt" ++ (suffixFor to)
230 | (LStrInt to) <- x = "LStrInt" ++ (suffixFor to)
221 | (LChInt to) <- x = "LChInt" ++ (suffixFor to)
231 | (LChInt to) <- x = "LChInt" ++ (suffixFor to)
232+ | (LPeek to _) <- x = "LPeek" ++ (suffixFor to)
222 | otherwise = takeWhile ((/=) ' ') $ show x
233 | otherwise = takeWhile ((/=) ' ') $ show x
224 suffixFor (ITFixed nt) = show nt
235 suffixFor (ITFixed nt) = show nt
@@ -291,10 +302,29 @@ sourceTypes (LStrRev) = [stringType]
291sourceTypes (LStdIn) = []
302sourceTypes (LStdIn) = []
292sourceTypes (LStdOut) = []
303sourceTypes (LStdOut) = []
293sourceTypes (LStdErr) = []
304sourceTypes (LStdErr) = []
305+sourceTypes (LAllocate) = [addressType]
306+sourceTypes (LAppendBuffer) =
307+ [bufferType, addressType, addressType, addressType, addressType, bufferType]
308+sourceTypes (LAppend nt _) = [bufferType, intTyToJType nt, addressType]
309+sourceTypes (LPeek _ _) = [bufferType, addressType]
294sourceTypes (LFork) = [objectType]
310sourceTypes (LFork) = [objectType]
295sourceTypes (LPar) = [objectType]
311sourceTypes (LPar) = [objectType]
296sourceTypes (LVMPtr) = []
312sourceTypes (LVMPtr) = []
297sourceTypes (LNullPtr) = [objectType]
313sourceTypes (LNullPtr) = [objectType]
298sourceTypes (LNoOp) = repeat objectType
314sourceTypes (LNoOp) = repeat objectType
300−
316+-----------------------------------------------------------------------
319+endiannessConstant :: Endianness -> Exp
320+endiannessConstant c =
321+ ExpName . Name . map Ident $ ["java", "nio", "ByteOrder", endiannessConstant' c]
323+ endiannessConstant' BE = "BIG_ENDIAN"
324+ endiannessConstant' LE = "LITTLE_ENDIAN"
325+ endiannessConstant' (IRTS.Lang.Native) = endiannessConstant' BE
327+endiannessArguments :: PrimFn -> [Exp]
328+endiannessArguments (LAppend _ end) = [endiannessConstant end]
329+endiannessArguments (LPeek _ end) = [endiannessConstant end]
330+endiannessArguments _ = []