Inject "core macros" into default syntax-expansion environment. Bit of a kludge but enough to work on logging-via-macros.

This commit is contained in:
Graydon Hoare
2011-12-20 13:38:10 -08:00
parent a24c19e867
commit 3bc4da96f1
4 changed files with 48 additions and 21 deletions

View File

@@ -34,12 +34,16 @@ fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
type lookup_fn = fn(file_pos) -> uint;
fn lookup_pos(map: codemap, pos: uint, lookup: lookup_fn) -> loc {
let len = vec::len(map.files);
let a = 0u;
let b = vec::len(map.files);
let b = len;
while b - a > 1u {
let m = (a + b) / 2u;
if lookup(map.files[m].start_pos) > pos { b = m; } else { a = m; }
}
if (a >= len) {
ret { filename: "-", line: 0u, col: 0u };
}
let f = map.files[a];
a = 0u;
b = vec::len(f.lines);