Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lying comment #285

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/Reopt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2090,22 +2090,24 @@ resolveArgType nm tp0 =
TypedefAnnType _ tp ->
resolveArgType nm tp

-- | This parses the types extracted from header function argumnts to
-- the machine code registers that the function will expect.
-- | This parses the types extracted from header function arguments to the
-- machine code registers that the function will expect.
argsToRegisters ::
forall m.
Monad m =>
-- | Number of arguments processed so far.
Int ->
-- | Remaining arguments to parse
-- | Vector of arguments to a given function
V.Vector AnnFunArg ->
ArgResolver m ()
argsToRegisters cnt args
| cnt >= V.length args = pure ()
| otherwise = do
let arg = args V.! cnt
let nm = fromMaybe ("arg" ++ show cnt) (funArgName arg)
resolveArgType nm (funArgType arg)
argsToRegisters (cnt + 1) args
argsToRegisters args = go 0
where
go :: Int -> ArgResolver m ()
go argIx
| argIx >= V.length args = pure ()
| otherwise = do
let arg = args V.! argIx
let nm = fromMaybe ("arg" ++ show argIx) (funArgName arg)
resolveArgType nm (funArgType arg)
go (argIx + 1)

parseReturnType :: AnnType -> Either ArgResolverError [Some X86RetInfo]
parseReturnType tp0 =
Expand All @@ -2124,7 +2126,7 @@ resolveAnnFunType ::
AnnFunType ->
ExceptT ArgResolverError m X86FunTypeInfo
resolveAnnFunType funType = do
args <- runArgResolver (argsToRegisters 0 (funArgs funType))
args <- runArgResolver (argsToRegisters (funArgs funType))
ret <-
case parseReturnType (funRet funType) of
Left e -> throwError e
Expand Down
Loading