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

@ -23,7 +23,7 @@ use print::pprust;
// a given file into the current one.
/* line!(): expands to the current line number */
pub fn expand_line(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_line(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
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 */
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::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 */
/* The filemap (`loc.file`) contains a bunch more information we could spit
* out if we wanted. */
pub fn expand_file(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_file(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
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))
}
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 {
let s = pprust::tts_to_str(tts, cx.parse_sess().interner);
base::MRExpr(mk_base_str(cx, sp, s))
}
pub fn expand_mod(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_mod(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "module_path!");
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
// This is generally a bad idea because it's going to behave
// unhygienically.
pub fn expand_include(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
pub fn expand_include(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let file = get_single_str_from_tts(cx, sp, tts, "include!");
let p = parse::new_sub_parser_from_file(
@ -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
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 {
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)));
@ -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)))
}
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 {
let file = get_single_str_from_tts(cx, sp, tts, "include_bin!");
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
// 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
if !arg.is_absolute {
let cu = Path(cx.codemap().span_to_filename(sp));