From e4964e8a0d74339ed7433082d9c49cde2d7dc1b9 Mon Sep 17 00:00:00 2001 From: Ilya Portnov Date: Sun, 2 Oct 2011 18:36:37 +0600 Subject: [PATCH] A bit more docs. --- JVM/Builder/Instructions.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) -- 2.25.1