Skip to content

Commit

Permalink
libsyntax: De-export libsyntax. rs=deexporting
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Jan 29, 2013
1 parent a80a65b commit b070590
Show file tree
Hide file tree
Showing 22 changed files with 579 additions and 610 deletions.
7 changes: 2 additions & 5 deletions src/libsyntax/ext/auto_encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,13 @@ use core::vec;
use std::map;
use std::map::HashMap;

export expand_auto_encode;
export expand_auto_decode;

// Transitional reexports so qquote can find the paths it is looking for
mod syntax {
pub use ext;
pub use parse;
}

fn expand_auto_encode(
pub fn expand_auto_encode(
cx: ext_ctxt,
span: span,
_mitem: ast::meta_item,
Expand Down Expand Up @@ -165,7 +162,7 @@ fn expand_auto_encode(
}
}

fn expand_auto_decode(
pub fn expand_auto_decode(
cx: ext_ctxt,
span: span,
_mitem: ast::meta_item,
Expand Down
48 changes: 25 additions & 23 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,38 @@ use std::map::HashMap;
// is now probably a redundant AST node, can be merged with
// ast::mac_invoc_tt.

struct MacroDef {
pub struct MacroDef {
name: ~str,
ext: SyntaxExtension
}

type ItemDecorator =
pub type ItemDecorator =
fn@(ext_ctxt, span, ast::meta_item, ~[@ast::item]) -> ~[@ast::item];

struct SyntaxExpanderTT {
pub struct SyntaxExpanderTT {
expander: SyntaxExpanderTTFun,
span: Option<span>
}

type SyntaxExpanderTTFun = fn@(ext_ctxt, span, ~[ast::token_tree])
-> MacResult;
pub type SyntaxExpanderTTFun = fn@(ext_ctxt, span, ~[ast::token_tree])
-> MacResult;

struct SyntaxExpanderTTItem {
pub struct SyntaxExpanderTTItem {
expander: SyntaxExpanderTTItemFun,
span: Option<span>
}

type SyntaxExpanderTTItemFun
pub type SyntaxExpanderTTItemFun
= fn@(ext_ctxt, span, ast::ident, ~[ast::token_tree]) -> MacResult;

enum MacResult {
pub enum MacResult {
MRExpr(@ast::expr),
MRItem(@ast::item),
MRAny(fn@()-> @ast::expr, fn@()-> Option<@ast::item>, fn@()->@ast::stmt),
MRDef(MacroDef)
}

enum SyntaxExtension {
pub enum SyntaxExtension {

// #[auto_encode] and such
ItemDecorator(ItemDecorator),
Expand All @@ -78,7 +78,7 @@ enum SyntaxExtension {

// A temporary hard-coded map of methods for expanding syntax extension
// AST nodes into full ASTs
fn syntax_expander_table() -> HashMap<~str, SyntaxExtension> {
pub fn syntax_expander_table() -> HashMap<~str, SyntaxExtension> {
fn builtin_normal_tt(f: SyntaxExpanderTTFun) -> SyntaxExtension {
NormalTT(SyntaxExpanderTT{expander: f, span: None})
}
Expand Down Expand Up @@ -161,7 +161,7 @@ fn syntax_expander_table() -> HashMap<~str, SyntaxExtension> {
// One of these is made during expansion and incrementally updated as we go;
// when a macro expansion occurs, the resulting nodes have the backtrace()
// -> expn_info of their expansion context stored into their span.
trait ext_ctxt {
pub trait ext_ctxt {
fn codemap() -> @CodeMap;
fn parse_sess() -> parse::parse_sess;
fn cfg() -> ast::crate_cfg;
Expand All @@ -187,8 +187,8 @@ trait ext_ctxt {
fn ident_of(st: ~str) -> ast::ident;
}

fn mk_ctxt(parse_sess: parse::parse_sess,
cfg: ast::crate_cfg) -> ext_ctxt {
pub fn mk_ctxt(parse_sess: parse::parse_sess,
cfg: ast::crate_cfg) -> ext_ctxt {
type ctxt_repr = {parse_sess: parse::parse_sess,
cfg: ast::crate_cfg,
mut backtrace: Option<@ExpnInfo>,
Expand Down Expand Up @@ -281,7 +281,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess,
move ((move imp) as ext_ctxt)
}

fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
pub fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
match expr.node {
ast::expr_lit(l) => match l.node {
ast::lit_str(s) => return *s,
Expand All @@ -291,9 +291,9 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
}
}

fn expr_to_ident(cx: ext_ctxt,
expr: @ast::expr,
err_msg: ~str) -> ast::ident {
pub fn expr_to_ident(cx: ext_ctxt,
expr: @ast::expr,
err_msg: ~str) -> ast::ident {
match expr.node {
ast::expr_path(p) => {
if vec::len(p.types) > 0u || vec::len(p.idents) != 1u {
Expand All @@ -305,15 +305,17 @@ fn expr_to_ident(cx: ext_ctxt,
}
}

fn check_zero_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
name: &str) {
pub fn check_zero_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
name: &str) {
if tts.len() != 0 {
cx.span_fatal(sp, fmt!("%s takes no arguments", name));
}
}

fn get_single_str_from_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
name: &str) -> ~str {
pub fn get_single_str_from_tts(cx: ext_ctxt,
sp: span,
tts: &[ast::token_tree],
name: &str) -> ~str {
if tts.len() != 1 {
cx.span_fatal(sp, fmt!("%s takes 1 argument.", name));
}
Expand All @@ -325,8 +327,8 @@ fn get_single_str_from_tts(cx: ext_ctxt, sp: span, tts: &[ast::token_tree],
}
}

fn get_exprs_from_tts(cx: ext_ctxt, tts: ~[ast::token_tree])
-> ~[@ast::expr] {
pub fn get_exprs_from_tts(cx: ext_ctxt, tts: ~[ast::token_tree])
-> ~[@ast::expr] {
let p = parse::new_parser_from_tts(cx.parse_sess(),
cx.cfg(),
tts);
Expand Down
Loading

0 comments on commit b070590

Please sign in to comment.