diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-03-15 22:06:26 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2015-03-15 22:06:26 +0000 |
commit | 1e9ab3bb0af9f6e361bd9f7b8f53802f30d68f15 (patch) | |
tree | 450559883ce179a16bbf113dedf67e80687dd22f /lib/system/jssys.nim | |
parent | faad6ed67ffcb450c8ab5b2697c917990686f80a (diff) | |
download | Nim-1e9ab3bb0af9f6e361bd9f7b8f53802f30d68f15.tar.gz |
Fixes #2323. Fixes #2148.
Diffstat (limited to 'lib/system/jssys.nim')
-rw-r--r-- | lib/system/jssys.nim | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 15b00f8f1..3b55f62ca 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -322,10 +322,10 @@ when defined(kwin): } print(buf); """ - + elif defined(nodejs): proc ewriteln(x: cstring) = log(x) - + proc rawEcho {.compilerproc, asmNoStackFrame.} = asm """ var buf = ""; @@ -339,12 +339,12 @@ else: var document {.importc, nodecl.}: ref TDocument - proc ewriteln(x: cstring) = + proc ewriteln(x: cstring) = var node = document.getElementsByTagName("body")[0] - if node != nil: + if node != nil: node.appendChild(document.createTextNode(x)) node.appendChild(document.createElement("br")) - else: + else: raise newException(ValueError, "<body> element does not exist yet!") proc rawEcho {.compilerproc.} = @@ -563,7 +563,11 @@ proc nimCopy(x: pointer, ti: PNimType): pointer = } """ of tyString: - asm "`result` = `x`.slice(0);" + asm """ + if (`x` !== null) { + `result` = `x`.slice(0); + } + """ else: result = x @@ -679,7 +683,7 @@ proc nimParseBiggestFloat(s: string, number: var BiggestFloat, start = 0): int { if s[i] == 'I' or s[i] == 'i': if s[i+1] == 'N' or s[i+1] == 'n': if s[i+2] == 'F' or s[i+2] == 'f': - if s[i+3] notin IdentChars: + if s[i+3] notin IdentChars: number = Inf*sign return i+3 - start return 0 |