Try to fix addr() ref and pointer for PHP
This commit is contained in:
parent
e4e8ebd4a5
commit
060a820d62
1 changed files with 10 additions and 1 deletions
|
|
@ -775,10 +775,17 @@ proc generateHeader(p: PProc, typ: PType): Rope =
|
||||||
add(result, name)
|
add(result, name)
|
||||||
add(result, "_Idx")
|
add(result, "_Idx")
|
||||||
elif not (i == 1 and param.name.s == "this"):
|
elif not (i == 1 and param.name.s == "this"):
|
||||||
if param.typ.skipTypes({tyGenericInst}).kind == tyVar:
|
let k = param.typ.skipTypes({tyGenericInst}).kind
|
||||||
|
if k in { tyVar, tyRef, tyPtr, tyPointer }:
|
||||||
add(result, "&")
|
add(result, "&")
|
||||||
add(result, "$")
|
add(result, "$")
|
||||||
add(result, name)
|
add(result, name)
|
||||||
|
# XXX I think something like this is needed for PHP to really support
|
||||||
|
# ptr "inside" strings and seq
|
||||||
|
#if mapType(param.typ) == etyBaseIndex:
|
||||||
|
# add(result, ", $")
|
||||||
|
# add(result, name)
|
||||||
|
# add(result, "_Idx")
|
||||||
|
|
||||||
const
|
const
|
||||||
nodeKindsNeedNoCopy = {nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit,
|
nodeKindsNeedNoCopy = {nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit,
|
||||||
|
|
@ -961,10 +968,12 @@ proc genArrayAccess(p: PProc, n: PNode, r: var TCompRes) =
|
||||||
if n.sons[0].kind in nkCallKinds+{nkStrLit..nkTripleStrLit}:
|
if n.sons[0].kind in nkCallKinds+{nkStrLit..nkTripleStrLit}:
|
||||||
useMagic(p, "nimAt")
|
useMagic(p, "nimAt")
|
||||||
if ty.kind in {tyString, tyCString}:
|
if ty.kind in {tyString, tyCString}:
|
||||||
|
# XXX this needs to be more like substr($1,$2)
|
||||||
r.res = "ord(nimAt($1, $2))" % [r.address, r.res]
|
r.res = "ord(nimAt($1, $2))" % [r.address, r.res]
|
||||||
else:
|
else:
|
||||||
r.res = "nimAt($1, $2)" % [r.address, r.res]
|
r.res = "nimAt($1, $2)" % [r.address, r.res]
|
||||||
elif ty.kind in {tyString, tyCString}:
|
elif ty.kind in {tyString, tyCString}:
|
||||||
|
# XXX this needs to be more like substr($1,$2)
|
||||||
r.res = "ord($1[$2])" % [r.address, r.res]
|
r.res = "ord($1[$2])" % [r.address, r.res]
|
||||||
else:
|
else:
|
||||||
r.res = "$1[$2]" % [r.address, r.res]
|
r.res = "$1[$2]" % [r.address, r.res]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue