on master help sign in
Merge pull request #346 from bitlisp/fixed-bigint-trunc

Fix truncation of Integer in C codegen

commit8b380635df53212463a22ad929f83c266a3995d3 authorEdwin Brady <edwin.brady@gmail.com> dateTue 25 Jun 2013, 13:16 (13 years ago) parente221d0810da5a2
1 file changed+1−1
src/IRTS/CodegenC.hs+1−1
src/IRTS/CodegenC.hs+1−1
@@ -352,7 +352,7 @@ doOp v (LZExt from to) [x]
352352 | intTyWidth from < intTyWidth to = bitCoerce v "Z" from to x
353353doOp v (LTrunc ITNative to) [x] = v ++ "idris_b" ++ show (intTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
354354doOp v (LTrunc from ITNative) [x] = v ++ "MKINT((i_int)" ++ creg x ++ "->info.bits" ++ show (intTyWidth from) ++ ")"
355−doOp v (LTrunc ITBig to) [x] = v ++ "idris_b" ++ show (intTyWidth to) ++ "const(vm, mpz_get_ui(GETMPZ(" ++ creg x ++ "))"
355+doOp v (LTrunc ITBig to) [x] = v ++ "idris_b" ++ show (intTyWidth to) ++ "const(vm, ISINT(" ++ creg x ++ ") ? GETINT(" ++ creg x ++ ") : mpz_get_ui(GETMPZ(" ++ creg x ++ ")))"
356356doOp v (LTrunc from to) [x]
357357 | intTyWidth from > intTyWidth to = bitCoerce v "T" from to x
358358