diff options
author | SimplyTheOther <simplytheother@gmail.com> | 2021-01-10 14:30:39 +0800 |
---|---|---|
committer | SimplyTheOther <simplytheother@gmail.com> | 2021-01-10 14:30:39 +0800 |
commit | b247c0d5aadf6eb7323641ffbcf7cc67bedd2c52 (patch) | |
tree | 3a4d3a0b0569d28f679ecbc74928125034d50f4f /gcc/rust/hir/rust-ast-lower-expr.h | |
parent | ee85db852a5a819e559ab00e7a382a34e925447a (diff) | |
parent | 0f42a240e53e932de0ae4799d54fe0bd15d06047 (diff) | |
download | gcc-b247c0d5aadf6eb7323641ffbcf7cc67bedd2c52.zip gcc-b247c0d5aadf6eb7323641ffbcf7cc67bedd2c52.tar.gz gcc-b247c0d5aadf6eb7323641ffbcf7cc67bedd2c52.tar.bz2 |
Merge branch 'master' of https://github.com/redbrain/gccrs
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower-expr.h')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-expr.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h index 87ba0dc..51bf108 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.h +++ b/gcc/rust/hir/rust-ast-lower-expr.h @@ -107,7 +107,7 @@ private: class ASTLoweringExpr : public ASTLoweringBase { public: - static HIR::Expr *translate (AST::Expr *expr) + static HIR::Expr *translate (AST::Expr *expr, bool *terminated = nullptr) { ASTLoweringExpr resolver; expr->accept_vis (resolver); @@ -121,6 +121,13 @@ public: resolver.mappings->insert_hir_expr ( resolver.translated->get_mappings ().get_crate_num (), resolver.translated->get_mappings ().get_hirid (), resolver.translated); + resolver.mappings->insert_location ( + resolver.translated->get_mappings ().get_crate_num (), + resolver.translated->get_mappings ().get_hirid (), + expr->get_locus_slow ()); + + if (terminated != nullptr) + *terminated = resolver.terminated; return resolver.translated; } @@ -129,22 +136,22 @@ public: void visit (AST::IfExpr &expr) { - translated = ASTLoweringIfBlock::translate (&expr); + translated = ASTLoweringIfBlock::translate (&expr, &terminated); } void visit (AST::IfExprConseqElse &expr) { - translated = ASTLoweringIfBlock::translate (&expr); + translated = ASTLoweringIfBlock::translate (&expr, &terminated); } void visit (AST::IfExprConseqIf &expr) { - translated = ASTLoweringIfBlock::translate (&expr); + translated = ASTLoweringIfBlock::translate (&expr, &terminated); } void visit (AST::BlockExpr &expr) { - translated = ASTLoweringBlock::translate (&expr); + translated = ASTLoweringBlock::translate (&expr, &terminated); } void visit (AST::PathInExpression &expr) @@ -154,6 +161,7 @@ public: void visit (AST::ReturnExpr &expr) { + terminated = true; HIR::Expr *return_expr = expr.has_returned_expr () ? ASTLoweringExpr::translate (expr.get_returned_expr ().get ()) @@ -498,10 +506,13 @@ public: } private: - ASTLoweringExpr () : translated (nullptr), translated_array_elems (nullptr) {} + ASTLoweringExpr () + : translated (nullptr), translated_array_elems (nullptr), terminated (false) + {} HIR::Expr *translated; HIR::ArrayElems *translated_array_elems; + bool terminated; }; } // namespace HIR |