diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-09-04 16:13:31 -0400 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-09-07 20:48:58 +0000 |
commit | 8da5a49a0ee5842c4abd0b079ee837290c420814 (patch) | |
tree | 603b90ce560d4a91e5e9196f499a8274faa91e07 /gcc/rust/backend/rust-compile-block.cc | |
parent | b6284bd9ff6f54136e6a88c261546a2b6ff12572 (diff) | |
download | gcc-8da5a49a0ee5842c4abd0b079ee837290c420814.zip gcc-8da5a49a0ee5842c4abd0b079ee837290c420814.tar.gz gcc-8da5a49a0ee5842c4abd0b079ee837290c420814.tar.bz2 |
Convert class Backend into namespace
gcc/rust/ChangeLog:
* rust-backend.h
(class Backend): Convert to ...
(namespace Backend): ... namespace.
* rust-gcc.cc
(Backend::Backend): Rename to ...
(Backend::init): ... here.
(rust_get_backend): Remove.
* rust-session-manager.cc
(rust_get_backend): Remove.
(Session::init): Use Backend::init instead of rust_get_backend.
(Session::compile_crate):
Initialize Context without pointer to Backend.
* rust-session-manager.h
(Session::backend): Remove.
* backend/rust-compile-context.cc
(Context::Context): Remove pointer to Backend.
* backend/rust-compile-context.h
(class Context): Remove pointer to Backend, update function calls.
* backend/rust-compile-base.cc: Update function calls.
* backend/rust-compile-block.cc: Likewise.
* backend/rust-compile-expr.cc: Likewise.
* backend/rust-compile-extern.h: Likewise.
* backend/rust-compile-fnparam.cc: Likewise.
* backend/rust-compile-intrinsic.cc: Likewise.
* backend/rust-compile-item.cc: Likewise.
* backend/rust-compile-pattern.cc: Likewise.
* backend/rust-compile-resolve-path.cc: Likewise.
* backend/rust-compile-type.cc: Likewise.
* backend/rust-compile-var-decl.h: Likewise.
* backend/rust-compile.cc: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-block.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-block.cc | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/gcc/rust/backend/rust-compile-block.cc b/gcc/rust/backend/rust-compile-block.cc index 9bfb0cf..a93e0bb 100644 --- a/gcc/rust/backend/rust-compile-block.cc +++ b/gcc/rust/backend/rust-compile-block.cc @@ -55,8 +55,8 @@ CompileBlock::visit (HIR::BlockExpr &expr) = compile_locals_for_block (ctx, *rib, fndecl); tree enclosing_scope = ctx->peek_enclosing_scope (); - tree new_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, - start_location, end_location); + tree new_block = Backend::block (fndecl, enclosing_scope, locals, + start_location, end_location); ctx->push_block (new_block); for (auto &s : expr.get_statements ()) @@ -75,13 +75,11 @@ CompileBlock::visit (HIR::BlockExpr &expr) if (result != nullptr) { location_t locus = expr.get_final_expr ()->get_locus (); - tree result_reference - = ctx->get_backend ()->var_expression (result, locus); + tree result_reference = Backend::var_expression (result, locus); tree assignment - = ctx->get_backend ()->assignment_statement (result_reference, - compiled_expr, - expr.get_locus ()); + = Backend::assignment_statement (result_reference, compiled_expr, + expr.get_locus ()); ctx->add_statement (assignment); } } @@ -89,13 +87,11 @@ CompileBlock::visit (HIR::BlockExpr &expr) { location_t locus = expr.get_locus (); tree compiled_expr = unit_expression (ctx, expr.get_locus ()); - tree result_reference - = ctx->get_backend ()->var_expression (result, locus); + tree result_reference = Backend::var_expression (result, locus); tree assignment - = ctx->get_backend ()->assignment_statement (result_reference, - compiled_expr, - expr.get_locus ()); + = Backend::assignment_statement (result_reference, compiled_expr, + expr.get_locus ()); ctx->add_statement (assignment); } @@ -113,9 +109,8 @@ CompileConditionalBlocks::visit (HIR::IfExpr &expr) tree then_block = CompileBlock::compile (expr.get_if_block ().get (), ctx, result); - translated - = ctx->get_backend ()->if_statement (fndecl, condition_expr, then_block, - NULL, expr.get_locus ()); + translated = Backend::if_statement (fndecl, condition_expr, then_block, NULL, + expr.get_locus ()); } void @@ -133,8 +128,8 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqElse &expr) location_t start_location = expr.get_else_block ()->get_locus (); location_t end_location = expr.get_else_block ()->get_locus (); // FIXME tree enclosing_scope = ctx->peek_enclosing_scope (); - tree else_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, - start_location, end_location); + tree else_block = Backend::block (fndecl, enclosing_scope, locals, + start_location, end_location); ctx->push_block (else_block); tree else_stmt_decl @@ -145,9 +140,8 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqElse &expr) ctx->pop_block (); - translated - = ctx->get_backend ()->if_statement (fndecl, condition_expr, then_block, - else_block, expr.get_locus ()); + translated = Backend::if_statement (fndecl, condition_expr, then_block, + else_block, expr.get_locus ()); } } // namespace Compile |