Start passing around &mut ExtCtxt

This commit is contained in:
Steven Fackler 2013-12-28 22:06:22 -07:00
parent 3965dddf49
commit 8143662836
16 changed files with 49 additions and 48 deletions

View file

@ -28,7 +28,7 @@ use std::str;
// a given file into the current one.
/* line!(): expands to the current line number */
pub fn expand_line(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "line!");
@ -39,7 +39,7 @@ pub fn expand_line(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
}
/* col!(): expands to the current column number */
pub fn expand_col(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_col(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "col!");
@ -51,7 +51,7 @@ pub fn expand_col(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
/* file!(): expands to the current filename */
/* The filemap (`loc.file`) contains a bunch more information we could spit
* out if we wanted. */
pub fn expand_file(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "file!");
@ -61,13 +61,13 @@ pub fn expand_file(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
base::MRExpr(cx.expr_str(topmost.call_site, filename))
}
pub fn expand_stringify(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
let s = pprust::tts_to_str(tts, get_ident_interner());
base::MRExpr(cx.expr_str(sp, s.to_managed()))
}
pub fn expand_mod(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "module_path!");
base::MRExpr(cx.expr_str(sp,
@ -77,7 +77,7 @@ pub fn expand_mod(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
// include! : parse the given file as an expr
// This is generally a bad idea because it's going to behave
// unhygienically.
pub fn expand_include(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include!");
// The file will be added to the code map by the parser
@ -88,7 +88,7 @@ pub fn expand_include(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
}
// include_str! : read the given file, insert it as a literal string expr
pub fn expand_include_str(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include_str!");
let file = res_rel_file(cx, sp, &Path::new(file));
@ -120,7 +120,7 @@ pub fn expand_include_str(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
}
}
pub fn expand_include_bin(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
-> base::MacResult
{
use std::at_vec;
@ -167,7 +167,7 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo {
// resolve a file-system path to an absolute file-system path (if it
// isn't already)
fn res_rel_file(cx: &ExtCtxt, sp: codemap::Span, arg: &Path) -> Path {
fn res_rel_file(cx: &mut ExtCtxt, sp: codemap::Span, arg: &Path) -> Path {
// NB: relative paths are resolved relative to the compilation unit
if !arg.is_absolute() {
let mut cu = Path::new(cx.codemap().span_to_filename(sp));