diff options
Diffstat (limited to 'gcc/rust/hir/tree/rust-hir-expr.h')
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-expr.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index 8a2d82f..1ee1066 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -93,6 +93,7 @@ class LiteralExpr : public ExprWithoutBlock { Literal literal; location_t locus; + bool negative_number = false; public: std::string as_string () const override @@ -132,6 +133,14 @@ public: ExprType get_expression_type () const override final { return ExprType::Lit; } + bool is_negative () const { return negative_number; } + void set_negative () + { + rust_assert (get_lit_type () == Literal::LitType::INT + || get_lit_type () == Literal::LitType::FLOAT); + negative_number = true; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ |