diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-22 16:28:26 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-04-22 16:28:26 +0200 |
commit | 3001bb64cc25e9174cf69ad5e12df17ad45ef6b8 (patch) | |
tree | 07b79b4659b34f34dae6bd07e2fedbf794306444 /gcc/rust/backend | |
parent | a936265bb0e6e042733c501db942615f2a64f705 (diff) | |
download | gcc-3001bb64cc25e9174cf69ad5e12df17ad45ef6b8.zip gcc-3001bb64cc25e9174cf69ad5e12df17ad45ef6b8.tar.gz gcc-3001bb64cc25e9174cf69ad5e12df17ad45ef6b8.tar.bz2 |
resolver: Refactor Rib class in a source file
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 84afa1e..1ee7cd5 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -306,33 +306,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; } |