1
Fork 0

librustc: Don't accept as Trait anymore; fix all occurrences of it.

This commit is contained in:
Patrick Walton 2013-03-12 13:00:50 -07:00
parent 24a0de4e7f
commit b1c699815d
101 changed files with 676 additions and 538 deletions

View file

@ -1227,7 +1227,7 @@ to pointers to the trait name, used as a type.
# impl Shape for int { }
# let mycircle = 0;
let myshape: Shape = @mycircle as @Shape;
let myshape: @Shape = @mycircle as @Shape;
~~~~
The resulting value is a managed box containing the value that was cast,

View file

@ -17,6 +17,7 @@ Simple compression
use libc;
use libc::{c_void, size_t, c_int};
use ptr;
use rand::RngUtil;
use vec;
#[cfg(test)] use rand;

View file

@ -20,6 +20,7 @@ pub mod linear {
use hash::Hash;
use iter;
use option::{None, Option, Some};
use rand::RngUtil;
use rand;
use uint;
use vec;

View file

@ -785,8 +785,7 @@ pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
-> Result<Writer, ~str> {
-> Result<@Writer, ~str> {
#[cfg(windows)]
fn wb() -> c_int {
(O_WRONLY | libc::consts::os::extra::O_BINARY) as c_int
@ -1079,22 +1078,24 @@ impl<T:Writer> WriterUtil for T {
}
#[allow(non_implicitly_copyable_typarams)]
pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<Writer, ~str> {
pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<@Writer, ~str> {
mk_file_writer(path, flags).chain(|w| result::Ok(w))
}
// FIXME: fileflags // #2004
pub fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
unsafe {
let f = do os::as_c_charp(path.to_str()) |pathbuf| {
do os::as_c_charp("w") |modebuf| {
libc::fopen(pathbuf, modebuf)
}
};
return if f as uint == 0u { result::Err(~"error opening "
+ path.to_str()) }
else { result::Ok(FILE_writer(f, true)) }
return if f as uint == 0u {
result::Err(~"error opening " + path.to_str())
} else {
result::Ok(FILE_writer(f, true))
}
}
}
@ -1142,14 +1143,14 @@ pub pure fn BytesWriter() -> BytesWriter {
BytesWriter { bytes: ~[], mut pos: 0u }
}
pub pure fn with_bytes_writer(f: &fn(Writer)) -> ~[u8] {
pub pure fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
let wr = @BytesWriter();
f(wr as Writer);
f(wr as @Writer);
let @BytesWriter{bytes, _} = wr;
return bytes;
}
pub pure fn with_str_writer(f: &fn(Writer)) -> ~str {
pub pure fn with_str_writer(f: &fn(@Writer)) -> ~str {
let mut v = with_bytes_writer(f);
// FIXME (#3758): This should not be needed.
@ -1277,8 +1278,8 @@ pub mod fsync {
pub trait FSyncable { fn fsync(&self, l: Level) -> int; }
// Call o.fsync after executing blk
pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
blk: &fn(v: Res<FSyncable>)) {
pub fn obj_sync(o: @FSyncable, opt_level: Option<Level>,
blk: &fn(v: Res<@FSyncable>)) {
blk(Res(Arg {
val: o, opt_level: opt_level,
fsync_fn: |o, l| o.fsync(l)
@ -1305,12 +1306,12 @@ mod tests {
~"A hoopy frood who really knows where his towel is.";
debug!(copy frood);
{
let out: io::Writer =
let out: @io::Writer =
result::get(
&io::file_writer(tmpfile, ~[io::Create, io::Truncate]));
out.write_str(frood);
}
let inp: io::Reader = result::get(&io::file_reader(tmpfile));
let inp: @io::Reader = result::get(&io::file_reader(tmpfile));
let frood2: ~str = inp.read_c_str();
debug!(copy frood2);
fail_unless!(frood == frood2);

View file

@ -1265,6 +1265,7 @@ mod tests {
use os::{remove_file, setenv};
use os;
use path::Path;
use rand::RngUtil;
use rand;
use run;
use str;
@ -1282,7 +1283,7 @@ mod tests {
}
fn make_rand_name() -> ~str {
let rng: rand::Rng = rand::Rng();
let rng: @rand::Rng = rand::Rng();
let n = ~"TEST" + rng.gen_str(10u);
fail_unless!(getenv(n).is_none());
n

View file

@ -22,97 +22,100 @@ use libc::size_t;
/// A type that can be randomly generated using an RNG
pub trait Rand {
static fn rand(rng: rand::Rng) -> Self;
static fn rand(rng: @rand::Rng) -> Self;
}
impl Rand for int {
static fn rand(rng: rand::Rng) -> int {
static fn rand(rng: @rand::Rng) -> int {
rng.gen_int()
}
}
impl Rand for i8 {
static fn rand(rng: rand::Rng) -> i8 {
static fn rand(rng: @rand::Rng) -> i8 {
rng.gen_i8()
}
}
impl Rand for i16 {
static fn rand(rng: rand::Rng) -> i16 {
static fn rand(rng: @rand::Rng) -> i16 {
rng.gen_i16()
}
}
impl Rand for i32 {
static fn rand(rng: rand::Rng) -> i32 {
static fn rand(rng: @rand::Rng) -> i32 {
rng.gen_i32()
}
}
impl Rand for i64 {
static fn rand(rng: rand::Rng) -> i64 {
static fn rand(rng: @rand::Rng) -> i64 {
rng.gen_i64()
}
}
impl Rand for u8 {
static fn rand(rng: rand::Rng) -> u8 {
static fn rand(rng: @rand::Rng) -> u8 {
rng.gen_u8()
}
}
impl Rand for u16 {
static fn rand(rng: rand::Rng) -> u16 {
static fn rand(rng: @rand::Rng) -> u16 {
rng.gen_u16()
}
}
impl Rand for u32 {
static fn rand(rng: rand::Rng) -> u32 {
static fn rand(rng: @rand::Rng) -> u32 {
rng.gen_u32()
}
}
impl Rand for u64 {
static fn rand(rng: rand::Rng) -> u64 {
static fn rand(rng: @rand::Rng) -> u64 {
rng.gen_u64()
}
}
impl Rand for float {
static fn rand(rng: rand::Rng) -> float {
static fn rand(rng: @rand::Rng) -> float {
rng.gen_float()
}
}
impl Rand for f32 {
static fn rand(rng: rand::Rng) -> f32 {
static fn rand(rng: @rand::Rng) -> f32 {
rng.gen_f32()
}
}
impl Rand for f64 {
static fn rand(rng: rand::Rng) -> f64 {
static fn rand(rng: @rand::Rng) -> f64 {
rng.gen_f64()
}
}
impl Rand for char {
static fn rand(rng: rand::Rng) -> char {
static fn rand(rng: @rand::Rng) -> char {
rng.gen_char()
}
}
impl Rand for bool {
static fn rand(rng: rand::Rng) -> bool {
static fn rand(rng: @rand::Rng) -> bool {
rng.gen_bool()
}
}
impl<T:Rand> Rand for Option<T> {
static fn rand(rng: rand::Rng) -> Option<T> {
if rng.gen_bool() { Some(Rand::rand(rng)) }
else { None }
static fn rand(rng: @rand::Rng) -> Option<T> {
if rng.gen_bool() {
Some(Rand::rand(rng))
} else {
None
}
}
}
@ -145,8 +148,83 @@ pub struct Weighted<T> {
item: T,
}
pub trait RngUtil {
fn gen<T:Rand>(&self) -> T;
/// Return a random int
fn gen_int(&self) -> int;
fn gen_int_range(&self, start: int, end: int) -> int;
/// Return a random i8
fn gen_i8(&self) -> i8;
/// Return a random i16
fn gen_i16(&self) -> i16;
/// Return a random i32
fn gen_i32(&self) -> i32;
/// Return a random i64
fn gen_i64(&self) -> i64;
/// Return a random uint
fn gen_uint(&self) -> uint;
/**
* Return a uint randomly chosen from the range [start, end),
* failing if start >= end
*/
fn gen_uint_range(&self, start: uint, end: uint) -> uint;
/// Return a random u8
fn gen_u8(&self) -> u8;
/// Return a random u16
fn gen_u16(&self) -> u16;
/// Return a random u32
fn gen_u32(&self) -> u32;
/// Return a random u64
fn gen_u64(&self) -> u64;
/// Return a random float in the interval [0,1]
fn gen_float(&self) -> float;
/// Return a random f32 in the interval [0,1]
fn gen_f32(&self) -> f32;
/// Return a random f64 in the interval [0,1]
fn gen_f64(&self) -> f64;
/// Return a random char
fn gen_char(&self) -> char;
/**
* Return a char randomly chosen from chars, failing if chars is empty
*/
fn gen_char_from(&self, chars: &str) -> char;
/// Return a random bool
fn gen_bool(&self) -> bool;
/// Return a bool with a 1 in n chance of true
fn gen_weighted_bool(&self, n: uint) -> bool;
/**
* Return a random string of the specified length composed of A-Z,a-z,0-9
*/
fn gen_str(&self, len: uint) -> ~str;
/// Return a random byte string of the specified length
fn gen_bytes(&self, len: uint) -> ~[u8];
/// Choose an item randomly, failing if values is empty
fn choose<T:Copy>(&self, values: &[T]) -> T;
/// Choose Some(item) randomly, returning None if values is empty
fn choose_option<T:Copy>(&self, values: &[T]) -> Option<T>;
/**
* Choose an item respecting the relative weights, failing if the sum of
* the weights is 0
*/
fn choose_weighted<T:Copy>(&self, v : &[Weighted<T>]) -> T;
/**
* Choose Some(item) respecting the relative weights, returning none if
* the sum of the weights is 0
*/
fn choose_weighted_option<T:Copy>(&self, v: &[Weighted<T>]) -> Option<T>;
/**
* Return a vec containing copies of the items, in order, where
* the weight of the item determines how many copies there are
*/
fn weighted_vec<T:Copy>(&self, v: &[Weighted<T>]) -> ~[T];
/// Shuffle a vec
fn shuffle<T:Copy>(&self, values: &[T]) -> ~[T];
/// Shuffle a mutable vec in place
fn shuffle_mut<T>(&self, values: &mut [T]);
}
/// Extension methods for random number generators
pub impl Rng {
impl RngUtil for @Rng {
/// Return a random value for a Rand type
fn gen<T:Rand>(&self) -> T {
Rand::rand(*self)
@ -407,7 +485,7 @@ pub fn seed() -> ~[u8] {
}
/// Create a random number generator with a system specified seed
pub fn Rng() -> Rng {
pub fn Rng() -> @Rng {
seeded_rng(seed())
}
@ -449,7 +527,7 @@ impl Rng for XorShiftState {
}
}
pub pure fn xorshift() -> Rng {
pub pure fn xorshift() -> @Rng {
// constants taken from http://en.wikipedia.org/wiki/Xorshift
seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32)
}
@ -467,7 +545,7 @@ fn tls_rng_state(_v: @RandRes) {}
* seeded by the system. Intended to be used in method chaining style, ie
* task_rng().gen_int().
*/
pub fn task_rng() -> Rng {
pub fn task_rng() -> @Rng {
let r : Option<@RandRes>;
unsafe {
r = task::local_data::local_data_get(tls_rng_state);

View file

@ -41,7 +41,7 @@ trait EscapedCharWriter {
fn write_escaped_char(&self, ch: char);
}
impl EscapedCharWriter for Writer {
impl EscapedCharWriter for @Writer {
fn write_escaped_char(&self, ch: char) {
match ch {
'\t' => self.write_str("\\t"),

View file

@ -45,13 +45,13 @@ pub trait Program {
fn get_id(&mut self) -> pid_t;
/// Returns an io::writer that can be used to write to stdin
fn input(&mut self) -> io::Writer;
fn input(&mut self) -> @io::Writer;
/// Returns an io::reader that can be used to read from stdout
fn output(&mut self) -> io::Reader;
fn output(&mut self) -> @io::Reader;
/// Returns an io::reader that can be used to read from stderr
fn err(&mut self) -> io::Reader;
fn err(&mut self) -> @io::Reader;
/// Closes the handle to the child processes standard input
fn close_input(&mut self);
@ -207,7 +207,7 @@ pub fn run_program(prog: &str, args: &[~str]) -> int {
*
* A class with a <program> field
*/
pub fn start_program(prog: &str, args: &[~str]) -> Program {
pub fn start_program(prog: &str, args: &[~str]) -> @Program {
let pipe_input = os::pipe();
let pipe_output = os::pipe();
let pipe_err = os::pipe();
@ -274,13 +274,13 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
impl Program for ProgRes {
fn get_id(&mut self) -> pid_t { return self.r.pid; }
fn input(&mut self) -> io::Writer {
fn input(&mut self) -> @io::Writer {
io::fd_writer(self.r.in_fd, false)
}
fn output(&mut self) -> io::Reader {
fn output(&mut self) -> @io::Reader {
io::FILE_reader(self.r.out_file, false)
}
fn err(&mut self) -> io::Reader {
fn err(&mut self) -> @io::Reader {
io::FILE_reader(self.r.err_file, false)
}
fn close_input(&mut self) { close_repr_input(&mut self.r); }

View file

@ -23,7 +23,7 @@ use super::rt::rust_task;
pub trait LocalData { }
impl<T:Durable> LocalData for @T { }
impl Eq for LocalData {
impl Eq for @LocalData {
pure fn eq(&self, other: &@LocalData) -> bool {
unsafe {
let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self));
@ -36,7 +36,7 @@ impl Eq for LocalData {
// If TLS is used heavily in future, this could be made more efficient with a
// proper map.
type TaskLocalElement = (*libc::c_void, *libc::c_void, LocalData);
type TaskLocalElement = (*libc::c_void, *libc::c_void, @LocalData);
// Has to be a pointer at outermost layer; the foreign call returns void *.
type TaskLocalMap = @mut ~[Option<TaskLocalElement>];

View file

@ -8,12 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use sys;
use cast;
use libc::{c_void, size_t};
use rand::RngUtil;
use rand;
use sys;
use task;
use vec;
use rand;
use libc::{c_void, size_t};
#[cfg(test)] use uint;

View file

@ -202,10 +202,13 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
newexpr: ast::expr, tm: test_mode) ->
ast::crate {
let j: @mut uint = @mut 0u;
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
original: &ast::expr_, fld: fold::ast_fold,
tm_: test_mode) ->
ast::expr_ {
fn fold_expr_rep(j_: @mut uint,
i_: uint,
newexpr_: ast::expr_,
original: &ast::expr_,
fld: @fold::ast_fold,
tm_: test_mode)
-> ast::expr_ {
*j_ += 1u;
if i_ + 1u == *j_ && safe_to_replace_expr(original, tm_) {
newexpr_
@ -229,10 +232,13 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
tm: test_mode) -> ast::crate {
let j: @mut uint = @mut 0u;
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
original: &ast::ty_, fld: fold::ast_fold,
tm_: test_mode) ->
ast::ty_ {
fn fold_ty_rep(j_: @mut uint,
i_: uint,
newty_: ast::ty_,
original: &ast::ty_,
fld: @fold::ast_fold,
tm_: test_mode)
-> ast::ty_ {
*j_ += 1u;
if i_ + 1u == *j_ && safe_to_replace_ty(original, tm_) {
newty_
@ -252,7 +258,7 @@ pub fn under(n: uint, it: &fn(uint)) {
while i < n { it(i); i += 1u; }
}
pub fn as_str(f: @fn(+x: io::Writer)) -> ~str {
pub fn as_str(f: @fn(+x: @io::Writer)) -> ~str {
io::with_str_writer(f)
}
@ -304,7 +310,8 @@ pub fn check_variants_T<T: Copy>(
diagnostic::mk_span_handler(handler, codemap),
crate2,
fname,
rdr, a,
rdr,
a,
pprust::no_ann(),
false))
};

View file

@ -681,7 +681,7 @@ pub fn build_session(sopts: @session::options,
pub fn build_session_(sopts: @session::options,
cm: @codemap::CodeMap,
demitter: diagnostic::Emitter,
span_diagnostic_handler: diagnostic::span_handler)
span_diagnostic_handler: @diagnostic::span_handler)
-> Session {
let target_cfg = build_target_config(sopts, demitter);
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
@ -870,7 +870,7 @@ pub fn early_error(emitter: diagnostic::Emitter, msg: ~str) -> ! {
fail!();
}
pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) {
pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) {
metadata::loader::list_file_metadata(
sess.parse_sess.interner,
session::sess_os_to_meta_os(sess.targ_cfg.os), path, out);

View file

@ -154,8 +154,8 @@ pub struct Session_ {
codemap: @codemap::CodeMap,
// For a library crate, this is always none
main_fn: @mut Option<(node_id, codemap::span)>,
span_diagnostic: diagnostic::span_handler,
filesearch: filesearch::FileSearch,
span_diagnostic: @diagnostic::span_handler,
filesearch: @filesearch::FileSearch,
building_library: @mut bool,
working_dir: Path,
lint_settings: lint::LintSettings
@ -227,7 +227,7 @@ pub impl Session {
fn next_node_id(&self) -> ast::node_id {
return syntax::parse::next_node_id(self.parse_sess);
}
fn diagnostic(&self) -> diagnostic::span_handler {
fn diagnostic(&self) -> @diagnostic::span_handler {
self.span_diagnostic
}
fn debugging_opt(&self, opt: uint) -> bool {

View file

@ -63,7 +63,7 @@ fn filter_view_item(cx: @Context, &&view_item: @ast::view_item
}
}
fn fold_mod(cx: @Context, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod {
fn fold_mod(cx: @Context, m: &ast::_mod, fld: @fold::ast_fold) -> ast::_mod {
let filtered_items =
m.items.filter_mapped(|a| filter_item(cx, *a));
let filtered_view_items =
@ -84,7 +84,7 @@ fn filter_foreign_item(cx: @Context, &&item: @ast::foreign_item) ->
fn fold_foreign_mod(
cx: @Context,
nm: &ast::foreign_mod,
fld: fold::ast_fold
fld: @fold::ast_fold
) -> ast::foreign_mod {
let filtered_items =
nm.items.filter_mapped(|a| filter_foreign_item(cx, *a));
@ -99,7 +99,7 @@ fn fold_foreign_mod(
}
fn fold_item_underscore(cx: @Context, item: &ast::item_,
fld: fold::ast_fold) -> ast::item_ {
fld: @fold::ast_fold) -> ast::item_ {
let item = match *item {
ast::item_impl(ref a, b, c, ref methods) => {
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
@ -135,7 +135,7 @@ fn filter_stmt(cx: @Context, &&stmt: @ast::stmt) ->
fn fold_block(
cx: @Context,
b: &ast::blk_,
fld: fold::ast_fold
fld: @fold::ast_fold
) -> ast::blk_ {
let filtered_stmts =
b.stmts.filter_mapped(|a| filter_stmt(cx, *a));

View file

@ -128,7 +128,7 @@ pub mod intrinsic {
#[abi = "rust-intrinsic"]
pub extern {
pub fn get_tydesc<T>() -> *();
pub fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor);
pub fn visit_tydesc(++td: *TyDesc, &&tv: @TyVisitor);
}
}
}

View file

@ -39,7 +39,7 @@ struct TestCtxt {
sess: session::Session,
crate: @ast::crate,
path: ~[ast::ident],
ext_cx: ext_ctxt,
ext_cx: @ext_ctxt,
testfns: ~[Test]
}
@ -102,7 +102,7 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
fn fold_mod(cx: @mut TestCtxt,
m: &ast::_mod,
fld: fold::ast_fold)
fld: @fold::ast_fold)
-> ast::_mod {
// Remove any #[main] from the AST so it doesn't clash with
// the one we're going to add. Only if compiling an executable.
@ -125,7 +125,7 @@ fn fold_mod(cx: @mut TestCtxt,
fn fold_crate(cx: @mut TestCtxt,
c: &ast::crate_,
fld: fold::ast_fold)
fld: @fold::ast_fold)
-> ast::crate_ {
let folded = fold::noop_fold_crate(c, fld);
@ -138,7 +138,7 @@ fn fold_crate(cx: @mut TestCtxt,
}
fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: fold::ast_fold)
fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: @fold::ast_fold)
-> Option<@ast::item> {
cx.path.push(i.ident);
debug!("current path: %s",

View file

@ -30,10 +30,10 @@ use std::oldmap::HashMap;
// Traverses an AST, reading all the information about use'd crates and extern
// libraries necessary for later resolving, typechecking, linking, etc.
pub fn read_crates(diag: span_handler,
pub fn read_crates(diag: @span_handler,
crate: ast::crate,
cstore: @mut cstore::CStore,
filesearch: FileSearch,
filesearch: @FileSearch,
os: loader::os,
statik: bool,
intr: @ident_interner) {
@ -75,7 +75,7 @@ fn dump_crates(crate_cache: @mut ~[cache_entry]) {
}
fn warn_if_multiple_versions(e: @mut Env,
diag: span_handler,
diag: @span_handler,
crate_cache: @mut ~[cache_entry]) {
use core::either::*;
@ -115,8 +115,8 @@ fn warn_if_multiple_versions(e: @mut Env,
}
struct Env {
diag: span_handler,
filesearch: FileSearch,
diag: @span_handler,
filesearch: @FileSearch,
cstore: @mut cstore::CStore,
os: loader::os,
statik: bool,

View file

@ -1017,14 +1017,15 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
}
fn list_meta_items(intr: @ident_interner,
meta_items: ebml::Doc, out: io::Writer) {
meta_items: ebml::Doc,
out: @io::Writer) {
for get_meta_items(meta_items).each |mi| {
out.write_str(fmt!("%s\n", pprust::meta_item_to_str(*mi, intr)));
}
}
fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: &str,
out: io::Writer) {
out: @io::Writer) {
out.write_str(fmt!("=Crate Attributes (%s)=\n", hash));
for get_attributes(md).each |attr| {
@ -1063,7 +1064,7 @@ pub fn get_crate_deps(intr: @ident_interner, data: @~[u8]) -> ~[crate_dep] {
return deps;
}
fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: io::Writer) {
fn list_crate_deps(intr: @ident_interner, data: @~[u8], out: @io::Writer) {
out.write_str(~"=External Dependencies=\n");
for get_crate_deps(intr, data).each |dep| {
@ -1106,7 +1107,7 @@ fn iter_crate_items(intr: @ident_interner, cdata: cmd,
}
pub fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8],
out: io::Writer) {
out: @io::Writer) {
let hash = get_crate_hash(bytes);
let md = reader::Doc(bytes);
list_crate_attributes(intr, md, *hash, out);

View file

@ -57,7 +57,7 @@ pub type encode_inlined_item = @fn(ecx: @EncodeContext,
ii: ast::inlined_item);
pub struct EncodeParams {
diag: span_handler,
diag: @span_handler,
tcx: ty::ctxt,
reachable: HashMap<ast::node_id, ()>,
reexports2: middle::resolve::ExportMap2,
@ -83,7 +83,7 @@ struct Stats {
}
pub struct EncodeContext {
diag: span_handler,
diag: @span_handler,
tcx: ty::ctxt,
stats: @mut Stats,
reachable: HashMap<ast::node_id, ()>,
@ -1054,7 +1054,7 @@ fn create_index<T:Copy + Hash + IterBytes>(index: ~[entry<T>]) ->
}
fn encode_index<T>(ebml_w: writer::Encoder, buckets: ~[@~[entry<T>]],
write_fn: &fn(io::Writer, T)) {
write_fn: &fn(@io::Writer, T)) {
let writer = ebml_w.writer;
ebml_w.start_tag(tag_index);
let mut bucket_locs: ~[uint] = ~[];
@ -1081,9 +1081,9 @@ fn encode_index<T>(ebml_w: writer::Encoder, buckets: ~[@~[entry<T>]],
ebml_w.end_tag();
}
fn write_str(writer: io::Writer, &&s: ~str) { writer.write_str(s); }
fn write_str(writer: @io::Writer, &&s: ~str) { writer.write_str(s); }
fn write_int(writer: io::Writer, &&n: int) {
fn write_int(writer: @io::Writer, &&n: int) {
fail_unless!(n < 0x7fff_ffff);
writer.write_be_u32(n as u32);
}
@ -1326,7 +1326,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
type_abbrevs: ty::new_ty_hash()
};
let ebml_w = writer::Encoder(wr as io::Writer);
let ebml_w = writer::Encoder(wr as @io::Writer);
encode_hash(ebml_w, ecx.link_meta.extras_hash);

View file

@ -37,7 +37,8 @@ pub trait FileSearch {
pub fn mk_filesearch(maybe_sysroot: Option<Path>,
target_triple: &str,
+addl_lib_search_paths: ~[Path]) -> FileSearch {
+addl_lib_search_paths: ~[Path])
-> @FileSearch {
struct FileSearchImpl {
sysroot: Path,
addl_lib_search_paths: ~[Path],
@ -78,7 +79,7 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
} as @FileSearch
}
pub fn search<T:Copy>(filesearch: FileSearch, pick: pick<T>) -> Option<T> {
pub fn search<T:Copy>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
let mut rslt = None;
for filesearch.lib_search_paths().each |lib_search_path| {
debug!("searching %s", lib_search_path.to_str());

View file

@ -44,8 +44,8 @@ pub enum os {
}
pub struct Context {
diag: span_handler,
filesearch: FileSearch,
diag: @span_handler,
filesearch: @FileSearch,
span: span,
ident: ast::ident,
metas: ~[@ast::meta_item],
@ -87,7 +87,7 @@ fn libname(cx: Context) -> (~str, ~str) {
fn find_library_crate_aux(
cx: Context,
(prefix, suffix): (~str, ~str),
filesearch: filesearch::FileSearch
filesearch: @filesearch::FileSearch
) -> Option<(~str, @~[u8])> {
let crate_name = crate_name_from_metas(cx.metas);
let prefix: ~str = prefix + *crate_name + ~"-";
@ -156,7 +156,8 @@ pub fn crate_name_from_metas(metas: &[@ast::meta_item]) -> @~str {
}
}
pub fn note_linkage_attrs(intr: @ident_interner, diag: span_handler,
pub fn note_linkage_attrs(intr: @ident_interner,
diag: @span_handler,
attrs: ~[ast::attribute]) {
for attr::find_linkage_metas(attrs).each |mi| {
diag.handler().note(fmt!("meta: %s",
@ -252,7 +253,9 @@ pub fn meta_section_name(os: os) -> ~str {
// A diagnostic function for dumping crate metadata to an output stream
pub fn list_file_metadata(intr: @ident_interner,
os: os, path: &Path, out: io::Writer) {
os: os,
path: &Path,
out: @io::Writer) {
match get_metadata_section(os, path) {
option::Some(bytes) => decoder::list_crate_metadata(intr, bytes, out),
option::None => {

View file

@ -27,7 +27,7 @@ use syntax::print::pprust::*;
use middle::ty::Vid;
pub struct ctxt {
diag: span_handler,
diag: @span_handler,
// Def -> str Callback:
ds: @fn(def_id) -> ~str,
// The type context.
@ -57,7 +57,7 @@ fn cx_uses_abbrevs(cx: @ctxt) -> bool {
}
}
pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
pub fn enc_ty(w: @io::Writer, cx: @ctxt, t: ty::t) {
match cx.abbrevs {
ac_no_abbrevs => {
let result_str = match cx.tcx.short_names_cache.find(&t) {
@ -113,7 +113,7 @@ pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
}
}
}
fn enc_mt(w: io::Writer, cx: @ctxt, mt: ty::mt) {
fn enc_mt(w: @io::Writer, cx: @ctxt, mt: ty::mt) {
match mt.mutbl {
m_imm => (),
m_mutbl => w.write_char('m'),
@ -122,7 +122,7 @@ fn enc_mt(w: io::Writer, cx: @ctxt, mt: ty::mt) {
enc_ty(w, cx, mt.ty);
}
fn enc_opt<T>(w: io::Writer, t: Option<T>, enc_f: &fn(T)) {
fn enc_opt<T>(w: @io::Writer, t: Option<T>, enc_f: &fn(T)) {
match &t {
&None => w.write_char('n'),
&Some(ref v) => {
@ -132,7 +132,7 @@ fn enc_opt<T>(w: io::Writer, t: Option<T>, enc_f: &fn(T)) {
}
}
fn enc_substs(w: io::Writer, cx: @ctxt, substs: ty::substs) {
fn enc_substs(w: @io::Writer, cx: @ctxt, substs: ty::substs) {
do enc_opt(w, substs.self_r) |r| { enc_region(w, cx, r) }
do enc_opt(w, substs.self_ty) |t| { enc_ty(w, cx, t) }
w.write_char('[');
@ -140,7 +140,7 @@ fn enc_substs(w: io::Writer, cx: @ctxt, substs: ty::substs) {
w.write_char(']');
}
fn enc_region(w: io::Writer, cx: @ctxt, r: ty::Region) {
fn enc_region(w: @io::Writer, cx: @ctxt, r: ty::Region) {
match r {
ty::re_bound(br) => {
w.write_char('b');
@ -169,7 +169,7 @@ fn enc_region(w: io::Writer, cx: @ctxt, r: ty::Region) {
}
}
fn enc_bound_region(w: io::Writer, cx: @ctxt, br: ty::bound_region) {
fn enc_bound_region(w: @io::Writer, cx: @ctxt, br: ty::bound_region) {
match br {
ty::br_self => w.write_char('s'),
ty::br_anon(idx) => {
@ -194,7 +194,7 @@ fn enc_bound_region(w: io::Writer, cx: @ctxt, br: ty::bound_region) {
}
}
pub fn enc_vstore(w: io::Writer, cx: @ctxt, v: ty::vstore) {
pub fn enc_vstore(w: @io::Writer, cx: @ctxt, v: ty::vstore) {
w.write_char('/');
match v {
ty::vstore_fixed(u) => {
@ -214,7 +214,7 @@ pub fn enc_vstore(w: io::Writer, cx: @ctxt, v: ty::vstore) {
}
}
pub fn enc_trait_store(w: io::Writer, cx: @ctxt, s: ty::TraitStore) {
pub fn enc_trait_store(w: @io::Writer, cx: @ctxt, s: ty::TraitStore) {
match s {
ty::UniqTraitStore => w.write_char('~'),
ty::BoxTraitStore => w.write_char('@'),
@ -226,7 +226,7 @@ pub fn enc_trait_store(w: io::Writer, cx: @ctxt, s: ty::TraitStore) {
}
}
fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
fn enc_sty(w: @io::Writer, cx: @ctxt, +st: ty::sty) {
match st {
ty::ty_nil => w.write_char('n'),
ty::ty_bot => w.write_char('z'),
@ -337,7 +337,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
}
}
fn enc_sigil(w: io::Writer, sigil: Sigil) {
fn enc_sigil(w: @io::Writer, sigil: Sigil) {
match sigil {
ManagedSigil => w.write_str("@"),
OwnedSigil => w.write_str("~"),
@ -345,19 +345,19 @@ fn enc_sigil(w: io::Writer, sigil: Sigil) {
}
}
pub fn enc_arg(w: io::Writer, cx: @ctxt, arg: ty::arg) {
pub fn enc_arg(w: @io::Writer, cx: @ctxt, arg: ty::arg) {
enc_mode(w, cx, arg.mode);
enc_ty(w, cx, arg.ty);
}
pub fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) {
pub fn enc_mode(w: @io::Writer, cx: @ctxt, m: mode) {
match ty::resolved_mode(cx.tcx, m) {
by_copy => w.write_char('+'),
by_ref => w.write_char('='),
}
}
fn enc_purity(w: io::Writer, p: purity) {
fn enc_purity(w: @io::Writer, p: purity) {
match p {
pure_fn => w.write_char('p'),
impure_fn => w.write_char('i'),
@ -366,26 +366,26 @@ fn enc_purity(w: io::Writer, p: purity) {
}
}
fn enc_abi(w: io::Writer, a: Abi) {
fn enc_abi(w: @io::Writer, a: Abi) {
match a {
RustAbi => w.write_char('r'),
}
}
fn enc_onceness(w: io::Writer, o: Onceness) {
fn enc_onceness(w: @io::Writer, o: Onceness) {
match o {
Once => w.write_char('o'),
Many => w.write_char('m')
}
}
fn enc_bare_fn_ty(w: io::Writer, cx: @ctxt, ft: &ty::BareFnTy) {
fn enc_bare_fn_ty(w: @io::Writer, cx: @ctxt, ft: &ty::BareFnTy) {
enc_purity(w, ft.purity);
enc_abi(w, ft.abi);
enc_fn_sig(w, cx, &ft.sig);
}
fn enc_closure_ty(w: io::Writer, cx: @ctxt, ft: &ty::ClosureTy) {
fn enc_closure_ty(w: @io::Writer, cx: @ctxt, ft: &ty::ClosureTy) {
enc_sigil(w, ft.sigil);
enc_purity(w, ft.purity);
enc_onceness(w, ft.onceness);
@ -393,7 +393,7 @@ fn enc_closure_ty(w: io::Writer, cx: @ctxt, ft: &ty::ClosureTy) {
enc_fn_sig(w, cx, &ft.sig);
}
fn enc_fn_sig(w: io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
w.write_char('[');
for fsig.inputs.each |arg| {
enc_arg(w, cx, *arg);
@ -402,7 +402,7 @@ fn enc_fn_sig(w: io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
enc_ty(w, cx, fsig.output);
}
pub fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
pub fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
for vec::each(*bs) |bound| {
match *bound {
ty::bound_owned => w.write_char('S'),

View file

@ -292,7 +292,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) {
// nested items, as otherwise it would get confused when translating
// inlined items.
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
fn drop_nested_items(blk: &ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
fn drop_nested_items(blk: &ast::blk_, fld: @fold::ast_fold) -> ast::blk_ {
let stmts_sans_items = do blk.stmts.filtered |stmt| {
match stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |

View file

@ -825,7 +825,8 @@ pub impl Liveness {
}
}
fn write_vars(&self, wr: io::Writer,
fn write_vars(&self,
wr: @io::Writer,
ln: LiveNode,
test: &fn(uint) -> LiveNode) {
let node_base_idx = self.idx(ln, Variable(0));

View file

@ -406,6 +406,6 @@ impl ABIInfo for X86_64_ABIInfo {
}
}
pub fn x86_64_abi_info() -> ABIInfo {
pub fn x86_64_abi_info() -> @ABIInfo {
return @X86_64_ABIInfo as @ABIInfo;
}

View file

@ -1035,7 +1035,7 @@ pub fn T_captured_tydescs(cx: @CrateContext, n: uint) -> TypeRef {
pub fn T_opaque_trait(cx: @CrateContext, store: ty::TraitStore) -> TypeRef {
match store {
ty::BoxTraitStore | ty::BareTraitStore => {
ty::BoxTraitStore => {
T_struct(~[T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)])
}
ty::UniqTraitStore => {
@ -1046,6 +1046,9 @@ pub fn T_opaque_trait(cx: @CrateContext, store: ty::TraitStore) -> TypeRef {
ty::RegionTraitStore(_) => {
T_struct(~[T_ptr(cx.tydesc_type), T_ptr(T_i8())])
}
ty::BareTraitStore => {
cx.sess.bug(~"can't make T_opaque_trait with bare trait store")
}
}
}

View file

@ -42,7 +42,7 @@ use syntax::{ast, ast_util};
use syntax::{attr, ast_map};
use syntax::parse::token::special_idents;
fn abi_info(arch: session::arch) -> cabi::ABIInfo {
fn abi_info(arch: session::arch) -> @cabi::ABIInfo {
return match arch {
arch_x86_64 => x86_64_abi_info(),
arch_arm => cabi_arm::abi_info(),

View file

@ -244,7 +244,7 @@ pub struct InstantiatedTraitRef {
pub type ctxt = @ctxt_;
struct ctxt_ {
diag: syntax::diagnostic::span_handler,
diag: @syntax::diagnostic::span_handler,
interner: HashMap<intern_key, t_box>,
next_id: @mut uint,
vecs_implicitly_copyable: bool,
@ -3600,11 +3600,7 @@ pub fn impl_traits(cx: ctxt, id: ast::def_id, store: TraitStore) -> ~[t] {
fn storeify(cx: ctxt, ty: t, store: TraitStore) -> t {
match ty::get(ty).sty {
ty::ty_trait(did, ref substs, trait_store) => {
if store == trait_store ||
(store == BareTraitStore &&
trait_store == BoxTraitStore) ||
(store == BoxTraitStore &&
trait_store == BareTraitStore) {
if store == trait_store {
ty
} else {
mk_trait(cx, did, (/*bad*/copy *substs), store)

View file

@ -218,7 +218,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
// Handle @, ~, and & being able to mean estrs and evecs.
// If a_seq_ty is a str or a vec, make it an estr/evec.
// Also handle function sigils and first-class trait types.
// Also handle first-class trait types.
fn mk_pointer<AC:AstConv,RS:region_scope + Copy + Durable>(
self: &AC,
rscope: &RS,

View file

@ -3204,6 +3204,19 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
fail_unless!(ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name));
let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name);
let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name);
let visitor_trait = match ty::get(visitor_trait).sty {
ty::ty_trait(trait_def_id, ref trait_substs, _) => {
ty::mk_trait(tcx,
trait_def_id,
copy *trait_substs,
ty::BoxTraitStore)
}
_ => {
tcx.sess.span_bug(it.span, ~"TyVisitor wasn't a trait?!")
}
};
let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty,
mutbl: ast::m_imm});
(0u, ~[arg(ast::by_copy, td_ptr),

View file

@ -198,12 +198,19 @@ pub fn lookup_vtable(vcx: &VtableContext,
vcx.infcx.ty_to_str(ity));
match ty::get(ity).sty {
ty::ty_trait(idid, _, _) => {
ty::ty_trait(idid, ref isubsts, _) => {
if trait_id == idid {
debug!("(checking vtable) @0 \
relating ty to trait \
ty with did %?",
idid);
// Convert `ity` so that it has the right vstore.
let ity = ty::mk_trait(vcx.tcx(),
idid,
copy *isubsts,
trait_store);
relate_trait_tys(vcx, location_info,
trait_ty, ity);
let vtable = vtable_param(n, n_bound);
@ -570,7 +577,6 @@ pub fn early_resolve_expr(ex: @ast::expr,
match (&ty::get(ty).sty, store) {
(&ty::ty_box(mt), ty::BoxTraitStore) |
// XXX: Bare trait store is deprecated.
(&ty::ty_box(mt), ty::BareTraitStore) |
(&ty::ty_uniq(mt), ty::UniqTraitStore) |
(&ty::ty_rptr(_, mt), ty::RegionTraitStore(*)) => {
let location_info =
@ -622,8 +628,14 @@ pub fn early_resolve_expr(ex: @ast::expr,
}
}
// XXX: Remove bare below.
(_, ty::BoxTraitStore) | (_, ty::BareTraitStore) => {
(_, ty::BareTraitStore) => {
fcx.ccx.tcx.sess.span_err(
ex.span,
~"a sigil (`@`, `~`, or `&`) must be specified \
when casting to a trait");
}
(_, ty::BoxTraitStore) => {
fcx.ccx.tcx.sess.span_err(
ex.span,
fmt!("can only cast an @-pointer \

View file

@ -369,12 +369,6 @@ pub fn super_trait_stores<C:Combine>(self: &C,
}
}
// XXX: This should go away soon.
(ty::BareTraitStore, ty::BoxTraitStore) |
(ty::BoxTraitStore, ty::BareTraitStore) => {
Ok(ty::BoxTraitStore)
}
_ if a == b => {
Ok(a)
}

View file

@ -125,7 +125,8 @@ pub struct binding_rscope {
pub fn in_binding_rscope<RS:region_scope + Copy + Durable>(self: &RS)
-> binding_rscope {
let base = @(copy *self) as @region_scope;
let base = @copy *self;
let base = base as @region_scope;
binding_rscope { base: base, anon_bindings: @mut 0 }
}
impl region_scope for binding_rscope {

View file

@ -59,7 +59,7 @@ enum CmdAction {
/// A utility function that hands off a pretty printer to a callback.
fn with_pp(intr: @token::ident_interner,
cb: &fn(@pprust::ps, io::Writer)) -> ~str {
cb: &fn(@pprust::ps, @io::Writer)) -> ~str {
do io::with_str_writer |writer| {
let pp = pprust::rust_printer(writer, intr);
@ -257,7 +257,7 @@ fn get_line(prompt: ~str) -> Option<~str> {
}
/// Run a command, e.g. :clear, :exit, etc.
fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer,
fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
cmd: ~str, args: ~[~str]) -> CmdAction {
let mut action = action_none;
match cmd {
@ -334,7 +334,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer,
/// Executes a line of input, which may either be rust code or a
/// :command. Returns a new Repl if it has changed.
fn run_line(repl: &mut Repl, in: io::Reader, out: io::Writer, line: ~str)
fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str)
-> Option<Repl> {
if line.starts_with(~":") {
let full = line.substr(1, line.len() - 1);

View file

@ -70,13 +70,14 @@ struct ListenerFn {
struct ReadyCtx {
sess: session::Session,
crate: @ast::crate,
ext_cx: ext_ctxt,
ext_cx: @ext_ctxt,
path: ~[ast::ident],
fns: ~[ListenerFn]
}
fn fold_mod(_ctx: @mut ReadyCtx, m: &ast::_mod,
fold: fold::ast_fold) -> ast::_mod {
fn fold_mod(_ctx: @mut ReadyCtx,
m: &ast::_mod,
fold: @fold::ast_fold) -> ast::_mod {
fn strip_main(item: @ast::item) -> @ast::item {
@ast::item {
attrs: do item.attrs.filtered |attr| {
@ -94,9 +95,9 @@ fn fold_mod(_ctx: @mut ReadyCtx, m: &ast::_mod,
}, fold)
}
fn fold_item(ctx: @mut ReadyCtx, item: @ast::item,
fold: fold::ast_fold) -> Option<@ast::item> {
fn fold_item(ctx: @mut ReadyCtx,
item: @ast::item,
fold: @fold::ast_fold) -> Option<@ast::item> {
ctx.path.push(item.ident);
let attrs = attr::find_attrs_by_name(item.attrs, ~"pkg_do");

View file

@ -1424,7 +1424,7 @@ mod tests {
fail_unless!(a.capacity() == uint::bits);
}
fn rng() -> rand::Rng {
fn rng() -> @rand::Rng {
let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
rand::seeded_rng(seed)
}

View file

@ -415,11 +415,11 @@ pub mod writer {
// ebml writing
pub struct Encoder {
writer: io::Writer,
writer: @io::Writer,
priv mut size_positions: ~[uint],
}
fn write_sized_vuint(w: io::Writer, n: uint, size: uint) {
fn write_sized_vuint(w: @io::Writer, n: uint, size: uint) {
match size {
1u => w.write(&[0x80u8 | (n as u8)]),
2u => w.write(&[0x40u8 | ((n >> 8_u) as u8), n as u8]),
@ -431,7 +431,7 @@ pub mod writer {
};
}
fn write_vuint(w: io::Writer, n: uint) {
fn write_vuint(w: @io::Writer, n: uint) {
if n < 0x7f_u { write_sized_vuint(w, n, 1u); return; }
if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; }
if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; }
@ -439,7 +439,7 @@ pub mod writer {
fail!(fmt!("vint to write too big: %?", n));
}
pub fn Encoder(w: io::Writer) -> Encoder {
pub fn Encoder(w: @io::Writer) -> Encoder {
let size_positions: ~[uint] = ~[];
Encoder { writer: w, mut size_positions: size_positions }
}

View file

@ -459,15 +459,15 @@ pub mod flatteners {
}
pub trait FromReader {
static fn from_reader(r: Reader) -> Self;
static fn from_reader(r: @Reader) -> Self;
}
pub trait FromWriter {
static fn from_writer(w: Writer) -> Self;
static fn from_writer(w: @Writer) -> Self;
}
impl FromReader for json::Decoder/&self {
static fn from_reader(r: Reader) -> json::Decoder/&self {
static fn from_reader(r: @Reader) -> json::Decoder/&self {
match json::from_reader(r) {
Ok(json) => {
json::Decoder(json)
@ -478,13 +478,13 @@ pub mod flatteners {
}
impl FromWriter for json::Encoder {
static fn from_writer(w: Writer) -> json::Encoder {
static fn from_writer(w: @Writer) -> json::Encoder {
json::Encoder(w)
}
}
impl FromReader for ebml::reader::Decoder {
static fn from_reader(r: Reader) -> ebml::reader::Decoder {
static fn from_reader(r: @Reader) -> ebml::reader::Decoder {
let buf = @r.read_whole_stream();
let doc = ebml::reader::Doc(buf);
ebml::reader::Decoder(doc)
@ -492,7 +492,7 @@ pub mod flatteners {
}
impl FromWriter for ebml::writer::Encoder {
static fn from_writer(w: Writer) -> ebml::writer::Encoder {
static fn from_writer(w: @Writer) -> ebml::writer::Encoder {
ebml::writer::Encoder(w)
}
}

View file

@ -74,10 +74,10 @@ fn spaces(n: uint) -> ~str {
}
pub struct Encoder {
priv wr: io::Writer,
priv wr: @io::Writer,
}
pub fn Encoder(wr: io::Writer) -> Encoder {
pub fn Encoder(wr: @io::Writer) -> Encoder {
Encoder { wr: wr }
}
@ -208,11 +208,11 @@ impl serialize::Encoder for Encoder {
}
pub struct PrettyEncoder {
priv wr: io::Writer,
priv wr: @io::Writer,
priv mut indent: uint,
}
pub fn PrettyEncoder(wr: io::Writer) -> PrettyEncoder {
pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder {
PrettyEncoder { wr: wr, indent: 0 }
}
@ -346,7 +346,7 @@ impl<S:serialize::Encoder> serialize::Encodable<S> for Json {
}
/// Encodes a json value into a io::writer
pub fn to_writer(wr: io::Writer, json: &Json) {
pub fn to_writer(wr: @io::Writer, json: &Json) {
json.encode(&Encoder(wr))
}
@ -359,7 +359,7 @@ pub pure fn to_str(json: &Json) -> ~str {
}
/// Encodes a json value into a io::writer
pub fn to_pretty_writer(wr: io::Writer, json: &Json) {
pub fn to_pretty_writer(wr: @io::Writer, json: &Json) {
json.encode(&PrettyEncoder(wr))
}
@ -369,14 +369,14 @@ pub fn to_pretty_str(json: &Json) -> ~str {
}
pub struct Parser {
priv rdr: io::Reader,
priv rdr: @io::Reader,
priv mut ch: char,
priv mut line: uint,
priv mut col: uint,
}
/// Decode a json value from an io::reader
pub fn Parser(rdr: io::Reader) -> Parser {
pub fn Parser(rdr: @io::Reader) -> Parser {
Parser {
rdr: rdr,
ch: rdr.read_char(),
@ -734,8 +734,8 @@ priv impl Parser {
}
}
/// Decodes a json value from an io::reader
pub fn from_reader(rdr: io::Reader) -> Result<Json, Error> {
/// Decodes a json value from an @io::Reader
pub fn from_reader(rdr: @io::Reader) -> Result<Json, Error> {
Parser(rdr).parse()
}

View file

@ -1799,7 +1799,7 @@ pub mod test {
let sock_buf = @socket_buf(result::unwrap(conn_result));
buf_write(sock_buf, expected_req);
let buf_reader = sock_buf as Reader;
let buf_reader = sock_buf as @Reader;
let actual_response = str::from_bytes(buf_reader.read_whole_stream());
debug!("Actual response: %s", actual_response);
fail_unless!(expected_resp == actual_response);

View file

@ -326,7 +326,7 @@ pub mod chained {
}
pub impl<K:Eq + IterBytes + Hash + Copy + ToStr,V:ToStr + Copy> T<K, V> {
fn to_writer(&self, wr: io::Writer) {
fn to_writer(&self, wr: @io::Writer) {
if self.count == 0u {
wr.write_str(~"{}");
return;

View file

@ -14,10 +14,10 @@ use core::io::WriterUtil;
use core::io;
pub struct Serializer {
wr: io::Writer,
wr: @io::Writer,
}
pub fn Serializer(wr: io::Writer) -> Serializer {
pub fn Serializer(wr: @io::Writer) -> Serializer {
Serializer { wr: wr }
}

View file

@ -138,7 +138,7 @@ condition! {
bad_parse: () -> ();
}
fn take_nonempty_prefix(rdr: io::Reader,
fn take_nonempty_prefix(rdr: @io::Reader,
ch: char,
pred: &fn(char) -> bool) -> (~str, char) {
let mut buf = ~"";
@ -154,7 +154,7 @@ fn take_nonempty_prefix(rdr: io::Reader,
(buf, ch)
}
fn take_num(rdr: io::Reader, ch: char) -> (uint, char) {
fn take_num(rdr: @io::Reader, ch: char) -> (uint, char) {
let (s, ch) = take_nonempty_prefix(rdr, ch, char::is_digit);
match uint::from_str(s) {
None => { bad_parse::cond.raise(()); (0, ch) },
@ -162,7 +162,7 @@ fn take_num(rdr: io::Reader, ch: char) -> (uint, char) {
}
}
fn take_ident(rdr: io::Reader, ch: char) -> (Identifier, char) {
fn take_ident(rdr: @io::Reader, ch: char) -> (Identifier, char) {
let (s,ch) = take_nonempty_prefix(rdr, ch, char::is_alphanumeric);
if s.all(char::is_digit) {
match uint::from_str(s) {
@ -180,8 +180,7 @@ fn expect(ch: char, c: char) {
}
}
fn parse_reader(rdr: io::Reader) -> Version {
fn parse_reader(rdr: @io::Reader) -> Version {
let (major, ch) = take_num(rdr, rdr.read_char());
expect(ch, '.');
let (minor, ch) = take_num(rdr, rdr.read_char());

View file

@ -893,6 +893,7 @@ mod test_tim_sort {
use sort::tim_sort;
use core::rand::RngUtil;
use core::rand;
use core::vec;
@ -990,6 +991,7 @@ mod big_tests {
use sort::*;
use core::rand::RngUtil;
use core::rand;
use core::task;
use core::uint;

View file

@ -12,6 +12,7 @@
use core::os;
use core::prelude::*;
use core::rand::RngUtil;
use core::rand;
pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {

View file

@ -36,10 +36,10 @@ pub const color_bright_magenta: u8 = 13u8;
pub const color_bright_cyan: u8 = 14u8;
pub const color_bright_white: u8 = 15u8;
pub fn esc(writer: io::Writer) { writer.write(~[0x1bu8, '[' as u8]); }
pub fn esc(writer: @io::Writer) { writer.write(~[0x1bu8, '[' as u8]); }
/// Reset the foreground and background colors to default
pub fn reset(writer: io::Writer) {
pub fn reset(writer: @io::Writer) {
esc(writer);
writer.write(~['0' as u8, 'm' as u8]);
}
@ -59,7 +59,7 @@ pub fn color_supported() -> bool {
};
}
pub fn set_color(writer: io::Writer, first_char: u8, color: u8) {
pub fn set_color(writer: @io::Writer, first_char: u8, color: u8) {
fail_unless!((color < 16u8));
esc(writer);
let mut color = color;
@ -68,12 +68,12 @@ pub fn set_color(writer: io::Writer, first_char: u8, color: u8) {
}
/// Set the foreground color
pub fn fg(writer: io::Writer, color: u8) {
pub fn fg(writer: @io::Writer, color: u8) {
return set_color(writer, '3' as u8, color);
}
/// Set the background color
pub fn bg(writer: io::Writer, color: u8) {
pub fn bg(writer: @io::Writer, color: u8) {
return set_color(writer, '4' as u8, color);
}

View file

@ -198,8 +198,8 @@ pub struct BenchSamples {
pub enum TestResult { TrOk, TrFailed, TrIgnored, TrBench(BenchSamples) }
struct ConsoleTestState {
out: io::Writer,
log_out: Option<io::Writer>,
out: @io::Writer,
log_out: Option<@io::Writer>,
use_color: bool,
mut total: uint,
mut passed: uint,
@ -316,7 +316,7 @@ pub fn run_tests_console(opts: &TestOpts,
}
}
fn write_log(out: io::Writer, result: TestResult, test: &TestDesc) {
fn write_log(out: @io::Writer, result: TestResult, test: &TestDesc) {
out.write_line(fmt!("%s %s",
match result {
TrOk => ~"ok",
@ -326,23 +326,26 @@ pub fn run_tests_console(opts: &TestOpts,
}, test.name.to_str()));
}
fn write_ok(out: io::Writer, use_color: bool) {
fn write_ok(out: @io::Writer, use_color: bool) {
write_pretty(out, ~"ok", term::color_green, use_color);
}
fn write_failed(out: io::Writer, use_color: bool) {
fn write_failed(out: @io::Writer, use_color: bool) {
write_pretty(out, ~"FAILED", term::color_red, use_color);
}
fn write_ignored(out: io::Writer, use_color: bool) {
fn write_ignored(out: @io::Writer, use_color: bool) {
write_pretty(out, ~"ignored", term::color_yellow, use_color);
}
fn write_bench(out: io::Writer, use_color: bool) {
fn write_bench(out: @io::Writer, use_color: bool) {
write_pretty(out, ~"bench", term::color_cyan, use_color);
}
fn write_pretty(out: io::Writer, word: &str, color: u8, use_color: bool) {
fn write_pretty(out: @io::Writer,
word: &str,
color: u8,
use_color: bool) {
if use_color && term::color_supported() {
term::fg(out, color);
}
@ -601,6 +604,7 @@ pub mod bench {
use stats::Stats;
use core::num;
use core::rand::RngUtil;
use core::rand;
use core::u64;
use core::vec;
@ -700,7 +704,6 @@ pub mod bench {
let mut prev_madp = 0.0;
loop {
let n_samples = rng.gen_uint_range(50, 60);
let n_iter = rng.gen_uint_range(magnitude,
magnitude * 2);

View file

@ -179,6 +179,7 @@ mod test {
use uv;
use core::iter;
use core::rand::RngUtil;
use core::rand;
use core::task;
use core::pipes::{stream, SharedChan};

View file

@ -706,6 +706,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
mod test_treemap {
use core::prelude::*;
use super::*;
use core::rand::RngUtil;
use core::rand;
#[test]

View file

@ -110,7 +110,7 @@ pub struct Ctx {
map: @map,
path: path,
local_id: uint,
diag: span_handler,
diag: @span_handler,
}
pub type vt = visit::vt<@mut Ctx>;
@ -132,7 +132,7 @@ pub fn mk_ast_map_visitor() -> vt {
});
}
pub fn map_crate(diag: span_handler, c: crate) -> map {
pub fn map_crate(diag: @span_handler, c: crate) -> map {
let cx = @mut Ctx {
map: @std::oldmap::HashMap(),
path: ~[],
@ -146,7 +146,7 @@ pub fn map_crate(diag: span_handler, c: crate) -> map {
// Used for items loaded from external crate that are being inlined into this
// crate. The `path` should be the path to the item but should not include
// the item itself.
pub fn map_decoded_item(diag: span_handler,
pub fn map_decoded_item(diag: @span_handler,
map: map,
+path: path,
ii: inlined_item) {

View file

@ -360,7 +360,7 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr {
}
pub fn require_unique_names(diagnostic: span_handler,
pub fn require_unique_names(diagnostic: @span_handler,
metas: &[@ast::meta_item]) {
let mut set = LinearSet::new();
for metas.each |meta| {

View file

@ -55,7 +55,7 @@ pub trait span_handler {
fn span_note(@mut self, sp: span, msg: &str);
fn span_bug(@mut self, sp: span, msg: &str) -> !;
fn span_unimpl(@mut self, sp: span, msg: &str) -> !;
fn handler(@mut self) -> handler;
fn handler(@mut self) -> @handler;
}
struct HandlerT {
@ -64,7 +64,7 @@ struct HandlerT {
}
struct CodemapT {
handler: handler,
handler: @handler,
cm: @codemap::CodeMap,
}
@ -89,7 +89,7 @@ impl span_handler for CodemapT {
fn span_unimpl(@mut self, sp: span, msg: &str) -> ! {
self.span_bug(sp, ~"unimplemented " + msg);
}
fn handler(@mut self) -> handler {
fn handler(@mut self) -> @handler {
self.handler
}
}
@ -143,8 +143,8 @@ pub fn ice_msg(msg: &str) -> ~str {
fmt!("internal compiler error: %s", msg)
}
pub fn mk_span_handler(handler: handler, cm: @codemap::CodeMap)
-> span_handler {
pub fn mk_span_handler(handler: @handler, cm: @codemap::CodeMap)
-> @span_handler {
@mut CodemapT { handler: handler, cm: cm } as @span_handler
}
@ -304,7 +304,7 @@ fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) {
}
}
pub fn expect<T:Copy>(diag: span_handler,
pub fn expect<T:Copy>(diag: @span_handler,
opt: Option<T>,
msg: &fn() -> ~str) -> T {
match opt {

View file

@ -41,10 +41,10 @@ fn next_state(s: State) -> Option<State> {
}
}
pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(),
let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(),
vec::from_slice(tts));
let mut asm = ~"";

View file

@ -110,7 +110,7 @@ mod syntax {
}
pub fn expand_auto_encode(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
_mitem: @ast::meta_item,
in_items: ~[@ast::item]
@ -165,7 +165,7 @@ pub fn expand_auto_encode(
}
pub fn expand_auto_decode(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
_mitem: @ast::meta_item,
in_items: ~[@ast::item]
@ -219,7 +219,7 @@ pub fn expand_auto_decode(
}
}
priv impl ext_ctxt {
priv impl @ext_ctxt {
fn bind_path(
&self,
span: span,
@ -426,7 +426,7 @@ priv impl ext_ctxt {
}
fn mk_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
ty_param: ast::TyParam,
@ -499,7 +499,7 @@ fn mk_impl(
}
fn mk_ser_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
generics: &ast::Generics,
@ -543,7 +543,7 @@ fn mk_ser_impl(
}
fn mk_deser_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
generics: &ast::Generics,
@ -587,7 +587,7 @@ fn mk_deser_impl(
}
fn mk_ser_method(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
+ser_body: ast::blk
) -> @ast::method {
@ -647,7 +647,7 @@ fn mk_ser_method(
}
fn mk_deser_method(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ty: @ast::Ty,
+deser_body: ast::blk
@ -701,7 +701,7 @@ fn mk_deser_method(
}
fn mk_struct_ser_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
fields: &[@ast::struct_field],
@ -762,7 +762,7 @@ fn mk_struct_ser_impl(
}
fn mk_struct_deser_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
fields: ~[@ast::struct_field],
@ -866,7 +866,7 @@ fn mk_struct_fields(fields: &[@ast::struct_field]) -> ~[field] {
}
fn mk_enum_ser_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
+enum_def: ast::enum_def,
@ -883,7 +883,7 @@ fn mk_enum_ser_impl(
}
fn mk_enum_deser_impl(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
ident: ast::ident,
+enum_def: ast::enum_def,
@ -900,7 +900,7 @@ fn mk_enum_deser_impl(
}
fn ser_variant(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
v_name: ast::ident,
v_idx: uint,
@ -982,7 +982,7 @@ fn ser_variant(
}
fn mk_enum_ser_body(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
name: ast::ident,
+variants: ~[ast::variant]
@ -1032,7 +1032,7 @@ fn mk_enum_ser_body(
}
fn mk_enum_deser_variant_nary(
cx: ext_ctxt,
cx: @ext_ctxt,
span: span,
name: ast::ident,
args: ~[ast::variant_arg]
@ -1069,7 +1069,7 @@ fn mk_enum_deser_variant_nary(
}
fn mk_enum_deser_body(
ext_cx: ext_ctxt,
ext_cx: @ext_ctxt,
span: span,
name: ast::ident,
variants: ~[ast::variant]

View file

@ -36,7 +36,7 @@ pub struct MacroDef {
ext: SyntaxExtension
}
pub type ItemDecorator = @fn(ext_ctxt,
pub type ItemDecorator = @fn(@ext_ctxt,
span,
@ast::meta_item,
~[@ast::item])
@ -47,7 +47,7 @@ pub struct SyntaxExpanderTT {
span: Option<span>
}
pub type SyntaxExpanderTTFun = @fn(ext_ctxt,
pub type SyntaxExpanderTTFun = @fn(@ext_ctxt,
span,
&[ast::token_tree])
-> MacResult;
@ -57,7 +57,7 @@ pub struct SyntaxExpanderTTItem {
span: Option<span>
}
pub type SyntaxExpanderTTItemFun = @fn(ext_ctxt,
pub type SyntaxExpanderTTItemFun = @fn(@ext_ctxt,
span,
ast::ident,
~[ast::token_tree])
@ -238,8 +238,8 @@ pub trait ext_ctxt {
fn ident_of(@mut self, st: ~str) -> ast::ident;
}
pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
+cfg: ast::crate_cfg) -> ext_ctxt {
pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, +cfg: ast::crate_cfg)
-> @ext_ctxt {
struct CtxtRepr {
parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg,
@ -333,7 +333,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess,
((imp) as @ext_ctxt)
}
pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
match expr.node {
ast::expr_lit(l) => match l.node {
ast::lit_str(s) => copy *s,
@ -343,7 +343,7 @@ pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
}
}
pub fn expr_to_ident(cx: ext_ctxt,
pub fn expr_to_ident(cx: @ext_ctxt,
expr: @ast::expr,
err_msg: ~str) -> ast::ident {
match expr.node {
@ -357,14 +357,14 @@ pub fn expr_to_ident(cx: ext_ctxt,
}
}
pub fn check_zero_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
pub fn check_zero_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree],
name: &str) {
if tts.len() != 0 {
cx.span_fatal(sp, fmt!("%s takes no arguments", name));
}
}
pub fn get_single_str_from_tts(cx: ext_ctxt,
pub fn get_single_str_from_tts(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree],
name: &str) -> ~str {
@ -379,7 +379,7 @@ pub fn get_single_str_from_tts(cx: ext_ctxt,
}
}
pub fn get_exprs_from_tts(cx: ext_ctxt, tts: &[ast::token_tree])
pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree])
-> ~[@ast::expr] {
let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(),

View file

@ -25,7 +25,7 @@ pub struct Field {
ex: @ast::expr
}
pub fn mk_expr(cx: ext_ctxt,
pub fn mk_expr(cx: @ext_ctxt,
sp: codemap::span,
+expr: ast::expr_)
-> @ast::expr {
@ -37,28 +37,28 @@ pub fn mk_expr(cx: ext_ctxt,
}
}
pub fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
pub fn mk_lit(cx: @ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
let sp_lit = @codemap::spanned { node: lit, span: sp };
mk_expr(cx, sp, ast::expr_lit(sp_lit))
}
pub fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr {
pub fn mk_int(cx: @ext_ctxt, sp: span, i: int) -> @ast::expr {
let lit = ast::lit_int(i as i64, ast::ty_i);
return mk_lit(cx, sp, lit);
}
pub fn mk_uint(cx: ext_ctxt, sp: span, u: uint) -> @ast::expr {
pub fn mk_uint(cx: @ext_ctxt, sp: span, u: uint) -> @ast::expr {
let lit = ast::lit_uint(u as u64, ast::ty_u);
return mk_lit(cx, sp, lit);
}
pub fn mk_u8(cx: ext_ctxt, sp: span, u: u8) -> @ast::expr {
pub fn mk_u8(cx: @ext_ctxt, sp: span, u: u8) -> @ast::expr {
let lit = ast::lit_uint(u as u64, ast::ty_u8);
return mk_lit(cx, sp, lit);
}
pub fn mk_binary(cx: ext_ctxt, sp: span, op: ast::binop,
pub fn mk_binary(cx: @ext_ctxt, sp: span, op: ast::binop,
lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr {
cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_binary(op, lhs, rhs))
}
pub fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
pub fn mk_unary(cx: @ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
-> @ast::expr {
cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_unary(op, e))
@ -88,69 +88,70 @@ pub fn mk_raw_path_global(sp: span, +idents: ~[ast::ident]) -> @ast::path {
rp: None,
types: ~[] }
}
pub fn mk_path(cx: ext_ctxt, sp: span, +idents: ~[ast::ident]) -> @ast::expr {
pub fn mk_path(cx: @ext_ctxt, sp: span, +idents: ~[ast::ident])
-> @ast::expr {
mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents)))
}
pub fn mk_path_global(cx: ext_ctxt, sp: span, +idents: ~[ast::ident])
pub fn mk_path_global(cx: @ext_ctxt, sp: span, +idents: ~[ast::ident])
-> @ast::expr {
mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents)))
}
pub fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident)
pub fn mk_access_(cx: @ext_ctxt, sp: span, p: @ast::expr, m: ast::ident)
-> @ast::expr {
mk_expr(cx, sp, ast::expr_field(p, m, ~[]))
}
pub fn mk_access(cx: ext_ctxt, sp: span, +p: ~[ast::ident], m: ast::ident)
pub fn mk_access(cx: @ext_ctxt, sp: span, +p: ~[ast::ident], m: ast::ident)
-> @ast::expr {
let pathexpr = mk_path(cx, sp, p);
return mk_access_(cx, sp, pathexpr, m);
}
pub fn mk_addr_of(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
pub fn mk_addr_of(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e));
}
pub fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr,
pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr,
+args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar))
}
pub fn mk_call(cx: ext_ctxt, sp: span, +fn_path: ~[ast::ident],
pub fn mk_call(cx: @ext_ctxt, sp: span, +fn_path: ~[ast::ident],
+args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args);
}
pub fn mk_call_global(cx: ext_ctxt, sp: span, +fn_path: ~[ast::ident],
pub fn mk_call_global(cx: @ext_ctxt, sp: span, +fn_path: ~[ast::ident],
+args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path_global(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args);
}
// e = expr, t = type
pub fn mk_base_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
pub fn mk_base_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr {
let vecexpr = ast::expr_vec(exprs, ast::m_imm);
mk_expr(cx, sp, vecexpr)
}
pub fn mk_vstore_e(cx: ext_ctxt, sp: span, expr: @ast::expr,
pub fn mk_vstore_e(cx: @ext_ctxt, sp: span, expr: @ast::expr,
vst: ast::expr_vstore) ->
@ast::expr {
mk_expr(cx, sp, ast::expr_vstore(expr, vst))
}
pub fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
pub fn mk_uniq_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::expr_vstore_uniq)
}
pub fn mk_slice_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
pub fn mk_slice_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs),
ast::expr_vstore_slice)
}
pub fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, +exprs: ~[@ast::expr])
pub fn mk_fixed_vec_e(cx: @ext_ctxt, sp: span, +exprs: ~[@ast::expr])
-> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs),
ast::expr_vstore_fixed(None))
}
pub fn mk_base_str(cx: ext_ctxt, sp: span, +s: ~str) -> @ast::expr {
pub fn mk_base_str(cx: @ext_ctxt, sp: span, +s: ~str) -> @ast::expr {
let lit = ast::lit_str(@s);
return mk_lit(cx, sp, lit);
}
pub fn mk_uniq_str(cx: ext_ctxt, sp: span, +s: ~str) -> @ast::expr {
pub fn mk_uniq_str(cx: @ext_ctxt, sp: span, +s: ~str) -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq)
}
pub fn mk_field(sp: span, f: &Field) -> ast::field {
@ -162,7 +163,7 @@ pub fn mk_field(sp: span, f: &Field) -> ast::field {
pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] {
fields.map(|f| mk_field(sp, f))
}
pub fn mk_struct_e(cx: ext_ctxt,
pub fn mk_struct_e(cx: @ext_ctxt,
sp: span,
+ctor_path: ~[ast::ident],
+fields: ~[Field])
@ -172,7 +173,7 @@ pub fn mk_struct_e(cx: ext_ctxt,
mk_fields(sp, fields),
option::None::<@ast::expr>))
}
pub fn mk_global_struct_e(cx: ext_ctxt,
pub fn mk_global_struct_e(cx: @ext_ctxt,
sp: span,
+ctor_path: ~[ast::ident],
+fields: ~[Field])
@ -182,7 +183,7 @@ pub fn mk_global_struct_e(cx: ext_ctxt,
mk_fields(sp, fields),
option::None::<@ast::expr>))
}
pub fn mk_glob_use(cx: ext_ctxt,
pub fn mk_glob_use(cx: @ext_ctxt,
sp: span,
+path: ~[ast::ident]) -> @ast::view_item {
let glob = @codemap::spanned {
@ -194,7 +195,7 @@ pub fn mk_glob_use(cx: ext_ctxt,
vis: ast::private,
span: sp }
}
pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
pub fn mk_local(cx: @ext_ctxt, sp: span, mutbl: bool,
ident: ast::ident, ex: @ast::expr) -> @ast::stmt {
let pat = @ast::pat {
@ -219,7 +220,7 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool,
let decl = codemap::spanned {node: ast::decl_local(~[local]), span: sp};
@codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp }
}
pub fn mk_block(cx: ext_ctxt, span: span,
pub fn mk_block(cx: @ext_ctxt, span: span,
+view_items: ~[@ast::view_item],
+stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> @ast::expr {
@ -235,7 +236,7 @@ pub fn mk_block(cx: ext_ctxt, span: span,
};
mk_expr(cx, span, ast::expr_block(blk))
}
pub fn mk_block_(cx: ext_ctxt,
pub fn mk_block_(cx: @ext_ctxt,
span: span,
+stmts: ~[@ast::stmt])
-> ast::blk {
@ -250,7 +251,7 @@ pub fn mk_block_(cx: ext_ctxt,
span: span,
}
}
pub fn mk_simple_block(cx: ext_ctxt,
pub fn mk_simple_block(cx: @ext_ctxt,
span: span,
expr: @ast::expr)
-> ast::blk {
@ -265,21 +266,21 @@ pub fn mk_simple_block(cx: ext_ctxt,
span: span,
}
}
pub fn mk_copy(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
pub fn mk_copy(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_copy(e))
}
pub fn mk_managed(cx: ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
pub fn mk_managed(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e))
}
pub fn mk_pat(cx: ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat {
pub fn mk_pat(cx: @ext_ctxt, span: span, +pat: ast::pat_) -> @ast::pat {
@ast::pat { id: cx.next_id(), node: pat, span: span }
}
pub fn mk_pat_ident(cx: ext_ctxt,
pub fn mk_pat_ident(cx: @ext_ctxt,
span: span,
ident: ast::ident) -> @ast::pat {
mk_pat_ident_with_binding_mode(cx, span, ident, ast::bind_by_copy)
}
pub fn mk_pat_ident_with_binding_mode(cx: ext_ctxt,
pub fn mk_pat_ident_with_binding_mode(cx: @ext_ctxt,
span: span,
ident: ast::ident,
bm: ast::binding_mode) -> @ast::pat {
@ -287,7 +288,7 @@ pub fn mk_pat_ident_with_binding_mode(cx: ext_ctxt,
let pat = ast::pat_ident(bm, path, None);
mk_pat(cx, span, pat)
}
pub fn mk_pat_enum(cx: ext_ctxt,
pub fn mk_pat_enum(cx: @ext_ctxt,
span: span,
path: @ast::path,
+subpats: ~[@ast::pat])
@ -295,7 +296,7 @@ pub fn mk_pat_enum(cx: ext_ctxt,
let pat = ast::pat_enum(path, Some(subpats));
mk_pat(cx, span, pat)
}
pub fn mk_pat_struct(cx: ext_ctxt,
pub fn mk_pat_struct(cx: @ext_ctxt,
span: span,
path: @ast::path,
+field_pats: ~[ast::field_pat])
@ -303,17 +304,17 @@ pub fn mk_pat_struct(cx: ext_ctxt,
let pat = ast::pat_struct(path, field_pats, false);
mk_pat(cx, span, pat)
}
pub fn mk_bool(cx: ext_ctxt, span: span, value: bool) -> @ast::expr {
pub fn mk_bool(cx: @ext_ctxt, span: span, value: bool) -> @ast::expr {
let lit_expr = ast::expr_lit(@codemap::spanned {
node: ast::lit_bool(value),
span: span });
build::mk_expr(cx, span, lit_expr)
}
pub fn mk_stmt(cx: ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt {
pub fn mk_stmt(cx: @ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt {
let stmt_ = ast::stmt_semi(expr, cx.next_id());
@codemap::spanned { node: stmt_, span: span }
}
pub fn mk_ty_path(cx: ext_ctxt,
pub fn mk_ty_path(cx: @ext_ctxt,
span: span,
+idents: ~[ ast::ident ])
-> @ast::Ty {
@ -322,7 +323,7 @@ pub fn mk_ty_path(cx: ext_ctxt,
let ty = @ast::Ty { id: cx.next_id(), node: ty, span: span };
ty
}
pub fn mk_ty_path_global(cx: ext_ctxt,
pub fn mk_ty_path_global(cx: @ext_ctxt,
span: span,
+idents: ~[ ast::ident ])
-> @ast::Ty {
@ -331,13 +332,13 @@ pub fn mk_ty_path_global(cx: ext_ctxt,
let ty = @ast::Ty { id: cx.next_id(), node: ty, span: span };
ty
}
pub fn mk_simple_ty_path(cx: ext_ctxt,
pub fn mk_simple_ty_path(cx: @ext_ctxt,
span: span,
ident: ast::ident)
-> @ast::Ty {
mk_ty_path(cx, span, ~[ ident ])
}
pub fn mk_arg(cx: ext_ctxt,
pub fn mk_arg(cx: @ext_ctxt,
span: span,
ident: ast::ident,
ty: @ast::Ty)
@ -354,13 +355,13 @@ pub fn mk_arg(cx: ext_ctxt,
pub fn mk_fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl {
ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val }
}
pub fn mk_ty_param(cx: ext_ctxt,
pub fn mk_ty_param(cx: @ext_ctxt,
ident: ast::ident,
bounds: @OptVec<ast::TyParamBound>)
-> ast::TyParam {
ast::TyParam { ident: ident, id: cx.next_id(), bounds: bounds }
}
pub fn mk_lifetime(cx: ext_ctxt,
pub fn mk_lifetime(cx: @ext_ctxt,
span: span,
ident: ast::ident) -> ast::Lifetime
{

View file

@ -16,7 +16,7 @@ use ext::base::*;
use ext::base;
use parse::token;
pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let mut res_str = ~"";
for tts.eachi |i, e| {

View file

@ -45,18 +45,18 @@ pub impl Junction {
}
}
type ExpandDerivingStructDefFn = &self/fn(ext_ctxt,
type ExpandDerivingStructDefFn = &self/fn(@ext_ctxt,
span,
x: &struct_def,
ident,
y: &Generics) -> @item;
type ExpandDerivingEnumDefFn = &self/fn(ext_ctxt,
type ExpandDerivingEnumDefFn = &self/fn(@ext_ctxt,
span,
x: &enum_def,
ident,
y: &Generics) -> @item;
pub fn expand_meta_deriving(cx: ext_ctxt,
pub fn expand_meta_deriving(cx: @ext_ctxt,
_span: span,
mitem: @meta_item,
in_items: ~[@item])
@ -98,7 +98,7 @@ pub fn expand_meta_deriving(cx: ext_ctxt,
}
}
pub fn expand_deriving_eq(cx: ext_ctxt,
pub fn expand_deriving_eq(cx: @ext_ctxt,
span: span,
_mitem: @meta_item,
in_items: ~[@item])
@ -110,7 +110,7 @@ pub fn expand_deriving_eq(cx: ext_ctxt,
expand_deriving_eq_enum_def)
}
pub fn expand_deriving_iter_bytes(cx: ext_ctxt,
pub fn expand_deriving_iter_bytes(cx: @ext_ctxt,
span: span,
_mitem: @meta_item,
in_items: ~[@item])
@ -122,7 +122,7 @@ pub fn expand_deriving_iter_bytes(cx: ext_ctxt,
expand_deriving_iter_bytes_enum_def)
}
pub fn expand_deriving_clone(cx: ext_ctxt,
pub fn expand_deriving_clone(cx: @ext_ctxt,
span: span,
_: @meta_item,
in_items: ~[@item])
@ -134,7 +134,7 @@ pub fn expand_deriving_clone(cx: ext_ctxt,
expand_deriving_clone_enum_def)
}
fn expand_deriving(cx: ext_ctxt,
fn expand_deriving(cx: @ext_ctxt,
span: span,
in_items: ~[@item],
expand_deriving_struct_def: ExpandDerivingStructDefFn,
@ -164,7 +164,7 @@ fn expand_deriving(cx: ext_ctxt,
result
}
fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item {
fn create_impl_item(cx: @ext_ctxt, span: span, +item: item_) -> @item {
@ast::item {
ident: clownshoes_extensions,
attrs: ~[],
@ -177,7 +177,7 @@ fn create_impl_item(cx: ext_ctxt, span: span, +item: item_) -> @item {
/// Creates a method from the given expression, the signature of which
/// conforms to the `eq` or `ne` method.
fn create_eq_method(cx: ext_ctxt,
fn create_eq_method(cx: @ext_ctxt,
span: span,
method_ident: ident,
type_ident: ident,
@ -236,7 +236,7 @@ fn create_eq_method(cx: ext_ctxt,
}
}
fn create_self_type_with_params(cx: ext_ctxt,
fn create_self_type_with_params(cx: @ext_ctxt,
span: span,
type_ident: ident,
generics: &Generics)
@ -258,7 +258,7 @@ fn create_self_type_with_params(cx: ext_ctxt,
@ast::Ty { id: cx.next_id(), node: self_type, span: span }
}
fn create_derived_impl(cx: ext_ctxt,
fn create_derived_impl(cx: @ext_ctxt,
span: span,
type_ident: ident,
generics: &Generics,
@ -320,7 +320,7 @@ fn create_derived_impl(cx: ext_ctxt,
return create_impl_item(cx, span, impl_item);
}
fn create_derived_eq_impl(cx: ext_ctxt,
fn create_derived_eq_impl(cx: @ext_ctxt,
span: span,
type_ident: ident,
generics: &Generics,
@ -336,7 +336,7 @@ fn create_derived_eq_impl(cx: ext_ctxt,
create_derived_impl(cx, span, type_ident, generics, methods, trait_path)
}
fn create_derived_iter_bytes_impl(cx: ext_ctxt,
fn create_derived_iter_bytes_impl(cx: @ext_ctxt,
span: span,
type_ident: ident,
generics: &Generics,
@ -351,7 +351,7 @@ fn create_derived_iter_bytes_impl(cx: ext_ctxt,
create_derived_impl(cx, span, type_ident, generics, methods, trait_path)
}
fn create_derived_clone_impl(cx: ext_ctxt,
fn create_derived_clone_impl(cx: @ext_ctxt,
span: span,
type_ident: ident,
generics: &Generics,
@ -368,7 +368,7 @@ fn create_derived_clone_impl(cx: ext_ctxt,
// Creates a method from the given set of statements conforming to the
// signature of the `iter_bytes` method.
fn create_iter_bytes_method(cx: ext_ctxt,
fn create_iter_bytes_method(cx: @ext_ctxt,
span: span,
+statements: ~[@stmt])
-> @method {
@ -417,7 +417,7 @@ fn create_iter_bytes_method(cx: ext_ctxt,
// Creates a method from the given expression conforming to the signature of
// the `clone` method.
fn create_clone_method(cx: ext_ctxt,
fn create_clone_method(cx: @ext_ctxt,
span: span,
+type_ident: ast::ident,
generics: &Generics,
@ -467,7 +467,7 @@ fn create_clone_method(cx: ext_ctxt,
}
}
fn create_subpatterns(cx: ext_ctxt,
fn create_subpatterns(cx: @ext_ctxt,
span: span,
prefix: ~str,
n: uint)
@ -496,7 +496,7 @@ fn is_struct_tuple(struct_def: &struct_def) -> bool {
})
}
fn create_enum_variant_pattern(cx: ext_ctxt,
fn create_enum_variant_pattern(cx: @ext_ctxt,
span: span,
variant: &variant,
prefix: ~str)
@ -542,7 +542,7 @@ fn create_enum_variant_pattern(cx: ext_ctxt,
}
}
fn call_substructure_eq_method(cx: ext_ctxt,
fn call_substructure_eq_method(cx: @ext_ctxt,
span: span,
self_field: @expr,
other_field_ref: @expr,
@ -571,7 +571,7 @@ fn call_substructure_eq_method(cx: ext_ctxt,
};
}
fn finish_eq_chain_expr(cx: ext_ctxt,
fn finish_eq_chain_expr(cx: @ext_ctxt,
span: span,
chain_expr: Option<@expr>,
junction: Junction)
@ -587,7 +587,7 @@ fn finish_eq_chain_expr(cx: ext_ctxt,
}
}
fn call_substructure_iter_bytes_method(cx: ext_ctxt,
fn call_substructure_iter_bytes_method(cx: @ext_ctxt,
span: span,
self_field: @expr)
-> @stmt {
@ -612,7 +612,7 @@ fn call_substructure_iter_bytes_method(cx: ext_ctxt,
build::mk_stmt(cx, span, self_call)
}
fn call_substructure_clone_method(cx: ext_ctxt,
fn call_substructure_clone_method(cx: @ext_ctxt,
span: span,
self_field: @expr)
-> @expr {
@ -622,7 +622,7 @@ fn call_substructure_clone_method(cx: ext_ctxt,
build::mk_call_(cx, span, self_method, ~[])
}
fn variant_arg_count(cx: ext_ctxt, span: span, variant: &variant) -> uint {
fn variant_arg_count(cx: @ext_ctxt, span: span, variant: &variant) -> uint {
match variant.node.kind {
tuple_variant_kind(ref args) => args.len(),
struct_variant_kind(ref struct_def) => struct_def.fields.len(),
@ -632,7 +632,7 @@ fn variant_arg_count(cx: ext_ctxt, span: span, variant: &variant) -> uint {
}
}
fn expand_deriving_eq_struct_def(cx: ext_ctxt,
fn expand_deriving_eq_struct_def(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
type_ident: ident,
@ -672,7 +672,7 @@ fn expand_deriving_eq_struct_def(cx: ext_ctxt,
ne_method);
}
fn expand_deriving_eq_enum_def(cx: ext_ctxt,
fn expand_deriving_eq_enum_def(cx: @ext_ctxt,
span: span,
enum_definition: &enum_def,
type_ident: ident,
@ -705,7 +705,7 @@ fn expand_deriving_eq_enum_def(cx: ext_ctxt,
ne_method);
}
fn expand_deriving_iter_bytes_struct_def(cx: ext_ctxt,
fn expand_deriving_iter_bytes_struct_def(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
type_ident: ident,
@ -724,7 +724,7 @@ fn expand_deriving_iter_bytes_struct_def(cx: ext_ctxt,
method);
}
fn expand_deriving_iter_bytes_enum_def(cx: ext_ctxt,
fn expand_deriving_iter_bytes_enum_def(cx: @ext_ctxt,
span: span,
enum_definition: &enum_def,
type_ident: ident,
@ -743,7 +743,7 @@ fn expand_deriving_iter_bytes_enum_def(cx: ext_ctxt,
method);
}
fn expand_deriving_clone_struct_def(cx: ext_ctxt,
fn expand_deriving_clone_struct_def(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
type_ident: ident,
@ -768,7 +768,7 @@ fn expand_deriving_clone_struct_def(cx: ext_ctxt,
create_derived_clone_impl(cx, span, type_ident, generics, method)
}
fn expand_deriving_clone_enum_def(cx: ext_ctxt,
fn expand_deriving_clone_enum_def(cx: @ext_ctxt,
span: span,
enum_definition: &enum_def,
type_ident: ident,
@ -785,7 +785,7 @@ fn expand_deriving_clone_enum_def(cx: ext_ctxt,
create_derived_clone_impl(cx, span, type_ident, generics, method)
}
fn expand_deriving_eq_struct_method(cx: ext_ctxt,
fn expand_deriving_eq_struct_method(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
method_ident: ident,
@ -841,7 +841,7 @@ fn expand_deriving_eq_struct_method(cx: ext_ctxt,
body);
}
fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt,
fn expand_deriving_iter_bytes_struct_method(cx: @ext_ctxt,
span: span,
struct_def: &struct_def)
-> @method {
@ -875,7 +875,7 @@ fn expand_deriving_iter_bytes_struct_method(cx: ext_ctxt,
return create_iter_bytes_method(cx, span, statements);
}
fn expand_deriving_clone_struct_method(cx: ext_ctxt,
fn expand_deriving_clone_struct_method(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
type_ident: ident,
@ -918,7 +918,7 @@ fn expand_deriving_clone_struct_method(cx: ext_ctxt,
create_clone_method(cx, span, type_ident, generics, struct_literal)
}
fn expand_deriving_clone_tuple_struct_method(cx: ext_ctxt,
fn expand_deriving_clone_tuple_struct_method(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
type_ident: ident,
@ -962,7 +962,7 @@ fn expand_deriving_clone_tuple_struct_method(cx: ext_ctxt,
create_clone_method(cx, span, type_ident, generics, self_match_expr)
}
fn expand_deriving_eq_enum_method(cx: ext_ctxt,
fn expand_deriving_eq_enum_method(cx: @ext_ctxt,
span: span,
enum_definition: &enum_def,
method_ident: ident,
@ -1096,7 +1096,7 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
self_match_expr);
}
fn expand_deriving_eq_struct_tuple_method(cx: ext_ctxt,
fn expand_deriving_eq_struct_tuple_method(cx: @ext_ctxt,
span: span,
struct_def: &struct_def,
method_ident: ident,
@ -1155,7 +1155,7 @@ fn expand_deriving_eq_struct_tuple_method(cx: ext_ctxt,
type_ident, generics, self_match_expr)
}
fn expand_enum_or_struct_match(cx: ext_ctxt,
fn expand_enum_or_struct_match(cx: @ext_ctxt,
span: span,
arms: ~[ ast::arm ])
-> @expr {
@ -1166,7 +1166,7 @@ fn expand_enum_or_struct_match(cx: ext_ctxt,
build::mk_expr(cx, span, self_match_expr)
}
fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
fn expand_deriving_iter_bytes_enum_method(cx: @ext_ctxt,
span: span,
enum_definition: &enum_def)
-> @method {
@ -1221,7 +1221,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
create_iter_bytes_method(cx, span, ~[ self_match_stmt ])
}
fn expand_deriving_clone_enum_method(cx: ext_ctxt,
fn expand_deriving_clone_enum_method(cx: @ext_ctxt,
span: span,
enum_definition: &enum_def,
type_ident: ident,

View file

@ -23,7 +23,7 @@ use ext::base::*;
use ext::base;
use ext::build::mk_uniq_str;
pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let var = get_single_str_from_tts(cx, sp, tts, "env!");

View file

@ -26,11 +26,11 @@ use core::option;
use core::vec;
pub fn expand_expr(extsbox: @mut SyntaxEnv,
cx: ext_ctxt,
cx: @ext_ctxt,
e: &expr_,
s: span,
fld: ast_fold,
orig: @fn(&expr_, span, ast_fold) -> (expr_, span))
fld: @ast_fold,
orig: @fn(&expr_, span, @ast_fold) -> (expr_, span))
-> (expr_, span) {
match *e {
// expr_mac should really be expr_ext or something; it's the
@ -112,10 +112,10 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
// NB: there is some redundancy between this and expand_item, below, and
// they might benefit from some amount of semantic and language-UI merger.
pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
cx: ext_ctxt,
cx: @ext_ctxt,
module_: &ast::_mod,
fld: ast_fold,
orig: @fn(&ast::_mod, ast_fold) -> ast::_mod)
fld: @ast_fold,
orig: @fn(&ast::_mod, @ast_fold) -> ast::_mod)
-> ast::_mod {
// Fold the contents first:
let module_ = orig(module_, fld);
@ -163,10 +163,10 @@ macro_rules! with_exts_frame (
// When we enter a module, record it, for the sake of `module!`
pub fn expand_item(extsbox: @mut SyntaxEnv,
cx: ext_ctxt,
cx: @ext_ctxt,
it: @ast::item,
fld: ast_fold,
orig: @fn(@ast::item, ast_fold) -> Option<@ast::item>)
fld: @ast_fold,
orig: @fn(@ast::item, @ast_fold) -> Option<@ast::item>)
-> Option<@ast::item> {
// need to do expansion first... it might turn out to be a module.
let maybe_it = match it.node {
@ -239,9 +239,9 @@ macro_rules! without_macro_scoping(
// Support for item-position macro invocations, exactly the same
// logic as for expression-position macro invocations.
pub fn expand_item_mac(+extsbox: @mut SyntaxEnv,
cx: ext_ctxt, &&it: @ast::item,
fld: ast_fold) -> Option<@ast::item> {
cx: @ext_ctxt, &&it: @ast::item,
fld: @ast_fold)
-> Option<@ast::item> {
let (pth, tts) = match it.node {
item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => {
(pth, copy *tts)
@ -307,11 +307,11 @@ pub fn expand_item_mac(+extsbox: @mut SyntaxEnv,
// expand a stmt
pub fn expand_stmt(extsbox: @mut SyntaxEnv,
cx: ext_ctxt,
cx: @ext_ctxt,
s: &stmt_,
sp: span,
fld: ast_fold,
orig: @fn(&stmt_, span, ast_fold) -> (stmt_, span))
fld: @ast_fold,
orig: @fn(&stmt_, span, @ast_fold) -> (stmt_, span))
-> (stmt_, span) {
let (mac, pth, tts, semi) = match *s {
stmt_mac(ref mac, semi) => {
@ -373,11 +373,11 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
pub fn expand_block(extsbox: @mut SyntaxEnv,
cx: ext_ctxt,
cx: @ext_ctxt,
blk: &blk_,
sp: span,
fld: ast_fold,
orig: @fn(&blk_, span, ast_fold) -> (blk_, span))
fld: @ast_fold,
orig: @fn(&blk_, span, @ast_fold) -> (blk_, span))
-> (blk_, span) {
match (*extsbox).find(&@~" block") {
// no scope limit on macros in this block, no need
@ -395,7 +395,7 @@ pub fn expand_block(extsbox: @mut SyntaxEnv,
}
}
pub fn new_span(cx: ext_ctxt, sp: span) -> span {
pub fn new_span(cx: @ext_ctxt, sp: span) -> span {
/* this discards information in the case of macro-defining macros */
return span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()};
}
@ -488,7 +488,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
// every method/element of AstFoldFns in fold.rs.
let extsbox = @mut syntax_expander_table();
let afp = default_ast_fold();
let cx: ext_ctxt = mk_ctxt(parse_sess, copy cfg);
let cx: @ext_ctxt = mk_ctxt(parse_sess, copy cfg);
let f_pre = @AstFoldFns {
fold_expr: |expr,span,recur|
expand_expr(extsbox, cx, expr, span, recur, afp.fold_expr),

View file

@ -27,7 +27,7 @@ use ext::build::*;
use core::unstable::extfmt::ct::*;
pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let args = get_exprs_from_tts(cx, tts);
if args.len() == 0 {
@ -38,7 +38,7 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
~"first argument to fmt! must be a string literal.");
let fmtspan = args[0].span;
debug!("Format string: %s", fmt);
fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: &str) -> ! {
fn parse_fmt_err_(cx: @ext_ctxt, sp: span, msg: &str) -> ! {
cx.span_fatal(sp, msg);
}
let parse_fmt_err: @fn(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s);
@ -50,23 +50,23 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
// probably be factored out in common with other code that builds
// expressions. Also: Cleanup the naming of these functions.
// Note: Moved many of the common ones to build.rs --kevina
fn pieces_to_expr(cx: ext_ctxt, sp: span,
fn pieces_to_expr(cx: @ext_ctxt, sp: span,
pieces: ~[Piece], args: ~[@ast::expr])
-> @ast::expr {
fn make_path_vec(cx: ext_ctxt, ident: @~str) -> ~[ast::ident] {
fn make_path_vec(cx: @ext_ctxt, ident: @~str) -> ~[ast::ident] {
let intr = cx.parse_sess().interner;
return ~[intr.intern(@~"unstable"), intr.intern(@~"extfmt"),
intr.intern(@~"rt"), intr.intern(ident)];
}
fn make_rt_path_expr(cx: ext_ctxt, sp: span, nm: @~str) -> @ast::expr {
fn make_rt_path_expr(cx: @ext_ctxt, sp: span, nm: @~str) -> @ast::expr {
let path = make_path_vec(cx, nm);
return mk_path_global(cx, sp, path);
}
// Produces an AST expression that represents a RT::conv record,
// which tells the RT::conv* functions how to perform the conversion
fn make_rt_conv_expr(cx: ext_ctxt, sp: span, cnv: Conv) -> @ast::expr {
fn make_flags(cx: ext_ctxt, sp: span, flags: ~[Flag]) -> @ast::expr {
fn make_rt_conv_expr(cx: @ext_ctxt, sp: span, cnv: Conv) -> @ast::expr {
fn make_flags(cx: @ext_ctxt, sp: span, flags: ~[Flag]) -> @ast::expr {
let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none");
for flags.each |f| {
let fstr = match *f {
@ -81,7 +81,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
}
return tmp_expr;
}
fn make_count(cx: ext_ctxt, sp: span, cnt: Count) -> @ast::expr {
fn make_count(cx: @ext_ctxt, sp: span, cnt: Count) -> @ast::expr {
match cnt {
CountImplied => {
return make_rt_path_expr(cx, sp, @~"CountImplied");
@ -95,7 +95,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
_ => cx.span_unimpl(sp, ~"unimplemented fmt! conversion")
}
}
fn make_ty(cx: ext_ctxt, sp: span, t: Ty) -> @ast::expr {
fn make_ty(cx: @ext_ctxt, sp: span, t: Ty) -> @ast::expr {
let mut rt_type;
match t {
TyHex(c) => match c {
@ -108,7 +108,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
}
return make_rt_path_expr(cx, sp, @rt_type);
}
fn make_conv_struct(cx: ext_ctxt, sp: span, flags_expr: @ast::expr,
fn make_conv_struct(cx: @ext_ctxt, sp: span, flags_expr: @ast::expr,
width_expr: @ast::expr, precision_expr: @ast::expr,
ty_expr: @ast::expr) -> @ast::expr {
let intr = cx.parse_sess().interner;
@ -139,7 +139,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
make_conv_struct(cx, sp, rt_conv_flags, rt_conv_width,
rt_conv_precision, rt_conv_ty)
}
fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: ~str, cnv: Conv,
fn make_conv_call(cx: @ext_ctxt, sp: span, conv_type: ~str, cnv: Conv,
arg: @ast::expr) -> @ast::expr {
let fname = ~"conv_" + conv_type;
let path = make_path_vec(cx, @fname);
@ -148,7 +148,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
return mk_call_global(cx, arg.span, path, args);
}
fn make_new_conv(cx: ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) ->
fn make_new_conv(cx: @ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) ->
@ast::expr {
// FIXME: Move validation code into core::extfmt (Issue #2249)

View file

@ -17,7 +17,7 @@ use ext::base::*;
use ext::base;
use print;
pub fn expand_syntax_ext(cx: ext_ctxt,
pub fn expand_syntax_ext(cx: @ext_ctxt,
sp: codemap::span,
tt: &[ast::token_tree])
-> base::MacResult {

View file

@ -138,7 +138,7 @@ pub trait ext_ctxt_ast_builder {
fn strip_bounds(&self, bounds: &Generics) -> Generics;
}
impl ext_ctxt_ast_builder for ext_ctxt {
impl ext_ctxt_ast_builder for @ext_ctxt {
fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty {
self.ty_path_ast_builder(path_global(~[
self.ident_of(~"core"),

View file

@ -37,9 +37,8 @@ use ext::base::ext_ctxt;
use ext::pipes::proto::{state, protocol, next_state};
use ext::pipes::proto;
impl proto::visitor<(), (), ()> for ext_ctxt {
fn visit_proto(&self, _proto: protocol,
_states: &[()]) { }
impl proto::visitor<(), (), ()> for @ext_ctxt {
fn visit_proto(&self, _proto: protocol, _states: &[()]) { }
fn visit_state(&self, state: state, _m: &[()]) {
if state.messages.len() == 0 {

View file

@ -45,7 +45,7 @@ use ext::pipes::proto::protocol;
use core::str;
use std::bitv::Bitv;
pub fn analyze(proto: protocol, _cx: ext_ctxt) {
pub fn analyze(proto: protocol, _cx: @ext_ctxt) {
debug!("initializing colive analysis");
let num_states = proto.num_states();
let mut colive = do (copy proto.states).map_to_vec |state| {

View file

@ -63,13 +63,15 @@ pub mod check;
pub mod liveness;
pub fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident,
pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident,
tt: ~[ast::token_tree]) -> base::MacResult {
let sess = cx.parse_sess();
let cfg = cx.cfg();
let tt_rdr = new_tt_reader(copy cx.parse_sess().span_diagnostic,
cx.parse_sess().interner, None, copy tt);
let rdr = tt_rdr as reader;
cx.parse_sess().interner,
None,
copy tt);
let rdr = tt_rdr as @reader;
let rust_parser = Parser(sess, cfg, rdr.dup());
let mut proto = rust_parser.parse_proto(cx.str_of(id));

View file

@ -26,27 +26,27 @@ use core::to_str::ToStr;
use core::vec;
pub trait gen_send {
fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item;
fn to_ty(&mut self, cx: ext_ctxt) -> @ast::Ty;
fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item;
fn to_ty(&mut self, cx: @ext_ctxt) -> @ast::Ty;
}
pub trait to_type_decls {
fn to_type_decls(&self, cx: ext_ctxt) -> ~[@ast::item];
fn to_endpoint_decls(&self, cx: ext_ctxt,
fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item];
fn to_endpoint_decls(&self, cx: @ext_ctxt,
dir: direction) -> ~[@ast::item];
}
pub trait gen_init {
fn gen_init(&self, cx: ext_ctxt) -> @ast::item;
fn compile(&self, cx: ext_ctxt) -> @ast::item;
fn buffer_ty_path(&self, cx: ext_ctxt) -> @ast::Ty;
fn gen_buffer_type(&self, cx: ext_ctxt) -> @ast::item;
fn gen_buffer_init(&self, ext_cx: ext_ctxt) -> @ast::expr;
fn gen_init_bounded(&self, ext_cx: ext_ctxt) -> @ast::expr;
fn gen_init(&self, cx: @ext_ctxt) -> @ast::item;
fn compile(&self, cx: @ext_ctxt) -> @ast::item;
fn buffer_ty_path(&self, cx: @ext_ctxt) -> @ast::Ty;
fn gen_buffer_type(&self, cx: @ext_ctxt) -> @ast::item;
fn gen_buffer_init(&self, ext_cx: @ext_ctxt) -> @ast::expr;
fn gen_init_bounded(&self, ext_cx: @ext_ctxt) -> @ast::expr;
}
impl gen_send for message {
fn gen_send(&mut self, cx: ext_ctxt, try: bool) -> @ast::item {
fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item {
debug!("pipec: gen_send");
let name = self.name();
@ -188,14 +188,14 @@ impl gen_send for message {
}
}
fn to_ty(&mut self, cx: ext_ctxt) -> @ast::Ty {
fn to_ty(&mut self, cx: @ext_ctxt) -> @ast::Ty {
cx.ty_path_ast_builder(path(~[cx.ident_of(self.name())], self.span())
.add_tys(cx.ty_vars_global(&self.get_generics().ty_params)))
}
}
impl to_type_decls for state {
fn to_type_decls(&self, cx: ext_ctxt) -> ~[@ast::item] {
fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item] {
debug!("pipec: to_type_decls");
// This compiles into two different type declarations. Say the
// state is called ping. This will generate both `ping` and
@ -244,7 +244,7 @@ impl to_type_decls for state {
]
}
fn to_endpoint_decls(&self, cx: ext_ctxt,
fn to_endpoint_decls(&self, cx: @ext_ctxt,
dir: direction) -> ~[@ast::item] {
debug!("pipec: to_endpoint_decls");
let dir = match dir {
@ -306,7 +306,7 @@ impl to_type_decls for state {
}
impl gen_init for protocol {
fn gen_init(&self, cx: ext_ctxt) -> @ast::item {
fn gen_init(&self, cx: @ext_ctxt) -> @ast::item {
let ext_cx = cx;
debug!("gen_init");
@ -344,7 +344,7 @@ impl gen_init for protocol {
body.to_source(cx)))
}
fn gen_buffer_init(&self, ext_cx: ext_ctxt) -> @ast::expr {
fn gen_buffer_init(&self, ext_cx: @ext_ctxt) -> @ast::expr {
ext_cx.struct_expr(path(~[ext_cx.ident_of(~"__Buffer")],
dummy_sp()),
self.states.map_to_vec(|s| {
@ -356,7 +356,7 @@ impl gen_init for protocol {
}))
}
fn gen_init_bounded(&self, ext_cx: ext_ctxt) -> @ast::expr {
fn gen_init_bounded(&self, ext_cx: @ext_ctxt) -> @ast::expr {
debug!("gen_init_bounded");
let buffer_fields = self.gen_buffer_init(ext_cx);
let buffer = quote_expr!(~::core::pipes::Buffer {
@ -382,7 +382,7 @@ impl gen_init for protocol {
})
}
fn buffer_ty_path(&self, cx: ext_ctxt) -> @ast::Ty {
fn buffer_ty_path(&self, cx: @ext_ctxt) -> @ast::Ty {
let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
for (copy self.states).each |s| {
for s.generics.ty_params.each |tp| {
@ -399,7 +399,7 @@ impl gen_init for protocol {
.add_tys(cx.ty_vars_global(&params)))
}
fn gen_buffer_type(&self, cx: ext_ctxt) -> @ast::item {
fn gen_buffer_type(&self, cx: @ext_ctxt) -> @ast::item {
let ext_cx = cx;
let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
let fields = do (copy self.states).map_to_vec |s| {
@ -442,7 +442,7 @@ impl gen_init for protocol {
cx.strip_bounds(&generics))
}
fn compile(&self, cx: ext_ctxt) -> @ast::item {
fn compile(&self, cx: @ext_ctxt) -> @ast::item {
let mut items = ~[self.gen_init(cx)];
let mut client_states = ~[];
let mut server_states = ~[];

View file

@ -96,7 +96,7 @@ pub impl state_ {
}
/// Returns the type that is used for the messages.
fn to_ty(&self, cx: ext_ctxt) -> @ast::Ty {
fn to_ty(&self, cx: @ext_ctxt) -> @ast::Ty {
cx.ty_path_ast_builder
(path(~[cx.ident_of(self.name)],self.span).add_tys(
cx.ty_vars(&self.generics.ty_params)))

View file

@ -49,11 +49,11 @@ pub mod rt {
use print::pprust::{item_to_str, ty_to_str};
pub trait ToTokens {
pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree];
pub fn to_tokens(&self, _cx: @ext_ctxt) -> ~[token_tree];
}
impl ToTokens for ~[token_tree] {
pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree] {
pub fn to_tokens(&self, _cx: @ext_ctxt) -> ~[token_tree] {
copy *self
}
}
@ -62,10 +62,10 @@ pub mod rt {
trait ToSource : ToTokens {
// Takes a thing and generates a string containing rust code for it.
pub fn to_source(cx: ext_ctxt) -> ~str;
pub fn to_source(cx: @ext_ctxt) -> ~str;
// If you can make source, you can definitely make tokens.
pub fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
pub fn to_tokens(cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
@ -74,47 +74,47 @@ pub mod rt {
pub trait ToSource {
// Takes a thing and generates a string containing rust code for it.
pub fn to_source(&self, cx: ext_ctxt) -> ~str;
pub fn to_source(&self, cx: @ext_ctxt) -> ~str;
}
impl ToSource for ast::ident {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
copy *cx.parse_sess().interner.get(*self)
}
}
impl ToSource for @ast::item {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
item_to_str(*self, cx.parse_sess().interner)
}
}
impl ToSource for ~[@ast::item] {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ~"\n\n")
}
}
impl ToSource for @ast::Ty {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
ty_to_str(*self, cx.parse_sess().interner)
}
}
impl ToSource for ~[@ast::Ty] {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ~", ")
}
}
impl ToSource for Generics {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
pprust::generics_to_str(self, cx.parse_sess().interner)
}
}
impl ToSource for @ast::expr {
fn to_source(&self, cx: ext_ctxt) -> ~str {
fn to_source(&self, cx: @ext_ctxt) -> ~str {
pprust::expr_to_str(*self, cx.parse_sess().interner)
}
}
@ -122,43 +122,43 @@ pub mod rt {
// Alas ... we write these out instead. All redundant.
impl ToTokens for ast::ident {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
impl ToTokens for @ast::item {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
impl ToTokens for ~[@ast::item] {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
impl ToTokens for @ast::Ty {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
impl ToTokens for ~[@ast::Ty] {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
impl ToTokens for Generics {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
impl ToTokens for @ast::expr {
fn to_tokens(&self, cx: ext_ctxt) -> ~[token_tree] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
@ -170,7 +170,7 @@ pub mod rt {
fn parse_tts(&self, s: ~str) -> ~[ast::token_tree];
}
impl ExtParseUtils for ext_ctxt {
impl ExtParseUtils for @ext_ctxt {
fn parse_item(&self, s: ~str) -> @ast::item {
let res = parse::parse_item_from_source_str(
@ -216,19 +216,19 @@ pub mod rt {
}
pub fn expand_quote_tokens(cx: ext_ctxt,
pub fn expand_quote_tokens(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
base::MRExpr(expand_tts(cx, sp, tts))
}
pub fn expand_quote_expr(cx: ext_ctxt,
pub fn expand_quote_expr(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
base::MRExpr(expand_parse_call(cx, sp, ~"parse_expr", ~[], tts))
}
pub fn expand_quote_item(cx: ext_ctxt,
pub fn expand_quote_item(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]);
@ -236,7 +236,7 @@ pub fn expand_quote_item(cx: ext_ctxt,
~[e_attrs], tts))
}
pub fn expand_quote_pat(cx: ext_ctxt,
pub fn expand_quote_pat(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_refutable = build::mk_lit(cx, sp, ast::lit_bool(true));
@ -244,7 +244,7 @@ pub fn expand_quote_pat(cx: ext_ctxt,
~[e_refutable], tts))
}
pub fn expand_quote_ty(cx: ext_ctxt,
pub fn expand_quote_ty(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_param_colons = build::mk_lit(cx, sp, ast::lit_bool(false));
@ -252,7 +252,7 @@ pub fn expand_quote_ty(cx: ext_ctxt,
~[e_param_colons], tts))
}
pub fn expand_quote_stmt(cx: ext_ctxt,
pub fn expand_quote_stmt(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]);
@ -260,16 +260,16 @@ pub fn expand_quote_stmt(cx: ext_ctxt,
~[e_attrs], tts))
}
fn ids_ext(cx: ext_ctxt, strs: ~[~str]) -> ~[ast::ident] {
fn ids_ext(cx: @ext_ctxt, strs: ~[~str]) -> ~[ast::ident] {
strs.map(|str| cx.parse_sess().interner.intern(@copy *str))
}
fn id_ext(cx: ext_ctxt, +str: ~str) -> ast::ident {
fn id_ext(cx: @ext_ctxt, +str: ~str) -> ast::ident {
cx.parse_sess().interner.intern(@str)
}
// Lift an ident to the expr that evaluates to that ident.
fn mk_ident(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr {
fn mk_ident(cx: @ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr {
let e_meth = build::mk_access(cx, sp,
ids_ext(cx, ~[~"ext_cx"]),
id_ext(cx, ~"ident_of"));
@ -277,13 +277,13 @@ fn mk_ident(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr {
build::mk_call_(cx, sp, e_meth, ~[e_str])
}
fn mk_bytepos(cx: ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr {
fn mk_bytepos(cx: @ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr {
let path = ids_ext(cx, ~[~"BytePos"]);
let arg = build::mk_uint(cx, sp, bpos.to_uint());
build::mk_call(cx, sp, path, ~[arg])
}
fn mk_binop(cx: ext_ctxt, sp: span, bop: token::binop) -> @ast::expr {
fn mk_binop(cx: @ext_ctxt, sp: span, bop: token::binop) -> @ast::expr {
let name = match bop {
PLUS => "PLUS",
MINUS => "MINUS",
@ -300,7 +300,7 @@ fn mk_binop(cx: ext_ctxt, sp: span, bop: token::binop) -> @ast::expr {
ids_ext(cx, ~[name.to_owned()]))
}
fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr {
fn mk_token(cx: @ext_ctxt, sp: span, tok: token::Token) -> @ast::expr {
match tok {
BINOP(binop) => {
@ -443,7 +443,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr {
}
fn mk_tt(cx: ext_ctxt, sp: span, tt: &ast::token_tree)
fn mk_tt(cx: @ext_ctxt, sp: span, tt: &ast::token_tree)
-> ~[@ast::stmt] {
match *tt {
@ -494,7 +494,7 @@ fn mk_tt(cx: ext_ctxt, sp: span, tt: &ast::token_tree)
}
}
fn mk_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
fn mk_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> ~[@ast::stmt] {
let mut ss = ~[];
for tts.each |tt| {
@ -503,7 +503,7 @@ fn mk_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
ss
}
fn expand_tts(cx: ext_ctxt,
fn expand_tts(cx: @ext_ctxt,
sp: span,
tts: &[ast::token_tree]) -> @ast::expr {
@ -577,7 +577,7 @@ fn expand_tts(cx: ext_ctxt,
ids_ext(cx, ~[~"tt"]))))
}
fn expand_parse_call(cx: ext_ctxt,
fn expand_parse_call(cx: @ext_ctxt,
sp: span,
+parse_method: ~str,
+arg_exprs: ~[@ast::expr],

View file

@ -29,7 +29,7 @@ use core::vec;
// a given file into the current one.
/* line!(): expands to the current line number */
pub fn expand_line(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_line(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "line!");
@ -40,7 +40,7 @@ pub fn expand_line(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
}
/* col!(): expands to the current column number */
pub fn expand_col(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_col(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "col!");
@ -52,7 +52,7 @@ pub fn expand_col(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
/* file!(): expands to the current filename */
/* The filemap (`loc.file`) contains a bunch more information we could spit
* out if we wanted. */
pub fn expand_file(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_file(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "file!");
@ -62,13 +62,13 @@ pub fn expand_file(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
base::MRExpr(mk_base_str(cx, topmost.call_site, filename))
}
pub fn expand_stringify(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_stringify(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let s = pprust::tts_to_str(tts, cx.parse_sess().interner);
base::MRExpr(mk_base_str(cx, sp, s))
}
pub fn expand_mod(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_mod(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "module_path!");
base::MRExpr(mk_base_str(cx, sp,
@ -79,7 +79,7 @@ pub fn expand_mod(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
// include! : parse the given file as an expr
// This is generally a bad idea because it's going to behave
// unhygienically.
pub fn expand_include(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_include(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include!");
let p = parse::new_sub_parser_from_file(
@ -89,7 +89,7 @@ pub fn expand_include(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
}
// include_str! : read the given file, insert it as a literal string expr
pub fn expand_include_str(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_include_str(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include_str!");
let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file)));
@ -103,7 +103,7 @@ pub fn expand_include_str(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
base::MRExpr(mk_base_str(cx, sp, result::unwrap(res)))
}
pub fn expand_include_bin(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_include_bin(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
@ -147,7 +147,7 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo {
// resolve a file-system path to an absolute file-system path (if it
// isn't already)
fn res_rel_file(cx: ext_ctxt, sp: codemap::span, arg: &Path) -> Path {
fn res_rel_file(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path {
// NB: relative paths are resolved relative to the compilation unit
if !arg.is_absolute {
let cu = Path(cx.codemap().span_to_filename(sp));

View file

@ -17,8 +17,10 @@ use ext::base;
use parse::lexer::{new_tt_reader, reader};
use parse::parser::Parser;
pub fn expand_trace_macros(cx: ext_ctxt, sp: span,
tt: &[ast::token_tree]) -> base::MacResult {
pub fn expand_trace_macros(cx: @ext_ctxt,
sp: span,
tt: &[ast::token_tree])
-> base::MacResult {
let sess = cx.parse_sess();
let cfg = cx.cfg();
let tt_rdr = new_tt_reader(
@ -27,7 +29,7 @@ pub fn expand_trace_macros(cx: ext_ctxt, sp: span,
None,
vec::from_slice(tt)
);
let rdr = tt_rdr as reader;
let rdr = tt_rdr as @reader;
let rust_parser = Parser(
sess,
copy cfg,

View file

@ -224,7 +224,7 @@ pub enum parse_result {
pub fn parse_or_else(
sess: @mut ParseSess,
+cfg: ast::crate_cfg,
rdr: reader,
rdr: @reader,
ms: ~[matcher]
) -> HashMap<ident, @named_match> {
match parse(sess, cfg, rdr, ms) {
@ -237,7 +237,7 @@ pub fn parse_or_else(
pub fn parse(
sess: @mut ParseSess,
cfg: ast::crate_cfg,
rdr: reader,
rdr: @reader,
ms: ~[matcher]
) -> parse_result {
let mut cur_eis = ~[];

View file

@ -27,8 +27,11 @@ use print;
use core::io;
pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
arg: ~[ast::token_tree]) -> base::MacResult {
pub fn add_new_extension(cx: @ext_ctxt,
sp: span,
name: ident,
arg: ~[ast::token_tree])
-> base::MacResult {
// these spans won't matter, anyways
fn ms(m: matcher_) -> matcher {
spanned { node: copy m, span: dummy_sp() }
@ -54,8 +57,10 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
// Parse the macro_rules! invocation (`none` is for no interpolations):
let arg_reader = new_tt_reader(copy cx.parse_sess().span_diagnostic,
cx.parse_sess().interner, None, copy arg);
let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(),
arg_reader as reader, argument_gram);
let argument_map = parse_or_else(cx.parse_sess(),
cx.cfg(),
arg_reader as @reader,
argument_gram);
// Extract the arguments:
let lhses = match argument_map.get(&lhs_nm) {
@ -69,7 +74,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
};
// Given `lhses` and `rhses`, this is the new macro we create
fn generic_extension(cx: ext_ctxt, sp: span, name: ident,
fn generic_extension(cx: @ext_ctxt, sp: span, name: ident,
arg: &[ast::token_tree],
lhses: ~[@named_match], rhses: ~[@named_match])
-> MacResult {
@ -98,7 +103,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
itr,
None,
vec::from_slice(arg)
) as reader;
) as @reader;
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, (*mtcs)) {
success(named_matches) => {
let rhs = match rhses[i] {
@ -118,8 +123,9 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
// rhs has holes ( `$id` and `$(...)` that need filled)
let trncbr = new_tt_reader(s_d, itr, Some(named_matches),
rhs);
let p = @Parser(cx.parse_sess(), cx.cfg(),
trncbr as reader);
let p = @Parser(cx.parse_sess(),
cx.cfg(),
trncbr as @reader);
// Let the context choose how to interpret the result.
// Weird, but useful for X-macros.
@ -140,7 +146,7 @@ pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
cx.span_fatal(best_fail_spot, best_fail_msg);
}
let exp: @fn(ext_ctxt, span, &[ast::token_tree]) -> MacResult =
let exp: @fn(@ext_ctxt, span, &[ast::token_tree]) -> MacResult =
|cx, sp, arg| generic_extension(cx, sp, name, arg, lhses, rhses);
return MRDef(MacroDef{

View file

@ -34,7 +34,7 @@ struct TtFrame {
}
pub struct TtReader {
sp_diag: span_handler,
sp_diag: @span_handler,
interner: @ident_interner,
// the unzipped tree:
cur: @mut TtFrame,
@ -50,7 +50,7 @@ pub struct TtReader {
/** This can do Macro-By-Example transcription. On the other hand, if
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
* should) be none. */
pub fn new_tt_reader(sp_diag: span_handler,
pub fn new_tt_reader(sp_diag: @span_handler,
itr: @ident_interner,
interp: Option<std::oldmap::HashMap<ident,@named_match>>,
+src: ~[ast::token_tree])

View file

@ -48,26 +48,26 @@ pub trait ast_fold {
pub struct AstFoldFns {
//unlike the others, item_ is non-trivial
fold_crate: @fn(&crate_, span, ast_fold) -> (crate_, span),
fold_view_item: @fn(view_item_, ast_fold) -> view_item_,
fold_foreign_item: @fn(@foreign_item, ast_fold) -> @foreign_item,
fold_item: @fn(@item, ast_fold) -> Option<@item>,
fold_struct_field: @fn(@struct_field, ast_fold) -> @struct_field,
fold_item_underscore: @fn(&item_, ast_fold) -> item_,
fold_method: @fn(@method, ast_fold) -> @method,
fold_block: @fn(&blk_, span, ast_fold) -> (blk_, span),
fold_stmt: @fn(&stmt_, span, ast_fold) -> (stmt_, span),
fold_arm: @fn(&arm, ast_fold) -> arm,
fold_pat: @fn(&pat_, span, ast_fold) -> (pat_, span),
fold_decl: @fn(&decl_, span, ast_fold) -> (decl_, span),
fold_expr: @fn(&expr_, span, ast_fold) -> (expr_, span),
fold_ty: @fn(&ty_, span, ast_fold) -> (ty_, span),
fold_mod: @fn(&_mod, ast_fold) -> _mod,
fold_foreign_mod: @fn(&foreign_mod, ast_fold) -> foreign_mod,
fold_variant: @fn(&variant_, span, ast_fold) -> (variant_, span),
fold_ident: @fn(ident, ast_fold) -> ident,
fold_path: @fn(@path, ast_fold) -> path,
fold_local: @fn(&local_, span, ast_fold) -> (local_, span),
fold_crate: @fn(&crate_, span, @ast_fold) -> (crate_, span),
fold_view_item: @fn(view_item_, @ast_fold) -> view_item_,
fold_foreign_item: @fn(@foreign_item, @ast_fold) -> @foreign_item,
fold_item: @fn(@item, @ast_fold) -> Option<@item>,
fold_struct_field: @fn(@struct_field, @ast_fold) -> @struct_field,
fold_item_underscore: @fn(&item_, @ast_fold) -> item_,
fold_method: @fn(@method, @ast_fold) -> @method,
fold_block: @fn(&blk_, span, @ast_fold) -> (blk_, span),
fold_stmt: @fn(&stmt_, span, @ast_fold) -> (stmt_, span),
fold_arm: @fn(&arm, @ast_fold) -> arm,
fold_pat: @fn(&pat_, span, @ast_fold) -> (pat_, span),
fold_decl: @fn(&decl_, span, @ast_fold) -> (decl_, span),
fold_expr: @fn(&expr_, span, @ast_fold) -> (expr_, span),
fold_ty: @fn(&ty_, span, @ast_fold) -> (ty_, span),
fold_mod: @fn(&_mod, @ast_fold) -> _mod,
fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod,
fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span),
fold_ident: @fn(ident, @ast_fold) -> ident,
fold_path: @fn(@path, @ast_fold) -> path,
fold_local: @fn(&local_, span, @ast_fold) -> (local_, span),
map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr],
new_id: @fn(node_id) -> node_id,
new_span: @fn(span) -> span
@ -436,8 +436,8 @@ fn noop_fold_decl(d: &decl_, fld: @ast_fold) -> decl_ {
}
}
pub fn wrap<T>(f: @fn(&T, ast_fold) -> T)
-> @fn(&T, span, ast_fold) -> (T, span) {
pub fn wrap<T>(f: @fn(&T, @ast_fold) -> T)
-> @fn(&T, span, @ast_fold) -> (T, span) {
let result: @fn(&T, span, @ast_fold) -> (T, span) = |x, s, fld| {
(f(x, fld), s)
};
@ -879,13 +879,13 @@ impl ast_fold for AstFoldFns {
}
}
pub impl ast_fold {
pub impl @ast_fold {
fn fold_attributes(&self, attrs: ~[attribute]) -> ~[attribute] {
attrs.map(|x| fold_attribute_(*x, *self))
}
}
pub fn make_fold(afp: ast_fold_fns) -> ast_fold {
pub fn make_fold(afp: ast_fold_fns) -> @ast_fold {
afp as @ast_fold
}

View file

@ -256,7 +256,7 @@ fn read_block_comment(rdr: @mut StringReader,
while level > 0 {
debug!("=== block comment level %d", level);
if is_eof(rdr) {
(rdr as reader).fatal(~"unterminated block comment");
(rdr as @reader).fatal(~"unterminated block comment");
}
if rdr.curr == '\n' {
trim_whitespace_prefix_and_push_line(&mut lines, curr_line,
@ -319,9 +319,11 @@ pub struct lit {
pos: BytePos
}
pub fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
pub fn gather_comments_and_literals(span_diagnostic:
@diagnostic::span_handler,
+path: ~str,
srdr: io::Reader) -> (~[cmnt], ~[lit]) {
srdr: @io::Reader)
-> (~[cmnt], ~[lit]) {
let src = @str::from_bytes(srdr.read_whole_stream());
let itr = parse::token::mk_fake_ident_interner();
let cm = CodeMap::new();

View file

@ -47,7 +47,7 @@ pub fn seq_sep_none() -> SeqSep {
}
}
pub fn token_to_str(reader: reader, token: &token::Token) -> ~str {
pub fn token_to_str(reader: @reader, token: &token::Token) -> ~str {
token::to_str(reader.interner(), token)
}

View file

@ -31,17 +31,17 @@ pub trait reader {
fn is_eof(@mut self) -> bool;
fn next_token(@mut self) -> TokenAndSpan;
fn fatal(@mut self, ~str) -> !;
fn span_diag(@mut self) -> span_handler;
fn span_diag(@mut self) -> @span_handler;
pure fn interner(@mut self) -> @token::ident_interner;
fn peek(@mut self) -> TokenAndSpan;
fn dup(@mut self) -> reader;
fn dup(@mut self) -> @reader;
}
#[deriving_eq]
pub struct TokenAndSpan {tok: token::Token, sp: span}
pub struct StringReader {
span_diagnostic: span_handler,
span_diagnostic: @span_handler,
src: @~str,
// The absolute offset within the codemap of the next character to read
pos: BytePos,
@ -58,7 +58,7 @@ pub struct StringReader {
peek_span: span
}
pub fn new_string_reader(span_diagnostic: span_handler,
pub fn new_string_reader(span_diagnostic: @span_handler,
filemap: @codemap::FileMap,
itr: @token::ident_interner)
-> @mut StringReader {
@ -68,7 +68,7 @@ pub fn new_string_reader(span_diagnostic: span_handler,
}
/* For comments.rs, which hackily pokes into 'pos' and 'curr' */
pub fn new_low_level_string_reader(span_diagnostic: span_handler,
pub fn new_low_level_string_reader(span_diagnostic: @span_handler,
filemap: @codemap::FileMap,
itr: @token::ident_interner)
-> @mut StringReader {
@ -121,7 +121,7 @@ impl reader for StringReader {
fn fatal(@mut self, m: ~str) -> ! {
self.span_diagnostic.span_fatal(copy self.peek_span, m)
}
fn span_diag(@mut self) -> span_handler { self.span_diagnostic }
fn span_diag(@mut self) -> @span_handler { self.span_diagnostic }
pure fn interner(@mut self) -> @token::ident_interner { self.interner }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
@ -129,7 +129,7 @@ impl reader for StringReader {
sp: copy self.peek_span,
}
}
fn dup(@mut self) -> reader { dup_string_reader(self) as reader }
fn dup(@mut self) -> @reader { dup_string_reader(self) as @reader }
}
impl reader for TtReader {
@ -138,7 +138,7 @@ impl reader for TtReader {
fn fatal(@mut self, m: ~str) -> ! {
self.sp_diag.span_fatal(copy self.cur_span, m);
}
fn span_diag(@mut self) -> span_handler { self.sp_diag }
fn span_diag(@mut self) -> @span_handler { self.sp_diag }
pure fn interner(@mut self) -> @token::ident_interner { self.interner }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
@ -146,7 +146,7 @@ impl reader for TtReader {
sp: copy self.cur_span,
}
}
fn dup(@mut self) -> reader { dup_tt_reader(self) as reader }
fn dup(@mut self) -> @reader { dup_tt_reader(self) as @reader }
}
// EFFECT: advance peek_tok and peek_span to refer to the next token.

View file

@ -48,7 +48,7 @@ pub mod obsolete;
pub struct ParseSess {
cm: @codemap::CodeMap,
next_id: node_id,
span_diagnostic: span_handler,
span_diagnostic: @span_handler,
interner: @ident_interner,
}
@ -62,7 +62,8 @@ pub fn new_parse_sess(demitter: Option<Emitter>) -> @mut ParseSess {
}
}
pub fn new_parse_sess_special_handler(sh: span_handler, cm: @codemap::CodeMap)
pub fn new_parse_sess_special_handler(sh: @span_handler,
cm: @codemap::CodeMap)
-> @mut ParseSess {
@mut ParseSess {
cm: cm,
@ -201,20 +202,19 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id {
return rv;
}
pub fn new_parser_from_source_str(
sess: @mut ParseSess,
pub fn new_parser_from_source_str(sess: @mut ParseSess,
+cfg: ast::crate_cfg,
+name: ~str,
+ss: codemap::FileSubstr,
source: @~str
) -> Parser {
source: @~str)
-> Parser {
let filemap = sess.cm.new_filemap_w_substr(name, ss, source);
let srdr = lexer::new_string_reader(
copy sess.span_diagnostic,
filemap,
sess.interner
);
Parser(sess, cfg, srdr as reader)
Parser(sess, cfg, srdr as @reader)
}
/// Read the entire source file, return a parser
@ -227,12 +227,10 @@ pub fn new_parser_result_from_file(
match io::read_whole_file_str(path) {
Ok(src) => {
let filemap = sess.cm.new_filemap(path.to_str(), @src);
let srdr = lexer::new_string_reader(
copy sess.span_diagnostic,
let srdr = lexer::new_string_reader(copy sess.span_diagnostic,
filemap,
sess.interner
);
Ok(Parser(sess, cfg, srdr as reader))
sess.interner);
Ok(Parser(sess, cfg, srdr as @reader))
}
Err(e) => Err(e)
@ -281,7 +279,7 @@ pub fn new_parser_from_tts(
None,
tts
);
Parser(sess, cfg, trdr as reader)
Parser(sess, cfg, trdr as @reader)
}
// abort if necessary

View file

@ -215,8 +215,8 @@ struct ParsedItemsAndViewItems {
pub fn Parser(sess: @mut ParseSess,
+cfg: ast::crate_cfg,
+rdr: reader) -> Parser {
+rdr: @reader)
-> Parser {
let tok0 = copy rdr.next_token();
let interner = rdr.interner();
@ -254,7 +254,7 @@ pub struct Parser {
tokens_consumed: @mut uint,
restriction: @mut restriction,
quote_depth: @mut uint, // not (yet) related to the quasiquoter
reader: reader,
reader: @reader,
interner: @token::ident_interner,
keywords: HashMap<~str, ()>,
strict_keywords: HashMap<~str, ()>,

View file

@ -76,7 +76,7 @@ pub fn end(s: @ps) {
pp::end(s.s);
}
pub fn rust_printer(writer: io::Writer, intr: @ident_interner) -> @ps {
pub fn rust_printer(writer: @io::Writer, intr: @ident_interner) -> @ps {
return @ps {
s: pp::mk_printer(writer, default_columns),
cm: None::<@CodeMap>,
@ -100,10 +100,15 @@ pub const default_columns: uint = 78u;
// Requires you to pass an input filename and reader so that
// it can scan the input text for comments and literals to
// copy forward.
pub fn print_crate(cm: @CodeMap, intr: @ident_interner,
span_diagnostic: diagnostic::span_handler,
crate: @ast::crate, filename: ~str, in: io::Reader,
out: io::Writer, ann: pp_ann, is_expanded: bool) {
pub fn print_crate(cm: @CodeMap,
intr: @ident_interner,
span_diagnostic: @diagnostic::span_handler,
crate: @ast::crate,
filename: ~str,
in: @io::Reader,
out: @io::Writer,
ann: pp_ann,
is_expanded: bool) {
let (cmnts, lits) = comments::gather_comments_and_literals(
span_diagnostic,
copy filename,

View file

@ -13,7 +13,7 @@
pub trait i<T> { }
pub fn f<T>() -> i<T> {
pub fn f<T>() -> @i<T> {
impl<T> i<T> for () { }
@() as @i<T>

View file

@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
}
fn main() {
let nyan : noisy = @cat(0, 2, ~"nyan") as @noisy;
let nyan : @noisy = @cat(0, 2, ~"nyan") as @noisy;
nyan.eat(); //~ ERROR type `@noisy` does not implement any method in scope named `eat`
}

View file

@ -14,14 +14,14 @@ impl<A:Copy> repeat<A> for @A {
fn get() -> A { *self }
}
fn repeater<A:Copy>(v: @A) -> repeat<A> {
fn repeater<A:Copy>(v: @A) -> @repeat<A> {
// Note: owned kind is not necessary as A appears in the trait type
@v as repeat::<A> // No
@v as @repeat::<A> // No
}
fn main() {
// Error results because the type of is inferred to be
// repeat<&blk/int> where blk is the lifetime of the block below.
// @repeat<&blk/int> where blk is the lifetime of the block below.
let y = { //~ ERROR reference is not valid
let x: &blk/int = &3;

View file

@ -26,22 +26,22 @@ fn to_foo<T:Copy>(t: T) {
// the fn body itself.
let v = &3;
struct F<T> { f: T }
let x = @F {f:t} as foo;
let x = @F {f:t} as @foo;
fail_unless!(x.foo(v) == 3);
}
fn to_foo_2<T:Copy>(t: T) -> foo {
fn to_foo_2<T:Copy>(t: T) -> @foo {
// Not OK---T may contain borrowed ptrs and it is going to escape
// as part of the returned foo value
struct F<T> { f: T }
@F {f:t} as foo //~ ERROR value may contain borrowed pointers; use `&static` bound
@F {f:t} as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound
}
fn to_foo_3<T:Copy + &static>(t: T) -> foo {
fn to_foo_3<T:Copy + &static>(t: T) -> @foo {
// OK---T may escape as part of the returned foo value, but it is
// owned and hence does not contain borrowed ptrs
struct F<T> { f: T }
@F {f:t} as foo
@F {f:t} as @foo
}
fn main() {

View file

@ -10,11 +10,11 @@
trait foo { fn foo(); }
fn to_foo<T:Copy + foo>(t: T) -> foo {
fn to_foo<T:Copy + foo>(t: T) -> @foo {
@t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound
}
fn to_foo2<T:Copy + foo + &static>(t: T) -> foo {
fn to_foo2<T:Copy + foo + &static>(t: T) -> @foo {
@t as @foo
}

View file

@ -15,7 +15,7 @@ use core::hashmap::linear::LinearMap;
fn main() {
let x: @Map<~str, ~str> = @LinearMap::new::<~str, ~str>() as
Map::<~str, ~str>;
@Map::<~str, ~str>;
let y: @Map<uint, ~str> = @x;
//~^ ERROR mismatched types: expected `@core::container::Map<uint,~str>`
}

View file

@ -22,7 +22,7 @@ fn a_fn1(e: an_enum<'a>) -> an_enum<'b> {
return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
}
fn a_fn2(e: a_trait<'a>) -> a_trait<'b> {
fn a_fn2(e: @a_trait<'a>) -> @a_trait<'b> {
return e; //~ ERROR mismatched types: expected `@a_trait/&b` but found `@a_trait/&a`
}

View file

@ -18,7 +18,7 @@ trait foo<'self> {
}
struct with_foo<'self> {
f: foo<'self>
f: @foo<'self>
}
trait set_foo_foo {

View file

@ -27,12 +27,12 @@ impl get_ctxt for has_ctxt<'self> {
}
fn get_v(gc: get_ctxt) -> uint {
fn get_v(gc: @get_ctxt) -> uint {
gc.get_ctxt().v
}
fn main() {
let ctxt = ctxt { v: 22u };
let hc = has_ctxt { c: &ctxt };
fail_unless!(get_v(@hc as get_ctxt) == 22u);
fail_unless!(get_v(@hc as @get_ctxt) == 22u);
}

View file

@ -20,10 +20,10 @@ impl<'self> get_ctxt<'self> for has_ctxt<'self> {
fn get_ctxt() -> &self/ctxt { self.c }
}
fn make_gc() -> get_ctxt {
fn make_gc() -> @get_ctxt {
let ctxt = ctxt { v: 22u };
let hc = has_ctxt { c: &ctxt }; //~ ERROR illegal borrow
return @hc as get_ctxt;
return @hc as @get_ctxt;
}
fn main() {

View file

@ -12,7 +12,7 @@ trait get_ctxt {
fn get_ctxt() -> &self/uint;
}
fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b {
fn make_gc1(gc: @get_ctxt/&a) -> @get_ctxt/&b {
return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b` but found `@get_ctxt/&a`
}
@ -24,8 +24,8 @@ impl get_ctxt/&self for Foo/&self {
fn get_ctxt() -> &self/uint { self.r }
}
fn make_gc2(foo: Foo/&a) -> get_ctxt/&b {
return @foo as get_ctxt; //~ ERROR cannot infer an appropriate lifetime
fn make_gc2(foo: Foo/&a) -> @get_ctxt/&b {
return @foo as @get_ctxt; //~ ERROR cannot infer an appropriate lifetime
}
fn main() {

View file

@ -24,7 +24,7 @@ impl<T:Copy> box_trait<T> for box_impl<T> {
fn set(t: T) { self.f = t; }
}
fn set_box_trait<T>(b: box_trait<@const T>, v: @const T) {
fn set_box_trait<T>(b: @box_trait<@const T>, v: @const T) {
b.set(v);
}
@ -34,7 +34,7 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
fn main() {
let b = box_impl::<@int>(box::<@int> {f: @3});
set_box_trait(@b as box_trait::<@int>, @mut 5);
set_box_trait(@b as @box_trait::<@int>, @mut 5);
//~^ ERROR values differ in mutability
set_box_impl(b, @mut 5);
//~^ ERROR values differ in mutability

View file

@ -15,5 +15,5 @@ impl bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
fn main() {
10i.dup::<int>(); //~ ERROR does not take type parameters
10i.blah::<int, int>(); //~ ERROR incorrect number of type parameters
(@10 as bar).dup(); //~ ERROR contains a self-type
(@10 as @bar).dup(); //~ ERROR contains a self-type
}

View file

@ -24,7 +24,7 @@ impl TraitB for int {
fn call_it<B:TraitB>(b: B) -> int {
let y = 4u;
b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait @TraitA
b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait TraitA
}
fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait clam<A:Copy> {
trait c lam<A:Copy> {
fn chowder(y: A);
}
struct foo<A> {
@ -26,13 +26,13 @@ fn foo<A:Copy>(b: A) -> foo<A> {
}
}
fn f<A:Copy>(x: clam<A>, a: A) {
fn f<A:Copy>(x: @clam<A>, a: A) {
x.chowder(a);
}
pub fn main() {
let c = foo(42);
let d: clam<int> = @c as clam::<int>;
let d: @clam<int> = @c as @clam::<int>;
f(d, c.x);
}

View file

@ -11,7 +11,7 @@
trait hax { }
impl<A> hax for A { }
fn perform_hax<T:&static>(x: @T) -> hax {
fn perform_hax<T:&static>(x: @T) -> @hax {
@x as @hax
}

View file

@ -25,7 +25,7 @@ pub fn main() {
// let y = @({a: 4i});
// let z = @({a: 4i} as it);
// let z = @({a: true} as it);
let z = @(@true as it);
let z = @(@true as @it);
// x.f();
// y.f();
// (*z).f();

View file

@ -14,9 +14,9 @@ impl<A:Copy> repeat<A> for @A {
fn get() -> A { *self }
}
fn repeater<A:Copy>(v: @A) -> repeat<A> {
fn repeater<A:Copy>(v: @A) -> @repeat<A> {
// Note: owned kind is not necessary as A appears in the trait type
@v as repeat::<A> // No
@v as @repeat::<A> // No
}
pub fn main() {

View file

@ -29,7 +29,7 @@ impl<A:Copy + Serializable> Serializable for F<A> {
}
}
impl Serializer for io::Writer {
impl Serializer for @io::Writer {
}
pub fn main() {

Some files were not shown because too many files have changed in this diff Show more