Fix for index check in PHP code.
This commit is contained in:
parent
77235947c1
commit
e737b47ee1
1 changed files with 4 additions and 1 deletions
|
|
@ -891,6 +891,9 @@ proc genArrayAddr(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
else: first = 0
|
else: first = 0
|
||||||
if optBoundsCheck in p.options and not isConstExpr(m.sons[1]):
|
if optBoundsCheck in p.options and not isConstExpr(m.sons[1]):
|
||||||
useMagic(p, "chckIndx")
|
useMagic(p, "chckIndx")
|
||||||
|
if p.target == targetPHP:
|
||||||
|
r.res = "chckIndx($1, $2, count($3))-$2" % [b.res, rope(first), a.res]
|
||||||
|
else:
|
||||||
r.res = "chckIndx($1, $2, $3.length)-$2" % [b.res, rope(first), a.res]
|
r.res = "chckIndx($1, $2, $3.length)-$2" % [b.res, rope(first), a.res]
|
||||||
elif first != 0:
|
elif first != 0:
|
||||||
r.res = "($1)-$2" % [b.res, rope(first)]
|
r.res = "($1)-$2" % [b.res, rope(first)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue