|
24 | 24 | #include "rust-hir-item.h"
|
25 | 25 | #include "rust-hir-type-check.h"
|
26 | 26 | #include "rust-hir-visitor.h"
|
27 |
| -#include "rust-name-resolver.h" |
28 | 27 | #include "rust-bir.h"
|
29 | 28 | #include "rust-bir-free-region.h"
|
30 | 29 | #include "rust-immutable-name-resolution-context.h"
|
@@ -75,7 +74,7 @@ struct BuilderContext
|
75 | 74 |
|
76 | 75 | // External context.
|
77 | 76 | Resolver::TypeCheckContext &tyctx;
|
78 |
| - Resolver::Resolver &resolver; |
| 77 | + const Resolver2_0::NameResolutionContext &resolver; |
79 | 78 |
|
80 | 79 | // BIR output
|
81 | 80 | BasicBlocks basic_blocks;
|
@@ -104,7 +103,7 @@ struct BuilderContext
|
104 | 103 | public:
|
105 | 104 | BuilderContext ()
|
106 | 105 | : tyctx (*Resolver::TypeCheckContext::get ()),
|
107 |
| - resolver (*Resolver::Resolver::get ()) |
| 106 | + resolver (Resolver2_0::ImmutableNameResolutionContext::get ().resolver ()) |
108 | 107 | {
|
109 | 108 | basic_blocks.emplace_back (); // StartBB
|
110 | 109 | }
|
@@ -403,69 +402,31 @@ class AbstractBuilder
|
403 | 402 |
|
404 | 403 | template <typename T> NodeId resolve_label (T &expr)
|
405 | 404 | {
|
406 |
| - NodeId resolved_label; |
407 |
| - if (flag_name_resolution_2_0) |
408 |
| - { |
409 |
| - auto &nr_ctx |
410 |
| - = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); |
411 |
| - auto res = nr_ctx.lookup (expr.get_mappings ().get_nodeid ()); |
412 |
| - rust_assert (res.has_value ()); |
413 |
| - resolved_label = res.value (); |
414 |
| - } |
415 |
| - else |
416 |
| - { |
417 |
| - bool ok = ctx.resolver.lookup_resolved_label ( |
418 |
| - expr.get_mappings ().get_nodeid (), &resolved_label); |
419 |
| - rust_assert (ok); |
420 |
| - } |
421 |
| - return resolved_label; |
| 405 | + auto res = ctx.resolver.lookup (expr.get_mappings ().get_nodeid ()); |
| 406 | + rust_assert (res.has_value ()); |
| 407 | + return res.value (); |
422 | 408 | }
|
423 | 409 |
|
424 | 410 | template <typename T> PlaceId resolve_variable (T &variable)
|
425 | 411 | {
|
426 |
| - NodeId variable_id; |
427 |
| - if (flag_name_resolution_2_0) |
428 |
| - { |
429 |
| - auto &nr_ctx |
430 |
| - = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); |
431 |
| - auto res = nr_ctx.lookup (variable.get_mappings ().get_nodeid ()); |
432 |
| - rust_assert (res.has_value ()); |
433 |
| - variable_id = res.value (); |
434 |
| - } |
435 |
| - else |
436 |
| - { |
437 |
| - bool ok = ctx.resolver.lookup_resolved_name ( |
438 |
| - variable.get_mappings ().get_nodeid (), &variable_id); |
439 |
| - rust_assert (ok); |
440 |
| - } |
441 |
| - return ctx.place_db.lookup_variable (variable_id); |
| 412 | + auto res = ctx.resolver.lookup (variable.get_mappings ().get_nodeid ()); |
| 413 | + rust_assert (res.has_value ()); |
| 414 | + return ctx.place_db.lookup_variable (res.value ()); |
442 | 415 | }
|
443 | 416 |
|
444 | 417 | template <typename T>
|
445 | 418 | PlaceId resolve_variable_or_fn (T &variable, TyTy::BaseType *ty)
|
446 | 419 | {
|
447 | 420 | ty = (ty) ? ty : lookup_type (variable);
|
| 421 | + |
448 | 422 | // Unlike variables,
|
449 | 423 | // functions do not have to be declared in PlaceDB before use.
|
450 |
| - NodeId variable_id; |
451 |
| - if (flag_name_resolution_2_0) |
452 |
| - { |
453 |
| - auto &nr_ctx |
454 |
| - = Resolver2_0::ImmutableNameResolutionContext::get ().resolver (); |
455 |
| - auto res = nr_ctx.lookup (variable.get_mappings ().get_nodeid ()); |
456 |
| - rust_assert (res.has_value ()); |
457 |
| - variable_id = res.value (); |
458 |
| - } |
459 |
| - else |
460 |
| - { |
461 |
| - bool ok = ctx.resolver.lookup_resolved_name ( |
462 |
| - variable.get_mappings ().get_nodeid (), &variable_id); |
463 |
| - rust_assert (ok); |
464 |
| - } |
465 | 424 | if (ty->is<TyTy::FnType> ())
|
466 | 425 | return ctx.place_db.get_constant (ty);
|
467 |
| - else |
468 |
| - return ctx.place_db.lookup_or_add_variable (variable_id, ty); |
| 426 | + |
| 427 | + auto res = ctx.resolver.lookup (variable.get_mappings ().get_nodeid ()); |
| 428 | + rust_assert (res.has_value ()); |
| 429 | + return ctx.place_db.lookup_or_add_variable (res.value (), ty); |
469 | 430 | }
|
470 | 431 |
|
471 | 432 | protected: // Implicit conversions.
|
|
0 commit comments