@@ -442,7 +442,7 @@ struct Module {
442
442
anonymous_children : RefCell < HashMap < NodeId , @Module > > ,
443
443
444
444
// The status of resolving each import in this module.
445
- import_resolutions : @ mut HashMap < Name , @mut ImportResolution > ,
445
+ import_resolutions : RefCell < HashMap < Name , @mut ImportResolution > > ,
446
446
447
447
// The number of unresolved globs that this module exports.
448
448
glob_count : Cell < uint > ,
@@ -472,7 +472,7 @@ impl Module {
472
472
imports : @mut ~[ ] ,
473
473
external_module_children : RefCell :: new ( HashMap :: new ( ) ) ,
474
474
anonymous_children : RefCell :: new ( HashMap :: new ( ) ) ,
475
- import_resolutions : @ mut HashMap :: new ( ) ,
475
+ import_resolutions : RefCell :: new ( HashMap :: new ( ) ) ,
476
476
glob_count : Cell :: new ( 0 ) ,
477
477
resolved_import_count : Cell :: new ( 0 ) ,
478
478
populated : Cell :: new ( !external) ,
@@ -1951,7 +1951,9 @@ impl Resolver {
1951
1951
self . idents_to_str( directive. module_path) ,
1952
1952
self . session. str_of( target) ) ;
1953
1953
1954
- match module_. import_resolutions . find ( & target. name ) {
1954
+ let mut import_resolutions = module_. import_resolutions
1955
+ . borrow_mut ( ) ;
1956
+ match import_resolutions. get ( ) . find ( & target. name ) {
1955
1957
Some ( & resolution) => {
1956
1958
debug ! ( "(building import directive) bumping \
1957
1959
reference") ;
@@ -1965,7 +1967,8 @@ impl Resolver {
1965
1967
debug ! ( "(building import directive) creating new" ) ;
1966
1968
let resolution = @mut ImportResolution :: new ( id, is_public) ;
1967
1969
resolution. outstanding_references = 1 ;
1968
- module_. import_resolutions . insert ( target. name , resolution) ;
1970
+ import_resolutions. get ( ) . insert ( target. name ,
1971
+ resolution) ;
1969
1972
}
1970
1973
}
1971
1974
}
@@ -2290,7 +2293,9 @@ impl Resolver {
2290
2293
// Now search the exported imports within the containing
2291
2294
// module.
2292
2295
2293
- match containing_module. import_resolutions . find ( & source. name ) {
2296
+ let import_resolutions = containing_module. import_resolutions
2297
+ . borrow ( ) ;
2298
+ match import_resolutions. get ( ) . find ( & source. name ) {
2294
2299
None => {
2295
2300
// The containing module definitely doesn't have an
2296
2301
// exported import with the name in question. We can
@@ -2385,8 +2390,11 @@ impl Resolver {
2385
2390
}
2386
2391
2387
2392
// We've successfully resolved the import. Write the results in.
2388
- assert ! ( module_. import_resolutions. contains_key( & target. name) ) ;
2389
- let import_resolution = module_. import_resolutions . get ( & target. name ) ;
2393
+ let import_resolution = {
2394
+ let import_resolutions = module_. import_resolutions . borrow ( ) ;
2395
+ assert ! ( import_resolutions. get( ) . contains_key( & target. name) ) ;
2396
+ import_resolutions. get ( ) . get_copy ( & target. name )
2397
+ } ;
2390
2398
2391
2399
match value_result {
2392
2400
BoundResult ( target_module, name_bindings) => {
@@ -2484,8 +2492,10 @@ impl Resolver {
2484
2492
assert_eq ! ( containing_module. glob_count. get( ) , 0 ) ;
2485
2493
2486
2494
// Add all resolved imports from the containing module.
2487
- for ( ident, target_import_resolution) in containing_module. import_resolutions . iter ( ) {
2488
-
2495
+ let import_resolutions = containing_module. import_resolutions
2496
+ . borrow ( ) ;
2497
+ for ( ident, target_import_resolution) in import_resolutions. get ( )
2498
+ . iter ( ) {
2489
2499
debug ! ( "(resolving glob import) writing module resolution \
2490
2500
{:?} into `{}`",
2491
2501
target_import_resolution. type_target. is_none( ) ,
@@ -2497,7 +2507,9 @@ impl Resolver {
2497
2507
}
2498
2508
2499
2509
// Here we merge two import resolutions.
2500
- match module_. import_resolutions . find ( ident) {
2510
+ let mut import_resolutions = module_. import_resolutions
2511
+ . borrow_mut ( ) ;
2512
+ match import_resolutions. get ( ) . find ( ident) {
2501
2513
None => {
2502
2514
// Simple: just copy the old import resolution.
2503
2515
let new_import_resolution =
@@ -2507,7 +2519,7 @@ impl Resolver {
2507
2519
new_import_resolution. type_target =
2508
2520
target_import_resolution. type_target ;
2509
2521
2510
- module_ . import_resolutions . insert
2522
+ import_resolutions. get ( ) . insert
2511
2523
( * ident, new_import_resolution) ;
2512
2524
}
2513
2525
Some ( & dest_import_resolution) => {
@@ -2539,13 +2551,15 @@ impl Resolver {
2539
2551
2540
2552
let merge_import_resolution = |name, name_bindings : @NameBindings | {
2541
2553
let dest_import_resolution;
2542
- match module_. import_resolutions . find ( & name) {
2554
+ let mut import_resolutions = module_. import_resolutions
2555
+ . borrow_mut ( ) ;
2556
+ match import_resolutions. get ( ) . find ( & name) {
2543
2557
None => {
2544
2558
// Create a new import resolution from this child.
2545
2559
dest_import_resolution = @mut ImportResolution :: new ( id,
2546
2560
is_public) ;
2547
- module_ . import_resolutions . insert
2548
- ( name , dest_import_resolution) ;
2561
+ import_resolutions. get ( ) . insert ( name ,
2562
+ dest_import_resolution) ;
2549
2563
}
2550
2564
Some ( & existing_import_resolution) => {
2551
2565
dest_import_resolution = existing_import_resolution;
@@ -2857,7 +2871,8 @@ impl Resolver {
2857
2871
// all its imports in the usual way; this is because chains of
2858
2872
// adjacent import statements are processed as though they mutated the
2859
2873
// current scope.
2860
- match module_. import_resolutions . find ( & name. name ) {
2874
+ let import_resolutions = module_. import_resolutions . borrow ( ) ;
2875
+ match import_resolutions. get ( ) . find ( & name. name ) {
2861
2876
None => {
2862
2877
// Not found; continue.
2863
2878
}
@@ -3130,7 +3145,8 @@ impl Resolver {
3130
3145
}
3131
3146
3132
3147
// Check the list of resolved imports.
3133
- match module_. import_resolutions . find ( & name. name ) {
3148
+ let import_resolutions = module_. import_resolutions . borrow ( ) ;
3149
+ match import_resolutions. get ( ) . find ( & name. name ) {
3134
3150
Some ( import_resolution) => {
3135
3151
if import_resolution. is_public &&
3136
3152
import_resolution. outstanding_references != 0 {
@@ -3315,8 +3331,11 @@ impl Resolver {
3315
3331
fn add_exports_for_module(&mut self,
3316
3332
exports2: &mut ~[Export2],
3317
3333
module_: @Module) {
3318
- for (name, importresolution) in module_.import_resolutions.iter() {
3319
- if !importresolution.is_public { continue }
3334
+ let import_resolutions = module_.import_resolutions.borrow();
3335
+ for (name, importresolution) in import_resolutions.get().iter() {
3336
+ if !importresolution.is_public {
3337
+ continue
3338
+ }
3320
3339
let xs = [TypeNS, ValueNS];
3321
3340
for &ns in xs.iter() {
3322
3341
match importresolution.target_for_namespace(ns) {
@@ -4673,7 +4692,9 @@ impl Resolver {
4673
4692
}
4674
4693
4675
4694
// Next, search import resolutions.
4676
- match containing_module. import_resolutions . find ( & name. name ) {
4695
+ let import_resolutions = containing_module. import_resolutions
4696
+ . borrow ( ) ;
4697
+ match import_resolutions. get ( ) . find ( & name. name ) {
4677
4698
Some ( import_resolution) if import_resolution. is_public => {
4678
4699
match ( * import_resolution) . target_for_namespace ( namespace) {
4679
4700
Some ( target) => {
@@ -5300,7 +5321,10 @@ impl Resolver {
5300
5321
}
5301
5322
5302
5323
// Look for imports.
5303
- for ( _, & import_resolution) in search_module. import_resolutions . iter ( ) {
5324
+ let import_resolutions = search_module. import_resolutions
5325
+ . borrow ( ) ;
5326
+ for ( _, & import_resolution) in import_resolutions. get ( )
5327
+ . iter ( ) {
5304
5328
match import_resolution. target_for_namespace ( TypeNS ) {
5305
5329
None => {
5306
5330
// Continue.
@@ -5493,7 +5517,8 @@ impl Resolver {
5493
5517
}
5494
5518
5495
5519
debug ! ( "Import resolutions:" ) ;
5496
- for ( name, import_resolution) in module_. import_resolutions . iter ( ) {
5520
+ let import_resolutions = module_. import_resolutions . borrow ( ) ;
5521
+ for ( name, import_resolution) in import_resolutions. get ( ) . iter ( ) {
5497
5522
let value_repr;
5498
5523
match import_resolution. target_for_namespace ( ValueNS ) {
5499
5524
None => { value_repr = ~""; }
0 commit comments