This commit is contained in:
Dominik Picheta 2015-03-15 22:06:26 +00:00
commit 1e9ab3bb0a
3 changed files with 53 additions and 13 deletions

View file

@ -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