fix: implements null pointer checks
This commit is contained in:
@@ -108,7 +108,7 @@ object RuntimeError {
|
|||||||
|
|
||||||
def generateHandler: Chain[AsmLine] = Chain(
|
def generateHandler: Chain[AsmLine] = Chain(
|
||||||
LabelDef(OutOfBoundsError.errLabel),
|
LabelDef(OutOfBoundsError.errLabel),
|
||||||
Pop(RSI), // le index
|
Pop(RSI),
|
||||||
stackAlign,
|
stackAlign,
|
||||||
Load(RDI, IndexAddress(RIP, LabelArg(OutOfBoundsError.strLabel))),
|
Load(RDI, IndexAddress(RIP, LabelArg(OutOfBoundsError.strLabel))),
|
||||||
assemblyIR.Call(CLibFunc.PrintF),
|
assemblyIR.Call(CLibFunc.PrintF),
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ object asmGenerator {
|
|||||||
chain ++= evalExprOntoStack(x)
|
chain ++= evalExprOntoStack(x)
|
||||||
chain += stack.pop(RAX)
|
chain += stack.pop(RAX)
|
||||||
chain += stack.pop(RCX)
|
chain += stack.pop(RCX)
|
||||||
|
chain += Compare(EAX, ImmediateVal(0))
|
||||||
|
chain += Jump(LabelArg(NullPtrError.errLabel), Cond.Equal)
|
||||||
chain += Compare(MemLocation(RAX, D32), ECX)
|
chain += Compare(MemLocation(RAX, D32), ECX)
|
||||||
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.LessEqual)
|
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.LessEqual)
|
||||||
chain += stack.pop(RDX)
|
chain += stack.pop(RDX)
|
||||||
@@ -302,6 +304,8 @@ object asmGenerator {
|
|||||||
chain += Compare(RCX, ImmediateVal(0))
|
chain += Compare(RCX, ImmediateVal(0))
|
||||||
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.Less)
|
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.Less)
|
||||||
chain += stack.pop(RAX)
|
chain += stack.pop(RAX)
|
||||||
|
chain += Compare(EAX, ImmediateVal(0))
|
||||||
|
chain += Jump(LabelArg(NullPtrError.errLabel), Cond.Equal)
|
||||||
chain += Compare(MemLocation(RAX, D32), ECX)
|
chain += Compare(MemLocation(RAX, D32), ECX)
|
||||||
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.LessEqual)
|
chain += Jump(LabelArg(OutOfBoundsError.errLabel), Cond.LessEqual)
|
||||||
// + Int because we store the length of the array at the start
|
// + Int because we store the length of the array at the start
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
|
|||||||
// "^.*wacc-examples/valid/IO/IOLoop.wacc.*$",
|
// "^.*wacc-examples/valid/IO/IOLoop.wacc.*$",
|
||||||
// "^.*wacc-examples/valid/IO/IOSequence.wacc.*$",
|
// "^.*wacc-examples/valid/IO/IOSequence.wacc.*$",
|
||||||
// "^.*wacc-examples/valid/pairs.*$",
|
// "^.*wacc-examples/valid/pairs.*$",
|
||||||
"^.*wacc-examples/valid/runtimeErr.*$",
|
//"^.*wacc-examples/valid/runtimeErr.*$",
|
||||||
// "^.*wacc-examples/valid/scope.*$",
|
// "^.*wacc-examples/valid/scope.*$",
|
||||||
// "^.*wacc-examples/valid/sequence.*$",
|
// "^.*wacc-examples/valid/sequence.*$",
|
||||||
// "^.*wacc-examples/valid/variables.*$",
|
// "^.*wacc-examples/valid/variables.*$",
|
||||||
|
|||||||
Reference in New Issue
Block a user