2
2
3
3
import std:: ivec;
4
4
import std:: str;
5
- import std:: vec;
6
5
import std:: uint;
7
6
import std:: ioivec;
8
7
import std:: option;
@@ -39,8 +38,8 @@ fn encode_def_id(&ebmlivec::writer ebml_w, &def_id id) {
39
38
}
40
39
41
40
fn encode_tag_variant_paths ( & ebmlivec:: writer ebml_w, & variant[ ] variants,
42
- & vec [ str] path,
43
- & mutable vec [ tup( str, uint) ] index) {
41
+ & str[ ] path ,
42
+ & mutable ( tup( str, uint) ) [ ] index) {
44
43
for ( variant variant in variants) {
45
44
add_to_index( ebml_w, path, index, variant. node. name) ;
46
45
ebmlivec:: start_tag ( ebml_w , tag_paths_data_item ) ;
@@ -50,15 +49,15 @@ fn encode_tag_variant_paths(&ebmlivec::writer ebml_w, &variant[] variants,
50
49
}
51
50
}
52
51
53
- fn add_to_index( & ebmlivec:: writer ebml_w, & vec [ str] path,
54
- & mutable vec [ tup( str, uint) ] index, & str name) {
55
- auto full_path = path + [ name] ;
56
- index += [ tup( str:: connect ( full_path, "::" ) , ebml_w. writer. tell( ) ) ] ;
52
+ fn add_to_index ( & ebmlivec:: writer ebml_w, & str [ ] path,
53
+ & mutable ( tup( str, uint) ) [ ] index , & str name ) {
54
+ auto full_path = path + ~ [ name ] ;
55
+ index += ~ [ tup ( str:: connect_ivec ( full_path, "::" ) , ebml_w. writer . tell ( ) ) ] ;
57
56
}
58
57
59
58
fn encode_native_module_item_paths ( & ebmlivec:: writer ebml_w,
60
- & native_mod nmod, & vec [ str] path,
61
- & mutable vec [ tup( str, uint) ] index) {
59
+ & native_mod nmod, & str [ ] path,
60
+ & mutable ( tup( str, uint) ) [ ] index ) {
62
61
for ( @native_item nitem in nmod. items ) {
63
62
add_to_index ( ebml_w, path, index, nitem. ident ) ;
64
63
ebmlivec:: start_tag ( ebml_w, tag_paths_data_item) ;
@@ -69,8 +68,8 @@ fn encode_native_module_item_paths(&ebmlivec::writer ebml_w,
69
68
}
70
69
71
70
fn encode_module_item_paths ( & ebmlivec:: writer ebml_w, & _mod module ,
72
- & vec [ str] path,
73
- & mutable vec [ tup( str, uint) ] index) {
71
+ & str [ ] path,
72
+ & mutable ( tup( str, uint) ) [ ] index ) {
74
73
for ( @item it in module. items ) {
75
74
if ( !is_exported ( it. ident , module) ) { cont; }
76
75
alt ( it. node ) {
@@ -93,7 +92,7 @@ fn encode_module_item_paths(&ebmlivec::writer ebml_w, &_mod module,
93
92
ebmlivec:: start_tag ( ebml_w, tag_paths_data_mod) ;
94
93
encode_name ( ebml_w, it. ident ) ;
95
94
encode_def_id ( ebml_w, local_def ( it. id ) ) ;
96
- encode_module_item_paths( ebml_w, _mod, path + [ it. ident] ,
95
+ encode_module_item_paths ( ebml_w, _mod, path + ~ [ it. ident ] ,
97
96
index) ;
98
97
ebmlivec:: end_tag ( ebml_w) ;
99
98
}
@@ -103,7 +102,7 @@ fn encode_module_item_paths(&ebmlivec::writer ebml_w, &_mod module,
103
102
encode_name ( ebml_w, it. ident ) ;
104
103
encode_def_id ( ebml_w, local_def ( it. id ) ) ;
105
104
encode_native_module_item_paths ( ebml_w, nmod,
106
- path + [ it. ident] , index) ;
105
+ path + ~ [ it. ident ] , index) ;
107
106
ebmlivec:: end_tag ( ebml_w) ;
108
107
}
109
108
case ( item_ty ( _, ?tps) ) {
@@ -149,10 +148,10 @@ fn encode_module_item_paths(&ebmlivec::writer ebml_w, &_mod module,
149
148
}
150
149
}
151
150
152
- fn encode_item_paths( & ebmlivec:: writer ebml_w, & @crate crate) ->
153
- vec [ tup( str, uint) ] {
154
- let vec [ tup( str, uint) ] index = [ ] ;
155
- let vec [ str] path = [ ] ;
151
+ fn encode_item_paths ( & ebmlivec:: writer ebml_w, & @crate crate)
152
+ -> ( tup ( str , uint ) ) [ ] {
153
+ let ( tup( str, uint) ) [ ] index = ~ [ ] ;
154
+ let str[ ] path = ~ [ ] ;
156
155
ebmlivec:: start_tag ( ebml_w, tag_paths) ;
157
156
encode_module_item_paths ( ebml_w, crate . node. module , path, index) ;
158
157
ebmlivec:: end_tag ( ebml_w) ;
@@ -213,10 +212,10 @@ fn encode_tag_id(&ebmlivec::writer ebml_w, &def_id id) {
213
212
214
213
fn encode_tag_variant_info( & @encode_ctxt ecx , & ebmlivec:: writer ebml_w,
215
214
node_id id, & variant[ ] variants,
216
- & mutable vec [ tup( int, uint) ] index,
215
+ & mutable ( tup( int, uint) ) [ ] index ,
217
216
& ty_param[ ] ty_params) {
218
217
for ( variant variant in variants) {
219
- index += [ tup( variant. node. id, ebml_w. writer. tell( ) ) ] ;
218
+ index += ~ [ tup ( variant . node. id, ebml_w . writer. tell( ) ) ] ;
220
219
ebmlivec:: start_tag ( ebml_w, tag_items_data_item) ;
221
220
encode_def_id ( ebml_w, local_def ( variant. node . id ) ) ;
222
221
encode_kind ( ebml_w, 'v' as u8 ) ;
@@ -233,7 +232,7 @@ fn encode_tag_variant_info(&@encode_ctxt ecx, &ebmlivec::writer ebml_w,
233
232
}
234
233
235
234
fn encode_info_for_item( @encode_ctxt ecx, & ebmlivec:: writer ebml_w,
236
- @item item, & mutable vec [ tup( int, uint) ] index) {
235
+ @item item, & mutable ( tup ( int, uint) ) [ ] index) {
237
236
alt ( item. node ) {
238
237
case ( item_const ( _, _) ) {
239
238
ebmlivec:: start_tag ( ebml_w, tag_items_data_item) ;
@@ -302,7 +301,7 @@ fn encode_info_for_item(@encode_ctxt ecx, &ebmlivec::writer ebml_w,
302
301
encode_symbol ( ecx, ebml_w, item. id ) ;
303
302
ebmlivec:: end_tag ( ebml_w) ;
304
303
305
- index += [ tup( ctor_id, ebml_w. writer. tell( ) ) ] ;
304
+ index += ~ [ tup ( ctor_id, ebml_w. writer . tell ( ) ) ] ;
306
305
ebmlivec:: start_tag ( ebml_w, tag_items_data_item) ;
307
306
encode_def_id ( ebml_w, local_def ( ctor_id) ) ;
308
307
encode_kind ( ebml_w, 'f' as u8 ) ;
@@ -321,7 +320,7 @@ fn encode_info_for_item(@encode_ctxt ecx, &ebmlivec::writer ebml_w,
321
320
encode_type ( ecx, ebml_w, ty:: ty_fn_ret ( ecx. ccx . tcx , fn_ty) ) ;
322
321
ebmlivec:: end_tag ( ebml_w) ;
323
322
324
- index += [ tup( ctor_id, ebml_w. writer. tell( ) ) ] ;
323
+ index += ~ [ tup ( ctor_id, ebml_w. writer . tell ( ) ) ] ;
325
324
ebmlivec:: start_tag ( ebml_w, tag_items_data_item) ;
326
325
encode_def_id ( ebml_w, local_def ( ctor_id) ) ;
327
326
encode_kind ( ebml_w, 'f' as u8 ) ;
@@ -355,19 +354,19 @@ fn encode_info_for_native_item(&@encode_ctxt ecx, &ebmlivec::writer ebml_w,
355
354
ebmlivec:: end_tag ( ebml_w) ;
356
355
}
357
356
358
- fn encode_info_for_items( & @encode_ctxt ecx, & ebmlivec:: writer ebml_w) ->
359
- vec [ tup( int, uint) ] {
360
- let vec [ tup( int, uint) ] index = [ ] ;
357
+ fn encode_info_for_items ( & @encode_ctxt ecx , & ebmlivec:: writer ebml_w)
358
+ -> ( tup ( int , uint ) ) [ ] {
359
+ let ( tup( int, uint) ) [ ] index = ~ [ ] ;
361
360
ebmlivec:: start_tag ( ebml_w, tag_items_data) ;
362
361
for each ( @tup( node_id, middle:: ast_map:: ast_node) kvp in
363
362
ecx. ccx . ast_map . items ( ) ) {
364
363
alt ( kvp. _1 ) {
365
364
case ( middle:: ast_map:: node_item ( ?i) ) {
366
- index += [ tup( kvp. _0, ebml_w. writer. tell( ) ) ] ;
365
+ index += ~ [ tup ( kvp. _0 , ebml_w. writer . tell ( ) ) ] ;
367
366
encode_info_for_item ( ecx, ebml_w, i, index) ;
368
367
}
369
368
case ( middle:: ast_map:: node_native_item ( ?i) ) {
370
- index += [ tup( kvp. _0, ebml_w. writer. tell( ) ) ] ;
369
+ index += ~ [ tup ( kvp. _0 , ebml_w. writer . tell ( ) ) ] ;
371
370
encode_info_for_native_item ( ecx, ebml_w, i) ;
372
371
}
373
372
case ( _) { }
@@ -380,27 +379,32 @@ fn encode_info_for_items(&@encode_ctxt ecx, &ebmlivec::writer ebml_w) ->
380
379
381
380
// Path and definition ID indexing
382
381
383
- fn create_index[ T ] ( & vec [ tup( T , uint) ] index, fn ( & T ) -> uint hash_fn) ->
384
- vec [ vec [ tup( T , uint) ] ] {
385
- let vec [ mutable vec [ tup( T , uint) ] ] buckets = vec :: empty_mut ( ) ;
386
- for each ( uint i in uint:: range( 0 u, 256 u) ) { buckets += [ mutable [ ] ] ; }
382
+ fn create_index[ T ] ( & ( tup ( T , uint) ) [ ] index, fn ( & T ) -> uint hash_fn)
383
+ -> ( @ ( tup ( T , uint) ) [ ] ) [ ] {
384
+ let ( @ mutable ( tup( T , uint) ) [ ] ) [ ] buckets = ~ [ ] ;
385
+ for each ( uint i in uint:: range( 0 u, 256 u) ) { buckets += ~ [ @ mutable ~ [ ] ] ; }
387
386
for ( tup( T , uint) elt in index) {
388
387
auto h = hash_fn ( elt. _0 ) ;
389
- buckets. ( h % 256 u) += [ elt] ;
388
+ * ( buckets. ( h % 256 u) ) += ~ [ elt] ;
390
389
}
391
- ret vec:: freeze( buckets) ;
390
+
391
+ auto buckets_frozen = ~[ ] ;
392
+ for ( @mutable ( tup( T , uint) ) [ ] bucket in buckets) {
393
+ buckets_frozen += ~[ @* bucket] ;
394
+ }
395
+ ret buckets_frozen;
392
396
}
393
397
394
- fn encode_index[ T ] ( & ebmlivec:: writer ebml_w, & vec [ vec [ tup( T , uint) ] ] buckets,
398
+ fn encode_index[ T ] ( & ebmlivec:: writer ebml_w, & ( @ ( tup( T , uint) ) [ ] ) [ ] buckets,
395
399
fn( & ioivec:: writer, & T ) write_fn) {
396
400
auto writer = ioivec:: new_writer_( ebml_w. writer) ;
397
401
ebmlivec:: start_tag( ebml_w, tag_index) ;
398
- let vec [ uint] bucket_locs = [ ] ;
402
+ let uint[ ] bucket_locs = ~ [ ] ;
399
403
ebmlivec:: start_tag( ebml_w, tag_index_buckets) ;
400
- for ( vec [ tup( T , uint) ] bucket in buckets) {
401
- bucket_locs += [ ebml_w. writer. tell( ) ] ;
404
+ for ( @ ( tup( T , uint) ) [ ] bucket in buckets) {
405
+ bucket_locs += ~ [ ebml_w. writer. tell( ) ] ;
402
406
ebmlivec:: start_tag( ebml_w, tag_index_buckets_bucket) ;
403
- for ( tup( T , uint) elt in bucket) {
407
+ for ( tup( T , uint) elt in * bucket) {
404
408
ebmlivec:: start_tag( ebml_w, tag_index_buckets_bucket_elt) ;
405
409
writer. write_be_uint( elt. _1, 4 u) ;
406
410
write_fn( writer, elt. _0) ;
@@ -458,7 +462,7 @@ fn encode_meta_item(&ebmlivec::writer ebml_w, &meta_item mi) {
458
462
}
459
463
}
460
464
461
- fn encode_attributes( & ebmlivec:: writer ebml_w, & vec [ attribute] attrs) {
465
+ fn encode_attributes( & ebmlivec:: writer ebml_w, & attribute[ ] attrs) {
462
466
ebmlivec:: start_tag( ebml_w, tag_attributes) ;
463
467
for ( attribute attr in attrs) {
464
468
ebmlivec:: start_tag( ebml_w, tag_attribute) ;
@@ -473,7 +477,7 @@ fn encode_attributes(&ebmlivec::writer ebml_w, &vec[attribute] attrs) {
473
477
// 'name' and 'vers' items, so if the user didn't provide them we will throw
474
478
// them in anyway with default values.
475
479
fn synthesize_crate_attrs( & @encode_ctxt ecx,
476
- & @crate crate ) -> vec [ attribute] {
480
+ & @crate crate) -> attribute[ ] {
477
481
478
482
fn synthesize_link_attr( & @encode_ctxt ecx, & ( @meta_item) [ ] items)
479
483
-> attribute {
@@ -497,44 +501,44 @@ fn synthesize_crate_attrs(&@encode_ctxt ecx,
497
501
ret attr:: mk_attr( link_item) ;
498
502
}
499
503
500
- let vec [ attribute] attrs = [ ] ;
504
+ let attribute[ ] attrs = ~ [ ] ;
501
505
auto found_link_attr = false ;
502
506
for ( attribute attr in crate . node. attrs) {
503
507
attrs += if ( attr:: get_attr_name( attr) != "link" ) {
504
- [ attr]
508
+ ~ [ attr]
505
509
} else {
506
510
alt ( attr. node. value. node) {
507
511
case ( meta_list( ?n, ?l) ) {
508
512
found_link_attr = true ;
509
- [ synthesize_link_attr( ecx, l) ]
513
+ ~ [ synthesize_link_attr( ecx, l) ]
510
514
}
511
- case ( _) { [ attr] }
515
+ case ( _) { ~ [ attr] }
512
516
}
513
517
}
514
518
}
515
519
516
520
if ( !found_link_attr) {
517
- attrs += [ synthesize_link_attr( ecx, ~[ ] ) ] ;
521
+ attrs += ~ [ synthesize_link_attr( ecx, ~[ ] ) ] ;
518
522
}
519
523
520
524
ret attrs;
521
525
}
522
526
523
527
fn encode_crate_deps( & ebmlivec:: writer ebml_w, & cstore:: cstore cstore) {
524
528
525
- fn get_ordered_names( & cstore:: cstore cstore) -> vec [ str ] {
529
+ fn get_ordered_names( & cstore:: cstore cstore) -> str [ ] {
526
530
type hashkv = @tup( crate_num, cstore:: crate_metadata) ;
527
531
type numname = tup( crate_num, str) ;
528
532
529
533
// Pull the cnums and names out of cstore
530
- let vec [ mutable numname ] pairs = [ mutable] ;
534
+ let numname [ mutable] pairs = ~ [ mutable] ;
531
535
for each ( hashkv hashkv in cstore:: iter_crate_data( cstore) ) {
532
- pairs += [ mutable tup( hashkv. _0, hashkv. _1. name) ] ;
536
+ pairs += ~ [ mutable tup( hashkv. _0, hashkv. _1. name) ] ;
533
537
}
534
538
535
539
// Sort by cnum
536
540
fn lteq( & numname kv1, & numname kv2) -> bool { kv1. _0 <= kv2. _0 }
537
- std:: sort:: quick_sort( lteq, pairs) ;
541
+ std:: sort:: ivector :: quick_sort ( lteq , pairs ) ;
538
542
539
543
// Sanity-check the crate numbers
540
544
auto expected_cnum = 1 ;
@@ -545,9 +549,9 @@ fn encode_crate_deps(&ebmlivec::writer ebml_w, &cstore::cstore cstore) {
545
549
546
550
// Return just the names
547
551
fn name ( & numname kv) -> str { kv. _1 }
548
- // mutable -> immutable hack for vec ::map
549
- auto immpairs = vec :: slice( pairs, 0 u, vec :: len( pairs) ) ;
550
- ret vec :: map( name, immpairs) ;
552
+ // mutable -> immutable hack for ivec ::map
553
+ auto immpairs = ivec :: slice ( pairs, 0 u, ivec :: len ( pairs) ) ;
554
+ ret ivec :: map ( name, immpairs) ;
551
555
}
552
556
553
557
// We're just going to write a list of crate names, with the assumption
0 commit comments