on master help sign in
Fix truncation of Integer in C codegen
commit10da5a2b3adf5447c1040f2d63484511dc376768 authorBenjamin Saunders <besaunde@sfu.ca> dateTue 25 Jun 2013, 01:00 (13 years ago) parent1b589f8
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