Skip to content

Commit 0133fb7

Browse files
committed
---
yaml --- r: 14028 b: refs/heads/try c: 1c91fb4 h: refs/heads/master v: v3
1 parent 184134f commit 0133fb7

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 4616117f171d96faa6027f89f4d8697815e14566
5+
refs/heads/try: 1c91fb4d91623bd50901ca4f4f215c928790e996
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/driver/diagnostic.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,7 @@ fn emit(cmsp: option<(codemap::codemap, span)>,
189189
fn highlight_lines(cm: codemap::codemap, sp: span,
190190
lines: @codemap::file_lines) {
191191

192-
// If we're not looking at a real file then we can't re-open it to
193-
// pull out the lines
194-
if lines.name == "-" { ret; }
195-
196-
let fm = codemap::get_filemap(cm, lines.name);
192+
let fm = lines.file;
197193

198194
// arbitrarily only print up to six lines of the error
199195
let max_lines = 6u;

branches/try/src/comp/middle/debuginfo.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn create_block(cx: @block_ctxt) -> @metadata<block_md> {
238238

239239
let start = codemap::lookup_char_pos(bcx_ccx(cx).sess.codemap,
240240
sp.lo);
241-
let fname = start.filename;
241+
let fname = start.file.name;
242242
let end = codemap::lookup_char_pos(bcx_ccx(cx).sess.codemap,
243243
sp.hi);
244244
let tg = LexicalBlockTag;
@@ -632,8 +632,8 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
632632
};
633633
}
634634

635-
fn filename_from_span(cx: @crate_ctxt, sp: span) -> str {
636-
codemap::lookup_char_pos(cx.sess.codemap, sp.lo).filename
635+
fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> str {
636+
codemap::lookup_char_pos(cx.sess.codemap, sp.lo).file.name
637637
}
638638

639639
fn create_var(type_tag: int, context: ValueRef, name: str, file: ValueRef,
@@ -670,7 +670,7 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
670670
local.span.lo);
671671
let ty = node_id_type(bcx, local.node.id);
672672
let tymd = create_ty(cx, ty, local.node.ty);
673-
let filemd = create_file(cx, loc.filename);
673+
let filemd = create_file(cx, loc.file.name);
674674
let context = alt bcx.parent {
675675
parent_none { create_function(bcx.fcx).node }
676676
parent_some(_) { create_block(bcx).node }
@@ -719,7 +719,7 @@ fn create_arg(bcx: @block_ctxt, arg: ast::arg, sp: span)
719719
sp.lo);
720720
let ty = node_id_type(bcx, arg.id);
721721
let tymd = create_ty(cx, ty, arg.ty);
722-
let filemd = create_file(cx, loc.filename);
722+
let filemd = create_file(cx, loc.file.name);
723723
let context = create_function(bcx.fcx);
724724
let mdnode = create_var(tg, context.node, arg.ident, filemd.node,
725725
loc.line as int, tymd.node);
@@ -812,7 +812,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
812812

813813
let loc = codemap::lookup_char_pos(cx.sess.codemap,
814814
sp.lo);
815-
let file_node = create_file(cx, loc.filename).node;
815+
let file_node = create_file(cx, loc.file.name).node;
816816
let key = if cx.item_symbols.contains_key(fcx.id) { fcx.id } else { id };
817817
let mangled = cx.item_symbols.get(key);
818818
let ty_node = if cx.sess.opts.extra_debuginfo {

branches/try/src/comp/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3848,7 +3848,7 @@ fn trans_fail_value(bcx: @block_ctxt, sp_opt: option<span>,
38483848
some(sp) {
38493849
let sess = bcx_ccx(bcx).sess;
38503850
let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo);
3851-
V_filename = C_cstr(bcx_ccx(bcx), loc.filename);
3851+
V_filename = C_cstr(bcx_ccx(bcx), loc.file.name);
38523852
V_line = loc.line as int;
38533853
}
38543854
none { V_filename = C_cstr(bcx_ccx(bcx), "<runtime>"); V_line = 0; }

branches/try/src/comp/syntax/codemap.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ type filemap =
1616

1717
type codemap = @{mutable files: [filemap]};
1818

19-
type loc = {filename: filename, line: uint, col: uint};
19+
type loc = {file: filemap, line: uint, col: uint};
2020

21-
fn new_codemap() -> codemap { ret @{mutable files: []}; }
21+
fn new_codemap() -> codemap {
22+
@{mutable files: [new_filemap("-", @"", 0u, 0u)]}
23+
}
2224

2325
fn new_filemap(filename: filename, src: @str,
2426
start_pos_ch: uint, start_pos_byte: uint)
@@ -28,6 +30,8 @@ fn new_filemap(filename: filename, src: @str,
2830
mutable lines: [{ch: start_pos_ch, byte: start_pos_byte}]};
2931
}
3032

33+
fn empty_filemap(cm: codemap) -> filemap {cm.files[0]}
34+
3135
fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
3236
file.lines += [{ch: chpos, byte: byte_pos}];
3337
}
@@ -60,10 +64,10 @@ fn lookup_line(map: codemap, pos: uint, lookup: lookup_fn)
6064
fn lookup_pos(map: codemap, pos: uint, lookup: lookup_fn) -> loc {
6165
alt lookup_line(map, pos, lookup) {
6266
some({fm: f, line: a}) {
63-
{filename: f.name, line: a + 1u, col: pos - lookup(f.lines[a])}
67+
{file: f, line: a + 1u, col: pos - lookup(f.lines[a])}
6468
}
6569
none {
66-
{ filename: "-", line: 0u, col: 0u }
70+
{ file: empty_filemap(map), line: 0u, col: 0u }
6771
}
6872
}
6973
}
@@ -89,20 +93,21 @@ type span = {lo: uint, hi: uint, expanded_from: opt_span};
8993
fn span_to_str(sp: span, cm: codemap) -> str {
9094
let cur = sp;
9195
let res = "";
96+
// FIXME: Should probably be doing pointer comparison on filemap
9297
let prev_file = none;
9398
while true {
9499
let lo = lookup_char_pos(cm, cur.lo);
95100
let hi = lookup_char_pos(cm, cur.hi);
96101
res +=
97102
#fmt["%s:%u:%u: %u:%u",
98-
if some(lo.filename) == prev_file {
103+
if some(lo.file.name) == prev_file {
99104
"-"
100-
} else { lo.filename }, lo.line, lo.col, hi.line, hi.col];
105+
} else { lo.file.name }, lo.line, lo.col, hi.line, hi.col];
101106
alt cur.expanded_from {
102107
os_none { break; }
103108
os_some(new_sp) {
104109
cur = *new_sp;
105-
prev_file = some(lo.filename);
110+
prev_file = some(lo.file.name);
106111
res += "<<";
107112
}
108113
}
@@ -111,14 +116,15 @@ fn span_to_str(sp: span, cm: codemap) -> str {
111116
ret res;
112117
}
113118

114-
type file_lines = {name: str, lines: [uint]};
119+
type file_lines = {file: filemap, lines: [uint]};
115120

116121
fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
117122
let lo = lookup_char_pos(cm, sp.lo);
118123
let hi = lookup_char_pos(cm, sp.hi);
124+
// FIXME: Check for filemap?
119125
let lines = [];
120126
uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
121-
ret @{name: lo.filename, lines: lines};
127+
ret @{file: lo.file, lines: lines};
122128
}
123129

124130
fn get_line(fm: filemap, line: int) -> str unsafe {

0 commit comments

Comments
 (0)