syntax: Remove uses of DVec
This commit is contained in:
parent
2a72099063
commit
7f99a02ddb
@ -24,7 +24,6 @@ source code snippets, etc.
|
||||
use core::prelude::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::dvec::DVec;
|
||||
use core::str;
|
||||
use core::to_bytes;
|
||||
use core::uint;
|
||||
@ -242,7 +241,7 @@ pub struct FileMap {
|
||||
/// Locations of lines beginnings in the source code
|
||||
lines: @mut ~[BytePos],
|
||||
/// Locations of multi-byte characters in the source code
|
||||
multibyte_chars: DVec<MultiByteChar>
|
||||
multibyte_chars: @mut ~[MultiByteChar],
|
||||
}
|
||||
|
||||
pub impl FileMap {
|
||||
@ -282,13 +281,13 @@ pub impl FileMap {
|
||||
}
|
||||
|
||||
pub struct CodeMap {
|
||||
files: DVec<@FileMap>
|
||||
files: @mut ~[@FileMap]
|
||||
}
|
||||
|
||||
pub impl CodeMap {
|
||||
static pub fn new() -> CodeMap {
|
||||
CodeMap {
|
||||
files: DVec()
|
||||
files: @mut ~[],
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,7 +314,7 @@ pub impl CodeMap {
|
||||
name: filename, substr: substr, src: src,
|
||||
start_pos: BytePos(start_pos),
|
||||
lines: @mut ~[],
|
||||
multibyte_chars: DVec()
|
||||
multibyte_chars: @mut ~[],
|
||||
};
|
||||
|
||||
self.files.push(filemap);
|
||||
|
@ -18,7 +18,6 @@ use core::io;
|
||||
use core::option;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
use core::dvec::DVec;
|
||||
|
||||
use std::term;
|
||||
|
||||
@ -203,7 +202,7 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
|
||||
io::stderr().write_str(fmt!(" %s\n", msg));
|
||||
}
|
||||
|
||||
pub fn collect(messages: @DVec<~str>)
|
||||
pub fn collect(messages: @mut ~[~str])
|
||||
-> @fn(Option<(@codemap::CodeMap, span)>, &str, level) {
|
||||
let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) =
|
||||
|_o, msg: &str, _l| { messages.push(msg.to_str()); };
|
||||
|
@ -29,7 +29,6 @@ use parse::token::special_idents::clownshoes_extensions;
|
||||
use ast_util;
|
||||
use opt_vec;
|
||||
|
||||
use core::dvec;
|
||||
use core::uint;
|
||||
|
||||
enum Junction {
|
||||
@ -99,7 +98,7 @@ fn expand_deriving(cx: ext_ctxt,
|
||||
expand_deriving_struct_def: ExpandDerivingStructDefFn,
|
||||
expand_deriving_enum_def: ExpandDerivingEnumDefFn)
|
||||
-> ~[@item] {
|
||||
let result = dvec::DVec();
|
||||
let mut result = ~[];
|
||||
for in_items.each |item| {
|
||||
result.push(copy *item);
|
||||
match item.node {
|
||||
@ -120,7 +119,7 @@ fn expand_deriving(cx: ext_ctxt,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
dvec::unwrap(result)
|
||||
result
|
||||
}
|
||||
|
||||
fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item {
|
||||
@ -202,14 +201,13 @@ fn create_self_type_with_params(cx: ext_ctxt,
|
||||
generics: &Generics)
|
||||
-> @Ty {
|
||||
// Create the type parameters on the `self` path.
|
||||
let self_ty_params = dvec::DVec();
|
||||
let mut self_ty_params = ~[];
|
||||
for generics.ty_params.each |ty_param| {
|
||||
let self_ty_param = build::mk_simple_ty_path(cx,
|
||||
span,
|
||||
ty_param.ident);
|
||||
self_ty_params.push(self_ty_param);
|
||||
}
|
||||
let self_ty_params = dvec::unwrap(self_ty_params);
|
||||
|
||||
// Create the type of `self`.
|
||||
let self_type = build::mk_raw_path_(span,
|
||||
@ -433,7 +431,7 @@ fn create_subpatterns(cx: ext_ctxt,
|
||||
prefix: ~str,
|
||||
n: uint)
|
||||
-> ~[@pat] {
|
||||
let subpats = dvec::DVec();
|
||||
let mut subpats = ~[];
|
||||
for uint::range(0, n) |_i| {
|
||||
// Create the subidentifier.
|
||||
let index = subpats.len().to_str();
|
||||
@ -445,7 +443,7 @@ fn create_subpatterns(cx: ext_ctxt,
|
||||
let subpat = build::mk_pat(cx, span, subpat);
|
||||
subpats.push(subpat);
|
||||
}
|
||||
return dvec::unwrap(subpats);
|
||||
return subpats;
|
||||
}
|
||||
|
||||
fn is_struct_tuple(struct_def: &struct_def) -> bool {
|
||||
@ -809,7 +807,7 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt,
|
||||
let self_ident = cx.ident_of(~"self");
|
||||
|
||||
// Create the body of the method.
|
||||
let statements = dvec::DVec();
|
||||
let mut statements = ~[];
|
||||
for struct_def.fields.each |struct_field| {
|
||||
match struct_field.node.kind {
|
||||
named_field(ident, _, _) => {
|
||||
@ -833,7 +831,6 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt,
|
||||
}
|
||||
|
||||
// Create the method itself.
|
||||
let statements = dvec::unwrap(statements);
|
||||
return create_iter_bytes_method(cx, span, statements);
|
||||
}
|
||||
|
||||
@ -942,9 +939,9 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
}
|
||||
|
||||
// Create the arms of the self match in the method body.
|
||||
let self_arms = dvec::DVec();
|
||||
let mut self_arms = ~[];
|
||||
for enum_definition.variants.each |self_variant| {
|
||||
let other_arms = dvec::DVec();
|
||||
let mut other_arms = ~[];
|
||||
|
||||
// Create the matching pattern.
|
||||
let matching_pat = create_enum_variant_pattern(cx,
|
||||
@ -1026,7 +1023,6 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
// Create the self pattern body.
|
||||
let other_expr = build::mk_path(cx, span, ~[ other_ident ]);
|
||||
let other_expr = build::mk_unary(cx, span, deref, other_expr);
|
||||
let other_arms = dvec::unwrap(other_arms);
|
||||
let other_match_expr = expr_match(other_expr, other_arms);
|
||||
let other_match_expr = build::mk_expr(cx,
|
||||
span,
|
||||
@ -1047,7 +1043,6 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
|
||||
// Create the method body.
|
||||
let self_expr = build::mk_path(cx, span, ~[ self_ident ]);
|
||||
let self_expr = build::mk_unary(cx, span, deref, self_expr);
|
||||
let self_arms = dvec::unwrap(self_arms);
|
||||
let self_match_expr = expr_match(self_expr, self_arms);
|
||||
let self_match_expr = build::mk_expr(cx, span, self_match_expr);
|
||||
|
||||
@ -1148,7 +1143,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
|
||||
}
|
||||
|
||||
// Feed the discriminant to the byte iteration function.
|
||||
let stmts = dvec::DVec();
|
||||
let mut stmts = ~[];
|
||||
let discrim_stmt = call_substructure_iter_bytes_method(cx,
|
||||
span,
|
||||
discriminant);
|
||||
@ -1167,7 +1162,6 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
|
||||
}
|
||||
|
||||
// Create the pattern body.
|
||||
let stmts = dvec::unwrap(stmts);
|
||||
let match_body_block = build::mk_block_(cx, span, stmts);
|
||||
|
||||
// Create the arm.
|
||||
|
@ -19,8 +19,6 @@ use parse::parser::Parser;
|
||||
use parse::token::{Token, EOF, to_str, nonterminal};
|
||||
use parse::token;
|
||||
|
||||
use core::dvec::DVec;
|
||||
use core::dvec;
|
||||
use core::option::{Option, Some, None};
|
||||
use core::str;
|
||||
use core::uint;
|
||||
@ -115,7 +113,7 @@ pub struct MatcherPos {
|
||||
sep: Option<Token>,
|
||||
idx: uint,
|
||||
up: matcher_pos_up, // mutable for swapping only
|
||||
matches: ~[DVec<@named_match>],
|
||||
matches: ~[~[@named_match]],
|
||||
match_lo: uint, match_hi: uint,
|
||||
sp_lo: BytePos,
|
||||
}
|
||||
@ -151,7 +149,7 @@ pub fn initial_matcher_pos(+ms: ~[matcher], +sep: Option<Token>, lo: BytePos)
|
||||
}
|
||||
}
|
||||
}
|
||||
let matches = vec::from_fn(count_names(ms), |_i| dvec::DVec());
|
||||
let matches = vec::from_fn(count_names(ms), |_i| ~[]);
|
||||
~MatcherPos {
|
||||
elts: ms,
|
||||
sep: sep,
|
||||
@ -283,7 +281,7 @@ pub fn parse(
|
||||
|
||||
// Only touch the binders we have actually bound
|
||||
for uint::range(ei.match_lo, ei.match_hi) |idx| {
|
||||
let sub = ei.matches[idx].get();
|
||||
let sub = ei.matches[idx];
|
||||
new_pos.matches[idx]
|
||||
.push(@matched_seq(sub,
|
||||
mk_sp(ei.sp_lo,
|
||||
@ -331,7 +329,7 @@ pub fn parse(
|
||||
}
|
||||
|
||||
let matches = vec::map(ei.matches, // fresh, same size:
|
||||
|_m| DVec::<@named_match>());
|
||||
|_m| ~[]);
|
||||
let ei_t = ei;
|
||||
cur_eis.push(~MatcherPos {
|
||||
elts: copy *matchers,
|
||||
@ -358,9 +356,11 @@ pub fn parse(
|
||||
/* error messages here could be improved with links to orig. rules */
|
||||
if tok == EOF {
|
||||
if eof_eis.len() == 1u {
|
||||
return success(
|
||||
nameize(sess, ms,
|
||||
eof_eis[0u].matches.map(|dv| dv.pop())));
|
||||
let mut v = ~[];
|
||||
for vec::each_mut(eof_eis[0u].matches) |dv| {
|
||||
v.push(dv.pop());
|
||||
}
|
||||
return success(nameize(sess, ms, v));
|
||||
} else if eof_eis.len() > 1u {
|
||||
return error(sp, ~"Ambiguity: multiple successful parses");
|
||||
} else {
|
||||
|
@ -28,7 +28,6 @@ use print::pp;
|
||||
use print::pprust;
|
||||
|
||||
use core::char;
|
||||
use core::dvec::DVec;
|
||||
use core::io;
|
||||
use core::str;
|
||||
use core::u64;
|
||||
@ -63,7 +62,7 @@ pub struct ps {
|
||||
comments: Option<~[comments::cmnt]>,
|
||||
literals: Option<~[comments::lit]>,
|
||||
cur_cmnt_and_lit: @mut CurrentCommentAndLiteral,
|
||||
boxes: DVec<pp::breaks>,
|
||||
boxes: @mut ~[pp::breaks],
|
||||
ann: pp_ann
|
||||
}
|
||||
|
||||
@ -88,7 +87,7 @@ pub fn rust_printer(writer: io::Writer, intr: @ident_interner) -> @ps {
|
||||
cur_cmnt: 0,
|
||||
cur_lit: 0
|
||||
},
|
||||
boxes: DVec(),
|
||||
boxes: @mut ~[],
|
||||
ann: no_ann()
|
||||
};
|
||||
}
|
||||
@ -123,7 +122,7 @@ pub fn print_crate(cm: @CodeMap, intr: @ident_interner,
|
||||
cur_cmnt: 0,
|
||||
cur_lit: 0
|
||||
},
|
||||
boxes: DVec(),
|
||||
boxes: @mut ~[],
|
||||
ann: ann
|
||||
};
|
||||
print_crate_(s, crate);
|
||||
|
@ -13,12 +13,11 @@
|
||||
// type, and vice versa.
|
||||
|
||||
use core::prelude::*;
|
||||
use core::dvec::DVec;
|
||||
use core::hashmap::linear::LinearMap;
|
||||
|
||||
pub struct Interner<T> {
|
||||
priv map: @mut LinearMap<T, uint>,
|
||||
priv vect: DVec<T>,
|
||||
priv vect: @mut ~[T],
|
||||
}
|
||||
|
||||
// when traits can extend traits, we should extend index<uint,T> to get []
|
||||
@ -26,7 +25,7 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
|
||||
static fn new() -> Interner<T> {
|
||||
Interner {
|
||||
map: @mut LinearMap::new(),
|
||||
vect: DVec(),
|
||||
vect: @mut ~[],
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +57,7 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
|
||||
// this isn't "pure" in the traditional sense, because it can go from
|
||||
// failing to returning a value as items are interned. But for typestate,
|
||||
// where we first check a pred and then rely on it, ceasing to fail is ok.
|
||||
pure fn get(&self, idx: uint) -> T { self.vect.get_elt(idx) }
|
||||
pure fn get(&self, idx: uint) -> T { self.vect[idx] }
|
||||
|
||||
fn len(&self) -> uint { self.vect.len() }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user