1
Fork 0

rustc: Eliminate some indirection to the syntax crate

This commit is contained in:
Brian Anderson 2012-05-13 17:12:56 -07:00
parent a2572fe77e
commit 1f52652a06
22 changed files with 49 additions and 77 deletions

View file

@ -22,6 +22,7 @@
use core(vers = "0.2"); use core(vers = "0.2");
use std(vers = "0.2"); use std(vers = "0.2");
use rustc(vers = "0.2"); use rustc(vers = "0.2");
use syntax(name = "rustsyntax", vers = "0.2");
import core::*; import core::*;

View file

@ -1,10 +1,10 @@
// cargo.rs - Rust package manager // cargo.rs - Rust package manager
import rustc::syntax::{ast, codemap}; import syntax::{ast, codemap};
import rustc::syntax::parse; import syntax::parse;
import rustc::util::filesearch::{get_cargo_root, get_cargo_root_nearest, import rustc::util::filesearch::{get_cargo_root, get_cargo_root_nearest,
get_cargo_sysroot, libdir}; get_cargo_sysroot, libdir};
import rustc::driver::diagnostic; import syntax::diagnostic;
import result::{ok, err}; import result::{ok, err};
import io::writer_util; import io::writer_util;

View file

@ -6,7 +6,7 @@
use core(vers = "0.2"); use core(vers = "0.2");
use std(vers = "0.2"); use std(vers = "0.2");
use rustc(vers = "0.2"); use syntax(name = "rustsyntax", vers = "0.2");
import core::*; import core::*;

View file

@ -1,9 +1,9 @@
import io::writer_util; import io::writer_util;
import rustc::syntax::{ast, ast_util, fold, visit, codemap}; import syntax::{ast, ast_util, fold, visit, codemap};
import rustc::syntax::parse; import syntax::parse;
import rustc::syntax::print::pprust; import syntax::print::pprust;
import rustc::driver::diagnostic; import syntax::diagnostic;
enum test_mode { tm_converge, tm_run, } enum test_mode { tm_converge, tm_run, }
type context = { mode: test_mode }; // + rng type context = { mode: test_mode }; // + rng

View file

@ -1,4 +1,4 @@
import rustsyntax::diagnostic; import syntax::diagnostic;
export diagnostic; export diagnostic;
export driver; export driver;

View file

@ -3,6 +3,7 @@
use core(vers = "0.2"); use core(vers = "0.2");
use std(vers = "0.2"); use std(vers = "0.2");
use rustc(vers = "0.2"); use rustc(vers = "0.2");
use syntax(name = "rustsyntax", vers = "0.2");
import core::*; import core::*;
@ -12,7 +13,7 @@ import std::getopts;
import std::map::hashmap; import std::map::hashmap;
import getopts::{opt_present}; import getopts::{opt_present};
import rustc::driver::driver::*; import rustc::driver::driver::*;
import rustc::syntax::codemap; import syntax::codemap;
import rustc::driver::diagnostic; import rustc::driver::diagnostic;
import rustc::middle::lint; import rustc::middle::lint;
import io::reader_util; import io::reader_util;

View file

@ -45,7 +45,7 @@ mod back {
mod driver { mod driver {
import session = driver_::session; import session = driver_::session;
export session; export session;
import diagnostic = rustsyntax::diagnostic; import diagnostic = syntax::diagnostic;
export diagnostic; export diagnostic;
} }

View file

@ -103,7 +103,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
alt ii { alt ii {
ast::ii_item(i) { ast::ii_item(i) {
#debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", #debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<",
rustsyntax::print::pprust::item_to_str(i)); syntax::print::pprust::item_to_str(i));
} }
_ { } _ { }
} }

View file

@ -13,7 +13,7 @@
use core(vers = "0.2"); use core(vers = "0.2");
use std(vers = "0.2"); use std(vers = "0.2");
use rustsyntax(vers = "0.2"); use syntax(name = "rustsyntax", vers = "0.2");
import core::*; import core::*;
@ -82,8 +82,6 @@ mod middle {
} }
} }
mod syntax;
mod front { mod front {
mod config; mod config;
mod test; mod test;

View file

@ -1,33 +0,0 @@
// Temporary wrapper modules for migrating syntax to its own crate
import rustsyntax::codemap;
export codemap;
import rustsyntax::ast;
export ast;
import rustsyntax::ast_util;
export ast_util;
import rustsyntax::visit;
export visit;
import rustsyntax::fold;
export fold;
import rustsyntax::print;
export print;
import rustsyntax::parse;
export parse;
import rustsyntax::util;
export util;
import rustsyntax::attr;
export attr;
import rustsyntax::ext;
export ext;
import rustsyntax::diagnostic;
export diagnostic;

View file

@ -10,10 +10,10 @@
import std::map::hashmap; import std::map::hashmap;
import rustc::driver::session; import rustc::driver::session;
import rustc::driver::driver; import rustc::driver::driver;
import rustc::driver::diagnostic; import syntax::diagnostic;
import rustc::driver::diagnostic::handler; import syntax::diagnostic::handler;
import rustc::syntax::ast; import syntax::ast;
import rustc::syntax::codemap; import syntax::codemap;
import rustc::middle::ast_map; import rustc::middle::ast_map;
import rustc::back::link; import rustc::back::link;
import rustc::util::filesearch; import rustc::util::filesearch;

View file

@ -5,8 +5,8 @@
an AST's attributes." an AST's attributes."
)]; )];
import rustc::syntax::ast; import syntax::ast;
import rustc::syntax::attr; import syntax::attr;
import core::tuple; import core::tuple;
export crate_attrs; export crate_attrs;
@ -21,10 +21,10 @@ type crate_attrs = {
mod test { mod test {
fn parse_attributes(source: str) -> [ast::attribute] { fn parse_attributes(source: str) -> [ast::attribute] {
import rustc::syntax::parse; import syntax::parse;
import rustc::syntax::parse::parser; import parse::parser;
import rustc::syntax::codemap; import syntax::codemap;
import rustc::driver::diagnostic; import syntax::diagnostic;
let cm = codemap::new_codemap(); let cm = codemap::new_codemap();
let handler = diagnostic::mk_handler(none); let handler = diagnostic::mk_handler(none);

View file

@ -6,7 +6,7 @@
of the natural-language documentation for a crate." of the natural-language documentation for a crate."
)]; )];
import rustc::syntax::ast; import syntax::ast;
import rustc::middle::ast_map; import rustc::middle::ast_map;
import std::map::hashmap; import std::map::hashmap;

View file

@ -1,6 +1,6 @@
#[doc = "Converts the Rust AST to the rustdoc document model"]; #[doc = "Converts the Rust AST to the rustdoc document model"];
import rustc::syntax::ast; import syntax::ast;
export from_srv, extract; export from_srv, extract;

View file

@ -180,7 +180,7 @@ fn write_header_(ctxt: ctxt, lvl: hlvl, title: str) {
fn header_kind(doc: doc::itemtag) -> str { fn header_kind(doc: doc::itemtag) -> str {
alt doc { alt doc {
doc::modtag(_) { doc::modtag(_) {
if doc.id() == rustc::syntax::ast::crate_node_id { if doc.id() == syntax::ast::crate_node_id {
"Crate" "Crate"
} else { } else {
"Module" "Module"
@ -216,7 +216,7 @@ fn header_kind(doc: doc::itemtag) -> str {
fn header_name(doc: doc::itemtag) -> str { fn header_name(doc: doc::itemtag) -> str {
let fullpath = str::connect(doc.path() + [doc.name()], "::"); let fullpath = str::connect(doc.path() + [doc.name()], "::");
alt doc { alt doc {
doc::modtag(_) if doc.id() != rustc::syntax::ast::crate_node_id { doc::modtag(_) if doc.id() != syntax::ast::crate_node_id {
fullpath fullpath
} }
doc::nmodtag(_) { doc::nmodtag(_) {

View file

@ -7,6 +7,8 @@ modules, pages for the crate, indexes, etc.
"]; "];
import syntax::ast;
export mk_pass; export mk_pass;
fn mk_pass(output_style: config::output_style) -> pass { fn mk_pass(output_style: config::output_style) -> pass {
@ -92,7 +94,7 @@ fn fold_mod(
let doc = fold::default_any_fold_mod(fold, doc); let doc = fold::default_any_fold_mod(fold, doc);
if doc.id() != rustc::syntax::ast::crate_node_id { if doc.id() != ast::crate_node_id {
let doc = strip_mod(doc); let doc = strip_mod(doc);
let page = doc::itempage(doc::modtag(doc)); let page = doc::itempage(doc::modtag(doc));

View file

@ -3,10 +3,10 @@
import rustc::driver::driver; import rustc::driver::driver;
import driver::{file_input, str_input}; import driver::{file_input, str_input};
import rustc::driver::session; import rustc::driver::session;
import rustc::driver::diagnostic; import syntax::diagnostic;
import rustc::syntax::ast; import syntax::ast;
import rustc::syntax::codemap; import syntax::codemap;
import rustc::syntax::parse; import syntax::parse;
export from_file, from_str, from_file_sess, from_str_sess; export from_file, from_str, from_file_sess, from_str_sess;

View file

@ -1,5 +1,7 @@
#[doc = "Records the full path to items"]; #[doc = "Records the full path to items"];
import syntax::ast;
export mk_pass; export mk_pass;
fn mk_pass() -> pass { fn mk_pass() -> pass {
@ -36,7 +38,7 @@ fn fold_item(fold: fold::fold<ctxt>, doc: doc::itemdoc) -> doc::itemdoc {
} }
fn fold_mod(fold: fold::fold<ctxt>, doc: doc::moddoc) -> doc::moddoc { fn fold_mod(fold: fold::fold<ctxt>, doc: doc::moddoc) -> doc::moddoc {
let is_topmod = doc.id() == rustc::syntax::ast::crate_node_id; let is_topmod = doc.id() == ast::crate_node_id;
if !is_topmod { vec::push(fold.ctxt.path, doc.name()); } if !is_topmod { vec::push(fold.ctxt.path, doc.name()); }
let doc = fold::default_any_fold_mod(fold, doc); let doc = fold::default_any_fold_mod(fold, doc);

View file

@ -1,7 +1,7 @@
#[doc = "Prunes branches of the tree that are not exported"]; #[doc = "Prunes branches of the tree that are not exported"];
import rustc::syntax::ast; import syntax::ast;
import rustc::syntax::ast_util; import syntax::ast_util;
import rustc::middle::ast_map; import rustc::middle::ast_map;
import std::map::hashmap; import std::map::hashmap;

View file

@ -3,12 +3,12 @@
import std::map; import std::map;
import std::map::hashmap; import std::map::hashmap;
import std::list; import std::list;
import rustc::syntax::ast; import syntax::ast;
import rustc::syntax::ast_util; import syntax::ast_util;
import rustc::util::common; import rustc::util::common;
import rustc::middle::ast_map; import rustc::middle::ast_map;
import rustc::syntax::visit; import syntax::visit;
import rustc::syntax::codemap; import syntax::codemap;
import rustc::middle::resolve; import rustc::middle::resolve;
export mk_pass; export mk_pass;
@ -316,7 +316,7 @@ fn merge_reexports(
fn fold_mod(fold: fold::fold<path_map>, doc: doc::moddoc) -> doc::moddoc { fn fold_mod(fold: fold::fold<path_map>, doc: doc::moddoc) -> doc::moddoc {
let doc = fold::default_seq_fold_mod(fold, doc); let doc = fold::default_seq_fold_mod(fold, doc);
let is_topmod = doc.id() == rustc::syntax::ast::crate_node_id; let is_topmod = doc.id() == ast::crate_node_id;
// In the case of the top mod, it really doesn't have a name; // In the case of the top mod, it really doesn't have a name;
// the name we have here is actually the crate name // the name we have here is actually the crate name

View file

@ -14,6 +14,7 @@
use core(vers = "0.2"); use core(vers = "0.2");
use std(vers = "0.2"); use std(vers = "0.2");
use rustc(vers = "0.2"); use rustc(vers = "0.2");
use syntax(name = "rustsyntax", vers = "0.2");
import core::*; import core::*;

View file

@ -1,8 +1,8 @@
#[doc = #[doc =
"Pulls type information out of the AST and attaches it to the document"]; "Pulls type information out of the AST and attaches it to the document"];
import rustc::syntax::ast; import syntax::ast;
import rustc::syntax::print::pprust; import syntax::print::pprust;
import rustc::middle::ast_map; import rustc::middle::ast_map;
import std::map::hashmap; import std::map::hashmap;