1 -- | This module exports shortcuts for some of JVM instructions (which are defined in JVM.Assembler).
2 module JVM.Builder.Instructions where
5 import qualified Data.ByteString.Lazy as B
9 import JVM.Builder.Monad
13 aconst_null :: Generate ()
14 aconst_null = i0 ACONST_NULL
15 iconst_m1 :: Generate ()
16 iconst_m1 = i0 ICONST_M1
17 iconst_0 :: Generate ()
18 iconst_0 = i0 ICONST_0
19 iconst_1 :: Generate ()
20 iconst_1 = i0 ICONST_1
21 iconst_2 :: Generate ()
22 iconst_2 = i0 ICONST_2
23 iconst_3 :: Generate ()
24 iconst_3 = i0 ICONST_3
25 iconst_4 :: Generate ()
26 iconst_4 = i0 ICONST_4
27 iconst_5 :: Generate ()
28 iconst_5 = i0 ICONST_5
29 lconst_0 :: Generate ()
30 lconst_0 = i0 LCONST_0
31 lconst_1 :: Generate ()
32 lconst_1 = i0 LCONST_1
33 fconst_0 :: Generate ()
34 fconst_0 = i0 FCONST_0
35 fconst_1 :: Generate ()
36 fconst_1 = i0 FCONST_1
37 fconst_2 :: Generate ()
38 fconst_2 = i0 FCONST_2
39 dconst_0 :: Generate ()
40 dconst_0 = i0 DCONST_0
41 dconst_1 :: Generate ()
42 dconst_1 = i0 DCONST_1
44 bipush :: Word8 -> Generate ()
45 bipush x = i0 (BIPUSH x)
46 sipush :: Word16 -> Generate ()
47 sipush x = i0 (SIPUSH x)
48 ldc1 :: Constant Resolved -> Generate ()
50 ldc2 :: Constant Resolved -> Generate ()
52 ldc2w :: Constant Resolved -> Generate ()
54 iload :: Constant Resolved -> Generate ()
56 lload :: Constant Resolved -> Generate ()
58 fload :: Constant Resolved -> Generate ()
60 dload :: Constant Resolved -> Generate ()
62 aload :: Constant Resolved -> Generate ()
65 iload_ :: IMM -> Generate ()
66 iload_ x = i0 (ILOAD_ x)
67 lload_ :: IMM -> Generate ()
68 lload_ x = i0 (LLOAD_ x)
69 fload_ :: IMM -> Generate ()
70 fload_ x = i0 (FLOAD_ x)
71 dload_ :: IMM -> Generate ()
72 dload_ x = i0 (DLOAD_ x)
73 aload_ :: IMM -> Generate ()
74 aload_ x = i0 (ALOAD_ x)
91 istore :: Constant Resolved -> Generate ()
92 istore x = i8 ISTORE x
93 lstore :: Constant Resolved -> Generate ()
94 lstore x = i8 LSTORE x
95 fstore :: Constant Resolved -> Generate ()
96 fstore x = i8 FSTORE x
97 dstore :: Constant Resolved -> Generate ()
98 dstore x = i8 DSTORE x
99 astore :: Constant Resolved -> Generate ()
100 astore x = i8 ASTORE x
102 istore_ :: Word8 -> Generate ()
103 istore_ x = i0 (ISTORE x)
104 lstore_ :: Word8 -> Generate ()
105 lstore_ x = i0 (LSTORE x)
106 fstore_ :: Word8 -> Generate ()
107 fstore_ x = i0 (FSTORE x)
108 dstore_ :: Word8 -> Generate ()
109 dstore_ x = i0 (DSTORE x)
110 astore_ :: Word8 -> Generate ()
111 astore_ x = i0 (ASTORE x)
113 iastore :: Generate ()
115 lastore :: Generate ()
117 fastore :: Generate ()
119 dastore :: Generate ()
121 aastore :: Generate ()
123 bastore :: Generate ()
125 castore :: Generate ()
127 sastore :: Generate ()
136 dup_x1 :: Generate ()
138 dup_x2 :: Generate ()
142 dup2_x1 :: Generate ()
144 dup2_x2 :: Generate ()
221 iinc :: Word8 -> Word8 -> Generate ()
222 iinc x y = i0 (IINC x y)
257 new :: B.ByteString -> Generate ()
261 newArray :: ArrayType -> Generate ()
263 i0 (NEWARRAY $ atype2byte t)
265 allocNewArray :: B.ByteString -> Generate ()
267 i1 ANEWARRAY (CClass cls)
269 invokeVirtual :: B.ByteString -> NameType Method -> Generate ()
270 invokeVirtual cls sig =
271 i1 INVOKEVIRTUAL (CMethod cls sig)
273 invokeStatic :: B.ByteString -> NameType Method -> Generate ()
274 invokeStatic cls sig =
275 i1 INVOKESTATIC (CMethod cls sig)
277 invokeSpecial :: B.ByteString -> NameType Method -> Generate ()
278 invokeSpecial cls sig =
279 i1 INVOKESPECIAL (CMethod cls sig)
281 getStaticField :: B.ByteString -> NameType Field -> Generate ()
282 getStaticField cls sig =
283 i1 GETSTATIC (CField cls sig)
285 loadString :: B.ByteString -> Generate ()
287 i8 LDC1 (CString str)
289 allocArray :: B.ByteString -> Generate ()
291 i1 ANEWARRAY (CClass cls)