diff options
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) + } + } } |