From 060a820d625250e823efa336b2602235ee085e68 Mon Sep 17 00:00:00 2001 From: Hans Raaf Date: Sun, 6 Mar 2016 23:37:40 +0100 Subject: Try to fix addr() ref and pointer for PHP --- compiler/jsgen.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 0cd0281af..3e7323929 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -775,10 +775,17 @@ proc generateHeader(p: PProc, typ: PType): Rope = add(result, name) add(result, "_Idx") 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, 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 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}: useMagic(p, "nimAt") 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] else: r.res = "nimAt($1, $2)" % [r.address, r.res] 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] else: r.res = "$1[$2]" % [r.address, r.res] -- cgit 1.4.1-2-gfad0