projects
/
hs-java.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
49404fe
)
A bit more docs.
author
Ilya Portnov
<portnov84@rambler.ru>
Sun, 2 Oct 2011 12:36:37 +0000
(18:36 +0600)
committer
Ilya Portnov
<portnov84@rambler.ru>
Sun, 2 Oct 2011 12:36:37 +0000
(18:36 +0600)
JVM/Builder/Instructions.hs
patch
|
blob
|
history
diff --git
a/JVM/Builder/Instructions.hs
b/JVM/Builder/Instructions.hs
index a9c82215e6c1cd9682746b2e328c29e9be5abf7b..78e3545b6ddf0eedd4f52c9c5fde3cadb2596b02 100644
(file)
--- a/
JVM/Builder/Instructions.hs
+++ b/
JVM/Builder/Instructions.hs
@@
-1,4
+1,6
@@
-- | This module exports shortcuts for some of JVM instructions (which are defined in JVM.Assembler).
-- | This module exports shortcuts for some of JVM instructions (which are defined in JVM.Assembler).
+-- These functions get Constants, put them into constants pool and generate instruction using index
+-- of constant in the pool.
module JVM.Builder.Instructions where
import Data.Word
module JVM.Builder.Instructions where
import Data.Word
@@
-45,6
+47,7
@@
bipush :: Word8 -> Generate ()
bipush x = i0 (BIPUSH x)
sipush :: Word16 -> Generate ()
sipush x = i0 (SIPUSH x)
bipush x = i0 (BIPUSH x)
sipush :: Word16 -> Generate ()
sipush x = i0 (SIPUSH x)
+
ldc1 :: Constant Resolved -> Generate ()
ldc1 x = i8 LDC1 x
ldc2 :: Constant Resolved -> Generate ()
ldc1 :: Constant Resolved -> Generate ()
ldc1 x = i8 LDC1 x
ldc2 :: Constant Resolved -> Generate ()
@@
-254,6
+257,14
@@
i2s = i0 I2S
lcmp :: Generate ()
lcmp = i0 LCMP
lcmp :: Generate ()
lcmp = i0 LCMP
+-- | Wide instruction
+wide :: (Word8 -> Instruction) -> Constant Resolved -> Generate ()
+wide fn c = do
+ ix <- addToPool c
+ let ix0 = fromIntegral (ix `div` 0x100) :: Word8
+ ix1 = fromIntegral (ix `mod` 0x100) :: Word8
+ i0 (WIDE ix0 $ fn ix1)
+
new :: B.ByteString -> Generate ()
new cls =
i1 NEW (CClass cls)
new :: B.ByteString -> Generate ()
new cls =
i1 NEW (CClass cls)