Skip to content
Browse files

Fixed bug which popped up in test.vm/vm.dcf. Array indexes were not b…

…eing fully computed because of a small bug in MidIR.hs. So, something like array[f()] would not evaluate f and it would just do array[0].
  • Loading branch information...
1 parent 13d6c48 commit 0d26dc2a86884c2cf9c4085195afb77d789e8d76 Kyle Miller committed Apr 25, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/MidIR.hs
View
4 src/MidIR.hs
@@ -253,7 +253,7 @@ statementToMidIR fname env c b (HAssignSt senv pos loc op expr)
A.IncAssign -> BinOp pos OpAdd (Load pos (arrptr i')) ex
A.DecAssign -> BinOp pos OpSub (Load pos (arrptr i')) ex
[checkhighl, okl, faill] <- replicateM 3 freshLabel
- return $ ((mkMiddle $ Store pos i' i)
+ return $ (gi <*> (mkMiddle $ Store pos i' i)
<*> (mkLast $ CondBranch pos (BinOp pos CmpLT (Var pos i') (Lit pos 0))
faill checkhighl))
|*><*| (mkFirst (Label pos checkhighl)
@@ -364,7 +364,7 @@ expressionToMidIR env (HLoadLoc senv pos loc)
deadv <- genTmpVar
errl <- genStr pos $ "Array index out of bounds at " ++ show pos ++ "\n"
[checkhighl, okl, faill] <- replicateM 3 freshLabel
- let g = ((mkMiddle $ Store pos i' i)
+ let g = (gi <*> (mkMiddle $ Store pos i' i)
<*> (mkLast $ CondBranch pos (BinOp pos CmpLT (Var pos i') (Lit pos 0))
faill checkhighl))
|*><*| (mkFirst (Label pos checkhighl)

0 comments on commit 0d26dc2

Please sign in to comment.
Something went wrong with that request. Please try again.