@@ -33,6 +33,9 @@ doubleType = PrimType DoubleT
3333array :: J.Type -> J.Type
3434array t = RefType . ArrayType $ t
3535
36+addressType :: J.Type
37+addressType = longType
38+
3639-----------------------------------------------------------------------
3740-- Boxed types
3841
@@ -48,6 +51,10 @@ stringType :: J.Type
4851stringType =
4952 RefType . ClassRefType $ ClassType [(Ident "String", [])]
5053
54+bufferType :: J.Type
55+bufferType =
56+ RefType . ClassRefType $ ClassType [(Ident "ByteBuffer", [])]
57+
5158threadType :: J.Type
5259threadType =
5360 RefType . ClassRefType $ ClassType [(Ident "Thread", [])]
@@ -132,6 +139,9 @@ runtimeExceptionType :: J.Type
132139runtimeExceptionType =
133140 RefType . ClassRefType $ ClassType [(Ident "RuntimeException", [])]
134141
142+-----------------------------------------------------------------------
143+-- Integer types
144+
135145nativeTyToJType :: NativeTy -> J.Type
136146nativeTyToJType IT8 = byteType
137147nativeTyToJType IT16 = shortType
@@ -219,6 +229,7 @@ opName x
219229 | (LFloatInt to) <- x = "LFloatInt" ++ (suffixFor to)
220230 | (LStrInt to) <- x = "LStrInt" ++ (suffixFor to)
221231 | (LChInt to) <- x = "LChInt" ++ (suffixFor to)
232+ | (LPeek to _) <- x = "LPeek" ++ (suffixFor to)
222233 | otherwise = takeWhile ((/=) ' ') $ show x
223234 where
224235 suffixFor (ITFixed nt) = show nt
@@ -291,10 +302,29 @@ sourceTypes (LStrRev) = [stringType]
291302sourceTypes (LStdIn) = []
292303sourceTypes (LStdOut) = []
293304sourceTypes (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]
294310sourceTypes (LFork) = [objectType]
295311sourceTypes (LPar) = [objectType]
296312sourceTypes (LVMPtr) = []
297313sourceTypes (LNullPtr) = [objectType]
298314sourceTypes (LNoOp) = repeat objectType
299315
300−
316+-----------------------------------------------------------------------
317+-- Endianess markers
318+
319+endiannessConstant :: Endianness -> Exp
320+endiannessConstant c =
321+ ExpName . Name . map Ident $ ["java", "nio", "ByteOrder", endiannessConstant' c]
322+ where
323+ endiannessConstant' BE = "BIG_ENDIAN"
324+ endiannessConstant' LE = "LITTLE_ENDIAN"
325+ endiannessConstant' (IRTS.Lang.Native) = endiannessConstant' BE
326+
327+endiannessArguments :: PrimFn -> [Exp]
328+endiannessArguments (LAppend _ end) = [endiannessConstant end]
329+endiannessArguments (LPeek _ end) = [endiannessConstant end]
330+endiannessArguments _ = []