diff options
Diffstat (limited to 'lib/system/jssys.nim')
-rw-r--r-- | lib/system/jssys.nim | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 836ac198d..8be19e5b8 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -228,6 +228,7 @@ proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} = proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} = asm """ + if (`s` === null) return ""; var len = `s`.length; var asciiPart = new Array(len); var fcc = String.fromCharCode; @@ -330,6 +331,8 @@ proc cmp(x, y: string): int = proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} = asm """ if (`a` == `b`) return true; + if (`a` === null && `b`.length == 0) return true; + if (`b` === null && `a`.length == 0) return true; if ((!`a`) || (!`b`)) return false; var alen = `a`.length; if (alen != `b`.length) return false; @@ -516,8 +519,11 @@ proc nimCopyAux(dest, src: JSRef, n: ptr TNimNode) {.compilerproc.} = `dest`[`n`.offset] = nimCopy(`dest`[`n`.offset], `src`[`n`.offset], `n`.typ); """ of nkList: - for i in 0..n.len-1: - nimCopyAux(dest, src, n.sons[i]) + asm """ + for (var i = 0; i < `n`.sons.length; i++) { + nimCopyAux(`dest`, `src`, `n`.sons[i]); + } + """ of nkCase: asm """ `dest`[`n`.offset] = nimCopy(`dest`[`n`.offset], `src`[`n`.offset], `n`.typ); |