@@ -21,7 +21,7 @@ module VirtualMachine.ByteCode where
2121 8 -> readIORef (current_class env) >>= \ c -> (return . VString . show . utf8_bytes) (constant_pool c !! (fromIntegral . string_index $ info))
2222 _ -> error $ " Bad Tag: " ++ show (tag info)
2323
24- {- Starting point of execution of ByteCode isntructions -}
24+ {- | Starting point of execution of ByteCode isntructions -}
2525 execute :: Runtime_Environment -> IO ()
2626 execute env = head <$> readIORef (stack env) -- Take the head of the stack (current stack frame)
2727 >>= \ frame -> when (debug_mode env) (debugFrame frame >>= putStrLn ) -- Optional Debug
@@ -91,7 +91,7 @@ module VirtualMachine.ByteCode where
9191 utf8_name = cpool !! fromIntegral (name_index name_and_type)
9292 in show . utf8_bytes $ utf8_name
9393
94- {- Loads from local_variables to operand_stack -}
94+ {- | Loads from local_variables to operand_stack -}
9595 loadOp :: StackFrame -> ByteCode -> IO ()
9696 loadOp frame bc
9797 -- Loads with the index as the next bytecode instruction
@@ -100,7 +100,7 @@ module VirtualMachine.ByteCode where
100100 | bc >= 26 && bc <= 45 = getLocal' frame ((bc - 26 ) `mod` 4 ) >>= pushOp frame
101101 | otherwise = error $ " Bad ByteCode Instruction: " ++ show bc
102102
103- {- Stores from operand_stack to local_variables -}
103+ {- | Stores from operand_stack to local_variables -}
104104 storeOp :: StackFrame -> ByteCode -> IO ()
105105 storeOp frame bc
106106 -- Stores with the index as the next bytecode instruction
@@ -118,7 +118,7 @@ module VirtualMachine.ByteCode where
118118 | otherwise = error $ " Bad ByteCode Instruction: " ++ show bc
119119
120120
121- {- Stores constant values on the Operand Stack. -}
121+ {- | Stores constant values on the Operand Stack. -}
122122 constOp :: StackFrame -> ByteCode -> IO ()
123123 constOp frame bc
124124 -- Null Reference
@@ -134,7 +134,7 @@ module VirtualMachine.ByteCode where
134134 -- ERROR
135135 | otherwise = error $ " Bad ByteCode Instruction: " ++ show bc
136136
137- {- Math operations which are abstracted by the Value type. -}
137+ {- | Math operations which are abstracted by the Value type. -}
138138 mathOp :: StackFrame -> ByteCode -> IO ()
139139 mathOp frame bc
140140 | bc >= 96 && bc <= 99 = applyBinaryOp (+)
@@ -160,7 +160,7 @@ module VirtualMachine.ByteCode where
160160 increment = -- 'iinc' has local variable index as first, with value as second indice
161161 join $ modifyLocal frame <$> getNextBC frame <*> ((+) . fromIntegral <$> getNextBC frame)
162162
163- {- Conditional jump instructions ('if', 'for', and 'while') -}
163+ {- | Conditional jump instructions ('if', 'for', and 'while') -}
164164 cmpOp :: StackFrame -> ByteCode -> IO ()
165165 cmpOp frame bc
166166 | bc >= 148 && bc <= 152 = pushCmp
@@ -199,15 +199,15 @@ module VirtualMachine.ByteCode where
199199 - 1 -> LT
200200 _ -> error " Bad Enumerable Value! "
201201
202- {- Obtains the next ByteCode instruction and increments the PC -}
202+ {- | Obtains the next ByteCode instruction and increments the PC -}
203203 getNextBC :: StackFrame -> IO ByteCode
204204 getNextBC frame = readIORef frame >>= \ f -> -- Read StackFrame from passed reference
205205 let segment = code_segment f in -- Retrieve current set of instructions
206206 readIORef (program_counter segment) >>= \ n -> -- Read current ByteCode instruction
207207 modifyIORef (program_counter segment) (+ 1 ) >> -- Increment PC
208208 return (byte_code segment !! fromIntegral n) -- Return ByteCode instruction
209209
210- {- Obtains the next two ByteCode instructions as a short, and increments the PC by 2 -}
210+ {- | Obtains the next two ByteCode instructions as a short, and increments the PC by 2 -}
211211 getNextShort :: StackFrame -> IO Word16
212212 getNextShort frame = replicateM 2 (getNextBC frame) >>= \ (i1: i2: _) ->
213213 return $ fromIntegral i1 `shift` 8 .|. fromIntegral i2
0 commit comments