diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-02 15:34:58 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-02 22:11:42 -0700 |
| commit | 5c49e4f4e92997869de1f75f9089c9db7e7a6ebe (patch) | |
| tree | 947f6d58da06e589a0ab0627319917a9d2352a8c /src/comp/syntax/ext/base.rs | |
| parent | b5f905342337a3dc12bdc5dc6d98d3ecdf60439d (diff) | |
| download | rust-5c49e4f4e92997869de1f75f9089c9db7e7a6ebe.tar.gz rust-5c49e4f4e92997869de1f75f9089c9db7e7a6ebe.zip | |
Reformat. Issue #855
Diffstat (limited to 'src/comp/syntax/ext/base.rs')
| -rw-r--r-- | src/comp/syntax/ext/base.rs | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index 2dcc43ef178..298f90237bc 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -8,10 +8,10 @@ import std::map::new_str_hash; import codemap; type syntax_expander = - fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> @ast::expr; -type macro_def = {ident: istr, ext: syntax_extension}; + fn(&ext_ctxt, span, @ast::expr, &option::t<str>) -> @ast::expr; +type macro_def = {ident: str, ext: syntax_extension}; type macro_definer = - fn(&ext_ctxt, span, @ast::expr, &option::t<istr>) -> macro_def; + fn(&ext_ctxt, span, @ast::expr, &option::t<str>) -> macro_def; tag syntax_extension { normal(syntax_expander); @@ -20,25 +20,25 @@ tag syntax_extension { // A temporary hard-coded map of methods for expanding syntax extension // AST nodes into full ASTs -fn syntax_expander_table() -> hashmap<istr, syntax_extension> { +fn syntax_expander_table() -> hashmap<str, syntax_extension> { let syntax_expanders = new_str_hash::<syntax_extension>(); - syntax_expanders.insert(~"fmt", normal(ext::fmt::expand_syntax_ext)); - syntax_expanders.insert(~"env", normal(ext::env::expand_syntax_ext)); - syntax_expanders.insert(~"macro", + syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext)); + syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext)); + syntax_expanders.insert("macro", macro_defining(ext::simplext::add_new_extension)); - syntax_expanders.insert(~"concat_idents", + syntax_expanders.insert("concat_idents", normal(ext::concat_idents::expand_syntax_ext)); - syntax_expanders.insert(~"ident_to_str", + syntax_expanders.insert("ident_to_str", normal(ext::ident_to_str::expand_syntax_ext)); - syntax_expanders.insert(~"log_syntax", + syntax_expanders.insert("log_syntax", normal(ext::log_syntax::expand_syntax_ext)); ret syntax_expanders; } obj ext_ctxt(sess: @session, - crate_file_name_hack: istr, + crate_file_name_hack: str, mutable backtrace: codemap::opt_span) { - fn crate_file_name() -> istr { ret crate_file_name_hack; } + fn crate_file_name() -> str { ret crate_file_name_hack; } fn session() -> @session { ret sess; } @@ -58,30 +58,27 @@ obj ext_ctxt(sess: @session, let tmp = pre; backtrace = tmp; } - _ { self.bug(~"tried to pop without a push"); } + _ { self.bug("tried to pop without a push"); } } } - fn span_fatal(sp: span, msg: istr) -> ! { + fn span_fatal(sp: span, msg: str) -> ! { self.print_backtrace(); sess.span_fatal(sp, msg); } - fn span_err(sp: span, msg: istr) { + fn span_err(sp: span, msg: str) { self.print_backtrace(); sess.span_err(sp, msg); } - fn span_unimpl(sp: span, msg: istr) -> ! { + fn span_unimpl(sp: span, msg: str) -> ! { self.print_backtrace(); sess.span_unimpl(sp, msg); } - fn span_bug(sp: span, msg: istr) -> ! { + fn span_bug(sp: span, msg: str) -> ! { self.print_backtrace(); sess.span_bug(sp, msg); } - fn bug(msg: istr) -> ! { - self.print_backtrace(); - sess.bug(msg); - } + fn bug(msg: str) -> ! { self.print_backtrace(); sess.bug(msg); } fn next_id() -> ast::node_id { ret sess.next_node_id(); } } @@ -96,11 +93,10 @@ fn mk_ctxt(sess: &session) -> ext_ctxt { // super-ugly and needs a better solution. let crate_file_name_hack = sess.get_codemap().files[0].name; - ret ext_ctxt(@sess, crate_file_name_hack, - codemap::os_none); + ret ext_ctxt(@sess, crate_file_name_hack, codemap::os_none); } -fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: &istr) -> istr { +fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: &str) -> str { alt expr.node { ast::expr_lit(l) { alt l.node { @@ -112,8 +108,7 @@ fn expr_to_str(cx: &ext_ctxt, expr: @ast::expr, error: &istr) -> istr { } } -fn expr_to_ident(cx: &ext_ctxt, expr: @ast::expr, - error: &istr) -> ast::ident { +fn expr_to_ident(cx: &ext_ctxt, expr: @ast::expr, error: &str) -> ast::ident { alt expr.node { ast::expr_path(p) { if vec::len(p.node.types) > 0u || vec::len(p.node.idents) != 1u { |
