@@ -169,7 +169,7 @@ jarHeader =
169 ++ "if test -n \"$JAVA_HOME\"; then\n"
169 ++ "if test -n \"$JAVA_HOME\"; then\n"
170 ++ " java=\"$JAVA_HOME/bin/java\"\n"
170 ++ " java=\"$JAVA_HOME/bin/java\"\n"
171 ++ "fi\n"
171 ++ "fi\n"
172− ++ "exec \"$java\" $java_args -jar $MYSELF \"$@\""
172+ ++ "exec \"$java\" $java_args -jar $MYSELF \"$@\"\n"
173 ++ "exit 1\n"
173 ++ "exit 1\n"
175-----------------------------------------------------------------------
175-----------------------------------------------------------------------
@@ -312,6 +312,7 @@ mkCompilationUnit globalInit defs hdrs out = do
312 , ImportDecl True idrisPrelude True
312 , ImportDecl True idrisPrelude True
313 , ImportDecl False bigInteger False
313 , ImportDecl False bigInteger False
314 , ImportDecl False runtimeException False
314 , ImportDecl False runtimeException False
315+ , ImportDecl False byteBuffer False
315 ] ++ otherHdrs
316 ] ++ otherHdrs
317 <$> mkTypeDecl clsName globalInit defs
318 <$> mkTypeDecl clsName globalInit defs
@@ -320,6 +321,7 @@ mkCompilationUnit globalInit defs hdrs out = do
320 idrisPrelude = J.Name $ map Ident ["org", "idris", "rts", "Prelude"]
321 idrisPrelude = J.Name $ map Ident ["org", "idris", "rts", "Prelude"]
321 bigInteger = J.Name $ map Ident ["java", "math", "BigInteger"]
322 bigInteger = J.Name $ map Ident ["java", "math", "BigInteger"]
322 runtimeException = J.Name $ map Ident ["java", "lang", "RuntimeException"]
323 runtimeException = J.Name $ map Ident ["java", "lang", "RuntimeException"]
324+ byteBuffer = J.Name $ map Ident ["java", "nio", "ByteBuffer"]
323 otherHdrs = map ( (\ name -> ImportDecl False name False)
325 otherHdrs = map ( (\ name -> ImportDecl False name False)
325 . map (Ident . T.unpack)
327 . map (Ident . T.unpack)
@@ -386,9 +388,7 @@ mkMainMethod =
387 [FormalParam [] (array stringType) False (VarId $ Ident "args")]
389 [FormalParam [] (array stringType) False (VarId $ Ident "args")]
388 $ Block [ BlockStmt . ExpStmt
390 $ Block [ BlockStmt . ExpStmt
389− $ call "idris_initArgs" [ (threadType ~> "currentThread") []
391+ $ call "idris_initArgs" [ jConst "args" ]
392 , BlockStmt . ExpStmt $ call (mangle' (sMN 0 "runMain")) []
392 , BlockStmt . ExpStmt $ call (mangle' (sMN 0 "runMain")) []
@@ -484,6 +484,8 @@ mkExp pp (SOp LFork [arg]) =
484 (mkThread arg) >>= ppExp pp
484 (mkThread arg) >>= ppExp pp
485mkExp pp (SOp LPar [arg]) =
485mkExp pp (SOp LPar [arg]) =
486 (Nothing <>@! arg) >>= ppExp pp
486 (Nothing <>@! arg) >>= ppExp pp
487+mkExp pp (SOp LRegisterPtr [ptr, i]) =
488+ (Nothing <>@! ptr) >>= ppExp pp
487mkExp pp (SOp LNoOp args) =
489mkExp pp (SOp LNoOp args) =
488 (Nothing <>@! (last args)) >>= ppExp pp
490 (Nothing <>@! (last args)) >>= ppExp pp
489mkExp pp (SOp LNullPtr args) =
491mkExp pp (SOp LNullPtr args) =
@@ -707,6 +709,7 @@ mkConstant c@(AType x) = ClassLit (Just $ box (constType c))
707mkConstant c@(StrType ) = ClassLit (Just $ stringType)
709mkConstant c@(StrType ) = ClassLit (Just $ stringType)
708mkConstant c@(PtrType ) = ClassLit (Just $ objectType)
710mkConstant c@(PtrType ) = ClassLit (Just $ objectType)
709mkConstant c@(ManagedPtrType) = ClassLit (Just $ objectType)
711mkConstant c@(ManagedPtrType) = ClassLit (Just $ objectType)
712+mkConstant c@(BufferType) = ClassLit (Just $ bufferType)
710mkConstant c@(VoidType ) = ClassLit (Just $ voidType)
713mkConstant c@(VoidType ) = ClassLit (Just $ voidType)
711mkConstant c@(Forgot ) = ClassLit (Just $ objectType)
714mkConstant c@(Forgot ) = ClassLit (Just $ objectType)
@@ -744,7 +747,7 @@ mkForeign pp (LANG_JAVA callType) resTy text params
745mkPrimitiveFunction :: PrimFn -> [LVar] -> CodeGeneration Exp
748mkPrimitiveFunction :: PrimFn -> [LVar] -> CodeGeneration Exp
746mkPrimitiveFunction op args =
749mkPrimitiveFunction op args =
747− (\ args -> (primFnType ~> opName op) args)
750+ (\ args -> (primFnType ~> opName op) (endiannessArguments op ++ args))
748 <$> sequence (zipWith (\ a t -> (Just t) <>@! a) args (sourceTypes op))
751 <$> sequence (zipWith (\ a t -> (Just t) <>@! a) args (sourceTypes op))
750mkThread :: LVar -> CodeGeneration Exp
753mkThread :: LVar -> CodeGeneration Exp