@@ -77,6 +77,7 @@ use syntax::opt_vec::OptVec;
77
77
78
78
use core:: option:: { Some , get, is_some, is_none} ;
79
79
use core:: str:: { connect, split_str} ;
80
+ use core:: hashmap:: linear:: LinearMap ;
80
81
use std:: oldmap:: HashMap ;
81
82
82
83
// Definition mapping
@@ -456,7 +457,7 @@ pub struct Module {
456
457
def_id: Option<def_id>,
457
458
kind: ModuleKind,
458
459
459
- children: @HashMap <ident,@mut NameBindings>,
460
+ children: @mut LinearMap <ident, @mut NameBindings>,
460
461
imports: @mut ~[@ImportDirective],
461
462
462
463
// The anonymous children of this node. Anonymous children are pseudo-
@@ -477,7 +478,7 @@ pub struct Module {
477
478
anonymous_children: @HashMap<node_id,@mut Module>,
478
479
479
480
// The status of resolving each import in this module.
480
- import_resolutions: @HashMap <ident,@mut ImportResolution>,
481
+ import_resolutions: @mut LinearMap <ident, @mut ImportResolution>,
481
482
482
483
// The number of unresolved globs that this module exports.
483
484
glob_count: uint,
@@ -494,10 +495,10 @@ pub fn Module(parent_link: ParentLink,
494
495
parent_link: parent_link,
495
496
def_id: def_id,
496
497
kind: kind,
497
- children: @HashMap (),
498
+ children: @mut LinearMap::new (),
498
499
imports: @mut ~[],
499
500
anonymous_children: @HashMap(),
500
- import_resolutions: @HashMap (),
501
+ import_resolutions: @mut LinearMap::new (),
501
502
glob_count: 0,
502
503
resolved_import_count: 0
503
504
}
@@ -1024,7 +1025,7 @@ pub impl Resolver {
1024
1025
*self.session.str_of(name)));
1025
1026
}
1026
1027
}
1027
- return (child, new_parent);
1028
+ return (* child, new_parent);
1028
1029
}
1029
1030
}
1030
1031
}
@@ -1614,7 +1615,7 @@ pub impl Resolver {
1614
1615
let name_bindings = parent_module.children.get(
1615
1616
&ident);
1616
1617
resolution.type_target =
1617
- Some(Target(parent_module, name_bindings));
1618
+ Some(Target(parent_module, * name_bindings));
1618
1619
}
1619
1620
}
1620
1621
@@ -2168,13 +2169,13 @@ pub impl Resolver {
2168
2169
// Continue.
2169
2170
}
2170
2171
Some ( child_name_bindings) => {
2171
- if ( * child_name_bindings) . defined_in_namespace ( ValueNS ) {
2172
+ if child_name_bindings. defined_in_namespace ( ValueNS ) {
2172
2173
value_result = BoundResult ( containing_module,
2173
- child_name_bindings) ;
2174
+ * child_name_bindings) ;
2174
2175
}
2175
- if ( * child_name_bindings) . defined_in_namespace ( TypeNS ) {
2176
+ if child_name_bindings. defined_in_namespace ( TypeNS ) {
2176
2177
type_result = BoundResult ( containing_module,
2177
- child_name_bindings) ;
2178
+ * child_name_bindings) ;
2178
2179
}
2179
2180
}
2180
2181
}
@@ -2244,11 +2245,11 @@ pub impl Resolver {
2244
2245
// The name is an import which has been fully
2245
2246
// resolved. We can, therefore, just follow it.
2246
2247
if value_result. is_unknown ( ) {
2247
- value_result = get_binding ( import_resolution,
2248
+ value_result = get_binding ( * import_resolution,
2248
2249
ValueNS ) ;
2249
2250
}
2250
2251
if type_result. is_unknown ( ) {
2251
- type_result = get_binding ( import_resolution,
2252
+ type_result = get_binding ( * import_resolution,
2252
2253
TypeNS ) ;
2253
2254
}
2254
2255
}
@@ -2355,9 +2356,9 @@ pub impl Resolver {
2355
2356
// Continue.
2356
2357
}
2357
2358
Some ( child_name_bindings) => {
2358
- if ( * child_name_bindings) . defined_in_namespace ( TypeNS ) {
2359
+ if child_name_bindings. defined_in_namespace ( TypeNS ) {
2359
2360
module_result = BoundResult ( containing_module,
2360
- child_name_bindings) ;
2361
+ * child_name_bindings) ;
2361
2362
}
2362
2363
}
2363
2364
}
@@ -2486,15 +2487,15 @@ pub impl Resolver {
2486
2487
2487
2488
// Add all resolved imports from the containing module.
2488
2489
for containing_module.import_resolutions.each
2489
- |&ident, & target_import_resolution| {
2490
+ |&( ident, target_import_resolution) | {
2490
2491
2491
2492
debug!(" ( resolving glob import) writing module resolution \
2492
2493
%? into `%s`",
2493
2494
is_none( & mut target_import_resolution. type_target) ,
2494
2495
self . module_to_str( module_) ) ;
2495
2496
2496
2497
// Here we merge two import resolutions.
2497
- match module_. import_resolutions . find ( & ident) {
2498
+ match module_. import_resolutions . find ( ident) {
2498
2499
None if target_import_resolution. privacy == Public => {
2499
2500
// Simple: just copy the old import resolution.
2500
2501
let new_import_resolution =
@@ -2507,7 +2508,7 @@ pub impl Resolver {
2507
2508
copy target_import_resolution. type_target ;
2508
2509
2509
2510
module_. import_resolutions . insert
2510
- ( ident, new_import_resolution) ;
2511
+ ( * ident, new_import_resolution) ;
2511
2512
}
2512
2513
None => { /* continue ... */ }
2513
2514
Some ( dest_import_resolution) => {
@@ -2537,39 +2538,39 @@ pub impl Resolver {
2537
2538
}
2538
2539
2539
2540
// Add all children from the containing module.
2540
- for containing_module. children. each |& ident, & name_bindings| {
2541
+ for containing_module. children. each |& ( ident, name_bindings) | {
2541
2542
let mut dest_import_resolution;
2542
- match module_. import_resolutions. find( & ident) {
2543
+ match module_. import_resolutions. find( ident) {
2543
2544
None => {
2544
2545
// Create a new import resolution from this child.
2545
2546
dest_import_resolution = @mut ImportResolution ( privacy,
2546
2547
span,
2547
2548
state) ;
2548
2549
module_. import_resolutions . insert
2549
- ( ident, dest_import_resolution) ;
2550
+ ( * ident, dest_import_resolution) ;
2550
2551
}
2551
2552
Some ( existing_import_resolution) => {
2552
- dest_import_resolution = existing_import_resolution;
2553
+ dest_import_resolution = * existing_import_resolution;
2553
2554
}
2554
2555
}
2555
2556
2556
2557
debug ! ( "(resolving glob import) writing resolution `%s` in `%s` \
2557
2558
to `%s`, privacy=%?",
2558
- * self . session. str_of( ident) ,
2559
+ * self . session. str_of( * ident) ,
2559
2560
self . module_to_str( containing_module) ,
2560
2561
self . module_to_str( module_) ,
2561
2562
copy dest_import_resolution. privacy) ;
2562
2563
2563
2564
// Merge the child item into the import resolution.
2564
- if ( * name_bindings) . defined_in_public_namespace ( ValueNS ) {
2565
+ if name_bindings. defined_in_public_namespace ( ValueNS ) {
2565
2566
debug ! ( "(resolving glob import) ... for value target" ) ;
2566
2567
dest_import_resolution. value_target =
2567
- Some ( Target ( containing_module, name_bindings) ) ;
2568
+ Some ( Target ( containing_module, * name_bindings) ) ;
2568
2569
}
2569
- if ( * name_bindings) . defined_in_public_namespace ( TypeNS ) {
2570
+ if name_bindings. defined_in_public_namespace ( TypeNS ) {
2570
2571
debug ! ( "(resolving glob import) ... for type target" ) ;
2571
2572
dest_import_resolution. type_target =
2572
- Some ( Target ( containing_module, name_bindings) ) ;
2573
+ Some ( Target ( containing_module, * name_bindings) ) ;
2573
2574
}
2574
2575
}
2575
2576
@@ -2763,8 +2764,8 @@ pub impl Resolver {
2763
2764
2764
2765
match module_. children . find ( & name) {
2765
2766
Some ( name_bindings)
2766
- if ( * name_bindings) . defined_in_namespace ( namespace) => {
2767
- return Success ( Target ( module_, name_bindings) ) ;
2767
+ if name_bindings. defined_in_namespace ( namespace) => {
2768
+ return Success ( Target ( module_, * name_bindings) ) ;
2768
2769
}
2769
2770
Some ( _) | None => { /* Not found; continue. */ }
2770
2771
}
@@ -3008,10 +3009,9 @@ pub impl Resolver {
3008
3009
// First, check the direct children of the module.
3009
3010
match module_. children . find ( & name) {
3010
3011
Some ( name_bindings)
3011
- if ( * name_bindings) . defined_in_namespace ( namespace) => {
3012
-
3012
+ if name_bindings. defined_in_namespace ( namespace) => {
3013
3013
debug ! ( "(resolving name in module) found node as child" ) ;
3014
- return Success ( Target ( module_, name_bindings) ) ;
3014
+ return Success ( Target ( module_, * name_bindings) ) ;
3015
3015
}
3016
3016
Some ( _) | None => {
3017
3017
// Continue.
@@ -3193,7 +3193,7 @@ pub impl Resolver {
3193
3193
fn add_exports_for_module(@mut self,
3194
3194
exports2: &mut ~[Export2],
3195
3195
module_: @mut Module) {
3196
- for module_.children.each |ident, namebindings| {
3196
+ for module_.children.each |&( ident, namebindings) | {
3197
3197
debug!(" ( computing exports) maybe export ' %s' ",
3198
3198
*self.session.str_of(*ident));
3199
3199
self.add_exports_of_namebindings(&mut *exports2,
@@ -3208,7 +3208,7 @@ pub impl Resolver {
3208
3208
false);
3209
3209
}
3210
3210
3211
- for module_.import_resolutions.each |ident, importresolution| {
3211
+ for module_.import_resolutions.each |&( ident, importresolution) | {
3212
3212
if importresolution.privacy != Public {
3213
3213
debug!(" ( computing exports) not reexporting private `%s`",
3214
3214
* self . session. str_of( * ident) ) ;
@@ -5311,9 +5311,9 @@ pub impl Resolver {
5311
5311
}
5312
5312
5313
5313
debug ! ( "Import resolutions:" ) ;
5314
- for module_. import_resolutions. each |& name, & import_resolution| {
5314
+ for module_. import_resolutions. each |& ( name, import_resolution) | {
5315
5315
let mut value_repr;
5316
- match ( * import_resolution) . target_for_namespace( ValueNS ) {
5316
+ match import_resolution. target_for_namespace( ValueNS ) {
5317
5317
None => { value_repr = ~""; }
5318
5318
Some ( _) => {
5319
5319
value_repr = ~" value: ?";
@@ -5322,15 +5322,15 @@ pub impl Resolver {
5322
5322
}
5323
5323
5324
5324
let mut type_repr;
5325
- match ( * import_resolution) . target_for_namespace( TypeNS ) {
5325
+ match import_resolution. target_for_namespace( TypeNS ) {
5326
5326
None => { type_repr = ~""; }
5327
5327
Some ( _) => {
5328
5328
type_repr = ~" type : ?";
5329
5329
// FIXME #4954
5330
5330
}
5331
5331
}
5332
5332
5333
- debug!( "* %s: %s%s", * self . session. str_of( name) ,
5333
+ debug ! ( "* %s:%s%s" , * self . session. str_of( * name) ,
5334
5334
value_repr, type_repr) ;
5335
5335
}
5336
5336
}
0 commit comments