2012-12-03 16:48:01 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-12-23 17:41:37 -05:00
|
|
|
use ast;
|
2013-08-31 18:13:04 +02:00
|
|
|
use codemap::Span;
|
2013-05-17 21:27:17 +10:00
|
|
|
use ext::base::ExtCtxt;
|
2013-01-08 19:37:25 -08:00
|
|
|
use ext::base;
|
2014-10-27 23:33:30 +11:00
|
|
|
use parse::token::keywords;
|
2012-08-15 10:45:10 -07:00
|
|
|
|
2014-05-05 18:56:44 -07:00
|
|
|
|
2013-12-28 22:06:22 -07:00
|
|
|
pub fn expand_trace_macros(cx: &mut ExtCtxt,
|
2013-08-31 18:13:04 +02:00
|
|
|
sp: Span,
|
2014-01-09 15:05:33 +02:00
|
|
|
tt: &[ast::TokenTree])
|
2014-08-27 21:46:52 -04:00
|
|
|
-> Box<base::MacResult+'static> {
|
2014-03-18 23:14:08 +11:00
|
|
|
match tt {
|
2014-10-27 23:33:30 +11:00
|
|
|
[ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::True) => {
|
2014-03-18 23:14:08 +11:00
|
|
|
cx.set_trace_macros(true);
|
|
|
|
}
|
2014-10-27 23:33:30 +11:00
|
|
|
[ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::False) => {
|
2014-03-18 23:14:08 +11:00
|
|
|
cx.set_trace_macros(false);
|
|
|
|
}
|
|
|
|
_ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),
|
2012-08-15 10:45:10 -07:00
|
|
|
}
|
2012-11-26 22:12:31 -05:00
|
|
|
|
2014-04-15 22:00:14 +10:00
|
|
|
base::DummyResult::any(sp)
|
2012-08-15 10:45:10 -07:00
|
|
|
}
|