diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-12-21 00:37:48 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-12-21 00:37:48 +0100 |
commit | 17a78f4f8d9f8d3e4f3cd115111d116f03647966 (patch) | |
tree | 5e5c001365421762e7269454f9541cd85531f86d /compiler/vm.nim | |
parent | ca0715082c24a90d7292d3b95cfd70de966f4f62 (diff) | |
parent | 26d02c9120c54e0c1a92e08b9b571a89c9f1d4ff (diff) | |
download | Nim-17a78f4f8d9f8d3e4f3cd115111d116f03647966.tar.gz |
Merge pull request #3654 from jangko/vm_uinttouint64conv
fixed #2514 unable to echo uint8-32 at compile time
Diffstat (limited to 'compiler/vm.nim')
-rw-r--r-- | compiler/vm.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim index 0e63daf89..895653652 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -359,7 +359,14 @@ proc opConv*(dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool = of tyFloat..tyFloat64: dest.intVal = int(src.floatVal) else: - dest.intVal = src.intVal and ((1 shl (desttyp.size*8))-1) + let srcDist = (sizeof(src.intVal) - srctyp.size) * 8 + let destDist = (sizeof(dest.intVal) - desttyp.size) * 8 + when system.cpuEndian == bigEndian: + dest.intVal = (src.intVal shr srcDist) shl srcDist + dest.intVal = (dest.intVal shr destDist) shl destDist + else: + dest.intVal = (src.intVal shl srcDist) shr srcDist + dest.intVal = (dest.intVal shl destDist) shr destDist of tyFloat..tyFloat64: if dest.kind != rkFloat: myreset(dest); dest.kind = rkFloat |