Downcase std modules again, move to :: for module dereferencing
This should be a snapshot transition.
This commit is contained in:
parent
b1d3364487
commit
3816e57fd2
168 changed files with 7643 additions and 7608 deletions
|
|
@ -1,69 +1,68 @@
|
|||
// -*- rust -*-
|
||||
|
||||
import front.creader;
|
||||
import front.parser;
|
||||
import front.token;
|
||||
import front.eval;
|
||||
import front.ast;
|
||||
import middle.trans;
|
||||
import middle.resolve;
|
||||
import middle.capture;
|
||||
import middle.ty;
|
||||
import middle.typeck;
|
||||
import middle.typestate_check;
|
||||
import back.Link;
|
||||
import lib.llvm;
|
||||
import util.common;
|
||||
import front::creader;
|
||||
import front::parser;
|
||||
import front::token;
|
||||
import front::eval;
|
||||
import front::ast;
|
||||
import middle::trans;
|
||||
import middle::resolve;
|
||||
import middle::capture;
|
||||
import middle::ty;
|
||||
import middle::typeck;
|
||||
import middle::typestate_check;
|
||||
import back::Link;
|
||||
import lib::llvm;
|
||||
import util::common;
|
||||
|
||||
import std.FS;
|
||||
import std.Map.mk_hashmap;
|
||||
import std.Option;
|
||||
import std.Option.some;
|
||||
import std.Option.none;
|
||||
import std.Str;
|
||||
import std.Vec;
|
||||
import std.IO;
|
||||
import std.Time;
|
||||
import std::fs;
|
||||
import std::map::mk_hashmap;
|
||||
import std::option;
|
||||
import std::option::some;
|
||||
import std::option::none;
|
||||
import std::_str;
|
||||
import std::_vec;
|
||||
import std::io;
|
||||
|
||||
import std.GetOpts;
|
||||
import std.GetOpts.optopt;
|
||||
import std.GetOpts.optmulti;
|
||||
import std.GetOpts.optflag;
|
||||
import std.GetOpts.opt_present;
|
||||
import std::getopts;
|
||||
import std::getopts::optopt;
|
||||
import std::getopts::optmulti;
|
||||
import std::getopts::optflag;
|
||||
import std::getopts::opt_present;
|
||||
|
||||
import back.Link.output_type;
|
||||
import back::Link::output_type;
|
||||
|
||||
fn default_environment(session.session sess,
|
||||
fn default_environment(session::session sess,
|
||||
str argv0,
|
||||
str input) -> eval.env {
|
||||
str input) -> eval::env {
|
||||
|
||||
auto libc = "libc.so";
|
||||
auto libc = "libc::so";
|
||||
alt (sess.get_targ_cfg().os) {
|
||||
case (session.os_win32) { libc = "msvcrt.dll"; }
|
||||
case (session.os_macos) { libc = "libc.dylib"; }
|
||||
case (session.os_linux) { libc = "libc.so.6"; }
|
||||
case (session::os_win32) { libc = "msvcrt.dll"; }
|
||||
case (session::os_macos) { libc = "libc::dylib"; }
|
||||
case (session::os_linux) { libc = "libc::so.6"; }
|
||||
}
|
||||
|
||||
ret
|
||||
vec(
|
||||
// Target bindings.
|
||||
tup("target_os", eval.val_str(std.OS.target_os())),
|
||||
tup("target_arch", eval.val_str("x86")),
|
||||
tup("target_libc", eval.val_str(libc)),
|
||||
tup("target_os", eval::val_str(std::os::target_os())),
|
||||
tup("target_arch", eval::val_str("x86")),
|
||||
tup("target_libc", eval::val_str(libc)),
|
||||
|
||||
// Build bindings.
|
||||
tup("build_compiler", eval.val_str(argv0)),
|
||||
tup("build_input", eval.val_str(input))
|
||||
tup("build_compiler", eval::val_str(argv0)),
|
||||
tup("build_input", eval::val_str(input))
|
||||
);
|
||||
}
|
||||
|
||||
fn parse_input(session.session sess,
|
||||
parser.parser p,
|
||||
str input) -> @ast.crate {
|
||||
if (Str.ends_with(input, ".rc")) {
|
||||
ret parser.parse_crate_from_crate_file(p);
|
||||
} else if (Str.ends_with(input, ".rs")) {
|
||||
ret parser.parse_crate_from_source_file(p);
|
||||
fn parse_input(session::session sess,
|
||||
parser::parser p,
|
||||
str input) -> @ast::crate {
|
||||
if (_str::ends_with(input, ".rc")) {
|
||||
ret parser::parse_crate_from_crate_file(p);
|
||||
} else if (_str::ends_with(input, ".rs")) {
|
||||
ret parser::parse_crate_from_source_file(p);
|
||||
}
|
||||
sess.err("unknown input file type: " + input);
|
||||
fail;
|
||||
|
|
@ -72,73 +71,74 @@ fn parse_input(session.session sess,
|
|||
fn time[T](bool do_it, str what, fn()->T thunk) -> T {
|
||||
if (!do_it) { ret thunk(); }
|
||||
|
||||
auto start = Time.get_time();
|
||||
auto start = std::time::get_time();
|
||||
auto rv = thunk();
|
||||
auto end = Time.get_time();
|
||||
auto end = std::time::get_time();
|
||||
|
||||
// FIXME: Actually do timeval math.
|
||||
log_err #fmt("time: %s took %u s", what, (end.sec - start.sec) as uint);
|
||||
ret rv;
|
||||
}
|
||||
|
||||
fn compile_input(session.session sess,
|
||||
eval.env env,
|
||||
fn compile_input(session::session sess,
|
||||
eval::env env,
|
||||
str input, str output) {
|
||||
auto time_passes = sess.get_opts().time_passes;
|
||||
auto def = tup(ast.local_crate, 0);
|
||||
auto p = parser.new_parser(sess, env, def, input, 0u, 0u);
|
||||
auto def = tup(ast::local_crate, 0);
|
||||
auto p = parser::new_parser(sess, env, def, input, 0u, 0u);
|
||||
auto crate = time(time_passes, "parsing",
|
||||
bind parse_input(sess, p, input));
|
||||
if (sess.get_opts().output_type == Link.output_type_none) {ret;}
|
||||
if (sess.get_opts().output_type == Link::output_type_none) {ret;}
|
||||
|
||||
crate = time(time_passes, "external crate reading",
|
||||
bind creader.read_crates(sess, crate));
|
||||
bind creader::read_crates(sess, crate));
|
||||
auto res = time(time_passes, "resolution",
|
||||
bind resolve.resolve_crate(sess, crate));
|
||||
bind resolve::resolve_crate(sess, crate));
|
||||
crate = res._0;
|
||||
auto def_map = res._1;
|
||||
time[()](time_passes, "capture checking",
|
||||
bind capture.check_for_captures(sess, crate, def_map));
|
||||
bind capture::check_for_captures(sess, crate, def_map));
|
||||
|
||||
auto ty_cx = ty.mk_ctxt(sess, def_map);
|
||||
auto ty_cx = ty::mk_ctxt(sess, def_map);
|
||||
auto typeck_result =
|
||||
time[typeck.typecheck_result](time_passes, "typechecking",
|
||||
bind typeck.check_crate(ty_cx, crate));
|
||||
time[typeck::typecheck_result](time_passes, "typechecking",
|
||||
bind typeck::check_crate(ty_cx, crate));
|
||||
crate = typeck_result._0;
|
||||
auto type_cache = typeck_result._1;
|
||||
|
||||
if (sess.get_opts().run_typestate) {
|
||||
crate = time(time_passes, "typestate checking",
|
||||
bind typestate_check.check_crate(crate, def_map));
|
||||
bind typestate_check::check_crate(crate, def_map));
|
||||
}
|
||||
|
||||
auto llmod = time[llvm.ModuleRef](time_passes, "translation",
|
||||
bind trans.trans_crate(sess, crate, ty_cx, type_cache, output));
|
||||
auto llmod = time[llvm::ModuleRef](time_passes, "translation",
|
||||
bind trans::trans_crate(sess, crate, ty_cx, type_cache, output));
|
||||
|
||||
time[()](time_passes, "LLVM passes",
|
||||
bind Link.Write.run_passes(sess, llmod, output));
|
||||
bind Link::Write::run_passes(sess, llmod, output));
|
||||
}
|
||||
|
||||
fn pretty_print_input(session.session sess,
|
||||
eval.env env,
|
||||
fn pretty_print_input(session::session sess,
|
||||
eval::env env,
|
||||
str input) {
|
||||
auto def = tup(ast.local_crate, 0);
|
||||
auto p = front.parser.new_parser(sess, env, def, input, 0u, 0u);
|
||||
auto crate = front.parser.parse_crate_from_source_file(p);
|
||||
pretty.pprust.print_file(sess, crate.node.module, input, std.IO.stdout());
|
||||
auto def = tup(ast::local_crate, 0);
|
||||
auto p = front::parser::new_parser(sess, env, def, input, 0u, 0u);
|
||||
auto crate = front::parser::parse_crate_from_source_file(p);
|
||||
pretty::pprust::print_file(sess, crate.node.module, input,
|
||||
std::io::stdout());
|
||||
}
|
||||
|
||||
fn version(str argv0) {
|
||||
auto vers = "unknown version";
|
||||
auto env_vers = #env("CFG_VERSION");
|
||||
if (Str.byte_len(env_vers) != 0u) {
|
||||
if (_str::byte_len(env_vers) != 0u) {
|
||||
vers = env_vers;
|
||||
}
|
||||
IO.stdout().write_str(#fmt("%s %s\n", argv0, vers));
|
||||
io::stdout().write_str(#fmt("%s %s\n", argv0, vers));
|
||||
}
|
||||
|
||||
fn usage(str argv0) {
|
||||
IO.stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) + "
|
||||
io::stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) + "
|
||||
options:
|
||||
|
||||
-h --help display this message
|
||||
|
|
@ -164,46 +164,46 @@ options:
|
|||
--no-typestate don't run the typestate pass (unsafe!)\n\n");
|
||||
}
|
||||
|
||||
fn get_os(str triple) -> session.os {
|
||||
if (Str.find(triple, "win32") > 0 ||
|
||||
Str.find(triple, "mingw32") > 0 ) {
|
||||
ret session.os_win32;
|
||||
} else if (Str.find(triple, "darwin") > 0) { ret session.os_macos; }
|
||||
else if (Str.find(triple, "linux") > 0) { ret session.os_linux; }
|
||||
fn get_os(str triple) -> session::os {
|
||||
if (_str::find(triple, "win32") > 0 ||
|
||||
_str::find(triple, "mingw32") > 0 ) {
|
||||
ret session::os_win32;
|
||||
} else if (_str::find(triple, "darwin") > 0) { ret session::os_macos; }
|
||||
else if (_str::find(triple, "linux") > 0) { ret session::os_linux; }
|
||||
}
|
||||
|
||||
fn get_arch(str triple) -> session.arch {
|
||||
if (Str.find(triple, "i386") > 0 ||
|
||||
Str.find(triple, "i486") > 0 ||
|
||||
Str.find(triple, "i586") > 0 ||
|
||||
Str.find(triple, "i686") > 0 ||
|
||||
Str.find(triple, "i786") > 0 ) {
|
||||
ret session.arch_x86;
|
||||
} else if (Str.find(triple, "x86_64") > 0) {
|
||||
ret session.arch_x64;
|
||||
} else if (Str.find(triple, "arm") > 0 ||
|
||||
Str.find(triple, "xscale") > 0 ) {
|
||||
ret session.arch_arm;
|
||||
fn get_arch(str triple) -> session::arch {
|
||||
if (_str::find(triple, "i386") > 0 ||
|
||||
_str::find(triple, "i486") > 0 ||
|
||||
_str::find(triple, "i586") > 0 ||
|
||||
_str::find(triple, "i686") > 0 ||
|
||||
_str::find(triple, "i786") > 0 ) {
|
||||
ret session::arch_x86;
|
||||
} else if (_str::find(triple, "x86_64") > 0) {
|
||||
ret session::arch_x64;
|
||||
} else if (_str::find(triple, "arm") > 0 ||
|
||||
_str::find(triple, "xscale") > 0 ) {
|
||||
ret session::arch_arm;
|
||||
}
|
||||
}
|
||||
|
||||
fn get_default_sysroot(str binary) -> str {
|
||||
auto dirname = FS.dirname(binary);
|
||||
if (Str.eq(dirname, binary)) { ret "."; }
|
||||
auto dirname = fs::dirname(binary);
|
||||
if (_str::eq(dirname, binary)) { ret "."; }
|
||||
ret dirname;
|
||||
}
|
||||
|
||||
fn main(vec[str] args) {
|
||||
|
||||
let str triple =
|
||||
std.Str.rustrt.str_from_cstr(llvm.llvm.LLVMRustGetHostTriple());
|
||||
std::_str::rustrt::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple());
|
||||
|
||||
let @session.config target_cfg =
|
||||
let @session::config target_cfg =
|
||||
@rec(os = get_os(triple),
|
||||
arch = get_arch(triple),
|
||||
int_type = common.ty_i32,
|
||||
uint_type = common.ty_u32,
|
||||
float_type = common.ty_f64);
|
||||
int_type = common::ty_i32,
|
||||
uint_type = common::ty_u32,
|
||||
float_type = common::ty_f64);
|
||||
|
||||
auto opts = vec(optflag("h"), optflag("help"),
|
||||
optflag("v"), optflag("version"),
|
||||
|
|
@ -214,14 +214,14 @@ fn main(vec[str] args) {
|
|||
optflag("save-temps"), optopt("sysroot"),
|
||||
optflag("time-passes"), optflag("time-llvm-passes"),
|
||||
optflag("no-typestate"), optflag("noverify"));
|
||||
auto binary = Vec.shift[str](args);
|
||||
auto binary = _vec::shift[str](args);
|
||||
auto match;
|
||||
alt (GetOpts.getopts(args, opts)) {
|
||||
case (GetOpts.failure(?f)) {
|
||||
log_err #fmt("error: %s", GetOpts.fail_str(f));
|
||||
alt (getopts::getopts(args, opts)) {
|
||||
case (getopts::failure(?f)) {
|
||||
log_err #fmt("error: %s", getopts::fail_str(f));
|
||||
fail;
|
||||
}
|
||||
case (GetOpts.success(?m)) { match = m; }
|
||||
case (getopts::success(?m)) { match = m; }
|
||||
}
|
||||
if (opt_present(match, "h") ||
|
||||
opt_present(match, "help")) {
|
||||
|
|
@ -239,16 +239,16 @@ fn main(vec[str] args) {
|
|||
auto ls = opt_present(match, "ls");
|
||||
auto glue = opt_present(match, "glue");
|
||||
auto shared = opt_present(match, "shared");
|
||||
auto output_file = GetOpts.opt_maybe_str(match, "o");
|
||||
auto library_search_paths = GetOpts.opt_strs(match, "L");
|
||||
auto output_file = getopts::opt_maybe_str(match, "o");
|
||||
auto library_search_paths = getopts::opt_strs(match, "L");
|
||||
|
||||
auto output_type = Link.output_type_bitcode;
|
||||
auto output_type = Link::output_type_bitcode;
|
||||
if (opt_present(match, "parse-only")) {
|
||||
output_type = Link.output_type_none;
|
||||
output_type = Link::output_type_none;
|
||||
} else if (opt_present(match, "S")) {
|
||||
output_type = Link.output_type_assembly;
|
||||
output_type = Link::output_type_assembly;
|
||||
} else if (opt_present(match, "c")) {
|
||||
output_type = Link.output_type_object;
|
||||
output_type = Link::output_type_object;
|
||||
}
|
||||
|
||||
auto verify = !opt_present(match, "noverify");
|
||||
|
|
@ -259,7 +259,7 @@ fn main(vec[str] args) {
|
|||
auto time_passes = opt_present(match, "time-passes");
|
||||
auto time_llvm_passes = opt_present(match, "time-llvm-passes");
|
||||
auto run_typestate = !opt_present(match, "no-typestate");
|
||||
auto sysroot_opt = GetOpts.opt_maybe_str(match, "sysroot");
|
||||
auto sysroot_opt = getopts::opt_maybe_str(match, "sysroot");
|
||||
|
||||
auto sysroot;
|
||||
alt (sysroot_opt) {
|
||||
|
|
@ -267,7 +267,7 @@ fn main(vec[str] args) {
|
|||
case (some[str](?s)) { sysroot = s; }
|
||||
}
|
||||
|
||||
let @session.options sopts =
|
||||
let @session::options sopts =
|
||||
@rec(shared = shared,
|
||||
optimize = optimize,
|
||||
debuginfo = debuginfo,
|
||||
|
|
@ -280,21 +280,21 @@ fn main(vec[str] args) {
|
|||
library_search_paths = library_search_paths,
|
||||
sysroot = sysroot);
|
||||
|
||||
auto crate_cache = common.new_int_hash[session.crate_metadata]();
|
||||
auto crate_cache = common::new_int_hash[session::crate_metadata]();
|
||||
auto target_crate_num = 0;
|
||||
let vec[@ast.meta_item] md = vec();
|
||||
let vec[@ast::meta_item] md = vec();
|
||||
auto sess =
|
||||
session.session(target_crate_num, target_cfg, sopts,
|
||||
crate_cache, md, front.codemap.new_codemap());
|
||||
session::session(target_crate_num, target_cfg, sopts,
|
||||
crate_cache, md, front::codemap::new_codemap());
|
||||
|
||||
auto n_inputs = Vec.len[str](match.free);
|
||||
auto n_inputs = _vec::len[str](match.free);
|
||||
|
||||
if (glue) {
|
||||
if (n_inputs > 0u) {
|
||||
sess.err("No input files allowed with --glue.");
|
||||
}
|
||||
auto out = Option.from_maybe[str]("glue.bc", output_file);
|
||||
middle.trans.make_common_glue(sess, out);
|
||||
auto out = option::from_maybe[str]("glue.bc", output_file);
|
||||
middle::trans::make_common_glue(sess, out);
|
||||
ret;
|
||||
}
|
||||
|
||||
|
|
@ -309,19 +309,19 @@ fn main(vec[str] args) {
|
|||
if (pretty) {
|
||||
pretty_print_input(sess, env, ifile);
|
||||
} else if (ls) {
|
||||
front.creader.list_file_metadata(ifile, std.IO.stdout());
|
||||
front::creader::list_file_metadata(ifile, std::io::stdout());
|
||||
} else {
|
||||
alt (output_file) {
|
||||
case (none[str]) {
|
||||
let vec[str] parts = Str.split(ifile, '.' as u8);
|
||||
Vec.pop[str](parts);
|
||||
let vec[str] parts = _str::split(ifile, '.' as u8);
|
||||
_vec::pop[str](parts);
|
||||
alt (output_type) {
|
||||
case (Link.output_type_none) { parts += vec("pp"); }
|
||||
case (Link.output_type_bitcode) { parts += vec("bc"); }
|
||||
case (Link.output_type_assembly) { parts += vec("s"); }
|
||||
case (Link.output_type_object) { parts += vec("o"); }
|
||||
case (Link::output_type_none) { parts += vec("pp"); }
|
||||
case (Link::output_type_bitcode) { parts += vec("bc"); }
|
||||
case (Link::output_type_assembly) { parts += vec("s"); }
|
||||
case (Link::output_type_object) { parts += vec("o"); }
|
||||
}
|
||||
auto ofile = Str.connect(parts, ".");
|
||||
auto ofile = _str::connect(parts, ".");
|
||||
compile_input(sess, env, ifile, ofile);
|
||||
}
|
||||
case (some[str](?ofile)) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import front.ast;
|
||||
import front.codemap;
|
||||
import util.common.span;
|
||||
import util.common.ty_mach;
|
||||
import std.UInt;
|
||||
import std.Term;
|
||||
import std.IO;
|
||||
import std.Map;
|
||||
import front::ast;
|
||||
import front::codemap;
|
||||
import util::common::span;
|
||||
import util::common::ty_mach;
|
||||
import std::_uint;
|
||||
import std::term;
|
||||
import std::io;
|
||||
import std::map;
|
||||
|
||||
tag os {
|
||||
os_win32;
|
||||
|
|
@ -33,37 +33,38 @@ type options = rec(bool shared,
|
|||
bool save_temps,
|
||||
bool time_passes,
|
||||
bool time_llvm_passes,
|
||||
back.Link.output_type output_type,
|
||||
back::Link::output_type output_type,
|
||||
vec[str] library_search_paths,
|
||||
str sysroot);
|
||||
|
||||
type crate_metadata = rec(str name,
|
||||
vec[u8] data);
|
||||
|
||||
fn emit_diagnostic(span sp, str msg, str kind, u8 color, codemap.codemap cm) {
|
||||
auto lo = codemap.lookup_pos(cm, sp.lo);
|
||||
auto hi = codemap.lookup_pos(cm, sp.hi);
|
||||
IO.stdout().write_str(#fmt("%s:%u:%u:%u:%u: ", lo.filename, lo.line,
|
||||
fn emit_diagnostic(span sp, str msg, str kind, u8 color,
|
||||
codemap::codemap cm) {
|
||||
auto lo = codemap::lookup_pos(cm, sp.lo);
|
||||
auto hi = codemap::lookup_pos(cm, sp.hi);
|
||||
io::stdout().write_str(#fmt("%s:%u:%u:%u:%u: ", lo.filename, lo.line,
|
||||
lo.col, hi.line, hi.col));
|
||||
|
||||
if (Term.color_supported()) {
|
||||
Term.fg(IO.stdout().get_buf_writer(), color);
|
||||
if (term::color_supported()) {
|
||||
term::fg(io::stdout().get_buf_writer(), color);
|
||||
}
|
||||
|
||||
IO.stdout().write_str(#fmt("%s:", kind));
|
||||
io::stdout().write_str(#fmt("%s:", kind));
|
||||
|
||||
if (Term.color_supported()) {
|
||||
Term.reset(IO.stdout().get_buf_writer());
|
||||
if (term::color_supported()) {
|
||||
term::reset(io::stdout().get_buf_writer());
|
||||
}
|
||||
|
||||
IO.stdout().write_str(#fmt(" %s\n", msg));
|
||||
io::stdout().write_str(#fmt(" %s\n", msg));
|
||||
}
|
||||
|
||||
state obj session(ast.crate_num cnum,
|
||||
state obj session(ast::crate_num cnum,
|
||||
@config targ_cfg, @options opts,
|
||||
Map.hashmap[int, crate_metadata] crates,
|
||||
mutable vec[@ast.meta_item] metadata,
|
||||
codemap.codemap cm) {
|
||||
map::hashmap[int, crate_metadata] crates,
|
||||
mutable vec[@ast::meta_item] metadata,
|
||||
codemap::codemap cm) {
|
||||
|
||||
fn get_targ_cfg() -> @config {
|
||||
ret targ_cfg;
|
||||
|
|
@ -73,7 +74,7 @@ state obj session(ast.crate_num cnum,
|
|||
ret opts;
|
||||
}
|
||||
|
||||
fn get_targ_crate_num() -> ast.crate_num {
|
||||
fn get_targ_crate_num() -> ast::crate_num {
|
||||
ret cnum;
|
||||
}
|
||||
|
||||
|
|
@ -88,10 +89,10 @@ state obj session(ast.crate_num cnum,
|
|||
fail;
|
||||
}
|
||||
|
||||
fn add_metadata(vec[@ast.meta_item] data) {
|
||||
fn add_metadata(vec[@ast::meta_item] data) {
|
||||
metadata = metadata + data;
|
||||
}
|
||||
fn get_metadata() -> vec[@ast.meta_item] {
|
||||
fn get_metadata() -> vec[@ast::meta_item] {
|
||||
ret metadata;
|
||||
}
|
||||
|
||||
|
|
@ -129,12 +130,12 @@ state obj session(ast.crate_num cnum,
|
|||
ret crates.contains_key(num);
|
||||
}
|
||||
|
||||
fn get_codemap() -> codemap.codemap {
|
||||
fn get_codemap() -> codemap::codemap {
|
||||
ret cm;
|
||||
}
|
||||
|
||||
fn lookup_pos(uint pos) -> codemap.loc {
|
||||
ret codemap.lookup_pos(cm, pos);
|
||||
fn lookup_pos(uint pos) -> codemap::loc {
|
||||
ret codemap::lookup_pos(cm, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue