Mercurial > projects > dang
view misc/Location.d @ 29:41d23f2762c3 new_gen
Merge, and updated Error class
Usage is something like:
---
auto e = new Error("No conversion between %0 and %1);
e.arg(t1).arg(t2);
e.loc(exp.location);
---
Multiple locations can be given, to do clang like errors in the future
author | Anders Halager <halager@gmail.com> |
---|---|
date | Sun, 20 Apr 2008 11:47:34 +0200 |
parents | 2d28b21faad6 |
children |
line wrap: on
line source
module misc.Location; import misc.DataSource; import tango.text.convert.Integer, tango.text.Util; struct Location { uint position; DataSource source; char[] toString () { int lineNumber = 0; char[] end_line; foreach (line; lines(source.get(0, position))) { ++lineNumber; end_line = line; } return source.name ~ "(" ~ .toString(lineNumber) ~ ":" ~ .toString(end_line.length) ~ ")"; } char[] get(uint length) { return source.get(position, length); } }