diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-05-12 03:02:39 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-05-13 00:47:18 +0200 |
commit | 746132d6963e8c5dabde19c62a89d22560b820fd (patch) | |
tree | 897ebba6589c13a3b1c8b9e071f38799aa5a6b04 | |
parent | 6e6c15081d8e660ebd4e7111c69962e4da2d2aa5 (diff) | |
download | Nim-746132d6963e8c5dabde19c62a89d22560b820fd.tar.gz |
PHP codegen improvements
-rw-r--r-- | compiler/jsgen.nim | 2 | ||||
-rw-r--r-- | lib/system.nim | 2 | ||||
-rw-r--r-- | lib/system/jssys.nim | 5 |
3 files changed, 6 insertions, 3 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index ea58bb7dd..964752c16 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -981,7 +981,7 @@ proc genArrayAccess(p: PProc, n: PNode, r: var TCompRes) = 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] + r.res = "ord(@$1[$2])" % [r.address, r.res] else: r.res = "$1[$2]" % [r.address, r.res] else: diff --git a/lib/system.nim b/lib/system.nim index 5d6fcf868..f584f7590 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2163,7 +2163,7 @@ proc `&` *[T](x: T, y: seq[T]): seq[T] {.noSideEffect.} = result[i+1] = y[i] when not defined(nimscript): - when not defined(JS): + when not defined(JS) or defined(nimphp): proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} = result = cast[pointer](x) else: diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 220683717..99997efe6 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -121,7 +121,10 @@ proc raiseException(e: ref Exception, ename: cstring) {. when not defined(noUnhandledHandler): if excHandler == 0: unhandledException(e) - asm "throw `e`;" + when defined(nimphp): + asm """throw new Exception($`e`["message"]);""" + else: + asm "throw `e`;" proc reraiseException() {.compilerproc, asmNoStackFrame.} = if lastJSError == nil: |