diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-11-13 12:31:23 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-11-13 12:32:59 +0100 |
commit | 37c05b71299ec00bd2679c3df22fb6ca0cd0e371 (patch) | |
tree | 7e20df47455a342e454fb9fdbaa1e710fba7fd81 /src/codegen/helpers.rs | |
parent | bdfab643e70df469dd0d163cc91bf48955250735 (diff) |
codegen: Special-case i64::MIN since it produces a overflow on aster.
Proper fix on aster soon, still worth to get this in I guess.
r? @fitzgen
Diffstat (limited to 'src/codegen/helpers.rs')
-rw-r--r-- | src/codegen/helpers.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index 016ba478..6e5a6f0e 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -117,4 +117,19 @@ pub mod ast_ty { } } } + + pub fn int_expr(val: i64) -> P<ast::Expr> { + use std::i64; + let expr = aster::AstBuilder::new().expr(); + + // This is not representable as an i64 if it's negative, so we + // special-case it. + // + // Fix in aster incoming. + if val == i64::MIN { + expr.neg().uint(1u64 << 63) + } else { + expr.int(val) + } + } } |