syntax::diagnostic: Remove unnecessary traits
This removes trait `handler` and `span_handler`, and renames `HandlerT` to `Handler`, `CodemapT` to `SpanHandler`.
This commit is contained in:
parent
a52cdfdfce
commit
fe10c63326
16 changed files with 74 additions and 103 deletions
|
@ -883,7 +883,7 @@ pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
|
||||||
pub fn build_session_(sopts: @session::options,
|
pub fn build_session_(sopts: @session::options,
|
||||||
cm: @codemap::CodeMap,
|
cm: @codemap::CodeMap,
|
||||||
demitter: @diagnostic::Emitter,
|
demitter: @diagnostic::Emitter,
|
||||||
span_diagnostic_handler: @mut diagnostic::span_handler)
|
span_diagnostic_handler: @mut diagnostic::SpanHandler)
|
||||||
-> Session {
|
-> Session {
|
||||||
let target_cfg = build_target_config(sopts, demitter);
|
let target_cfg = build_target_config(sopts, demitter);
|
||||||
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
|
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
|
||||||
|
|
|
@ -209,7 +209,7 @@ pub struct Session_ {
|
||||||
// For a library crate, this is always none
|
// For a library crate, this is always none
|
||||||
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
||||||
entry_type: Cell<Option<EntryFnType>>,
|
entry_type: Cell<Option<EntryFnType>>,
|
||||||
span_diagnostic: @mut diagnostic::span_handler,
|
span_diagnostic: @mut diagnostic::SpanHandler,
|
||||||
filesearch: @filesearch::FileSearch,
|
filesearch: @filesearch::FileSearch,
|
||||||
building_library: Cell<bool>,
|
building_library: Cell<bool>,
|
||||||
working_dir: Path,
|
working_dir: Path,
|
||||||
|
@ -292,7 +292,7 @@ impl Session_ {
|
||||||
|
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
pub fn diagnostic(&self) -> @mut diagnostic::span_handler {
|
pub fn diagnostic(&self) -> @mut diagnostic::SpanHandler {
|
||||||
self.span_diagnostic
|
self.span_diagnostic
|
||||||
}
|
}
|
||||||
pub fn debugging_opt(&self, opt: uint) -> bool {
|
pub fn debugging_opt(&self, opt: uint) -> bool {
|
||||||
|
|
|
@ -22,7 +22,7 @@ use syntax::abi;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::codemap::{Span, dummy_sp};
|
use syntax::codemap::{Span, dummy_sp};
|
||||||
use syntax::diagnostic::span_handler;
|
use syntax::diagnostic::SpanHandler;
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use syntax::parse::token::ident_interner;
|
use syntax::parse::token::ident_interner;
|
||||||
use syntax::crateid::CrateId;
|
use syntax::crateid::CrateId;
|
||||||
|
@ -86,7 +86,7 @@ fn dump_crates(crate_cache: &[cache_entry]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn warn_if_multiple_versions(e: &mut Env,
|
fn warn_if_multiple_versions(e: &mut Env,
|
||||||
diag: @mut span_handler,
|
diag: @mut SpanHandler,
|
||||||
crate_cache: &[cache_entry]) {
|
crate_cache: &[cache_entry]) {
|
||||||
if crate_cache.len() != 0u {
|
if crate_cache.len() != 0u {
|
||||||
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
|
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
|
||||||
|
|
|
@ -39,7 +39,7 @@ use syntax::ast_map;
|
||||||
use syntax::ast_util::*;
|
use syntax::ast_util::*;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::diagnostic::span_handler;
|
use syntax::diagnostic::SpanHandler;
|
||||||
use syntax::parse::token::special_idents;
|
use syntax::parse::token::special_idents;
|
||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use syntax::visit::Visitor;
|
use syntax::visit::Visitor;
|
||||||
|
@ -57,7 +57,7 @@ pub type encode_inlined_item<'a> = 'a |ecx: &EncodeContext,
|
||||||
ii: ast::inlined_item|;
|
ii: ast::inlined_item|;
|
||||||
|
|
||||||
pub struct EncodeParams<'a> {
|
pub struct EncodeParams<'a> {
|
||||||
diag: @mut span_handler,
|
diag: @mut SpanHandler,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
reexports2: middle::resolve::ExportMap2,
|
reexports2: middle::resolve::ExportMap2,
|
||||||
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
|
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
|
||||||
|
@ -83,7 +83,7 @@ struct Stats {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EncodeContext<'a> {
|
pub struct EncodeContext<'a> {
|
||||||
diag: @mut span_handler,
|
diag: @mut SpanHandler,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
stats: @Stats,
|
stats: @Stats,
|
||||||
reexports2: middle::resolve::ExportMap2,
|
reexports2: middle::resolve::ExportMap2,
|
||||||
|
|
|
@ -19,7 +19,7 @@ use metadata::encoder;
|
||||||
use metadata::filesearch::{FileMatches, FileDoesntMatch};
|
use metadata::filesearch::{FileMatches, FileDoesntMatch};
|
||||||
use metadata::filesearch;
|
use metadata::filesearch;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::diagnostic::span_handler;
|
use syntax::diagnostic::SpanHandler;
|
||||||
use syntax::parse::token::ident_interner;
|
use syntax::parse::token::ident_interner;
|
||||||
use syntax::crateid::CrateId;
|
use syntax::crateid::CrateId;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
|
@ -231,7 +231,7 @@ impl Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn note_crateid_attr(diag: @mut span_handler,
|
pub fn note_crateid_attr(diag: @mut SpanHandler,
|
||||||
crateid: &CrateId) {
|
crateid: &CrateId) {
|
||||||
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
|
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ use middle::ty;
|
||||||
use syntax::abi::AbiSet;
|
use syntax::abi::AbiSet;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::*;
|
use syntax::ast::*;
|
||||||
use syntax::diagnostic::span_handler;
|
use syntax::diagnostic::SpanHandler;
|
||||||
use syntax::print::pprust::*;
|
use syntax::print::pprust::*;
|
||||||
|
|
||||||
macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
|
macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
|
||||||
|
@ -32,7 +32,7 @@ macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
|
||||||
) )
|
) )
|
||||||
|
|
||||||
pub struct ctxt {
|
pub struct ctxt {
|
||||||
diag: @mut span_handler,
|
diag: @mut SpanHandler,
|
||||||
// Def -> str Callback:
|
// Def -> str Callback:
|
||||||
ds: extern "Rust" fn(DefId) -> ~str,
|
ds: extern "Rust" fn(DefId) -> ~str,
|
||||||
// The type context.
|
// The type context.
|
||||||
|
|
|
@ -267,7 +267,7 @@ pub type ctxt = @ctxt_;
|
||||||
/// generates so that so that it can be reused and doesn't have to be redone
|
/// generates so that so that it can be reused and doesn't have to be redone
|
||||||
/// later on.
|
/// later on.
|
||||||
struct ctxt_ {
|
struct ctxt_ {
|
||||||
diag: @mut syntax::diagnostic::span_handler,
|
diag: @mut syntax::diagnostic::SpanHandler,
|
||||||
interner: RefCell<HashMap<intern_key, ~t_box_>>,
|
interner: RefCell<HashMap<intern_key, ~t_box_>>,
|
||||||
next_id: Cell<uint>,
|
next_id: Cell<uint>,
|
||||||
cstore: @metadata::cstore::CStore,
|
cstore: @metadata::cstore::CStore,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use ast_util::{inlined_item_utils, stmt_id};
|
||||||
use ast_util;
|
use ast_util;
|
||||||
use codemap::Span;
|
use codemap::Span;
|
||||||
use codemap;
|
use codemap;
|
||||||
use diagnostic::span_handler;
|
use diagnostic::SpanHandler;
|
||||||
use parse::token::get_ident_interner;
|
use parse::token::get_ident_interner;
|
||||||
use parse::token::ident_interner;
|
use parse::token::ident_interner;
|
||||||
use parse::token::special_idents;
|
use parse::token::special_idents;
|
||||||
|
@ -152,7 +152,7 @@ pub type map = @mut HashMap<NodeId, ast_node>;
|
||||||
pub struct Ctx {
|
pub struct Ctx {
|
||||||
map: map,
|
map: map,
|
||||||
path: path,
|
path: path,
|
||||||
diag: @mut span_handler,
|
diag: @mut SpanHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ctx {
|
impl Ctx {
|
||||||
|
@ -373,7 +373,7 @@ impl Visitor<()> for Ctx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_crate(diag: @mut span_handler, c: &Crate) -> map {
|
pub fn map_crate(diag: @mut SpanHandler, c: &Crate) -> map {
|
||||||
let cx = @mut Ctx {
|
let cx = @mut Ctx {
|
||||||
map: @mut HashMap::new(),
|
map: @mut HashMap::new(),
|
||||||
path: ~[],
|
path: ~[],
|
||||||
|
@ -386,7 +386,7 @@ pub fn map_crate(diag: @mut span_handler, c: &Crate) -> map {
|
||||||
// Used for items loaded from external crate that are being inlined into this
|
// Used for items loaded from external crate that are being inlined into this
|
||||||
// crate. The `path` should be the path to the item but should not include
|
// crate. The `path` should be the path to the item but should not include
|
||||||
// the item itself.
|
// the item itself.
|
||||||
pub fn map_decoded_item(diag: @mut span_handler,
|
pub fn map_decoded_item(diag: @mut SpanHandler,
|
||||||
map: map,
|
map: map,
|
||||||
path: path,
|
path: path,
|
||||||
ii: &inlined_item) {
|
ii: &inlined_item) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use ast;
|
||||||
use ast::{Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};
|
use ast::{Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};
|
||||||
use codemap::{Span, Spanned, spanned, dummy_spanned};
|
use codemap::{Span, Spanned, spanned, dummy_spanned};
|
||||||
use codemap::BytePos;
|
use codemap::BytePos;
|
||||||
use diagnostic::span_handler;
|
use diagnostic::SpanHandler;
|
||||||
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
|
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
|
||||||
use crateid::CrateId;
|
use crateid::CrateId;
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ pub fn find_stability<AM: AttrMetaMethods, It: Iterator<AM>>(mut metas: It) -> O
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn require_unique_names(diagnostic: @mut span_handler,
|
pub fn require_unique_names(diagnostic: @mut SpanHandler,
|
||||||
metas: &[@MetaItem]) {
|
metas: &[@MetaItem]) {
|
||||||
let mut set = HashSet::new();
|
let mut set = HashSet::new();
|
||||||
for meta in metas.iter() {
|
for meta in metas.iter() {
|
||||||
|
@ -381,7 +381,7 @@ pub fn require_unique_names(diagnostic: @mut span_handler,
|
||||||
* present (before fields, if any) with that type; reprensentation
|
* present (before fields, if any) with that type; reprensentation
|
||||||
* optimizations which would remove it will not be done.
|
* optimizations which would remove it will not be done.
|
||||||
*/
|
*/
|
||||||
pub fn find_repr_attr(diagnostic: @mut span_handler, attr: @ast::MetaItem, acc: ReprAttr)
|
pub fn find_repr_attr(diagnostic: @mut SpanHandler, attr: @ast::MetaItem, acc: ReprAttr)
|
||||||
-> ReprAttr {
|
-> ReprAttr {
|
||||||
let mut acc = acc;
|
let mut acc = acc;
|
||||||
match attr.node {
|
match attr.node {
|
||||||
|
|
|
@ -26,95 +26,67 @@ pub trait Emitter {
|
||||||
lvl: level);
|
lvl: level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// a handler deals with errors; certain errors
|
|
||||||
// (fatal, bug, unimpl) may cause immediate exit,
|
|
||||||
// others log errors for later reporting.
|
|
||||||
pub trait handler {
|
|
||||||
fn fatal(@mut self, msg: &str) -> !;
|
|
||||||
fn err(@mut self, msg: &str);
|
|
||||||
fn bump_err_count(@mut self);
|
|
||||||
fn err_count(@mut self) -> uint;
|
|
||||||
fn has_errors(@mut self) -> bool;
|
|
||||||
fn abort_if_errors(@mut self);
|
|
||||||
fn warn(@mut self, msg: &str);
|
|
||||||
fn note(@mut self, msg: &str);
|
|
||||||
// used to indicate a bug in the compiler:
|
|
||||||
fn bug(@mut self, msg: &str) -> !;
|
|
||||||
fn unimpl(@mut self, msg: &str) -> !;
|
|
||||||
fn emit(@mut self,
|
|
||||||
cmsp: Option<(@codemap::CodeMap, Span)>,
|
|
||||||
msg: &str,
|
|
||||||
lvl: level);
|
|
||||||
}
|
|
||||||
|
|
||||||
// a span-handler is like a handler but also
|
// a span-handler is like a handler but also
|
||||||
// accepts span information for source-location
|
// accepts span information for source-location
|
||||||
// reporting.
|
// reporting.
|
||||||
pub trait span_handler {
|
pub struct SpanHandler {
|
||||||
fn span_fatal(@mut self, sp: Span, msg: &str) -> !;
|
handler: @mut Handler,
|
||||||
fn span_err(@mut self, sp: Span, msg: &str);
|
|
||||||
fn span_warn(@mut self, sp: Span, msg: &str);
|
|
||||||
fn span_note(@mut self, sp: Span, msg: &str);
|
|
||||||
fn span_bug(@mut self, sp: Span, msg: &str) -> !;
|
|
||||||
fn span_unimpl(@mut self, sp: Span, msg: &str) -> !;
|
|
||||||
fn handler(@mut self) -> @mut handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct HandlerT {
|
|
||||||
err_count: uint,
|
|
||||||
emit: @Emitter,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CodemapT {
|
|
||||||
handler: @mut handler,
|
|
||||||
cm: @codemap::CodeMap,
|
cm: @codemap::CodeMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl span_handler for CodemapT {
|
impl SpanHandler {
|
||||||
fn span_fatal(@mut self, sp: Span, msg: &str) -> ! {
|
pub fn span_fatal(@mut self, sp: Span, msg: &str) -> ! {
|
||||||
self.handler.emit(Some((self.cm, sp)), msg, fatal);
|
self.handler.emit(Some((self.cm, sp)), msg, fatal);
|
||||||
fail!();
|
fail!();
|
||||||
}
|
}
|
||||||
fn span_err(@mut self, sp: Span, msg: &str) {
|
pub fn span_err(@mut self, sp: Span, msg: &str) {
|
||||||
self.handler.emit(Some((self.cm, sp)), msg, error);
|
self.handler.emit(Some((self.cm, sp)), msg, error);
|
||||||
self.handler.bump_err_count();
|
self.handler.bump_err_count();
|
||||||
}
|
}
|
||||||
fn span_warn(@mut self, sp: Span, msg: &str) {
|
pub fn span_warn(@mut self, sp: Span, msg: &str) {
|
||||||
self.handler.emit(Some((self.cm, sp)), msg, warning);
|
self.handler.emit(Some((self.cm, sp)), msg, warning);
|
||||||
}
|
}
|
||||||
fn span_note(@mut self, sp: Span, msg: &str) {
|
pub fn span_note(@mut self, sp: Span, msg: &str) {
|
||||||
self.handler.emit(Some((self.cm, sp)), msg, note);
|
self.handler.emit(Some((self.cm, sp)), msg, note);
|
||||||
}
|
}
|
||||||
fn span_bug(@mut self, sp: Span, msg: &str) -> ! {
|
pub fn span_bug(@mut self, sp: Span, msg: &str) -> ! {
|
||||||
self.span_fatal(sp, ice_msg(msg));
|
self.span_fatal(sp, ice_msg(msg));
|
||||||
}
|
}
|
||||||
fn span_unimpl(@mut self, sp: Span, msg: &str) -> ! {
|
pub fn span_unimpl(@mut self, sp: Span, msg: &str) -> ! {
|
||||||
self.span_bug(sp, ~"unimplemented " + msg);
|
self.span_bug(sp, ~"unimplemented " + msg);
|
||||||
}
|
}
|
||||||
fn handler(@mut self) -> @mut handler {
|
pub fn handler(@mut self) -> @mut Handler {
|
||||||
self.handler
|
self.handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl handler for HandlerT {
|
// a handler deals with errors; certain errors
|
||||||
fn fatal(@mut self, msg: &str) -> ! {
|
// (fatal, bug, unimpl) may cause immediate exit,
|
||||||
|
// others log errors for later reporting.
|
||||||
|
pub struct Handler {
|
||||||
|
err_count: uint,
|
||||||
|
emit: @Emitter,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Handler {
|
||||||
|
pub fn fatal(@mut self, msg: &str) -> ! {
|
||||||
self.emit.emit(None, msg, fatal);
|
self.emit.emit(None, msg, fatal);
|
||||||
fail!();
|
fail!();
|
||||||
}
|
}
|
||||||
fn err(@mut self, msg: &str) {
|
pub fn err(@mut self, msg: &str) {
|
||||||
self.emit.emit(None, msg, error);
|
self.emit.emit(None, msg, error);
|
||||||
self.bump_err_count();
|
self.bump_err_count();
|
||||||
}
|
}
|
||||||
fn bump_err_count(@mut self) {
|
pub fn bump_err_count(@mut self) {
|
||||||
self.err_count += 1u;
|
self.err_count += 1u;
|
||||||
}
|
}
|
||||||
fn err_count(@mut self) -> uint {
|
pub fn err_count(@mut self) -> uint {
|
||||||
self.err_count
|
self.err_count
|
||||||
}
|
}
|
||||||
fn has_errors(@mut self) -> bool {
|
pub fn has_errors(@mut self) -> bool {
|
||||||
self.err_count > 0u
|
self.err_count > 0u
|
||||||
}
|
}
|
||||||
fn abort_if_errors(@mut self) {
|
pub fn abort_if_errors(@mut self) {
|
||||||
let s;
|
let s;
|
||||||
match self.err_count {
|
match self.err_count {
|
||||||
0u => return,
|
0u => return,
|
||||||
|
@ -126,19 +98,19 @@ impl handler for HandlerT {
|
||||||
}
|
}
|
||||||
self.fatal(s);
|
self.fatal(s);
|
||||||
}
|
}
|
||||||
fn warn(@mut self, msg: &str) {
|
pub fn warn(@mut self, msg: &str) {
|
||||||
self.emit.emit(None, msg, warning);
|
self.emit.emit(None, msg, warning);
|
||||||
}
|
}
|
||||||
fn note(@mut self, msg: &str) {
|
pub fn note(@mut self, msg: &str) {
|
||||||
self.emit.emit(None, msg, note);
|
self.emit.emit(None, msg, note);
|
||||||
}
|
}
|
||||||
fn bug(@mut self, msg: &str) -> ! {
|
pub fn bug(@mut self, msg: &str) -> ! {
|
||||||
self.fatal(ice_msg(msg));
|
self.fatal(ice_msg(msg));
|
||||||
}
|
}
|
||||||
fn unimpl(@mut self, msg: &str) -> ! {
|
pub fn unimpl(@mut self, msg: &str) -> ! {
|
||||||
self.bug(~"unimplemented " + msg);
|
self.bug(~"unimplemented " + msg);
|
||||||
}
|
}
|
||||||
fn emit(@mut self,
|
pub fn emit(@mut self,
|
||||||
cmsp: Option<(@codemap::CodeMap, Span)>,
|
cmsp: Option<(@codemap::CodeMap, Span)>,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
lvl: level) {
|
lvl: level) {
|
||||||
|
@ -151,24 +123,24 @@ pub fn ice_msg(msg: &str) -> ~str {
|
||||||
\nWe would appreciate a bug report: {}", msg, BUG_REPORT_URL)
|
\nWe would appreciate a bug report: {}", msg, BUG_REPORT_URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_span_handler(handler: @mut handler, cm: @codemap::CodeMap)
|
pub fn mk_span_handler(handler: @mut Handler, cm: @codemap::CodeMap)
|
||||||
-> @mut span_handler {
|
-> @mut SpanHandler {
|
||||||
@mut CodemapT {
|
@mut SpanHandler {
|
||||||
handler: handler,
|
handler: handler,
|
||||||
cm: cm,
|
cm: cm,
|
||||||
} as @mut span_handler
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_handler(emitter: Option<@Emitter>) -> @mut handler {
|
pub fn mk_handler(emitter: Option<@Emitter>) -> @mut Handler {
|
||||||
let emit: @Emitter = match emitter {
|
let emit: @Emitter = match emitter {
|
||||||
Some(e) => e,
|
Some(e) => e,
|
||||||
None => @DefaultEmitter as @Emitter
|
None => @DefaultEmitter as @Emitter
|
||||||
};
|
};
|
||||||
|
|
||||||
@mut HandlerT {
|
@mut Handler {
|
||||||
err_count: 0,
|
err_count: 0,
|
||||||
emit: emit,
|
emit: emit,
|
||||||
} as @mut handler
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq)]
|
||||||
|
@ -356,7 +328,7 @@ fn print_macro_backtrace(cm: @codemap::CodeMap, sp: Span) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect<T:Clone>(
|
pub fn expect<T:Clone>(
|
||||||
diag: @mut span_handler,
|
diag: @mut SpanHandler,
|
||||||
opt: Option<T>,
|
opt: Option<T>,
|
||||||
msg: || -> ~str)
|
msg: || -> ~str)
|
||||||
-> T {
|
-> T {
|
||||||
|
|
|
@ -12,7 +12,6 @@ use ast;
|
||||||
use ast::Name;
|
use ast::Name;
|
||||||
use codemap;
|
use codemap;
|
||||||
use codemap::{CodeMap, Span, ExpnInfo};
|
use codemap::{CodeMap, Span, ExpnInfo};
|
||||||
use diagnostic::span_handler;
|
|
||||||
use ext;
|
use ext;
|
||||||
use ext::expand;
|
use ext::expand;
|
||||||
use parse;
|
use parse;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use ast;
|
use ast;
|
||||||
use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,Ident};
|
use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,Ident};
|
||||||
use codemap::{Span, dummy_sp};
|
use codemap::{Span, dummy_sp};
|
||||||
use diagnostic::span_handler;
|
use diagnostic::SpanHandler;
|
||||||
use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
|
use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
|
||||||
use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident};
|
use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident};
|
||||||
use parse::token::{ident_to_str};
|
use parse::token::{ident_to_str};
|
||||||
|
@ -30,7 +30,7 @@ struct TtFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TtReader {
|
pub struct TtReader {
|
||||||
sp_diag: @mut span_handler,
|
sp_diag: @mut SpanHandler,
|
||||||
// the unzipped tree:
|
// the unzipped tree:
|
||||||
stack: @mut TtFrame,
|
stack: @mut TtFrame,
|
||||||
/* for MBE-style macro transcription */
|
/* for MBE-style macro transcription */
|
||||||
|
@ -45,7 +45,7 @@ pub struct TtReader {
|
||||||
/** This can do Macro-By-Example transcription. On the other hand, if
|
/** This can do Macro-By-Example transcription. On the other hand, if
|
||||||
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
|
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
|
||||||
* should) be none. */
|
* should) be none. */
|
||||||
pub fn new_tt_reader(sp_diag: @mut span_handler,
|
pub fn new_tt_reader(sp_diag: @mut SpanHandler,
|
||||||
interp: Option<HashMap<Ident,@named_match>>,
|
interp: Option<HashMap<Ident,@named_match>>,
|
||||||
src: ~[ast::token_tree])
|
src: ~[ast::token_tree])
|
||||||
-> @mut TtReader {
|
-> @mut TtReader {
|
||||||
|
|
|
@ -342,7 +342,7 @@ pub struct lit {
|
||||||
// it appears this function is called only from pprust... that's
|
// it appears this function is called only from pprust... that's
|
||||||
// probably not a good thing.
|
// probably not a good thing.
|
||||||
pub fn gather_comments_and_literals(span_diagnostic:
|
pub fn gather_comments_and_literals(span_diagnostic:
|
||||||
@mut diagnostic::span_handler,
|
@mut diagnostic::SpanHandler,
|
||||||
path: @str,
|
path: @str,
|
||||||
srdr: &mut io::Reader)
|
srdr: &mut io::Reader)
|
||||||
-> (~[cmnt], ~[lit]) {
|
-> (~[cmnt], ~[lit]) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use ast;
|
use ast;
|
||||||
use codemap::{BytePos, CharPos, CodeMap, Pos, Span};
|
use codemap::{BytePos, CharPos, CodeMap, Pos, Span};
|
||||||
use codemap;
|
use codemap;
|
||||||
use diagnostic::span_handler;
|
use diagnostic::SpanHandler;
|
||||||
use ext::tt::transcribe::{tt_next_token};
|
use ext::tt::transcribe::{tt_next_token};
|
||||||
use ext::tt::transcribe::{dup_tt_reader};
|
use ext::tt::transcribe::{dup_tt_reader};
|
||||||
use parse::token;
|
use parse::token;
|
||||||
|
@ -29,7 +29,7 @@ pub trait reader {
|
||||||
fn is_eof(@mut self) -> bool;
|
fn is_eof(@mut self) -> bool;
|
||||||
fn next_token(@mut self) -> TokenAndSpan;
|
fn next_token(@mut self) -> TokenAndSpan;
|
||||||
fn fatal(@mut self, ~str) -> !;
|
fn fatal(@mut self, ~str) -> !;
|
||||||
fn span_diag(@mut self) -> @mut span_handler;
|
fn span_diag(@mut self) -> @mut SpanHandler;
|
||||||
fn peek(@mut self) -> TokenAndSpan;
|
fn peek(@mut self) -> TokenAndSpan;
|
||||||
fn dup(@mut self) -> @mut reader;
|
fn dup(@mut self) -> @mut reader;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ pub struct TokenAndSpan {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StringReader {
|
pub struct StringReader {
|
||||||
span_diagnostic: @mut span_handler,
|
span_diagnostic: @mut SpanHandler,
|
||||||
src: @str,
|
src: @str,
|
||||||
// The absolute offset within the codemap of the next character to read
|
// The absolute offset within the codemap of the next character to read
|
||||||
pos: BytePos,
|
pos: BytePos,
|
||||||
|
@ -57,7 +57,7 @@ pub struct StringReader {
|
||||||
peek_span: Span
|
peek_span: Span
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_string_reader(span_diagnostic: @mut span_handler,
|
pub fn new_string_reader(span_diagnostic: @mut SpanHandler,
|
||||||
filemap: @codemap::FileMap)
|
filemap: @codemap::FileMap)
|
||||||
-> @mut StringReader {
|
-> @mut StringReader {
|
||||||
let r = new_low_level_string_reader(span_diagnostic, filemap);
|
let r = new_low_level_string_reader(span_diagnostic, filemap);
|
||||||
|
@ -66,7 +66,7 @@ pub fn new_string_reader(span_diagnostic: @mut span_handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For comments.rs, which hackily pokes into 'pos' and 'curr' */
|
/* For comments.rs, which hackily pokes into 'pos' and 'curr' */
|
||||||
pub fn new_low_level_string_reader(span_diagnostic: @mut span_handler,
|
pub fn new_low_level_string_reader(span_diagnostic: @mut SpanHandler,
|
||||||
filemap: @codemap::FileMap)
|
filemap: @codemap::FileMap)
|
||||||
-> @mut StringReader {
|
-> @mut StringReader {
|
||||||
// Force the initial reader bump to start on a fresh line
|
// Force the initial reader bump to start on a fresh line
|
||||||
|
@ -118,7 +118,7 @@ impl reader for StringReader {
|
||||||
fn fatal(@mut self, m: ~str) -> ! {
|
fn fatal(@mut self, m: ~str) -> ! {
|
||||||
self.span_diagnostic.span_fatal(self.peek_span, m)
|
self.span_diagnostic.span_fatal(self.peek_span, m)
|
||||||
}
|
}
|
||||||
fn span_diag(@mut self) -> @mut span_handler { self.span_diagnostic }
|
fn span_diag(@mut self) -> @mut SpanHandler { self.span_diagnostic }
|
||||||
fn peek(@mut self) -> TokenAndSpan {
|
fn peek(@mut self) -> TokenAndSpan {
|
||||||
// XXX(pcwalton): Bad copy!
|
// XXX(pcwalton): Bad copy!
|
||||||
TokenAndSpan {
|
TokenAndSpan {
|
||||||
|
@ -139,7 +139,7 @@ impl reader for TtReader {
|
||||||
fn fatal(@mut self, m: ~str) -> ! {
|
fn fatal(@mut self, m: ~str) -> ! {
|
||||||
self.sp_diag.span_fatal(self.cur_span, m);
|
self.sp_diag.span_fatal(self.cur_span, m);
|
||||||
}
|
}
|
||||||
fn span_diag(@mut self) -> @mut span_handler { self.sp_diag }
|
fn span_diag(@mut self) -> @mut SpanHandler { self.sp_diag }
|
||||||
fn peek(@mut self) -> TokenAndSpan {
|
fn peek(@mut self) -> TokenAndSpan {
|
||||||
TokenAndSpan {
|
TokenAndSpan {
|
||||||
tok: self.cur_tok.clone(),
|
tok: self.cur_tok.clone(),
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
use ast;
|
use ast;
|
||||||
use codemap::{Span, CodeMap, FileMap, FileSubstr};
|
use codemap::{Span, CodeMap, FileMap, FileSubstr};
|
||||||
use codemap;
|
use codemap;
|
||||||
use diagnostic::{span_handler, mk_span_handler, mk_handler, Emitter};
|
use diagnostic::{SpanHandler, mk_span_handler, mk_handler, Emitter};
|
||||||
use parse::attr::parser_attr;
|
use parse::attr::parser_attr;
|
||||||
use parse::lexer::reader;
|
use parse::lexer::reader;
|
||||||
use parse::parser::Parser;
|
use parse::parser::Parser;
|
||||||
|
@ -41,7 +41,7 @@ pub mod obsolete;
|
||||||
// info about a parsing session.
|
// info about a parsing session.
|
||||||
pub struct ParseSess {
|
pub struct ParseSess {
|
||||||
cm: @codemap::CodeMap, // better be the same as the one in the reader!
|
cm: @codemap::CodeMap, // better be the same as the one in the reader!
|
||||||
span_diagnostic: @mut span_handler, // better be the same as the one in the reader!
|
span_diagnostic: @mut SpanHandler, // better be the same as the one in the reader!
|
||||||
/// Used to determine and report recursive mod inclusions
|
/// Used to determine and report recursive mod inclusions
|
||||||
included_mod_stack: ~[Path],
|
included_mod_stack: ~[Path],
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ pub fn new_parse_sess(demitter: Option<@Emitter>) -> @mut ParseSess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_parse_sess_special_handler(sh: @mut span_handler,
|
pub fn new_parse_sess_special_handler(sh: @mut SpanHandler,
|
||||||
cm: @codemap::CodeMap)
|
cm: @codemap::CodeMap)
|
||||||
-> @mut ParseSess {
|
-> @mut ParseSess {
|
||||||
@mut ParseSess {
|
@mut ParseSess {
|
||||||
|
|
|
@ -118,7 +118,7 @@ pub static default_columns: uint = 78u;
|
||||||
// copy forward.
|
// copy forward.
|
||||||
pub fn print_crate(cm: @CodeMap,
|
pub fn print_crate(cm: @CodeMap,
|
||||||
intr: @ident_interner,
|
intr: @ident_interner,
|
||||||
span_diagnostic: @mut diagnostic::span_handler,
|
span_diagnostic: @mut diagnostic::SpanHandler,
|
||||||
crate: &ast::Crate,
|
crate: &ast::Crate,
|
||||||
filename: @str,
|
filename: @str,
|
||||||
input: @mut io::Reader,
|
input: @mut io::Reader,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue