feat: implements outofbounds error. array negative bounds check added
This commit is contained in:
@@ -190,9 +190,13 @@ object asmGenerator {
|
||||
case ArrayElem(x, i) =>
|
||||
chain ++= evalExprOntoStack(rhs)
|
||||
chain ++= evalExprOntoStack(i)
|
||||
chain += Compare(stack.head, ImmediateVal(0))
|
||||
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.Less)
|
||||
chain ++= evalExprOntoStack(x)
|
||||
chain += stack.pop(RAX)
|
||||
chain += stack.pop(RCX)
|
||||
// chain += Compare(RAX, RCX)
|
||||
// chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.GreaterEqual)
|
||||
chain += stack.pop(RDX)
|
||||
|
||||
chain += Move(
|
||||
@@ -294,6 +298,8 @@ object asmGenerator {
|
||||
chain ++= evalExprOntoStack(x)
|
||||
chain ++= evalExprOntoStack(i)
|
||||
chain += stack.pop(RCX)
|
||||
chain += Compare(RCX, ImmediateVal(0))
|
||||
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.Less)
|
||||
chain += stack.pop(RAX)
|
||||
// + Int because we store the length of the array at the start
|
||||
chain += Move(
|
||||
|
||||
Reference in New Issue
Block a user