This commit is contained in:
flywind 2021-01-11 08:07:48 -06:00 • committed by GitHub
commit aa185c0e9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View file

@ -429,13 +429,13 @@ proc opConv(c: PCtx; dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType):
return true
of tyUInt..tyUInt64:
dest.ensureKind(rkInt)
case skipTypes(srctyp, abstractRange).kind
let styp = srctyp.skipTypes(abstractRange) # skip distinct types(dest type could do this too if needed)
case styp.kind
of tyFloat..tyFloat64:
dest.intVal = int(src.floatVal)
else:
let srcDist = (sizeof(src.intVal) - srctyp.size) * 8
let srcDist = (sizeof(src.intVal) - styp.size) * 8
let destDist = (sizeof(dest.intVal) - desttyp.size) * 8
var value = cast[BiggestUInt](src.intVal)
value = (value shl srcDist) shr srcDist
value = (value shl destDist) shr destDist