Ast spanned<T> refactoring, renaming: crate, local, blk, crate_num, crate_cfg.
`crate => Crate` `local => Local` `blk => Block` `crate_num => CrateNum` `crate_cfg => CrateConfig` Also, Crate and Local are not wrapped in spanned<T> anymore.
This commit is contained in:
parent
7b2218d248
commit
4bd1424622
@ -488,7 +488,7 @@ pub mod write {
|
||||
*/
|
||||
|
||||
pub fn build_link_meta(sess: Session,
|
||||
c: &ast::crate,
|
||||
c: &ast::Crate,
|
||||
output: &Path,
|
||||
symbol_hasher: &mut hash::State)
|
||||
-> LinkMeta {
|
||||
@ -498,12 +498,12 @@ pub fn build_link_meta(sess: Session,
|
||||
cmh_items: ~[@ast::MetaItem]
|
||||
}
|
||||
|
||||
fn provided_link_metas(sess: Session, c: &ast::crate) ->
|
||||
fn provided_link_metas(sess: Session, c: &ast::Crate) ->
|
||||
ProvidedMetas {
|
||||
let mut name = None;
|
||||
let mut vers = None;
|
||||
let mut cmh_items = ~[];
|
||||
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
|
||||
let linkage_metas = attr::find_linkage_metas(c.attrs);
|
||||
attr::require_unique_names(sess.diagnostic(), linkage_metas);
|
||||
for linkage_metas.iter().advance |meta| {
|
||||
match meta.name_str_pair() {
|
||||
|
@ -64,7 +64,7 @@ pub fn source_name(input: &input) -> @str {
|
||||
}
|
||||
|
||||
pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
|
||||
ast::crate_cfg {
|
||||
ast::CrateConfig {
|
||||
let (libc, tos) = match sess.targ_cfg.os {
|
||||
session::os_win32 => (@"msvcrt.dll", @"win32"),
|
||||
session::os_macos => (@"libc.dylib", @"macos"),
|
||||
@ -96,14 +96,14 @@ pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
|
||||
mk(@"build_input", source_name(input))];
|
||||
}
|
||||
|
||||
pub fn append_configuration(cfg: &mut ast::crate_cfg, name: @str) {
|
||||
pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
|
||||
if !cfg.iter().any(|mi| mi.name() == name) {
|
||||
cfg.push(attr::mk_word_item(name))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
|
||||
ast::crate_cfg {
|
||||
ast::CrateConfig {
|
||||
// Combine the configuration requested by the session (command line) with
|
||||
// some default and generated configuration items
|
||||
let default_cfg = default_configuration(sess, argv0, input);
|
||||
@ -117,11 +117,11 @@ pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
|
||||
|
||||
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
|
||||
fn parse_cfgspecs(cfgspecs: ~[~str],
|
||||
demitter: diagnostic::Emitter) -> ast::crate_cfg {
|
||||
demitter: diagnostic::Emitter) -> ast::CrateConfig {
|
||||
do cfgspecs.consume_iter().transform |s| {
|
||||
let sess = parse::new_parse_sess(Some(demitter));
|
||||
parse::parse_meta_from_source_str(@"cfgspec", s.to_managed(), ~[], sess)
|
||||
}.collect::<ast::crate_cfg>()
|
||||
}.collect::<ast::CrateConfig>()
|
||||
}
|
||||
|
||||
pub enum input {
|
||||
@ -132,8 +132,8 @@ pub enum input {
|
||||
str_input(@str)
|
||||
}
|
||||
|
||||
pub fn parse_input(sess: Session, cfg: ast::crate_cfg, input: &input)
|
||||
-> @ast::crate {
|
||||
pub fn parse_input(sess: Session, cfg: ast::CrateConfig, input: &input)
|
||||
-> @ast::Crate {
|
||||
match *input {
|
||||
file_input(ref file) => {
|
||||
parse::parse_crate_from_file(&(*file), cfg, sess.parse_sess)
|
||||
@ -167,11 +167,11 @@ pub enum compile_phase {
|
||||
|
||||
#[fixed_stack_segment]
|
||||
pub fn compile_rest(sess: Session,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
phases: compile_upto,
|
||||
outputs: Option<@OutputFilenames>,
|
||||
curr: Option<@ast::crate>)
|
||||
-> (Option<@ast::crate>, Option<ty::ctxt>) {
|
||||
curr: Option<@ast::Crate>)
|
||||
-> (Option<@ast::Crate>, Option<ty::ctxt>) {
|
||||
|
||||
let time_passes = sess.time_passes();
|
||||
|
||||
@ -372,11 +372,11 @@ pub fn compile_rest(sess: Session,
|
||||
}
|
||||
|
||||
pub fn compile_upto(sess: Session,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
input: &input,
|
||||
upto: compile_phase,
|
||||
outputs: Option<@OutputFilenames>)
|
||||
-> (Option<@ast::crate>, Option<ty::ctxt>) {
|
||||
-> (Option<@ast::Crate>, Option<ty::ctxt>) {
|
||||
let time_passes = sess.time_passes();
|
||||
let crate = time(time_passes,
|
||||
~"parsing",
|
||||
@ -395,7 +395,7 @@ pub fn compile_upto(sess: Session,
|
||||
Some(crate))
|
||||
}
|
||||
|
||||
pub fn compile_input(sess: Session, cfg: ast::crate_cfg, input: &input,
|
||||
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
|
||||
outdir: &Option<Path>, output: &Option<Path>) {
|
||||
let upto = if sess.opts.parse_only { cu_parse }
|
||||
else if sess.opts.no_trans { cu_no_trans }
|
||||
@ -404,7 +404,7 @@ pub fn compile_input(sess: Session, cfg: ast::crate_cfg, input: &input,
|
||||
compile_upto(sess, cfg, input, upto, Some(outputs));
|
||||
}
|
||||
|
||||
pub fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: &input,
|
||||
pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input,
|
||||
ppm: pp_mode) {
|
||||
fn ann_paren_for_expr(node: pprust::ann_node) {
|
||||
match node {
|
||||
|
@ -158,7 +158,7 @@ pub struct options {
|
||||
// items to the crate config, and during parsing the entire crate config
|
||||
// will be added to the crate AST node. This should not be used for
|
||||
// anything except building the full crate config prior to parsing.
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
binary: @str,
|
||||
test: bool,
|
||||
parse_only: bool,
|
||||
@ -357,7 +357,7 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: &fn() -> ~str)
|
||||
}
|
||||
|
||||
pub fn building_library(req_crate_type: crate_type,
|
||||
crate: &ast::crate,
|
||||
crate: &ast::Crate,
|
||||
testing: bool) -> bool {
|
||||
match req_crate_type {
|
||||
bin_crate => false,
|
||||
@ -367,7 +367,7 @@ pub fn building_library(req_crate_type: crate_type,
|
||||
false
|
||||
} else {
|
||||
match syntax::attr::first_attr_value_str_by_name(
|
||||
crate.node.attrs,
|
||||
crate.attrs,
|
||||
"crate_type") {
|
||||
Some(s) => "lib" == s,
|
||||
_ => false
|
||||
@ -402,7 +402,7 @@ mod test {
|
||||
attr::mk_attr(attr::mk_name_value_item_str(@"crate_type", t))
|
||||
}
|
||||
|
||||
fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate {
|
||||
fn make_crate(with_bin: bool, with_lib: bool) -> @ast::Crate {
|
||||
let mut attrs = ~[];
|
||||
if with_bin {
|
||||
attrs.push(make_crate_type_attr(@"bin"));
|
||||
@ -410,11 +410,12 @@ mod test {
|
||||
if with_lib {
|
||||
attrs.push(make_crate_type_attr(@"lib"));
|
||||
}
|
||||
@codemap::respan(codemap::dummy_sp(), ast::crate_ {
|
||||
@ast::Crate {
|
||||
module: ast::_mod { view_items: ~[], items: ~[] },
|
||||
attrs: attrs,
|
||||
config: ~[]
|
||||
})
|
||||
config: ~[],
|
||||
span: codemap::dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -20,14 +20,14 @@ struct Context {
|
||||
|
||||
// Support conditional compilation by transforming the AST, stripping out
|
||||
// any items that do not belong in the current configuration
|
||||
pub fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
|
||||
pub fn strip_unconfigured_items(crate: @ast::Crate) -> @ast::Crate {
|
||||
do strip_items(crate) |attrs| {
|
||||
in_cfg(crate.node.config, attrs)
|
||||
in_cfg(crate.config, attrs)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn strip_items(crate: &ast::crate, in_cfg: in_cfg_pred)
|
||||
-> @ast::crate {
|
||||
pub fn strip_items(crate: &ast::Crate, in_cfg: in_cfg_pred)
|
||||
-> @ast::Crate {
|
||||
|
||||
let ctxt = @Context { in_cfg: in_cfg };
|
||||
|
||||
@ -131,16 +131,16 @@ fn filter_stmt(cx: @Context, stmt: @ast::stmt) ->
|
||||
|
||||
fn fold_block(
|
||||
cx: @Context,
|
||||
b: &ast::blk,
|
||||
b: &ast::Block,
|
||||
fld: @fold::ast_fold
|
||||
) -> ast::blk {
|
||||
) -> ast::Block {
|
||||
let resulting_stmts = do b.stmts.iter().filter_map |a| {
|
||||
filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt))
|
||||
}.collect();
|
||||
let filtered_view_items = do b.view_items.iter().filter_map |a| {
|
||||
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
|
||||
}.collect();
|
||||
ast::blk {
|
||||
ast::Block {
|
||||
view_items: filtered_view_items,
|
||||
stmts: resulting_stmts,
|
||||
expr: b.expr.map(|x| fld.fold_expr(*x)),
|
||||
|
@ -20,8 +20,8 @@ use syntax::fold;
|
||||
|
||||
static STD_VERSION: &'static str = "0.8-pre";
|
||||
|
||||
pub fn maybe_inject_libstd_ref(sess: Session, crate: @ast::crate)
|
||||
-> @ast::crate {
|
||||
pub fn maybe_inject_libstd_ref(sess: Session, crate: @ast::Crate)
|
||||
-> @ast::Crate {
|
||||
if use_std(crate) {
|
||||
inject_libstd_ref(sess, crate)
|
||||
} else {
|
||||
@ -29,20 +29,21 @@ pub fn maybe_inject_libstd_ref(sess: Session, crate: @ast::crate)
|
||||
}
|
||||
}
|
||||
|
||||
fn use_std(crate: &ast::crate) -> bool {
|
||||
!attr::contains_name(crate.node.attrs, "no_std")
|
||||
fn use_std(crate: &ast::Crate) -> bool {
|
||||
!attr::contains_name(crate.attrs, "no_std")
|
||||
}
|
||||
|
||||
fn no_prelude(attrs: &[ast::Attribute]) -> bool {
|
||||
attr::contains_name(attrs, "no_implicit_prelude")
|
||||
}
|
||||
|
||||
fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
|
||||
fn inject_libstd_ref(sess: Session, crate: &ast::Crate) -> @ast::Crate {
|
||||
fn spanned<T>(x: T) -> codemap::spanned<T> {
|
||||
codemap::spanned { node: x, span: dummy_sp() }
|
||||
}
|
||||
|
||||
let precursor = @fold::AstFoldFns {
|
||||
fold_crate: |crate, span, fld| {
|
||||
fold_crate: |crate, fld| {
|
||||
let n1 = sess.next_node_id();
|
||||
let vi1 = ast::view_item {
|
||||
node: ast::view_item_extern_mod(
|
||||
@ -68,11 +69,10 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
|
||||
}
|
||||
|
||||
// FIXME #2543: Bad copy.
|
||||
let new_crate = ast::crate_ {
|
||||
ast::Crate {
|
||||
module: new_module,
|
||||
..(*crate).clone()
|
||||
};
|
||||
(new_crate, span)
|
||||
}
|
||||
},
|
||||
fold_item: |item, fld| {
|
||||
if !no_prelude(item.attrs) {
|
||||
|
@ -37,7 +37,7 @@ struct Test {
|
||||
|
||||
struct TestCtxt {
|
||||
sess: session::Session,
|
||||
crate: @ast::crate,
|
||||
crate: @ast::Crate,
|
||||
path: ~[ast::ident],
|
||||
ext_cx: @ExtCtxt,
|
||||
testfns: ~[Test]
|
||||
@ -46,12 +46,12 @@ struct TestCtxt {
|
||||
// Traverse the crate, collecting all the test functions, eliding any
|
||||
// existing main functions, and synthesizing a main test harness
|
||||
pub fn modify_for_testing(sess: session::Session,
|
||||
crate: @ast::crate)
|
||||
-> @ast::crate {
|
||||
crate: @ast::Crate)
|
||||
-> @ast::Crate {
|
||||
// We generate the test harness when building in the 'test'
|
||||
// configuration, either with the '--test' or '--cfg test'
|
||||
// command line options.
|
||||
let should_test = attr::contains_name(crate.node.config, "test");
|
||||
let should_test = attr::contains_name(crate.config, "test");
|
||||
|
||||
if should_test {
|
||||
generate_test_harness(sess, crate)
|
||||
@ -61,8 +61,8 @@ pub fn modify_for_testing(sess: session::Session,
|
||||
}
|
||||
|
||||
fn generate_test_harness(sess: session::Session,
|
||||
crate: @ast::crate)
|
||||
-> @ast::crate {
|
||||
crate: @ast::Crate)
|
||||
-> @ast::Crate {
|
||||
let cx: @mut TestCtxt = @mut TestCtxt {
|
||||
sess: sess,
|
||||
crate: crate,
|
||||
@ -81,7 +81,7 @@ fn generate_test_harness(sess: session::Session,
|
||||
});
|
||||
|
||||
let precursor = @fold::AstFoldFns {
|
||||
fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),
|
||||
fold_crate: |a,b| fold_crate(cx, a, b),
|
||||
fold_item: |a,b| fold_item(cx, a, b),
|
||||
fold_mod: |a,b| fold_mod(cx, a, b),.. *fold::default_ast_fold()};
|
||||
|
||||
@ -91,7 +91,7 @@ fn generate_test_harness(sess: session::Session,
|
||||
return res;
|
||||
}
|
||||
|
||||
fn strip_test_functions(crate: &ast::crate) -> @ast::crate {
|
||||
fn strip_test_functions(crate: &ast::Crate) -> @ast::Crate {
|
||||
// When not compiling with --test we should not compile the
|
||||
// #[test] functions
|
||||
do config::strip_items(crate) |attrs| {
|
||||
@ -132,13 +132,13 @@ fn fold_mod(cx: @mut TestCtxt,
|
||||
fold::noop_fold_mod(&mod_nomain, fld)
|
||||
}
|
||||
|
||||
fn fold_crate(cx: @mut TestCtxt, c: &ast::crate_, fld: @fold::ast_fold)
|
||||
-> ast::crate_ {
|
||||
fn fold_crate(cx: @mut TestCtxt, c: &ast::Crate, fld: @fold::ast_fold)
|
||||
-> ast::Crate {
|
||||
let folded = fold::noop_fold_crate(c, fld);
|
||||
|
||||
// Add a special __test module to the crate that will contain code
|
||||
// generated for the test harness
|
||||
ast::crate_ {
|
||||
ast::Crate {
|
||||
module: add_test_module(cx, &folded.module),
|
||||
.. folded
|
||||
}
|
||||
@ -236,7 +236,7 @@ fn is_ignored(cx: @mut TestCtxt, i: @ast::item) -> bool {
|
||||
do i.attrs.iter().any |attr| {
|
||||
// check ignore(cfg(foo, bar))
|
||||
"ignore" == attr.name() && match attr.meta_item_list() {
|
||||
Some(ref cfgs) => attr::test_cfg(cx.crate.node.config, cfgs.iter().transform(|x| *x)),
|
||||
Some(ref cfgs) => attr::test_cfg(cx.crate.config, cfgs.iter().transform(|x| *x)),
|
||||
None => true
|
||||
}
|
||||
}
|
||||
@ -370,7 +370,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item {
|
||||
}
|
||||
|
||||
fn is_extra(cx: &TestCtxt) -> bool {
|
||||
let items = attr::find_linkage_metas(cx.crate.node.attrs);
|
||||
let items = attr::find_linkage_metas(cx.crate.attrs);
|
||||
match attr::last_meta_item_value_str_by_name(items, "name") {
|
||||
Some(s) if "extra" == s => true,
|
||||
_ => false
|
||||
|
@ -29,7 +29,7 @@ use syntax::ast;
|
||||
// Traverses an AST, reading all the information about use'd crates and extern
|
||||
// libraries necessary for later resolving, typechecking, linking, etc.
|
||||
pub fn read_crates(diag: @span_handler,
|
||||
crate: &ast::crate,
|
||||
crate: &ast::Crate,
|
||||
cstore: @mut cstore::CStore,
|
||||
filesearch: @FileSearch,
|
||||
os: loader::os,
|
||||
@ -118,14 +118,14 @@ struct Env {
|
||||
os: loader::os,
|
||||
statik: bool,
|
||||
crate_cache: @mut ~[cache_entry],
|
||||
next_crate_num: ast::crate_num,
|
||||
next_crate_num: ast::CrateNum,
|
||||
intr: @ident_interner
|
||||
}
|
||||
|
||||
fn visit_crate(e: &Env, c: &ast::crate) {
|
||||
fn visit_crate(e: &Env, c: &ast::Crate) {
|
||||
let cstore = e.cstore;
|
||||
|
||||
for c.node.attrs.iter().filter(|m| "link_args" == m.name()).advance |a| {
|
||||
for c.attrs.iter().filter(|m| "link_args" == m.name()).advance |a| {
|
||||
match a.value_str() {
|
||||
Some(ref linkarg) => {
|
||||
cstore::add_used_link_args(cstore, *linkarg);
|
||||
@ -237,7 +237,7 @@ fn resolve_crate(e: @mut Env,
|
||||
metas: ~[@ast::MetaItem],
|
||||
hash: @str,
|
||||
span: span)
|
||||
-> ast::crate_num {
|
||||
-> ast::CrateNum {
|
||||
let metas = metas_with_ident(token::ident_to_str(&ident), metas);
|
||||
|
||||
match existing_match(e, metas, hash) {
|
||||
|
@ -42,7 +42,7 @@ pub fn get_type_param_count(cstore: @mut cstore::CStore, def: ast::def_id)
|
||||
|
||||
/// Iterates over all the language items in the given crate.
|
||||
pub fn each_lang_item(cstore: @mut cstore::CStore,
|
||||
cnum: ast::crate_num,
|
||||
cnum: ast::CrateNum,
|
||||
f: &fn(ast::node_id, uint) -> bool) -> bool {
|
||||
let crate_data = cstore::get_crate_data(cstore, cnum);
|
||||
decoder::each_lang_item(crate_data, f)
|
||||
@ -50,7 +50,7 @@ pub fn each_lang_item(cstore: @mut cstore::CStore,
|
||||
|
||||
/// Iterates over all the paths in the given crate.
|
||||
pub fn each_path(cstore: @mut cstore::CStore,
|
||||
cnum: ast::crate_num,
|
||||
cnum: ast::CrateNum,
|
||||
f: &fn(&str, decoder::def_like, ast::visibility) -> bool)
|
||||
-> bool {
|
||||
let crate_data = cstore::get_crate_data(cstore, cnum);
|
||||
@ -232,7 +232,7 @@ pub fn get_item_visibility(cstore: @mut cstore::CStore,
|
||||
}
|
||||
|
||||
pub fn get_link_args_for_crate(cstore: @mut cstore::CStore,
|
||||
crate_num: ast::crate_num)
|
||||
crate_num: ast::CrateNum)
|
||||
-> ~[~str] {
|
||||
let cdata = cstore::get_crate_data(cstore, crate_num);
|
||||
decoder::get_link_args_for_crate(cdata)
|
||||
|
@ -25,17 +25,17 @@ use syntax::parse::token::ident_interner;
|
||||
// local crate numbers (as generated during this session). Each external
|
||||
// crate may refer to types in other external crates, and each has their
|
||||
// own crate numbers.
|
||||
pub type cnum_map = @mut HashMap<ast::crate_num, ast::crate_num>;
|
||||
pub type cnum_map = @mut HashMap<ast::CrateNum, ast::CrateNum>;
|
||||
|
||||
pub struct crate_metadata {
|
||||
name: @str,
|
||||
data: @~[u8],
|
||||
cnum_map: cnum_map,
|
||||
cnum: ast::crate_num
|
||||
cnum: ast::CrateNum
|
||||
}
|
||||
|
||||
pub struct CStore {
|
||||
priv metas: HashMap <ast::crate_num, @crate_metadata>,
|
||||
priv metas: HashMap <ast::CrateNum, @crate_metadata>,
|
||||
priv extern_mod_crate_map: extern_mod_crate_map,
|
||||
priv used_crate_files: ~[Path],
|
||||
priv used_libraries: ~[@str],
|
||||
@ -44,7 +44,7 @@ pub struct CStore {
|
||||
}
|
||||
|
||||
// Map from node_id's of local extern mod statements to crate numbers
|
||||
type extern_mod_crate_map = HashMap<ast::node_id, ast::crate_num>;
|
||||
type extern_mod_crate_map = HashMap<ast::node_id, ast::CrateNum>;
|
||||
|
||||
pub fn mk_cstore(intr: @ident_interner) -> CStore {
|
||||
return CStore {
|
||||
@ -57,33 +57,33 @@ pub fn mk_cstore(intr: @ident_interner) -> CStore {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_crate_data(cstore: &CStore, cnum: ast::crate_num)
|
||||
pub fn get_crate_data(cstore: &CStore, cnum: ast::CrateNum)
|
||||
-> @crate_metadata {
|
||||
return *cstore.metas.get(&cnum);
|
||||
}
|
||||
|
||||
pub fn get_crate_hash(cstore: &CStore, cnum: ast::crate_num) -> @str {
|
||||
pub fn get_crate_hash(cstore: &CStore, cnum: ast::CrateNum) -> @str {
|
||||
let cdata = get_crate_data(cstore, cnum);
|
||||
decoder::get_crate_hash(cdata.data)
|
||||
}
|
||||
|
||||
pub fn get_crate_vers(cstore: &CStore, cnum: ast::crate_num) -> @str {
|
||||
pub fn get_crate_vers(cstore: &CStore, cnum: ast::CrateNum) -> @str {
|
||||
let cdata = get_crate_data(cstore, cnum);
|
||||
decoder::get_crate_vers(cdata.data)
|
||||
}
|
||||
|
||||
pub fn set_crate_data(cstore: &mut CStore,
|
||||
cnum: ast::crate_num,
|
||||
cnum: ast::CrateNum,
|
||||
data: @crate_metadata) {
|
||||
cstore.metas.insert(cnum, data);
|
||||
}
|
||||
|
||||
pub fn have_crate_data(cstore: &CStore, cnum: ast::crate_num) -> bool {
|
||||
pub fn have_crate_data(cstore: &CStore, cnum: ast::CrateNum) -> bool {
|
||||
cstore.metas.contains_key(&cnum)
|
||||
}
|
||||
|
||||
pub fn iter_crate_data(cstore: &CStore,
|
||||
i: &fn(ast::crate_num, @crate_metadata)) {
|
||||
i: &fn(ast::CrateNum, @crate_metadata)) {
|
||||
for cstore.metas.iter().advance |(&k, &v)| {
|
||||
i(k, v);
|
||||
}
|
||||
@ -126,13 +126,13 @@ pub fn get_used_link_args<'a>(cstore: &'a CStore) -> &'a [@str] {
|
||||
|
||||
pub fn add_extern_mod_stmt_cnum(cstore: &mut CStore,
|
||||
emod_id: ast::node_id,
|
||||
cnum: ast::crate_num) {
|
||||
cnum: ast::CrateNum) {
|
||||
cstore.extern_mod_crate_map.insert(emod_id, cnum);
|
||||
}
|
||||
|
||||
pub fn find_extern_mod_stmt_cnum(cstore: &CStore,
|
||||
emod_id: ast::node_id)
|
||||
-> Option<ast::crate_num> {
|
||||
-> Option<ast::CrateNum> {
|
||||
cstore.extern_mod_crate_map.find(&emod_id).map_consume(|x| *x)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: &fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
None
|
||||
}
|
||||
|
||||
pub type GetCrateDataCb<'self> = &'self fn(ast::crate_num) -> cmd;
|
||||
pub type GetCrateDataCb<'self> = &'self fn(ast::CrateNum) -> cmd;
|
||||
|
||||
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||
@ -174,7 +174,7 @@ fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
|
||||
None
|
||||
}
|
||||
|
||||
fn item_reqd_and_translated_parent_item(cnum: ast::crate_num,
|
||||
fn item_reqd_and_translated_parent_item(cnum: ast::CrateNum,
|
||||
d: ebml::Doc) -> ast::def_id {
|
||||
let trait_did = item_parent_item(d).expect("item without parent");
|
||||
ast::def_id { crate: cnum, node: trait_did.node }
|
||||
@ -311,7 +311,7 @@ fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::ident {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::CrateNum)
|
||||
-> def_like {
|
||||
let fam = item_family(item);
|
||||
match fam {
|
||||
@ -349,7 +349,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lookup_def(cnum: ast::crate_num, data: @~[u8], did_: ast::def_id) ->
|
||||
pub fn lookup_def(cnum: ast::CrateNum, data: @~[u8], did_: ast::def_id) ->
|
||||
ast::def {
|
||||
let item = lookup_item(did_.node, data);
|
||||
let did = ast::def_id { crate: cnum, node: did_.node };
|
||||
@ -1160,7 +1160,7 @@ pub fn get_crate_attributes(data: @~[u8]) -> ~[ast::Attribute] {
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct crate_dep {
|
||||
cnum: ast::crate_num,
|
||||
cnum: ast::CrateNum,
|
||||
name: ast::ident,
|
||||
vers: @str,
|
||||
hash: @str
|
||||
|
@ -1170,14 +1170,14 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
|
||||
|
||||
fn encode_info_for_items(ecx: &EncodeContext,
|
||||
ebml_w: &mut writer::Encoder,
|
||||
crate: &crate)
|
||||
crate: &Crate)
|
||||
-> ~[entry<int>] {
|
||||
let index = @mut ~[];
|
||||
ebml_w.start_tag(tag_items_data);
|
||||
index.push(entry { val: crate_node_id, pos: ebml_w.writer.tell() });
|
||||
encode_info_for_mod(ecx,
|
||||
ebml_w,
|
||||
&crate.node.module,
|
||||
&crate.module,
|
||||
crate_node_id,
|
||||
[],
|
||||
syntax::parse::token::special_idents::invalid,
|
||||
@ -1348,7 +1348,7 @@ fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[Attribute]) {
|
||||
// 'name' and 'vers' items, so if the user didn't provide them we will throw
|
||||
// them in anyway with default values.
|
||||
fn synthesize_crate_attrs(ecx: &EncodeContext,
|
||||
crate: &crate) -> ~[Attribute] {
|
||||
crate: &Crate) -> ~[Attribute] {
|
||||
|
||||
fn synthesize_link_attr(ecx: &EncodeContext, items: ~[@MetaItem]) ->
|
||||
Attribute {
|
||||
@ -1377,7 +1377,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext,
|
||||
|
||||
let mut attrs = ~[];
|
||||
let mut found_link_attr = false;
|
||||
for crate.node.attrs.iter().advance |attr| {
|
||||
for crate.attrs.iter().advance |attr| {
|
||||
attrs.push(
|
||||
if "link" != attr.name() {
|
||||
*attr
|
||||
@ -1477,11 +1477,11 @@ fn encode_link_args(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
|
||||
}
|
||||
|
||||
fn encode_misc_info(ecx: &EncodeContext,
|
||||
crate: &crate,
|
||||
crate: &Crate,
|
||||
ebml_w: &mut writer::Encoder) {
|
||||
ebml_w.start_tag(tag_misc_info);
|
||||
ebml_w.start_tag(tag_misc_info_crate_items);
|
||||
for crate.node.module.items.iter().advance |&item| {
|
||||
for crate.module.items.iter().advance |&item| {
|
||||
ebml_w.start_tag(tag_mod_child);
|
||||
ebml_w.wr_str(def_to_str(local_def(item.id)));
|
||||
ebml_w.end_tag();
|
||||
@ -1531,7 +1531,7 @@ pub static metadata_encoding_version : &'static [u8] =
|
||||
0x74, //'t' as u8,
|
||||
0, 0, 0, 1 ];
|
||||
|
||||
pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
|
||||
pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
|
||||
let wr = @io::BytesWriter::new();
|
||||
let stats = Stats {
|
||||
inline_bytes: 0,
|
||||
|
@ -291,7 +291,7 @@ fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) {
|
||||
// nested items, as otherwise it would get confused when translating
|
||||
// inlined items.
|
||||
fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
|
||||
fn drop_nested_items(blk: &ast::blk, fld: @fold::ast_fold) -> ast::blk {
|
||||
fn drop_nested_items(blk: &ast::Block, fld: @fold::ast_fold) -> ast::Block {
|
||||
let stmts_sans_items = do blk.stmts.iter().filter_map |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
|
||||
@ -302,7 +302,7 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
|
||||
ast::stmt_mac(*) => fail!("unexpanded macro in astencode")
|
||||
}
|
||||
}.collect();
|
||||
let blk_sans_items = ast::blk {
|
||||
let blk_sans_items = ast::Block {
|
||||
view_items: ~[], // I don't know if we need the view_items here,
|
||||
// but it doesn't break tests!
|
||||
stmts: stmts_sans_items,
|
||||
@ -1206,7 +1206,7 @@ fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
|
||||
|
||||
#[cfg(test)]
|
||||
trait fake_ext_ctxt {
|
||||
fn cfg(&self) -> ast::crate_cfg;
|
||||
fn cfg(&self) -> ast::CrateConfig;
|
||||
fn parse_sess(&self) -> @mut parse::ParseSess;
|
||||
fn call_site(&self) -> span;
|
||||
fn ident_of(&self, st: &str) -> ast::ident;
|
||||
@ -1217,7 +1217,7 @@ type fake_session = @mut parse::ParseSess;
|
||||
|
||||
#[cfg(test)]
|
||||
impl fake_ext_ctxt for fake_session {
|
||||
fn cfg(&self) -> ast::crate_cfg { ~[] }
|
||||
fn cfg(&self) -> ast::CrateConfig { ~[] }
|
||||
fn parse_sess(&self) -> @mut parse::ParseSess { *self }
|
||||
fn call_site(&self) -> span {
|
||||
codemap::span {
|
||||
|
@ -44,7 +44,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
|
||||
dfcx_loans: &LoanDataFlow,
|
||||
move_data: move_data::FlowedMoveData,
|
||||
all_loans: &[Loan],
|
||||
body: &ast::blk) {
|
||||
body: &ast::Block) {
|
||||
debug!("check_loans(body id=%?)", body.id);
|
||||
|
||||
let clcx = CheckLoanCtxt {
|
||||
@ -615,7 +615,7 @@ impl<'self> CheckLoanCtxt<'self> {
|
||||
|
||||
fn check_loans_in_fn<'a>(fk: &visit::fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
(this, visitor): (CheckLoanCtxt<'a>,
|
||||
@ -676,7 +676,7 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind,
|
||||
}
|
||||
}
|
||||
|
||||
fn check_loans_in_local<'a>(local: @ast::local,
|
||||
fn check_loans_in_local<'a>(local: @ast::Local,
|
||||
(this, vt): (CheckLoanCtxt<'a>,
|
||||
visit::vt<CheckLoanCtxt<'a>>)) {
|
||||
visit::visit_local(local, (this, vt));
|
||||
@ -745,7 +745,7 @@ fn check_loans_in_pat<'a>(pat: @ast::pat,
|
||||
visit::visit_pat(pat, (this, vt));
|
||||
}
|
||||
|
||||
fn check_loans_in_block<'a>(blk: &ast::blk,
|
||||
fn check_loans_in_block<'a>(blk: &ast::Block,
|
||||
(this, vt): (CheckLoanCtxt<'a>,
|
||||
visit::vt<CheckLoanCtxt<'a>>))
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ struct GatherLoanCtxt {
|
||||
|
||||
pub fn gather_loans(bccx: @BorrowckCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk)
|
||||
body: &ast::Block)
|
||||
-> (id_range, @mut ~[Loan], @mut move_data::MoveData) {
|
||||
let glcx = @mut GatherLoanCtxt {
|
||||
bccx: bccx,
|
||||
@ -109,7 +109,7 @@ fn add_pat_to_id_range(p: @ast::pat,
|
||||
|
||||
fn gather_loans_in_fn(fk: &visit::fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
(this, v): (@mut GatherLoanCtxt,
|
||||
@ -131,21 +131,21 @@ fn gather_loans_in_fn(fk: &visit::fn_kind,
|
||||
}
|
||||
}
|
||||
|
||||
fn gather_loans_in_block(blk: &ast::blk,
|
||||
fn gather_loans_in_block(blk: &ast::Block,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
visit::vt<@mut GatherLoanCtxt>)) {
|
||||
this.id_range.add(blk.id);
|
||||
visit::visit_block(blk, (this, vt));
|
||||
}
|
||||
|
||||
fn gather_loans_in_local(local: @ast::local,
|
||||
fn gather_loans_in_local(local: @ast::Local,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
visit::vt<@mut GatherLoanCtxt>)) {
|
||||
match local.node.init {
|
||||
match local.init {
|
||||
None => {
|
||||
// Variable declarations without initializers are considered "moves":
|
||||
let tcx = this.bccx.tcx;
|
||||
do pat_util::pat_bindings(tcx.def_map, local.node.pat)
|
||||
do pat_util::pat_bindings(tcx.def_map, local.pat)
|
||||
|_, id, span, _| {
|
||||
gather_moves::gather_decl(this.bccx,
|
||||
this.move_data,
|
||||
@ -157,7 +157,7 @@ fn gather_loans_in_local(local: @ast::local,
|
||||
Some(init) => {
|
||||
// Variable declarations with initializers are considered "assigns":
|
||||
let tcx = this.bccx.tcx;
|
||||
do pat_util::pat_bindings(tcx.def_map, local.node.pat)
|
||||
do pat_util::pat_bindings(tcx.def_map, local.pat)
|
||||
|_, id, span, _| {
|
||||
gather_moves::gather_assignment(this.bccx,
|
||||
this.move_data,
|
||||
@ -167,7 +167,7 @@ fn gather_loans_in_local(local: @ast::local,
|
||||
id);
|
||||
}
|
||||
let init_cmt = this.bccx.cat_expr(init);
|
||||
this.gather_pat(init_cmt, local.node.pat, None);
|
||||
this.gather_pat(init_cmt, local.pat, None);
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ impl GatherLoanCtxt {
|
||||
|
||||
fn gather_fn_arg_patterns(&mut self,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk) {
|
||||
body: &ast::Block) {
|
||||
/*!
|
||||
* Walks the patterns for fn arguments, checking that they
|
||||
* do not attempt illegal moves or create refs that outlive
|
||||
|
@ -66,7 +66,7 @@ pub fn check_crate(
|
||||
moves_map: moves::MovesMap,
|
||||
moved_variables_set: moves::MovedVariablesSet,
|
||||
capture_map: moves::CaptureMap,
|
||||
crate: &ast::crate) -> (root_map, write_guard_map)
|
||||
crate: &ast::Crate) -> (root_map, write_guard_map)
|
||||
{
|
||||
let bccx = @BorrowckCtxt {
|
||||
tcx: tcx,
|
||||
@ -116,7 +116,7 @@ pub fn check_crate(
|
||||
|
||||
fn borrowck_fn(fk: &visit::fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
(this, v): (@BorrowckCtxt,
|
||||
|
@ -473,7 +473,7 @@ impl FlowedMoveData {
|
||||
tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
id_range: ast_util::id_range,
|
||||
body: &ast::blk)
|
||||
body: &ast::Block)
|
||||
-> FlowedMoveData
|
||||
{
|
||||
let mut dfcx_moves =
|
||||
|
@ -33,7 +33,7 @@ struct LoopScope {
|
||||
|
||||
pub fn construct(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
blk: &ast::blk) -> CFG {
|
||||
blk: &ast::Block) -> CFG {
|
||||
let mut cfg_builder = CFGBuilder {
|
||||
exit_map: HashMap::new(),
|
||||
graph: graph::Graph::new(),
|
||||
@ -51,7 +51,7 @@ pub fn construct(tcx: ty::ctxt,
|
||||
}
|
||||
|
||||
impl CFGBuilder {
|
||||
fn block(&mut self, blk: &ast::blk, pred: CFGIndex) -> CFGIndex {
|
||||
fn block(&mut self, blk: &ast::Block, pred: CFGIndex) -> CFGIndex {
|
||||
let mut stmts_exit = pred;
|
||||
for blk.stmts.iter().advance |&stmt| {
|
||||
stmts_exit = self.stmt(stmt, stmts_exit);
|
||||
@ -81,8 +81,8 @@ impl CFGBuilder {
|
||||
fn decl(&mut self, decl: @ast::decl, pred: CFGIndex) -> CFGIndex {
|
||||
match decl.node {
|
||||
ast::decl_local(local) => {
|
||||
let init_exit = self.opt_expr(local.node.init, pred);
|
||||
self.pat(local.node.pat, init_exit)
|
||||
let init_exit = self.opt_expr(local.init, pred);
|
||||
self.pat(local.pat, init_exit)
|
||||
}
|
||||
|
||||
ast::decl_item(_) => {
|
||||
|
@ -55,7 +55,7 @@ pub struct CFGIndices {
|
||||
impl CFG {
|
||||
pub fn new(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
blk: &ast::blk) -> CFG {
|
||||
blk: &ast::Block) -> CFG {
|
||||
construct::construct(tcx, method_map, blk)
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ use syntax::codemap;
|
||||
use syntax::{visit, ast_util, ast_map};
|
||||
|
||||
pub fn check_crate(sess: Session,
|
||||
crate: &crate,
|
||||
crate: &Crate,
|
||||
ast_map: ast_map::map,
|
||||
def_map: resolve::DefMap,
|
||||
method_map: typeck::method_map,
|
||||
|
@ -20,7 +20,7 @@ pub struct Context {
|
||||
can_ret: bool
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt, crate: &crate) {
|
||||
pub fn check_crate(tcx: ty::ctxt, crate: &Crate) {
|
||||
visit::visit_crate(crate,
|
||||
(Context { in_loop: false, can_ret: true },
|
||||
visit::mk_vt(@visit::Visitor {
|
||||
|
@ -36,7 +36,7 @@ pub struct MatchCheckCtxt {
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
method_map: method_map,
|
||||
moves_map: moves::MovesMap,
|
||||
crate: &crate) {
|
||||
crate: &Crate) {
|
||||
let cx = @MatchCheckCtxt {tcx: tcx,
|
||||
method_map: method_map,
|
||||
moves_map: moves_map};
|
||||
@ -738,23 +738,23 @@ pub fn default(cx: &MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
|
||||
}
|
||||
|
||||
pub fn check_local(cx: &MatchCheckCtxt,
|
||||
loc: @local,
|
||||
loc: @Local,
|
||||
(s, v): ((),
|
||||
visit::vt<()>)) {
|
||||
visit::visit_local(loc, (s, v));
|
||||
if is_refutable(cx, loc.node.pat) {
|
||||
cx.tcx.sess.span_err(loc.node.pat.span,
|
||||
if is_refutable(cx, loc.pat) {
|
||||
cx.tcx.sess.span_err(loc.pat.span,
|
||||
"refutable pattern in local binding");
|
||||
}
|
||||
|
||||
// Check legality of move bindings.
|
||||
check_legality_of_move_bindings(cx, false, [ loc.node.pat ]);
|
||||
check_legality_of_move_bindings(cx, false, [ loc.pat ]);
|
||||
}
|
||||
|
||||
pub fn check_fn(cx: &MatchCheckCtxt,
|
||||
kind: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
sp: span,
|
||||
id: node_id,
|
||||
(s, v): ((),
|
||||
|
@ -265,7 +265,7 @@ pub fn lookup_constness(tcx: ty::ctxt, e: &expr) -> constness {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process_crate(crate: &ast::crate,
|
||||
pub fn process_crate(crate: &ast::Crate,
|
||||
tcx: ty::ctxt) {
|
||||
let v = visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
visit_expr_post: |e| { classify(e, tcx); },
|
||||
|
@ -297,7 +297,7 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
|
||||
|
||||
impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
||||
// ^^^^^^^^^^^^^ only needed for pretty printing
|
||||
pub fn propagate(&mut self, blk: &ast::blk) {
|
||||
pub fn propagate(&mut self, blk: &ast::Block) {
|
||||
//! Performs the data flow analysis.
|
||||
|
||||
if self.bits_per_id == 0 {
|
||||
@ -329,7 +329,7 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> {
|
||||
});
|
||||
}
|
||||
|
||||
fn pretty_print_to(@self, wr: @io::Writer, blk: &ast::blk) {
|
||||
fn pretty_print_to(@self, wr: @io::Writer, blk: &ast::Block) {
|
||||
let pre: @fn(pprust::ann_node) = |node| {
|
||||
let (ps, id) = match node {
|
||||
pprust::node_expr(ps, expr) => (ps, expr.id),
|
||||
@ -383,7 +383,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
|
||||
}
|
||||
|
||||
fn walk_block(&mut self,
|
||||
blk: &ast::blk,
|
||||
blk: &ast::Block,
|
||||
in_out: &mut [uint],
|
||||
loop_scopes: &mut ~[LoopScope]) {
|
||||
debug!("DataFlowContext::walk_block(blk.id=%?, in_out=%s)",
|
||||
@ -425,8 +425,8 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
|
||||
loop_scopes: &mut ~[LoopScope]) {
|
||||
match decl.node {
|
||||
ast::decl_local(local) => {
|
||||
self.walk_opt_expr(local.node.init, in_out, loop_scopes);
|
||||
self.walk_pat(local.node.pat, in_out, loop_scopes);
|
||||
self.walk_opt_expr(local.init, in_out, loop_scopes);
|
||||
self.walk_pat(local.pat, in_out, loop_scopes);
|
||||
}
|
||||
|
||||
ast::decl_item(_) => {}
|
||||
|
@ -47,7 +47,7 @@ fn type_is_unsafe_function(ty: ty::t) -> bool {
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
method_map: method_map,
|
||||
crate: &ast::crate) {
|
||||
crate: &ast::Crate) {
|
||||
let context = @mut Context {
|
||||
method_map: method_map,
|
||||
unsafe_context: SafeContext,
|
||||
|
@ -12,7 +12,7 @@
|
||||
use driver::session;
|
||||
use driver::session::Session;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::ast::{crate, node_id, item, item_fn};
|
||||
use syntax::ast::{Crate, node_id, item, item_fn};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::span;
|
||||
use syntax::visit::{default_visitor, mk_vt, vt, Visitor, visit_crate, visit_item};
|
||||
@ -40,7 +40,7 @@ struct EntryContext {
|
||||
|
||||
type EntryVisitor = vt<@mut EntryContext>;
|
||||
|
||||
pub fn find_entry_point(session: Session, crate: &crate, ast_map: ast_map::map) {
|
||||
pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) {
|
||||
|
||||
// FIXME #4404 android JNI hacks
|
||||
if *session.building_library &&
|
||||
|
@ -34,7 +34,7 @@ pub type freevar_map = @mut HashMap<ast::node_id, freevar_info>;
|
||||
// Since we want to be able to collect upvars in some arbitrary piece
|
||||
// of the AST, we take a walker function that we invoke with a visitor
|
||||
// in order to start the search.
|
||||
fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
|
||||
fn collect_freevars(def_map: resolve::DefMap, blk: &ast::Block)
|
||||
-> freevar_info {
|
||||
let seen = @mut HashMap::new();
|
||||
let refs = @mut ~[];
|
||||
@ -87,13 +87,13 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
|
||||
// efficient as it fully recomputes the free variables at every
|
||||
// node of interest rather than building up the free variables in
|
||||
// one pass. This could be improved upon if it turns out to matter.
|
||||
pub fn annotate_freevars(def_map: resolve::DefMap, crate: &ast::crate) ->
|
||||
pub fn annotate_freevars(def_map: resolve::DefMap, crate: &ast::Crate) ->
|
||||
freevar_map {
|
||||
let freevars = @mut HashMap::new();
|
||||
|
||||
let walk_fn: @fn(&visit::fn_kind,
|
||||
&ast::fn_decl,
|
||||
&ast::blk,
|
||||
&ast::Block,
|
||||
span,
|
||||
ast::node_id) = |_, _, blk, _, nid| {
|
||||
let vars = collect_freevars(def_map, blk);
|
||||
|
@ -59,7 +59,7 @@ pub struct Context {
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
crate: &crate) {
|
||||
crate: &Crate) {
|
||||
let ctx = Context {
|
||||
tcx: tcx,
|
||||
method_map: method_map,
|
||||
@ -107,7 +107,7 @@ fn check_struct_safe_for_destructor(cx: Context,
|
||||
}
|
||||
}
|
||||
|
||||
fn check_block(block: &blk, (cx, visitor): (Context, visit::vt<Context>)) {
|
||||
fn check_block(block: &Block, (cx, visitor): (Context, visit::vt<Context>)) {
|
||||
visit::visit_block(block, (cx, visitor));
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ fn with_appropriate_checker(cx: Context, id: node_id,
|
||||
fn check_fn(
|
||||
fk: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
sp: span,
|
||||
fn_id: node_id,
|
||||
(cx, v): (Context,
|
||||
|
@ -23,7 +23,7 @@
|
||||
use driver::session::Session;
|
||||
use metadata::csearch::each_lang_item;
|
||||
use metadata::cstore::iter_crate_data;
|
||||
use syntax::ast::{crate, def_id, MetaItem};
|
||||
use syntax::ast::{Crate, def_id, MetaItem};
|
||||
use syntax::ast_util::local_def;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor};
|
||||
@ -291,14 +291,14 @@ impl LanguageItems {
|
||||
struct LanguageItemCollector<'self> {
|
||||
items: LanguageItems,
|
||||
|
||||
crate: &'self crate,
|
||||
crate: &'self Crate,
|
||||
session: Session,
|
||||
|
||||
item_refs: HashMap<@str, uint>,
|
||||
}
|
||||
|
||||
impl<'self> LanguageItemCollector<'self> {
|
||||
pub fn new<'a>(crate: &'a crate, session: Session)
|
||||
pub fn new<'a>(crate: &'a Crate, session: Session)
|
||||
-> LanguageItemCollector<'a> {
|
||||
let mut item_refs = HashMap::new();
|
||||
|
||||
@ -442,7 +442,7 @@ impl<'self> LanguageItemCollector<'self> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn collect_language_items(crate: &crate,
|
||||
pub fn collect_language_items(crate: &Crate,
|
||||
session: Session)
|
||||
-> LanguageItems {
|
||||
let mut collector = LanguageItemCollector::new(crate, session);
|
||||
|
@ -127,7 +127,7 @@ pub type LintDict = HashMap<&'static str, LintSpec>;
|
||||
enum AttributedNode<'self> {
|
||||
Item(@ast::item),
|
||||
Method(&'self ast::method),
|
||||
Crate(@ast::crate),
|
||||
Crate(@ast::Crate),
|
||||
}
|
||||
|
||||
#[deriving(Eq)]
|
||||
@ -938,8 +938,8 @@ fn lint_unused_mut() -> visit::vt<@mut Context> {
|
||||
|
||||
visit::mk_vt(@visit::Visitor {
|
||||
visit_local: |l, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
|
||||
if l.node.is_mutbl {
|
||||
check_pat(cx, l.node.pat);
|
||||
if l.is_mutbl {
|
||||
check_pat(cx, l.pat);
|
||||
}
|
||||
visit::visit_local(l, (cx, vt));
|
||||
},
|
||||
@ -1095,7 +1095,7 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
|
||||
pub fn check_crate(tcx: ty::ctxt, crate: @ast::Crate) {
|
||||
let cx = @mut Context {
|
||||
dict: @get_lint_dict(),
|
||||
curr: SmallIntMap::new(),
|
||||
@ -1128,7 +1128,7 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
|
||||
cx.add_lint(lint_missing_doc());
|
||||
|
||||
// Actually perform the lint checks (iterating the ast)
|
||||
do cx.with_lint_attrs(crate.node.attrs) {
|
||||
do cx.with_lint_attrs(crate.attrs) {
|
||||
cx.process(Crate(crate));
|
||||
|
||||
visit::visit_crate(crate, (cx, visit::mk_vt(@visit::Visitor {
|
||||
|
@ -155,7 +155,7 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
capture_map: moves::CaptureMap,
|
||||
crate: &crate) {
|
||||
crate: &Crate) {
|
||||
let visitor = visit::mk_vt(@visit::Visitor {
|
||||
visit_fn: visit_fn,
|
||||
visit_local: visit_local,
|
||||
@ -343,7 +343,7 @@ impl IrMaps {
|
||||
|
||||
fn visit_fn(fk: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
sp: span,
|
||||
id: node_id,
|
||||
(this, v): (@mut IrMaps,
|
||||
@ -414,20 +414,20 @@ fn visit_fn(fk: &visit::fn_kind,
|
||||
lsets.warn_about_unused_args(decl, entry_ln);
|
||||
}
|
||||
|
||||
fn visit_local(local: @local, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
|
||||
fn visit_local(local: @Local, (this, vt): (@mut IrMaps, vt<@mut IrMaps>)) {
|
||||
let def_map = this.tcx.def_map;
|
||||
do pat_util::pat_bindings(def_map, local.node.pat) |_bm, p_id, sp, path| {
|
||||
do pat_util::pat_bindings(def_map, local.pat) |_bm, p_id, sp, path| {
|
||||
debug!("adding local variable %d", p_id);
|
||||
let name = ast_util::path_to_ident(path);
|
||||
this.add_live_node_for_node(p_id, VarDefNode(sp));
|
||||
let kind = match local.node.init {
|
||||
let kind = match local.init {
|
||||
Some(_) => FromLetWithInitializer,
|
||||
None => FromLetNoInitializer
|
||||
};
|
||||
this.add_variable(Local(LocalInfo {
|
||||
id: p_id,
|
||||
ident: name,
|
||||
is_mutbl: local.node.is_mutbl,
|
||||
is_mutbl: local.is_mutbl,
|
||||
kind: kind
|
||||
}));
|
||||
}
|
||||
@ -884,7 +884,7 @@ impl Liveness {
|
||||
|
||||
// _______________________________________________________________________
|
||||
|
||||
pub fn compute(&self, decl: &fn_decl, body: &blk) -> LiveNode {
|
||||
pub fn compute(&self, decl: &fn_decl, body: &Block) -> LiveNode {
|
||||
// if there is a `break` or `again` at the top level, then it's
|
||||
// effectively a return---this only occurs in `for` loops,
|
||||
// where the body is really a closure.
|
||||
@ -909,7 +909,7 @@ impl Liveness {
|
||||
entry_ln
|
||||
}
|
||||
|
||||
pub fn propagate_through_fn_block(&self, _: &fn_decl, blk: &blk)
|
||||
pub fn propagate_through_fn_block(&self, _: &fn_decl, blk: &Block)
|
||||
-> LiveNode {
|
||||
// the fallthrough exit is only for those cases where we do not
|
||||
// explicitly return:
|
||||
@ -921,7 +921,7 @@ impl Liveness {
|
||||
self.propagate_through_block(blk, self.s.fallthrough_ln)
|
||||
}
|
||||
|
||||
pub fn propagate_through_block(&self, blk: &blk, succ: LiveNode)
|
||||
pub fn propagate_through_block(&self, blk: &Block, succ: LiveNode)
|
||||
-> LiveNode {
|
||||
let succ = self.propagate_through_opt_expr(blk.expr, succ);
|
||||
do blk.stmts.rev_iter().fold(succ) |succ, stmt| {
|
||||
@ -956,7 +956,7 @@ impl Liveness {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn propagate_through_local(&self, local: &local, succ: LiveNode)
|
||||
pub fn propagate_through_local(&self, local: &Local, succ: LiveNode)
|
||||
-> LiveNode {
|
||||
// Note: we mark the variable as defined regardless of whether
|
||||
// there is an initializer. Initially I had thought to only mark
|
||||
@ -972,8 +972,8 @@ impl Liveness {
|
||||
// initialization, which is mildly more complex than checking
|
||||
// once at the func header but otherwise equivalent.
|
||||
|
||||
let succ = self.propagate_through_opt_expr(local.node.init, succ);
|
||||
self.define_bindings_in_pat(local.node.pat, succ)
|
||||
let succ = self.propagate_through_opt_expr(local.init, succ);
|
||||
self.define_bindings_in_pat(local.pat, succ)
|
||||
}
|
||||
|
||||
pub fn propagate_through_exprs(&self, exprs: &[@expr], succ: LiveNode)
|
||||
@ -1331,7 +1331,7 @@ impl Liveness {
|
||||
pub fn propagate_through_loop(&self,
|
||||
expr: &expr,
|
||||
cond: Option<@expr>,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
succ: LiveNode)
|
||||
-> LiveNode {
|
||||
|
||||
@ -1406,10 +1406,10 @@ impl Liveness {
|
||||
// _______________________________________________________________________
|
||||
// Checking for error conditions
|
||||
|
||||
fn check_local(local: @local, (this, vt): (@Liveness, vt<@Liveness>)) {
|
||||
match local.node.init {
|
||||
fn check_local(local: @Local, (this, vt): (@Liveness, vt<@Liveness>)) {
|
||||
match local.init {
|
||||
Some(_) => {
|
||||
this.warn_about_unused_or_dead_vars_in_pat(local.node.pat);
|
||||
this.warn_about_unused_or_dead_vars_in_pat(local.pat);
|
||||
}
|
||||
None => {
|
||||
|
||||
@ -1417,7 +1417,7 @@ fn check_local(local: @local, (this, vt): (@Liveness, vt<@Liveness>)) {
|
||||
// should not be live at this point.
|
||||
|
||||
debug!("check_local() with no initializer");
|
||||
do this.pat_bindings(local.node.pat) |ln, var, sp, id| {
|
||||
do this.pat_bindings(local.pat) |ln, var, sp, id| {
|
||||
if !this.warn_about_unused(sp, id, ln, var) {
|
||||
match this.live_on_exit(ln, var) {
|
||||
None => { /* not live: good */ }
|
||||
@ -1491,7 +1491,7 @@ fn check_expr(expr: @expr, (this, vt): (@Liveness, vt<@Liveness>)) {
|
||||
}
|
||||
|
||||
fn check_fn(_fk: &visit::fn_kind, _decl: &fn_decl,
|
||||
_body: &blk, _sp: span, _id: node_id,
|
||||
_body: &Block, _sp: span, _id: node_id,
|
||||
(_self, _v): (@Liveness, vt<@Liveness>)) {
|
||||
// do not check contents of nested fns
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ enum UseMode {
|
||||
|
||||
pub fn compute_moves(tcx: ty::ctxt,
|
||||
method_map: method_map,
|
||||
crate: &crate) -> MoveMaps
|
||||
crate: &Crate) -> MoveMaps
|
||||
{
|
||||
let visitor = visit::mk_vt(@visit::Visitor {
|
||||
visit_fn: compute_modes_for_fn,
|
||||
@ -227,18 +227,18 @@ pub fn moved_variable_node_id_from_def(def: def) -> Option<node_id> {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Expressions
|
||||
|
||||
fn compute_modes_for_local<'a>(local: @local,
|
||||
fn compute_modes_for_local<'a>(local: @Local,
|
||||
(cx, v): (VisitContext,
|
||||
vt<VisitContext>)) {
|
||||
cx.use_pat(local.node.pat);
|
||||
for local.node.init.iter().advance |&init| {
|
||||
cx.use_pat(local.pat);
|
||||
for local.init.iter().advance |&init| {
|
||||
cx.use_expr(init, Read, v);
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_modes_for_fn(fk: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
span: span,
|
||||
id: node_id,
|
||||
(cx, v): (VisitContext,
|
||||
@ -281,7 +281,7 @@ impl VisitContext {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn consume_block(&self, blk: &blk, visitor: vt<VisitContext>) {
|
||||
pub fn consume_block(&self, blk: &Block, visitor: vt<VisitContext>) {
|
||||
/*!
|
||||
* Indicates that the value of `blk` will be consumed,
|
||||
* meaning either copied or moved depending on its type.
|
||||
|
@ -39,7 +39,7 @@ use syntax::visit;
|
||||
|
||||
pub fn check_crate<'mm>(tcx: ty::ctxt,
|
||||
method_map: &'mm method_map,
|
||||
crate: &ast::crate) {
|
||||
crate: &ast::Crate) {
|
||||
let privileged_items = @mut ~[];
|
||||
|
||||
// Adds an item to its scope.
|
||||
|
@ -110,7 +110,7 @@ impl ReachableContext {
|
||||
|
||||
// Step 1: Mark all public symbols, and add all public symbols that might
|
||||
// be inlined to a worklist.
|
||||
fn mark_public_symbols(&self, crate: @crate) {
|
||||
fn mark_public_symbols(&self, crate: @Crate) {
|
||||
let reachable_symbols = self.reachable_symbols;
|
||||
let worklist = self.worklist;
|
||||
let visitor = visit::mk_vt(@Visitor {
|
||||
@ -403,7 +403,7 @@ impl ReachableContext {
|
||||
|
||||
pub fn find_reachable(tcx: ty::ctxt,
|
||||
method_map: typeck::method_map,
|
||||
crate: @crate)
|
||||
crate: @Crate)
|
||||
-> @mut HashSet<node_id> {
|
||||
// XXX(pcwalton): We only need to mark symbols that are exported. But this
|
||||
// is more complicated than just looking at whether the symbol is `pub`,
|
||||
|
@ -323,7 +323,7 @@ fn parent_to_expr(cx: Context, child_id: ast::node_id, sp: span) {
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_block(blk: &ast::blk, (cx, visitor): (Context, visit::vt<Context>)) {
|
||||
fn resolve_block(blk: &ast::Block, (cx, visitor): (Context, visit::vt<Context>)) {
|
||||
// Record the parent of this block.
|
||||
parent_to_expr(cx, blk.id, blk.span);
|
||||
|
||||
@ -398,11 +398,11 @@ fn resolve_expr(expr: @ast::expr, (cx, visitor): (Context, visit::vt<Context>))
|
||||
visit::visit_expr(expr, (new_cx, visitor));
|
||||
}
|
||||
|
||||
fn resolve_local(local: @ast::local,
|
||||
fn resolve_local(local: @ast::Local,
|
||||
(cx, visitor) : (Context,
|
||||
visit::vt<Context>)) {
|
||||
assert_eq!(cx.var_parent, cx.parent);
|
||||
parent_to_expr(cx, local.node.id, local.span);
|
||||
parent_to_expr(cx, local.id, local.span);
|
||||
visit::visit_local(local, (cx, visitor));
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ fn resolve_item(item: @ast::item, (cx, visitor): (Context, visit::vt<Context>))
|
||||
|
||||
fn resolve_fn(fk: &visit::fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
sp: span,
|
||||
id: ast::node_id,
|
||||
(cx, visitor): (Context,
|
||||
@ -457,7 +457,7 @@ fn resolve_fn(fk: &visit::fn_kind,
|
||||
|
||||
pub fn resolve_crate(sess: Session,
|
||||
def_map: resolve::DefMap,
|
||||
crate: &ast::crate) -> @mut RegionMaps
|
||||
crate: &ast::Crate) -> @mut RegionMaps
|
||||
{
|
||||
let region_maps = @mut RegionMaps {
|
||||
scope_map: HashMap::new(),
|
||||
@ -706,7 +706,7 @@ fn determine_rp_in_item(item: @ast::item,
|
||||
|
||||
fn determine_rp_in_fn(fk: &visit::fn_kind,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
_: span,
|
||||
_: ast::node_id,
|
||||
(cx, visitor): (@mut DetermineRpCtxt,
|
||||
@ -874,7 +874,7 @@ fn determine_rp_in_struct_field(
|
||||
pub fn determine_rp_in_crate(sess: Session,
|
||||
ast_map: ast_map::map,
|
||||
def_map: resolve::DefMap,
|
||||
crate: &ast::crate)
|
||||
crate: &ast::Crate)
|
||||
-> region_paramd_items {
|
||||
let cx = @mut DetermineRpCtxt {
|
||||
sess: sess,
|
||||
|
@ -764,7 +764,7 @@ pub fn namespace_error_to_str(ns: NamespaceError) -> &'static str {
|
||||
|
||||
pub fn Resolver(session: Session,
|
||||
lang_items: LanguageItems,
|
||||
crate: @crate)
|
||||
crate: @Crate)
|
||||
-> Resolver {
|
||||
let graph_root = @mut NameBindings();
|
||||
|
||||
@ -821,7 +821,7 @@ pub fn Resolver(session: Session,
|
||||
pub struct Resolver {
|
||||
session: @Session,
|
||||
lang_items: LanguageItems,
|
||||
crate: @crate,
|
||||
crate: @Crate,
|
||||
|
||||
intr: @ident_interner,
|
||||
|
||||
@ -1050,7 +1050,7 @@ impl Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn block_needs_anonymous_module(@mut self, block: &blk) -> bool {
|
||||
pub fn block_needs_anonymous_module(@mut self, block: &Block) -> bool {
|
||||
// If the block has view items, we need an anonymous module.
|
||||
if block.view_items.len() > 0 {
|
||||
return true;
|
||||
@ -1544,7 +1544,7 @@ impl Resolver {
|
||||
}
|
||||
|
||||
pub fn build_reduced_graph_for_block(@mut self,
|
||||
block: &blk,
|
||||
block: &Block,
|
||||
(parent, visitor):
|
||||
(ReducedGraphParent,
|
||||
vt<ReducedGraphParent>)) {
|
||||
@ -3709,7 +3709,7 @@ impl Resolver {
|
||||
rib_kind: RibKind,
|
||||
optional_declaration: Option<&fn_decl>,
|
||||
type_parameters: TypeParameters,
|
||||
block: &blk,
|
||||
block: &Block,
|
||||
self_binding: SelfBinding,
|
||||
visitor: ResolveVisitor) {
|
||||
// Create a value rib for the function.
|
||||
@ -3983,14 +3983,14 @@ impl Resolver {
|
||||
visit_mod(module_, span, id, ((), visitor));
|
||||
}
|
||||
|
||||
pub fn resolve_local(@mut self, local: @local, visitor: ResolveVisitor) {
|
||||
let mutability = if local.node.is_mutbl {Mutable} else {Immutable};
|
||||
pub fn resolve_local(@mut self, local: @Local, visitor: ResolveVisitor) {
|
||||
let mutability = if local.is_mutbl {Mutable} else {Immutable};
|
||||
|
||||
// Resolve the type.
|
||||
self.resolve_type(&local.node.ty, visitor);
|
||||
self.resolve_type(&local.ty, visitor);
|
||||
|
||||
// Resolve the initializer, if necessary.
|
||||
match local.node.init {
|
||||
match local.init {
|
||||
None => {
|
||||
// Nothing to do.
|
||||
}
|
||||
@ -4000,7 +4000,7 @@ impl Resolver {
|
||||
}
|
||||
|
||||
// Resolve the pattern.
|
||||
self.resolve_pattern(local.node.pat, LocalIrrefutableMode, mutability,
|
||||
self.resolve_pattern(local.pat, LocalIrrefutableMode, mutability,
|
||||
None, visitor);
|
||||
}
|
||||
|
||||
@ -4073,7 +4073,7 @@ impl Resolver {
|
||||
self.value_ribs.pop();
|
||||
}
|
||||
|
||||
pub fn resolve_block(@mut self, block: &blk, visitor: ResolveVisitor) {
|
||||
pub fn resolve_block(@mut self, block: &Block, visitor: ResolveVisitor) {
|
||||
debug!("(resolving block) entering block");
|
||||
self.value_ribs.push(@Rib(NormalRibKind));
|
||||
|
||||
@ -4874,7 +4874,7 @@ impl Resolver {
|
||||
i -= 1;
|
||||
match this.type_ribs[i].kind {
|
||||
MethodRibKind(node_id, _) =>
|
||||
for this.crate.node.module.items.iter().advance |item| {
|
||||
for this.crate.module.items.iter().advance |item| {
|
||||
if item.id == node_id {
|
||||
match item.node {
|
||||
item_struct(class_def, _) => {
|
||||
@ -5407,7 +5407,7 @@ pub struct CrateMap {
|
||||
/// Entry point to crate resolution.
|
||||
pub fn resolve_crate(session: Session,
|
||||
lang_items: LanguageItems,
|
||||
crate: @crate)
|
||||
crate: @Crate)
|
||||
-> CrateMap {
|
||||
let resolver = @mut Resolver(session, lang_items, crate);
|
||||
resolver.resolve();
|
||||
|
@ -1092,23 +1092,23 @@ pub fn trans_trace(bcx: block, sp_opt: Option<span>, trace_str: @str) {
|
||||
Call(bcx, ccx.upcalls.trace, args);
|
||||
}
|
||||
|
||||
pub fn ignore_lhs(_bcx: block, local: &ast::local) -> bool {
|
||||
match local.node.pat.node {
|
||||
pub fn ignore_lhs(_bcx: block, local: &ast::Local) -> bool {
|
||||
match local.pat.node {
|
||||
ast::pat_wild => true, _ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_local(bcx: block, local: &ast::local) -> block {
|
||||
pub fn init_local(bcx: block, local: &ast::Local) -> block {
|
||||
|
||||
debug!("init_local(bcx=%s, local.id=%?)",
|
||||
bcx.to_str(), local.node.id);
|
||||
bcx.to_str(), local.id);
|
||||
let _indenter = indenter();
|
||||
|
||||
let _icx = push_ctxt("init_local");
|
||||
|
||||
if ignore_lhs(bcx, local) {
|
||||
// Handle let _ = e; just like e;
|
||||
match local.node.init {
|
||||
match local.init {
|
||||
Some(init) => {
|
||||
return expr::trans_into(bcx, init, expr::Ignore);
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ pub fn init_local(bcx: block, local: &ast::local) -> block {
|
||||
}
|
||||
}
|
||||
|
||||
_match::store_local(bcx, local.node.pat, local.node.init)
|
||||
_match::store_local(bcx, local.pat, local.init)
|
||||
}
|
||||
|
||||
pub fn trans_stmt(cx: block, s: &ast::stmt) -> block {
|
||||
@ -1445,7 +1445,7 @@ pub fn with_scope_datumblock(bcx: block, opt_node_info: Option<NodeInfo>,
|
||||
DatumBlock {bcx: leave_block(bcx, scope_cx), datum: datum}
|
||||
}
|
||||
|
||||
pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) {
|
||||
pub fn block_locals(b: &ast::Block, it: &fn(@ast::Local)) {
|
||||
for b.stmts.iter().advance |s| {
|
||||
match s.node {
|
||||
ast::stmt_decl(d, _) => {
|
||||
@ -1838,7 +1838,7 @@ pub enum self_arg { impl_self(ty::t, ty::SelfMode), no_self, }
|
||||
pub fn trans_closure(ccx: @mut CrateContext,
|
||||
path: path,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
llfndecl: ValueRef,
|
||||
self_arg: self_arg,
|
||||
param_substs: Option<@param_substs>,
|
||||
@ -1919,7 +1919,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
|
||||
pub fn trans_fn(ccx: @mut CrateContext,
|
||||
path: path,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
llfndecl: ValueRef,
|
||||
self_arg: self_arg,
|
||||
param_substs: Option<@param_substs>,
|
||||
@ -2638,7 +2638,7 @@ pub fn trans_constant(ccx: &mut CrateContext, it: @ast::item) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trans_constants(ccx: @mut CrateContext, crate: &ast::crate) {
|
||||
pub fn trans_constants(ccx: @mut CrateContext, crate: &ast::Crate) {
|
||||
visit::visit_crate(
|
||||
crate, ((),
|
||||
visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
@ -2895,7 +2895,7 @@ pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::encode_
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_metadata(cx: &mut CrateContext, crate: &ast::crate) {
|
||||
pub fn write_metadata(cx: &mut CrateContext, crate: &ast::Crate) {
|
||||
if !*cx.sess.building_library { return; }
|
||||
|
||||
let encode_inlined_item: encoder::encode_inlined_item =
|
||||
@ -2953,7 +2953,7 @@ pub fn write_abi_version(ccx: &mut CrateContext) {
|
||||
}
|
||||
|
||||
pub fn trans_crate(sess: session::Session,
|
||||
crate: &ast::crate,
|
||||
crate: &ast::Crate,
|
||||
tcx: ty::ctxt,
|
||||
output: &Path,
|
||||
emap2: resolve::ExportMap2,
|
||||
@ -2994,7 +2994,7 @@ pub fn trans_crate(sess: session::Session,
|
||||
|
||||
{
|
||||
let _icx = push_ctxt("text");
|
||||
trans_mod(ccx, &crate.node.module);
|
||||
trans_mod(ccx, &crate.module);
|
||||
}
|
||||
|
||||
decl_gc_metadata(ccx, llmod_id);
|
||||
|
@ -554,7 +554,7 @@ pub fn trans_lang_call_with_type_params(bcx: block,
|
||||
ArgVals(args), Some(dest), DontAutorefArg).bcx;
|
||||
}
|
||||
|
||||
pub fn body_contains_ret(body: &ast::blk) -> bool {
|
||||
pub fn body_contains_ret(body: &ast::Block) -> bool {
|
||||
let cx = @mut false;
|
||||
visit::visit_block(body, (cx, visit::mk_vt(@visit::Visitor {
|
||||
visit_item: |_i, (_cx, _v)| { },
|
||||
|
@ -370,7 +370,7 @@ pub fn load_environment(fcx: fn_ctxt,
|
||||
pub fn trans_expr_fn(bcx: block,
|
||||
sigil: ast::Sigil,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
outer_id: ast::node_id,
|
||||
user_id: ast::node_id,
|
||||
is_loop_body: Option<Option<ValueRef>>,
|
||||
|
@ -491,7 +491,7 @@ impl get_node_info for ast::expr {
|
||||
}
|
||||
}
|
||||
|
||||
impl get_node_info for ast::blk {
|
||||
impl get_node_info for ast::Block {
|
||||
fn info(&self) -> Option<NodeInfo> {
|
||||
Some(NodeInfo {id: self.id,
|
||||
callee_id: None,
|
||||
|
@ -34,7 +34,7 @@ use syntax::ast_map::path_mod;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::span;
|
||||
|
||||
pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
|
||||
pub fn trans_block(bcx: block, b: &ast::Block, dest: expr::Dest) -> block {
|
||||
let _icx = push_ctxt("trans_block");
|
||||
let mut bcx = bcx;
|
||||
for b.stmts.iter().advance |s| {
|
||||
@ -55,7 +55,7 @@ pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
|
||||
|
||||
pub fn trans_if(bcx: block,
|
||||
cond: @ast::expr,
|
||||
thn: &ast::blk,
|
||||
thn: &ast::Block,
|
||||
els: Option<@ast::expr>,
|
||||
dest: expr::Dest)
|
||||
-> block {
|
||||
@ -167,7 +167,7 @@ pub fn join_blocks(parent_bcx: block, in_cxs: &[block]) -> block {
|
||||
return out;
|
||||
}
|
||||
|
||||
pub fn trans_while(bcx: block, cond: @ast::expr, body: &ast::blk) -> block {
|
||||
pub fn trans_while(bcx: block, cond: @ast::expr, body: &ast::Block) -> block {
|
||||
let _icx = push_ctxt("trans_while");
|
||||
let next_bcx = sub_block(bcx, "while next");
|
||||
|
||||
@ -207,7 +207,7 @@ pub fn trans_while(bcx: block, cond: @ast::expr, body: &ast::blk) -> block {
|
||||
}
|
||||
|
||||
pub fn trans_loop(bcx:block,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
opt_label: Option<ident>)
|
||||
-> block {
|
||||
let _icx = push_ctxt("trans_loop");
|
||||
|
@ -134,10 +134,10 @@ pub fn finalize(cx: @mut CrateContext) {
|
||||
///
|
||||
/// Adds the created metadata nodes directly to the crate's IR.
|
||||
/// The return value should be ignored if called from outside of the debuginfo module.
|
||||
pub fn create_local_var_metadata(bcx: block, local: @ast::local) -> DIVariable {
|
||||
pub fn create_local_var_metadata(bcx: block, local: @ast::Local) -> DIVariable {
|
||||
let cx = bcx.ccx();
|
||||
|
||||
let ident = match local.node.pat.node {
|
||||
let ident = match local.pat.node {
|
||||
ast::pat_ident(_, ref pth, _) => ast_util::path_to_ident(pth),
|
||||
// FIXME this should be handled (#2533)
|
||||
_ => {
|
||||
@ -150,8 +150,8 @@ pub fn create_local_var_metadata(bcx: block, local: @ast::local) -> DIVariable {
|
||||
debug!("create_local_var_metadata: %s", name);
|
||||
|
||||
let loc = span_start(cx, local.span);
|
||||
let ty = node_id_type(bcx, local.node.id);
|
||||
let type_metadata = type_metadata(cx, ty, local.node.ty.span);
|
||||
let ty = node_id_type(bcx, local.id);
|
||||
let type_metadata = type_metadata(cx, ty, local.ty.span);
|
||||
let file_metadata = file_metadata(cx, loc.file.name);
|
||||
|
||||
let context = match bcx.parent {
|
||||
@ -176,12 +176,12 @@ pub fn create_local_var_metadata(bcx: block, local: @ast::local) -> DIVariable {
|
||||
};
|
||||
|
||||
// FIXME(#6814) Should use `pat_util::pat_bindings` for pats like (a, b) etc
|
||||
let llptr = match bcx.fcx.lllocals.find_copy(&local.node.pat.id) {
|
||||
let llptr = match bcx.fcx.lllocals.find_copy(&local.pat.id) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
bcx.tcx().sess.span_bug(
|
||||
local.span,
|
||||
fmt!("No entry in lllocals table for %?", local.node.id));
|
||||
fmt!("No entry in lllocals table for %?", local.id));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -973,7 +973,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
|
||||
pub fn trans_foreign_fn(ccx: @mut CrateContext,
|
||||
path: ast_map::path,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
llwrapfn: ValueRef,
|
||||
id: ast::node_id) {
|
||||
let _icx = push_ctxt("foreign::build_foreign_fn");
|
||||
@ -981,7 +981,7 @@ pub fn trans_foreign_fn(ccx: @mut CrateContext,
|
||||
fn build_rust_fn(ccx: @mut CrateContext,
|
||||
path: &ast_map::path,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
id: ast::node_id)
|
||||
-> ValueRef {
|
||||
let _icx = push_ctxt("foreign::foreign::build_rust_fn");
|
||||
|
@ -406,7 +406,7 @@ pub fn mark_for_expr(cx: &Context, e: &expr) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_body(cx: &Context, body: &blk) {
|
||||
pub fn handle_body(cx: &Context, body: &Block) {
|
||||
let v = visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: |e, (cx, v)| {
|
||||
visit::visit_expr(e, (cx, v));
|
||||
@ -414,7 +414,7 @@ pub fn handle_body(cx: &Context, body: &blk) {
|
||||
},
|
||||
visit_local: |l, (cx, v)| {
|
||||
visit::visit_local(l, (cx, v));
|
||||
node_type_needs(cx, use_repr, l.node.id);
|
||||
node_type_needs(cx, use_repr, l.id);
|
||||
},
|
||||
visit_pat: |p, (cx, v)| {
|
||||
visit::visit_pat(p, (cx, v));
|
||||
|
@ -2853,7 +2853,7 @@ pub fn tys_in_fn_sig(sig: &FnSig) -> ~[t] {
|
||||
}
|
||||
|
||||
// Type accessors for AST nodes
|
||||
pub fn block_ty(cx: ctxt, b: &ast::blk) -> t {
|
||||
pub fn block_ty(cx: ctxt, b: &ast::Block) -> t {
|
||||
return node_id_to_type(cx, b.id);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ impl PurityState {
|
||||
PurityState { def: def, purity: purity, from_fn: true }
|
||||
}
|
||||
|
||||
pub fn recurse(&mut self, blk: &ast::blk) -> PurityState {
|
||||
pub fn recurse(&mut self, blk: &ast::Block) -> PurityState {
|
||||
match self.purity {
|
||||
// If this unsafe, then if the outer function was already marked as
|
||||
// unsafe we shouldn't attribute the unsafe'ness to the block. This
|
||||
@ -303,7 +303,7 @@ impl ExprTyProvider for FnCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_item_types(ccx: @mut CrateCtxt, crate: &ast::crate) {
|
||||
pub fn check_item_types(ccx: @mut CrateCtxt, crate: &ast::Crate) {
|
||||
let visit = visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
visit_item: |a| check_item(ccx, a),
|
||||
.. *visit::default_simple_visitor()
|
||||
@ -313,7 +313,7 @@ pub fn check_item_types(ccx: @mut CrateCtxt, crate: &ast::crate) {
|
||||
|
||||
pub fn check_bare_fn(ccx: @mut CrateCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
id: ast::node_id,
|
||||
self_info: Option<SelfInfo>) {
|
||||
let fty = ty::node_id_to_type(ccx.tcx, id);
|
||||
@ -339,7 +339,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
fn_sig: &ty::FnSig,
|
||||
decl: &ast::fn_decl,
|
||||
id: ast::node_id,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
fn_kind: FnKind,
|
||||
inherited_isr: isr_alist,
|
||||
inherited: @inherited) -> @mut FnCtxt
|
||||
@ -439,7 +439,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
|
||||
fn gather_locals(fcx: @mut FnCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
arg_tys: &[ty::t],
|
||||
opt_self_info: Option<SelfInfo>) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
@ -484,17 +484,17 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
}
|
||||
|
||||
// Add explicitly-declared locals.
|
||||
let visit_local: @fn(@ast::local, ((), visit::vt<()>)) =
|
||||
let visit_local: @fn(@ast::Local, ((), visit::vt<()>)) =
|
||||
|local, (e, v)| {
|
||||
let o_ty = match local.node.ty.node {
|
||||
let o_ty = match local.ty.node {
|
||||
ast::ty_infer => None,
|
||||
_ => Some(fcx.to_ty(&local.node.ty))
|
||||
_ => Some(fcx.to_ty(&local.ty))
|
||||
};
|
||||
assign(local.node.id, o_ty);
|
||||
assign(local.id, o_ty);
|
||||
debug!("Local variable %s is assigned type %s",
|
||||
fcx.pat_to_str(local.node.pat),
|
||||
fcx.pat_to_str(local.pat),
|
||||
fcx.infcx().ty_to_str(
|
||||
fcx.inh.locals.get_copy(&local.node.id)));
|
||||
fcx.inh.locals.get_copy(&local.id)));
|
||||
visit::visit_local(local, (e, v));
|
||||
};
|
||||
|
||||
@ -514,7 +514,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
visit::visit_pat(p, (e, v));
|
||||
};
|
||||
|
||||
let visit_block: @fn(&ast::blk, ((), visit::vt<()>)) = |b, (e, v)| {
|
||||
let visit_block: @fn(&ast::Block, ((), visit::vt<()>)) = |b, (e, v)| {
|
||||
// non-obvious: the `blk` variable maps to region lb, so
|
||||
// we have to keep this up-to-date. This
|
||||
// is... unfortunate. It'd be nice to not need this.
|
||||
@ -525,7 +525,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
|
||||
// Don't descend into fns and items
|
||||
fn visit_fn(_fk: &visit::fn_kind, _decl: &ast::fn_decl,
|
||||
_body: &ast::blk, _sp: span,
|
||||
_body: &ast::Block, _sp: span,
|
||||
_id: ast::node_id, (_t,_v): ((), visit::vt<()>)) {
|
||||
}
|
||||
fn visit_item(_i: @ast::item, (_e,_v): ((), visit::vt<()>)) { }
|
||||
@ -1456,7 +1456,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||
// or if-check
|
||||
fn check_then_else(fcx: @mut FnCtxt,
|
||||
cond_expr: @ast::expr,
|
||||
then_blk: &ast::blk,
|
||||
then_blk: &ast::Block,
|
||||
opt_else_expr: Option<@ast::expr>,
|
||||
id: ast::node_id,
|
||||
sp: span,
|
||||
@ -1705,7 +1705,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||
expr: @ast::expr,
|
||||
ast_sigil_opt: Option<ast::Sigil>,
|
||||
decl: &ast::fn_decl,
|
||||
body: &ast::blk,
|
||||
body: &ast::Block,
|
||||
fn_kind: FnKind,
|
||||
expected: Option<ty::t>) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
@ -2900,18 +2900,18 @@ pub fn check_decl_initializer(fcx: @mut FnCtxt,
|
||||
check_expr_coercable_to_type(fcx, init, local_ty)
|
||||
}
|
||||
|
||||
pub fn check_decl_local(fcx: @mut FnCtxt, local: @ast::local) {
|
||||
pub fn check_decl_local(fcx: @mut FnCtxt, local: @ast::Local) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
||||
let t = fcx.local_ty(local.span, local.node.id);
|
||||
fcx.write_ty(local.node.id, t);
|
||||
let t = fcx.local_ty(local.span, local.id);
|
||||
fcx.write_ty(local.id, t);
|
||||
|
||||
match local.node.init {
|
||||
match local.init {
|
||||
Some(init) => {
|
||||
check_decl_initializer(fcx, local.node.id, init);
|
||||
check_decl_initializer(fcx, local.id, init);
|
||||
let init_ty = fcx.expr_ty(init);
|
||||
if ty::type_is_error(init_ty) || ty::type_is_bot(init_ty) {
|
||||
fcx.write_ty(local.node.id, init_ty);
|
||||
fcx.write_ty(local.id, init_ty);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@ -2919,12 +2919,12 @@ pub fn check_decl_local(fcx: @mut FnCtxt, local: @ast::local) {
|
||||
|
||||
let pcx = pat_ctxt {
|
||||
fcx: fcx,
|
||||
map: pat_id_map(tcx.def_map, local.node.pat),
|
||||
map: pat_id_map(tcx.def_map, local.pat),
|
||||
};
|
||||
_match::check_pat(&pcx, local.node.pat, t);
|
||||
let pat_ty = fcx.node_ty(local.node.pat.id);
|
||||
_match::check_pat(&pcx, local.pat, t);
|
||||
let pat_ty = fcx.node_ty(local.pat.id);
|
||||
if ty::type_is_error(pat_ty) || ty::type_is_bot(pat_ty) {
|
||||
fcx.write_ty(local.node.id, pat_ty);
|
||||
fcx.write_ty(local.id, pat_ty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2938,7 +2938,7 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) {
|
||||
match decl.node {
|
||||
ast::decl_local(ref l) => {
|
||||
check_decl_local(fcx, *l);
|
||||
let l_t = fcx.node_ty(l.node.id);
|
||||
let l_t = fcx.node_ty(l.id);
|
||||
saw_bot = saw_bot || ty::type_is_bot(l_t);
|
||||
saw_err = saw_err || ty::type_is_error(l_t);
|
||||
}
|
||||
@ -2973,7 +2973,7 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_block_no_value(fcx: @mut FnCtxt, blk: &ast::blk) {
|
||||
pub fn check_block_no_value(fcx: @mut FnCtxt, blk: &ast::Block) {
|
||||
check_block_with_expected(fcx, blk, Some(ty::mk_nil()));
|
||||
let blkty = fcx.node_ty(blk.id);
|
||||
if ty::type_is_error(blkty) {
|
||||
@ -2988,12 +2988,12 @@ pub fn check_block_no_value(fcx: @mut FnCtxt, blk: &ast::blk) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_block(fcx0: @mut FnCtxt, blk: &ast::blk) {
|
||||
pub fn check_block(fcx0: @mut FnCtxt, blk: &ast::Block) {
|
||||
check_block_with_expected(fcx0, blk, None)
|
||||
}
|
||||
|
||||
pub fn check_block_with_expected(fcx: @mut FnCtxt,
|
||||
blk: &ast::blk,
|
||||
blk: &ast::Block,
|
||||
expected: Option<ty::t>) {
|
||||
let purity_state = fcx.ps.recurse(blk);
|
||||
let prev = replace(&mut fcx.ps, purity_state);
|
||||
@ -3419,7 +3419,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: @mut FnCtxt,
|
||||
}
|
||||
|
||||
// Returns true if b contains a break that can exit from b
|
||||
pub fn may_break(cx: ty::ctxt, id: ast::node_id, b: &ast::blk) -> bool {
|
||||
pub fn may_break(cx: ty::ctxt, id: ast::node_id, b: &ast::Block) -> bool {
|
||||
// First: is there an unlabeled break immediately
|
||||
// inside the loop?
|
||||
(loop_query(b, |e| {
|
||||
|
@ -153,7 +153,7 @@ pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::expr) {
|
||||
fcx.infcx().resolve_regions();
|
||||
}
|
||||
|
||||
pub fn regionck_fn(fcx: @mut FnCtxt, blk: &ast::blk) {
|
||||
pub fn regionck_fn(fcx: @mut FnCtxt, blk: &ast::Block) {
|
||||
let rcx = @mut Rcx { fcx: fcx, errors_reported: 0,
|
||||
repeating_scope: blk.id };
|
||||
if fcx.err_count_since_creation() == 0 {
|
||||
@ -187,7 +187,7 @@ fn visit_item(_item: @ast::item, (_rcx, _v): (@mut Rcx, rvt)) {
|
||||
// Ignore items
|
||||
}
|
||||
|
||||
fn visit_block(b: &ast::blk, (rcx, v): (@mut Rcx, rvt)) {
|
||||
fn visit_block(b: &ast::Block, (rcx, v): (@mut Rcx, rvt)) {
|
||||
rcx.fcx.tcx().region_maps.record_cleanup_scope(b.id);
|
||||
visit::visit_block(b, (rcx, v));
|
||||
}
|
||||
@ -201,9 +201,9 @@ fn visit_arm(arm: &ast::arm, (rcx, v): (@mut Rcx, rvt)) {
|
||||
visit::visit_arm(arm, (rcx, v));
|
||||
}
|
||||
|
||||
fn visit_local(l: @ast::local, (rcx, v): (@mut Rcx, rvt)) {
|
||||
fn visit_local(l: @ast::Local, (rcx, v): (@mut Rcx, rvt)) {
|
||||
// see above
|
||||
constrain_bindings_in_pat(l.node.pat, rcx);
|
||||
constrain_bindings_in_pat(l.pat, rcx);
|
||||
visit::visit_local(l, (rcx, v));
|
||||
}
|
||||
|
||||
|
@ -698,7 +698,7 @@ pub fn resolve_impl(ccx: @mut CrateCtxt, impl_item: @ast::item) {
|
||||
|
||||
// Detect points where a trait-bounded type parameter is
|
||||
// instantiated, resolve the impls for the parameters.
|
||||
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::blk) {
|
||||
pub fn resolve_in_block(fcx: @mut FnCtxt, bl: &ast::Block) {
|
||||
visit::visit_block(bl, (fcx, visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: resolve_expr,
|
||||
visit_item: |_,_| {},
|
||||
|
@ -271,7 +271,7 @@ fn visit_expr(e: @ast::expr, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
visit::visit_expr(e, (wbcx, v));
|
||||
}
|
||||
|
||||
fn visit_block(b: &ast::blk, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
fn visit_block(b: &ast::Block, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
if !wbcx.success {
|
||||
return;
|
||||
}
|
||||
@ -294,16 +294,16 @@ fn visit_pat(p: @ast::pat, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
visit::visit_pat(p, (wbcx, v));
|
||||
}
|
||||
|
||||
fn visit_local(l: @ast::local, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
fn visit_local(l: @ast::Local, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
if !wbcx.success { return; }
|
||||
let var_ty = wbcx.fcx.local_ty(l.span, l.node.id);
|
||||
let var_ty = wbcx.fcx.local_ty(l.span, l.id);
|
||||
match resolve_type(wbcx.fcx.infcx(), var_ty, resolve_all | force_all) {
|
||||
Ok(lty) => {
|
||||
debug!("Type for local %s (id %d) resolved to %s",
|
||||
pat_to_str(l.node.pat, wbcx.fcx.tcx().sess.intr()),
|
||||
l.node.id,
|
||||
pat_to_str(l.pat, wbcx.fcx.tcx().sess.intr()),
|
||||
l.id,
|
||||
wbcx.fcx.infcx().ty_to_str(lty));
|
||||
write_ty_to_tcx(wbcx.fcx.ccx.tcx, l.node.id, lty);
|
||||
write_ty_to_tcx(wbcx.fcx.ccx.tcx, l.id, lty);
|
||||
}
|
||||
Err(e) => {
|
||||
wbcx.fcx.ccx.tcx.sess.span_err(
|
||||
@ -339,7 +339,7 @@ pub fn resolve_type_vars_in_expr(fcx: @mut FnCtxt, e: @ast::expr) -> bool {
|
||||
|
||||
pub fn resolve_type_vars_in_fn(fcx: @mut FnCtxt,
|
||||
decl: &ast::fn_decl,
|
||||
blk: &ast::blk,
|
||||
blk: &ast::Block,
|
||||
self_info: Option<SelfInfo>) -> bool {
|
||||
let wbcx = @mut WbCtxt { fcx: fcx, success: true };
|
||||
let visit = mk_visitor();
|
||||
|
@ -36,7 +36,7 @@ use middle::typeck::infer::combine::Combine;
|
||||
use middle::typeck::infer::InferCtxt;
|
||||
use middle::typeck::infer::{new_infer_ctxt, resolve_ivar, resolve_type};
|
||||
use middle::typeck::infer;
|
||||
use syntax::ast::{crate, def_id, def_struct, def_ty};
|
||||
use syntax::ast::{Crate, def_id, def_struct, def_ty};
|
||||
use syntax::ast::{item, item_enum, item_impl, item_mod, item_struct};
|
||||
use syntax::ast::{local_crate, trait_ref, ty_path};
|
||||
use syntax::ast;
|
||||
@ -169,7 +169,7 @@ pub struct CoherenceChecker {
|
||||
}
|
||||
|
||||
impl CoherenceChecker {
|
||||
pub fn check_coherence(self, crate: &crate) {
|
||||
pub fn check_coherence(self, crate: &Crate) {
|
||||
// Check implementations and traits. This populates the tables
|
||||
// containing the inherent methods and extension methods. It also
|
||||
// builds up the trait inheritance table.
|
||||
@ -481,7 +481,7 @@ impl CoherenceChecker {
|
||||
}
|
||||
|
||||
// Privileged scope checking
|
||||
pub fn check_privileged_scopes(self, crate: &crate) {
|
||||
pub fn check_privileged_scopes(self, crate: &Crate) {
|
||||
visit_crate(crate, ((), mk_vt(@Visitor {
|
||||
visit_item: |item, (_context, visitor)| {
|
||||
match item.node {
|
||||
@ -882,7 +882,7 @@ fn subst_receiver_types_in_method_ty(tcx: ty::ctxt,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn check_coherence(crate_context: @mut CrateCtxt, crate: &crate) {
|
||||
pub fn check_coherence(crate_context: @mut CrateCtxt, crate: &Crate) {
|
||||
let coherence_checker = CoherenceChecker(crate_context);
|
||||
coherence_checker.check_coherence(crate);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ use syntax::opt_vec::OptVec;
|
||||
use syntax::opt_vec;
|
||||
use syntax::parse::token::special_idents;
|
||||
|
||||
pub fn collect_item_types(ccx: @mut CrateCtxt, crate: &ast::crate) {
|
||||
pub fn collect_item_types(ccx: @mut CrateCtxt, crate: &ast::Crate) {
|
||||
fn collect_intrinsic_type(ccx: &CrateCtxt,
|
||||
lang_item: ast::def_id) {
|
||||
let ty::ty_param_bounds_and_ty { ty: ty, _ } =
|
||||
|
@ -34,7 +34,7 @@ use syntax::parse::parse_crate_from_source_str;
|
||||
use syntax::{ast, attr, parse};
|
||||
|
||||
struct Env {
|
||||
crate: @ast::crate,
|
||||
crate: @ast::Crate,
|
||||
tcx: ty::ctxt,
|
||||
infcx: infer::infer_ctxt,
|
||||
err_messages: @DVec<~str>
|
||||
|
@ -407,7 +407,7 @@ fn check_for_entry_fn(ccx: &CrateCtxt) {
|
||||
|
||||
pub fn check_crate(tcx: ty::ctxt,
|
||||
trait_map: resolve::TraitMap,
|
||||
crate: &ast::crate)
|
||||
crate: &ast::Crate)
|
||||
-> (method_map, vtable_map) {
|
||||
let time_passes = tcx.sess.time_passes();
|
||||
let ccx = @mut CrateCtxt {
|
||||
|
@ -62,7 +62,7 @@ pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
|
||||
|
||||
// Takes a predicate p, returns true iff p is true for any subexpressions
|
||||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
pub fn loop_query(b: &ast::blk, p: @fn(&ast::expr_) -> bool) -> bool {
|
||||
pub fn loop_query(b: &ast::Block, p: @fn(&ast::expr_) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr: @fn(@ast::expr,
|
||||
(@mut bool,
|
||||
@ -85,7 +85,7 @@ pub fn loop_query(b: &ast::blk, p: @fn(&ast::expr_) -> bool) -> bool {
|
||||
|
||||
// Takes a predicate p, returns true iff p is true for any subexpressions
|
||||
// of b -- skipping any inner loops (loop, while, loop_body)
|
||||
pub fn block_query(b: &ast::blk, p: @fn(@ast::expr) -> bool) -> bool {
|
||||
pub fn block_query(b: &ast::Block, p: @fn(@ast::expr) -> bool) -> bool {
|
||||
let rs = @mut false;
|
||||
let visit_expr: @fn(@ast::expr,
|
||||
(@mut bool,
|
||||
@ -100,8 +100,8 @@ pub fn block_query(b: &ast::blk, p: @fn(@ast::expr) -> bool) -> bool {
|
||||
return *rs;
|
||||
}
|
||||
|
||||
pub fn local_rhs_span(l: @ast::local, def: span) -> span {
|
||||
match l.node.init {
|
||||
pub fn local_rhs_span(l: @ast::Local, def: span) -> span {
|
||||
match l.init {
|
||||
Some(i) => return i.span,
|
||||
_ => return def
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ use syntax::ast_map;
|
||||
use syntax;
|
||||
|
||||
pub struct Ctxt {
|
||||
ast: @ast::crate,
|
||||
ast: @ast::Crate,
|
||||
ast_map: ast_map::map
|
||||
}
|
||||
|
||||
type SrvOwner<'self,T> = &'self fn(srv: Srv) -> T;
|
||||
pub type CtxtHandler<T> = ~fn(ctxt: Ctxt) -> T;
|
||||
type Parser = ~fn(Session, s: @str) -> @ast::crate;
|
||||
type Parser = ~fn(Session, s: @str) -> @ast::Crate;
|
||||
|
||||
enum Msg {
|
||||
HandleRequest(~fn(Ctxt)),
|
||||
@ -109,7 +109,7 @@ pub fn exec<T:Send>(
|
||||
}
|
||||
|
||||
fn build_ctxt(sess: Session,
|
||||
ast: @ast::crate) -> Ctxt {
|
||||
ast: @ast::Crate) -> Ctxt {
|
||||
|
||||
use rustc::front::config;
|
||||
|
||||
@ -143,7 +143,7 @@ fn should_prune_unconfigured_items() {
|
||||
do from_str(source) |srv| {
|
||||
do exec(srv) |ctxt| {
|
||||
// one item: the __std_macros secret module
|
||||
assert_eq!(ctxt.ast.node.module.items.len(), 1);
|
||||
assert_eq!(ctxt.ast.module.items.len(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ fn fold_crate(
|
||||
let doc = fold::default_seq_fold_crate(fold, doc);
|
||||
|
||||
let attrs = do astsrv::exec(srv) |ctxt| {
|
||||
let attrs = ctxt.ast.node.attrs.clone();
|
||||
let attrs = ctxt.ast.attrs.clone();
|
||||
attr_parser::parse_crate(attrs)
|
||||
};
|
||||
|
||||
@ -87,7 +87,7 @@ fn fold_item(
|
||||
let desc = if doc.id == ast::crate_node_id {
|
||||
// This is the top-level mod, use the crate attributes
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
attr_parser::parse_desc(ctxt.ast.node.attrs.clone())
|
||||
attr_parser::parse_desc(ctxt.ast.attrs.clone())
|
||||
}
|
||||
} else {
|
||||
parse_item_attrs(srv, doc.id, attr_parser::parse_desc)
|
||||
|
@ -44,7 +44,7 @@ pub fn from_srv(
|
||||
}
|
||||
|
||||
pub fn extract(
|
||||
crate: @ast::crate,
|
||||
crate: @ast::Crate,
|
||||
default_name: ~str
|
||||
) -> doc::Doc {
|
||||
doc::Doc {
|
||||
@ -57,11 +57,11 @@ pub fn extract(
|
||||
}
|
||||
|
||||
fn top_moddoc_from_crate(
|
||||
crate: @ast::crate,
|
||||
crate: @ast::Crate,
|
||||
default_name: ~str
|
||||
) -> doc::ModDoc {
|
||||
moddoc_from_mod(mk_itemdoc(ast::crate_node_id, default_name),
|
||||
crate.node.module.clone())
|
||||
crate.module.clone())
|
||||
}
|
||||
|
||||
fn mk_itemdoc(id: ast::node_id, name: ~str) -> doc::ItemDoc {
|
||||
|
@ -17,26 +17,26 @@ use rustc::driver::session;
|
||||
use syntax::ast;
|
||||
use syntax::parse;
|
||||
|
||||
pub fn from_file(file: &Path) -> @ast::crate {
|
||||
pub fn from_file(file: &Path) -> @ast::Crate {
|
||||
parse::parse_crate_from_file(
|
||||
file, ~[], parse::new_parse_sess(None))
|
||||
}
|
||||
|
||||
pub fn from_str(source: @str) -> @ast::crate {
|
||||
pub fn from_str(source: @str) -> @ast::Crate {
|
||||
parse::parse_crate_from_source_str(
|
||||
@"-", source, ~[], parse::new_parse_sess(None))
|
||||
}
|
||||
|
||||
pub fn from_file_sess(sess: session::Session, file: &Path) -> @ast::crate {
|
||||
pub fn from_file_sess(sess: session::Session, file: &Path) -> @ast::Crate {
|
||||
parse::parse_crate_from_file(
|
||||
file, cfg(sess, file_input((*file).clone())), sess.parse_sess)
|
||||
}
|
||||
|
||||
pub fn from_str_sess(sess: session::Session, source: @str) -> @ast::crate {
|
||||
pub fn from_str_sess(sess: session::Session, source: @str) -> @ast::Crate {
|
||||
parse::parse_crate_from_source_str(
|
||||
@"-", source, cfg(sess, str_input(source)), sess.parse_sess)
|
||||
}
|
||||
|
||||
fn cfg(sess: session::Session, input: driver::input) -> ast::crate_cfg {
|
||||
fn cfg(sess: session::Session, input: driver::input) -> ast::CrateConfig {
|
||||
driver::build_configuration(sess, @"rustdoc", &input)
|
||||
}
|
||||
|
@ -271,11 +271,11 @@ impl Program {
|
||||
///
|
||||
/// Once the types are known, they are inserted into the local_vars map in
|
||||
/// this Program (to be deserialized later on
|
||||
pub fn register_new_vars(&mut self, blk: &ast::blk, tcx: ty::ctxt) {
|
||||
pub fn register_new_vars(&mut self, blk: &ast::Block, tcx: ty::ctxt) {
|
||||
debug!("looking for new variables");
|
||||
let newvars = @mut HashMap::new();
|
||||
do each_user_local(blk) |local| {
|
||||
let mutable = local.node.is_mutbl;
|
||||
let mutable = local.is_mutbl;
|
||||
do each_binding(local) |path, id| {
|
||||
let name = do with_pp(token::get_ident_interner()) |pp, _| {
|
||||
pprust::print_path(pp, path, false);
|
||||
@ -350,7 +350,7 @@ impl Program {
|
||||
}
|
||||
|
||||
// helper functions to perform ast iteration
|
||||
fn each_user_local(blk: &ast::blk, f: &fn(@ast::local)) {
|
||||
fn each_user_local(blk: &ast::Block, f: &fn(@ast::Local)) {
|
||||
do find_user_block(blk) |blk| {
|
||||
for blk.stmts.iter().advance |stmt| {
|
||||
match stmt.node {
|
||||
@ -366,7 +366,7 @@ impl Program {
|
||||
}
|
||||
}
|
||||
|
||||
fn find_user_block(blk: &ast::blk, f: &fn(&ast::blk)) {
|
||||
fn find_user_block(blk: &ast::Block, f: &fn(&ast::Block)) {
|
||||
for blk.stmts.iter().advance |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_semi(e, _) => {
|
||||
|
@ -185,7 +185,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
// Local declarations must be specially dealt with,
|
||||
// record all local declarations for use later on
|
||||
ast::decl_local(l) => {
|
||||
let mutbl = l.node.is_mutbl;
|
||||
let mutbl = l.is_mutbl;
|
||||
do each_binding(l) |path, _| {
|
||||
let s = do with_pp(intr) |pp, _| {
|
||||
pprust::print_path(pp, path, false);
|
||||
@ -261,7 +261,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
return (program, jit::consume_engine());
|
||||
|
||||
fn parse_input(sess: session::Session, binary: @str,
|
||||
input: &str) -> @ast::crate {
|
||||
input: &str) -> @ast::Crate {
|
||||
let code = fmt!("fn main() {\n %s \n}", input);
|
||||
let input = driver::str_input(code.to_managed());
|
||||
let cfg = driver::build_configuration(sess, binary, &input);
|
||||
@ -271,9 +271,9 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
crate.expect("parsing should return a crate")
|
||||
}
|
||||
|
||||
fn find_main(crate: @ast::crate, sess: session::Session,
|
||||
f: &fn(&ast::blk)) {
|
||||
for crate.node.module.items.iter().advance |item| {
|
||||
fn find_main(crate: @ast::Crate, sess: session::Session,
|
||||
f: &fn(&ast::Block)) {
|
||||
for crate.module.items.iter().advance |item| {
|
||||
match item.node {
|
||||
ast::item_fn(_, _, _, _, ref blk) => {
|
||||
if item.ident == sess.ident_of("main") {
|
||||
|
@ -14,7 +14,7 @@ use syntax::print::pp;
|
||||
use syntax::print::pprust;
|
||||
use syntax::parse::token;
|
||||
|
||||
pub fn each_binding(l: @ast::local, f: @fn(&ast::Path, ast::node_id)) {
|
||||
pub fn each_binding(l: @ast::Local, f: @fn(&ast::Path, ast::node_id)) {
|
||||
use syntax::visit;
|
||||
|
||||
let vt = visit::mk_simple_visitor(
|
||||
@ -30,7 +30,7 @@ pub fn each_binding(l: @ast::local, f: @fn(&ast::Path, ast::node_id)) {
|
||||
.. *visit::default_simple_visitor()
|
||||
}
|
||||
);
|
||||
(vt.visit_pat)(l.node.pat, ((), vt));
|
||||
(vt.visit_pat)(l.pat, ((), vt));
|
||||
}
|
||||
|
||||
/// A utility function that hands off a pretty printer to a callback.
|
||||
|
@ -83,9 +83,9 @@ struct PkgScript<'self> {
|
||||
/// build script
|
||||
sess: session::Session,
|
||||
/// The config for compiling the custom build script
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
/// The crate for the custom build script
|
||||
crate: @ast::crate,
|
||||
crate: @ast::Crate,
|
||||
/// Directory in which to store build output
|
||||
build_dir: Path
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ struct ListenerFn {
|
||||
|
||||
struct ReadyCtx {
|
||||
sess: session::Session,
|
||||
crate: @ast::crate,
|
||||
crate: @ast::Crate,
|
||||
ext_cx: @ExtCtxt,
|
||||
path: ~[ast::ident],
|
||||
fns: ~[ListenerFn]
|
||||
@ -139,7 +139,7 @@ fn fold_item(ctx: @mut ReadyCtx,
|
||||
|
||||
/// Generate/filter main function, add the list of commands, etc.
|
||||
pub fn ready_crate(sess: session::Session,
|
||||
crate: @ast::crate) -> @ast::crate {
|
||||
crate: @ast::Crate) -> @ast::Crate {
|
||||
let ctx = @mut ReadyCtx {
|
||||
sess: sess,
|
||||
crate: crate,
|
||||
@ -238,7 +238,7 @@ pub fn compile_input(ctxt: &Ctx,
|
||||
});
|
||||
|
||||
// Inject the link attributes so we get the right package name and version
|
||||
if attr::find_linkage_metas(crate.node.attrs).is_empty() {
|
||||
if attr::find_linkage_metas(crate.attrs).is_empty() {
|
||||
let short_name_to_use = match what {
|
||||
Test => fmt!("%stest", pkg_id.short_name),
|
||||
Bench => fmt!("%sbench", pkg_id.short_name),
|
||||
@ -249,9 +249,10 @@ pub fn compile_input(ctxt: &Ctx,
|
||||
~[attr::mk_name_value_item_str(@"name", short_name_to_use.to_managed()),
|
||||
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())];
|
||||
|
||||
crate = @codemap::respan(crate.span, ast::crate_ {
|
||||
crate = @ast::Crate {
|
||||
attrs: ~[attr::mk_attr(attr::mk_list_item(@"link", link_options))],
|
||||
.. crate.node.clone()});
|
||||
.. (*crate).clone()
|
||||
};
|
||||
}
|
||||
|
||||
debug!("calling compile_crate_from_input, out_dir = %s,
|
||||
@ -268,15 +269,15 @@ pub fn compile_input(ctxt: &Ctx,
|
||||
pub fn compile_crate_from_input(input: &driver::input,
|
||||
build_dir: &Path,
|
||||
sess: session::Session,
|
||||
crate: @ast::crate,
|
||||
cfg: ast::crate_cfg,
|
||||
crate: @ast::Crate,
|
||||
cfg: ast::CrateConfig,
|
||||
compile_from: driver::compile_phase) {
|
||||
debug!("Calling build_output_filenames with %s, building library? %?",
|
||||
build_dir.to_str(), sess.building_library);
|
||||
|
||||
// bad copy
|
||||
let outputs = driver::build_output_filenames(input, &Some((*build_dir).clone()), &None,
|
||||
crate.node.attrs, sess);
|
||||
crate.attrs, sess);
|
||||
|
||||
debug!("Outputs are %? and output type = %?", outputs, sess.opts.output_type);
|
||||
debug!("additional libraries:");
|
||||
@ -324,7 +325,7 @@ pub fn compile_crate(ctxt: &Ctx, pkg_id: &PkgId,
|
||||
pub fn find_and_install_dependencies(ctxt: &Ctx,
|
||||
sess: session::Session,
|
||||
workspace: &Path,
|
||||
c: &ast::crate,
|
||||
c: &ast::Crate,
|
||||
save: @fn(Path)
|
||||
) {
|
||||
// :-(
|
||||
|
@ -113,17 +113,17 @@ pub struct Path {
|
||||
types: ~[Ty],
|
||||
}
|
||||
|
||||
pub type crate_num = int;
|
||||
pub type CrateNum = int;
|
||||
|
||||
pub type node_id = int;
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub struct def_id {
|
||||
crate: crate_num,
|
||||
crate: CrateNum,
|
||||
node: node_id,
|
||||
}
|
||||
|
||||
pub static local_crate: crate_num = 0;
|
||||
pub static local_crate: CrateNum = 0;
|
||||
pub static crate_node_id: node_id = 0;
|
||||
|
||||
// The AST represents all type param bounds as types.
|
||||
@ -195,15 +195,14 @@ pub enum def {
|
||||
|
||||
// The set of MetaItems that define the compilation environment of the crate,
|
||||
// used to drive conditional compilation
|
||||
pub type crate_cfg = ~[@MetaItem];
|
||||
|
||||
pub type crate = spanned<crate_>;
|
||||
pub type CrateConfig = ~[@MetaItem];
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub struct crate_ {
|
||||
pub struct Crate {
|
||||
module: _mod,
|
||||
attrs: ~[Attribute],
|
||||
config: crate_cfg,
|
||||
config: CrateConfig,
|
||||
span: span,
|
||||
}
|
||||
|
||||
pub type MetaItem = spanned<MetaItem_>;
|
||||
@ -240,10 +239,8 @@ impl Eq for MetaItem_ {
|
||||
}
|
||||
}
|
||||
|
||||
//pub type blk = spanned<blk_>;
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable,IterBytes)]
|
||||
pub struct blk {
|
||||
pub struct Block {
|
||||
view_items: ~[view_item],
|
||||
stmts: ~[@stmt],
|
||||
expr: Option<@expr>,
|
||||
@ -385,22 +382,21 @@ pub enum stmt_ {
|
||||
// FIXME (pending discussion of #1697, #2178...): local should really be
|
||||
// a refinement on pat.
|
||||
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||
pub struct local_ {
|
||||
pub struct Local {
|
||||
is_mutbl: bool,
|
||||
ty: Ty,
|
||||
pat: @pat,
|
||||
init: Option<@expr>,
|
||||
id: node_id,
|
||||
span: span,
|
||||
}
|
||||
|
||||
pub type local = spanned<local_>;
|
||||
|
||||
pub type decl = spanned<decl_>;
|
||||
|
||||
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||
pub enum decl_ {
|
||||
// a local (let) binding:
|
||||
decl_local(@local),
|
||||
decl_local(@Local),
|
||||
// an item binding:
|
||||
decl_item(@item),
|
||||
}
|
||||
@ -409,7 +405,7 @@ pub enum decl_ {
|
||||
pub struct arm {
|
||||
pats: ~[@pat],
|
||||
guard: Option<@expr>,
|
||||
body: blk,
|
||||
body: Block,
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
@ -464,21 +460,21 @@ pub enum expr_ {
|
||||
expr_unary(node_id, unop, @expr),
|
||||
expr_lit(@lit),
|
||||
expr_cast(@expr, Ty),
|
||||
expr_if(@expr, blk, Option<@expr>),
|
||||
expr_while(@expr, blk),
|
||||
expr_if(@expr, Block, Option<@expr>),
|
||||
expr_while(@expr, Block),
|
||||
/* Conditionless loop (can be exited with break, cont, or ret)
|
||||
Same semantics as while(true) { body }, but typestate knows that the
|
||||
(implicit) condition is always true. */
|
||||
expr_loop(blk, Option<ident>),
|
||||
expr_loop(Block, Option<ident>),
|
||||
expr_match(@expr, ~[arm]),
|
||||
expr_fn_block(fn_decl, blk),
|
||||
expr_fn_block(fn_decl, Block),
|
||||
// Inner expr is always an expr_fn_block. We need the wrapping node to
|
||||
// easily type this (a function returning nil on the inside but bool on
|
||||
// the outside).
|
||||
expr_loop_body(@expr),
|
||||
// Like expr_loop_body but for 'do' blocks
|
||||
expr_do_body(@expr),
|
||||
expr_block(blk),
|
||||
expr_block(Block),
|
||||
|
||||
expr_assign(@expr, @expr),
|
||||
expr_assign_op(node_id, binop, @expr, @expr),
|
||||
@ -863,7 +859,7 @@ pub struct method {
|
||||
explicit_self: explicit_self,
|
||||
purity: purity,
|
||||
decl: fn_decl,
|
||||
body: blk,
|
||||
body: Block,
|
||||
id: node_id,
|
||||
span: span,
|
||||
self_id: node_id,
|
||||
@ -1051,7 +1047,7 @@ pub struct item {
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub enum item_ {
|
||||
item_static(Ty, mutability, @expr),
|
||||
item_fn(fn_decl, purity, AbiSet, Generics, blk),
|
||||
item_fn(fn_decl, purity, AbiSet, Generics, Block),
|
||||
item_mod(_mod),
|
||||
item_foreign_mod(foreign_mod),
|
||||
item_ty(Ty, Generics),
|
||||
|
@ -73,7 +73,7 @@ pub enum ast_node {
|
||||
node_stmt(@stmt),
|
||||
node_arg,
|
||||
node_local(ident),
|
||||
node_block(blk),
|
||||
node_block(Block),
|
||||
node_struct_ctor(@struct_def, @item, @path),
|
||||
node_callee_scope(@expr)
|
||||
}
|
||||
@ -104,7 +104,7 @@ pub fn mk_ast_map_visitor() -> vt {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn map_crate(diag: @span_handler, c: &crate) -> map {
|
||||
pub fn map_crate(diag: @span_handler, c: &Crate) -> map {
|
||||
let cx = @mut Ctx {
|
||||
map: @mut HashMap::new(),
|
||||
path: ~[],
|
||||
@ -157,7 +157,7 @@ pub fn map_decoded_item(diag: @span_handler,
|
||||
pub fn map_fn(
|
||||
fk: &visit::fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
sp: codemap::span,
|
||||
id: node_id,
|
||||
(cx,v): (@mut Ctx,
|
||||
@ -169,7 +169,7 @@ pub fn map_fn(
|
||||
visit::visit_fn(fk, decl, body, sp, id, (cx, v));
|
||||
}
|
||||
|
||||
pub fn map_block(b: &blk, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
|
||||
pub fn map_block(b: &Block, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
|
||||
cx.map.insert(b.id, node_block(/* FIXME (#2543) */ (*b).clone()));
|
||||
visit::visit_block(b, (cx, v));
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ pub fn is_call_expr(e: @expr) -> bool {
|
||||
match e.node { expr_call(*) => true, _ => false }
|
||||
}
|
||||
|
||||
pub fn block_from_expr(e: @expr) -> blk {
|
||||
pub fn block_from_expr(e: @expr) -> Block {
|
||||
let mut blk = default_block(~[], option::Some::<@expr>(e), e.id);
|
||||
blk.span = e.span;
|
||||
return blk;
|
||||
@ -205,8 +205,8 @@ pub fn default_block(
|
||||
stmts1: ~[@stmt],
|
||||
expr1: Option<@expr>,
|
||||
id1: node_id
|
||||
) -> blk {
|
||||
ast::blk {
|
||||
) -> Block {
|
||||
ast::Block {
|
||||
view_items: ~[],
|
||||
stmts: stmts1,
|
||||
expr: expr1,
|
||||
@ -443,7 +443,7 @@ pub fn id_visitor<T: Clone>(vfn: @fn(node_id, T)) -> visit::vt<T> {
|
||||
},
|
||||
|
||||
visit_local: |l, (t, vt)| {
|
||||
vfn(l.node.id, t.clone());
|
||||
vfn(l.id, t.clone());
|
||||
visit::visit_local(l, (t, vt));
|
||||
},
|
||||
visit_block: |b, (t, vt)| {
|
||||
@ -570,7 +570,7 @@ pub trait EachViewItem {
|
||||
pub fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool;
|
||||
}
|
||||
|
||||
impl EachViewItem for ast::crate {
|
||||
impl EachViewItem for ast::Crate {
|
||||
fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool {
|
||||
let broke = @mut false;
|
||||
let vtor: visit::vt<()> = visit::mk_simple_visitor(@visit::SimpleVisitor {
|
||||
|
@ -212,7 +212,7 @@ pub fn syntax_expander_table() -> SyntaxEnv {
|
||||
// -> expn_info of their expansion context stored into their span.
|
||||
pub struct ExtCtxt {
|
||||
parse_sess: @mut parse::ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
backtrace: @mut Option<@ExpnInfo>,
|
||||
|
||||
// These two @mut's should really not be here,
|
||||
@ -225,7 +225,7 @@ pub struct ExtCtxt {
|
||||
}
|
||||
|
||||
impl ExtCtxt {
|
||||
pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg)
|
||||
pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::CrateConfig)
|
||||
-> @ExtCtxt {
|
||||
@ExtCtxt {
|
||||
parse_sess: parse_sess,
|
||||
@ -238,7 +238,7 @@ impl ExtCtxt {
|
||||
|
||||
pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
|
||||
pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
|
||||
pub fn cfg(&self) -> ast::crate_cfg { self.cfg.clone() }
|
||||
pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
|
||||
pub fn call_site(&self) -> span {
|
||||
match *self.backtrace {
|
||||
Some(@ExpnInfo {call_site: cs, _}) => cs,
|
||||
|
@ -76,12 +76,12 @@ pub trait AstBuilder {
|
||||
fn stmt_let(&self, sp: span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt;
|
||||
|
||||
// blocks
|
||||
fn blk(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::blk;
|
||||
fn blk_expr(&self, expr: @ast::expr) -> ast::blk;
|
||||
fn blk(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> ast::Block;
|
||||
fn blk_expr(&self, expr: @ast::expr) -> ast::Block;
|
||||
fn blk_all(&self, span: span,
|
||||
view_items: ~[ast::view_item],
|
||||
stmts: ~[@ast::stmt],
|
||||
expr: Option<@ast::expr>) -> ast::blk;
|
||||
expr: Option<@ast::expr>) -> ast::Block;
|
||||
|
||||
// expressions
|
||||
fn expr(&self, span: span, node: ast::expr_) -> @ast::expr;
|
||||
@ -105,7 +105,7 @@ pub trait AstBuilder {
|
||||
fn expr_method_call(&self, span: span,
|
||||
expr: @ast::expr, ident: ast::ident,
|
||||
args: ~[@ast::expr]) -> @ast::expr;
|
||||
fn expr_blk(&self, b: ast::blk) -> @ast::expr;
|
||||
fn expr_blk(&self, b: ast::Block) -> @ast::expr;
|
||||
|
||||
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field;
|
||||
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr;
|
||||
@ -147,11 +147,11 @@ pub trait AstBuilder {
|
||||
fn expr_if(&self, span: span,
|
||||
cond: @ast::expr, then: @ast::expr, els: Option<@ast::expr>) -> @ast::expr;
|
||||
|
||||
fn lambda_fn_decl(&self, span: span, fn_decl: ast::fn_decl, blk: ast::blk) -> @ast::expr;
|
||||
fn lambda_fn_decl(&self, span: span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr;
|
||||
|
||||
fn lambda(&self, span: span, ids: ~[ast::ident], blk: ast::blk) -> @ast::expr;
|
||||
fn lambda0(&self, span: span, blk: ast::blk) -> @ast::expr;
|
||||
fn lambda1(&self, span: span, blk: ast::blk, ident: ast::ident) -> @ast::expr;
|
||||
fn lambda(&self, span: span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr;
|
||||
fn lambda0(&self, span: span, blk: ast::Block) -> @ast::expr;
|
||||
fn lambda1(&self, span: span, blk: ast::Block, ident: ast::ident) -> @ast::expr;
|
||||
|
||||
fn lambda_expr(&self, span: span, ids: ~[ast::ident], blk: @ast::expr) -> @ast::expr;
|
||||
fn lambda_expr_0(&self, span: span, expr: @ast::expr) -> @ast::expr;
|
||||
@ -175,13 +175,13 @@ pub trait AstBuilder {
|
||||
inputs: ~[ast::arg],
|
||||
output: ast::Ty,
|
||||
generics: Generics,
|
||||
body: ast::blk) -> @ast::item;
|
||||
body: ast::Block) -> @ast::item;
|
||||
fn item_fn(&self,
|
||||
span: span,
|
||||
name: ident,
|
||||
inputs: ~[ast::arg],
|
||||
output: ast::Ty,
|
||||
body: ast::blk) -> @ast::item;
|
||||
body: ast::Block) -> @ast::item;
|
||||
|
||||
fn variant(&self, span: span, name: ident, tys: ~[ast::Ty]) -> ast::variant;
|
||||
fn item_enum_poly(&self,
|
||||
@ -375,31 +375,31 @@ impl AstBuilder for @ExtCtxt {
|
||||
|
||||
fn stmt_let(&self, sp: span, mutbl: bool, ident: ast::ident, ex: @ast::expr) -> @ast::stmt {
|
||||
let pat = self.pat_ident(sp, ident);
|
||||
let local = @respan(sp,
|
||||
ast::local_ {
|
||||
is_mutbl: mutbl,
|
||||
ty: self.ty_infer(sp),
|
||||
pat: pat,
|
||||
init: Some(ex),
|
||||
id: self.next_id(),
|
||||
});
|
||||
let local = @ast::Local {
|
||||
is_mutbl: mutbl,
|
||||
ty: self.ty_infer(sp),
|
||||
pat: pat,
|
||||
init: Some(ex),
|
||||
id: self.next_id(),
|
||||
span: sp,
|
||||
};
|
||||
let decl = respan(sp, ast::decl_local(local));
|
||||
@respan(sp, ast::stmt_decl(@decl, self.next_id()))
|
||||
}
|
||||
|
||||
fn blk(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::blk {
|
||||
fn blk(&self, span: span, stmts: ~[@ast::stmt], expr: Option<@expr>) -> ast::Block {
|
||||
self.blk_all(span, ~[], stmts, expr)
|
||||
}
|
||||
|
||||
fn blk_expr(&self, expr: @ast::expr) -> ast::blk {
|
||||
fn blk_expr(&self, expr: @ast::expr) -> ast::Block {
|
||||
self.blk_all(expr.span, ~[], ~[], Some(expr))
|
||||
}
|
||||
fn blk_all(&self,
|
||||
span: span,
|
||||
view_items: ~[ast::view_item],
|
||||
stmts: ~[@ast::stmt],
|
||||
expr: Option<@ast::expr>) -> ast::blk {
|
||||
ast::blk {
|
||||
expr: Option<@ast::expr>) -> ast::Block {
|
||||
ast::Block {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
@ -474,7 +474,7 @@ impl AstBuilder for @ExtCtxt {
|
||||
self.expr(span,
|
||||
ast::expr_method_call(self.next_id(), expr, ident, ~[], args, ast::NoSugar))
|
||||
}
|
||||
fn expr_blk(&self, b: ast::blk) -> @ast::expr {
|
||||
fn expr_blk(&self, b: ast::Block) -> @ast::expr {
|
||||
self.expr(b.span, ast::expr_block(b))
|
||||
}
|
||||
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field {
|
||||
@ -595,23 +595,23 @@ impl AstBuilder for @ExtCtxt {
|
||||
self.expr(span, ast::expr_if(cond, self.blk_expr(then), els))
|
||||
}
|
||||
|
||||
fn lambda_fn_decl(&self, span: span, fn_decl: ast::fn_decl, blk: ast::blk) -> @ast::expr {
|
||||
fn lambda_fn_decl(&self, span: span, fn_decl: ast::fn_decl, blk: ast::Block) -> @ast::expr {
|
||||
self.expr(span, ast::expr_fn_block(fn_decl, blk))
|
||||
}
|
||||
fn lambda(&self, span: span, ids: ~[ast::ident], blk: ast::blk) -> @ast::expr {
|
||||
fn lambda(&self, span: span, ids: ~[ast::ident], blk: ast::Block) -> @ast::expr {
|
||||
let fn_decl = self.fn_decl(
|
||||
ids.map(|id| self.arg(span, *id, self.ty_infer(span))),
|
||||
self.ty_infer(span));
|
||||
|
||||
self.expr(span, ast::expr_fn_block(fn_decl, blk))
|
||||
}
|
||||
fn lambda0(&self, _span: span, blk: ast::blk) -> @ast::expr {
|
||||
fn lambda0(&self, _span: span, blk: ast::Block) -> @ast::expr {
|
||||
let ext_cx = *self;
|
||||
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
|
||||
quote_expr!(|| $blk_e )
|
||||
}
|
||||
|
||||
fn lambda1(&self, _span: span, blk: ast::blk, ident: ast::ident) -> @ast::expr {
|
||||
fn lambda1(&self, _span: span, blk: ast::Block, ident: ast::ident) -> @ast::expr {
|
||||
let ext_cx = *self;
|
||||
let blk_e = self.expr(blk.span, ast::expr_block(blk.clone()));
|
||||
quote_expr!(|$ident| $blk_e )
|
||||
@ -674,7 +674,7 @@ impl AstBuilder for @ExtCtxt {
|
||||
inputs: ~[ast::arg],
|
||||
output: ast::Ty,
|
||||
generics: Generics,
|
||||
body: ast::blk) -> @ast::item {
|
||||
body: ast::Block) -> @ast::item {
|
||||
self.item(span,
|
||||
name,
|
||||
~[],
|
||||
@ -690,7 +690,7 @@ impl AstBuilder for @ExtCtxt {
|
||||
name: ident,
|
||||
inputs: ~[ast::arg],
|
||||
output: ast::Ty,
|
||||
body: ast::blk
|
||||
body: ast::Block
|
||||
) -> @ast::item {
|
||||
self.item_fn_poly(
|
||||
span,
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast::{blk, crate, expr_, expr_mac, mac_invoc_tt};
|
||||
use ast::{Block, Crate, expr_, expr_mac, mac_invoc_tt};
|
||||
use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
|
||||
use ast::{illegal_ctxt};
|
||||
use ast;
|
||||
@ -395,10 +395,10 @@ pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> {
|
||||
|
||||
pub fn expand_block(extsbox: @mut SyntaxEnv,
|
||||
_cx: @ExtCtxt,
|
||||
blk: &blk,
|
||||
blk: &Block,
|
||||
fld: @ast_fold,
|
||||
orig: @fn(&blk, @ast_fold) -> blk)
|
||||
-> blk {
|
||||
orig: @fn(&Block, @ast_fold) -> Block)
|
||||
-> Block {
|
||||
// see note below about treatment of exts table
|
||||
with_exts_frame!(extsbox,false,orig(blk,fld))
|
||||
}
|
||||
@ -691,7 +691,7 @@ pub fn std_macros() -> @str {
|
||||
// add a bunch of macros as though they were placed at the head of the
|
||||
// program (ick). This should run before cfg stripping.
|
||||
pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
|
||||
cfg: ast::crate_cfg, c: &crate) -> @crate {
|
||||
cfg: ast::CrateConfig, c: &Crate) -> @Crate {
|
||||
let sm = match parse_item_from_source_str(@"<std-macros>",
|
||||
std_macros(),
|
||||
cfg.clone(),
|
||||
@ -718,7 +718,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
|
||||
}
|
||||
|
||||
pub fn expand_crate(parse_sess: @mut parse::ParseSess,
|
||||
cfg: ast::crate_cfg, c: &crate) -> @crate {
|
||||
cfg: ast::CrateConfig, c: &Crate) -> @Crate {
|
||||
// adding *another* layer of indirection here so that the block
|
||||
// visitor can swap out one exts table for another for the duration
|
||||
// of the block. The cleaner alternative would be to thread the
|
||||
|
@ -110,7 +110,7 @@ pub mod rt {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToSource for ast::blk {
|
||||
impl ToSource for ast::Block {
|
||||
fn to_source(&self) -> @str {
|
||||
pprust::block_to_str(self, get_ident_interner()).to_managed()
|
||||
}
|
||||
@ -238,7 +238,7 @@ pub mod rt {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToTokens for ast::blk {
|
||||
impl ToTokens for ast::Block {
|
||||
fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] {
|
||||
cx.parse_tts(self.to_source())
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ pub enum parse_result {
|
||||
|
||||
pub fn parse_or_else(
|
||||
sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
rdr: @reader,
|
||||
ms: ~[matcher]
|
||||
) -> HashMap<ident, @named_match> {
|
||||
@ -236,7 +236,7 @@ pub fn parse_or_else(
|
||||
|
||||
pub fn parse(
|
||||
sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
rdr: @reader,
|
||||
ms: &[matcher]
|
||||
) -> parse_result {
|
||||
|
@ -15,14 +15,14 @@ use parse::token;
|
||||
use opt_vec::OptVec;
|
||||
|
||||
pub trait ast_fold {
|
||||
fn fold_crate(@self, &crate) -> crate;
|
||||
fn fold_crate(@self, &Crate) -> Crate;
|
||||
fn fold_view_item(@self, &view_item) -> view_item;
|
||||
fn fold_foreign_item(@self, @foreign_item) -> @foreign_item;
|
||||
fn fold_item(@self, @item) -> Option<@item>;
|
||||
fn fold_struct_field(@self, @struct_field) -> @struct_field;
|
||||
fn fold_item_underscore(@self, &item_) -> item_;
|
||||
fn fold_method(@self, @method) -> @method;
|
||||
fn fold_block(@self, &blk) -> blk;
|
||||
fn fold_block(@self, &Block) -> Block;
|
||||
fn fold_stmt(@self, &stmt) -> Option<@stmt>;
|
||||
fn fold_arm(@self, &arm) -> arm;
|
||||
fn fold_pat(@self, @pat) -> @pat;
|
||||
@ -34,7 +34,7 @@ pub trait ast_fold {
|
||||
fn fold_variant(@self, &variant) -> variant;
|
||||
fn fold_ident(@self, ident) -> ident;
|
||||
fn fold_path(@self, &Path) -> Path;
|
||||
fn fold_local(@self, @local) -> @local;
|
||||
fn fold_local(@self, @Local) -> @Local;
|
||||
fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr];
|
||||
fn new_id(@self, node_id) -> node_id;
|
||||
fn new_span(@self, span) -> span;
|
||||
@ -44,14 +44,14 @@ pub trait ast_fold {
|
||||
|
||||
pub struct AstFoldFns {
|
||||
//unlike the others, item_ is non-trivial
|
||||
fold_crate: @fn(&crate_, span, @ast_fold) -> (crate_, span),
|
||||
fold_crate: @fn(&Crate, @ast_fold) -> Crate,
|
||||
fold_view_item: @fn(&view_item_, @ast_fold) -> view_item_,
|
||||
fold_foreign_item: @fn(@foreign_item, @ast_fold) -> @foreign_item,
|
||||
fold_item: @fn(@item, @ast_fold) -> Option<@item>,
|
||||
fold_struct_field: @fn(@struct_field, @ast_fold) -> @struct_field,
|
||||
fold_item_underscore: @fn(&item_, @ast_fold) -> item_,
|
||||
fold_method: @fn(@method, @ast_fold) -> @method,
|
||||
fold_block: @fn(&blk, @ast_fold) -> blk,
|
||||
fold_block: @fn(&Block, @ast_fold) -> Block,
|
||||
fold_stmt: @fn(&stmt_, span, @ast_fold) -> (Option<stmt_>, span),
|
||||
fold_arm: @fn(&arm, @ast_fold) -> arm,
|
||||
fold_pat: @fn(&pat_, span, @ast_fold) -> (pat_, span),
|
||||
@ -63,7 +63,7 @@ pub struct AstFoldFns {
|
||||
fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span),
|
||||
fold_ident: @fn(ident, @ast_fold) -> ident,
|
||||
fold_path: @fn(&Path, @ast_fold) -> Path,
|
||||
fold_local: @fn(&local_, span, @ast_fold) -> (local_, span),
|
||||
fold_local: @fn(@Local, @ast_fold) -> @Local,
|
||||
map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr],
|
||||
new_id: @fn(node_id) -> node_id,
|
||||
new_span: @fn(span) -> span
|
||||
@ -196,14 +196,15 @@ pub fn fold_generics(generics: &Generics, fld: @ast_fold) -> Generics {
|
||||
lifetimes: fold_lifetimes(&generics.lifetimes, fld)}
|
||||
}
|
||||
|
||||
pub fn noop_fold_crate(c: &crate_, fld: @ast_fold) -> crate_ {
|
||||
pub fn noop_fold_crate(c: &Crate, fld: @ast_fold) -> Crate {
|
||||
let fold_meta_item = |x| fold_meta_item_(x, fld);
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
|
||||
crate_ {
|
||||
Crate {
|
||||
module: fld.fold_mod(&c.module),
|
||||
attrs: c.attrs.map(|x| fold_attribute(*x)),
|
||||
config: c.config.map(|x| fold_meta_item(*x)),
|
||||
span: fld.new_span(c.span),
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,7 +377,7 @@ fn noop_fold_method(m: @method, fld: @ast_fold) -> @method {
|
||||
}
|
||||
|
||||
|
||||
pub fn noop_fold_block(b: &blk, fld: @ast_fold) -> blk {
|
||||
pub fn noop_fold_block(b: &Block, fld: @ast_fold) -> Block {
|
||||
let view_items = b.view_items.map(|x| fld.fold_view_item(x));
|
||||
let mut stmts = ~[];
|
||||
for b.stmts.iter().advance |stmt| {
|
||||
@ -385,7 +386,7 @@ pub fn noop_fold_block(b: &blk, fld: @ast_fold) -> blk {
|
||||
Some(stmt) => stmts.push(stmt)
|
||||
}
|
||||
}
|
||||
ast::blk {
|
||||
ast::Block {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: b.expr.map(|x| fld.fold_expr(*x)),
|
||||
@ -771,13 +772,14 @@ fn noop_fold_path(p: &Path, fld: @ast_fold) -> Path {
|
||||
}
|
||||
}
|
||||
|
||||
fn noop_fold_local(l: &local_, fld: @ast_fold) -> local_ {
|
||||
local_ {
|
||||
fn noop_fold_local(l: @Local, fld: @ast_fold) -> @Local {
|
||||
@Local {
|
||||
is_mutbl: l.is_mutbl,
|
||||
ty: fld.fold_ty(&l.ty),
|
||||
pat: fld.fold_pat(l.pat),
|
||||
init: l.init.map(|e| fld.fold_expr(*e)),
|
||||
id: fld.new_id(l.id),
|
||||
span: fld.new_span(l.span),
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,7 +795,7 @@ fn noop_span(sp: span) -> span { return sp; }
|
||||
|
||||
pub fn default_ast_fold() -> ast_fold_fns {
|
||||
@AstFoldFns {
|
||||
fold_crate: wrap(noop_fold_crate),
|
||||
fold_crate: noop_fold_crate,
|
||||
fold_view_item: noop_fold_view_item,
|
||||
fold_foreign_item: noop_fold_foreign_item,
|
||||
fold_item: noop_fold_item,
|
||||
@ -812,7 +814,7 @@ pub fn default_ast_fold() -> ast_fold_fns {
|
||||
fold_variant: wrap(noop_fold_variant),
|
||||
fold_ident: noop_fold_ident,
|
||||
fold_path: noop_fold_path,
|
||||
fold_local: wrap(noop_fold_local),
|
||||
fold_local: noop_fold_local,
|
||||
map_exprs: noop_map_exprs,
|
||||
new_id: noop_id,
|
||||
new_span: noop_span,
|
||||
@ -821,9 +823,8 @@ pub fn default_ast_fold() -> ast_fold_fns {
|
||||
|
||||
impl ast_fold for AstFoldFns {
|
||||
/* naturally, a macro to write these would be nice */
|
||||
fn fold_crate(@self, c: &crate) -> crate {
|
||||
let (n, s) = (self.fold_crate)(&c.node, c.span, self as @ast_fold);
|
||||
spanned { node: n, span: (self.new_span)(s) }
|
||||
fn fold_crate(@self, c: &Crate) -> Crate {
|
||||
(self.fold_crate)(c, self as @ast_fold)
|
||||
}
|
||||
fn fold_view_item(@self, x: &view_item) -> view_item {
|
||||
ast::view_item {
|
||||
@ -856,7 +857,7 @@ impl ast_fold for AstFoldFns {
|
||||
fn fold_method(@self, x: @method) -> @method {
|
||||
(self.fold_method)(x, self as @ast_fold)
|
||||
}
|
||||
fn fold_block(@self, x: &blk) -> blk {
|
||||
fn fold_block(@self, x: &Block) -> Block {
|
||||
(self.fold_block)(x, self as @ast_fold)
|
||||
}
|
||||
fn fold_stmt(@self, x: &stmt) -> Option<@stmt> {
|
||||
@ -916,9 +917,8 @@ impl ast_fold for AstFoldFns {
|
||||
fn fold_path(@self, x: &Path) -> Path {
|
||||
(self.fold_path)(x, self as @ast_fold)
|
||||
}
|
||||
fn fold_local(@self, x: @local) -> @local {
|
||||
let (n, s) = (self.fold_local)(&x.node, x.span, self as @ast_fold);
|
||||
@spanned { node: n, span: (self.new_span)(s) }
|
||||
fn fold_local(@self, x: @Local) -> @Local {
|
||||
(self.fold_local)(x, self as @ast_fold)
|
||||
}
|
||||
fn map_exprs(@self,
|
||||
f: @fn(@expr) -> @expr,
|
||||
@ -969,8 +969,8 @@ mod test {
|
||||
}
|
||||
|
||||
// this version doesn't care about getting comments or docstrings in.
|
||||
fn fake_print_crate(s: @pprust::ps, crate: &ast::crate) {
|
||||
pprust::print_mod(s, &crate.node.module, crate.node.attrs);
|
||||
fn fake_print_crate(s: @pprust::ps, crate: &ast::Crate) {
|
||||
pprust::print_mod(s, &crate.module, crate.attrs);
|
||||
}
|
||||
|
||||
// change every identifier to "zz"
|
||||
|
@ -39,7 +39,7 @@ pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
|
||||
pub fn expr_is_simple_block(e: @ast::expr) -> bool {
|
||||
match e.node {
|
||||
ast::expr_block(
|
||||
ast::blk { rules: ast::default_blk, _ }
|
||||
ast::Block { rules: ast::default_blk, _ }
|
||||
) => true,
|
||||
_ => false
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ pub fn new_parse_sess_special_handler(sh: @span_handler,
|
||||
|
||||
pub fn parse_crate_from_file(
|
||||
input: &Path,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @mut ParseSess
|
||||
) -> @ast::crate {
|
||||
) -> @ast::Crate {
|
||||
new_parser_from_file(sess, /*bad*/ cfg.clone(), input).parse_crate_mod()
|
||||
// why is there no p.abort_if_errors here?
|
||||
}
|
||||
@ -86,9 +86,9 @@ pub fn parse_crate_from_file(
|
||||
pub fn parse_crate_from_source_str(
|
||||
name: @str,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @mut ParseSess
|
||||
) -> @ast::crate {
|
||||
) -> @ast::Crate {
|
||||
let p = new_parser_from_source_str(sess,
|
||||
/*bad*/ cfg.clone(),
|
||||
name,
|
||||
@ -99,7 +99,7 @@ pub fn parse_crate_from_source_str(
|
||||
pub fn parse_expr_from_source_str(
|
||||
name: @str,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @mut ParseSess
|
||||
) -> @ast::expr {
|
||||
let p = new_parser_from_source_str(
|
||||
@ -114,7 +114,7 @@ pub fn parse_expr_from_source_str(
|
||||
pub fn parse_item_from_source_str(
|
||||
name: @str,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
attrs: ~[ast::Attribute],
|
||||
sess: @mut ParseSess
|
||||
) -> Option<@ast::item> {
|
||||
@ -130,7 +130,7 @@ pub fn parse_item_from_source_str(
|
||||
pub fn parse_meta_from_source_str(
|
||||
name: @str,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @mut ParseSess
|
||||
) -> @ast::MetaItem {
|
||||
let p = new_parser_from_source_str(
|
||||
@ -145,7 +145,7 @@ pub fn parse_meta_from_source_str(
|
||||
pub fn parse_stmt_from_source_str(
|
||||
name: @str,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
attrs: ~[ast::Attribute],
|
||||
sess: @mut ParseSess
|
||||
) -> @ast::stmt {
|
||||
@ -161,7 +161,7 @@ pub fn parse_stmt_from_source_str(
|
||||
pub fn parse_tts_from_source_str(
|
||||
name: @str,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @mut ParseSess
|
||||
) -> ~[ast::token_tree] {
|
||||
let p = new_parser_from_source_str(
|
||||
@ -184,7 +184,7 @@ pub fn parse_from_source_str<T>(
|
||||
f: &fn(&Parser) -> T,
|
||||
name: @str, ss: codemap::FileSubstr,
|
||||
source: @str,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @mut ParseSess
|
||||
) -> T {
|
||||
let p = new_parser_from_source_substr(
|
||||
@ -212,7 +212,7 @@ pub fn next_node_id(sess: @mut ParseSess) -> node_id {
|
||||
|
||||
// Create a new parser from a source string
|
||||
pub fn new_parser_from_source_str(sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
name: @str,
|
||||
source: @str)
|
||||
-> Parser {
|
||||
@ -222,7 +222,7 @@ pub fn new_parser_from_source_str(sess: @mut ParseSess,
|
||||
// Create a new parser from a source string where the origin
|
||||
// is specified as a substring of another file.
|
||||
pub fn new_parser_from_source_substr(sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
name: @str,
|
||||
ss: codemap::FileSubstr,
|
||||
source: @str)
|
||||
@ -234,7 +234,7 @@ pub fn new_parser_from_source_substr(sess: @mut ParseSess,
|
||||
/// if the file doesn't exist
|
||||
pub fn new_parser_from_file(
|
||||
sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
path: &Path
|
||||
) -> Parser {
|
||||
filemap_to_parser(sess,file_to_filemap(sess,path,None),cfg)
|
||||
@ -245,7 +245,7 @@ pub fn new_parser_from_file(
|
||||
/// On an error, use the given span as the source of the problem.
|
||||
pub fn new_sub_parser_from_file(
|
||||
sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
path: &Path,
|
||||
sp: span
|
||||
) -> Parser {
|
||||
@ -255,14 +255,14 @@ pub fn new_sub_parser_from_file(
|
||||
/// Given a filemap and config, return a parser
|
||||
pub fn filemap_to_parser(sess: @mut ParseSess,
|
||||
filemap: @FileMap,
|
||||
cfg: ast::crate_cfg) -> Parser {
|
||||
cfg: ast::CrateConfig) -> Parser {
|
||||
tts_to_parser(sess,filemap_to_tts(sess,filemap),cfg)
|
||||
}
|
||||
|
||||
// must preserve old name for now, because quote! from the *existing*
|
||||
// compiler expands into it
|
||||
pub fn new_parser_from_tts(sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
tts: ~[ast::token_tree]) -> Parser {
|
||||
tts_to_parser(sess,tts,cfg)
|
||||
}
|
||||
@ -313,7 +313,7 @@ pub fn filemap_to_tts(sess: @mut ParseSess, filemap: @FileMap)
|
||||
// given tts and cfg, produce a parser
|
||||
pub fn tts_to_parser(sess: @mut ParseSess,
|
||||
tts: ~[ast::token_tree],
|
||||
cfg: ast::crate_cfg) -> Parser {
|
||||
cfg: ast::CrateConfig) -> Parser {
|
||||
let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts);
|
||||
Parser(sess, cfg, trdr as @reader)
|
||||
}
|
||||
@ -551,7 +551,7 @@ mod test {
|
||||
lifetimes: opt_vec::Empty,
|
||||
ty_params: opt_vec::Empty,
|
||||
},
|
||||
ast::blk {
|
||||
ast::Block {
|
||||
view_items: ~[],
|
||||
stmts: ~[@spanned{
|
||||
node: ast::stmt_semi(@ast::expr{
|
||||
|
@ -16,9 +16,9 @@ use ast::{TyBareFn, TyClosure};
|
||||
use ast::{RegionTyParamBound, TraitTyParamBound};
|
||||
use ast::{provided, public, purity};
|
||||
use ast::{_mod, add, arg, arm, Attribute, bind_by_ref, bind_infer};
|
||||
use ast::{bitand, bitor, bitxor, blk};
|
||||
use ast::{bitand, bitor, bitxor, Block};
|
||||
use ast::{blk_check_mode, box};
|
||||
use ast::{crate, crate_cfg, decl, decl_item};
|
||||
use ast::{Crate, CrateConfig, decl, decl_item};
|
||||
use ast::{decl_local, default_blk, deref, div, enum_def, explicit_self};
|
||||
use ast::{expr, expr_, expr_addr_of, expr_match, expr_again};
|
||||
use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
|
||||
@ -36,7 +36,7 @@ use ast::{ident, impure_fn, inherited, item, item_, item_static};
|
||||
use ast::{item_enum, item_fn, item_foreign_mod, item_impl};
|
||||
use ast::{item_mac, item_mod, item_struct, item_trait, item_ty, lit, lit_};
|
||||
use ast::{lit_bool, lit_float, lit_float_unsuffixed, lit_int};
|
||||
use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const};
|
||||
use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, Local, m_const};
|
||||
use ast::{m_imm, m_mutbl, mac_, mac_invoc_tt, matcher, match_nonterminal};
|
||||
use ast::{match_seq, match_tok, method, mt, mul, mutability};
|
||||
use ast::{named_field, neg, node_id, noreturn, not, pat, pat_box, pat_enum};
|
||||
@ -261,7 +261,7 @@ struct ParsedItemsAndViewItems {
|
||||
/* ident is handled by common.rs */
|
||||
|
||||
pub fn Parser(sess: @mut ParseSess,
|
||||
cfg: ast::crate_cfg,
|
||||
cfg: ast::CrateConfig,
|
||||
rdr: @reader)
|
||||
-> Parser {
|
||||
let tok0 = rdr.next_token();
|
||||
@ -299,7 +299,7 @@ pub fn Parser(sess: @mut ParseSess,
|
||||
// ooh, nasty mutable fields everywhere....
|
||||
pub struct Parser {
|
||||
sess: @mut ParseSess,
|
||||
cfg: crate_cfg,
|
||||
cfg: CrateConfig,
|
||||
// the current token:
|
||||
token: @mut token::Token,
|
||||
// the span of the current token:
|
||||
@ -2294,7 +2294,7 @@ impl Parser {
|
||||
let lo = self.last_span.lo;
|
||||
let decl = parse_decl();
|
||||
let body = parse_body();
|
||||
let fakeblock = ast::blk {
|
||||
let fakeblock = ast::Block {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(body),
|
||||
@ -2460,7 +2460,7 @@ impl Parser {
|
||||
self.eat(&token::COMMA);
|
||||
}
|
||||
|
||||
let blk = ast::blk {
|
||||
let blk = ast::Block {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
@ -2916,7 +2916,7 @@ impl Parser {
|
||||
}
|
||||
|
||||
// parse a local variable declaration
|
||||
fn parse_local(&self, is_mutbl: bool) -> @local {
|
||||
fn parse_local(&self, is_mutbl: bool) -> @Local {
|
||||
let lo = self.span.lo;
|
||||
let pat = self.parse_pat();
|
||||
|
||||
@ -2931,17 +2931,14 @@ impl Parser {
|
||||
};
|
||||
if self.eat(&token::COLON) { ty = self.parse_ty(false); }
|
||||
let init = self.parse_initializer();
|
||||
@spanned(
|
||||
lo,
|
||||
self.last_span.hi,
|
||||
ast::local_ {
|
||||
is_mutbl: is_mutbl,
|
||||
ty: ty,
|
||||
pat: pat,
|
||||
init: init,
|
||||
id: self.get_id(),
|
||||
}
|
||||
)
|
||||
@ast::Local {
|
||||
is_mutbl: is_mutbl,
|
||||
ty: ty,
|
||||
pat: pat,
|
||||
init: init,
|
||||
id: self.get_id(),
|
||||
span: mk_sp(lo, self.last_span.hi),
|
||||
}
|
||||
}
|
||||
|
||||
// parse a "let" stmt
|
||||
@ -3077,7 +3074,7 @@ impl Parser {
|
||||
}
|
||||
|
||||
// parse a block. No inner attrs are allowed.
|
||||
pub fn parse_block(&self) -> blk {
|
||||
pub fn parse_block(&self) -> Block {
|
||||
maybe_whole!(self, nt_block);
|
||||
|
||||
let lo = self.span.lo;
|
||||
@ -3091,7 +3088,7 @@ impl Parser {
|
||||
|
||||
// parse a block. Inner attrs are allowed.
|
||||
fn parse_inner_attrs_and_block(&self)
|
||||
-> (~[Attribute], blk) {
|
||||
-> (~[Attribute], Block) {
|
||||
|
||||
maybe_whole!(pair_empty self, nt_block);
|
||||
|
||||
@ -3109,13 +3106,13 @@ impl Parser {
|
||||
// I guess that also means "already parsed the 'impure'" if
|
||||
// necessary, and this should take a qualifier.
|
||||
// some blocks start with "#{"...
|
||||
fn parse_block_tail(&self, lo: BytePos, s: blk_check_mode) -> blk {
|
||||
fn parse_block_tail(&self, lo: BytePos, s: blk_check_mode) -> Block {
|
||||
self.parse_block_tail_(lo, s, ~[])
|
||||
}
|
||||
|
||||
// parse the rest of a block expression or function body
|
||||
fn parse_block_tail_(&self, lo: BytePos, s: blk_check_mode,
|
||||
first_item_attrs: ~[Attribute]) -> blk {
|
||||
first_item_attrs: ~[Attribute]) -> Block {
|
||||
let mut stmts = ~[];
|
||||
let mut expr = None;
|
||||
|
||||
@ -3237,7 +3234,7 @@ impl Parser {
|
||||
|
||||
let hi = self.span.hi;
|
||||
self.bump();
|
||||
ast::blk {
|
||||
ast::Block {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
@ -4946,7 +4943,7 @@ impl Parser {
|
||||
|
||||
// Parses a source module as a crate. This is the main
|
||||
// entry point for the parser.
|
||||
pub fn parse_crate_mod(&self) -> @crate {
|
||||
pub fn parse_crate_mod(&self) -> @Crate {
|
||||
let lo = self.span.lo;
|
||||
// parse the crate's inner attrs, maybe (oops) one
|
||||
// of the attrs of an item:
|
||||
@ -4954,10 +4951,13 @@ impl Parser {
|
||||
let first_item_outer_attrs = next;
|
||||
// parse the items inside the crate:
|
||||
let m = self.parse_mod_items(token::EOF, first_item_outer_attrs);
|
||||
@spanned(lo, self.span.lo,
|
||||
ast::crate_ { module: m,
|
||||
attrs: inner,
|
||||
config: self.cfg.clone() })
|
||||
|
||||
@ast::Crate {
|
||||
module: m,
|
||||
attrs: inner,
|
||||
config: self.cfg.clone(),
|
||||
span: mk_sp(lo, self.span.lo)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_str(&self) -> @str {
|
||||
|
@ -99,7 +99,7 @@ pub enum Token {
|
||||
/// For interpolation during macro expansion.
|
||||
pub enum nonterminal {
|
||||
nt_item(@ast::item),
|
||||
nt_block(ast::blk),
|
||||
nt_block(ast::Block),
|
||||
nt_stmt(@ast::stmt),
|
||||
nt_pat( @ast::pat),
|
||||
nt_expr(@ast::expr),
|
||||
|
@ -33,7 +33,7 @@ use std::uint;
|
||||
|
||||
// The @ps is stored here to prevent recursive type.
|
||||
pub enum ann_node<'self> {
|
||||
node_block(@ps, &'self ast::blk),
|
||||
node_block(@ps, &'self ast::Block),
|
||||
node_item(@ps, &'self ast::item),
|
||||
node_expr(@ps, &'self ast::expr),
|
||||
node_pat(@ps, &'self ast::pat),
|
||||
@ -106,7 +106,7 @@ pub static default_columns: uint = 78u;
|
||||
pub fn print_crate(cm: @CodeMap,
|
||||
intr: @ident_interner,
|
||||
span_diagnostic: @diagnostic::span_handler,
|
||||
crate: &ast::crate,
|
||||
crate: &ast::Crate,
|
||||
filename: @str,
|
||||
in: @io::Reader,
|
||||
out: @io::Writer,
|
||||
@ -140,8 +140,8 @@ pub fn print_crate(cm: @CodeMap,
|
||||
print_crate_(s, crate);
|
||||
}
|
||||
|
||||
pub fn print_crate_(s: @ps, crate: &ast::crate) {
|
||||
print_mod(s, &crate.node.module, crate.node.attrs);
|
||||
pub fn print_crate_(s: @ps, crate: &ast::Crate) {
|
||||
print_mod(s, &crate.module, crate.attrs);
|
||||
print_remaining_comments(s);
|
||||
eof(s.s);
|
||||
}
|
||||
@ -200,7 +200,7 @@ pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::ident,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn block_to_str(blk: &ast::blk, intr: @ident_interner) -> ~str {
|
||||
pub fn block_to_str(blk: &ast::Block, intr: @ident_interner) -> ~str {
|
||||
do io::with_str_writer |wr| {
|
||||
let s = rust_printer(wr, intr);
|
||||
// containing cbox, will be closed by print-block at }
|
||||
@ -910,22 +910,22 @@ pub fn print_stmt(s: @ps, st: &ast::stmt) {
|
||||
maybe_print_trailing_comment(s, st.span, None);
|
||||
}
|
||||
|
||||
pub fn print_block(s: @ps, blk: &ast::blk) {
|
||||
pub fn print_block(s: @ps, blk: &ast::Block) {
|
||||
print_possibly_embedded_block(s, blk, block_normal, indent_unit);
|
||||
}
|
||||
|
||||
pub fn print_block_unclosed(s: @ps, blk: &ast::blk) {
|
||||
pub fn print_block_unclosed(s: @ps, blk: &ast::Block) {
|
||||
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, &[],
|
||||
false);
|
||||
}
|
||||
|
||||
pub fn print_block_unclosed_indent(s: @ps, blk: &ast::blk, indented: uint) {
|
||||
pub fn print_block_unclosed_indent(s: @ps, blk: &ast::Block, indented: uint) {
|
||||
print_possibly_embedded_block_(s, blk, block_normal, indented, &[],
|
||||
false);
|
||||
}
|
||||
|
||||
pub fn print_block_with_attrs(s: @ps,
|
||||
blk: &ast::blk,
|
||||
blk: &ast::Block,
|
||||
attrs: &[ast::Attribute]) {
|
||||
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs,
|
||||
true);
|
||||
@ -934,7 +934,7 @@ pub fn print_block_with_attrs(s: @ps,
|
||||
pub enum embed_type { block_block_fn, block_normal, }
|
||||
|
||||
pub fn print_possibly_embedded_block(s: @ps,
|
||||
blk: &ast::blk,
|
||||
blk: &ast::Block,
|
||||
embedded: embed_type,
|
||||
indented: uint) {
|
||||
print_possibly_embedded_block_(
|
||||
@ -942,7 +942,7 @@ pub fn print_possibly_embedded_block(s: @ps,
|
||||
}
|
||||
|
||||
pub fn print_possibly_embedded_block_(s: @ps,
|
||||
blk: &ast::blk,
|
||||
blk: &ast::Block,
|
||||
embedded: embed_type,
|
||||
indented: uint,
|
||||
attrs: &[ast::Attribute],
|
||||
@ -977,7 +977,7 @@ pub fn print_possibly_embedded_block_(s: @ps,
|
||||
(s.ann.post)(ann_node);
|
||||
}
|
||||
|
||||
pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::blk,
|
||||
pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::Block,
|
||||
elseopt: Option<@ast::expr>, chk: bool) {
|
||||
head(s, "if");
|
||||
if chk { word_nbsp(s, "check"); }
|
||||
@ -1447,11 +1447,11 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
|
||||
end(s);
|
||||
}
|
||||
|
||||
pub fn print_local_decl(s: @ps, loc: &ast::local) {
|
||||
print_pat(s, loc.node.pat);
|
||||
match loc.node.ty.node {
|
||||
pub fn print_local_decl(s: @ps, loc: &ast::Local) {
|
||||
print_pat(s, loc.pat);
|
||||
match loc.ty.node {
|
||||
ast::ty_infer => (),
|
||||
_ => { word_space(s, ":"); print_type(s, &loc.node.ty); }
|
||||
_ => { word_space(s, ":"); print_type(s, &loc.ty); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1463,15 +1463,15 @@ pub fn print_decl(s: @ps, decl: &ast::decl) {
|
||||
ibox(s, indent_unit);
|
||||
word_nbsp(s, "let");
|
||||
|
||||
if loc.node.is_mutbl {
|
||||
if loc.is_mutbl {
|
||||
word_nbsp(s, "mut");
|
||||
}
|
||||
|
||||
fn print_local(s: @ps, loc: &ast::local) {
|
||||
fn print_local(s: @ps, loc: &ast::Local) {
|
||||
ibox(s, indent_unit);
|
||||
print_local_decl(s, loc);
|
||||
end(s);
|
||||
match loc.node.init {
|
||||
match loc.init {
|
||||
Some(init) => {
|
||||
nbsp(s);
|
||||
word_space(s, "=");
|
||||
@ -1492,7 +1492,7 @@ pub fn print_ident(s: @ps, ident: ast::ident) {
|
||||
word(s.s, ident_to_str(&ident));
|
||||
}
|
||||
|
||||
pub fn print_for_decl(s: @ps, loc: &ast::local, coll: &ast::expr) {
|
||||
pub fn print_for_decl(s: @ps, loc: &ast::Local, coll: &ast::expr) {
|
||||
print_local_decl(s, loc);
|
||||
space(s.s);
|
||||
word_space(s, "in");
|
||||
|
@ -33,7 +33,7 @@ pub fn string_to_parser(source_str: @str) -> Parser {
|
||||
p
|
||||
}
|
||||
|
||||
pub fn string_to_crate (source_str : @str) -> @ast::crate {
|
||||
pub fn string_to_crate (source_str : @str) -> @ast::Crate {
|
||||
string_to_parser(source_str).parse_crate_mod()
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ pub struct Visitor<E> {
|
||||
visit_view_item: @fn(&view_item, (E, vt<E>)),
|
||||
visit_foreign_item: @fn(@foreign_item, (E, vt<E>)),
|
||||
visit_item: @fn(@item, (E, vt<E>)),
|
||||
visit_local: @fn(@local, (E, vt<E>)),
|
||||
visit_block: @fn(&blk, (E, vt<E>)),
|
||||
visit_local: @fn(@Local, (E, vt<E>)),
|
||||
visit_block: @fn(&Block, (E, vt<E>)),
|
||||
visit_stmt: @fn(@stmt, (E, vt<E>)),
|
||||
visit_arm: @fn(&arm, (E, vt<E>)),
|
||||
visit_pat: @fn(@pat, (E, vt<E>)),
|
||||
@ -85,7 +85,7 @@ pub struct Visitor<E> {
|
||||
visit_expr_post: @fn(@expr, (E, vt<E>)),
|
||||
visit_ty: @fn(&Ty, (E, vt<E>)),
|
||||
visit_generics: @fn(&Generics, (E, vt<E>)),
|
||||
visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id, (E, vt<E>)),
|
||||
visit_fn: @fn(&fn_kind, &fn_decl, &Block, span, node_id, (E, vt<E>)),
|
||||
visit_ty_method: @fn(&ty_method, (E, vt<E>)),
|
||||
visit_trait_method: @fn(&trait_method, (E, vt<E>)),
|
||||
visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, (E, vt<E>)),
|
||||
@ -118,8 +118,8 @@ pub fn default_visitor<E:Clone>() -> visitor<E> {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn visit_crate<E:Clone>(c: &crate, (e, v): (E, vt<E>)) {
|
||||
(v.visit_mod)(&c.node.module, c.span, crate_node_id, (e, v));
|
||||
pub fn visit_crate<E:Clone>(c: &Crate, (e, v): (E, vt<E>)) {
|
||||
(v.visit_mod)(&c.module, c.span, crate_node_id, (e, v));
|
||||
}
|
||||
|
||||
pub fn visit_mod<E:Clone>(m: &_mod,
|
||||
@ -136,10 +136,10 @@ pub fn visit_mod<E:Clone>(m: &_mod,
|
||||
|
||||
pub fn visit_view_item<E>(_vi: &view_item, (_e, _v): (E, vt<E>)) { }
|
||||
|
||||
pub fn visit_local<E:Clone>(loc: &local, (e, v): (E, vt<E>)) {
|
||||
(v.visit_pat)(loc.node.pat, (e.clone(), v));
|
||||
(v.visit_ty)(&loc.node.ty, (e.clone(), v));
|
||||
match loc.node.init {
|
||||
pub fn visit_local<E:Clone>(loc: &Local, (e, v): (E, vt<E>)) {
|
||||
(v.visit_pat)(loc.pat, (e.clone(), v));
|
||||
(v.visit_ty)(&loc.ty, (e.clone(), v));
|
||||
match loc.init {
|
||||
None => (),
|
||||
Some(ex) => (v.visit_expr)(ex, (e, v))
|
||||
}
|
||||
@ -386,7 +386,7 @@ pub fn visit_method_helper<E:Clone>(m: &method, (e, v): (E, vt<E>)) {
|
||||
(e, v));
|
||||
}
|
||||
|
||||
pub fn visit_fn<E:Clone>(fk: &fn_kind, decl: &fn_decl, body: &blk, _sp: span,
|
||||
pub fn visit_fn<E:Clone>(fk: &fn_kind, decl: &fn_decl, body: &Block, _sp: span,
|
||||
_id: node_id, (e, v): (E, vt<E>)) {
|
||||
visit_fn_decl(decl, (e.clone(), v));
|
||||
let generics = generics_of_fn(fk);
|
||||
@ -425,7 +425,7 @@ pub fn visit_struct_field<E:Clone>(sf: &struct_field, (e, v): (E, vt<E>)) {
|
||||
(v.visit_ty)(&sf.node.ty, (e, v));
|
||||
}
|
||||
|
||||
pub fn visit_block<E:Clone>(b: &blk, (e, v): (E, vt<E>)) {
|
||||
pub fn visit_block<E:Clone>(b: &Block, (e, v): (E, vt<E>)) {
|
||||
for b.view_items.iter().advance |vi| {
|
||||
(v.visit_view_item)(vi, (e.clone(), v));
|
||||
}
|
||||
@ -583,8 +583,8 @@ pub struct SimpleVisitor {
|
||||
visit_view_item: @fn(&view_item),
|
||||
visit_foreign_item: @fn(@foreign_item),
|
||||
visit_item: @fn(@item),
|
||||
visit_local: @fn(@local),
|
||||
visit_block: @fn(&blk),
|
||||
visit_local: @fn(@Local),
|
||||
visit_block: @fn(&Block),
|
||||
visit_stmt: @fn(@stmt),
|
||||
visit_arm: @fn(&arm),
|
||||
visit_pat: @fn(@pat),
|
||||
@ -593,7 +593,7 @@ pub struct SimpleVisitor {
|
||||
visit_expr_post: @fn(@expr),
|
||||
visit_ty: @fn(&Ty),
|
||||
visit_generics: @fn(&Generics),
|
||||
visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id),
|
||||
visit_fn: @fn(&fn_kind, &fn_decl, &Block, span, node_id),
|
||||
visit_ty_method: @fn(&ty_method),
|
||||
visit_trait_method: @fn(&trait_method),
|
||||
visit_struct_def: @fn(@struct_def, ident, &Generics, node_id),
|
||||
@ -653,11 +653,11 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
f(i);
|
||||
visit_item(i, (e, v));
|
||||
}
|
||||
fn v_local(f: @fn(@local), l: @local, (e, v): ((), vt<()>)) {
|
||||
fn v_local(f: @fn(@Local), l: @Local, (e, v): ((), vt<()>)) {
|
||||
f(l);
|
||||
visit_local(l, (e, v));
|
||||
}
|
||||
fn v_block(f: @fn(&ast::blk), bl: &ast::blk, (e, v): ((), vt<()>)) {
|
||||
fn v_block(f: @fn(&ast::Block), bl: &ast::Block, (e, v): ((), vt<()>)) {
|
||||
f(bl);
|
||||
visit_block(bl, (e, v));
|
||||
}
|
||||
@ -718,10 +718,10 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
visit_generics(ps, (e, v));
|
||||
}
|
||||
fn v_fn(
|
||||
f: @fn(&fn_kind, &fn_decl, &blk, span, node_id),
|
||||
f: @fn(&fn_kind, &fn_decl, &Block, span, node_id),
|
||||
fk: &fn_kind,
|
||||
decl: &fn_decl,
|
||||
body: &blk,
|
||||
body: &Block,
|
||||
sp: span,
|
||||
id: node_id,
|
||||
(e, v): ((), vt<()>)
|
||||
|
@ -23,7 +23,7 @@ use syntax::print::*;
|
||||
|
||||
|
||||
trait fake_ext_ctxt {
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn cfg() -> ast::Crate_cfg;
|
||||
fn parse_sess() -> parse::parse_sess;
|
||||
fn call_site() -> span;
|
||||
fn ident_of(st: &str) -> ast::ident;
|
||||
@ -32,7 +32,7 @@ trait fake_ext_ctxt {
|
||||
type fake_session = parse::parse_sess;
|
||||
|
||||
impl fake_ext_ctxt for fake_session {
|
||||
fn cfg() -> ast::crate_cfg { ~[] }
|
||||
fn cfg() -> ast::Crate_cfg { ~[] }
|
||||
fn parse_sess() -> parse::parse_sess { self }
|
||||
fn call_site() -> span {
|
||||
codemap::span {
|
||||
|
@ -22,7 +22,7 @@ use syntax::parse::parser;
|
||||
use syntax::print::*;
|
||||
|
||||
trait fake_ext_ctxt {
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn cfg() -> ast::Crate_cfg;
|
||||
fn parse_sess() -> parse::parse_sess;
|
||||
fn call_site() -> span;
|
||||
fn ident_of(st: &str) -> ast::ident;
|
||||
@ -31,7 +31,7 @@ trait fake_ext_ctxt {
|
||||
type fake_session = parse::parse_sess;
|
||||
|
||||
impl fake_ext_ctxt for fake_session {
|
||||
fn cfg() -> ast::crate_cfg { ~[] }
|
||||
fn cfg() -> ast::Crate_cfg { ~[] }
|
||||
fn parse_sess() -> parse::parse_sess { self }
|
||||
fn call_site() -> span {
|
||||
codemap::span {
|
||||
|
@ -32,18 +32,18 @@ fn new_parse_sess() -> parser::parse_sess {
|
||||
|
||||
trait fake_ext_ctxt {
|
||||
fn session() -> fake_session;
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn cfg() -> ast::Crate_cfg;
|
||||
fn parse_sess() -> parser::parse_sess;
|
||||
}
|
||||
|
||||
type fake_options = {cfg: ast::crate_cfg};
|
||||
type fake_options = {cfg: ast::Crate_cfg};
|
||||
|
||||
type fake_session = {opts: @fake_options,
|
||||
parse_sess: parser::parse_sess};
|
||||
|
||||
impl of fake_ext_ctxt for fake_session {
|
||||
fn session() -> fake_session {self}
|
||||
fn cfg() -> ast::crate_cfg { self.opts.cfg }
|
||||
fn cfg() -> ast::Crate_cfg { self.opts.cfg }
|
||||
fn parse_sess() -> parser::parse_sess { self.parse_sess }
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ use syntax::print::*;
|
||||
|
||||
|
||||
trait fake_ext_ctxt {
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn cfg() -> ast::Crate_cfg;
|
||||
fn parse_sess() -> parse::parse_sess;
|
||||
fn call_site() -> span;
|
||||
fn ident_of(st: &str) -> ast::ident;
|
||||
@ -33,7 +33,7 @@ trait fake_ext_ctxt {
|
||||
type fake_session = parse::parse_sess;
|
||||
|
||||
impl fake_ext_ctxt for fake_session {
|
||||
fn cfg() -> ast::crate_cfg { ~[] }
|
||||
fn cfg() -> ast::Crate_cfg { ~[] }
|
||||
fn parse_sess() -> parse::parse_sess { self }
|
||||
fn call_site() -> span {
|
||||
codemap::span {
|
||||
|
Loading…
x
Reference in New Issue
Block a user