diff options
author | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2015-09-14 20:32:09 +0300 |
---|---|---|
committer | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2015-09-14 20:32:09 +0300 |
commit | 6ac2ba122366bdd320b1ab6ce7a6ca3cbb362800 (patch) | |
tree | cb19711283560489477ecbfaf87002ef9e952d68 /compiler | |
parent | fa177076842d5a5e7900469d6b5ec0e2e432d17c (diff) | |
download | Nim-6ac2ba122366bdd320b1ab6ce7a6ca3cbb362800.tar.gz |
Uint64 to string in pure nim. array[char] to string fixed in vm.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/vm.nim | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim index 0db287c6a..4dd3b5232 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -320,8 +320,19 @@ proc opConv*(dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool = dest.node.strVal = if src.intVal == 0: "false" else: "true" of tyFloat..tyFloat128: dest.node.strVal = $src.floatVal - of tyString, tyCString: + of tyString: dest.node.strVal = src.node.strVal + of tyCString: + if src.node.kind == nkBracket: + # Array of chars + var strVal = "" + for son in src.node.sons: + let c = char(son.intVal) + if c == '\0': break + strVal.add(c) + dest.node.strVal = strVal + else: + dest.node.strVal = src.node.strVal of tyChar: dest.node.strVal = $chr(src.intVal) else: |