Skip to content

Commit

Permalink
fix some norm error
Browse files Browse the repository at this point in the history
  • Loading branch information
TTENSHII committed Jan 14, 2024
1 parent 905178f commit dd5b17a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lvtrun/src/Parsing/Code.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module Parsing.Code
where

import Data.Int (Int64)
import Control.Exception (throw)
import Control.Monad (when)
import Control.Exception (throw)
import qualified Data.ByteString.Lazy as BSL

import Types
Expand Down Expand Up @@ -80,10 +80,9 @@ parseFunctions _ [] = throw $ WasmError "parseFunctions: bad section"
parseFunctions (x:xs) (y:ys) = parseFunction x y : parseFunctions xs ys

getFuncCode :: Section -> [Function] -> [Function]
getFuncCode (Section CodeID _ content) functions = do
let (nbFunc, rest) = getLEB128ToI64 content
let funcCodes = diviseBytes rest
when (nbFunc /= fromIntegral (length funcCodes)) $
throw $ WasmError "getFuncCode: bad section"
getFuncCode (Section CodeID _ content) functions =
parseFunctions funcCodes functions
where
(nbFunc, rest) = getLEB128ToI64 content
funcCodes = diviseBytes rest
getFuncCode _ _ = throw $ WasmError "getFuncCode: bad section"

0 comments on commit dd5b17a

Please sign in to comment.