uninitialized read is marked
This commit is contained in:
parent
99eddc7c55
commit
57f262554b
1 changed files with 11 additions and 5 deletions
|
@ -197,8 +197,14 @@ invAcc a i ('[':t) = invAcc a (i+1 + g) (drop g t) -- TODO check reads in f
|
||||||
-- all variables with false at the end of a block are unused
|
-- all variables with false at the end of a block are unused
|
||||||
invAcc a i s@(c:t) = let writeAcc = getWrite i s
|
invAcc a i s@(c:t) = let writeAcc = getWrite i s
|
||||||
matchLen = (length $ (\(v,_,_) -> v) (fromJust writeAcc))
|
matchLen = (length $ (\(v,_,_) -> v) (fromJust writeAcc))
|
||||||
|
readAcc = getRead i s
|
||||||
|
readLen = (length $ fst (fromJust readAcc))
|
||||||
in if isNothing writeAcc
|
in if isNothing writeAcc
|
||||||
then invAcc a (i+1) t -- no assignment in rest str TODO check for reads here
|
then if isNothing readAcc
|
||||||
|
then invAcc a (i+1) t
|
||||||
|
else if isUnassigned (fromJust readAcc) a
|
||||||
|
then (snd (fromJust readAcc)) : (invAcc a (i+1+readLen) (drop readLen t))
|
||||||
|
else invAcc (markRead (fromJust readAcc) a) (i+1+readLen) (drop readLen t) -- no assignment in rest str TODO check for reads here
|
||||||
else invAcc (a ++ [fromJust writeAcc]) (i+1+matchLen) (drop matchLen t) -- assignment in accumStr, advance offset to end
|
else invAcc (a ++ [fromJust writeAcc]) (i+1+matchLen) (drop matchLen t) -- assignment in accumStr, advance offset to end
|
||||||
invAcc a _ _ = map (\(_,s,_) -> s) a
|
invAcc a _ _ = map (\(_,s,_) -> s) a
|
||||||
|
|
||||||
|
@ -214,11 +220,11 @@ getRead offset s = ((Tdfa.matchOnceText §~ "^(\\**[[:word:]]+)") s) >>= matchTo
|
||||||
let m = match ! 1 -- extract the match group (0 = the whole match)
|
let m = match ! 1 -- extract the match group (0 = the whole match)
|
||||||
in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))))
|
in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))))
|
||||||
|
|
||||||
isUnassigned :: String -> [(String,Slice,Bool)] -> Bool
|
isUnassigned :: (String,Slice) -> [(String,Slice,Bool)] -> Bool
|
||||||
isUnassigned s = null . filter (\(t,_,_) -> t == s)
|
isUnassigned (s,_) = null . filter (\(t,_,_) -> t == s)
|
||||||
|
|
||||||
markRead :: String -> [(String,Slice,Bool)] -> [(String,Slice,Bool)]
|
markRead :: (String,Slice) -> [(String,Slice,Bool)] -> [(String,Slice,Bool)]
|
||||||
markRead s = map (\(v,p,b) -> (v,p,b || v == s))
|
markRead (s,_) = map (\(v,p,b) -> (v,p,b || v == s))
|
||||||
|
|
||||||
enterBlock :: [(String,Slice,Bool)] -> [(String,Slice,Bool)]
|
enterBlock :: [(String,Slice,Bool)] -> [(String,Slice,Bool)]
|
||||||
enterBlock = map (\(v,s,b) -> ('*':v,s,b))
|
enterBlock = map (\(v,s,b) -> ('*':v,s,b))
|
||||||
|
|
Loading…
Reference in a new issue