on master help sign in
Merge pull request #334 from JanBessai/master

Some fixes related to typeconversion in the Java backend

commit06a745666aa1b1fea4e1d48b8e85ad49a24f39f2 authorEdwin Brady <edwin.brady@gmail.com> dateThu 20 Jun 2013, 01:23 (13 years ago) parentf593dcc9054e62
2 files changed+4−14
java/src/main/java/org/idris/rts/ForeignPrimitives.java+2−2 src/IRTS/CodegenJava.hs+2−12
java/src/main/java/org/idris/rts/ForeignPrimitives.java+2−2
@@ -209,9 +209,9 @@ public class ForeignPrimitives {
209209 buf = null;
210210 }
211211
212− public static Integer idris_peek(Object buf, int offset) {
212+ public static byte idris_peek(Object buf, int offset) {
213213 ByteBuffer buffer = (ByteBuffer)buf;
214− return Integer.valueOf(buffer.get(offset));
214+ return buffer.get(offset);
215215 }
216216
217217 public static void idris_poke(Object buf, int offset, Object data) {
src/IRTS/CodegenJava.hs+2−12
@@ -1375,10 +1375,7 @@ mkExp (SOp LStrLen [arg]) =
13751375mkExp (SOp (LIntFloat ity) [arg]) =
13761376 mkPrimitiveCast (intTyToClass ity) doubleType arg
13771377mkExp (SOp (LFloatInt ity) [arg]) =
1378− mkPrimitiveCast doubleType (intTyToClass ity) arg
1379−mkExp (SOp (LIntStr ITBig) [arg]) =
1380− (\ var -> InstanceCreation [] bigIntegerType [var] Nothing)
1381− <$> mkVarAccess (Just stringType) arg
1378+ mkSignedExt (intTyToMethod ity) doubleType (intTyToClass ity) arg
13821379mkExp (SOp (LIntStr ity) [arg]) =
13831380 mkToString (intTyToClass ity) arg
13841381mkExp (SOp (LStrInt ity) [arg]) =
@@ -1486,14 +1483,7 @@ mkExp (SOp (LSExt from to) [var])
14861483 = mkSignedExt (intTyToMethod to) (intTyToClass from) (intTyToClass to) var
14871484mkExp (SOp (LTrunc from to) [var])
14881485 | intTyWidth from > intTyWidth to
1489− = (\ var -> MethodInv $
1490− TypeMethodCall (J.Name [intTyToIdent to])
1491− []
1492− (Ident "valueOf")
1493− [ MethodInv
1494− $ PrimaryMethodCall var [] (Ident (intTyToMethod to)) [] ]
1495− )
1496− <$> mkVarAccess (Just $ intTyToClass from) var
1486+ = mkSignedExt (intTyToMethod to) (intTyToClass from) (intTyToClass to) var
14971487mkExp (SOp LFExp [arg]) = mkMathFun "exp" arg
14981488mkExp (SOp LFLog [arg]) = mkMathFun "log" arg
14991489mkExp (SOp LFSin [arg]) = mkMathFun "sin" arg