From: Ilya Portnov Date: Sun, 2 Oct 2011 12:36:37 +0000 (+0600) Subject: A bit more docs. X-Git-Tag: v0.3.2~28 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=hs-java.git;a=commitdiff_plain;h=26a29502e585cef2e9c35d508d9e6b82fa0fcef9 A bit more docs. --- diff --git a/JVM/Builder/Instructions.hs b/JVM/Builder/Instructions.hs index a9c8221..78e3545 100644 --- 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). +-- 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 @@ -45,6 +47,7 @@ bipush :: Word8 -> Generate () 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 () @@ -254,6 +257,14 @@ i2s = i0 I2S 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)