2012-12-03 18:48:01 -06: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 16:41:37 -06:00
|
|
|
use ast;
|
2013-08-31 11:13:04 -05:00
|
|
|
use codemap::Span;
|
2013-05-17 06:27:17 -05:00
|
|
|
use ext::base::ExtCtxt;
|
2013-01-08 21:37:25 -06:00
|
|
|
use ext::base;
|
2014-03-18 07:14:08 -05:00
|
|
|
use parse::token::{keywords, is_keyword};
|
2012-08-15 12:45:10 -05:00
|
|
|
|
2014-05-05 20:56:44 -05:00
|
|
|
|
2013-12-28 23:06:22 -06:00
|
|
|
pub fn expand_trace_macros(cx: &mut ExtCtxt,
|
2013-08-31 11:13:04 -05:00
|
|
|
sp: Span,
|
2014-01-09 07:05:33 -06:00
|
|
|
tt: &[ast::TokenTree])
|
2014-08-27 20:46:52 -05:00
|
|
|
-> Box<base::MacResult+'static> {
|
2014-03-18 07:14:08 -05:00
|
|
|
match tt {
|
|
|
|
[ast::TTTok(_, ref tok)] if is_keyword(keywords::True, tok) => {
|
|
|
|
cx.set_trace_macros(true);
|
|
|
|
}
|
|
|
|
[ast::TTTok(_, ref tok)] if is_keyword(keywords::False, tok) => {
|
|
|
|
cx.set_trace_macros(false);
|
|
|
|
}
|
|
|
|
_ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),
|
2012-08-15 12:45:10 -05:00
|
|
|
}
|
2012-11-26 21:12:31 -06:00
|
|
|
|
2014-04-15 07:00:14 -05:00
|
|
|
base::DummyResult::any(sp)
|
2012-08-15 12:45:10 -05:00
|
|
|
}
|