diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-25 10:36:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 10:36:08 +0000 |
commit | d54ca716854b30c6a6431310d7f1726073ecee25 (patch) | |
tree | f544810a9ef95704b724dff03ddb4308283a79ed /gcc/rust/backend | |
parent | bbbd15a4a137ac096edfbe5bfe7885b91037f128 (diff) | |
parent | 23db789ecb574e702ca3f3aea6b7d6f9ddbe99cd (diff) | |
download | gcc-d54ca716854b30c6a6431310d7f1726073ecee25.zip gcc-d54ca716854b30c6a6431310d7f1726073ecee25.tar.gz gcc-d54ca716854b30c6a6431310d7f1726073ecee25.tar.bz2 |
Merge #1160
1160: Refactor name resolver r=CohenArthur a=CohenArthur
This PR splits up the `rust-name-resolver.h` file into source and header. It also removes a bunch of `iterate_*` functions: Some were not used anymore, and some were refactored.
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.cc | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 4f55b22..b969b7a 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -333,33 +333,33 @@ HIRCompileBase::compile_locals_for_block (Context *ctx, Resolver::Rib &rib, tree fndecl) { std::vector<Bvariable *> locals; - rib.iterate_decls ([&] (NodeId n, Location) mutable -> bool { - Resolver::Definition d; - bool ok = ctx->get_resolver ()->lookup_definition (n, &d); - rust_assert (ok); - - HIR::Stmt *decl = nullptr; - ok = ctx->get_mappings ()->resolve_nodeid_to_stmt (d.parent, &decl); - rust_assert (ok); - - // if its a function we extract this out side of this fn context - // and it is not a local to this function - bool is_item = ctx->get_mappings ()->lookup_hir_item ( - decl->get_mappings ().get_crate_num (), - decl->get_mappings ().get_hirid ()) - != nullptr; - if (is_item) - { - HIR::Item *item = static_cast<HIR::Item *> (decl); - CompileItem::compile (item, ctx); - return true; - } - - Bvariable *compiled = CompileVarDecl::compile (fndecl, decl, ctx); - locals.push_back (compiled); + for (auto it : rib.get_declarations ()) + { + auto node_id = it.first; + + Resolver::Definition d; + bool ok = ctx->get_resolver ()->lookup_definition (node_id, &d); + rust_assert (ok); + + HIR::Stmt *decl = nullptr; + ok = ctx->get_mappings ()->resolve_nodeid_to_stmt (d.parent, &decl); + rust_assert (ok); + + // if its a function we extract this out side of this fn context + // and it is not a local to this function + bool is_item = ctx->get_mappings ()->lookup_hir_item ( + decl->get_mappings ().get_crate_num (), + decl->get_mappings ().get_hirid ()) + != nullptr; + if (is_item) + { + HIR::Item *item = static_cast<HIR::Item *> (decl); + CompileItem::compile (item, ctx); + } - return true; - }); + Bvariable *compiled = CompileVarDecl::compile (fndecl, decl, ctx); + locals.push_back (compiled); + }; return locals; } |