2011-03-25 16:32:39 -05:00
|
|
|
import front.ast;
|
2010-09-01 15:24:14 -05:00
|
|
|
import util.common.span;
|
2010-11-22 18:27:00 -06:00
|
|
|
import util.common.ty_mach;
|
2010-09-01 15:24:14 -05:00
|
|
|
import std._uint;
|
2011-03-25 12:42:57 -05:00
|
|
|
import std.map;
|
2010-09-01 15:24:14 -05:00
|
|
|
|
2010-11-22 18:27:00 -06:00
|
|
|
tag os {
|
|
|
|
os_win32;
|
|
|
|
os_macos;
|
|
|
|
os_linux;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag arch {
|
|
|
|
arch_x86;
|
|
|
|
arch_x64;
|
|
|
|
arch_arm;
|
|
|
|
}
|
|
|
|
|
|
|
|
type cfg = rec(os os,
|
|
|
|
arch arch,
|
|
|
|
ty_mach int_type,
|
|
|
|
ty_mach uint_type,
|
|
|
|
ty_mach float_type);
|
|
|
|
|
2011-03-25 12:42:57 -05:00
|
|
|
type crate_metadata = vec[u8];
|
|
|
|
|
2011-03-25 16:32:39 -05:00
|
|
|
obj session(ast.crate_num cnum, cfg targ,
|
|
|
|
map.hashmap[int, crate_metadata] crates) {
|
2010-11-22 18:27:00 -06:00
|
|
|
|
|
|
|
fn get_targ_cfg() -> cfg {
|
|
|
|
ret targ;
|
|
|
|
}
|
|
|
|
|
2011-03-25 16:32:39 -05:00
|
|
|
fn get_targ_crate_num() -> ast.crate_num {
|
|
|
|
ret cnum;
|
|
|
|
}
|
|
|
|
|
2010-09-23 15:15:51 -05:00
|
|
|
fn span_err(span sp, str msg) {
|
2010-10-18 18:03:22 -05:00
|
|
|
log #fmt("%s:%u:%u:%u:%u: error: %s",
|
|
|
|
sp.filename,
|
|
|
|
sp.lo.line, sp.lo.col,
|
|
|
|
sp.hi.line, sp.hi.col,
|
|
|
|
msg);
|
2010-09-01 15:24:14 -05:00
|
|
|
fail;
|
|
|
|
}
|
|
|
|
|
2010-09-23 15:15:51 -05:00
|
|
|
fn err(str msg) {
|
2010-10-18 18:03:22 -05:00
|
|
|
log #fmt("error: %s", msg);
|
2010-09-01 15:24:14 -05:00
|
|
|
fail;
|
|
|
|
}
|
2010-09-23 15:15:51 -05:00
|
|
|
|
2011-03-18 15:44:13 -05:00
|
|
|
fn span_warn(span sp, str msg) {
|
|
|
|
log #fmt("%s:%u:%u:%u:%u: warning: %s",
|
|
|
|
sp.filename,
|
|
|
|
sp.lo.line, sp.lo.col,
|
|
|
|
sp.hi.line, sp.hi.col,
|
|
|
|
msg);
|
|
|
|
}
|
|
|
|
|
2010-11-22 18:27:00 -06:00
|
|
|
fn bug(str msg) {
|
|
|
|
log #fmt("error: internal compiler error %s", msg);
|
|
|
|
fail;
|
|
|
|
}
|
|
|
|
|
2011-03-18 14:30:44 -05:00
|
|
|
fn span_unimpl(span sp, str msg) {
|
|
|
|
log #fmt("%s:%u:%u:%u:%u: error: unimplemented %s",
|
|
|
|
sp.filename,
|
|
|
|
sp.lo.line, sp.lo.col,
|
|
|
|
sp.hi.line, sp.hi.col,
|
|
|
|
msg);
|
|
|
|
fail;
|
|
|
|
}
|
|
|
|
|
2010-09-23 15:15:51 -05:00
|
|
|
fn unimpl(str msg) {
|
2010-10-18 18:03:22 -05:00
|
|
|
log #fmt("error: unimplemented %s", msg);
|
2010-09-23 15:15:51 -05:00
|
|
|
fail;
|
|
|
|
}
|
2011-03-25 12:42:57 -05:00
|
|
|
|
|
|
|
fn get_external_crate(int num) -> crate_metadata {
|
|
|
|
ret crates.get(num);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_external_crate(int num, &crate_metadata metadata) {
|
|
|
|
crates.insert(num, metadata);
|
|
|
|
}
|
2011-03-25 13:10:50 -05:00
|
|
|
|
|
|
|
fn has_external_crate(int num) -> bool {
|
|
|
|
ret crates.contains_key(num);
|
|
|
|
}
|
2010-09-01 15:24:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Local Variables:
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
2011-03-25 17:07:27 -05:00
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
2010-09-01 15:24:14 -05:00
|
|
|
// End:
|