1
Fork 0

syntax/ext: modernise ext_ctxt to be CamelCase and use new.

This commit is contained in:
Huon Wilson 2013-05-17 21:27:17 +10:00
parent eea265ea16
commit 4045da9f4f
36 changed files with 331 additions and 332 deletions

View file

@ -17,7 +17,7 @@ use syntax::ast_util::*;
use syntax::attr; use syntax::attr;
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan}; use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
use syntax::codemap; use syntax::codemap;
use syntax::ext::base::{mk_ctxt, ext_ctxt}; use syntax::ext::base::ExtCtxt;
use syntax::fold; use syntax::fold;
use syntax::print::pprust; use syntax::print::pprust;
use syntax::{ast, ast_util}; use syntax::{ast, ast_util};
@ -36,7 +36,7 @@ struct TestCtxt {
sess: session::Session, sess: session::Session,
crate: @ast::crate, crate: @ast::crate,
path: ~[ast::ident], path: ~[ast::ident],
ext_cx: @ext_ctxt, ext_cx: @ExtCtxt,
testfns: ~[Test] testfns: ~[Test]
} }
@ -64,7 +64,7 @@ fn generate_test_harness(sess: session::Session,
let cx: @mut TestCtxt = @mut TestCtxt { let cx: @mut TestCtxt = @mut TestCtxt {
sess: sess, sess: sess,
crate: crate, crate: crate,
ext_cx: mk_ctxt(sess.parse_sess, copy sess.opts.cfg), ext_cx: ExtCtxt::new(sess.parse_sess, copy sess.opts.cfg),
path: ~[], path: ~[],
testfns: ~[] testfns: ~[]
}; };

View file

@ -19,7 +19,7 @@ use std::semver;
use std::term; use std::term;
use syntax::ast_util::*; use syntax::ast_util::*;
use syntax::codemap::{dummy_sp, spanned, dummy_spanned}; use syntax::codemap::{dummy_sp, spanned, dummy_spanned};
use syntax::ext::base::{mk_ctxt, ext_ctxt}; use syntax::ext::base::ExtCtxt;
use syntax::{ast, attr, codemap, diagnostic, fold}; use syntax::{ast, attr, codemap, diagnostic, fold};
use syntax::ast::{meta_name_value, meta_list}; use syntax::ast::{meta_name_value, meta_list};
use syntax::attr::{mk_attr}; use syntax::attr::{mk_attr};
@ -178,7 +178,7 @@ struct ListenerFn {
struct ReadyCtx { struct ReadyCtx {
sess: session::Session, sess: session::Session,
crate: @ast::crate, crate: @ast::crate,
ext_cx: @ext_ctxt, ext_cx: @ExtCtxt,
path: ~[ast::ident], path: ~[ast::ident],
fns: ~[ListenerFn] fns: ~[ListenerFn]
} }
@ -247,7 +247,7 @@ pub fn ready_crate(sess: session::Session,
let ctx = @mut ReadyCtx { let ctx = @mut ReadyCtx {
sess: sess, sess: sess,
crate: crate, crate: crate,
ext_cx: mk_ctxt(sess.parse_sess, copy sess.opts.cfg), ext_cx: ExtCtxt::new(sess.parse_sess, copy sess.opts.cfg),
path: ~[], path: ~[],
fns: ~[] fns: ~[]
}; };

View file

@ -37,7 +37,7 @@ 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let p = parse::new_parser_from_tts(cx.parse_sess(), let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(), cx.cfg(),

View file

@ -15,7 +15,7 @@ use codemap::span;
use ext::base::*; use ext::base::*;
pub fn expand_auto_encode( pub fn expand_auto_encode(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
_mitem: @ast::meta_item, _mitem: @ast::meta_item,
in_items: ~[@ast::item] in_items: ~[@ast::item]
@ -25,7 +25,7 @@ pub fn expand_auto_encode(
} }
pub fn expand_auto_decode( pub fn expand_auto_decode(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
_mitem: @ast::meta_item, _mitem: @ast::meta_item,
in_items: ~[@ast::item] in_items: ~[@ast::item]

View file

@ -33,7 +33,7 @@ pub struct MacroDef {
ext: SyntaxExtension ext: SyntaxExtension
} }
pub type ItemDecorator = @fn(@ext_ctxt, pub type ItemDecorator = @fn(@ExtCtxt,
span, span,
@ast::meta_item, @ast::meta_item,
~[@ast::item]) ~[@ast::item])
@ -44,7 +44,7 @@ pub struct SyntaxExpanderTT {
span: Option<span> span: Option<span>
} }
pub type SyntaxExpanderTTFun = @fn(@ext_ctxt, pub type SyntaxExpanderTTFun = @fn(@ExtCtxt,
span, span,
&[ast::token_tree]) &[ast::token_tree])
-> MacResult; -> MacResult;
@ -54,7 +54,7 @@ pub struct SyntaxExpanderTTItem {
span: Option<span> span: Option<span>
} }
pub type SyntaxExpanderTTItemFun = @fn(@ext_ctxt, pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt,
span, span,
ast::ident, ast::ident,
~[ast::token_tree]) ~[ast::token_tree])
@ -202,7 +202,7 @@ pub fn syntax_expander_table() -> SyntaxEnv {
// One of these is made during expansion and incrementally updated as we go; // One of these is made during expansion and incrementally updated as we go;
// when a macro expansion occurs, the resulting nodes have the backtrace() // when a macro expansion occurs, the resulting nodes have the backtrace()
// -> expn_info of their expansion context stored into their span. // -> expn_info of their expansion context stored into their span.
pub struct ext_ctxt { pub struct ExtCtxt {
parse_sess: @mut parse::ParseSess, parse_sess: @mut parse::ParseSess,
cfg: ast::crate_cfg, cfg: ast::crate_cfg,
backtrace: @mut Option<@ExpnInfo>, backtrace: @mut Option<@ExpnInfo>,
@ -216,7 +216,17 @@ pub struct ext_ctxt {
trace_mac: @mut bool trace_mac: @mut bool
} }
pub impl ext_ctxt { pub impl ExtCtxt {
fn new(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg) -> @ExtCtxt {
@ExtCtxt {
parse_sess: parse_sess,
cfg: cfg,
backtrace: @mut None,
mod_path: @mut ~[],
trace_mac: @mut false
}
}
fn codemap(&self) -> @CodeMap { self.parse_sess.cm } fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess } fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
fn cfg(&self) -> ast::crate_cfg { copy self.cfg } fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
@ -294,18 +304,7 @@ pub impl ext_ctxt {
} }
} }
pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg) pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::expr, err_msg: ~str) -> ~str {
-> @ext_ctxt {
@ext_ctxt {
parse_sess: parse_sess,
cfg: cfg,
backtrace: @mut None,
mod_path: @mut ~[],
trace_mac: @mut false
}
}
pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
match expr.node { match expr.node {
ast::expr_lit(l) => match l.node { ast::expr_lit(l) => match l.node {
ast::lit_str(s) => copy *s, ast::lit_str(s) => copy *s,
@ -315,7 +314,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: @ExtCtxt,
expr: @ast::expr, expr: @ast::expr,
err_msg: &str) -> ast::ident { err_msg: &str) -> ast::ident {
match expr.node { match expr.node {
@ -329,14 +328,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: @ExtCtxt, sp: span, tts: &[ast::token_tree],
name: &str) { name: &str) {
if tts.len() != 0 { if tts.len() != 0 {
cx.span_fatal(sp, fmt!("%s takes no arguments", name)); 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: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree], tts: &[ast::token_tree],
name: &str) -> ~str { name: &str) -> ~str {
@ -351,7 +350,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: @ExtCtxt, tts: &[ast::token_tree])
-> ~[@ast::expr] { -> ~[@ast::expr] {
let p = parse::new_parser_from_tts(cx.parse_sess(), let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(), cx.cfg(),

View file

@ -12,7 +12,7 @@ use ast;
use codemap; use codemap;
use codemap::span; use codemap::span;
use fold; use fold;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use opt_vec::OptVec; use opt_vec::OptVec;
@ -22,7 +22,7 @@ pub struct Field {
ex: @ast::expr ex: @ast::expr
} }
pub fn mk_expr(cx: @ext_ctxt, pub fn mk_expr(cx: @ExtCtxt,
sp: codemap::span, sp: codemap::span,
expr: ast::expr_) expr: ast::expr_)
-> @ast::expr { -> @ast::expr {
@ -34,32 +34,32 @@ 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: @ExtCtxt, sp: span, lit: ast::lit_) -> @ast::expr {
let sp_lit = @codemap::spanned { node: lit, span: sp }; let sp_lit = @codemap::spanned { node: lit, span: sp };
mk_expr(cx, sp, ast::expr_lit(sp_lit)) 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: @ExtCtxt, sp: span, i: int) -> @ast::expr {
let lit = ast::lit_int(i as i64, ast::ty_i); let lit = ast::lit_int(i as i64, ast::ty_i);
return mk_lit(cx, sp, lit); return mk_lit(cx, sp, lit);
} }
pub fn mk_uint(cx: @ext_ctxt, sp: span, u: uint) -> @ast::expr { pub fn mk_uint(cx: @ExtCtxt, sp: span, u: uint) -> @ast::expr {
let lit = ast::lit_uint(u as u64, ast::ty_u); let lit = ast::lit_uint(u as u64, ast::ty_u);
return mk_lit(cx, sp, lit); return mk_lit(cx, sp, lit);
} }
pub fn mk_u8(cx: @ext_ctxt, sp: span, u: u8) -> @ast::expr { pub fn mk_u8(cx: @ExtCtxt, sp: span, u: u8) -> @ast::expr {
let lit = ast::lit_uint(u as u64, ast::ty_u8); let lit = ast::lit_uint(u as u64, ast::ty_u8);
return mk_lit(cx, sp, lit); return mk_lit(cx, sp, lit);
} }
pub fn mk_binary(cx: @ext_ctxt, sp: span, op: ast::binop, pub fn mk_binary(cx: @ExtCtxt, sp: span, op: ast::binop,
lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr { lhs: @ast::expr, rhs: @ast::expr) -> @ast::expr {
cx.next_id(); // see ast_util::op_expr_callee_id cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_binary(op, lhs, rhs)) mk_expr(cx, sp, ast::expr_binary(op, lhs, rhs))
} }
pub fn mk_deref(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { pub fn mk_deref(cx: @ExtCtxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_unary(cx, sp, ast::deref, e) mk_unary(cx, sp, ast::deref, e)
} }
pub fn mk_unary(cx: @ext_ctxt, sp: span, op: ast::unop, e: @ast::expr) pub fn mk_unary(cx: @ExtCtxt, sp: span, op: ast::unop, e: @ast::expr)
-> @ast::expr { -> @ast::expr {
cx.next_id(); // see ast_util::op_expr_callee_id cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_unary(op, e)) mk_expr(cx, sp, ast::expr_unary(op, e))
@ -91,78 +91,78 @@ pub fn mk_raw_path_global_(sp: span,
rp: rp, rp: rp,
types: types } types: types }
} }
pub fn mk_path_raw(cx: @ext_ctxt, sp: span, path: @ast::Path)-> @ast::expr { pub fn mk_path_raw(cx: @ExtCtxt, sp: span, path: @ast::Path)-> @ast::expr {
mk_expr(cx, sp, ast::expr_path(path)) mk_expr(cx, sp, ast::expr_path(path))
} }
pub fn mk_path(cx: @ext_ctxt, sp: span, idents: ~[ast::ident]) pub fn mk_path(cx: @ExtCtxt, sp: span, idents: ~[ast::ident])
-> @ast::expr { -> @ast::expr {
mk_path_raw(cx, sp, mk_raw_path(sp, idents)) mk_path_raw(cx, sp, mk_raw_path(sp, idents))
} }
pub fn mk_path_global(cx: @ext_ctxt, sp: span, idents: ~[ast::ident]) pub fn mk_path_global(cx: @ExtCtxt, sp: span, idents: ~[ast::ident])
-> @ast::expr { -> @ast::expr {
mk_path_raw(cx, sp, mk_raw_path_global(sp, idents)) mk_path_raw(cx, sp, 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: @ExtCtxt, sp: span, p: @ast::expr, m: ast::ident)
-> @ast::expr { -> @ast::expr {
mk_expr(cx, sp, ast::expr_field(p, m, ~[])) 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: @ExtCtxt, sp: span, p: ~[ast::ident], m: ast::ident)
-> @ast::expr { -> @ast::expr {
let pathexpr = mk_path(cx, sp, p); let pathexpr = mk_path(cx, sp, p);
return mk_access_(cx, sp, pathexpr, m); 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: @ExtCtxt, sp: span, e: @ast::expr) -> @ast::expr {
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e)); return mk_expr(cx, sp, ast::expr_addr_of(ast::m_imm, e));
} }
pub fn mk_mut_addr_of(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { pub fn mk_mut_addr_of(cx: @ExtCtxt, sp: span, e: @ast::expr) -> @ast::expr {
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_mutbl, e)); return mk_expr(cx, sp, ast::expr_addr_of(ast::m_mutbl, e));
} }
pub fn mk_method_call(cx: @ext_ctxt, pub fn mk_method_call(cx: @ExtCtxt,
sp: span, sp: span,
rcvr_expr: @ast::expr, rcvr_expr: @ast::expr,
method_ident: ast::ident, method_ident: ast::ident,
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_method_call(rcvr_expr, method_ident, ~[], args, ast::NoSugar)) mk_expr(cx, sp, ast::expr_method_call(rcvr_expr, method_ident, ~[], args, ast::NoSugar))
} }
pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr, pub fn mk_call_(cx: @ExtCtxt, sp: span, fn_expr: @ast::expr,
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar)) 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: @ExtCtxt, sp: span, fn_path: ~[ast::ident],
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path(cx, sp, fn_path); let pathexpr = mk_path(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args); 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: @ExtCtxt, sp: span, fn_path: ~[ast::ident],
args: ~[@ast::expr]) -> @ast::expr { args: ~[@ast::expr]) -> @ast::expr {
let pathexpr = mk_path_global(cx, sp, fn_path); let pathexpr = mk_path_global(cx, sp, fn_path);
return mk_call_(cx, sp, pathexpr, args); return mk_call_(cx, sp, pathexpr, args);
} }
// e = expr, t = type // 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: @ExtCtxt, sp: span, exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
let vecexpr = ast::expr_vec(exprs, ast::m_imm); let vecexpr = ast::expr_vec(exprs, ast::m_imm);
mk_expr(cx, sp, vecexpr) mk_expr(cx, sp, vecexpr)
} }
pub fn mk_vstore_e(cx: @ext_ctxt, sp: span, expr: @ast::expr, pub fn mk_vstore_e(cx: @ExtCtxt, sp: span, expr: @ast::expr,
vst: ast::expr_vstore) -> vst: ast::expr_vstore) ->
@ast::expr { @ast::expr {
mk_expr(cx, sp, ast::expr_vstore(expr, vst)) 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: @ExtCtxt, sp: span, exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::expr_vstore_uniq) 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: @ExtCtxt, sp: span, exprs: ~[@ast::expr])
-> @ast::expr { -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs),
ast::expr_vstore_slice) ast::expr_vstore_slice)
} }
pub fn mk_base_str(cx: @ext_ctxt, sp: span, s: ~str) -> @ast::expr { pub fn mk_base_str(cx: @ExtCtxt, sp: span, s: ~str) -> @ast::expr {
let lit = ast::lit_str(@s); let lit = ast::lit_str(@s);
return mk_lit(cx, sp, lit); 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: @ExtCtxt, sp: span, s: ~str) -> @ast::expr {
mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::expr_vstore_uniq) 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 { pub fn mk_field(sp: span, f: &Field) -> ast::field {
@ -174,7 +174,7 @@ pub fn mk_field(sp: span, f: &Field) -> ast::field {
pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] { pub fn mk_fields(sp: span, fields: ~[Field]) -> ~[ast::field] {
fields.map(|f| mk_field(sp, f)) fields.map(|f| mk_field(sp, f))
} }
pub fn mk_struct_e(cx: @ext_ctxt, pub fn mk_struct_e(cx: @ExtCtxt,
sp: span, sp: span,
ctor_path: ~[ast::ident], ctor_path: ~[ast::ident],
fields: ~[Field]) fields: ~[Field])
@ -184,7 +184,7 @@ pub fn mk_struct_e(cx: @ext_ctxt,
mk_fields(sp, fields), mk_fields(sp, fields),
option::None::<@ast::expr>)) option::None::<@ast::expr>))
} }
pub fn mk_global_struct_e(cx: @ext_ctxt, pub fn mk_global_struct_e(cx: @ExtCtxt,
sp: span, sp: span,
ctor_path: ~[ast::ident], ctor_path: ~[ast::ident],
fields: ~[Field]) fields: ~[Field])
@ -194,7 +194,7 @@ pub fn mk_global_struct_e(cx: @ext_ctxt,
mk_fields(sp, fields), mk_fields(sp, fields),
option::None::<@ast::expr>)) option::None::<@ast::expr>))
} }
pub fn mk_glob_use(cx: @ext_ctxt, pub fn mk_glob_use(cx: @ExtCtxt,
sp: span, sp: span,
vis: ast::visibility, vis: ast::visibility,
path: ~[ast::ident]) -> @ast::view_item { path: ~[ast::ident]) -> @ast::view_item {
@ -207,7 +207,7 @@ pub fn mk_glob_use(cx: @ext_ctxt,
vis: vis, vis: vis,
span: sp } span: sp }
} }
pub fn mk_local(cx: @ext_ctxt, sp: span, mutbl: bool, pub fn mk_local(cx: @ExtCtxt, sp: span, mutbl: bool,
ident: ast::ident, ex: @ast::expr) -> @ast::stmt { ident: ast::ident, ex: @ast::expr) -> @ast::stmt {
let pat = @ast::pat { let pat = @ast::pat {
@ -232,7 +232,7 @@ pub fn mk_local(cx: @ext_ctxt, sp: span, mutbl: bool,
let decl = codemap::spanned {node: ast::decl_local(~[local]), span: sp}; let decl = codemap::spanned {node: ast::decl_local(~[local]), span: sp};
@codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), 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: @ExtCtxt, span: span,
view_items: ~[@ast::view_item], view_items: ~[@ast::view_item],
stmts: ~[@ast::stmt], stmts: ~[@ast::stmt],
expr: Option<@ast::expr>) -> @ast::expr { expr: Option<@ast::expr>) -> @ast::expr {
@ -248,7 +248,7 @@ pub fn mk_block(cx: @ext_ctxt, span: span,
}; };
mk_expr(cx, span, ast::expr_block(blk)) mk_expr(cx, span, ast::expr_block(blk))
} }
pub fn mk_block_(cx: @ext_ctxt, pub fn mk_block_(cx: @ExtCtxt,
span: span, span: span,
stmts: ~[@ast::stmt]) stmts: ~[@ast::stmt])
-> ast::blk { -> ast::blk {
@ -263,7 +263,7 @@ pub fn mk_block_(cx: @ext_ctxt,
span: span, span: span,
} }
} }
pub fn mk_simple_block(cx: @ext_ctxt, pub fn mk_simple_block(cx: @ExtCtxt,
span: span, span: span,
expr: @ast::expr) expr: @ast::expr)
-> ast::blk { -> ast::blk {
@ -278,14 +278,14 @@ pub fn mk_simple_block(cx: @ext_ctxt,
span: span, span: span,
} }
} }
pub fn mk_lambda_(cx: @ext_ctxt, pub fn mk_lambda_(cx: @ExtCtxt,
span: span, span: span,
fn_decl: ast::fn_decl, fn_decl: ast::fn_decl,
blk: ast::blk) blk: ast::blk)
-> @ast::expr { -> @ast::expr {
mk_expr(cx, span, ast::expr_fn_block(fn_decl, blk)) mk_expr(cx, span, ast::expr_fn_block(fn_decl, blk))
} }
pub fn mk_lambda(cx: @ext_ctxt, pub fn mk_lambda(cx: @ExtCtxt,
span: span, span: span,
fn_decl: ast::fn_decl, fn_decl: ast::fn_decl,
expr: @ast::expr) expr: @ast::expr)
@ -293,7 +293,7 @@ pub fn mk_lambda(cx: @ext_ctxt,
let blk = mk_simple_block(cx, span, expr); let blk = mk_simple_block(cx, span, expr);
mk_lambda_(cx, span, fn_decl, blk) mk_lambda_(cx, span, fn_decl, blk)
} }
pub fn mk_lambda_stmts(cx: @ext_ctxt, pub fn mk_lambda_stmts(cx: @ExtCtxt,
span: span, span: span,
fn_decl: ast::fn_decl, fn_decl: ast::fn_decl,
stmts: ~[@ast::stmt]) stmts: ~[@ast::stmt])
@ -301,37 +301,37 @@ pub fn mk_lambda_stmts(cx: @ext_ctxt,
let blk = mk_block(cx, span, ~[], stmts, None); let blk = mk_block(cx, span, ~[], stmts, None);
mk_lambda(cx, span, fn_decl, blk) mk_lambda(cx, span, fn_decl, blk)
} }
pub fn mk_lambda_no_args(cx: @ext_ctxt, pub fn mk_lambda_no_args(cx: @ExtCtxt,
span: span, span: span,
expr: @ast::expr) expr: @ast::expr)
-> @ast::expr { -> @ast::expr {
let fn_decl = mk_fn_decl(~[], mk_ty_infer(cx, span)); let fn_decl = mk_fn_decl(~[], mk_ty_infer(cx, span));
mk_lambda(cx, span, fn_decl, expr) mk_lambda(cx, span, fn_decl, expr)
} }
pub fn mk_copy(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr { pub fn mk_copy(cx: @ExtCtxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_copy(e)) 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: @ExtCtxt, sp: span, e: @ast::expr) -> @ast::expr {
mk_expr(cx, sp, ast::expr_unary(ast::box(ast::m_imm), e)) 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: @ExtCtxt, span: span, pat: ast::pat_) -> @ast::pat {
@ast::pat { id: cx.next_id(), node: pat, span: span } @ast::pat { id: cx.next_id(), node: pat, span: span }
} }
pub fn mk_pat_wild(cx: @ext_ctxt, span: span) -> @ast::pat { pub fn mk_pat_wild(cx: @ExtCtxt, span: span) -> @ast::pat {
mk_pat(cx, span, ast::pat_wild) mk_pat(cx, span, ast::pat_wild)
} }
pub fn mk_pat_lit(cx: @ext_ctxt, pub fn mk_pat_lit(cx: @ExtCtxt,
span: span, span: span,
expr: @ast::expr) -> @ast::pat { expr: @ast::expr) -> @ast::pat {
mk_pat(cx, span, ast::pat_lit(expr)) mk_pat(cx, span, ast::pat_lit(expr))
} }
pub fn mk_pat_ident(cx: @ext_ctxt, pub fn mk_pat_ident(cx: @ExtCtxt,
span: span, span: span,
ident: ast::ident) -> @ast::pat { ident: ast::ident) -> @ast::pat {
mk_pat_ident_with_binding_mode(cx, span, ident, ast::bind_by_copy) 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: @ExtCtxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
bm: ast::binding_mode) -> @ast::pat { bm: ast::binding_mode) -> @ast::pat {
@ -339,7 +339,7 @@ pub fn mk_pat_ident_with_binding_mode(cx: @ext_ctxt,
let pat = ast::pat_ident(bm, path, None); let pat = ast::pat_ident(bm, path, None);
mk_pat(cx, span, pat) mk_pat(cx, span, pat)
} }
pub fn mk_pat_enum(cx: @ext_ctxt, pub fn mk_pat_enum(cx: @ExtCtxt,
span: span, span: span,
path: @ast::Path, path: @ast::Path,
subpats: ~[@ast::pat]) subpats: ~[@ast::pat])
@ -347,7 +347,7 @@ pub fn mk_pat_enum(cx: @ext_ctxt,
let pat = ast::pat_enum(path, Some(subpats)); let pat = ast::pat_enum(path, Some(subpats));
mk_pat(cx, span, pat) mk_pat(cx, span, pat)
} }
pub fn mk_pat_struct(cx: @ext_ctxt, pub fn mk_pat_struct(cx: @ExtCtxt,
span: span, span: span,
path: @ast::Path, path: @ast::Path,
field_pats: ~[ast::field_pat]) field_pats: ~[ast::field_pat])
@ -355,13 +355,13 @@ pub fn mk_pat_struct(cx: @ext_ctxt,
let pat = ast::pat_struct(path, field_pats, false); let pat = ast::pat_struct(path, field_pats, false);
mk_pat(cx, span, pat) mk_pat(cx, span, pat)
} }
pub fn mk_bool(cx: @ext_ctxt, span: span, value: bool) -> @ast::expr { pub fn mk_bool(cx: @ExtCtxt, span: span, value: bool) -> @ast::expr {
let lit_expr = ast::expr_lit(@codemap::spanned { let lit_expr = ast::expr_lit(@codemap::spanned {
node: ast::lit_bool(value), node: ast::lit_bool(value),
span: span }); span: span });
build::mk_expr(cx, span, lit_expr) 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: @ExtCtxt, span: span, expr: @ast::expr) -> @ast::stmt {
let stmt_ = ast::stmt_semi(expr, cx.next_id()); let stmt_ = ast::stmt_semi(expr, cx.next_id());
@codemap::spanned { node: stmt_, span: span } @codemap::spanned { node: stmt_, span: span }
} }
@ -373,7 +373,7 @@ pub fn mk_ty_mt(ty: @ast::Ty, mutbl: ast::mutability) -> ast::mt {
} }
} }
pub fn mk_ty(cx: @ext_ctxt, pub fn mk_ty(cx: @ExtCtxt,
span: span, span: span,
ty: ast::ty_) -> @ast::Ty { ty: ast::ty_) -> @ast::Ty {
@ast::Ty { @ast::Ty {
@ -383,7 +383,7 @@ pub fn mk_ty(cx: @ext_ctxt,
} }
} }
pub fn mk_ty_path(cx: @ext_ctxt, pub fn mk_ty_path(cx: @ExtCtxt,
span: span, span: span,
idents: ~[ ast::ident ]) idents: ~[ ast::ident ])
-> @ast::Ty { -> @ast::Ty {
@ -391,7 +391,7 @@ pub fn mk_ty_path(cx: @ext_ctxt,
mk_ty_path_path(cx, span, ty) mk_ty_path_path(cx, span, ty)
} }
pub fn mk_ty_path_global(cx: @ext_ctxt, pub fn mk_ty_path_global(cx: @ExtCtxt,
span: span, span: span,
idents: ~[ ast::ident ]) idents: ~[ ast::ident ])
-> @ast::Ty { -> @ast::Ty {
@ -399,7 +399,7 @@ pub fn mk_ty_path_global(cx: @ext_ctxt,
mk_ty_path_path(cx, span, ty) mk_ty_path_path(cx, span, ty)
} }
pub fn mk_ty_path_path(cx: @ext_ctxt, pub fn mk_ty_path_path(cx: @ExtCtxt,
span: span, span: span,
path: @ast::Path) path: @ast::Path)
-> @ast::Ty { -> @ast::Ty {
@ -407,7 +407,7 @@ pub fn mk_ty_path_path(cx: @ext_ctxt,
mk_ty(cx, span, ty) mk_ty(cx, span, ty)
} }
pub fn mk_ty_rptr(cx: @ext_ctxt, pub fn mk_ty_rptr(cx: @ExtCtxt,
span: span, span: span,
ty: @ast::Ty, ty: @ast::Ty,
lifetime: Option<@ast::Lifetime>, lifetime: Option<@ast::Lifetime>,
@ -416,39 +416,39 @@ pub fn mk_ty_rptr(cx: @ext_ctxt,
mk_ty(cx, span, mk_ty(cx, span,
ast::ty_rptr(lifetime, mk_ty_mt(ty, mutbl))) ast::ty_rptr(lifetime, mk_ty_mt(ty, mutbl)))
} }
pub fn mk_ty_uniq(cx: @ext_ctxt, span: span, ty: @ast::Ty) -> @ast::Ty { pub fn mk_ty_uniq(cx: @ExtCtxt, span: span, ty: @ast::Ty) -> @ast::Ty {
mk_ty(cx, span, ast::ty_uniq(mk_ty_mt(ty, ast::m_imm))) mk_ty(cx, span, ast::ty_uniq(mk_ty_mt(ty, ast::m_imm)))
} }
pub fn mk_ty_box(cx: @ext_ctxt, span: span, pub fn mk_ty_box(cx: @ExtCtxt, span: span,
ty: @ast::Ty, mutbl: ast::mutability) -> @ast::Ty { ty: @ast::Ty, mutbl: ast::mutability) -> @ast::Ty {
mk_ty(cx, span, ast::ty_box(mk_ty_mt(ty, mutbl))) mk_ty(cx, span, ast::ty_box(mk_ty_mt(ty, mutbl)))
} }
pub fn mk_ty_infer(cx: @ext_ctxt, span: span) -> @ast::Ty { pub fn mk_ty_infer(cx: @ExtCtxt, span: span) -> @ast::Ty {
mk_ty(cx, span, ast::ty_infer) mk_ty(cx, span, ast::ty_infer)
} }
pub fn mk_trait_ref_global(cx: @ext_ctxt, pub fn mk_trait_ref_global(cx: @ExtCtxt,
span: span, span: span,
idents: ~[ ast::ident ]) idents: ~[ ast::ident ])
-> @ast::trait_ref -> @ast::trait_ref
{ {
mk_trait_ref_(cx, build::mk_raw_path_global(span, idents)) mk_trait_ref_(cx, build::mk_raw_path_global(span, idents))
} }
pub fn mk_trait_ref_(cx: @ext_ctxt, path: @ast::Path) -> @ast::trait_ref { pub fn mk_trait_ref_(cx: @ExtCtxt, path: @ast::Path) -> @ast::trait_ref {
@ast::trait_ref { @ast::trait_ref {
path: path, path: path,
ref_id: cx.next_id() ref_id: cx.next_id()
} }
} }
pub fn mk_simple_ty_path(cx: @ext_ctxt, pub fn mk_simple_ty_path(cx: @ExtCtxt,
span: span, span: span,
ident: ast::ident) ident: ast::ident)
-> @ast::Ty { -> @ast::Ty {
mk_ty_path(cx, span, ~[ ident ]) mk_ty_path(cx, span, ~[ ident ])
} }
pub fn mk_arg(cx: @ext_ctxt, pub fn mk_arg(cx: @ExtCtxt,
span: span, span: span,
ident: ast::ident, ident: ast::ident,
ty: @ast::Ty) ty: @ast::Ty)
@ -464,29 +464,29 @@ pub fn mk_arg(cx: @ext_ctxt,
pub fn mk_fn_decl(inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl { 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 } ast::fn_decl { inputs: inputs, output: output, cf: ast::return_val }
} }
pub fn mk_trait_ty_param_bound_global(cx: @ext_ctxt, pub fn mk_trait_ty_param_bound_global(cx: @ExtCtxt,
span: span, span: span,
idents: ~[ast::ident]) idents: ~[ast::ident])
-> ast::TyParamBound { -> ast::TyParamBound {
ast::TraitTyParamBound(mk_trait_ref_global(cx, span, idents)) ast::TraitTyParamBound(mk_trait_ref_global(cx, span, idents))
} }
pub fn mk_trait_ty_param_bound_(cx: @ext_ctxt, pub fn mk_trait_ty_param_bound_(cx: @ExtCtxt,
path: @ast::Path) -> ast::TyParamBound { path: @ast::Path) -> ast::TyParamBound {
ast::TraitTyParamBound(mk_trait_ref_(cx, path)) ast::TraitTyParamBound(mk_trait_ref_(cx, path))
} }
pub fn mk_ty_param(cx: @ext_ctxt, pub fn mk_ty_param(cx: @ExtCtxt,
ident: ast::ident, ident: ast::ident,
bounds: @OptVec<ast::TyParamBound>) bounds: @OptVec<ast::TyParamBound>)
-> ast::TyParam { -> ast::TyParam {
ast::TyParam { ident: ident, id: cx.next_id(), bounds: bounds } ast::TyParam { ident: ident, id: cx.next_id(), bounds: bounds }
} }
pub fn mk_lifetime(cx: @ext_ctxt, pub fn mk_lifetime(cx: @ExtCtxt,
span: span, span: span,
ident: ast::ident) ident: ast::ident)
-> ast::Lifetime { -> ast::Lifetime {
ast::Lifetime { id: cx.next_id(), span: span, ident: ident } ast::Lifetime { id: cx.next_id(), span: span, ident: ident }
} }
pub fn mk_arm(cx: @ext_ctxt, pub fn mk_arm(cx: @ExtCtxt,
span: span, span: span,
pats: ~[@ast::pat], pats: ~[@ast::pat],
expr: @ast::expr) expr: @ast::expr)
@ -497,7 +497,7 @@ pub fn mk_arm(cx: @ext_ctxt,
body: mk_simple_block(cx, span, expr) body: mk_simple_block(cx, span, expr)
} }
} }
pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr { pub fn mk_unreachable(cx: @ExtCtxt, span: span) -> @ast::expr {
let loc = cx.codemap().lookup_char_pos(span.lo); let loc = cx.codemap().lookup_char_pos(span.lo);
mk_call_global( mk_call_global(
cx, cx,
@ -515,11 +515,11 @@ pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr {
] ]
) )
} }
pub fn mk_unreachable_arm(cx: @ext_ctxt, span: span) -> ast::arm { pub fn mk_unreachable_arm(cx: @ExtCtxt, span: span) -> ast::arm {
mk_arm(cx, span, ~[mk_pat_wild(cx, span)], mk_unreachable(cx, span)) mk_arm(cx, span, ~[mk_pat_wild(cx, span)], mk_unreachable(cx, span))
} }
pub fn make_self(cx: @ext_ctxt, span: span) -> @ast::expr { pub fn make_self(cx: @ExtCtxt, span: span) -> @ast::expr {
build::mk_expr(cx, span, ast::expr_self) build::mk_expr(cx, span, ast::expr_self)
} }
@ -529,7 +529,7 @@ pub fn make_self(cx: @ext_ctxt, span: span) -> @ast::expr {
// These functions just duplicate AST nodes. // These functions just duplicate AST nodes.
// //
pub fn duplicate_expr(cx: @ext_ctxt, expr: @ast::expr) -> @ast::expr { pub fn duplicate_expr(cx: @ExtCtxt, expr: @ast::expr) -> @ast::expr {
let folder = fold::default_ast_fold(); let folder = fold::default_ast_fold();
let folder = @fold::AstFoldFns { let folder = @fold::AstFoldFns {
new_id: |_| cx.next_id(), new_id: |_| cx.next_id(),
@ -599,7 +599,7 @@ trait ExtCtxtMethods {
-> @ast::expr; -> @ast::expr;
} }
impl ExtCtxtMethods for @ext_ctxt { impl ExtCtxtMethods for @ExtCtxt {
fn bind_path( fn bind_path(
&self, &self,
_span: span, _span: span,

View file

@ -16,7 +16,7 @@ use ext::base::*;
use ext::base; use ext::base;
use ext::build::{mk_u8, mk_slice_vec_e}; use ext::build::{mk_u8, mk_slice_vec_e};
pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult {
// Gather all argument expressions // Gather all argument expressions
let exprs = get_exprs_from_tts(cx, tts); let exprs = get_exprs_from_tts(cx, tts);
let mut bytes = ~[]; let mut bytes = ~[];

View file

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

View file

@ -10,12 +10,12 @@
use ast::{meta_item, item, expr}; use ast::{meta_item, item, expr};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_clone(cx: @ext_ctxt, pub fn expand_deriving_clone(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) in_items: ~[@item])
@ -42,7 +42,7 @@ pub fn expand_deriving_clone(cx: @ext_ctxt,
&trait_def) &trait_def)
} }
pub fn expand_deriving_deep_clone(cx: @ext_ctxt, pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) in_items: ~[@item])
@ -73,7 +73,7 @@ pub fn expand_deriving_deep_clone(cx: @ext_ctxt,
fn cs_clone( fn cs_clone(
name: &str, name: &str,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let clone_ident = substr.method_ident; let clone_ident = substr.method_ident;
let ctor_ident; let ctor_ident;

View file

@ -10,21 +10,21 @@
use ast::{meta_item, item, expr}; use ast::{meta_item, item, expr};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_eq(cx: @ext_ctxt, pub fn expand_deriving_eq(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
// structures are equal if all fields are equal, and non equal, if // structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different // any fields are not equal or if the enum variants are different
fn cs_eq(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { fn cs_eq(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cs_and(|cx, span, _, _| build::mk_bool(cx, span, false), cs_and(|cx, span, _, _| build::mk_bool(cx, span, false),
cx, span, substr) cx, span, substr)
} }
fn cs_ne(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { fn cs_ne(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cs_or(|cx, span, _, _| build::mk_bool(cx, span, true), cs_or(|cx, span, _, _| build::mk_bool(cx, span, true),
cx, span, substr) cx, span, substr)
} }

View file

@ -11,11 +11,11 @@
use ast::{meta_item, item, expr_if, expr}; use ast::{meta_item, item, expr_if, expr};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_ord(cx: @ext_ctxt, pub fn expand_deriving_ord(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
@ -55,7 +55,7 @@ pub fn expand_deriving_ord(cx: @ext_ctxt,
/// `less`: is this `lt` or `le`? `equal`: is this `le` or `ge`? /// `less`: is this `lt` or `le`? `equal`: is this `le` or `ge`?
fn cs_ord(less: bool, equal: bool, fn cs_ord(less: bool, equal: bool,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
let binop = if less { let binop = if less {
cx.ident_of("lt") cx.ident_of("lt")

View file

@ -11,16 +11,16 @@
use ast::{meta_item, item, expr}; use ast::{meta_item, item, expr};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_totaleq(cx: @ext_ctxt, pub fn expand_deriving_totaleq(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
fn cs_equals(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { fn cs_equals(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cs_and(|cx, span, _, _| build::mk_bool(cx, span, false), cs_and(|cx, span, _, _| build::mk_bool(cx, span, false),
cx, span, substr) cx, span, substr)
} }

View file

@ -10,12 +10,12 @@
use ast::{meta_item, item, expr}; use ast::{meta_item, item, expr};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
use core::cmp::{Ordering, Equal, Less, Greater}; use core::cmp::{Ordering, Equal, Less, Greater};
pub fn expand_deriving_totalord(cx: @ext_ctxt, pub fn expand_deriving_totalord(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
@ -41,7 +41,7 @@ pub fn expand_deriving_totalord(cx: @ext_ctxt,
} }
pub fn ordering_const(cx: @ext_ctxt, span: span, cnst: Ordering) -> @expr { pub fn ordering_const(cx: @ExtCtxt, span: span, cnst: Ordering) -> @expr {
let cnst = match cnst { let cnst = match cnst {
Less => "Less", Less => "Less",
Equal => "Equal", Equal => "Equal",
@ -53,7 +53,7 @@ pub fn ordering_const(cx: @ext_ctxt, span: span, cnst: Ordering) -> @expr {
cx.ident_of(cnst)]) cx.ident_of(cnst)])
} }
pub fn cs_cmp(cx: @ext_ctxt, span: span, pub fn cs_cmp(cx: @ExtCtxt, span: span,
substr: &Substructure) -> @expr { substr: &Substructure) -> @expr {
cs_same_method_fold( cs_same_method_fold(

View file

@ -15,7 +15,7 @@ encodable.rs for more.
use ast; use ast;
use ast::*; use ast::*;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::*; use ext::deriving::*;
use codemap::{span, spanned}; use codemap::{span, spanned};
@ -23,7 +23,7 @@ use ast_util;
use opt_vec; use opt_vec;
pub fn expand_deriving_decodable( pub fn expand_deriving_decodable(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
_mitem: @meta_item, _mitem: @meta_item,
in_items: ~[@item] in_items: ~[@item]
@ -38,7 +38,7 @@ pub fn expand_deriving_decodable(
} }
fn create_derived_decodable_impl( fn create_derived_decodable_impl(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
type_ident: ident, type_ident: ident,
generics: &Generics, generics: &Generics,
@ -91,7 +91,7 @@ fn create_derived_decodable_impl(
// Creates a method from the given set of statements conforming to the // Creates a method from the given set of statements conforming to the
// signature of the `decodable` method. // signature of the `decodable` method.
fn create_decode_method( fn create_decode_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
type_ident: ast::ident, type_ident: ast::ident,
generics: &Generics, generics: &Generics,
@ -142,7 +142,7 @@ fn create_decode_method(
} }
fn call_substructure_decode_method( fn call_substructure_decode_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span span: span
) -> @ast::expr { ) -> @ast::expr {
// Call the substructure method. // Call the substructure method.
@ -166,7 +166,7 @@ fn call_substructure_decode_method(
} }
fn expand_deriving_decodable_struct_def( fn expand_deriving_decodable_struct_def(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
@ -192,7 +192,7 @@ fn expand_deriving_decodable_struct_def(
} }
fn expand_deriving_decodable_enum_def( fn expand_deriving_decodable_enum_def(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
enum_definition: &enum_def, enum_definition: &enum_def,
type_ident: ident, type_ident: ident,
@ -218,7 +218,7 @@ fn expand_deriving_decodable_enum_def(
} }
fn create_read_struct_field( fn create_read_struct_field(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
idx: uint, idx: uint,
ident: ident ident: ident
@ -251,7 +251,7 @@ fn create_read_struct_field(
} }
fn create_read_struct_arg( fn create_read_struct_arg(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
idx: uint, idx: uint,
ident: ident ident: ident
@ -274,7 +274,7 @@ fn create_read_struct_arg(
} }
fn expand_deriving_decodable_struct_method( fn expand_deriving_decodable_struct_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
@ -334,7 +334,7 @@ fn expand_deriving_decodable_struct_method(
} }
fn create_read_variant_arg( fn create_read_variant_arg(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
idx: uint, idx: uint,
variant: &ast::variant variant: &ast::variant
@ -392,7 +392,7 @@ fn create_read_variant_arg(
} }
fn create_read_enum_variant( fn create_read_enum_variant(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
enum_definition: &enum_def enum_definition: &enum_def
) -> @expr { ) -> @expr {
@ -459,7 +459,7 @@ fn create_read_enum_variant(
} }
fn expand_deriving_decodable_enum_method( fn expand_deriving_decodable_enum_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
enum_definition: &enum_def, enum_definition: &enum_def,
type_ident: ast::ident, type_ident: ast::ident,

View file

@ -78,7 +78,7 @@ would yield functions like:
use ast; use ast;
use ast::*; use ast::*;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::*; use ext::deriving::*;
use codemap::{span, spanned}; use codemap::{span, spanned};
@ -86,7 +86,7 @@ use ast_util;
use opt_vec; use opt_vec;
pub fn expand_deriving_encodable( pub fn expand_deriving_encodable(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
_mitem: @meta_item, _mitem: @meta_item,
in_items: ~[@item] in_items: ~[@item]
@ -101,7 +101,7 @@ pub fn expand_deriving_encodable(
} }
fn create_derived_encodable_impl( fn create_derived_encodable_impl(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
type_ident: ident, type_ident: ident,
generics: &Generics, generics: &Generics,
@ -154,7 +154,7 @@ fn create_derived_encodable_impl(
// Creates a method from the given set of statements conforming to the // Creates a method from the given set of statements conforming to the
// signature of the `encodable` method. // signature of the `encodable` method.
fn create_encode_method( fn create_encode_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
statements: ~[@stmt] statements: ~[@stmt]
) -> @method { ) -> @method {
@ -197,7 +197,7 @@ fn create_encode_method(
} }
fn call_substructure_encode_method( fn call_substructure_encode_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
self_field: @expr self_field: @expr
) -> @ast::expr { ) -> @ast::expr {
@ -217,7 +217,7 @@ fn call_substructure_encode_method(
} }
fn expand_deriving_encodable_struct_def( fn expand_deriving_encodable_struct_def(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
@ -242,7 +242,7 @@ fn expand_deriving_encodable_struct_def(
} }
fn expand_deriving_encodable_enum_def( fn expand_deriving_encodable_enum_def(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
enum_definition: &enum_def, enum_definition: &enum_def,
type_ident: ident, type_ident: ident,
@ -267,7 +267,7 @@ fn expand_deriving_encodable_enum_def(
} }
fn expand_deriving_encodable_struct_method( fn expand_deriving_encodable_struct_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
type_ident: ident, type_ident: ident,
struct_def: &struct_def struct_def: &struct_def
@ -361,7 +361,7 @@ fn expand_deriving_encodable_struct_method(
} }
fn expand_deriving_encodable_enum_method( fn expand_deriving_encodable_enum_method(
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
type_ident: ast::ident, type_ident: ast::ident,
enum_definition: &enum_def enum_definition: &enum_def

View file

@ -165,7 +165,7 @@ StaticEnum(<ast::enum_def of C>, ~[(<ident of C0>, Left(1)),
use ast; use ast;
use ast::{enum_def, expr, ident, Generics, struct_def}; use ast::{enum_def, expr, ident, Generics, struct_def};
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::*; use ext::deriving::*;
use codemap::{span,respan}; use codemap::{span,respan};
@ -174,7 +174,7 @@ use opt_vec;
pub use self::ty::*; pub use self::ty::*;
mod ty; mod ty;
pub fn expand_deriving_generic(cx: @ext_ctxt, pub fn expand_deriving_generic(cx: @ExtCtxt,
span: span, span: span,
_mitem: @ast::meta_item, _mitem: @ast::meta_item,
in_items: ~[@ast::item], in_items: ~[@ast::item],
@ -281,7 +281,7 @@ Combine the values of all the fields together. The last argument is
all the fields of all the structures, see above for details. all the fields of all the structures, see above for details.
*/ */
pub type CombineSubstructureFunc<'self> = pub type CombineSubstructureFunc<'self> =
&'self fn(@ext_ctxt, span, &Substructure) -> @expr; &'self fn(@ExtCtxt, span, &Substructure) -> @expr;
/** /**
Deal with non-matching enum variants, the arguments are a list Deal with non-matching enum variants, the arguments are a list
@ -289,14 +289,14 @@ representing each variant: (variant index, ast::variant instance,
[variant fields]), and a list of the nonself args of the type [variant fields]), and a list of the nonself args of the type
*/ */
pub type EnumNonMatchFunc<'self> = pub type EnumNonMatchFunc<'self> =
&'self fn(@ext_ctxt, span, &'self fn(@ExtCtxt, span,
&[(uint, ast::variant, &[(uint, ast::variant,
~[(Option<ident>, @expr)])], ~[(Option<ident>, @expr)])],
&[@expr]) -> @expr; &[@expr]) -> @expr;
impl<'self> TraitDef<'self> { impl<'self> TraitDef<'self> {
fn create_derived_impl(&self, cx: @ext_ctxt, span: span, fn create_derived_impl(&self, cx: @ExtCtxt, span: span,
type_ident: ident, generics: &Generics, type_ident: ident, generics: &Generics,
methods: ~[@ast::method]) -> @ast::item { methods: ~[@ast::method]) -> @ast::item {
let trait_path = self.path.to_path(cx, span, type_ident, generics); let trait_path = self.path.to_path(cx, span, type_ident, generics);
@ -315,7 +315,7 @@ impl<'self> TraitDef<'self> {
additional_bounds) additional_bounds)
} }
fn expand_struct_def(&self, cx: @ext_ctxt, fn expand_struct_def(&self, cx: @ExtCtxt,
span: span, span: span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
@ -347,7 +347,7 @@ impl<'self> TraitDef<'self> {
} }
fn expand_enum_def(&self, fn expand_enum_def(&self,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
@ -380,7 +380,7 @@ impl<'self> TraitDef<'self> {
impl<'self> MethodDef<'self> { impl<'self> MethodDef<'self> {
fn call_substructure_method(&self, fn call_substructure_method(&self,
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -398,7 +398,7 @@ impl<'self> MethodDef<'self> {
&substructure) &substructure)
} }
fn get_ret_ty(&self, cx: @ext_ctxt, span: span, fn get_ret_ty(&self, cx: @ExtCtxt, span: span,
generics: &Generics, type_ident: ident) -> @ast::Ty { generics: &Generics, type_ident: ident) -> @ast::Ty {
self.ret_ty.to_ty(cx, span, type_ident, generics) self.ret_ty.to_ty(cx, span, type_ident, generics)
} }
@ -407,7 +407,7 @@ impl<'self> MethodDef<'self> {
self.explicit_self.is_none() self.explicit_self.is_none()
} }
fn split_self_nonself_args(&self, cx: @ext_ctxt, span: span, fn split_self_nonself_args(&self, cx: @ExtCtxt, span: span,
type_ident: ident, generics: &Generics) type_ident: ident, generics: &Generics)
-> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, @ast::Ty)]) { -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, @ast::Ty)]) {
@ -451,7 +451,7 @@ impl<'self> MethodDef<'self> {
(ast_explicit_self, self_args, nonself_args, arg_tys) (ast_explicit_self, self_args, nonself_args, arg_tys)
} }
fn create_method(&self, cx: @ext_ctxt, span: span, fn create_method(&self, cx: @ExtCtxt, span: span,
type_ident: ident, type_ident: ident,
generics: &Generics, generics: &Generics,
explicit_self: ast::explicit_self, explicit_self: ast::explicit_self,
@ -509,7 +509,7 @@ impl<'self> MethodDef<'self> {
~~~ ~~~
*/ */
fn expand_struct_method_body(&self, fn expand_struct_method_body(&self,
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
@ -567,7 +567,7 @@ impl<'self> MethodDef<'self> {
} }
fn expand_static_struct_method_body(&self, fn expand_static_struct_method_body(&self,
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
struct_def: &struct_def, struct_def: &struct_def,
type_ident: ident, type_ident: ident,
@ -609,7 +609,7 @@ impl<'self> MethodDef<'self> {
~~~ ~~~
*/ */
fn expand_enum_method_body(&self, fn expand_enum_method_body(&self,
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
@ -645,7 +645,7 @@ impl<'self> MethodDef<'self> {
the first call). the first call).
*/ */
fn build_enum_match(&self, fn build_enum_match(&self,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
self_args: &[@expr], self_args: &[@expr],
@ -786,7 +786,7 @@ impl<'self> MethodDef<'self> {
} }
fn expand_static_enum_method_body(&self, fn expand_static_enum_method_body(&self,
cx: @ext_ctxt, cx: @ExtCtxt,
span: span, span: span,
enum_def: &enum_def, enum_def: &enum_def,
type_ident: ident, type_ident: ident,
@ -810,7 +810,7 @@ impl<'self> MethodDef<'self> {
} }
} }
fn summarise_struct(cx: @ext_ctxt, span: span, fn summarise_struct(cx: @ExtCtxt, span: span,
struct_def: &struct_def) -> Either<uint, ~[ident]> { struct_def: &struct_def) -> Either<uint, ~[ident]> {
let mut named_idents = ~[]; let mut named_idents = ~[];
let mut unnamed_count = 0; let mut unnamed_count = 0;
@ -840,12 +840,12 @@ Fold the fields. `use_foldl` controls whether this is done
left-to-right (`true`) or right-to-left (`false`). left-to-right (`true`) or right-to-left (`false`).
*/ */
pub fn cs_fold(use_foldl: bool, pub fn cs_fold(use_foldl: bool,
f: &fn(@ext_ctxt, span, f: &fn(@ExtCtxt, span,
old: @expr, old: @expr,
self_f: @expr, other_fs: &[@expr]) -> @expr, self_f: @expr, other_fs: &[@expr]) -> @expr,
base: @expr, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
match *substructure.fields { match *substructure.fields {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
@ -879,9 +879,9 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
~~~ ~~~
*/ */
#[inline(always)] #[inline(always)]
pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr, pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
match *substructure.fields { match *substructure.fields {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => { EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
@ -911,10 +911,10 @@ fields. `use_foldl` controls whether this is done left-to-right
*/ */
#[inline(always)] #[inline(always)]
pub fn cs_same_method_fold(use_foldl: bool, pub fn cs_same_method_fold(use_foldl: bool,
f: &fn(@ext_ctxt, span, @expr, @expr) -> @expr, f: &fn(@ExtCtxt, span, @expr, @expr) -> @expr,
base: @expr, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_same_method( cs_same_method(
|cx, span, vals| { |cx, span, vals| {
@ -940,7 +940,7 @@ on all the fields.
#[inline(always)] #[inline(always)]
pub fn cs_binop(binop: ast::binop, base: @expr, pub fn cs_binop(binop: ast::binop, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f: EnumNonMatchFunc,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_same_method_fold( cs_same_method_fold(
true, // foldl is good enough true, // foldl is good enough
@ -958,7 +958,7 @@ pub fn cs_binop(binop: ast::binop, base: @expr,
/// cs_binop with binop == or /// cs_binop with binop == or
#[inline(always)] #[inline(always)]
pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_binop(ast::or, build::mk_bool(cx, span, false), cs_binop(ast::or, build::mk_bool(cx, span, false),
enum_nonmatch_f, enum_nonmatch_f,
@ -967,7 +967,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
/// cs_binop with binop == and /// cs_binop with binop == and
#[inline(always)] #[inline(always)]
pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ext_ctxt, span: span, cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr { substructure: &Substructure) -> @expr {
cs_binop(ast::and, build::mk_bool(cx, span, true), cs_binop(ast::and, build::mk_bool(cx, span, true),
enum_nonmatch_f, enum_nonmatch_f,

View file

@ -10,11 +10,11 @@
use ast::{meta_item, item, expr, and}; use ast::{meta_item, item, expr, and};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_iter_bytes(cx: @ext_ctxt, pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) -> ~[@item] { in_items: ~[@item]) -> ~[@item] {
@ -41,7 +41,7 @@ pub fn expand_deriving_iter_bytes(cx: @ext_ctxt,
expand_deriving_generic(cx, span, mitem, in_items, &trait_def) expand_deriving_generic(cx, span, mitem, in_items, &trait_def)
} }
fn iter_bytes_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
let lsb0_f = match substr.nonself_args { let lsb0_f = match substr.nonself_args {
[l, f] => ~[l, f], [l, f] => ~[l, f],
_ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`") _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`")

View file

@ -20,7 +20,7 @@ library.
use ast; use ast;
use ast::{Ty, enum_def, expr, ident, item, Generics, meta_item, struct_def}; use ast::{Ty, enum_def, expr, ident, item, Generics, meta_item, struct_def};
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use codemap::{span, respan}; use codemap::{span, respan};
use parse::token::special_idents::clownshoes_extensions; use parse::token::special_idents::clownshoes_extensions;
@ -45,20 +45,20 @@ pub mod totalord;
pub mod generic; pub mod generic;
pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ext_ctxt, pub type ExpandDerivingStructDefFn<'self> = &'self fn(@ExtCtxt,
span, span,
x: &struct_def, x: &struct_def,
ident, ident,
y: &Generics) y: &Generics)
-> @item; -> @item;
pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ext_ctxt, pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt,
span, span,
x: &enum_def, x: &enum_def,
ident, ident,
y: &Generics) y: &Generics)
-> @item; -> @item;
pub fn expand_meta_deriving(cx: @ext_ctxt, pub fn expand_meta_deriving(cx: @ExtCtxt,
_span: span, _span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) in_items: ~[@item])
@ -113,7 +113,7 @@ pub fn expand_meta_deriving(cx: @ext_ctxt,
} }
} }
pub fn expand_deriving(cx: @ext_ctxt, pub fn expand_deriving(cx: @ExtCtxt,
span: span, span: span,
in_items: ~[@item], in_items: ~[@item],
expand_deriving_struct_def: ExpandDerivingStructDefFn, expand_deriving_struct_def: ExpandDerivingStructDefFn,
@ -143,7 +143,7 @@ pub fn expand_deriving(cx: @ext_ctxt,
result result
} }
fn create_impl_item(cx: @ext_ctxt, span: span, item: ast::item_) -> @item { fn create_impl_item(cx: @ExtCtxt, span: span, item: ast::item_) -> @item {
let doc_attr = respan(span, let doc_attr = respan(span,
ast::lit_str(@~"Automatically derived.")); ast::lit_str(@~"Automatically derived."));
let doc_attr = respan(span, ast::meta_name_value(@~"doc", doc_attr)); let doc_attr = respan(span, ast::meta_name_value(@~"doc", doc_attr));
@ -164,7 +164,7 @@ fn create_impl_item(cx: @ext_ctxt, span: span, item: ast::item_) -> @item {
} }
} }
pub fn create_self_type_with_params(cx: @ext_ctxt, pub fn create_self_type_with_params(cx: @ExtCtxt,
span: span, span: span,
type_ident: ident, type_ident: ident,
generics: &Generics) generics: &Generics)
@ -193,7 +193,7 @@ pub fn create_self_type_with_params(cx: @ext_ctxt,
build::mk_ty_path_path(cx, span, self_type) build::mk_ty_path_path(cx, span, self_type)
} }
pub fn create_derived_impl(cx: @ext_ctxt, pub fn create_derived_impl(cx: @ExtCtxt,
span: span, span: span,
type_ident: ident, type_ident: ident,
generics: &Generics, generics: &Generics,
@ -249,7 +249,7 @@ pub fn create_derived_impl(cx: @ext_ctxt,
return create_impl_item(cx, span, impl_item); return create_impl_item(cx, span, impl_item);
} }
pub fn create_subpatterns(cx: @ext_ctxt, pub fn create_subpatterns(cx: @ExtCtxt,
span: span, span: span,
field_paths: ~[@ast::Path], field_paths: ~[@ast::Path],
mutbl: ast::mutability) mutbl: ast::mutability)
@ -265,7 +265,7 @@ enum StructType {
Unknown, Record, Tuple Unknown, Record, Tuple
} }
pub fn create_struct_pattern(cx: @ext_ctxt, pub fn create_struct_pattern(cx: @ExtCtxt,
span: span, span: span,
struct_ident: ident, struct_ident: ident,
struct_def: &struct_def, struct_def: &struct_def,
@ -326,7 +326,7 @@ pub fn create_struct_pattern(cx: @ext_ctxt,
(pattern, ident_expr) (pattern, ident_expr)
} }
pub fn create_enum_variant_pattern(cx: @ext_ctxt, pub fn create_enum_variant_pattern(cx: @ExtCtxt,
span: span, span: span,
variant: &ast::variant, variant: &ast::variant,
prefix: &str, prefix: &str,
@ -366,14 +366,14 @@ pub fn create_enum_variant_pattern(cx: @ext_ctxt,
} }
} }
pub fn variant_arg_count(_cx: @ext_ctxt, _span: span, variant: &ast::variant) -> uint { pub fn variant_arg_count(_cx: @ExtCtxt, _span: span, variant: &ast::variant) -> uint {
match variant.node.kind { match variant.node.kind {
ast::tuple_variant_kind(ref args) => args.len(), ast::tuple_variant_kind(ref args) => args.len(),
ast::struct_variant_kind(ref struct_def) => struct_def.fields.len(), ast::struct_variant_kind(ref struct_def) => struct_def.fields.len(),
} }
} }
pub fn expand_enum_or_struct_match(cx: @ext_ctxt, pub fn expand_enum_or_struct_match(cx: @ExtCtxt,
span: span, span: span,
arms: ~[ ast::arm ]) arms: ~[ ast::arm ])
-> @expr { -> @expr {

View file

@ -11,11 +11,11 @@
use ast; use ast;
use ast::{meta_item, item, expr, ident}; use ast::{meta_item, item, expr, ident};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_rand(cx: @ext_ctxt, pub fn expand_deriving_rand(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) in_items: ~[@item])
@ -47,7 +47,7 @@ pub fn expand_deriving_rand(cx: @ext_ctxt,
expand_deriving_generic(cx, span, mitem, in_items, &trait_def) expand_deriving_generic(cx, span, mitem, in_items, &trait_def)
} }
fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
let rng = match substr.nonself_args { let rng = match substr.nonself_args {
[rng] => ~[ rng ], [rng] => ~[ rng ],
_ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`")
@ -113,7 +113,7 @@ fn rand_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr
_ => cx.bug("Non-static method in `deriving(Rand)`") _ => cx.bug("Non-static method in `deriving(Rand)`")
}; };
fn rand_thing(cx: @ext_ctxt, span: span, fn rand_thing(cx: @ExtCtxt, span: span,
ctor_ident: ident, ctor_ident: ident,
summary: &Either<uint, ~[ident]>, summary: &Either<uint, ~[ident]>,
rand_call: &fn() -> @expr) -> @expr { rand_call: &fn() -> @expr) -> @expr {

View file

@ -10,11 +10,11 @@
use ast::{meta_item, item, expr}; use ast::{meta_item, item, expr};
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use ext::deriving::generic::*; use ext::deriving::generic::*;
pub fn expand_deriving_to_str(cx: @ext_ctxt, pub fn expand_deriving_to_str(cx: @ExtCtxt,
span: span, span: span,
mitem: @meta_item, mitem: @meta_item,
in_items: ~[@item]) in_items: ~[@item])
@ -39,7 +39,7 @@ pub fn expand_deriving_to_str(cx: @ext_ctxt,
expand_deriving_generic(cx, span, mitem, in_items, &trait_def) expand_deriving_generic(cx, span, mitem, in_items, &trait_def)
} }
fn to_str_substructure(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { fn to_str_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
match substr.self_args { match substr.self_args {
[self_obj] => { [self_obj] => {
let self_addr = build::mk_addr_of(cx, span, self_obj); let self_addr = build::mk_addr_of(cx, span, self_obj);

View file

@ -15,7 +15,7 @@ explicit `Self` type to use when specifying impls to be derived.
use ast; use ast;
use ast::{expr,Generics,ident}; use ast::{expr,Generics,ident};
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::build; use ext::build;
use codemap::{span,respan}; use codemap::{span,respan};
use opt_vec; use opt_vec;
@ -53,13 +53,13 @@ pub impl<'self> Path<'self> {
} }
} }
fn to_ty(&self, cx: @ext_ctxt, span: span, fn to_ty(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> @ast::Ty { self_ty: ident, self_generics: &Generics) -> @ast::Ty {
build::mk_ty_path_path(cx, span, build::mk_ty_path_path(cx, span,
self.to_path(cx, span, self.to_path(cx, span,
self_ty, self_generics)) self_ty, self_generics))
} }
fn to_path(&self, cx: @ext_ctxt, span: span, fn to_path(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> @ast::Path { self_ty: ident, self_generics: &Generics) -> @ast::Path {
let idents = self.path.map(|s| cx.ident_of(*s) ); let idents = self.path.map(|s| cx.ident_of(*s) );
let lt = mk_lifetime(cx, span, &self.lifetime); let lt = mk_lifetime(cx, span, &self.lifetime);
@ -104,7 +104,7 @@ pub fn nil_ty() -> Ty<'static> {
Tuple(~[]) Tuple(~[])
} }
fn mk_lifetime(cx: @ext_ctxt, span: span, lt: &Option<&str>) -> Option<@ast::Lifetime> { fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<@ast::Lifetime> {
match *lt { match *lt {
Some(ref s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(*s))), Some(ref s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(*s))),
None => None None => None
@ -112,7 +112,7 @@ fn mk_lifetime(cx: @ext_ctxt, span: span, lt: &Option<&str>) -> Option<@ast::Lif
} }
pub impl<'self> Ty<'self> { pub impl<'self> Ty<'self> {
fn to_ty(&self, cx: @ext_ctxt, span: span, fn to_ty(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> @ast::Ty { self_ty: ident, self_generics: &Generics) -> @ast::Ty {
match *self { match *self {
Ptr(ref ty, ref ptr) => { Ptr(ref ty, ref ptr) => {
@ -146,7 +146,7 @@ pub impl<'self> Ty<'self> {
} }
} }
fn to_path(&self, cx: @ext_ctxt, span: span, fn to_path(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> @ast::Path { self_ty: ident, self_generics: &Generics) -> @ast::Path {
match *self { match *self {
Self => { Self => {
@ -172,7 +172,7 @@ pub impl<'self> Ty<'self> {
} }
fn mk_ty_param(cx: @ext_ctxt, span: span, name: &str, bounds: &[Path], fn mk_ty_param(cx: @ExtCtxt, span: span, name: &str, bounds: &[Path],
self_ident: ident, self_generics: &Generics) -> ast::TyParam { self_ident: ident, self_generics: &Generics) -> ast::TyParam {
let bounds = opt_vec::from( let bounds = opt_vec::from(
do bounds.map |b| { do bounds.map |b| {
@ -201,7 +201,7 @@ pub impl<'self> LifetimeBounds<'self> {
lifetimes: ~[], bounds: ~[] lifetimes: ~[], bounds: ~[]
} }
} }
fn to_generics(&self, cx: @ext_ctxt, span: span, fn to_generics(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> Generics { self_ty: ident, self_generics: &Generics) -> Generics {
let lifetimes = do self.lifetimes.map |lt| { let lifetimes = do self.lifetimes.map |lt| {
build::mk_lifetime(cx, span, cx.ident_of(*lt)) build::mk_lifetime(cx, span, cx.ident_of(*lt))
@ -218,7 +218,7 @@ pub impl<'self> LifetimeBounds<'self> {
} }
pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: &Option<PtrTy>) pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
-> (@expr, ast::explicit_self) { -> (@expr, ast::explicit_self) {
let self_path = build::make_self(cx, span); let self_path = build::make_self(cx, span);
match *self_ptr { match *self_ptr {

View file

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

View file

@ -23,7 +23,7 @@ use parse;
use parse::{parse_item_from_source_str}; use parse::{parse_item_from_source_str};
pub fn expand_expr(extsbox: @mut SyntaxEnv, pub fn expand_expr(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, cx: @ExtCtxt,
e: &expr_, e: &expr_,
s: span, s: span,
fld: @ast_fold, fld: @ast_fold,
@ -109,7 +109,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
// NB: there is some redundancy between this and expand_item, below, and // NB: there is some redundancy between this and expand_item, below, and
// they might benefit from some amount of semantic and language-UI merger. // they might benefit from some amount of semantic and language-UI merger.
pub fn expand_mod_items(extsbox: @mut SyntaxEnv, pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, cx: @ExtCtxt,
module_: &ast::_mod, module_: &ast::_mod,
fld: @ast_fold, fld: @ast_fold,
orig: @fn(&ast::_mod, @ast_fold) -> ast::_mod) orig: @fn(&ast::_mod, @ast_fold) -> ast::_mod)
@ -161,7 +161,7 @@ macro_rules! with_exts_frame (
// When we enter a module, record it, for the sake of `module!` // When we enter a module, record it, for the sake of `module!`
pub fn expand_item(extsbox: @mut SyntaxEnv, pub fn expand_item(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, cx: @ExtCtxt,
it: @ast::item, it: @ast::item,
fld: @ast_fold, fld: @ast_fold,
orig: @fn(@ast::item, @ast_fold) -> Option<@ast::item>) orig: @fn(@ast::item, @ast_fold) -> Option<@ast::item>)
@ -227,7 +227,7 @@ macro_rules! without_macro_scoping(
// Support for item-position macro invocations, exactly the same // Support for item-position macro invocations, exactly the same
// logic as for expression-position macro invocations. // logic as for expression-position macro invocations.
pub fn expand_item_mac(extsbox: @mut SyntaxEnv, pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, it: @ast::item, cx: @ExtCtxt, it: @ast::item,
fld: @ast_fold) fld: @ast_fold)
-> Option<@ast::item> { -> Option<@ast::item> {
let (pth, tts) = match it.node { let (pth, tts) = match it.node {
@ -294,7 +294,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
// expand a stmt // expand a stmt
pub fn expand_stmt(extsbox: @mut SyntaxEnv, pub fn expand_stmt(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, cx: @ExtCtxt,
s: &stmt_, s: &stmt_,
sp: span, sp: span,
fld: @ast_fold, fld: @ast_fold,
@ -360,7 +360,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
pub fn expand_block(extsbox: @mut SyntaxEnv, pub fn expand_block(extsbox: @mut SyntaxEnv,
cx: @ext_ctxt, cx: @ExtCtxt,
blk: &blk_, blk: &blk_,
sp: span, sp: span,
fld: @ast_fold, fld: @ast_fold,
@ -381,7 +381,7 @@ pub fn expand_block(extsbox: @mut SyntaxEnv,
} }
} }
pub fn new_span(cx: @ext_ctxt, sp: span) -> span { pub fn new_span(cx: @ExtCtxt, sp: span) -> span {
/* this discards information in the case of macro-defining macros */ /* this discards information in the case of macro-defining macros */
return span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; return span {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()};
} }
@ -590,7 +590,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
// every method/element of AstFoldFns in fold.rs. // every method/element of AstFoldFns in fold.rs.
let extsbox = @mut syntax_expander_table(); let extsbox = @mut syntax_expander_table();
let afp = default_ast_fold(); let afp = default_ast_fold();
let cx: @ext_ctxt = mk_ctxt(parse_sess, copy cfg); let cx = ExtCtxt::new(parse_sess, copy cfg);
let f_pre = @AstFoldFns { let f_pre = @AstFoldFns {
fold_expr: |expr,span,recur| fold_expr: |expr,span,recur|
expand_expr(extsbox, cx, expr, span, recur, afp.fold_expr), expand_expr(extsbox, cx, expr, span, recur, afp.fold_expr),

View file

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

View file

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

View file

@ -19,7 +19,7 @@ use ast;
use ast_util; use ast_util;
use codemap::{span, respan, dummy_sp, spanned}; use codemap::{span, respan, dummy_sp, spanned};
use codemap; use codemap;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::quote::rt::*; use ext::quote::rt::*;
use opt_vec; use opt_vec;
use opt_vec::OptVec; use opt_vec::OptVec;
@ -135,7 +135,7 @@ pub trait ext_ctxt_ast_builder {
fn strip_bounds(&self, bounds: &Generics) -> Generics; fn strip_bounds(&self, bounds: &Generics) -> Generics;
} }
impl ext_ctxt_ast_builder for @ext_ctxt { impl ext_ctxt_ast_builder for @ExtCtxt {
fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty { fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty {
self.ty_path_ast_builder(path_global(~[ self.ty_path_ast_builder(path_global(~[
self.ident_of("core"), self.ident_of("core"),

View file

@ -31,11 +31,11 @@ that.
use ast; use ast;
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::pipes::proto::{state, protocol, next_state}; use ext::pipes::proto::{state, protocol, next_state};
use ext::pipes::proto; use ext::pipes::proto;
impl proto::visitor<(), (), ()> for @ext_ctxt { impl proto::visitor<(), (), ()> for @ExtCtxt {
fn visit_proto(&self, _proto: protocol, _states: &[()]) { } fn visit_proto(&self, _proto: protocol, _states: &[()]) { }
fn visit_state(&self, state: state, _m: &[()]) { fn visit_state(&self, state: state, _m: &[()]) {

View file

@ -37,12 +37,12 @@ updating the states using rule (2) until there are no changes.
*/ */
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::pipes::proto::{protocol_}; use ext::pipes::proto::{protocol_};
use std::bitv::Bitv; use std::bitv::Bitv;
pub fn analyze(proto: @mut protocol_, _cx: @ext_ctxt) { pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
debug!("initializing colive analysis"); debug!("initializing colive analysis");
let num_states = proto.num_states(); let num_states = proto.num_states();
let mut colive = do (copy proto.states).map_to_vec |state| { let mut colive = do (copy proto.states).map_to_vec |state| {

View file

@ -46,7 +46,7 @@ FIXME (#3072) - This is still incomplete.
use ast; use ast;
use codemap::span; use codemap::span;
use ext::base; use ext::base;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::pipes::parse_proto::proto_parser; use ext::pipes::parse_proto::proto_parser;
use ext::pipes::pipec::gen_init; use ext::pipes::pipec::gen_init;
use ext::pipes::proto::visit; use ext::pipes::proto::visit;
@ -63,7 +63,7 @@ pub mod check;
pub mod liveness; pub mod liveness;
pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident, pub fn expand_proto(cx: @ExtCtxt, _sp: span, id: ast::ident,
tt: ~[ast::token_tree]) -> base::MacResult { tt: ~[ast::token_tree]) -> base::MacResult {
let sess = cx.parse_sess(); let sess = cx.parse_sess();
let cfg = cx.cfg(); let cfg = cx.cfg();

View file

@ -12,7 +12,7 @@
use ast; use ast;
use codemap::{dummy_sp, spanned}; use codemap::{dummy_sp, spanned};
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path}; use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
use ext::pipes::ast_builder::{path_global}; use ext::pipes::ast_builder::{path_global};
use ext::pipes::proto::*; use ext::pipes::proto::*;
@ -21,27 +21,27 @@ use opt_vec;
use opt_vec::OptVec; use opt_vec::OptVec;
pub trait gen_send { pub trait gen_send {
fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item; fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item;
fn to_ty(&mut self, cx: @ext_ctxt) -> @ast::Ty; fn to_ty(&mut self, cx: @ExtCtxt) -> @ast::Ty;
} }
pub trait to_type_decls { pub trait to_type_decls {
fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item]; fn to_type_decls(&self, cx: @ExtCtxt) -> ~[@ast::item];
fn to_endpoint_decls(&self, cx: @ext_ctxt, fn to_endpoint_decls(&self, cx: @ExtCtxt,
dir: direction) -> ~[@ast::item]; dir: direction) -> ~[@ast::item];
} }
pub trait gen_init { pub trait gen_init {
fn gen_init(&self, cx: @ext_ctxt) -> @ast::item; fn gen_init(&self, cx: @ExtCtxt) -> @ast::item;
fn compile(&self, cx: @ext_ctxt) -> @ast::item; fn compile(&self, cx: @ExtCtxt) -> @ast::item;
fn buffer_ty_path(&self, cx: @ext_ctxt) -> @ast::Ty; fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty;
fn gen_buffer_type(&self, cx: @ext_ctxt) -> @ast::item; fn gen_buffer_type(&self, cx: @ExtCtxt) -> @ast::item;
fn gen_buffer_init(&self, ext_cx: @ext_ctxt) -> @ast::expr; fn gen_buffer_init(&self, ext_cx: @ExtCtxt) -> @ast::expr;
fn gen_init_bounded(&self, ext_cx: @ext_ctxt) -> @ast::expr; fn gen_init_bounded(&self, ext_cx: @ExtCtxt) -> @ast::expr;
} }
impl gen_send for message { impl gen_send for message {
fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item { fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item {
debug!("pipec: gen_send"); debug!("pipec: gen_send");
let name = self.name(); let name = self.name();
@ -184,14 +184,14 @@ impl gen_send for message {
} }
} }
fn to_ty(&mut self, cx: @ext_ctxt) -> @ast::Ty { fn to_ty(&mut self, cx: @ExtCtxt) -> @ast::Ty {
cx.ty_path_ast_builder(path(~[cx.ident_of(self.name())], self.span()) cx.ty_path_ast_builder(path(~[cx.ident_of(self.name())], self.span())
.add_tys(cx.ty_vars_global(&self.get_generics().ty_params))) .add_tys(cx.ty_vars_global(&self.get_generics().ty_params)))
} }
} }
impl to_type_decls for state { impl to_type_decls for state {
fn to_type_decls(&self, cx: @ext_ctxt) -> ~[@ast::item] { fn to_type_decls(&self, cx: @ExtCtxt) -> ~[@ast::item] {
debug!("pipec: to_type_decls"); debug!("pipec: to_type_decls");
// This compiles into two different type declarations. Say the // This compiles into two different type declarations. Say the
// state is called ping. This will generate both `ping` and // state is called ping. This will generate both `ping` and
@ -240,7 +240,7 @@ impl to_type_decls for state {
] ]
} }
fn to_endpoint_decls(&self, cx: @ext_ctxt, fn to_endpoint_decls(&self, cx: @ExtCtxt,
dir: direction) -> ~[@ast::item] { dir: direction) -> ~[@ast::item] {
debug!("pipec: to_endpoint_decls"); debug!("pipec: to_endpoint_decls");
let dir = match dir { let dir = match dir {
@ -302,7 +302,7 @@ impl to_type_decls for state {
} }
impl gen_init for protocol { impl gen_init for protocol {
fn gen_init(&self, cx: @ext_ctxt) -> @ast::item { fn gen_init(&self, cx: @ExtCtxt) -> @ast::item {
let ext_cx = cx; let ext_cx = cx;
debug!("gen_init"); debug!("gen_init");
@ -340,7 +340,7 @@ impl gen_init for protocol {
body.to_source(cx))) body.to_source(cx)))
} }
fn gen_buffer_init(&self, ext_cx: @ext_ctxt) -> @ast::expr { fn gen_buffer_init(&self, ext_cx: @ExtCtxt) -> @ast::expr {
ext_cx.struct_expr(path(~[ext_cx.ident_of("__Buffer")], ext_cx.struct_expr(path(~[ext_cx.ident_of("__Buffer")],
dummy_sp()), dummy_sp()),
self.states.map_to_vec(|s| { self.states.map_to_vec(|s| {
@ -352,7 +352,7 @@ impl gen_init for protocol {
})) }))
} }
fn gen_init_bounded(&self, ext_cx: @ext_ctxt) -> @ast::expr { fn gen_init_bounded(&self, ext_cx: @ExtCtxt) -> @ast::expr {
debug!("gen_init_bounded"); debug!("gen_init_bounded");
let buffer_fields = self.gen_buffer_init(ext_cx); let buffer_fields = self.gen_buffer_init(ext_cx);
let buffer = quote_expr!(~::core::pipes::Buffer { let buffer = quote_expr!(~::core::pipes::Buffer {
@ -378,7 +378,7 @@ impl gen_init for protocol {
}) })
} }
fn buffer_ty_path(&self, cx: @ext_ctxt) -> @ast::Ty { fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty {
let mut params: OptVec<ast::TyParam> = opt_vec::Empty; let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
for (copy self.states).each |s| { for (copy self.states).each |s| {
for s.generics.ty_params.each |tp| { for s.generics.ty_params.each |tp| {
@ -395,7 +395,7 @@ impl gen_init for protocol {
.add_tys(cx.ty_vars_global(&params))) .add_tys(cx.ty_vars_global(&params)))
} }
fn gen_buffer_type(&self, cx: @ext_ctxt) -> @ast::item { fn gen_buffer_type(&self, cx: @ExtCtxt) -> @ast::item {
let ext_cx = cx; let ext_cx = cx;
let mut params: OptVec<ast::TyParam> = opt_vec::Empty; let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
let fields = do (copy self.states).map_to_vec |s| { let fields = do (copy self.states).map_to_vec |s| {
@ -436,7 +436,7 @@ impl gen_init for protocol {
cx.strip_bounds(&generics)) cx.strip_bounds(&generics))
} }
fn compile(&self, cx: @ext_ctxt) -> @ast::item { fn compile(&self, cx: @ExtCtxt) -> @ast::item {
let mut items = ~[self.gen_init(cx)]; let mut items = ~[self.gen_init(cx)];
let mut client_states = ~[]; let mut client_states = ~[];
let mut server_states = ~[]; let mut server_states = ~[];

View file

@ -10,7 +10,7 @@
use ast; use ast;
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path}; use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
#[deriving(Eq)] #[deriving(Eq)]
@ -92,7 +92,7 @@ pub impl state_ {
} }
/// Returns the type that is used for the messages. /// Returns the type that is used for the messages.
fn to_ty(&self, cx: @ext_ctxt) -> @ast::Ty { fn to_ty(&self, cx: @ExtCtxt) -> @ast::Ty {
cx.ty_path_ast_builder cx.ty_path_ast_builder
(path(~[cx.ident_of(self.name)],self.span).add_tys( (path(~[cx.ident_of(self.name)],self.span).add_tys(
cx.ty_vars(&self.generics.ty_params))) cx.ty_vars(&self.generics.ty_params)))

View file

@ -10,7 +10,7 @@
use ast; use ast;
use codemap::{BytePos, Pos, span}; use codemap::{BytePos, Pos, span};
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::base; use ext::base;
use ext::build; use ext::build;
use parse::token::*; use parse::token::*;
@ -30,7 +30,7 @@ use parse;
pub mod rt { pub mod rt {
use ast; use ast;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use parse; use parse;
use print::pprust; use print::pprust;
@ -44,11 +44,11 @@ pub mod rt {
use print::pprust::{item_to_str, ty_to_str}; use print::pprust::{item_to_str, ty_to_str};
pub trait ToTokens { pub trait ToTokens {
pub fn to_tokens(&self, _cx: @ext_ctxt) -> ~[token_tree]; pub fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree];
} }
impl ToTokens for ~[token_tree] { impl ToTokens for ~[token_tree] {
pub fn to_tokens(&self, _cx: @ext_ctxt) -> ~[token_tree] { pub fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree] {
copy *self copy *self
} }
} }
@ -57,10 +57,10 @@ pub mod rt {
trait ToSource : ToTokens { trait ToSource : ToTokens {
// Takes a thing and generates a string containing rust code for it. // 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: @ExtCtxt) -> ~str;
// If you can make source, you can definitely make tokens. // If you can make source, you can definitely make tokens.
pub fn to_tokens(cx: @ext_ctxt) -> ~[token_tree] { pub fn to_tokens(cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
@ -69,80 +69,80 @@ pub mod rt {
pub trait ToSource { pub trait ToSource {
// Takes a thing and generates a string containing rust code for it. // 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: @ExtCtxt) -> ~str;
} }
impl ToSource for ast::ident { impl ToSource for ast::ident {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
copy *cx.parse_sess().interner.get(*self) copy *cx.parse_sess().interner.get(*self)
} }
} }
impl ToSource for @ast::item { impl ToSource for @ast::item {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
item_to_str(*self, cx.parse_sess().interner) item_to_str(*self, cx.parse_sess().interner)
} }
} }
impl<'self> ToSource for &'self [@ast::item] { impl<'self> ToSource for &'self [@ast::item] {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), "\n\n") str::connect(self.map(|i| i.to_source(cx)), "\n\n")
} }
} }
impl ToSource for @ast::Ty { impl ToSource for @ast::Ty {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
ty_to_str(*self, cx.parse_sess().interner) ty_to_str(*self, cx.parse_sess().interner)
} }
} }
impl<'self> ToSource for &'self [@ast::Ty] { impl<'self> ToSource for &'self [@ast::Ty] {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ", ") str::connect(self.map(|i| i.to_source(cx)), ", ")
} }
} }
impl ToSource for Generics { impl ToSource for Generics {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
pprust::generics_to_str(self, cx.parse_sess().interner) pprust::generics_to_str(self, cx.parse_sess().interner)
} }
} }
impl ToSource for @ast::expr { impl ToSource for @ast::expr {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
pprust::expr_to_str(*self, cx.parse_sess().interner) pprust::expr_to_str(*self, cx.parse_sess().interner)
} }
} }
impl ToSource for ast::blk { impl ToSource for ast::blk {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ExtCtxt) -> ~str {
pprust::block_to_str(self, cx.parse_sess().interner) pprust::block_to_str(self, cx.parse_sess().interner)
} }
} }
impl<'self> ToSource for &'self str { impl<'self> ToSource for &'self str {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_str(@str::to_owned(*self))); let lit = dummy_spanned(ast::lit_str(@str::to_owned(*self)));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for int { impl ToSource for int {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i)); let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for i8 { impl ToSource for i8 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i8)); let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i8));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for i16 { impl ToSource for i16 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i16)); let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i16));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
@ -150,49 +150,49 @@ pub mod rt {
impl ToSource for i32 { impl ToSource for i32 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i32)); let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i32));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for i64 { impl ToSource for i64 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i64)); let lit = dummy_spanned(ast::lit_int(*self as i64, ast::ty_i64));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for uint { impl ToSource for uint {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u)); let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for u8 { impl ToSource for u8 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u8)); let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u8));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for u16 { impl ToSource for u16 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u16)); let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u16));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for u32 { impl ToSource for u32 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u32)); let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u32));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
} }
impl ToSource for u64 { impl ToSource for u64 {
fn to_source(&self, _cx: @ext_ctxt) -> ~str { fn to_source(&self, _cx: @ExtCtxt) -> ~str {
let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u64)); let lit = dummy_spanned(ast::lit_uint(*self as u64, ast::ty_u64));
pprust::lit_to_str(@lit) pprust::lit_to_str(@lit)
} }
@ -201,115 +201,115 @@ pub mod rt {
// Alas ... we write these out instead. All redundant. // Alas ... we write these out instead. All redundant.
impl ToTokens for ast::ident { impl ToTokens for ast::ident {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for @ast::item { impl ToTokens for @ast::item {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl<'self> ToTokens for &'self [@ast::item] { impl<'self> ToTokens for &'self [@ast::item] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for @ast::Ty { impl ToTokens for @ast::Ty {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl<'self> ToTokens for &'self [@ast::Ty] { impl<'self> ToTokens for &'self [@ast::Ty] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for Generics { impl ToTokens for Generics {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for @ast::expr { impl ToTokens for @ast::expr {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for ast::blk { impl ToTokens for ast::blk {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl<'self> ToTokens for &'self str { impl<'self> ToTokens for &'self str {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for int { impl ToTokens for int {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for i8 { impl ToTokens for i8 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for i16 { impl ToTokens for i16 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for i32 { impl ToTokens for i32 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for i64 { impl ToTokens for i64 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for uint { impl ToTokens for uint {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for u8 { impl ToTokens for u8 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for u16 { impl ToTokens for u16 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for u32 { impl ToTokens for u32 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ToTokens for u64 { impl ToTokens for u64 {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
@ -321,7 +321,7 @@ pub mod rt {
fn parse_tts(&self, s: ~str) -> ~[ast::token_tree]; fn parse_tts(&self, s: ~str) -> ~[ast::token_tree];
} }
impl ExtParseUtils for @ext_ctxt { impl ExtParseUtils for ExtCtxt {
fn parse_item(&self, s: ~str) -> @ast::item { fn parse_item(&self, s: ~str) -> @ast::item {
let res = parse::parse_item_from_source_str( let res = parse::parse_item_from_source_str(
@ -367,19 +367,19 @@ pub mod rt {
} }
pub fn expand_quote_tokens(cx: @ext_ctxt, pub fn expand_quote_tokens(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
base::MRExpr(expand_tts(cx, sp, tts)) base::MRExpr(expand_tts(cx, sp, tts))
} }
pub fn expand_quote_expr(cx: @ext_ctxt, pub fn expand_quote_expr(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
base::MRExpr(expand_parse_call(cx, sp, "parse_expr", ~[], tts)) base::MRExpr(expand_parse_call(cx, sp, "parse_expr", ~[], tts))
} }
pub fn expand_quote_item(cx: @ext_ctxt, pub fn expand_quote_item(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]); let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]);
@ -387,7 +387,7 @@ pub fn expand_quote_item(cx: @ext_ctxt,
~[e_attrs], tts)) ~[e_attrs], tts))
} }
pub fn expand_quote_pat(cx: @ext_ctxt, pub fn expand_quote_pat(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
let e_refutable = build::mk_lit(cx, sp, ast::lit_bool(true)); let e_refutable = build::mk_lit(cx, sp, ast::lit_bool(true));
@ -395,7 +395,7 @@ pub fn expand_quote_pat(cx: @ext_ctxt,
~[e_refutable], tts)) ~[e_refutable], tts))
} }
pub fn expand_quote_ty(cx: @ext_ctxt, pub fn expand_quote_ty(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
let e_param_colons = build::mk_lit(cx, sp, ast::lit_bool(false)); let e_param_colons = build::mk_lit(cx, sp, ast::lit_bool(false));
@ -403,7 +403,7 @@ pub fn expand_quote_ty(cx: @ext_ctxt,
~[e_param_colons], tts)) ~[e_param_colons], tts))
} }
pub fn expand_quote_stmt(cx: @ext_ctxt, pub fn expand_quote_stmt(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> base::MacResult { tts: &[ast::token_tree]) -> base::MacResult {
let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]); let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]);
@ -411,16 +411,16 @@ pub fn expand_quote_stmt(cx: @ext_ctxt,
~[e_attrs], tts)) ~[e_attrs], tts))
} }
fn ids_ext(cx: @ext_ctxt, strs: ~[~str]) -> ~[ast::ident] { fn ids_ext(cx: @ExtCtxt, strs: ~[~str]) -> ~[ast::ident] {
strs.map(|str| cx.parse_sess().interner.intern(*str)) strs.map(|str| cx.parse_sess().interner.intern(*str))
} }
fn id_ext(cx: @ext_ctxt, str: &str) -> ast::ident { fn id_ext(cx: @ExtCtxt, str: &str) -> ast::ident {
cx.parse_sess().interner.intern(str) cx.parse_sess().interner.intern(str)
} }
// Lift an ident to the expr that evaluates to that ident. // 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: @ExtCtxt, sp: span, ident: ast::ident) -> @ast::expr {
let e_str = build::mk_base_str(cx, sp, cx.str_of(ident)); let e_str = build::mk_base_str(cx, sp, cx.str_of(ident));
build::mk_method_call(cx, sp, build::mk_method_call(cx, sp,
build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])), build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
@ -428,13 +428,13 @@ fn mk_ident(cx: @ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr {
~[e_str]) ~[e_str])
} }
fn mk_bytepos(cx: @ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr { fn mk_bytepos(cx: @ExtCtxt, sp: span, bpos: BytePos) -> @ast::expr {
let path = ids_ext(cx, ~[~"BytePos"]); let path = ids_ext(cx, ~[~"BytePos"]);
let arg = build::mk_uint(cx, sp, bpos.to_uint()); let arg = build::mk_uint(cx, sp, bpos.to_uint());
build::mk_call(cx, sp, path, ~[arg]) build::mk_call(cx, sp, path, ~[arg])
} }
fn mk_binop(cx: @ext_ctxt, sp: span, bop: token::binop) -> @ast::expr { fn mk_binop(cx: @ExtCtxt, sp: span, bop: token::binop) -> @ast::expr {
let name = match bop { let name = match bop {
PLUS => "PLUS", PLUS => "PLUS",
MINUS => "MINUS", MINUS => "MINUS",
@ -451,7 +451,7 @@ fn mk_binop(cx: @ext_ctxt, sp: span, bop: token::binop) -> @ast::expr {
ids_ext(cx, ~[name.to_owned()])) ids_ext(cx, ~[name.to_owned()]))
} }
fn mk_token(cx: @ext_ctxt, sp: span, tok: &token::Token) -> @ast::expr { fn mk_token(cx: @ExtCtxt, sp: span, tok: &token::Token) -> @ast::expr {
match *tok { match *tok {
BINOP(binop) => { BINOP(binop) => {
@ -600,7 +600,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: @ExtCtxt, sp: span, tt: &ast::token_tree)
-> ~[@ast::stmt] { -> ~[@ast::stmt] {
match *tt { match *tt {
@ -646,7 +646,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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> ~[@ast::stmt] { -> ~[@ast::stmt] {
let mut ss = ~[]; let mut ss = ~[];
for tts.each |tt| { for tts.each |tt| {
@ -655,7 +655,7 @@ fn mk_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
ss ss
} }
fn expand_tts(cx: @ext_ctxt, fn expand_tts(cx: @ExtCtxt,
sp: span, sp: span,
tts: &[ast::token_tree]) -> @ast::expr { tts: &[ast::token_tree]) -> @ast::expr {
@ -729,7 +729,7 @@ fn expand_tts(cx: @ext_ctxt,
ids_ext(cx, ~[~"tt"])))) ids_ext(cx, ~[~"tt"]))))
} }
fn expand_parse_call(cx: @ext_ctxt, fn expand_parse_call(cx: @ExtCtxt,
sp: span, sp: span,
parse_method: &str, parse_method: &str,
arg_exprs: ~[@ast::expr], arg_exprs: ~[@ast::expr],

View file

@ -23,7 +23,7 @@ use print::pprust;
// a given file into the current one. // a given file into the current one.
/* line!(): expands to the current line number */ /* 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
base::check_zero_tts(cx, sp, tts, "line!"); base::check_zero_tts(cx, sp, tts, "line!");
@ -34,7 +34,7 @@ pub fn expand_line(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
} }
/* col!(): expands to the current column number */ /* 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
base::check_zero_tts(cx, sp, tts, "col!"); base::check_zero_tts(cx, sp, tts, "col!");
@ -46,7 +46,7 @@ pub fn expand_col(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
/* file!(): expands to the current filename */ /* file!(): expands to the current filename */
/* The filemap (`loc.file`) contains a bunch more information we could spit /* The filemap (`loc.file`) contains a bunch more information we could spit
* out if we wanted. */ * out if we wanted. */
pub fn expand_file(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) pub fn expand_file(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
base::check_zero_tts(cx, sp, tts, "file!"); base::check_zero_tts(cx, sp, tts, "file!");
@ -56,13 +56,13 @@ pub fn expand_file(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
base::MRExpr(mk_base_str(cx, topmost.call_site, filename)) 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let s = pprust::tts_to_str(tts, cx.parse_sess().interner); let s = pprust::tts_to_str(tts, cx.parse_sess().interner);
base::MRExpr(mk_base_str(cx, sp, s)) 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
base::check_zero_tts(cx, sp, tts, "module_path!"); base::check_zero_tts(cx, sp, tts, "module_path!");
base::MRExpr(mk_base_str(cx, sp, base::MRExpr(mk_base_str(cx, sp,
@ -73,7 +73,7 @@ pub fn expand_mod(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
// include! : parse the given file as an expr // include! : parse the given file as an expr
// This is generally a bad idea because it's going to behave // This is generally a bad idea because it's going to behave
// unhygienically. // unhygienically.
pub fn expand_include(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) pub fn expand_include(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include!"); let file = get_single_str_from_tts(cx, sp, tts, "include!");
let p = parse::new_sub_parser_from_file( let p = parse::new_sub_parser_from_file(
@ -83,7 +83,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 // 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include_str!"); 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))); let res = io::read_whole_file_str(&res_rel_file(cx, sp, &Path(file)));
@ -97,7 +97,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))) 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: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include_bin!"); let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) { match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
@ -141,7 +141,7 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo {
// resolve a file-system path to an absolute file-system path (if it // resolve a file-system path to an absolute file-system path (if it
// isn't already) // isn't already)
fn res_rel_file(cx: @ext_ctxt, sp: codemap::span, arg: &Path) -> Path { fn res_rel_file(cx: @ExtCtxt, sp: codemap::span, arg: &Path) -> Path {
// NB: relative paths are resolved relative to the compilation unit // NB: relative paths are resolved relative to the compilation unit
if !arg.is_absolute { if !arg.is_absolute {
let cu = Path(cx.codemap().span_to_filename(sp)); let cu = Path(cx.codemap().span_to_filename(sp));

View file

@ -10,12 +10,12 @@
use ast; use ast;
use codemap::span; use codemap::span;
use ext::base::ext_ctxt; use ext::base::ExtCtxt;
use ext::base; use ext::base;
use parse::lexer::{new_tt_reader, reader}; use parse::lexer::{new_tt_reader, reader};
use parse::parser::Parser; use parse::parser::Parser;
pub fn expand_trace_macros(cx: @ext_ctxt, pub fn expand_trace_macros(cx: @ExtCtxt,
sp: span, sp: span,
tt: &[ast::token_tree]) tt: &[ast::token_tree])
-> base::MacResult { -> base::MacResult {

View file

@ -13,7 +13,7 @@ use ast::{ident, matcher_, matcher, match_tok, match_nonterminal, match_seq};
use ast::{tt_delim}; use ast::{tt_delim};
use ast; use ast;
use codemap::{span, spanned, dummy_sp}; use codemap::{span, spanned, dummy_sp};
use ext::base::{ext_ctxt, MacResult, MRAny, MRDef, MacroDef, NormalTT}; use ext::base::{ExtCtxt, MacResult, MRAny, MRDef, MacroDef, NormalTT};
use ext::base; use ext::base;
use ext::tt::macro_parser::{error}; use ext::tt::macro_parser::{error};
use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
@ -26,7 +26,7 @@ use print;
use core::io; use core::io;
pub fn add_new_extension(cx: @ext_ctxt, pub fn add_new_extension(cx: @ExtCtxt,
sp: span, sp: span,
name: ident, name: ident,
arg: ~[ast::token_tree]) arg: ~[ast::token_tree])
@ -73,7 +73,7 @@ pub fn add_new_extension(cx: @ext_ctxt,
}; };
// Given `lhses` and `rhses`, this is the new macro we create // 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: @ExtCtxt, sp: span, name: ident,
arg: &[ast::token_tree], arg: &[ast::token_tree],
lhses: &[@named_match], rhses: &[@named_match]) lhses: &[@named_match], rhses: &[@named_match])
-> MacResult { -> MacResult {
@ -145,7 +145,7 @@ pub fn add_new_extension(cx: @ext_ctxt,
cx.span_fatal(best_fail_spot, best_fail_msg); cx.span_fatal(best_fail_spot, best_fail_msg);
} }
let exp: @fn(@ext_ctxt, span, &[ast::token_tree]) -> MacResult = let exp: @fn(@ExtCtxt, span, &[ast::token_tree]) -> MacResult =
|cx, sp, arg| generic_extension(cx, sp, name, arg, *lhses, *rhses); |cx, sp, arg| generic_extension(cx, sp, name, arg, *lhses, *rhses);
return MRDef(MacroDef{ return MRDef(MacroDef{

View file

@ -12,9 +12,9 @@
extern mod syntax; extern mod syntax;
use syntax::ext::base::ext_ctxt; use syntax::ext::base::ExtCtxt;
fn syntax_extension(ext_cx: @ext_ctxt) { fn syntax_extension(ext_cx: @ExtCtxt) {
let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(1 + 2); let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(1 + 2);
let p_toks : ~[syntax::ast::token_tree] = quote_tokens!((x, 1 .. 4, *)); let p_toks : ~[syntax::ast::token_tree] = quote_tokens!((x, 1 .. 4, *));