aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r--gcc/rust/backend/rust-compile.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 69245dc..2630c0f 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -288,9 +288,36 @@ Compilation::visit (AST::DereferenceExpr &expr)
void
Compilation::visit (AST::ErrorPropagationExpr &expr)
{}
+
void
Compilation::visit (AST::NegationExpr &expr)
-{}
+{
+ Bexpression *root = NULL;
+ VISIT_POP (expr.get_expr ()->get_locus_slow (), expr.get_expr (), root,
+ exprs);
+ if (root == NULL)
+ {
+ rust_error_at (expr.get_expr ()->get_locus_slow (), "failed to compile");
+ return;
+ }
+
+ Operator op;
+ switch (expr.negation_type)
+ {
+ case AST::NegationExpr::NEGATE:
+ op = OPERATOR_MINUS;
+ break;
+ case AST::NegationExpr::NOT:
+ op = OPERATOR_NOT;
+ break;
+ default:
+ rust_fatal_error (expr.get_locus_slow (), "failed to compile operator");
+ return;
+ }
+
+ auto unary = backend->unary_expression (op, root, expr.get_locus_slow ());
+ exprs.push_back (unary);
+}
void
Compilation::visit (AST::ArithmeticOrLogicalExpr &expr)