2011-06-15 11:19:50 -07:00
|
|
|
|
2011-07-05 11:48:19 +02:00
|
|
|
import syntax::ast;
|
|
|
|
import syntax::codemap;
|
|
|
|
import codemap::span;
|
|
|
|
import syntax::ast::ty_mach;
|
2011-05-17 20:41:41 +02:00
|
|
|
import std::uint;
|
2011-05-12 17:24:54 +02:00
|
|
|
import std::io;
|
|
|
|
import std::map;
|
2011-06-07 17:54:22 -07:00
|
|
|
import std::option;
|
|
|
|
import std::option::some;
|
|
|
|
import std::option::none;
|
2011-07-04 13:22:23 -04:00
|
|
|
import std::str;
|
2010-09-01 13:24:14 -07:00
|
|
|
|
2011-06-15 11:19:50 -07:00
|
|
|
tag os { os_win32; os_macos; os_linux; }
|
|
|
|
|
|
|
|
tag arch { arch_x86; arch_x64; arch_arm; }
|
|
|
|
|
|
|
|
type config =
|
|
|
|
rec(os os,
|
|
|
|
arch arch,
|
|
|
|
ty_mach int_type,
|
|
|
|
ty_mach uint_type,
|
|
|
|
ty_mach float_type);
|
|
|
|
|
|
|
|
type options =
|
2011-07-07 14:42:18 -04:00
|
|
|
rec(bool library,
|
2011-07-07 15:25:09 -04:00
|
|
|
bool static,
|
2011-06-15 11:19:50 -07:00
|
|
|
uint optimize,
|
|
|
|
bool debuginfo,
|
|
|
|
bool verify,
|
|
|
|
bool run_typestate,
|
|
|
|
bool save_temps,
|
|
|
|
bool stats,
|
|
|
|
bool time_passes,
|
|
|
|
bool time_llvm_passes,
|
|
|
|
back::link::output_type output_type,
|
|
|
|
vec[str] library_search_paths,
|
2011-07-01 15:30:25 -07:00
|
|
|
str sysroot,
|
|
|
|
// The crate config requested for the session, which may be combined
|
|
|
|
// with additional crate configurations during the compile process
|
2011-07-06 14:29:50 -07:00
|
|
|
ast::crate_cfg cfg,
|
|
|
|
bool test);
|
2011-06-15 11:19:50 -07:00
|
|
|
|
|
|
|
type crate_metadata = rec(str name, vec[u8] data);
|
2011-03-25 10:42:57 -07:00
|
|
|
|
2011-07-05 16:09:32 +02:00
|
|
|
obj session(@config targ_cfg,
|
2011-06-15 11:19:50 -07:00
|
|
|
@options opts,
|
2011-07-07 18:00:16 -07:00
|
|
|
metadata::cstore::cstore cstore,
|
2011-06-18 22:55:53 -07:00
|
|
|
codemap::codemap cm,
|
|
|
|
mutable uint err_count) {
|
2011-06-15 11:19:50 -07:00
|
|
|
fn get_targ_cfg() -> @config { ret targ_cfg; }
|
|
|
|
fn get_opts() -> @options { ret opts; }
|
2011-07-07 18:00:16 -07:00
|
|
|
fn get_cstore() -> metadata::cstore::cstore { cstore }
|
2011-06-18 22:41:20 -07:00
|
|
|
fn span_fatal(span sp, str msg) -> ! {
|
2011-04-28 10:50:54 -07:00
|
|
|
// FIXME: Use constants, but rustboot doesn't know how to export them.
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_error(some(sp), msg, cm);
|
2010-09-01 13:24:14 -07:00
|
|
|
fail;
|
|
|
|
}
|
2011-06-18 22:41:20 -07:00
|
|
|
fn fatal(str msg) -> ! {
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_error(none, msg, cm);
|
2010-09-01 13:24:14 -07:00
|
|
|
fail;
|
|
|
|
}
|
2011-06-18 22:55:53 -07:00
|
|
|
fn span_err(span sp, str msg) {
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_error(some(sp), msg, cm);
|
2011-06-18 22:55:53 -07:00
|
|
|
err_count += 1u;
|
|
|
|
}
|
2011-06-29 11:07:29 -07:00
|
|
|
fn err(str msg) {
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_error(none, msg, cm);
|
2011-06-18 22:55:53 -07:00
|
|
|
err_count += 1u;
|
|
|
|
}
|
|
|
|
fn abort_if_errors() {
|
|
|
|
if (err_count > 0u) {
|
|
|
|
self.fatal("aborting due to previous errors");
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 13:44:13 -07:00
|
|
|
fn span_warn(span sp, str msg) {
|
2011-04-28 10:50:54 -07:00
|
|
|
// FIXME: Use constants, but rustboot doesn't know how to export them.
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_warning(some(sp), msg, cm);
|
2011-06-07 17:54:22 -07:00
|
|
|
}
|
|
|
|
fn warn(str msg) {
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_warning(none, msg, cm);
|
2011-03-18 13:44:13 -07:00
|
|
|
}
|
2011-05-17 14:12:49 -07:00
|
|
|
fn span_note(span sp, str msg) {
|
|
|
|
// FIXME: Use constants, but rustboot doesn't know how to export them.
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_note(some(sp), msg, cm);
|
2011-06-07 17:54:22 -07:00
|
|
|
}
|
2011-06-29 11:08:53 -07:00
|
|
|
fn note(str msg) {
|
2011-07-05 11:48:19 +02:00
|
|
|
codemap::emit_note(none, msg, cm);
|
2011-06-29 11:08:53 -07:00
|
|
|
}
|
2011-06-07 17:54:22 -07:00
|
|
|
fn span_bug(span sp, str msg) -> ! {
|
2011-06-18 22:41:20 -07:00
|
|
|
self.span_fatal(sp, #fmt("internal compiler error %s", msg));
|
2011-05-17 14:12:49 -07:00
|
|
|
}
|
2011-05-20 17:36:33 -07:00
|
|
|
fn bug(str msg) -> ! {
|
2011-06-18 22:41:20 -07:00
|
|
|
self.fatal(#fmt("internal compiler error %s", msg));
|
2010-11-22 16:27:00 -08:00
|
|
|
}
|
2011-05-20 17:36:33 -07:00
|
|
|
fn span_unimpl(span sp, str msg) -> ! {
|
2011-06-07 17:54:22 -07:00
|
|
|
self.span_bug(sp, "unimplemented " + msg);
|
2011-03-18 12:30:44 -07:00
|
|
|
}
|
2011-06-15 11:19:50 -07:00
|
|
|
fn unimpl(str msg) -> ! { self.bug("unimplemented " + msg); }
|
|
|
|
fn get_codemap() -> codemap::codemap { ret cm; }
|
2011-05-12 17:24:54 +02:00
|
|
|
fn lookup_pos(uint pos) -> codemap::loc {
|
|
|
|
ret codemap::lookup_pos(cm, pos);
|
2011-04-08 18:44:20 +02:00
|
|
|
}
|
2011-07-05 11:48:19 +02:00
|
|
|
fn span_str(span sp) -> str {
|
|
|
|
ret codemap::span_to_str(sp, self.get_codemap());
|
|
|
|
}
|
2010-09-01 13:24:14 -07:00
|
|
|
}
|
|
|
|
// Local Variables:
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
2011-03-25 15:07:27 -07:00
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
2010-09-01 13:24:14 -07:00
|
|
|
// End:
|