X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=harpy.git;a=blobdiff_plain;f=Harpy%2FCodeGenMonad.hs;h=46d930db2dafb2e53b4a3738702fd9dbb7a3fb4e;hp=0c0a281defe70b2814bd9bb3510053f79aacedd9;hb=4e512910dd2601fadf48bdc2633473934793717a;hpb=ff05e966530a580c052bf5c3ca25241c94ad0d13 diff --git a/Harpy/CodeGenMonad.hs b/Harpy/CodeGenMonad.hs index 0c0a281..46d930d 100644 --- a/Harpy/CodeGenMonad.hs +++ b/Harpy/CodeGenMonad.hs @@ -525,9 +525,12 @@ disassemble = do where insertLabels :: [Dis.Instruction] -> CodeGen e s [Dis.Instruction] insertLabels = liftM concat . mapM ins ins :: Dis.Instruction -> CodeGen e s [Dis.Instruction] - ins i@(Dis.BadInstruction{}) = return [i] + ins i@(Dis.BadInstruction _ _ addr _) = insWithLabel i addr ins i@(Dis.PseudoInstruction{}) = return [i] - ins i@(Dis.Instruction{Dis.address = addr}) = + ins i@(Dis.Instruction{Dis.address = addr}) = insWithLabel i addr + + insWithLabel :: Dis.Instruction -> Int -> CodeGen e s [Dis.Instruction] + insWithLabel i addr = do state <- getInternalState let allLabs = Map.toList (definedLabels state) labs = filter (\ (_, (buf, ofs, _)) -> fromIntegral (ptrToWordPtr (buf `plusPtr` ofs)) == addr) allLabs