]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ext/source_util.rs
Merge remote-tracking branch 'brson/codemap'
[rust.git] / src / libsyntax / ext / source_util.rs
index 45c8fd76e4f2cf3619aa16c42329bfa4d1c71e68..baf92175e7d6b5be4b7aa603217dd02d9ca2c092 100644 (file)
@@ -1,5 +1,5 @@
 use base::*;
-use codemap::span;
+use codemap::{span, Loc, FileMap};
 use print::pprust;
 use build::{mk_base_vec_e,mk_uint,mk_u8,mk_uniq_str};
 
@@ -16,7 +16,7 @@
 fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                _body: ast::mac_body) -> @ast::expr {
     get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"line");
-    let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo);
+    let loc = cx.codemap().lookup_char_pos(sp.lo);
     return mk_uint(cx, sp, loc.line);
 }
 
@@ -24,8 +24,8 @@ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
 fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
               _body: ast::mac_body) -> @ast::expr {
     get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"col");
-    let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo);
-    return mk_uint(cx, sp, loc.col);
+    let loc = cx.codemap().lookup_char_pos(sp.lo);
+    return mk_uint(cx, sp, loc.col.to_uint());
 }
 
 /* file!(): expands to the current filename */
@@ -34,8 +34,8 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
 fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                _body: ast::mac_body) -> @ast::expr {
     get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"file");
-    let { file: @{ name: filename, _ }, _ } =
-        codemap::lookup_char_pos(cx.codemap(), sp.lo);
+    let Loc { file: @FileMap { name: filename, _ }, _ } =
+        cx.codemap().lookup_char_pos(sp.lo);
     return mk_uniq_str(cx, sp, filename);
 }
 
@@ -103,7 +103,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
 fn res_rel_file(cx: ext_ctxt, sp: codemap::span, arg: &Path) -> Path {
     // NB: relative paths are resolved relative to the compilation unit
     if !arg.is_absolute {
-        let cu = Path(codemap::span_to_filename(sp, cx.codemap()));
+        let cu = Path(cx.codemap().span_to_filename(sp));
         cu.dir_path().push_many(arg.components)
     } else {
         copy *arg