Skip to content

Commit 1a6a93c

Browse files
committed
---
yaml --- r: 11867 b: refs/heads/master c: fe90c18 h: refs/heads/master i: 11865: 1cf364f 11863: 46459b5 v: v3
1 parent 9e5cfe7 commit 1a6a93c

File tree

3 files changed

+43
-35
lines changed

3 files changed

+43
-35
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2c8c50d6cb1d7cce0f597dd60daf2a5109b9c0de
2+
refs/heads/master: fe90c189f488d336fc34979d6b928555d984a4d7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/metadata/encoder.rs

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import io::writer_util;
66
import ebml::writer;
77
import syntax::ast::*;
88
import syntax::print::pprust;
9-
import syntax::ast_util;
9+
import syntax::{ast_util, visit};
1010
import syntax::ast_util::local_def;
1111
import common::*;
1212
import middle::trans::common::crate_ctxt;
@@ -249,13 +249,13 @@ fn encode_parent_item(ebml_w: ebml::writer, id: def_id) {
249249

250250
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
251251
id: node_id, variants: [variant],
252-
path: ast_map::path, &index: [entry<int>],
252+
path: ast_map::path, index: @mutable [entry<int>],
253253
ty_params: [ty_param]) {
254254
let disr_val = 0;
255255
let i = 0;
256256
let vi = ty::enum_variants(ecx.ccx.tcx, {crate: local_crate, node: id});
257257
for variant: variant in variants {
258-
index += [{val: variant.node.id, pos: ebml_w.writer.tell()}];
258+
*index += [{val: variant.node.id, pos: ebml_w.writer.tell()}];
259259
ebml_w.start_tag(tag_items_data_item);
260260
encode_def_id(ebml_w, local_def(variant.node.id));
261261
encode_family(ebml_w, 'v');
@@ -329,7 +329,7 @@ fn purity_fn_family(p: purity) -> char {
329329
}
330330

331331
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
332-
&index: [entry<int>], path: ast_map::path) -> bool {
332+
index: @mutable [entry<int>], path: ast_map::path) {
333333

334334
fn should_inline(attrs: [attribute]) -> bool {
335335
alt attr::find_inline_attr(attrs) {
@@ -340,7 +340,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
340340

341341
let tcx = ecx.ccx.tcx;
342342
let must_write = alt item.node { item_enum(_, _) { true } _ { false } };
343-
if !must_write && !ecx.reachable.contains_key(item.id) { ret false; }
343+
if !must_write && !ecx.reachable.contains_key(item.id) { ret; }
344+
*index += [{val: item.id, pos: ebml_w.writer.tell()}];
344345

345346
alt item.node {
346347
item_const(_, _) {
@@ -419,7 +420,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
419420
encode_path(ebml_w, path, ast_map::path_name(item.ident));
420421
ebml_w.end_tag();
421422

422-
index += [{val: ctor_id, pos: ebml_w.writer.tell()}];
423+
*index += [{val: ctor_id, pos: ebml_w.writer.tell()}];
423424
ebml_w.start_tag(tag_items_data_item);
424425
encode_def_id(ebml_w, local_def(ctor_id));
425426
encode_family(ebml_w, 'f');
@@ -457,7 +458,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
457458

458459
let impl_path = path + [ast_map::path_name(item.ident)];
459460
for m in methods {
460-
index += [{val: m.id, pos: ebml_w.writer.tell()}];
461+
*index += [{val: m.id, pos: ebml_w.writer.tell()}];
461462
ebml_w.start_tag(tag_items_data_item);
462463
encode_def_id(ebml_w, local_def(m.id));
463464
encode_family(ebml_w, purity_fn_family(m.decl.purity));
@@ -496,13 +497,15 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
496497
ebml_w.end_tag();
497498
}
498499
}
499-
ret true;
500500
}
501501

502502
fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
503-
nitem: @native_item, path: ast_map::path)
504-
-> bool {
505-
if !ecx.reachable.contains_key(nitem.id) { ret false; }
503+
nitem: @native_item,
504+
index: @mutable [entry<int>],
505+
path: ast_map::path) {
506+
if !ecx.reachable.contains_key(nitem.id) { ret; }
507+
*index += [{val: nitem.id, pos: ebml_w.writer.tell()}];
508+
506509
ebml_w.start_tag(tag_items_data_item);
507510
alt nitem.node {
508511
native_item_fn(fn_decl, tps) {
@@ -515,30 +518,35 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
515518
}
516519
}
517520
ebml_w.end_tag();
518-
ret true;
519521
}
520522

521523
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
522-
crate_mod: _mod) -> [entry<int>] {
523-
let index: [entry<int>] = [];
524+
crate: @crate) -> [entry<int>] {
525+
let index = @mutable [];
524526
ebml_w.start_tag(tag_items_data);
525-
index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
526-
encode_info_for_mod(ecx, ebml_w, crate_mod, crate_node_id, [], "");
527-
ecx.ccx.tcx.items.items {|key, val|
528-
let where = ebml_w.writer.tell();
529-
let written = alt val {
530-
middle::ast_map::node_item(i, path) if i.id == key {
531-
encode_info_for_item(ecx, ebml_w, i, index, *path)
532-
}
533-
middle::ast_map::node_native_item(i, _, path) {
534-
encode_info_for_native_item(ecx, ebml_w, i, *path)
535-
}
536-
_ { false }
537-
};
538-
if written { index += [{val: key, pos: where}]; }
539-
};
527+
*index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
528+
encode_info_for_mod(ecx, ebml_w, crate.node.module,
529+
crate_node_id, [], "");
530+
visit::visit_crate(*crate, (), visit::mk_vt(@{
531+
visit_expr: {|_e, _cx, _v|},
532+
visit_item: {|i, cx, v|
533+
visit::visit_item(i, cx, v);
534+
let path = alt check ecx.ccx.tcx.items.get(i.id) {
535+
ast_map::node_item(_, pt) { pt }
536+
};
537+
encode_info_for_item(ecx, ebml_w, i, index, *path);
538+
},
539+
visit_native_item: {|ni, cx, v|
540+
visit::visit_native_item(ni, cx, v);
541+
let path = alt check ecx.ccx.tcx.items.get(ni.id) {
542+
ast_map::node_native_item(_, _, pt) { pt }
543+
};
544+
encode_info_for_native_item(ecx, ebml_w, ni, index, *path);
545+
}
546+
with *visit::default_visitor()
547+
}));
540548
ebml_w.end_tag();
541-
ret index;
549+
ret *index;
542550
}
543551

544552

@@ -765,7 +773,7 @@ fn encode_metadata(cx: @crate_ctxt, crate: @crate) -> [u8] {
765773

766774
// Encode and index the items.
767775
ebml_w.start_tag(tag_items);
768-
let items_index = encode_info_for_items(ecx, ebml_w, crate.node.module);
776+
let items_index = encode_info_for_items(ecx, ebml_w, crate);
769777
let items_buckets = create_index(items_index, hash_node_id);
770778
encode_index(ebml_w, items_buckets, write_int);
771779
ebml_w.end_tag();

trunk/src/rustc/middle/trans/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ fn set_struct_body(t: TypeRef, elts: [TypeRef]) unsafe {
527527
fn T_empty_struct() -> TypeRef { ret T_struct([]); }
528528

529529
// A vtable is, in reality, a vtable pointer followed by zero or more pointers
530-
// to tydescs and other vtables that it closes over. But the types and number of
531-
// those are rarely known to the code that needs to manipulate them, so they
532-
// are described by this opaque type.
530+
// to tydescs and other vtables that it closes over. But the types and number
531+
// of those are rarely known to the code that needs to manipulate them, so
532+
// they are described by this opaque type.
533533
fn T_vtable() -> TypeRef { T_array(T_ptr(T_i8()), 1u) }
534534

535535
fn T_task(targ_cfg: @session::config) -> TypeRef {

0 commit comments

Comments
 (0)