aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-01-23 11:43:31 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-01-30 12:06:37 +0000
commit51a2da3d567dfbc70e9407276dfabc0b963ad420 (patch)
tree15e1526300e8952b0e918e621e3a98c9e9862c80 /gcc
parentad46f0871d80966a1dd1adf7bf444c99f094d42a (diff)
downloadgcc-51a2da3d567dfbc70e9407276dfabc0b963ad420.zip
gcc-51a2da3d567dfbc70e9407276dfabc0b963ad420.tar.gz
gcc-51a2da3d567dfbc70e9407276dfabc0b963ad420.tar.bz2
ast: Add new Expr::Kinds
Collapses all of the OperatorExprs into Expr instead of first having to check for OperatorExpr and then check for each OperatorExpr::Kind. gcc/rust/ChangeLog: * ast/rust-ast.h: Add new Expr::Kinds. * ast/rust-expr.h: Implement missing get_expr_kind(), Add get_function_expr_ptr()
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast.h10
-rw-r--r--gcc/rust/ast/rust-expr.h31
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 2d907e2..e3999db 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1263,6 +1263,16 @@ public:
Identifier,
FormatArgs,
MacroInvocation,
+ Borrow,
+ Dereference,
+ ErrorPropagation,
+ Negation,
+ ArithmeticOrLogical,
+ Comparison,
+ LazyBoolean,
+ TypeCast,
+ Assignment,
+ CompoundAssignment,
};
virtual Kind get_expr_kind () const = 0;
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 852c3f3..cff09fe 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -407,6 +407,8 @@ public:
bool get_is_double_borrow () const { return double_borrow; }
bool is_raw_borrow () const { return raw_borrow; }
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::Borrow; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -437,6 +439,8 @@ public:
return *main_or_left_expr;
}
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::Dereference; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -468,6 +472,11 @@ public:
return *main_or_left_expr;
}
+ Expr::Kind get_expr_kind () const override
+ {
+ return Expr::Kind::ErrorPropagation;
+ }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -511,6 +520,8 @@ public:
return *main_or_left_expr;
}
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::Negation; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -599,6 +610,11 @@ public:
void visit_lhs (ASTVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (ASTVisitor &vis) { right_expr->accept_vis (vis); }
+ Expr::Kind get_expr_kind () const override
+ {
+ return Expr::Kind::ArithmeticOrLogical;
+ }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -686,6 +702,8 @@ public:
ExprType get_kind () { return expr_type; }
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::Comparison; }
+
/* TODO: implement via a function call to std::cmp::PartialEq::eq(&op1, &op2)
* maybe? */
protected:
@@ -774,6 +792,8 @@ public:
ExprType get_kind () { return expr_type; }
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::LazyBoolean; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -836,6 +856,8 @@ public:
return *type_to_convert_to;
}
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::TypeCast; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -914,6 +936,8 @@ public:
return *right_expr;
}
+ Expr::Kind get_expr_kind () const override { return Expr::Kind::Assignment; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -1000,6 +1024,11 @@ public:
return right_expr;
}
+ Expr::Kind get_expr_kind () const override
+ {
+ return Expr::Kind::CompoundAssignment;
+ }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -2139,6 +2168,8 @@ public:
return *function;
}
+ std::unique_ptr<Expr> &get_function_expr_ptr () { return function; }
+
const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
std::vector<Attribute> &get_outer_attrs () override { return outer_attrs; }