check bounds instead of index

This commit is contained in:
nitely 2018-06-05 20:22:27 -03:00
commit ba39f359aa
3 changed files with 39 additions and 10 deletions

View file

@ -83,7 +83,7 @@ proc isInCurrentFrame(p: BProc, n: PNode): bool =
result = isInCurrentFrame(p, n.sons[0])
else: discard
proc genIndexCheck(p: BProc; arr, idx: TLoc)
proc genBoundsCheck(p: BProc; arr, a, b: TLoc)
proc openArrayLoc(p: BProc, n: PNode): Rope =
var a: TLoc
@ -97,8 +97,7 @@ proc openArrayLoc(p: BProc, n: PNode): Rope =
initLocExpr(p, q[3], c)
# but first produce the required index checks:
if optBoundsCheck in p.options:
genIndexCheck(p, a, b)
genIndexCheck(p, a, c)
genBoundsCheck(p, a, b, c)
let ty = skipTypes(a.t, abstractVar+{tyPtr})
case ty.kind
of tyArray: