diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-01-16 18:26:36 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-01-17 14:21:59 +0000 |
commit | 7066c0eca18f99aca3e88a08b2aaf71d970d0ab6 (patch) | |
tree | 6a7626091cb903a168937d15138e998ed5b79d78 /gcc/rust/hir/rust-ast-lower-expr.h | |
parent | a79e3b31be51d16c6dcc87722d35fe8cc3227355 (diff) | |
download | gcc-7066c0eca18f99aca3e88a08b2aaf71d970d0ab6.zip gcc-7066c0eca18f99aca3e88a08b2aaf71d970d0ab6.tar.gz gcc-7066c0eca18f99aca3e88a08b2aaf71d970d0ab6.tar.bz2 |
Support GroupedExpr's
This makes the expression handling support exprs within parens. Such as:
x = (2*a) + 3;
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower-expr.h')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-expr.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h index 701efd5..1003e8c 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.h +++ b/gcc/rust/hir/rust-ast-lower-expr.h @@ -525,6 +525,25 @@ public: inner_attribs, outer_attribs); } + void visit (AST::GroupedExpr &expr) + { + std::vector<HIR::Attribute> inner_attribs; + std::vector<HIR::Attribute> outer_attribs; + + HIR::Expr *paren_expr + = ASTLoweringExpr::translate (expr.get_expr_in_parens ().get ()); + + auto crate_num = mappings->get_current_crate (); + Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), + mappings->get_next_hir_id (crate_num), + UNKNOWN_LOCAL_DEFID); + + translated + = new HIR::GroupedExpr (mapping, std::unique_ptr<HIR::Expr> (paren_expr), + std::move (inner_attribs), + std::move (outer_attribs), expr.get_locus ()); + } + private: ASTLoweringExpr () : translated (nullptr), translated_array_elems (nullptr), terminated (false) |