feat: implements outofbounds error. array negative bounds check added
This commit is contained in:
@@ -100,5 +100,23 @@ object RuntimeError {
|
||||
|
||||
}
|
||||
|
||||
val all: Chain[RuntimeError] = Chain(ZeroDivError, BadChrError, NullPtrError, OverflowError)
|
||||
case object OutOfBoundsError extends RuntimeError {
|
||||
|
||||
val strLabel = ".L._errOutOfBounds_str0"
|
||||
val errStr = "fatal error: array index %d out of bounds"
|
||||
val errLabel = ".L._errOutOfBounds"
|
||||
|
||||
def generateHandler: Chain[AsmLine] = Chain(
|
||||
LabelDef(OutOfBoundsError.errLabel),
|
||||
Pop(RSI), // le index
|
||||
stackAlign,
|
||||
Load(RDI, IndexAddress(RIP, LabelArg(OutOfBoundsError.strLabel))),
|
||||
assemblyIR.Call(CLibFunc.PrintF),
|
||||
Move(RDI, ImmediateVal(255)),
|
||||
assemblyIR.Call(CLibFunc.Exit)
|
||||
)
|
||||
}
|
||||
|
||||
val all: Chain[RuntimeError] =
|
||||
Chain(ZeroDivError, BadChrError, NullPtrError, OverflowError, OutOfBoundsError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user