Remove '.' after nullary tags in patterns
Does what it says on the tin. The next commit will remove support for this syntax.
This commit is contained in:
parent
ca7cfbe3d0
commit
04a2887f87
@ -417,7 +417,7 @@ fn install_source(c: cargo, path: str) {
|
||||
for cf: str in cratefiles {
|
||||
let p = load_pkg(cf);
|
||||
alt p {
|
||||
none. { cont; }
|
||||
none { cont; }
|
||||
some(_p) {
|
||||
if c.test {
|
||||
test_one_crate(c, path, cf, _p);
|
||||
@ -559,7 +559,7 @@ fn cmd_install(c: cargo, argv: [str]) {
|
||||
|
||||
let wd = alt tempfile::mkdtemp(c.workdir + fs::path_sep(), "") {
|
||||
some(_wd) { _wd }
|
||||
none. { fail "needed temp dir"; }
|
||||
none { fail "needed temp dir"; }
|
||||
};
|
||||
|
||||
if str::starts_with(target, "uuid:") {
|
||||
|
@ -43,7 +43,7 @@ fn load_intrinsics_bc(sess: session) -> option::t<ModuleRef> {
|
||||
sess.filesearch,
|
||||
bind filesearch::pick_file("intrinsics.bc", _)) {
|
||||
option::some(path) { path }
|
||||
option::none. {
|
||||
option::none {
|
||||
sess.warn("couldn't find intrinsics.bc");
|
||||
ret option::none;
|
||||
}
|
||||
@ -70,7 +70,7 @@ fn load_intrinsics_ll(sess: session) -> ModuleRef {
|
||||
sess.filesearch,
|
||||
bind filesearch::pick_file("intrinsics.ll", _)) {
|
||||
option::some(path) { path }
|
||||
option::none. { sess.fatal("couldn't find intrinsics.ll") }
|
||||
option::none { sess.fatal("couldn't find intrinsics.ll") }
|
||||
};
|
||||
let llintrinsicsmod = str::as_buf(path, { |buf|
|
||||
llvm::LLVMRustParseAssemblyFile(buf)
|
||||
@ -86,7 +86,7 @@ fn link_intrinsics(sess: session, llmod: ModuleRef) {
|
||||
let llintrinsicsmod = {
|
||||
alt load_intrinsics_bc(sess) {
|
||||
option::some(m) { m }
|
||||
option::none. {
|
||||
option::none {
|
||||
// When the bitcode format changes we can't parse a .bc
|
||||
// file produced with a newer LLVM (as happens when stage0
|
||||
// is trying to build against a new LLVM revision), in
|
||||
@ -139,7 +139,7 @@ mod write {
|
||||
|
||||
if opts.save_temps {
|
||||
alt opts.output_type {
|
||||
output_type_bitcode. {
|
||||
output_type_bitcode {
|
||||
if opts.optimize != 0u {
|
||||
let filename = mk_intermediate_name(output, "no-opt.bc");
|
||||
str::as_buf(filename,
|
||||
@ -383,12 +383,12 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
|
||||
if attr::get_meta_item_name(meta) == "name" {
|
||||
alt attr::get_meta_item_value_str(meta) {
|
||||
some(v) { name = some(v); }
|
||||
none. { cmh_items += [meta]; }
|
||||
none { cmh_items += [meta]; }
|
||||
}
|
||||
} else if attr::get_meta_item_name(meta) == "vers" {
|
||||
alt attr::get_meta_item_value_str(meta) {
|
||||
some(v) { vers = some(v); }
|
||||
none. { cmh_items += [meta]; }
|
||||
none { cmh_items += [meta]; }
|
||||
}
|
||||
} else { cmh_items += [meta]; }
|
||||
}
|
||||
@ -442,7 +442,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
|
||||
output: str, metas: provided_metas) -> str {
|
||||
ret alt metas.name {
|
||||
some(v) { v }
|
||||
none. {
|
||||
none {
|
||||
let name =
|
||||
{
|
||||
let os = str::split(fs::basename(output), '.' as u8);
|
||||
@ -463,7 +463,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
|
||||
metas: provided_metas) -> str {
|
||||
ret alt metas.vers {
|
||||
some(v) { v }
|
||||
none. {
|
||||
none {
|
||||
let vers = "0.0";
|
||||
warn_missing(sess, "vers", vers);
|
||||
vers
|
||||
@ -509,7 +509,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str {
|
||||
let hash = "";
|
||||
alt ccx.type_sha1s.find(t) {
|
||||
some(h) { hash = h; }
|
||||
none. {
|
||||
none {
|
||||
hash = symbol_hash(ccx.tcx, ccx.sha, t, ccx.link_meta);
|
||||
ccx.type_sha1s.insert(t, hash);
|
||||
}
|
||||
|
@ -5,37 +5,37 @@ fn get_target_strs(target_os: session::os) -> target_strs::t {
|
||||
module_asm: "",
|
||||
|
||||
meta_sect_name: alt target_os {
|
||||
session::os_macos. { "__DATA,__note.rustc" }
|
||||
session::os_win32. { ".note.rustc" }
|
||||
session::os_linux. { ".note.rustc" }
|
||||
session::os_freebsd. { ".note.rustc" }
|
||||
session::os_macos { "__DATA,__note.rustc" }
|
||||
session::os_win32 { ".note.rustc" }
|
||||
session::os_linux { ".note.rustc" }
|
||||
session::os_freebsd { ".note.rustc" }
|
||||
},
|
||||
|
||||
data_layout: alt target_os {
|
||||
session::os_macos. {
|
||||
session::os_macos {
|
||||
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" +
|
||||
"-f32:32:32-f64:32:64-v64:64:64" +
|
||||
"-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32"
|
||||
}
|
||||
|
||||
session::os_win32. {
|
||||
session::os_win32 {
|
||||
"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32"
|
||||
}
|
||||
|
||||
session::os_linux. {
|
||||
session::os_linux {
|
||||
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
|
||||
}
|
||||
|
||||
session::os_freebsd. {
|
||||
session::os_freebsd {
|
||||
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
|
||||
}
|
||||
},
|
||||
|
||||
target_triple: alt target_os {
|
||||
session::os_macos. { "i686-apple-darwin" }
|
||||
session::os_win32. { "i686-pc-mingw32" }
|
||||
session::os_linux. { "i686-unknown-linux-gnu" }
|
||||
session::os_freebsd. { "i686-unknown-freebsd" }
|
||||
session::os_macos { "i686-apple-darwin" }
|
||||
session::os_win32 { "i686-pc-mingw32" }
|
||||
session::os_linux { "i686-unknown-linux-gnu" }
|
||||
session::os_freebsd { "i686-unknown-freebsd" }
|
||||
},
|
||||
|
||||
gcc_args: ["-m32"]
|
||||
|
@ -5,33 +5,33 @@ fn get_target_strs(target_os: session::os) -> target_strs::t {
|
||||
module_asm: "",
|
||||
|
||||
meta_sect_name: alt target_os {
|
||||
session::os_macos. { "__DATA,__note.rustc" }
|
||||
session::os_win32. { ".note.rustc" }
|
||||
session::os_linux. { ".note.rustc" }
|
||||
session::os_freebsd. { ".note.rustc" }
|
||||
session::os_macos { "__DATA,__note.rustc" }
|
||||
session::os_win32 { ".note.rustc" }
|
||||
session::os_linux { ".note.rustc" }
|
||||
session::os_freebsd { ".note.rustc" }
|
||||
},
|
||||
|
||||
data_layout: alt target_os {
|
||||
session::os_macos. {
|
||||
session::os_macos {
|
||||
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
|
||||
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
|
||||
"s0:64:64-f80:128:128-n8:16:32:64"
|
||||
}
|
||||
|
||||
session::os_win32. {
|
||||
session::os_win32 {
|
||||
// FIXME: Test this. Copied from linux
|
||||
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
|
||||
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
|
||||
"s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
}
|
||||
|
||||
session::os_linux. {
|
||||
session::os_linux {
|
||||
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
|
||||
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
|
||||
"s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
}
|
||||
|
||||
session::os_freebsd. {
|
||||
session::os_freebsd {
|
||||
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
|
||||
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
|
||||
"s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
@ -39,10 +39,10 @@ fn get_target_strs(target_os: session::os) -> target_strs::t {
|
||||
},
|
||||
|
||||
target_triple: alt target_os {
|
||||
session::os_macos. { "x86_64-apple-darwin" }
|
||||
session::os_win32. { "x86_64-pc-mingw32" }
|
||||
session::os_linux. { "x86_64-unknown-linux-gnu" }
|
||||
session::os_freebsd. { "x86_64-unknown-freebsd" }
|
||||
session::os_macos { "x86_64-apple-darwin" }
|
||||
session::os_win32 { "x86_64-pc-mingw32" }
|
||||
session::os_linux { "x86_64-unknown-linux-gnu" }
|
||||
session::os_freebsd { "x86_64-unknown-freebsd" }
|
||||
},
|
||||
|
||||
gcc_args: ["-m64"]
|
||||
|
@ -91,7 +91,7 @@ fn mk_handler(cm: codemap::codemap,
|
||||
|
||||
let emit = alt emitter {
|
||||
some(e) { e }
|
||||
none. {
|
||||
none {
|
||||
let f = fn@(cmsp: option<(codemap::codemap, span)>,
|
||||
msg: str, t: level) {
|
||||
emit(cmsp, msg, t);
|
||||
@ -116,19 +116,19 @@ tag level {
|
||||
|
||||
fn diagnosticstr(lvl: level) -> str {
|
||||
alt lvl {
|
||||
fatal. { "error" }
|
||||
error. { "error" }
|
||||
warning. { "warning" }
|
||||
note. { "note" }
|
||||
fatal { "error" }
|
||||
error { "error" }
|
||||
warning { "warning" }
|
||||
note { "note" }
|
||||
}
|
||||
}
|
||||
|
||||
fn diagnosticcolor(lvl: level) -> u8 {
|
||||
alt lvl {
|
||||
fatal. { term::color_bright_red }
|
||||
error. { term::color_bright_red }
|
||||
warning. { term::color_bright_yellow }
|
||||
note. { term::color_bright_green }
|
||||
fatal { term::color_bright_red }
|
||||
error { term::color_bright_red }
|
||||
warning { term::color_bright_yellow }
|
||||
note { term::color_bright_green }
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ fn emit(cmsp: option<(codemap::codemap, span)>,
|
||||
print_diagnostic(ss, lvl, msg);
|
||||
highlight_lines(cm, sp, lines);
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
print_diagnostic("", lvl, msg);
|
||||
}
|
||||
}
|
||||
|
@ -280,22 +280,22 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
|
||||
// from stdin, we're going to just suck the source into a string
|
||||
// so both the parser and pretty-printer can use it.
|
||||
let upto = alt ppm {
|
||||
ppm_expanded. { cu_expand }
|
||||
ppm_typed. { cu_typeck }
|
||||
ppm_expanded { cu_expand }
|
||||
ppm_typed { cu_typeck }
|
||||
_ { cu_parse }
|
||||
};
|
||||
let {crate, tcx, src} = compile_upto(sess, cfg, input, upto, none);
|
||||
|
||||
let ann: pprust::pp_ann = pprust::no_ann();
|
||||
alt ppm {
|
||||
ppm_typed. {
|
||||
ppm_typed {
|
||||
ann = {pre: ann_paren_for_expr,
|
||||
post: bind ann_typed_post(option::get(tcx), _)};
|
||||
}
|
||||
ppm_identified. {
|
||||
ppm_identified {
|
||||
ann = {pre: ann_paren_for_expr, post: ann_identified_post};
|
||||
}
|
||||
ppm_expanded. | ppm_normal. {}
|
||||
ppm_expanded | ppm_normal {}
|
||||
}
|
||||
pprust::print_crate(sess.codemap, sess.diagnostic, crate, input,
|
||||
io::string_reader(src), io::stdout(), ann);
|
||||
@ -332,11 +332,11 @@ fn build_target_config(sopts: @session::options,
|
||||
demitter: diagnostic::emitter) -> @session::config {
|
||||
let os = alt get_os(sopts.target_triple) {
|
||||
some(os) { os }
|
||||
none. { early_error(demitter, "Unknown operating system!") }
|
||||
none { early_error(demitter, "Unknown operating system!") }
|
||||
};
|
||||
let arch = alt get_arch(sopts.target_triple) {
|
||||
some(arch) { arch }
|
||||
none. { early_error(demitter,
|
||||
none { early_error(demitter,
|
||||
"Unknown architecture! " + sopts.target_triple) }
|
||||
};
|
||||
let (int_type, uint_type, float_type) = alt arch {
|
||||
@ -429,7 +429,7 @@ fn build_session_options(match: getopts::match,
|
||||
} else { 0u };
|
||||
let target =
|
||||
alt target_opt {
|
||||
none. { host_triple() }
|
||||
none { host_triple() }
|
||||
some(s) { s }
|
||||
};
|
||||
|
||||
@ -538,8 +538,8 @@ fn build_output_filenames(ifile: str,
|
||||
|
||||
let obj_suffix =
|
||||
alt sopts.output_type {
|
||||
link::output_type_none. { "none" }
|
||||
link::output_type_bitcode. { "bc" }
|
||||
link::output_type_none { "none" }
|
||||
link::output_type_bitcode { "bc" }
|
||||
link::output_type_assembly. { "s" }
|
||||
link::output_type_llvm_assembly. { "ll" }
|
||||
// Object and exe output both use the '.o' extension here
|
||||
@ -549,13 +549,13 @@ fn build_output_filenames(ifile: str,
|
||||
};
|
||||
|
||||
alt ofile {
|
||||
none. {
|
||||
none {
|
||||
// "-" as input file will cause the parser to read from stdin so we
|
||||
// have to make up a name
|
||||
// We want to toss everything after the final '.'
|
||||
let dirname = alt odir {
|
||||
some(d) { d }
|
||||
none. {
|
||||
none {
|
||||
if input_is_stdin(ifile) {
|
||||
std::os::getcwd()
|
||||
} else {
|
||||
|
@ -114,9 +114,9 @@ impl session for session {
|
||||
fn building_library(req_crate_type: crate_type, crate: @ast::crate,
|
||||
testing: bool) -> bool {
|
||||
alt req_crate_type {
|
||||
bin_crate. { false }
|
||||
lib_crate. { true }
|
||||
unknown_crate. {
|
||||
bin_crate { false }
|
||||
lib_crate { true }
|
||||
unknown_crate {
|
||||
if testing {
|
||||
false
|
||||
} else {
|
||||
|
@ -202,7 +202,7 @@ fn require_unique_names(sess: session, metas: [@ast::meta_item]) {
|
||||
|
||||
fn native_abi(attrs: [ast::attribute]) -> either::t<str, ast::native_abi> {
|
||||
ret alt attr::get_meta_item_value_str_by_name(attrs, "abi") {
|
||||
option::none. {
|
||||
option::none {
|
||||
either::right(ast::native_abi_cdecl)
|
||||
}
|
||||
option::some("rust-intrinsic") {
|
||||
@ -236,10 +236,10 @@ fn meta_item_value_from_list(
|
||||
some(item) {
|
||||
alt attr::get_meta_item_value_str(item) {
|
||||
some(value) { some(value) }
|
||||
none. { none }
|
||||
none { none }
|
||||
}
|
||||
}
|
||||
none. { none }
|
||||
none { none }
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ fn meta_item_list_from_list(
|
||||
some(item) {
|
||||
attr::get_meta_item_list(item)
|
||||
}
|
||||
none. { none }
|
||||
none { none }
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ fn name_value_str_pair(
|
||||
let name = attr::get_meta_item_name(item);
|
||||
some((name, value))
|
||||
}
|
||||
none. { none }
|
||||
none { none }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ fn visit_item(e: env, i: @ast::item) {
|
||||
}
|
||||
nn
|
||||
}
|
||||
none. { i.ident }
|
||||
none { i.ident }
|
||||
};
|
||||
let already_added = false;
|
||||
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u {
|
||||
@ -84,7 +84,7 @@ fn visit_item(e: env, i: @ast::item) {
|
||||
some(linkarg) {
|
||||
cstore::add_used_link_args(cstore, linkarg);
|
||||
}
|
||||
none. {/* fallthrough */ }
|
||||
none {/* fallthrough */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ fn visit_item(e: env, i: @ast::item) {
|
||||
fn list_file_metadata(sess: session::session, path: str, out: io::writer) {
|
||||
alt get_metadata_section(sess, path) {
|
||||
option::some(bytes) { decoder::list_crate_metadata(bytes, out); }
|
||||
option::none. {
|
||||
option::none {
|
||||
out.write_str("Could not find metadata in " + path + ".\n");
|
||||
}
|
||||
}
|
||||
@ -154,7 +154,7 @@ fn find_library_crate(sess: session::session, ident: ast::ident,
|
||||
_ { ident }
|
||||
}
|
||||
}
|
||||
none. { ident }
|
||||
none { ident }
|
||||
}
|
||||
};
|
||||
|
||||
@ -239,7 +239,7 @@ fn load_library_crate(sess: session::session, span: span, ident: ast::ident,
|
||||
|
||||
alt find_library_crate(sess, ident, metas) {
|
||||
some(t) { ret t; }
|
||||
none. {
|
||||
none {
|
||||
sess.span_fatal(span, #fmt["can't find crate for '%s'", ident]);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id,
|
||||
ebml::tagged_docs(mod_item, tag_mod_impl) {|doc|
|
||||
let did = translate_def_id(cdata, parse_def_id(ebml::doc_data(doc)));
|
||||
let item = lookup_item(did.node, data), nm = item_name(item);
|
||||
if alt name { some(n) { n == nm } none. { true } } {
|
||||
if alt name { some(n) { n == nm } none { true } } {
|
||||
let base_tps = item_ty_param_count(doc);
|
||||
result += [@{did: did, ident: nm,
|
||||
methods: item_impl_methods(cdata, item, base_tps)}];
|
||||
@ -393,7 +393,7 @@ fn get_attributes(md: ebml::doc) -> [ast::attribute] {
|
||||
span: ast_util::dummy_sp()}];
|
||||
};
|
||||
}
|
||||
option::none. { }
|
||||
option::none { }
|
||||
}
|
||||
ret attrs;
|
||||
}
|
||||
@ -489,7 +489,7 @@ fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
|
||||
|
||||
alt cdata.cnum_map.find(did.crate) {
|
||||
option::some(n) { ret {crate: n, node: did.node}; }
|
||||
option::none. { fail "didn't find a crate in the cnum_map"; }
|
||||
option::none { fail "didn't find a crate in the cnum_map"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,9 +296,9 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||
encode_def_id(ebml_w, local_def(item.id));
|
||||
encode_family(ebml_w,
|
||||
alt decl.purity {
|
||||
unsafe_fn. { 'u' }
|
||||
pure_fn. { 'p' }
|
||||
impure_fn. { 'f' }
|
||||
unsafe_fn { 'u' }
|
||||
pure_fn { 'p' }
|
||||
impure_fn { 'f' }
|
||||
} as u8);
|
||||
encode_type_param_bounds(ebml_w, ecx, tps);
|
||||
encode_type(ecx, ebml_w, node_id_to_monotype(tcx, item.id));
|
||||
@ -420,7 +420,7 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
nitem: @native_item) {
|
||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||
alt nitem.node {
|
||||
native_item_ty. {
|
||||
native_item_ty {
|
||||
encode_def_id(ebml_w, local_def(nitem.id));
|
||||
encode_family(ebml_w, 'T' as u8);
|
||||
encode_type(ecx, ebml_w,
|
||||
@ -429,9 +429,9 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
native_item_fn(fn_decl, tps) {
|
||||
let letter =
|
||||
alt fn_decl.purity {
|
||||
unsafe_fn. { 'U' }
|
||||
pure_fn. { 'P' } // this is currently impossible, but hey.
|
||||
impure_fn. { 'F' }
|
||||
unsafe_fn { 'U' }
|
||||
pure_fn { 'P' } // this is currently impossible, but hey.
|
||||
impure_fn { 'F' }
|
||||
} as u8;
|
||||
encode_def_id(ebml_w, local_def(nitem.id));
|
||||
encode_family(ebml_w, letter);
|
||||
|
@ -277,7 +277,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
||||
assert (next(st) as char == '#');
|
||||
alt st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) {
|
||||
some(tt) { ret tt; }
|
||||
none. {
|
||||
none {
|
||||
let ps = @{pos: pos with *st};
|
||||
let tt = parse_ty(ps, conv);
|
||||
st.tcx.rcache.insert({cnum: st.crate, pos: pos, len: len}, tt);
|
||||
|
@ -29,17 +29,17 @@ tag abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap<ty::t, ty_abbrev>); }
|
||||
|
||||
fn cx_uses_abbrevs(cx: @ctxt) -> bool {
|
||||
alt cx.abbrevs {
|
||||
ac_no_abbrevs. { ret false; }
|
||||
ac_no_abbrevs { ret false; }
|
||||
ac_use_abbrevs(_) { ret true; }
|
||||
}
|
||||
}
|
||||
|
||||
fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
|
||||
alt cx.abbrevs {
|
||||
ac_no_abbrevs. {
|
||||
ac_no_abbrevs {
|
||||
let result_str = alt cx.tcx.short_names_cache.find(t) {
|
||||
some(s) { *s }
|
||||
none. {
|
||||
none {
|
||||
let buf = io::mk_mem_buffer();
|
||||
enc_sty(io::mem_buffer_writer(buf), cx,
|
||||
ty::struct_raw(cx.tcx, t));
|
||||
@ -52,7 +52,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
|
||||
ac_use_abbrevs(abbrevs) {
|
||||
alt abbrevs.find(t) {
|
||||
some(a) { w.write_str(*a.s); ret; }
|
||||
none. {
|
||||
none {
|
||||
let pos = w.tell();
|
||||
enc_sty(w, cx, ty::struct_raw(cx.tcx, t));
|
||||
let end = w.tell();
|
||||
@ -79,44 +79,44 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
|
||||
}
|
||||
fn enc_mt(w: io::writer, cx: @ctxt, mt: ty::mt) {
|
||||
alt mt.mut {
|
||||
imm. { }
|
||||
mut. { w.write_char('m'); }
|
||||
maybe_mut. { w.write_char('?'); }
|
||||
imm { }
|
||||
mut { w.write_char('m'); }
|
||||
maybe_mut { w.write_char('?'); }
|
||||
}
|
||||
enc_ty(w, cx, mt.ty);
|
||||
}
|
||||
fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||
alt st {
|
||||
ty::ty_nil. { w.write_char('n'); }
|
||||
ty::ty_bot. { w.write_char('z'); }
|
||||
ty::ty_bool. { w.write_char('b'); }
|
||||
ty::ty_nil { w.write_char('n'); }
|
||||
ty::ty_bot { w.write_char('z'); }
|
||||
ty::ty_bool { w.write_char('b'); }
|
||||
ty::ty_int(t) {
|
||||
alt t {
|
||||
ty_i. { w.write_char('i'); }
|
||||
ty_char. { w.write_char('c'); }
|
||||
ty_i8. { w.write_str("MB"); }
|
||||
ty_i16. { w.write_str("MW"); }
|
||||
ty_i32. { w.write_str("ML"); }
|
||||
ty_i64. { w.write_str("MD"); }
|
||||
ty_i { w.write_char('i'); }
|
||||
ty_char { w.write_char('c'); }
|
||||
ty_i8 { w.write_str("MB"); }
|
||||
ty_i16 { w.write_str("MW"); }
|
||||
ty_i32 { w.write_str("ML"); }
|
||||
ty_i64 { w.write_str("MD"); }
|
||||
}
|
||||
}
|
||||
ty::ty_uint(t) {
|
||||
alt t {
|
||||
ty_u. { w.write_char('u'); }
|
||||
ty_u8. { w.write_str("Mb"); }
|
||||
ty_u16. { w.write_str("Mw"); }
|
||||
ty_u32. { w.write_str("Ml"); }
|
||||
ty_u64. { w.write_str("Md"); }
|
||||
ty_u { w.write_char('u'); }
|
||||
ty_u8 { w.write_str("Mb"); }
|
||||
ty_u16 { w.write_str("Mw"); }
|
||||
ty_u32 { w.write_str("Ml"); }
|
||||
ty_u64 { w.write_str("Md"); }
|
||||
}
|
||||
}
|
||||
ty::ty_float(t) {
|
||||
alt t {
|
||||
ty_f. { w.write_char('l'); }
|
||||
ty_f32. { w.write_str("Mf"); }
|
||||
ty_f64. { w.write_str("MF"); }
|
||||
ty_f { w.write_char('l'); }
|
||||
ty_f32 { w.write_str("Mf"); }
|
||||
ty_f64 { w.write_str("MF"); }
|
||||
}
|
||||
}
|
||||
ty::ty_str. { w.write_char('S'); }
|
||||
ty::ty_str { w.write_char('S'); }
|
||||
ty::ty_tag(def, tys) {
|
||||
w.write_str("t[");
|
||||
w.write_str(cx.ds(def));
|
||||
@ -178,11 +178,11 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||
w.write_char('|');
|
||||
w.write_str(uint::str(id));
|
||||
}
|
||||
ty::ty_type. { w.write_char('Y'); }
|
||||
ty::ty_send_type. { w.write_char('y'); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_block.) { w.write_str("C&"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_box.) { w.write_str("C@"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_uniq.) { w.write_str("C~"); }
|
||||
ty::ty_type { w.write_char('Y'); }
|
||||
ty::ty_send_type { w.write_char('y'); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_block) { w.write_str("C&"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_box) { w.write_str("C@"); }
|
||||
ty::ty_opaque_closure_ptr(ty::ck_uniq) { w.write_str("C~"); }
|
||||
ty::ty_constr(ty, cs) {
|
||||
w.write_str("A[");
|
||||
enc_ty(w, cx, ty);
|
||||
@ -201,11 +201,11 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||
}
|
||||
fn enc_proto(w: io::writer, proto: proto) {
|
||||
alt proto {
|
||||
proto_uniq. { w.write_str("f~"); }
|
||||
proto_box. { w.write_str("f@"); }
|
||||
proto_block. { w.write_str("f&"); }
|
||||
proto_any. { w.write_str("f*"); }
|
||||
proto_bare. { w.write_str("fn"); }
|
||||
proto_uniq { w.write_str("f~"); }
|
||||
proto_box { w.write_str("f@"); }
|
||||
proto_block { w.write_str("f&"); }
|
||||
proto_any { w.write_str("f*"); }
|
||||
proto_bare { w.write_str("fn"); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,11 +213,11 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) {
|
||||
w.write_char('[');
|
||||
for arg: ty::arg in ft.inputs {
|
||||
alt arg.mode {
|
||||
by_mut_ref. { w.write_char('&'); }
|
||||
by_move. { w.write_char('-'); }
|
||||
by_copy. { w.write_char('+'); }
|
||||
by_ref. { w.write_char('='); }
|
||||
by_val. { w.write_char('#'); }
|
||||
by_mut_ref { w.write_char('&'); }
|
||||
by_move { w.write_char('-'); }
|
||||
by_copy { w.write_char('+'); }
|
||||
by_ref { w.write_char('='); }
|
||||
by_val { w.write_char('#'); }
|
||||
}
|
||||
enc_ty(w, cx, arg.ty);
|
||||
}
|
||||
@ -231,7 +231,7 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) {
|
||||
enc_constr(w, cx, c);
|
||||
}
|
||||
alt ft.ret_style {
|
||||
noreturn. { w.write_char('!'); }
|
||||
noreturn { w.write_char('!'); }
|
||||
_ { enc_ty(w, cx, ft.output); }
|
||||
}
|
||||
}
|
||||
@ -246,7 +246,7 @@ fn enc_constr(w: io::writer, cx: @ctxt, c: @ty::constr) {
|
||||
for a: @constr_arg in c.node.args {
|
||||
if semi { w.write_char(';'); } else { semi = true; }
|
||||
alt a.node {
|
||||
carg_base. { w.write_char('*'); }
|
||||
carg_base { w.write_char('*'); }
|
||||
carg_ident(i) { w.write_uint(i); }
|
||||
carg_lit(l) { w.write_str(lit_to_str(l)); }
|
||||
}
|
||||
@ -263,7 +263,7 @@ fn enc_ty_constr(w: io::writer, cx: @ctxt, c: @ty::type_constr) {
|
||||
for a: @ty::ty_constr_arg in c.node.args {
|
||||
if semi { w.write_char(';'); } else { semi = true; }
|
||||
alt a.node {
|
||||
carg_base. { w.write_char('*'); }
|
||||
carg_base { w.write_char('*'); }
|
||||
carg_ident(p) { w.write_str(path_to_str(p)); }
|
||||
carg_lit(l) { w.write_str(lit_to_str(l)); }
|
||||
}
|
||||
@ -274,8 +274,8 @@ fn enc_ty_constr(w: io::writer, cx: @ctxt, c: @ty::type_constr) {
|
||||
fn enc_bounds(w: io::writer, cx: @ctxt, bs: @[ty::param_bound]) {
|
||||
for bound in *bs {
|
||||
alt bound {
|
||||
ty::bound_send. { w.write_char('S'); }
|
||||
ty::bound_copy. { w.write_char('C'); }
|
||||
ty::bound_send { w.write_char('S'); }
|
||||
ty::bound_copy { w.write_char('C'); }
|
||||
ty::bound_iface(tp) {
|
||||
w.write_char('I');
|
||||
enc_ty(w, cx, tp);
|
||||
|
@ -90,10 +90,10 @@ fn visit_fn(cx: @ctx, _fk: visit::fn_kind, decl: ast::fn_decl,
|
||||
// be called multiple times.
|
||||
let proto = ty::ty_fn_proto(cx.tcx, fty);
|
||||
alt proto {
|
||||
ast::proto_block. | ast::proto_any. {
|
||||
ast::proto_block | ast::proto_any {
|
||||
check_loop(*cx, sc) {|| v.visit_block(body, sc, v);}
|
||||
}
|
||||
ast::proto_box. | ast::proto_uniq. | ast::proto_bare. {
|
||||
ast::proto_box | ast::proto_uniq | ast::proto_bare {
|
||||
let sc = {bs: [], invalid: @mutable list::nil};
|
||||
v.visit_block(body, sc, v);
|
||||
}
|
||||
@ -156,7 +156,7 @@ fn visit_block(cx: @ctx, b: ast::blk, sc: scope, v: vt<scope>) {
|
||||
check_lval(cx, init.expr, sc, v);
|
||||
}
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,9 +197,9 @@ fn add_bindings_for_let(cx: ctx, &bs: [binding], loc: @ast::local) {
|
||||
|
||||
fn cant_copy(cx: ctx, b: binding) -> bool {
|
||||
alt b.copied {
|
||||
not_allowed. { ret true; }
|
||||
copied. { ret false; }
|
||||
not_copied. {}
|
||||
not_allowed { ret true; }
|
||||
copied { ret false; }
|
||||
not_copied {}
|
||||
}
|
||||
let ty = ty::node_id_to_type(cx.tcx, b.node_id);
|
||||
if ty::type_allows_implicit_copy(cx.tcx, ty) {
|
||||
@ -240,8 +240,8 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
|
||||
local_id: 0u,
|
||||
unsafe_tys: unsafe_set(root.mut),
|
||||
mutable copied: alt arg_t.mode {
|
||||
ast::by_move. | ast::by_copy. { copied }
|
||||
ast::by_mut_ref. { not_allowed }
|
||||
ast::by_move | ast::by_copy { copied }
|
||||
ast::by_mut_ref { not_allowed }
|
||||
_ { not_copied }
|
||||
}}];
|
||||
i += 1u;
|
||||
@ -306,7 +306,7 @@ fn check_call(cx: ctx, sc: scope, f: @ast::expr, args: [@ast::expr])
|
||||
break;
|
||||
}
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
i += 1u;
|
||||
@ -335,7 +335,7 @@ fn check_alt(cx: ctx, input: @ast::expr, arms: [ast::arm], sc: scope,
|
||||
let canon_id = pat_id_map.get(proot.name);
|
||||
alt vec::find(binding_info, {|x| x.id == canon_id}) {
|
||||
some(s) { s.unsafe_tys += unsafe_set(proot.mut); }
|
||||
none. {
|
||||
none {
|
||||
binding_info += [
|
||||
{id: canon_id,
|
||||
mutable unsafe_tys: unsafe_set(proot.mut),
|
||||
@ -466,8 +466,8 @@ fn test_scope(cx: ctx, sc: scope, b: binding, p: @ast::path) {
|
||||
if !is_none(prob) && cant_copy(cx, b) {
|
||||
let i = option::get(prob);
|
||||
let msg = alt i.reason {
|
||||
overwritten. { "overwriting " + ast_util::path_name(i.path) }
|
||||
val_taken. { "taking the value of " + ast_util::path_name(i.path) }
|
||||
overwritten { "overwriting " + ast_util::path_name(i.path) }
|
||||
val_taken { "taking the value of " + ast_util::path_name(i.path) }
|
||||
};
|
||||
err(cx, i.sp, msg + " will invalidate reference " +
|
||||
ast_util::path_name(p) + ", which is still used");
|
||||
@ -523,7 +523,7 @@ fn ty_can_unsafely_include(cx: ctx, needle: unsafe_ty, haystack: ty::t,
|
||||
for t in ts { if helper(tcx, needle, t, mut) { ret true; } }
|
||||
ret false;
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_bare., _}) { ret false; }
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) { ret false; }
|
||||
// These may contain anything.
|
||||
ty::ty_fn(_) | ty::ty_iface(_, _) { ret true; }
|
||||
// A type param may include everything, but can only be
|
||||
@ -557,13 +557,13 @@ fn local_id_of_node(cx: ctx, id: node_id) -> uint {
|
||||
fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
|
||||
fn score_ty(tcx: ty::ctxt, ty: ty::t) -> uint {
|
||||
ret alt ty::struct(tcx, ty) {
|
||||
ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int(_) |
|
||||
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type. | ty::ty_native(_) |
|
||||
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
|
||||
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type | ty::ty_native(_) |
|
||||
ty::ty_ptr(_) { 1u }
|
||||
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
|
||||
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
|
||||
ty::ty_fn(_) | ty::ty_native_fn(_, _) { 4u }
|
||||
ty::ty_str. | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
|
||||
ty::ty_str | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
|
||||
ty::ty_uniq(mt) { 1u + score_ty(tcx, mt.ty) }
|
||||
ty::ty_tag(_, ts) | ty::ty_tup(ts) {
|
||||
let sum = 0u;
|
||||
@ -590,7 +590,7 @@ fn pattern_roots(tcx: ty::ctxt, mut: option::t<unsafe_ty>, pat: @ast::pat)
|
||||
fn walk(tcx: ty::ctxt, mut: option::t<unsafe_ty>, pat: @ast::pat,
|
||||
&set: [pattern_root]) {
|
||||
alt normalize_pat(tcx, pat).node {
|
||||
ast::pat_wild. | ast::pat_lit(_) | ast::pat_range(_, _) {}
|
||||
ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) {}
|
||||
ast::pat_ident(nm, sub) {
|
||||
set += [{id: pat.id, name: path_to_ident(nm), mut: mut,
|
||||
span: pat.span}];
|
||||
@ -648,7 +648,7 @@ fn find_invalid(id: node_id, lst: list<@invalid>)
|
||||
let cur = lst;
|
||||
while true {
|
||||
alt cur {
|
||||
list::nil. { break; }
|
||||
list::nil { break; }
|
||||
list::cons(head, tail) {
|
||||
if head.node_id == id { ret some(head); }
|
||||
cur = *tail;
|
||||
|
@ -75,11 +75,11 @@ fn check_capture_clause(tcx: ty::ctxt,
|
||||
};
|
||||
|
||||
alt fn_proto {
|
||||
ast::proto_any. | ast::proto_block. {
|
||||
ast::proto_any | ast::proto_block {
|
||||
check_block_captures(cap_clause.copies);
|
||||
check_block_captures(cap_clause.moves);
|
||||
}
|
||||
ast::proto_bare. | ast::proto_box. | ast::proto_uniq. {
|
||||
ast::proto_bare | ast::proto_box | ast::proto_uniq {
|
||||
vec::iter(cap_clause.copies, check_capture_item);
|
||||
vec::iter(cap_clause.moves, check_capture_item);
|
||||
vec::iter(cap_clause.moves, check_not_upvar);
|
||||
@ -113,15 +113,15 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
||||
}
|
||||
|
||||
let implicit_mode = alt fn_proto {
|
||||
ast::proto_any. | ast::proto_block. { cap_ref }
|
||||
ast::proto_bare. | ast::proto_box. | ast::proto_uniq. { cap_copy }
|
||||
ast::proto_any | ast::proto_block { cap_ref }
|
||||
ast::proto_bare | ast::proto_box | ast::proto_uniq { cap_copy }
|
||||
};
|
||||
|
||||
vec::iter(*freevars) { |fvar|
|
||||
let fvar_def_id = ast_util::def_id_of_def(fvar.def).node;
|
||||
alt cap_map.find(fvar_def_id) {
|
||||
option::some(_) { /* was explicitly named, do nothing */ }
|
||||
option::none. {
|
||||
option::none {
|
||||
cap_map.insert(fvar_def_id, {def:fvar.def, mode:implicit_mode});
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ fn pattern_supersedes(tcx: ty::ctxt, a: @pat, b: @pat) -> bool {
|
||||
|
||||
alt a.node {
|
||||
pat_ident(_, some(p)) { pattern_supersedes(tcx, p, b) }
|
||||
pat_wild. | pat_ident(_, none.) { true }
|
||||
pat_wild | pat_ident(_, none) { true }
|
||||
pat_lit(la) {
|
||||
alt b.node {
|
||||
pat_lit(lb) { lit_expr_eq(la, lb) }
|
||||
@ -142,7 +142,7 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
|
||||
pat_box(sub) | pat_uniq(sub) | pat_ident(_, some(sub)) {
|
||||
is_refutable(tcx, sub)
|
||||
}
|
||||
pat_wild. | pat_ident(_, none.) { false }
|
||||
pat_wild | pat_ident(_, none) { false }
|
||||
pat_lit(_) { true }
|
||||
pat_rec(fields, _) {
|
||||
for field: field_pat in fields {
|
||||
|
@ -45,7 +45,7 @@ fn check_expr(sess: session, e: @expr, &&is_const: bool, v: visit::vt<bool>) {
|
||||
if is_const {
|
||||
alt e.node {
|
||||
expr_unary(box(_), _) | expr_unary(uniq(_), _) |
|
||||
expr_unary(deref., _){
|
||||
expr_unary(deref, _){
|
||||
sess.span_err(e.span,
|
||||
"disallowed operator in constant expression");
|
||||
ret;
|
||||
|
@ -160,7 +160,7 @@ fn create_compile_unit(cx: @crate_ctxt, full_path: str)
|
||||
alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
|
||||
{|md| md.data.path == full_path}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
let work_dir = cx.sess.working_dir;
|
||||
@ -202,7 +202,7 @@ fn create_file(cx: @crate_ctxt, full_path: str) -> @metadata<file_md> {
|
||||
alt cached_metadata::<@metadata<file_md>>(
|
||||
cache, tg, {|md| md.data.path == full_path}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
let fname = fs::basename(full_path);
|
||||
@ -234,17 +234,17 @@ fn create_block(cx: @block_ctxt) -> @metadata<block_md> {
|
||||
cache, tg,
|
||||
{|md| start == md.data.start && end == md.data.end}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
let parent = alt cx.parent {
|
||||
trans_common::parent_none. { create_function(cx.fcx).node }
|
||||
trans_common::parent_none { create_function(cx.fcx).node }
|
||||
trans_common::parent_some(bcx) { create_block(cx).node }
|
||||
};
|
||||
let file_node = create_file(bcx_ccx(cx), fname);
|
||||
let unique_id = alt cache.find(LexicalBlockTag) {
|
||||
option::some(v) { vec::len(v) as int }
|
||||
option::none. { 0 }
|
||||
option::none { 0 }
|
||||
};
|
||||
let lldata = [lltag(tg),
|
||||
parent,
|
||||
@ -270,30 +270,30 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| t == md.data.hash}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
let (name, (size, align), encoding) = alt ty.node {
|
||||
ast::ty_bool. {("bool", size_and_align_of::<bool>(), DW_ATE_boolean)}
|
||||
ast::ty_bool {("bool", size_and_align_of::<bool>(), DW_ATE_boolean)}
|
||||
ast::ty_int(m) { alt m {
|
||||
ast::ty_char. {("char", size_and_align_of::<char>(), DW_ATE_unsigned)}
|
||||
ast::ty_i. {("int", size_and_align_of::<int>(), DW_ATE_signed)}
|
||||
ast::ty_i8. {("i8", size_and_align_of::<i8>(), DW_ATE_signed_char)}
|
||||
ast::ty_i16. {("i16", size_and_align_of::<i16>(), DW_ATE_signed)}
|
||||
ast::ty_i32. {("i32", size_and_align_of::<i32>(), DW_ATE_signed)}
|
||||
ast::ty_i64. {("i64", size_and_align_of::<i64>(), DW_ATE_signed)}
|
||||
ast::ty_char {("char", size_and_align_of::<char>(), DW_ATE_unsigned)}
|
||||
ast::ty_i {("int", size_and_align_of::<int>(), DW_ATE_signed)}
|
||||
ast::ty_i8 {("i8", size_and_align_of::<i8>(), DW_ATE_signed_char)}
|
||||
ast::ty_i16 {("i16", size_and_align_of::<i16>(), DW_ATE_signed)}
|
||||
ast::ty_i32 {("i32", size_and_align_of::<i32>(), DW_ATE_signed)}
|
||||
ast::ty_i64 {("i64", size_and_align_of::<i64>(), DW_ATE_signed)}
|
||||
}}
|
||||
ast::ty_uint(m) { alt m {
|
||||
ast::ty_u. {("uint", size_and_align_of::<uint>(), DW_ATE_unsigned)}
|
||||
ast::ty_u8. {("u8", size_and_align_of::<u8>(), DW_ATE_unsigned_char)}
|
||||
ast::ty_u16. {("u16", size_and_align_of::<u16>(), DW_ATE_unsigned)}
|
||||
ast::ty_u32. {("u32", size_and_align_of::<u32>(), DW_ATE_unsigned)}
|
||||
ast::ty_u64. {("u64", size_and_align_of::<u64>(), DW_ATE_unsigned)}
|
||||
ast::ty_u {("uint", size_and_align_of::<uint>(), DW_ATE_unsigned)}
|
||||
ast::ty_u8 {("u8", size_and_align_of::<u8>(), DW_ATE_unsigned_char)}
|
||||
ast::ty_u16 {("u16", size_and_align_of::<u16>(), DW_ATE_unsigned)}
|
||||
ast::ty_u32 {("u32", size_and_align_of::<u32>(), DW_ATE_unsigned)}
|
||||
ast::ty_u64 {("u64", size_and_align_of::<u64>(), DW_ATE_unsigned)}
|
||||
}}
|
||||
ast::ty_float(m) { alt m {
|
||||
ast::ty_f. {("float", size_and_align_of::<float>(), DW_ATE_float)}
|
||||
ast::ty_f32. {("f32", size_and_align_of::<f32>(), DW_ATE_float)}
|
||||
ast::ty_f64. {("f64", size_and_align_of::<f64>(), DW_ATE_float)}
|
||||
ast::ty_f {("float", size_and_align_of::<float>(), DW_ATE_float)}
|
||||
ast::ty_f32 {("f32", size_and_align_of::<f32>(), DW_ATE_float)}
|
||||
ast::ty_f64 {("f64", size_and_align_of::<f64>(), DW_ATE_float)}
|
||||
}}
|
||||
};
|
||||
|
||||
@ -325,7 +325,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: codemap::span,
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| ty::hash_ty(t) == ty::hash_ty(md.data.hash)}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}*/
|
||||
let (size, align) = size_and_align_of::<ctypes::intptr_t>();
|
||||
let fname = filename_from_span(cx, span);
|
||||
@ -418,7 +418,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| ty::hash_ty(outer) == ty::hash_ty(md.data.hash)}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}*/
|
||||
let fname = filename_from_span(cx, span);
|
||||
let file_node = create_file(cx, fname);
|
||||
@ -492,24 +492,24 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, vec_ty: @ast::ty)
|
||||
|
||||
fn member_size_and_align(ty: @ast::ty) -> (int, int) {
|
||||
alt ty.node {
|
||||
ast::ty_bool. { size_and_align_of::<bool>() }
|
||||
ast::ty_bool { size_and_align_of::<bool>() }
|
||||
ast::ty_int(m) { alt m {
|
||||
ast::ty_char. { size_and_align_of::<char>() }
|
||||
ast::ty_i. { size_and_align_of::<int>() }
|
||||
ast::ty_i8. { size_and_align_of::<i8>() }
|
||||
ast::ty_i16. { size_and_align_of::<i16>() }
|
||||
ast::ty_i32. { size_and_align_of::<i32>() }
|
||||
ast::ty_char { size_and_align_of::<char>() }
|
||||
ast::ty_i { size_and_align_of::<int>() }
|
||||
ast::ty_i8 { size_and_align_of::<i8>() }
|
||||
ast::ty_i16 { size_and_align_of::<i16>() }
|
||||
ast::ty_i32 { size_and_align_of::<i32>() }
|
||||
}}
|
||||
ast::ty_uint(m) { alt m {
|
||||
ast::ty_u. { size_and_align_of::<uint>() }
|
||||
ast::ty_u8. { size_and_align_of::<i8>() }
|
||||
ast::ty_u16. { size_and_align_of::<u16>() }
|
||||
ast::ty_u32. { size_and_align_of::<u32>() }
|
||||
ast::ty_u { size_and_align_of::<uint>() }
|
||||
ast::ty_u8 { size_and_align_of::<i8>() }
|
||||
ast::ty_u16 { size_and_align_of::<u16>() }
|
||||
ast::ty_u32 { size_and_align_of::<u32>() }
|
||||
}}
|
||||
ast::ty_float(m) { alt m {
|
||||
ast::ty_f. { size_and_align_of::<float>() }
|
||||
ast::ty_f32. { size_and_align_of::<f32>() }
|
||||
ast::ty_f64. { size_and_align_of::<f64>() }
|
||||
ast::ty_f { size_and_align_of::<float>() }
|
||||
ast::ty_f32 { size_and_align_of::<f32>() }
|
||||
ast::ty_f64 { size_and_align_of::<f64>() }
|
||||
}}
|
||||
ast::ty_box(_) | ast::ty_uniq(_) {
|
||||
size_and_align_of::<ctypes::uintptr_t>()
|
||||
@ -534,14 +534,14 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| t == md.data.hash}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}*/
|
||||
|
||||
fn t_to_ty(cx: @crate_ctxt, t: ty::t, span: codemap::span) -> @ast::ty {
|
||||
let ty = alt ty::struct(ccx_tcx(cx), t) {
|
||||
ty::ty_nil. { ast::ty_nil }
|
||||
ty::ty_bot. { ast::ty_bot }
|
||||
ty::ty_bool. { ast::ty_bool }
|
||||
ty::ty_nil { ast::ty_nil }
|
||||
ty::ty_bot { ast::ty_bot }
|
||||
ty::ty_bool { ast::ty_bool }
|
||||
ty::ty_int(t) { ast::ty_int(t) }
|
||||
ty::ty_float(t) { ast::ty_float(t) }
|
||||
ty::ty_uint(t) { ast::ty_uint(t) }
|
||||
@ -627,7 +627,7 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
|
||||
alt cached_metadata::<@metadata<local_var_md>>(
|
||||
cache, tg, {|md| md.data.id == local.node.id}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
let name = path_to_ident(alt pat_util::normalize_pat(bcx_tcx(bcx),
|
||||
@ -640,7 +640,7 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
|
||||
let tymd = create_ty(cx, ty, local.node.ty);
|
||||
let filemd = create_file(cx, loc.filename);
|
||||
let context = alt bcx.parent {
|
||||
trans_common::parent_none. { create_function(bcx.fcx).node }
|
||||
trans_common::parent_none { create_function(bcx.fcx).node }
|
||||
trans_common::parent_some(_) { create_block(bcx).node }
|
||||
};
|
||||
let mdnode = create_var(tg, context, name, filemd.node,
|
||||
@ -650,7 +650,7 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
|
||||
|
||||
let llptr = alt bcx.fcx.lllocals.find(local.node.id) {
|
||||
option::some(local_mem(v)) { v }
|
||||
option::none. {
|
||||
option::none {
|
||||
alt bcx.fcx.lllocals.get(local.node.pat.id) {
|
||||
local_imm(v) { v }
|
||||
}
|
||||
@ -671,7 +671,7 @@ fn create_arg(bcx: @block_ctxt, arg: ast::arg)
|
||||
alt cached_metadata::<@metadata<argument_md>>(
|
||||
cache, ArgVariableTag, {|md| md.data.id == arg.id}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
/*let arg_n = alt cx.ast_map.get(arg.id) {
|
||||
@ -759,7 +759,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
|
||||
cache, SubprogramTag, {|md| md.data.path == path &&
|
||||
/*md.data.path == ??*/ true}) {
|
||||
option::some(md) { ret md; }
|
||||
option::none. {}
|
||||
option::none {}
|
||||
}
|
||||
|
||||
let loc = codemap::lookup_char_pos(cx.sess.codemap,
|
||||
@ -769,7 +769,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
|
||||
let mangled = cx.item_symbols.get(key);
|
||||
let ty_node = if cx.sess.opts.extra_debuginfo {
|
||||
alt ret_ty.node {
|
||||
ast::ty_nil. { llnull() }
|
||||
ast::ty_nil { llnull() }
|
||||
_ { create_ty(cx, ty::node_id_to_type(ccx_tcx(cx), id),
|
||||
ret_ty).node }
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ fn fn_usage_expr(expr: @ast::expr,
|
||||
ast::expr_path(path) {
|
||||
if !ctx.unsafe_fn_legal {
|
||||
alt ctx.tcx.def_map.find(expr.id) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn.)) |
|
||||
some(ast::def_native_fn(_, ast::unsafe_fn.)) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn)) |
|
||||
some(ast::def_native_fn(_, ast::unsafe_fn)) {
|
||||
log(error, ("expr=", expr_to_str(expr)));
|
||||
ctx.tcx.sess.span_fatal(
|
||||
expr.span,
|
||||
@ -33,7 +33,7 @@ fn fn_usage_expr(expr: @ast::expr,
|
||||
if !ctx.generic_bare_fn_legal
|
||||
&& ty::expr_has_ty_params(ctx.tcx, expr) {
|
||||
alt ty::struct(ctx.tcx, ty::expr_ty(ctx.tcx, expr)) {
|
||||
ty::ty_fn({proto: ast::proto_bare., _}) {
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) {
|
||||
ctx.tcx.sess.span_fatal(
|
||||
expr.span,
|
||||
"generic bare functions can only be called or bound");
|
||||
|
@ -49,7 +49,7 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk)
|
||||
ast::expr_path(path) {
|
||||
let i = 0;
|
||||
alt def_map.find(expr.id) {
|
||||
none. { fail ("Not found: " + path_to_str(path)) }
|
||||
none { fail ("Not found: " + path_to_str(path)) }
|
||||
some(df) {
|
||||
let def = df;
|
||||
while i < depth {
|
||||
@ -104,7 +104,7 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) ->
|
||||
|
||||
fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
|
||||
alt tcx.freevars.find(fid) {
|
||||
none. { fail "get_freevars: " + int::str(fid) + " has no freevars"; }
|
||||
none { fail "get_freevars: " + int::str(fid) + " has no freevars"; }
|
||||
some(d) { ret d; }
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
|
||||
let llvalptr = bld::PointerCast(bcx, llval, T_ptr(T_ptr(T_i8())));
|
||||
|
||||
alt td_r.kind {
|
||||
tk_derived. {
|
||||
tk_derived {
|
||||
// It's a derived type descriptor. First, spill it.
|
||||
let lltydescptr = trans::alloca(bcx, val_ty(lltydesc));
|
||||
|
||||
@ -81,11 +81,11 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
|
||||
bld::Call(llderivedtydescs, gcroot, [lltydescptr, lldestindex]);
|
||||
bld::Call(bcx, gcroot, [llvalptr, llsrcindex]);
|
||||
}
|
||||
tk_param. {
|
||||
tk_param {
|
||||
bcx_tcx(cx).sess.bug("we should never be trying to root values " +
|
||||
"of a type parameter");
|
||||
}
|
||||
tk_static. {
|
||||
tk_static {
|
||||
// Static type descriptor.
|
||||
|
||||
let llstaticgcmeta =
|
||||
@ -103,9 +103,9 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
|
||||
|
||||
fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
|
||||
alt ty::struct(cx, ty) {
|
||||
ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int(_) |
|
||||
ty::ty_float(_) | ty::ty_uint(_) | ty::ty_str. |
|
||||
ty::ty_type. | ty::ty_native(_) | ty::ty_ptr(_) | ty::ty_type. |
|
||||
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
|
||||
ty::ty_float(_) | ty::ty_uint(_) | ty::ty_str |
|
||||
ty::ty_type | ty::ty_native(_) | ty::ty_ptr(_) | ty::ty_type. |
|
||||
ty::ty_native(_) {
|
||||
ret false;
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ import driver::session::session;
|
||||
|
||||
fn kind_to_str(k: kind) -> str {
|
||||
alt k {
|
||||
kind_sendable. { "sendable" }
|
||||
kind_copyable. { "copyable" }
|
||||
kind_noncopyable. { "noncopyable" }
|
||||
kind_sendable { "sendable" }
|
||||
kind_copyable { "copyable" }
|
||||
kind_noncopyable { "noncopyable" }
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,10 +61,10 @@ fn with_appropriate_checker(cx: ctx, id: node_id,
|
||||
b: block(fn@(ctx, ty::t, sp: span))) {
|
||||
let fty = ty::node_id_to_monotype(cx.tcx, id);
|
||||
alt ty::ty_fn_proto(cx.tcx, fty) {
|
||||
proto_uniq. { b(check_send); }
|
||||
proto_box. { b(check_copy); }
|
||||
proto_bare. { b(check_none); }
|
||||
proto_any. | proto_block. { /* no check needed */ }
|
||||
proto_uniq { b(check_send); }
|
||||
proto_box { b(check_copy); }
|
||||
proto_bare { b(check_none); }
|
||||
proto_any | proto_block { /* no check needed */ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
expr_ret(some(ex)) { maybe_copy(cx, ex); }
|
||||
expr_copy(expr) { check_copy_ex(cx, expr, false); }
|
||||
// Vector add copies.
|
||||
expr_binary(add., ls, rs) { maybe_copy(cx, ls); maybe_copy(cx, rs); }
|
||||
expr_binary(add, ls, rs) { maybe_copy(cx, ls); maybe_copy(cx, rs); }
|
||||
expr_rec(fields, def) {
|
||||
for field in fields { maybe_copy(cx, field.node.expr); }
|
||||
alt def {
|
||||
@ -163,7 +163,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
expr_call(f, args, _) {
|
||||
let i = 0u;
|
||||
for arg_t in ty::ty_fn_args(cx.tcx, ty::expr_ty(cx.tcx, f)) {
|
||||
alt arg_t.mode { by_copy. { maybe_copy(cx, args[i]); } _ {} }
|
||||
alt arg_t.mode { by_copy { maybe_copy(cx, args[i]); } _ {} }
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
@ -186,7 +186,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
none. {}
|
||||
none {}
|
||||
}
|
||||
}
|
||||
expr_ternary(_, a, b) { maybe_copy(cx, a); maybe_copy(cx, b); }
|
||||
@ -203,7 +203,7 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
|
||||
stmt_decl(@{node: decl_local(locals), _}, _) {
|
||||
for (_, local) in locals {
|
||||
alt local.node.init {
|
||||
some({op: init_assign., expr}) { maybe_copy(cx, expr); }
|
||||
some({op: init_assign, expr}) { maybe_copy(cx, expr); }
|
||||
_ {}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
visit::visit_expr_opt(oexpr, cx, v);
|
||||
leave_fn(cx);
|
||||
}
|
||||
expr_break. { add_block_exit(cx, loop); }
|
||||
expr_break { add_block_exit(cx, loop); }
|
||||
expr_while(_, _) | expr_do_while(_, _) {
|
||||
visit_block(loop, cx) {|| visit::visit_expr(ex, cx, v);}
|
||||
}
|
||||
@ -160,7 +160,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
}
|
||||
_ {
|
||||
alt arg_ts[i].mode {
|
||||
by_mut_ref. { clear_if_path(cx, arg, v, false); }
|
||||
by_mut_ref { clear_if_path(cx, arg, v, false); }
|
||||
_ { v.visit_expr(arg, cx, v); }
|
||||
}
|
||||
}
|
||||
@ -179,12 +179,12 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
||||
let fty = ty::node_id_to_type(cx.tcx, id);
|
||||
let proto = ty::ty_fn_proto(cx.tcx, fty);
|
||||
alt proto {
|
||||
proto_any. | proto_block. {
|
||||
proto_any | proto_block {
|
||||
visit_block(func, cx, {||
|
||||
visit::visit_fn(fk, decl, body, sp, id, cx, v);
|
||||
});
|
||||
}
|
||||
proto_box. | proto_uniq. | proto_bare. {
|
||||
proto_box | proto_uniq | proto_bare {
|
||||
alt cx.tcx.freevars.find(id) {
|
||||
some(vars) {
|
||||
for v in *vars {
|
||||
@ -283,8 +283,8 @@ fn clear_in_current(cx: ctx, my_def: node_id, to: bool) {
|
||||
fn clear_def_if_path(cx: ctx, d: def, to: bool)
|
||||
-> option<node_id> {
|
||||
alt d {
|
||||
def_local(def_id, let_copy.) | def_arg(def_id, by_copy.) |
|
||||
def_arg(def_id, by_move.) {
|
||||
def_local(def_id, let_copy) | def_arg(def_id, by_copy) |
|
||||
def_arg(def_id, by_move) {
|
||||
clear_in_current(cx, def_id.node, to);
|
||||
some(def_id.node)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ fn expr_root(tcx: ty::ctxt, ex: @expr, autoderef: bool) ->
|
||||
kind: index,
|
||||
outer_t: auto_unbox.t}];
|
||||
}
|
||||
ty::ty_str. {
|
||||
ty::ty_str {
|
||||
ds += [@{mut: false, kind: index, outer_t: auto_unbox.t}];
|
||||
}
|
||||
}
|
||||
@ -125,9 +125,9 @@ tag msg { msg_assign; msg_move_out; msg_mut_ref; }
|
||||
|
||||
fn mk_err(cx: @ctx, span: syntax::codemap::span, msg: msg, name: str) {
|
||||
cx.tcx.sess.span_err(span, alt msg {
|
||||
msg_assign. { "assigning to " + name }
|
||||
msg_move_out. { "moving out of " + name }
|
||||
msg_mut_ref. { "passing " + name + " by mutable reference" }
|
||||
msg_assign { "assigning to " + name }
|
||||
msg_move_out { "moving out of " + name }
|
||||
msg_mut_ref { "passing " + name + " by mutable reference" }
|
||||
});
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ fn visit_decl(cx: @ctx, d: @decl, &&e: (), v: visit::vt<()>) {
|
||||
some(init) {
|
||||
if init.op == init_move { check_move_rhs(cx, init.expr); }
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,8 +224,8 @@ fn check_call(cx: @ctx, f: @expr, args: [@expr]) {
|
||||
let i = 0u;
|
||||
for arg_t: ty::arg in arg_ts {
|
||||
alt arg_t.mode {
|
||||
by_mut_ref. { check_lval(cx, args[i], msg_mut_ref); }
|
||||
by_move. { check_lval(cx, args[i], msg_move_out); }
|
||||
by_mut_ref { check_lval(cx, args[i], msg_mut_ref); }
|
||||
by_move { check_lval(cx, args[i], msg_move_out); }
|
||||
_ {}
|
||||
}
|
||||
i += 1u;
|
||||
@ -239,15 +239,15 @@ fn check_bind(cx: @ctx, f: @expr, args: [option::t<@expr>]) {
|
||||
alt arg {
|
||||
some(expr) {
|
||||
alt (alt arg_ts[i].mode {
|
||||
by_mut_ref. { some("by mutable reference") }
|
||||
by_move. { some("by move") }
|
||||
by_mut_ref { some("by mutable reference") }
|
||||
by_move { some("by move") }
|
||||
_ { none }
|
||||
}) {
|
||||
some(name) {
|
||||
cx.tcx.sess.span_err(
|
||||
expr.span, "can not bind an argument passed " + name);
|
||||
}
|
||||
none. {}
|
||||
none {}
|
||||
}
|
||||
}
|
||||
_ {}
|
||||
@ -262,19 +262,19 @@ fn is_immutable_def(cx: @ctx, def: def) -> option::t<str> {
|
||||
def_use(_) {
|
||||
some("static item")
|
||||
}
|
||||
def_arg(_, by_ref.) | def_arg(_, by_val.) |
|
||||
def_arg(_, mode_infer.) { some("argument") }
|
||||
def_arg(_, by_ref) | def_arg(_, by_val) |
|
||||
def_arg(_, mode_infer) { some("argument") }
|
||||
def_self(_) { some("self argument") }
|
||||
def_upvar(_, inner, node_id) {
|
||||
let ty = ty::node_id_to_monotype(cx.tcx, node_id);
|
||||
let proto = ty::ty_fn_proto(cx.tcx, ty);
|
||||
ret alt proto {
|
||||
proto_any. | proto_block. { is_immutable_def(cx, *inner) }
|
||||
proto_any | proto_block { is_immutable_def(cx, *inner) }
|
||||
_ { some("upvar") }
|
||||
};
|
||||
}
|
||||
def_binding(_) { some("binding") }
|
||||
def_local(_, let_ref.) { some("by-reference binding") }
|
||||
def_local(_, let_ref) { some("by-reference binding") }
|
||||
_ { none }
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ fn normalize_pat_def_map(dm: resolve::def_map, p: @pat) -> @pat {
|
||||
// have to do it the hard way b/c ast fold doesn't pass around
|
||||
// node IDs. bother.
|
||||
alt p.node {
|
||||
pat_wild. { p }
|
||||
pat_ident(_, none.) { normalize_one(dm, p) }
|
||||
pat_wild { p }
|
||||
pat_ident(_, none) { normalize_one(dm, p) }
|
||||
pat_ident(q, some(r)) {
|
||||
@{node: pat_ident(q, some(normalize_pat_def_map(dm, r)))
|
||||
with *p}
|
||||
@ -58,7 +58,7 @@ fn normalize_one(dm: resolve::def_map, p: @pat) -> @pat {
|
||||
_ { p }
|
||||
}
|
||||
}
|
||||
none. { p }
|
||||
none { p }
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,14 +93,14 @@ fn pat_id_map(tcx: ty::ctxt, pat: @pat) -> pat_id_map {
|
||||
// Could return a constrained type in order to express that (future work)
|
||||
fn pat_bindings(pat: @pat, it: block(@pat)) {
|
||||
alt pat.node {
|
||||
pat_ident(_, option::none.) { it(pat); }
|
||||
pat_ident(_, option::none) { it(pat); }
|
||||
pat_ident(_, option::some(sub)) { it(pat); pat_bindings(sub, it); }
|
||||
pat_tag(_, sub) { for p in sub { pat_bindings(p, it); } }
|
||||
pat_rec(fields, _) { for f in fields { pat_bindings(f.pat, it); } }
|
||||
pat_tup(elts) { for elt in elts { pat_bindings(elt, it); } }
|
||||
pat_box(sub) { pat_bindings(sub, it); }
|
||||
pat_uniq(sub) { pat_bindings(sub, it); }
|
||||
pat_wild. | pat_lit(_) | pat_range(_, _) { }
|
||||
pat_wild | pat_lit(_) | pat_range(_, _) { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ fn pat_binding_ids(pat: @pat) -> [node_id] {
|
||||
|
||||
fn path_to_ident(p: @path) -> ident {
|
||||
alt vec::last(p.node.idents) {
|
||||
none. { // sigh
|
||||
none { // sigh
|
||||
fail "Malformed path"; }
|
||||
some(i) { ret i; }
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ fn new_ext_hash() -> ext_hash {
|
||||
ret str::hash(v.ident) + util::common::hash_def(v.did) +
|
||||
alt v.ns {
|
||||
ns_val(_) { 1u }
|
||||
ns_type. { 2u }
|
||||
ns_module. { 3u }
|
||||
ns_type { 2u }
|
||||
ns_module { 3u }
|
||||
};
|
||||
}
|
||||
fn eq(v1: key, v2: key) -> bool {
|
||||
@ -88,8 +88,8 @@ fn new_exp_hash() -> exp_map {
|
||||
ret str::hash(v.path) +
|
||||
alt v.ns {
|
||||
ns_val(_) { 1u }
|
||||
ns_type. { 2u }
|
||||
ns_module. { 3u }
|
||||
ns_type { 2u }
|
||||
ns_module { 3u }
|
||||
};
|
||||
}
|
||||
fn eq(v1: key, v2: key) -> bool {
|
||||
@ -286,11 +286,11 @@ fn map_crate(e: @env, c: @ast::crate) {
|
||||
}
|
||||
scope_block(b, _, _) {
|
||||
let globs = alt e.block_map.find(b.node.id) {
|
||||
some(globs) { globs + [glob] } none. { [glob] }
|
||||
some(globs) { globs + [glob] } none { [glob] }
|
||||
};
|
||||
e.block_map.insert(b.node.id, globs);
|
||||
}
|
||||
scope_crate. {
|
||||
scope_crate {
|
||||
e.mod_map.get(ast::crate_node_id).glob_imports += [glob];
|
||||
}
|
||||
}
|
||||
@ -422,7 +422,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
||||
}
|
||||
/* Here we determine whether a given pat_ident binds a new
|
||||
variable a refers to a nullary tag. */
|
||||
ast::pat_ident(p, none.) {
|
||||
ast::pat_ident(p, none) {
|
||||
let fnd = lookup_in_scope(*e, sc, p.span, path_to_ident(p),
|
||||
ns_val(ns_a_tag));
|
||||
alt fnd {
|
||||
@ -504,8 +504,8 @@ fn visit_fn_with_scope(e: @env, fk: visit::fn_kind, decl: ast::fn_decl,
|
||||
let scope = alt fk {
|
||||
visit::fk_item_fn(_, tps) | visit::fk_res(_, tps) |
|
||||
visit::fk_method(_, tps) { scope_bare_fn(decl, id, tps) }
|
||||
visit::fk_anon(ast::proto_bare.) { scope_bare_fn(decl, id, []) }
|
||||
visit::fk_anon(_) | visit::fk_fn_block. { scope_fn_expr(decl, id, []) }
|
||||
visit::fk_anon(ast::proto_bare) { scope_bare_fn(decl, id, []) }
|
||||
visit::fk_anon(_) | visit::fk_fn_block { scope_fn_expr(decl, id, []) }
|
||||
};
|
||||
|
||||
visit::visit_fn(fk, decl, body, sp, id, cons(scope, @sc), v);
|
||||
@ -557,7 +557,7 @@ fn visit_expr_with_scope(x: @ast::expr, sc: scopes, v: vt<scopes>) {
|
||||
}
|
||||
|
||||
// This is only for irrefutable patterns (e.g. ones that appear in a let)
|
||||
// So if x occurs, and x is already known to be a tag, that's always an error.
|
||||
// So if x occurs, and x is already known to be a tag, that's always an error
|
||||
fn visit_local_with_scope(e: @env, loc: @local, sc:scopes, v:vt<scopes>) {
|
||||
// Check whether the given local has the same name as a tag that's
|
||||
// in scope
|
||||
@ -616,7 +616,7 @@ fn resolve_constr(e: @env, c: @ast::constr, sc: scopes, _v: vt<scopes>) {
|
||||
ns_val(ns_any_value));
|
||||
if option::is_some(new_def) {
|
||||
alt option::get(new_def) {
|
||||
ast::def_fn(pred_id, ast::pure_fn.) {
|
||||
ast::def_fn(pred_id, ast::pure_fn) {
|
||||
e.def_map.insert(c.node.id, ast::def_fn(pred_id, ast::pure_fn));
|
||||
}
|
||||
_ {
|
||||
@ -675,7 +675,7 @@ fn resolve_import(e: env, defid: ast::def_id, name: ast::ident,
|
||||
cons(scope_block(b, _, _), _) {
|
||||
lst(id, b.node.view_items)
|
||||
}
|
||||
cons(scope_crate., _) {
|
||||
cons(scope_crate, _) {
|
||||
lst(id,
|
||||
option::get(e.mod_map.get(ast::crate_node_id).m).view_items)
|
||||
}
|
||||
@ -693,7 +693,7 @@ fn resolve_import(e: env, defid: ast::def_id, name: ast::ident,
|
||||
{|ns| lookup_in_scope(e, sc, sp, end_id, ns) }, []);
|
||||
} else {
|
||||
alt lookup_in_scope(e, sc, sp, ids[0], ns_module) {
|
||||
none. {
|
||||
none {
|
||||
unresolved_err(e, in_scope(sc), sp, ids[0], ns_name(ns_module));
|
||||
}
|
||||
some(dcur_) {
|
||||
@ -710,7 +710,7 @@ fn resolve_import(e: env, defid: ast::def_id, name: ast::ident,
|
||||
dcur = alt lookup_in_mod(e, dcur, sp, ids[i], ns_module,
|
||||
outside) {
|
||||
some(dcur) { dcur }
|
||||
none. {
|
||||
none {
|
||||
unresolved_err(e, in_mod(dcur), sp, ids[i],
|
||||
ns_name(ns_module));
|
||||
break;
|
||||
@ -738,14 +738,14 @@ fn resolve_import(e: env, defid: ast::def_id, name: ast::ident,
|
||||
// Utilities
|
||||
fn ns_name(ns: namespace) -> str {
|
||||
alt ns {
|
||||
ns_type. { "typename" }
|
||||
ns_type { "typename" }
|
||||
ns_val(v) {
|
||||
alt (v) {
|
||||
ns_any_value. { "name" }
|
||||
ns_a_tag. { "tag" }
|
||||
ns_any_value { "name" }
|
||||
ns_a_tag { "tag" }
|
||||
}
|
||||
}
|
||||
ns_module. { ret "modulename" }
|
||||
ns_module { ret "modulename" }
|
||||
}
|
||||
}
|
||||
|
||||
@ -758,7 +758,7 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
|
||||
alt sc {
|
||||
cons(cur, rest) {
|
||||
alt cur {
|
||||
scope_crate. | scope_bare_fn(_, _, _) |
|
||||
scope_crate | scope_bare_fn(_, _, _) |
|
||||
scope_fn_expr(_, _, _) |
|
||||
scope_item(@{node: ast::item_mod(_), _}) {
|
||||
ret some(cur);
|
||||
@ -835,7 +835,7 @@ fn lookup_path_strict(e: env, sc: scopes, sp: span, pth: ast::path_,
|
||||
fn lookup_in_scope_strict(e: env, sc: scopes, sp: span, name: ident,
|
||||
ns: namespace) -> option::t<def> {
|
||||
alt lookup_in_scope(e, sc, sp, name, ns) {
|
||||
none. {
|
||||
none {
|
||||
unresolved_err(e, in_scope(sc), sp, name, ns_name(ns));
|
||||
ret none;
|
||||
}
|
||||
@ -884,7 +884,7 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace)
|
||||
fn in_scope(e: env, sp: span, name: ident, s: scope, ns: namespace) ->
|
||||
option::t<def> {
|
||||
alt s {
|
||||
scope_crate. {
|
||||
scope_crate {
|
||||
ret lookup_in_local_mod(e, ast::crate_node_id, sp,
|
||||
name, ns, inside);
|
||||
}
|
||||
@ -953,7 +953,7 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace)
|
||||
let sc = sc;
|
||||
while true {
|
||||
alt copy sc {
|
||||
nil. { ret none::<def>; }
|
||||
nil { ret none::<def>; }
|
||||
cons(hd, tl) {
|
||||
let fnd = in_scope(e, sp, name, hd, ns);
|
||||
if !is_none(fnd) {
|
||||
@ -962,7 +962,7 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace)
|
||||
if left_fn && local || left_fn_level2 && self_scope
|
||||
|| scope_is_fn(hd) && left_fn && def_is_ty_arg(df) {
|
||||
let msg = alt ns {
|
||||
ns_type. {
|
||||
ns_type {
|
||||
"attempt to use a type argument out of scope"
|
||||
}
|
||||
ns_val(v) {
|
||||
@ -970,7 +970,7 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace)
|
||||
/* If we were looking for a tag, at this point
|
||||
we know it's bound to a non-tag value, and
|
||||
we can return none instead of failing */
|
||||
ns_a_tag. { ret none; }
|
||||
ns_a_tag { ret none; }
|
||||
_ { "attempted dynamic environment-capture" }
|
||||
}
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ fn lookup_in_ty_params(e: env, name: ident, ty_params: [ast::ty_param])
|
||||
let n = 0u;
|
||||
for tp: ast::ty_param in ty_params {
|
||||
if str::eq(tp.ident, name) && alt e.current_tp {
|
||||
some(cur) { n < cur } none. { true }
|
||||
some(cur) { n < cur } none { true }
|
||||
} { ret some(ast::def_ty_param(local_def(tp.id), n)); }
|
||||
n += 1u;
|
||||
}
|
||||
@ -1031,7 +1031,7 @@ fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl,
|
||||
ty_params: [ast::ty_param],
|
||||
ns: namespace) -> option::t<def> {
|
||||
alt ns {
|
||||
ns_val(ns_any_value.) {
|
||||
ns_val(ns_any_value) {
|
||||
for a: ast::arg in decl.inputs {
|
||||
if str::eq(a.ident, name) {
|
||||
ret some(ast::def_arg(local_def(a.id), a.mode));
|
||||
@ -1039,7 +1039,7 @@ fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl,
|
||||
}
|
||||
ret none::<def>;
|
||||
}
|
||||
ns_type. { ret lookup_in_ty_params(e, name, ty_params); }
|
||||
ns_type { ret lookup_in_ty_params(e, name, ty_params); }
|
||||
_ { ret none::<def>; }
|
||||
}
|
||||
}
|
||||
@ -1155,10 +1155,10 @@ fn found_def_item(i: @ast::item, ns: namespace) -> option::t<def> {
|
||||
}
|
||||
ast::item_res(_, _, _, _, ctor_id) {
|
||||
alt ns {
|
||||
ns_val(ns_any_value.) {
|
||||
ns_val(ns_any_value) {
|
||||
ret some(ast::def_fn(local_def(ctor_id), ast::impure_fn));
|
||||
}
|
||||
ns_type. { ret some(ast::def_ty(local_def(i.id))); }
|
||||
ns_type { ret some(ast::def_ty(local_def(i.id))); }
|
||||
_ { }
|
||||
}
|
||||
}
|
||||
@ -1170,7 +1170,7 @@ fn found_def_item(i: @ast::item, ns: namespace) -> option::t<def> {
|
||||
fn lookup_in_mod_strict(e: env, m: def, sp: span, name: ident,
|
||||
ns: namespace, dr: dir) -> option::t<def> {
|
||||
alt lookup_in_mod(e, m, sp, name, ns, dr) {
|
||||
none. {
|
||||
none {
|
||||
unresolved_err(e, in_mod(m), sp, name, ns_name(ns));
|
||||
ret none;
|
||||
}
|
||||
@ -1231,8 +1231,8 @@ fn lookup_import(e: env, defid: def_id, ns: namespace) -> option::t<def> {
|
||||
if e.used_imports.track {
|
||||
e.used_imports.data += [defid.node];
|
||||
}
|
||||
ret alt ns { ns_val(_) { val } ns_type. { typ }
|
||||
ns_module. { md } };
|
||||
ret alt ns { ns_val(_) { val } ns_type { typ }
|
||||
ns_module { md } };
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1254,12 +1254,12 @@ fn lookup_in_local_mod(e: env, node_id: node_id, sp: span, id: ident,
|
||||
ret none::<def>; // name is not visible
|
||||
}
|
||||
alt info.index.find(id) {
|
||||
none. { }
|
||||
none { }
|
||||
some(lst_) {
|
||||
let lst = lst_;
|
||||
while true {
|
||||
alt lst {
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
cons(hd, tl) {
|
||||
let found = lookup_in_mie(e, hd, ns);
|
||||
if !is_none(found) { ret found; }
|
||||
@ -1284,7 +1284,7 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
|
||||
}
|
||||
alt lookup_in_mod(e, def.def, sp, name, ns, dr) {
|
||||
some(d) { option::some({def: d, item: def.item}) }
|
||||
none. { none }
|
||||
none { none }
|
||||
}
|
||||
}
|
||||
let matches = vec::filter_map(copy globs,
|
||||
@ -1326,8 +1326,8 @@ fn lookup_glob_in_mod(e: env, info: @indexed_mod, sp: span, id: ident,
|
||||
glob_resolved(val, typ, md) {
|
||||
ret alt wanted_ns {
|
||||
ns_val(_) { val }
|
||||
ns_type. { typ }
|
||||
ns_module. { md }
|
||||
ns_type { typ }
|
||||
ns_module { md }
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1357,7 +1357,7 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
|
||||
}
|
||||
mie_native_item(native_item) {
|
||||
alt native_item.node {
|
||||
ast::native_item_ty. {
|
||||
ast::native_item_ty {
|
||||
if ns == ns_type {
|
||||
ret some(ast::def_native_ty(local_def(native_item.id)));
|
||||
}
|
||||
@ -1380,7 +1380,7 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
|
||||
fn add_to_index(index: hashmap<ident, list<mod_index_entry>>, id: ident,
|
||||
ent: mod_index_entry) {
|
||||
alt index.find(id) {
|
||||
none. { index.insert(id, cons(ent, @nil::<mod_index_entry>)); }
|
||||
none { index.insert(id, cons(ent, @nil::<mod_index_entry>)); }
|
||||
some(prev) { index.insert(id, cons(ent, @prev)); }
|
||||
}
|
||||
}
|
||||
@ -1471,7 +1471,7 @@ fn ns_for_def(d: def) -> namespace {
|
||||
// a tag
|
||||
fn ns_ok(wanted:namespace, actual:namespace) -> bool {
|
||||
alt actual {
|
||||
ns_val(ns_a_tag.) {
|
||||
ns_val(ns_a_tag) {
|
||||
alt wanted {
|
||||
ns_val(_) { true }
|
||||
_ { false }
|
||||
@ -1556,7 +1556,7 @@ fn check_mod_name(e: env, name: ident, entries: list<mod_index_entry>) {
|
||||
}
|
||||
entries = *rest;
|
||||
}
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1798,7 +1798,7 @@ fn check_exports(e: @env) {
|
||||
}
|
||||
}
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -1892,7 +1892,7 @@ fn find_impls_in_mod(e: env, m: def, &impls: [@_impl],
|
||||
let cached;
|
||||
alt e.impl_cache.find(defid) {
|
||||
some(v) { cached = v; }
|
||||
none. {
|
||||
none {
|
||||
cached = if defid.crate == ast::local_crate {
|
||||
let tmp = [];
|
||||
for i in option::get(e.mod_map.get(defid.node).m).items {
|
||||
|
@ -313,24 +313,24 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
|
||||
let s = [];
|
||||
|
||||
alt ty::struct(ccx.tcx, t) {
|
||||
ty::ty_nil. | ty::ty_bool. | ty::ty_uint(ast::ty_u8.) |
|
||||
ty::ty_bot. { s += [shape_u8]; }
|
||||
ty::ty_int(ast::ty_i.) { s += [s_int(ccx.tcx)]; }
|
||||
ty::ty_float(ast::ty_f.) { s += [s_float(ccx.tcx)]; }
|
||||
ty::ty_uint(ast::ty_u.) | ty::ty_ptr(_) |
|
||||
ty::ty_nil | ty::ty_bool | ty::ty_uint(ast::ty_u8) |
|
||||
ty::ty_bot { s += [shape_u8]; }
|
||||
ty::ty_int(ast::ty_i) { s += [s_int(ccx.tcx)]; }
|
||||
ty::ty_float(ast::ty_f) { s += [s_float(ccx.tcx)]; }
|
||||
ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) |
|
||||
ty::ty_native(_) { s += [s_uint(ccx.tcx)]; }
|
||||
ty::ty_type. { s += [s_tydesc(ccx.tcx)]; }
|
||||
ty::ty_send_type. { s += [s_send_tydesc(ccx.tcx)]; }
|
||||
ty::ty_int(ast::ty_i8.) { s += [shape_i8]; }
|
||||
ty::ty_uint(ast::ty_u16.) { s += [shape_u16]; }
|
||||
ty::ty_int(ast::ty_i16.) { s += [shape_i16]; }
|
||||
ty::ty_uint(ast::ty_u32.) { s += [shape_u32]; }
|
||||
ty::ty_int(ast::ty_i32.) | ty::ty_int(ast::ty_char.) {s += [shape_i32];}
|
||||
ty::ty_uint(ast::ty_u64.) { s += [shape_u64]; }
|
||||
ty::ty_int(ast::ty_i64.) { s += [shape_i64]; }
|
||||
ty::ty_float(ast::ty_f32.) { s += [shape_f32]; }
|
||||
ty::ty_float(ast::ty_f64.) { s += [shape_f64]; }
|
||||
ty::ty_str. {
|
||||
ty::ty_type { s += [s_tydesc(ccx.tcx)]; }
|
||||
ty::ty_send_type { s += [s_send_tydesc(ccx.tcx)]; }
|
||||
ty::ty_int(ast::ty_i8) { s += [shape_i8]; }
|
||||
ty::ty_uint(ast::ty_u16) { s += [shape_u16]; }
|
||||
ty::ty_int(ast::ty_i16) { s += [shape_i16]; }
|
||||
ty::ty_uint(ast::ty_u32) { s += [shape_u32]; }
|
||||
ty::ty_int(ast::ty_i32) | ty::ty_int(ast::ty_char) {s += [shape_i32];}
|
||||
ty::ty_uint(ast::ty_u64) { s += [shape_u64]; }
|
||||
ty::ty_int(ast::ty_i64) { s += [shape_i64]; }
|
||||
ty::ty_float(ast::ty_f32) { s += [shape_f32]; }
|
||||
ty::ty_float(ast::ty_f64) { s += [shape_f64]; }
|
||||
ty::ty_str {
|
||||
s += [shape_vec];
|
||||
add_bool(s, true); // type is POD
|
||||
let unit_ty = ty::mk_mach_uint(ccx.tcx, ast::ty_u8);
|
||||
@ -338,19 +338,19 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
|
||||
}
|
||||
ty::ty_tag(did, tps) {
|
||||
alt tag_kind(ccx, did) {
|
||||
tk_unit. {
|
||||
tk_unit {
|
||||
// FIXME: For now we do this.
|
||||
s += [s_variant_tag_t(ccx.tcx)];
|
||||
}
|
||||
tk_enum. { s += [s_variant_tag_t(ccx.tcx)]; }
|
||||
tk_complex. {
|
||||
tk_enum { s += [s_variant_tag_t(ccx.tcx)]; }
|
||||
tk_complex {
|
||||
s += [shape_tag];
|
||||
|
||||
let sub = [];
|
||||
|
||||
let id;
|
||||
alt ccx.shape_cx.tag_id_to_index.find(did) {
|
||||
none. {
|
||||
none {
|
||||
id = ccx.shape_cx.next_tag_id;
|
||||
ccx.shape_cx.tag_id_to_index.insert(did, id);
|
||||
ccx.shape_cx.tag_order += [did];
|
||||
@ -423,19 +423,19 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
|
||||
// Find the type parameter in the parameter list.
|
||||
alt vec::position(n, ty_param_map) {
|
||||
some(i) { s += [shape_var, i as u8]; }
|
||||
none. { fail "ty param not found in ty_param_map"; }
|
||||
none { fail "ty param not found in ty_param_map"; }
|
||||
}
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_box., _}) {
|
||||
ty::ty_fn({proto: ast::proto_box, _}) {
|
||||
s += [shape_box_fn];
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_uniq., _}) {
|
||||
ty::ty_fn({proto: ast::proto_uniq, _}) {
|
||||
s += [shape_uniq_fn];
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_block., _}) {
|
||||
ty::ty_fn({proto: ast::proto_block, _}) {
|
||||
s += [shape_stack_fn];
|
||||
}
|
||||
ty::ty_fn({proto: ast::proto_bare., _}) {
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) {
|
||||
s += [shape_bare_fn];
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(_) {
|
||||
|
@ -126,15 +126,15 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
|
||||
if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); }
|
||||
let llty = alt ty::struct(cx.tcx, t) {
|
||||
ty::ty_native(_) { T_ptr(T_i8()) }
|
||||
ty::ty_nil. { T_nil() }
|
||||
ty::ty_bot. {
|
||||
ty::ty_nil { T_nil() }
|
||||
ty::ty_bot {
|
||||
T_nil() /* ...I guess? */
|
||||
}
|
||||
ty::ty_bool. { T_bool() }
|
||||
ty::ty_bool { T_bool() }
|
||||
ty::ty_int(t) { T_int_ty(cx, t) }
|
||||
ty::ty_uint(t) { T_uint_ty(cx, t) }
|
||||
ty::ty_float(t) { T_float_ty(cx, t) }
|
||||
ty::ty_str. { T_ptr(T_vec(cx, T_i8())) }
|
||||
ty::ty_str { T_ptr(T_vec(cx, T_i8())) }
|
||||
ty::ty_tag(did, _) { type_of_tag(cx, sp, did, t) }
|
||||
ty::ty_box(mt) {
|
||||
let mt_ty = mt.ty;
|
||||
@ -188,7 +188,7 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
|
||||
std::util::unreachable()
|
||||
}
|
||||
ty::ty_param(_, _) { T_typaram(cx.tn) }
|
||||
ty::ty_send_type. | ty::ty_type. { T_ptr(cx.tydesc_type) }
|
||||
ty::ty_send_type | ty::ty_type { T_ptr(cx.tydesc_type) }
|
||||
ty::ty_tup(elts) {
|
||||
let tys = [];
|
||||
for elt in elts {
|
||||
@ -442,7 +442,7 @@ fn dynastack_alloca(cx: @block_ctxt, t: TypeRef, n: ValueRef, ty: ty::t) ->
|
||||
let bcx = cx;
|
||||
let dy_cx = new_raw_block_ctxt(cx.fcx, cx.fcx.lldynamicallocas);
|
||||
alt bcx_fcx(cx).llobstacktoken {
|
||||
none. {
|
||||
none {
|
||||
bcx_fcx(cx).llobstacktoken =
|
||||
some(mk_obstack_token(bcx_ccx(cx), cx.fcx));
|
||||
}
|
||||
@ -935,7 +935,7 @@ fn get_derived_tydesc(cx: @block_ctxt, t: ty::t, escapes: bool,
|
||||
ret rslt(cx, info.lltydesc);
|
||||
}
|
||||
}
|
||||
none. {/* fall through */ }
|
||||
none {/* fall through */ }
|
||||
}
|
||||
|
||||
bcx_ccx(cx).stats.n_derived_tydescs += 1u;
|
||||
@ -1015,7 +1015,7 @@ fn get_tydesc(cx: @block_ctxt, t: ty::t, escapes: bool,
|
||||
uint::str(id));
|
||||
}
|
||||
}
|
||||
none. {/* fall through */ }
|
||||
none {/* fall through */ }
|
||||
}
|
||||
|
||||
// Does it contain a type param? If so, generate a derived tydesc.
|
||||
@ -1033,7 +1033,7 @@ fn get_static_tydesc(cx: @block_ctxt, t: ty::t, ty_params: [uint])
|
||||
-> @tydesc_info {
|
||||
alt bcx_ccx(cx).tydescs.find(t) {
|
||||
some(info) { ret info; }
|
||||
none. {
|
||||
none {
|
||||
bcx_ccx(cx).stats.n_static_tydescs += 1u;
|
||||
let info = declare_tydesc(cx.fcx.lcx, cx.sp, t, ty_params);
|
||||
bcx_ccx(cx).tydescs.insert(t, info);
|
||||
@ -1199,22 +1199,22 @@ fn emit_tydescs(ccx: @crate_ctxt) {
|
||||
let ti = val;
|
||||
let take_glue =
|
||||
alt ti.take_glue {
|
||||
none. { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
|
||||
none { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
|
||||
some(v) { ccx.stats.n_real_glues += 1u; v }
|
||||
};
|
||||
let drop_glue =
|
||||
alt ti.drop_glue {
|
||||
none. { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
|
||||
none { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
|
||||
some(v) { ccx.stats.n_real_glues += 1u; v }
|
||||
};
|
||||
let free_glue =
|
||||
alt ti.free_glue {
|
||||
none. { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
|
||||
none { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) }
|
||||
some(v) { ccx.stats.n_real_glues += 1u; v }
|
||||
};
|
||||
let cmp_glue =
|
||||
alt ti.cmp_glue {
|
||||
none. { ccx.stats.n_null_glues += 1u; C_null(cmp_fn_ty) }
|
||||
none { ccx.stats.n_null_glues += 1u; C_null(cmp_fn_ty) }
|
||||
some(v) { ccx.stats.n_real_glues += 1u; v }
|
||||
};
|
||||
|
||||
@ -1264,12 +1264,12 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
|
||||
Store(r.bcx, r.val, v);
|
||||
r.bcx
|
||||
}
|
||||
ty::ty_vec(_) | ty::ty_str. {
|
||||
ty::ty_vec(_) | ty::ty_str {
|
||||
let r = tvec::duplicate(bcx, Load(bcx, v), t);
|
||||
Store(r.bcx, r.val, v);
|
||||
r.bcx
|
||||
}
|
||||
ty::ty_send_type. {
|
||||
ty::ty_send_type {
|
||||
// sendable type descriptors are basically unique pointers,
|
||||
// they must be cloned when copied:
|
||||
let r = Load(bcx, v);
|
||||
@ -1328,7 +1328,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
|
||||
let v = PointerCast(bcx, v, type_of_1(bcx, t));
|
||||
trans_uniq::make_free_glue(bcx, v, t)
|
||||
}
|
||||
ty::ty_vec(_) | ty::ty_str. {
|
||||
ty::ty_vec(_) | ty::ty_str {
|
||||
tvec::make_free_glue(bcx, PointerCast(bcx, v, type_of_1(bcx, t)), t)
|
||||
}
|
||||
ty::ty_iface(_, _) {
|
||||
@ -1345,7 +1345,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
|
||||
abi::tydesc_field_drop_glue, ti);
|
||||
trans_free_if_not_gc(bcx, b)
|
||||
}
|
||||
ty::ty_send_type. {
|
||||
ty::ty_send_type {
|
||||
// sendable type descriptors are basically unique pointers,
|
||||
// they must be freed.
|
||||
let ccx = bcx_ccx(bcx);
|
||||
@ -1372,7 +1372,7 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
|
||||
ty::ty_box(_) | ty::ty_iface(_, _) {
|
||||
decr_refcnt_maybe_free(bcx, Load(bcx, v0), t)
|
||||
}
|
||||
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str. | ty::ty_send_type. {
|
||||
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str | ty::ty_send_type {
|
||||
free_ty(bcx, Load(bcx, v0), t)
|
||||
}
|
||||
ty::ty_res(did, inner, tps) {
|
||||
@ -1478,12 +1478,12 @@ fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
|
||||
let f = bind compare_scalar_values(cx, lhs, rhs, _, op);
|
||||
|
||||
alt ty::struct(bcx_tcx(cx), t) {
|
||||
ty::ty_nil. { ret rslt(cx, f(nil_type)); }
|
||||
ty::ty_bool. | ty::ty_ptr(_) { ret rslt(cx, f(unsigned_int)); }
|
||||
ty::ty_nil { ret rslt(cx, f(nil_type)); }
|
||||
ty::ty_bool | ty::ty_ptr(_) { ret rslt(cx, f(unsigned_int)); }
|
||||
ty::ty_int(_) { ret rslt(cx, f(signed_int)); }
|
||||
ty::ty_uint(_) { ret rslt(cx, f(unsigned_int)); }
|
||||
ty::ty_float(_) { ret rslt(cx, f(floating_point)); }
|
||||
ty::ty_type. {
|
||||
ty::ty_type {
|
||||
ret rslt(trans_fail(cx, none,
|
||||
"attempt to compare values of type type"),
|
||||
C_nil());
|
||||
@ -1506,44 +1506,44 @@ fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
|
||||
fn compare_scalar_values(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
|
||||
nt: scalar_type, op: ast::binop) -> ValueRef {
|
||||
alt nt {
|
||||
nil_type. {
|
||||
nil_type {
|
||||
// We don't need to do actual comparisons for nil.
|
||||
// () == () holds but () < () does not.
|
||||
alt op {
|
||||
ast::eq. | ast::le. | ast::ge. { ret C_bool(true); }
|
||||
ast::ne. | ast::lt. | ast::gt. { ret C_bool(false); }
|
||||
ast::eq | ast::le | ast::ge { ret C_bool(true); }
|
||||
ast::ne | ast::lt | ast::gt { ret C_bool(false); }
|
||||
}
|
||||
}
|
||||
floating_point. {
|
||||
floating_point {
|
||||
let cmp = alt op {
|
||||
ast::eq. { lib::llvm::LLVMRealOEQ }
|
||||
ast::ne. { lib::llvm::LLVMRealUNE }
|
||||
ast::lt. { lib::llvm::LLVMRealOLT }
|
||||
ast::le. { lib::llvm::LLVMRealOLE }
|
||||
ast::gt. { lib::llvm::LLVMRealOGT }
|
||||
ast::ge. { lib::llvm::LLVMRealOGE }
|
||||
ast::eq { lib::llvm::LLVMRealOEQ }
|
||||
ast::ne { lib::llvm::LLVMRealUNE }
|
||||
ast::lt { lib::llvm::LLVMRealOLT }
|
||||
ast::le { lib::llvm::LLVMRealOLE }
|
||||
ast::gt { lib::llvm::LLVMRealOGT }
|
||||
ast::ge { lib::llvm::LLVMRealOGE }
|
||||
};
|
||||
ret FCmp(cx, cmp, lhs, rhs);
|
||||
}
|
||||
signed_int. {
|
||||
signed_int {
|
||||
let cmp = alt op {
|
||||
ast::eq. { lib::llvm::LLVMIntEQ }
|
||||
ast::ne. { lib::llvm::LLVMIntNE }
|
||||
ast::lt. { lib::llvm::LLVMIntSLT }
|
||||
ast::le. { lib::llvm::LLVMIntSLE }
|
||||
ast::gt. { lib::llvm::LLVMIntSGT }
|
||||
ast::ge. { lib::llvm::LLVMIntSGE }
|
||||
ast::eq { lib::llvm::LLVMIntEQ }
|
||||
ast::ne { lib::llvm::LLVMIntNE }
|
||||
ast::lt { lib::llvm::LLVMIntSLT }
|
||||
ast::le { lib::llvm::LLVMIntSLE }
|
||||
ast::gt { lib::llvm::LLVMIntSGT }
|
||||
ast::ge { lib::llvm::LLVMIntSGE }
|
||||
};
|
||||
ret ICmp(cx, cmp, lhs, rhs);
|
||||
}
|
||||
unsigned_int. {
|
||||
unsigned_int {
|
||||
let cmp = alt op {
|
||||
ast::eq. { lib::llvm::LLVMIntEQ }
|
||||
ast::ne. { lib::llvm::LLVMIntNE }
|
||||
ast::lt. { lib::llvm::LLVMIntULT }
|
||||
ast::le. { lib::llvm::LLVMIntULE }
|
||||
ast::gt. { lib::llvm::LLVMIntUGT }
|
||||
ast::ge. { lib::llvm::LLVMIntUGE }
|
||||
ast::eq { lib::llvm::LLVMIntEQ }
|
||||
ast::ne { lib::llvm::LLVMIntNE }
|
||||
ast::lt { lib::llvm::LLVMIntULT }
|
||||
ast::le { lib::llvm::LLVMIntULE }
|
||||
ast::gt { lib::llvm::LLVMIntUGT }
|
||||
ast::ge { lib::llvm::LLVMIntUGE }
|
||||
};
|
||||
ret ICmp(cx, cmp, lhs, rhs);
|
||||
}
|
||||
@ -1697,12 +1697,12 @@ fn lazily_emit_all_generic_info_tydesc_glues(cx: @block_ctxt,
|
||||
fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
|
||||
static_ti: option::t<@tydesc_info>) {
|
||||
alt static_ti {
|
||||
none. { }
|
||||
none { }
|
||||
some(ti) {
|
||||
if field == abi::tydesc_field_take_glue {
|
||||
alt ti.take_glue {
|
||||
some(_) { }
|
||||
none. {
|
||||
none {
|
||||
#debug("+++ lazily_emit_tydesc_glue TAKE %s",
|
||||
ty_to_str(bcx_tcx(cx), ti.ty));
|
||||
let lcx = cx.fcx.lcx;
|
||||
@ -1720,7 +1720,7 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
|
||||
} else if field == abi::tydesc_field_drop_glue {
|
||||
alt ti.drop_glue {
|
||||
some(_) { }
|
||||
none. {
|
||||
none {
|
||||
#debug("+++ lazily_emit_tydesc_glue DROP %s",
|
||||
ty_to_str(bcx_tcx(cx), ti.ty));
|
||||
let lcx = cx.fcx.lcx;
|
||||
@ -1738,7 +1738,7 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
|
||||
} else if field == abi::tydesc_field_free_glue {
|
||||
alt ti.free_glue {
|
||||
some(_) { }
|
||||
none. {
|
||||
none {
|
||||
#debug("+++ lazily_emit_tydesc_glue FREE %s",
|
||||
ty_to_str(bcx_tcx(cx), ti.ty));
|
||||
let lcx = cx.fcx.lcx;
|
||||
@ -1756,7 +1756,7 @@ fn lazily_emit_tydesc_glue(cx: @block_ctxt, field: int,
|
||||
} else if field == abi::tydesc_field_cmp_glue {
|
||||
alt ti.cmp_glue {
|
||||
some(_) { }
|
||||
none. {
|
||||
none {
|
||||
#debug("+++ lazily_emit_tydesc_glue CMP %s",
|
||||
ty_to_str(bcx_tcx(cx), ti.ty));
|
||||
ti.cmp_glue = some(bcx_ccx(cx).upcalls.cmp_type);
|
||||
@ -1775,7 +1775,7 @@ fn call_tydesc_glue_full(cx: @block_ctxt, v: ValueRef, tydesc: ValueRef,
|
||||
|
||||
let static_glue_fn = none;
|
||||
alt static_ti {
|
||||
none. {/* no-op */ }
|
||||
none {/* no-op */ }
|
||||
some(sti) {
|
||||
if field == abi::tydesc_field_take_glue {
|
||||
static_glue_fn = sti.take_glue;
|
||||
@ -1794,7 +1794,7 @@ fn call_tydesc_glue_full(cx: @block_ctxt, v: ValueRef, tydesc: ValueRef,
|
||||
|
||||
let llfn;
|
||||
alt static_glue_fn {
|
||||
none. {
|
||||
none {
|
||||
let llfnptr = GEPi(cx, tydesc, [0, field]);
|
||||
llfn = Load(cx, llfnptr);
|
||||
}
|
||||
@ -1840,7 +1840,7 @@ fn call_cmp_glue(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef, t: ty::t,
|
||||
|
||||
let llfn;
|
||||
alt ti {
|
||||
none. {
|
||||
none {
|
||||
let llfnptr =
|
||||
GEPi(bcx, lltydesc, [0, abi::tydesc_field_cmp_glue]);
|
||||
llfn = Load(bcx, llfnptr);
|
||||
@ -1870,7 +1870,7 @@ fn drop_ty(cx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
|
||||
|
||||
fn drop_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> @block_ctxt {
|
||||
alt ty::struct(bcx_tcx(bcx), t) {
|
||||
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str. { free_ty(bcx, v, t) }
|
||||
ty::ty_uniq(_) | ty::ty_vec(_) | ty::ty_str { free_ty(bcx, v, t) }
|
||||
ty::ty_box(_) | ty::ty_iface(_, _) { decr_refcnt_maybe_free(bcx, v, t) }
|
||||
}
|
||||
}
|
||||
@ -1884,7 +1884,7 @@ fn take_ty_immediate(bcx: @block_ctxt, v: ValueRef, t: ty::t) -> result {
|
||||
check trans_uniq::type_is_unique_box(bcx, t);
|
||||
trans_uniq::duplicate(bcx, v, t)
|
||||
}
|
||||
ty::ty_str. | ty::ty_vec(_) { tvec::duplicate(bcx, v, t) }
|
||||
ty::ty_str | ty::ty_vec(_) { tvec::duplicate(bcx, v, t) }
|
||||
_ { rslt(bcx, v) }
|
||||
}
|
||||
}
|
||||
@ -2046,7 +2046,7 @@ fn trans_crate_lit(cx: @crate_ctxt, lit: ast::lit) -> ValueRef {
|
||||
ast::lit_uint(u, t) { C_integral(T_uint_ty(cx, t), u, False) }
|
||||
ast::lit_float(fs, t) { C_floating(fs, T_float_ty(cx, t)) }
|
||||
ast::lit_bool(b) { C_bool(b) }
|
||||
ast::lit_nil. { C_nil() }
|
||||
ast::lit_nil { C_nil() }
|
||||
ast::lit_str(s) {
|
||||
cx.sess.span_unimpl(lit.span, "unique string in this context");
|
||||
}
|
||||
@ -2083,11 +2083,11 @@ fn trans_unary(bcx: @block_ctxt, op: ast::unop, e: @ast::expr,
|
||||
if dest == ignore { ret trans_expr(bcx, e, ignore); }
|
||||
let e_ty = ty::expr_ty(bcx_tcx(bcx), e);
|
||||
alt op {
|
||||
ast::not. {
|
||||
ast::not {
|
||||
let {bcx, val} = trans_temp_expr(bcx, e);
|
||||
ret store_in_dest(bcx, Not(bcx, val), dest);
|
||||
}
|
||||
ast::neg. {
|
||||
ast::neg {
|
||||
let {bcx, val} = trans_temp_expr(bcx, e);
|
||||
let neg = if ty::type_is_fp(bcx_tcx(bcx), e_ty) {
|
||||
FNeg(bcx, val)
|
||||
@ -2099,7 +2099,7 @@ fn trans_unary(bcx: @block_ctxt, op: ast::unop, e: @ast::expr,
|
||||
add_clean_free(bcx, box, false);
|
||||
// Cast the body type to the type of the value. This is needed to
|
||||
// make tags work, since tags have a different LLVM type depending
|
||||
// on whether they're boxed or not.
|
||||
// on whether they're boxed or not
|
||||
let ccx = bcx_ccx(bcx);
|
||||
if check type_has_static_size(ccx, e_ty) {
|
||||
let e_sp = e.span;
|
||||
@ -2113,7 +2113,7 @@ fn trans_unary(bcx: @block_ctxt, op: ast::unop, e: @ast::expr,
|
||||
ast::uniq(_) {
|
||||
ret trans_uniq::trans_uniq(bcx, e, id, dest);
|
||||
}
|
||||
ast::deref. {
|
||||
ast::deref {
|
||||
bcx_ccx(bcx).sess.bug("deref expressions should have been \
|
||||
translated using trans_lval(), not \
|
||||
trans_unary()");
|
||||
@ -2131,17 +2131,17 @@ fn trans_compare(cx: @block_ctxt, op: ast::binop, lhs: ValueRef,
|
||||
// Determine the operation we need.
|
||||
let llop;
|
||||
alt op {
|
||||
ast::eq. | ast::ne. { llop = C_u8(abi::cmp_glue_op_eq); }
|
||||
ast::lt. | ast::ge. { llop = C_u8(abi::cmp_glue_op_lt); }
|
||||
ast::le. | ast::gt. { llop = C_u8(abi::cmp_glue_op_le); }
|
||||
ast::eq | ast::ne { llop = C_u8(abi::cmp_glue_op_eq); }
|
||||
ast::lt | ast::ge { llop = C_u8(abi::cmp_glue_op_lt); }
|
||||
ast::le | ast::gt { llop = C_u8(abi::cmp_glue_op_le); }
|
||||
}
|
||||
|
||||
let rs = call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
|
||||
|
||||
// Invert the result if necessary.
|
||||
alt op {
|
||||
ast::eq. | ast::lt. | ast::le. { ret rslt(rs.bcx, rs.val); }
|
||||
ast::ne. | ast::ge. | ast::gt. {
|
||||
ast::eq | ast::lt | ast::le { ret rslt(rs.bcx, rs.val); }
|
||||
ast::ne | ast::ge | ast::gt {
|
||||
ret rslt(rs.bcx, Not(rs.bcx, rs.val));
|
||||
}
|
||||
}
|
||||
@ -2161,36 +2161,36 @@ fn trans_eager_binop(cx: @block_ctxt, op: ast::binop, lhs: ValueRef,
|
||||
ret tvec::trans_add(cx, intype, lhs, rhs, dest);
|
||||
}
|
||||
let cx = cx, val = alt op {
|
||||
ast::add. {
|
||||
ast::add {
|
||||
if is_float { FAdd(cx, lhs, rhs) }
|
||||
else { Add(cx, lhs, rhs) }
|
||||
}
|
||||
ast::subtract. {
|
||||
ast::subtract {
|
||||
if is_float { FSub(cx, lhs, rhs) }
|
||||
else { Sub(cx, lhs, rhs) }
|
||||
}
|
||||
ast::mul. {
|
||||
ast::mul {
|
||||
if is_float { FMul(cx, lhs, rhs) }
|
||||
else { Mul(cx, lhs, rhs) }
|
||||
}
|
||||
ast::div. {
|
||||
ast::div {
|
||||
if is_float { FDiv(cx, lhs, rhs) }
|
||||
else if ty::type_is_signed(bcx_tcx(cx), intype) {
|
||||
SDiv(cx, lhs, rhs)
|
||||
} else { UDiv(cx, lhs, rhs) }
|
||||
}
|
||||
ast::rem. {
|
||||
ast::rem {
|
||||
if is_float { FRem(cx, lhs, rhs) }
|
||||
else if ty::type_is_signed(bcx_tcx(cx), intype) {
|
||||
SRem(cx, lhs, rhs)
|
||||
} else { URem(cx, lhs, rhs) }
|
||||
}
|
||||
ast::bitor. { Or(cx, lhs, rhs) }
|
||||
ast::bitand. { And(cx, lhs, rhs) }
|
||||
ast::bitxor. { Xor(cx, lhs, rhs) }
|
||||
ast::lsl. { Shl(cx, lhs, rhs) }
|
||||
ast::lsr. { LShr(cx, lhs, rhs) }
|
||||
ast::asr. { AShr(cx, lhs, rhs) }
|
||||
ast::bitor { Or(cx, lhs, rhs) }
|
||||
ast::bitand { And(cx, lhs, rhs) }
|
||||
ast::bitxor { Xor(cx, lhs, rhs) }
|
||||
ast::lsl { Shl(cx, lhs, rhs) }
|
||||
ast::lsr { LShr(cx, lhs, rhs) }
|
||||
ast::asr { AShr(cx, lhs, rhs) }
|
||||
_ {
|
||||
let cmpr = trans_compare(cx, op, lhs, lhs_t, rhs, rhs_t);
|
||||
cx = cmpr.bcx;
|
||||
@ -2222,7 +2222,7 @@ fn trans_assign_op(bcx: @block_ctxt, op: ast::binop, dst: @ast::expr,
|
||||
let {bcx, val: rhs_val} = trans_temp_expr(lhs_res.bcx, src);
|
||||
if ty::type_is_sequence(tcx, t) {
|
||||
alt op {
|
||||
ast::add. {
|
||||
ast::add {
|
||||
ret tvec::trans_append(bcx, t, lhs_res.val, rhs_val);
|
||||
}
|
||||
_ { }
|
||||
@ -2283,7 +2283,7 @@ fn autoderef(cx: @block_ctxt, v: ValueRef, t: ty::t) -> result_t {
|
||||
|
||||
fn trans_lazy_binop(bcx: @block_ctxt, op: ast::binop, a: @ast::expr,
|
||||
b: @ast::expr, dest: dest) -> @block_ctxt {
|
||||
let is_and = alt op { ast::and. { true } ast::or. { false } };
|
||||
let is_and = alt op { ast::and { true } ast::or { false } };
|
||||
let lhs_res = trans_temp_expr(bcx, a);
|
||||
if lhs_res.bcx.unreachable { ret lhs_res.bcx; }
|
||||
let rhs_cx = new_scope_block_ctxt(lhs_res.bcx, "rhs");
|
||||
@ -2316,7 +2316,7 @@ fn trans_binary(cx: @block_ctxt, op: ast::binop, a: @ast::expr, b: @ast::expr,
|
||||
dest: dest) -> @block_ctxt {
|
||||
// First couple cases are lazy:
|
||||
alt op {
|
||||
ast::and. | ast::or. {
|
||||
ast::and | ast::or {
|
||||
ret trans_lazy_binop(cx, op, a, b, dest);
|
||||
}
|
||||
_ {
|
||||
@ -2381,7 +2381,7 @@ fn join_returns(parent_cx: @block_ctxt, in_cxs: [@block_ctxt],
|
||||
// Used to put an immediate value in a dest.
|
||||
fn store_in_dest(bcx: @block_ctxt, val: ValueRef, dest: dest) -> @block_ctxt {
|
||||
alt dest {
|
||||
ignore. {}
|
||||
ignore {}
|
||||
by_val(cell) { *cell = val; }
|
||||
save_in(addr) { Store(bcx, val, addr); }
|
||||
}
|
||||
@ -2578,7 +2578,7 @@ fn lval_static_fn(bcx: @block_ctxt, fn_id: ast::def_id, id: ast::node_id)
|
||||
fn lookup_discriminant(lcx: @local_ctxt, vid: ast::def_id) -> ValueRef {
|
||||
let ccx = lcx.ccx;
|
||||
alt ccx.discrims.find(vid) {
|
||||
none. {
|
||||
none {
|
||||
// It's an external discriminant that we haven't seen yet.
|
||||
assert (vid.crate != ast::local_crate);
|
||||
let sym = csearch::get_symbol(lcx.ccx.sess.cstore, vid);
|
||||
@ -2788,7 +2788,7 @@ fn trans_lval(cx: @block_ctxt, e: @ast::expr) -> lval_result {
|
||||
ast::expr_index(base, idx) {
|
||||
ret trans_index(cx, e.span, base, idx, e.id);
|
||||
}
|
||||
ast::expr_unary(ast::deref., base) {
|
||||
ast::expr_unary(ast::deref, base) {
|
||||
let ccx = bcx_ccx(cx);
|
||||
let sub = trans_temp_expr(cx, base);
|
||||
let t = ty::expr_ty(ccx.tcx, base);
|
||||
@ -2826,11 +2826,11 @@ fn trans_lval(cx: @block_ctxt, e: @ast::expr) -> lval_result {
|
||||
fn maybe_add_env(bcx: @block_ctxt, c: lval_maybe_callee)
|
||||
-> (lval_kind, ValueRef) {
|
||||
alt c.env {
|
||||
is_closure. { (c.kind, c.val) }
|
||||
is_closure { (c.kind, c.val) }
|
||||
self_env(_) | dict_env(_, _) {
|
||||
fail "Taking the value of a method does not work yet (issue #435)";
|
||||
}
|
||||
null_env. {
|
||||
null_env {
|
||||
let llfnty = llvm::LLVMGetElementType(val_ty(c.val));
|
||||
(temporary, create_real_fn_pair(bcx, llfnty, c.val,
|
||||
null_env_ptr(bcx)))
|
||||
@ -2849,7 +2849,7 @@ fn lval_maybe_callee_to_lval(c: lval_maybe_callee, ty: ty::t) -> lval_result {
|
||||
add_clean_temp(bcx, space.val, ty);
|
||||
ret {bcx: bcx, val: space.val, kind: temporary};
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
let (kind, val) = maybe_add_env(c.bcx, c);
|
||||
ret {bcx: c.bcx, val: val, kind: kind};
|
||||
}
|
||||
@ -2915,41 +2915,41 @@ fn trans_cast(cx: @block_ctxt, e: @ast::expr, id: ast::node_id,
|
||||
|
||||
let newval =
|
||||
alt {in: k_in, out: k_out} {
|
||||
{in: integral., out: integral.} {
|
||||
{in: integral, out: integral.} {
|
||||
int_cast(e_res.bcx, ll_t_out, ll_t_in, e_res.val, s_in)
|
||||
}
|
||||
{in: float., out: float.} {
|
||||
{in: float, out: float.} {
|
||||
float_cast(e_res.bcx, ll_t_out, ll_t_in, e_res.val)
|
||||
}
|
||||
{in: integral., out: float.} {
|
||||
{in: integral, out: float} {
|
||||
if s_in {
|
||||
SIToFP(e_res.bcx, e_res.val, ll_t_out)
|
||||
} else { UIToFP(e_res.bcx, e_res.val, ll_t_out) }
|
||||
}
|
||||
{in: float., out: integral.} {
|
||||
{in: float, out: integral} {
|
||||
if ty::type_is_signed(ccx.tcx, t_out) {
|
||||
FPToSI(e_res.bcx, e_res.val, ll_t_out)
|
||||
} else { FPToUI(e_res.bcx, e_res.val, ll_t_out) }
|
||||
}
|
||||
{in: integral., out: pointer.} {
|
||||
{in: integral, out: pointer} {
|
||||
IntToPtr(e_res.bcx, e_res.val, ll_t_out)
|
||||
}
|
||||
{in: pointer., out: integral.} {
|
||||
{in: pointer, out: integral} {
|
||||
PtrToInt(e_res.bcx, e_res.val, ll_t_out)
|
||||
}
|
||||
{in: pointer., out: pointer.} {
|
||||
{in: pointer, out: pointer.} {
|
||||
PointerCast(e_res.bcx, e_res.val, ll_t_out)
|
||||
}
|
||||
{in: tag_., out: integral.} | {in: tag_., out: float.} {
|
||||
{in: tag_, out: integral} | {in: tag_., out: float} {
|
||||
let cx = e_res.bcx;
|
||||
let lltagty = T_opaque_tag_ptr(ccx);
|
||||
let av_tag = PointerCast(cx, e_res.val, lltagty);
|
||||
let lldiscrim_a_ptr = GEPi(cx, av_tag, [0, 0]);
|
||||
let lldiscrim_a = Load(cx, lldiscrim_a_ptr);
|
||||
alt k_out {
|
||||
integral. {int_cast(e_res.bcx, ll_t_out,
|
||||
integral {int_cast(e_res.bcx, ll_t_out,
|
||||
val_ty(lldiscrim_a), lldiscrim_a, true)}
|
||||
float. {SIToFP(e_res.bcx, lldiscrim_a, ll_t_out)}
|
||||
float {SIToFP(e_res.bcx, lldiscrim_a, ll_t_out)}
|
||||
}
|
||||
}
|
||||
_ { ccx.sess.bug("Translating unsupported cast.") }
|
||||
@ -3081,7 +3081,7 @@ fn trans_args(cx: @block_ctxt, llenv: ValueRef,
|
||||
}
|
||||
// Arg 0: Output pointer.
|
||||
let llretslot = alt dest {
|
||||
ignore. {
|
||||
ignore {
|
||||
if ty::type_is_nil(tcx, retty) {
|
||||
llvm::LLVMGetUndef(T_ptr(T_nil()))
|
||||
} else {
|
||||
@ -3153,12 +3153,12 @@ fn trans_call(in_cx: @block_ctxt, f: @ast::expr,
|
||||
let faddr = f_res.val;
|
||||
let llenv, dict_param = none;
|
||||
alt f_res.env {
|
||||
null_env. {
|
||||
null_env {
|
||||
llenv = llvm::LLVMGetUndef(T_opaque_cbox_ptr(bcx_ccx(cx)));
|
||||
}
|
||||
self_env(e) { llenv = e; }
|
||||
dict_env(dict, e) { llenv = e; dict_param = some(dict); }
|
||||
is_closure. {
|
||||
is_closure {
|
||||
// It's a closure. Have to fetch the elements
|
||||
if f_res.kind == owned {
|
||||
faddr = load_if_immediate(bcx, faddr, fn_expr_ty);
|
||||
@ -3186,7 +3186,7 @@ fn trans_call(in_cx: @block_ctxt, f: @ast::expr,
|
||||
bcx = invoke_full(bcx, faddr, llargs, args_res.to_zero,
|
||||
args_res.to_revoke);
|
||||
alt dest {
|
||||
ignore. {
|
||||
ignore {
|
||||
if llvm::LLVMIsUndef(llretslot) != lib::llvm::True {
|
||||
bcx = drop_ty(bcx, llretslot, ret_ty);
|
||||
}
|
||||
@ -3271,7 +3271,7 @@ fn get_landing_pad(bcx: @block_ctxt,
|
||||
} else {
|
||||
scope_bcx = alt scope_bcx.parent {
|
||||
parent_some(b) { b }
|
||||
parent_none. {
|
||||
parent_none {
|
||||
ret scope_bcx;
|
||||
}
|
||||
};
|
||||
@ -3316,7 +3316,7 @@ fn trans_landing_pad(bcx: @block_ctxt,
|
||||
bcx = trans_block_cleanups(bcx, scope_cx);
|
||||
scope_cx = alt scope_cx.parent {
|
||||
parent_some(b) { b }
|
||||
parent_none. { break; }
|
||||
parent_none { break; }
|
||||
};
|
||||
}
|
||||
|
||||
@ -3330,7 +3330,7 @@ fn trans_tup(bcx: @block_ctxt, elts: [@ast::expr], id: ast::node_id,
|
||||
let t = node_id_type(bcx.fcx.lcx.ccx, id);
|
||||
let bcx = bcx;
|
||||
let addr = alt dest {
|
||||
ignore. {
|
||||
ignore {
|
||||
for ex in elts { bcx = trans_expr(bcx, ex, ignore); }
|
||||
ret bcx;
|
||||
}
|
||||
@ -3355,7 +3355,7 @@ fn trans_rec(bcx: @block_ctxt, fields: [ast::field],
|
||||
let t = node_id_type(bcx_ccx(bcx), id);
|
||||
let bcx = bcx;
|
||||
let addr = alt dest {
|
||||
ignore. {
|
||||
ignore {
|
||||
for fld in fields {
|
||||
bcx = trans_expr(bcx, fld.node.expr, ignore);
|
||||
}
|
||||
@ -3390,7 +3390,7 @@ fn trans_rec(bcx: @block_ctxt, fields: [ast::field],
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
none. {}
|
||||
none {}
|
||||
};
|
||||
|
||||
// Now revoke the cleanups as we pass responsibility for the data
|
||||
@ -3527,11 +3527,11 @@ fn trans_expr(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
||||
}
|
||||
|
||||
// These return nothing
|
||||
ast::expr_break. {
|
||||
ast::expr_break {
|
||||
assert dest == ignore;
|
||||
ret trans_break(e.span, bcx);
|
||||
}
|
||||
ast::expr_cont. {
|
||||
ast::expr_cont {
|
||||
assert dest == ignore;
|
||||
ret trans_cont(e.span, bcx);
|
||||
}
|
||||
@ -3657,7 +3657,7 @@ fn lval_to_dps(bcx: @block_ctxt, e: @ast::expr, dest: dest) -> @block_ctxt {
|
||||
save_in(loc) {
|
||||
bcx = store_temp_expr(bcx, INIT, loc, lv, ty, last_use);
|
||||
}
|
||||
ignore. {}
|
||||
ignore {}
|
||||
}
|
||||
ret bcx;
|
||||
}
|
||||
@ -3805,7 +3805,7 @@ fn trans_fail_value(bcx: @block_ctxt, sp_opt: option::t<span>,
|
||||
V_filename = C_cstr(bcx_ccx(bcx), loc.filename);
|
||||
V_line = loc.line as int;
|
||||
}
|
||||
none. { V_filename = C_cstr(bcx_ccx(bcx), "<runtime>"); V_line = 0; }
|
||||
none { V_filename = C_cstr(bcx_ccx(bcx), "<runtime>"); V_line = 0; }
|
||||
}
|
||||
let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8()));
|
||||
V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8()));
|
||||
@ -3837,7 +3837,7 @@ fn trans_break_cont(sp: span, bcx: @block_ctxt, to_end: bool)
|
||||
_ {
|
||||
alt cleanup_cx.parent {
|
||||
parent_some(cx) { cleanup_cx = cx; }
|
||||
parent_none. {
|
||||
parent_none {
|
||||
bcx_ccx(bcx).sess.span_fatal
|
||||
(sp, if to_end { "Break" } else { "Cont" } +
|
||||
" outside a loop");
|
||||
@ -3871,7 +3871,7 @@ fn trans_ret(bcx: @block_ctxt, e: option::t<@ast::expr>) -> @block_ctxt {
|
||||
bcx = trans_block_cleanups(bcx, cleanup_cx);
|
||||
alt cleanup_cx.parent {
|
||||
parent_some(b) { cleanup_cx = b; }
|
||||
parent_none. { more_cleanups = false; }
|
||||
parent_none { more_cleanups = false; }
|
||||
}
|
||||
}
|
||||
build_return(bcx);
|
||||
@ -3894,7 +3894,7 @@ fn init_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
||||
let llptr = alt bcx.fcx.lllocals.find(local.node.id) {
|
||||
some(local_mem(v)) { v }
|
||||
// This is a local that is kept immediate
|
||||
none. {
|
||||
none {
|
||||
let initexpr = alt local.node.init { some({expr, _}) { expr } };
|
||||
let {bcx, val, kind} = trans_temp_lval(bcx, initexpr);
|
||||
if kind != temporary {
|
||||
@ -3929,8 +3929,8 @@ fn init_ref_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
||||
let init_expr = option::get(local.node.init).expr;
|
||||
let {bcx, val, kind} = trans_lval(bcx, init_expr);
|
||||
alt kind {
|
||||
owned_imm. { val = do_spill_noroot(bcx, val); }
|
||||
owned. {}
|
||||
owned_imm { val = do_spill_noroot(bcx, val); }
|
||||
owned {}
|
||||
}
|
||||
ret trans_alt::bind_irrefutable_pat(bcx, local.node.pat, val, false);
|
||||
}
|
||||
@ -4096,7 +4096,7 @@ fn trans_fn_cleanups(fcx: @fn_ctxt, cx: @block_ctxt) {
|
||||
let lltoken = lltoken_; // satisfy alias checker
|
||||
Call(cx, fcx_ccx(fcx).upcalls.dynastack_free, [lltoken]);
|
||||
}
|
||||
none. {/* nothing to do */ }
|
||||
none {/* nothing to do */ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -4181,7 +4181,7 @@ fn alloc_local(cx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
||||
let t = node_id_type(bcx_ccx(cx), local.node.id);
|
||||
let p = normalize_pat(bcx_tcx(cx), local.node.pat);
|
||||
let is_simple = alt p.node {
|
||||
ast::pat_ident(_, none.) { true } _ { false }
|
||||
ast::pat_ident(_, none) { true } _ { false }
|
||||
};
|
||||
// Do not allocate space for locals that can be kept immediate.
|
||||
let ccx = bcx_ccx(cx);
|
||||
@ -4189,13 +4189,13 @@ fn alloc_local(cx: @block_ctxt, local: @ast::local) -> @block_ctxt {
|
||||
!ccx.last_uses.contains_key(local.node.pat.id) &&
|
||||
ty::type_is_immediate(ccx.tcx, t) {
|
||||
alt local.node.init {
|
||||
some({op: ast::init_assign., _}) { ret cx; }
|
||||
some({op: ast::init_assign, _}) { ret cx; }
|
||||
_ {}
|
||||
}
|
||||
}
|
||||
let r = alloc_ty(cx, t);
|
||||
alt p.node {
|
||||
ast::pat_ident(pth, none.) {
|
||||
ast::pat_ident(pth, none) {
|
||||
if bcx_ccx(cx).sess.opts.debuginfo {
|
||||
let _: () = str::as_buf(path_to_ident(pth), {|buf|
|
||||
llvm::LLVMSetValueName(r.val, buf)
|
||||
@ -4326,7 +4326,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
|
||||
impl_self(tt) {
|
||||
cx.llself = some({v: cx.llenv, t: tt});
|
||||
}
|
||||
no_self. {}
|
||||
no_self {}
|
||||
}
|
||||
for tp in ty_params {
|
||||
let lltydesc = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
|
||||
@ -4338,7 +4338,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
|
||||
let dict = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
|
||||
arg_n += 1u;
|
||||
dicts = some(alt dicts {
|
||||
none. { [dict] }
|
||||
none { [dict] }
|
||||
some(ds) { ds + [dict] }
|
||||
});
|
||||
}
|
||||
@ -4368,9 +4368,9 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: @block_ctxt, args: [ast::arg],
|
||||
let id = args[arg_n].id;
|
||||
let argval = alt fcx.llargs.get(id) { local_mem(v) { v } };
|
||||
alt arg.mode {
|
||||
ast::by_mut_ref. { }
|
||||
ast::by_move. | ast::by_copy. { add_clean(bcx, argval, arg.ty); }
|
||||
ast::by_val. {
|
||||
ast::by_mut_ref { }
|
||||
ast::by_move | ast::by_copy { add_clean(bcx, argval, arg.ty); }
|
||||
ast::by_val {
|
||||
if !ty::type_is_immediate(bcx_tcx(bcx), arg.ty) {
|
||||
let {bcx: cx, val: alloc} = alloc_ty(bcx, arg.ty);
|
||||
bcx = cx;
|
||||
@ -4380,7 +4380,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: @block_ctxt, args: [ast::arg],
|
||||
fcx.llargs.insert(id, local_imm(argval));
|
||||
}
|
||||
}
|
||||
ast::by_ref. {}
|
||||
ast::by_ref {}
|
||||
}
|
||||
if fcx_ccx(fcx).sess.opts.extra_debuginfo {
|
||||
debuginfo::create_arg(bcx, args[arg_n]);
|
||||
@ -4607,42 +4607,42 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
||||
let is_float = ty::type_is_fp(ccx_tcx(cx), ty);
|
||||
let signed = ty::type_is_signed(ccx_tcx(cx), ty);
|
||||
ret alt b {
|
||||
ast::add. {
|
||||
ast::add {
|
||||
if is_float { llvm::LLVMConstFAdd(te1, te2) }
|
||||
else { llvm::LLVMConstAdd(te1, te2) }
|
||||
}
|
||||
ast::subtract. {
|
||||
ast::subtract {
|
||||
if is_float { llvm::LLVMConstFSub(te1, te2) }
|
||||
else { llvm::LLVMConstSub(te1, te2) }
|
||||
}
|
||||
ast::mul. {
|
||||
ast::mul {
|
||||
if is_float { llvm::LLVMConstFMul(te1, te2) }
|
||||
else { llvm::LLVMConstMul(te1, te2) }
|
||||
}
|
||||
ast::div. {
|
||||
ast::div {
|
||||
if is_float { llvm::LLVMConstFDiv(te1, te2) }
|
||||
else if signed { llvm::LLVMConstSDiv(te1, te2) }
|
||||
else { llvm::LLVMConstUDiv(te1, te2) }
|
||||
}
|
||||
ast::rem. {
|
||||
ast::rem {
|
||||
if is_float { llvm::LLVMConstFRem(te1, te2) }
|
||||
else if signed { llvm::LLVMConstSRem(te1, te2) }
|
||||
else { llvm::LLVMConstURem(te1, te2) }
|
||||
}
|
||||
ast::and. |
|
||||
ast::or. { cx.sess.span_unimpl(e.span, "binop logic"); }
|
||||
ast::bitxor. { llvm::LLVMConstXor(te1, te2) }
|
||||
ast::bitand. { llvm::LLVMConstAnd(te1, te2) }
|
||||
ast::bitor. { llvm::LLVMConstOr(te1, te2) }
|
||||
ast::lsl. { llvm::LLVMConstShl(te1, te2) }
|
||||
ast::lsr. { llvm::LLVMConstLShr(te1, te2) }
|
||||
ast::asr. { llvm::LLVMConstAShr(te1, te2) }
|
||||
ast::eq. |
|
||||
ast::lt. |
|
||||
ast::le. |
|
||||
ast::ne. |
|
||||
ast::ge. |
|
||||
ast::gt. { cx.sess.span_unimpl(e.span, "binop comparator"); }
|
||||
ast::and |
|
||||
ast::or { cx.sess.span_unimpl(e.span, "binop logic"); }
|
||||
ast::bitxor { llvm::LLVMConstXor(te1, te2) }
|
||||
ast::bitand { llvm::LLVMConstAnd(te1, te2) }
|
||||
ast::bitor { llvm::LLVMConstOr(te1, te2) }
|
||||
ast::lsl { llvm::LLVMConstShl(te1, te2) }
|
||||
ast::lsr { llvm::LLVMConstLShr(te1, te2) }
|
||||
ast::asr { llvm::LLVMConstAShr(te1, te2) }
|
||||
ast::eq |
|
||||
ast::lt |
|
||||
ast::le |
|
||||
ast::ne |
|
||||
ast::ge |
|
||||
ast::gt { cx.sess.span_unimpl(e.span, "binop comparator"); }
|
||||
}
|
||||
}
|
||||
ast::expr_unary(u, e) {
|
||||
@ -4652,10 +4652,10 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
||||
ret alt u {
|
||||
ast::box(_) |
|
||||
ast::uniq(_) |
|
||||
ast::deref. { cx.sess.span_bug(e.span,
|
||||
ast::deref { cx.sess.span_bug(e.span,
|
||||
"bad unop type in trans_const_expr"); }
|
||||
ast::not. { llvm::LLVMConstNot(te) }
|
||||
ast::neg. {
|
||||
ast::not { llvm::LLVMConstNot(te) }
|
||||
ast::neg {
|
||||
if is_float { llvm::LLVMConstFNeg(te) }
|
||||
else { llvm::LLVMConstNeg(te) }
|
||||
}
|
||||
@ -4848,7 +4848,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
|
||||
|
||||
for native_item in native_mod.items {
|
||||
alt native_item.node {
|
||||
ast::native_item_ty. {}
|
||||
ast::native_item_ty {}
|
||||
ast::native_item_fn(fn_decl, tps) {
|
||||
let span = native_item.span;
|
||||
let id = native_item.id;
|
||||
@ -4860,7 +4860,7 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
|
||||
vec::len(tps), llshimfn, llwrapfn);
|
||||
}
|
||||
|
||||
none. {
|
||||
none {
|
||||
ccx.sess.span_fatal(
|
||||
native_item.span,
|
||||
"unbound function item in trans_native_mod");
|
||||
@ -4933,7 +4933,7 @@ fn trans_item(cx: @local_ctxt, item: ast::item) {
|
||||
}
|
||||
}
|
||||
|
||||
// Translate a module. Doing this amounts to translating the items in the
|
||||
// Translate a module. Doing this amounts to translating the items in the
|
||||
// module; there ends up being no artifact (aside from linkage names) of
|
||||
// separate modules in the compiled program. That's because modules exist
|
||||
// only as a convenience for humans working with the code, to organize names
|
||||
@ -5084,7 +5084,7 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint {
|
||||
let native_item =
|
||||
alt cx.ast_map.find(id) { some(ast_map::node_native_item(i)) { i } };
|
||||
alt native_item.node {
|
||||
ast::native_item_ty. {
|
||||
ast::native_item_ty {
|
||||
cx.sess.bug("register_native_fn(): native fn isn't \
|
||||
actually a fn");
|
||||
}
|
||||
@ -5113,7 +5113,7 @@ fn raw_native_fn_type(ccx: @crate_ctxt, sp: span, args: [ty::arg],
|
||||
|
||||
fn link_name(i: @ast::native_item) -> str {
|
||||
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
|
||||
none. { ret i.ident; }
|
||||
none { ret i.ident; }
|
||||
option::some(ln) { ret ln; }
|
||||
}
|
||||
}
|
||||
@ -5130,7 +5130,7 @@ fn collect_native_item(ccx: @crate_ctxt,
|
||||
let node_type = node_id_type(ccx, id);
|
||||
let fn_abi =
|
||||
alt attr::get_meta_item_value_str_by_name(i.attrs, "abi") {
|
||||
option::none. {
|
||||
option::none {
|
||||
// if abi isn't specified for this function, inherit from
|
||||
// its enclosing native module
|
||||
option::get(*abi)
|
||||
|
@ -129,7 +129,7 @@ fn enter_match(m: match, col: uint, val: ValueRef, e: enter_pat) -> match {
|
||||
vec::slice(br.pats, col + 1u, vec::len(br.pats));
|
||||
let new_br = @{pats: pats,
|
||||
bound: alt br.pats[col].node {
|
||||
ast::pat_ident(name, none.) {
|
||||
ast::pat_ident(name, none) {
|
||||
br.bound + [{ident: path_to_ident(name),
|
||||
val: val}]
|
||||
}
|
||||
@ -137,7 +137,7 @@ fn enter_match(m: match, col: uint, val: ValueRef, e: enter_pat) -> match {
|
||||
} with *br};
|
||||
result += [new_br];
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
ret result;
|
||||
@ -146,8 +146,8 @@ fn enter_match(m: match, col: uint, val: ValueRef, e: enter_pat) -> match {
|
||||
fn enter_default(m: match, col: uint, val: ValueRef) -> match {
|
||||
fn matches_always(p: @ast::pat) -> bool {
|
||||
alt p.node {
|
||||
ast::pat_wild. | ast::pat_rec(_, _) |
|
||||
ast::pat_ident(_, none.) | ast::pat_tup(_) { true }
|
||||
ast::pat_wild | ast::pat_rec(_, _) |
|
||||
ast::pat_ident(_, none) | ast::pat_tup(_) { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
@ -508,7 +508,7 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
||||
}
|
||||
let else_cx =
|
||||
alt kind {
|
||||
no_branch. | single. { bcx }
|
||||
no_branch | single { bcx }
|
||||
_ { new_sub_block_ctxt(bcx, "match_else") }
|
||||
};
|
||||
let sw;
|
||||
@ -525,8 +525,8 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
||||
for opt: opt in opts {
|
||||
let opt_cx = new_sub_block_ctxt(bcx, "match_case");
|
||||
alt kind {
|
||||
single. { Br(bcx, opt_cx.llbb); }
|
||||
switch. {
|
||||
single { Br(bcx, opt_cx.llbb); }
|
||||
switch {
|
||||
let res = trans_opt(bcx, opt);
|
||||
alt res {
|
||||
single_result(r) {
|
||||
@ -535,7 +535,7 @@ fn compile_submatch(bcx: @block_ctxt, m: match, vals: [ValueRef], f: mk_fail,
|
||||
}
|
||||
}
|
||||
}
|
||||
compare. {
|
||||
compare {
|
||||
let compare_cx = new_scope_block_ctxt(bcx, "compare_scope");
|
||||
Br(bcx, compare_cx.llbb);
|
||||
bcx = compare_cx;
|
||||
@ -603,7 +603,7 @@ fn make_phi_bindings(bcx: @block_ctxt, map: [exit_node],
|
||||
if ex.to as uint == our_block {
|
||||
alt assoc(name, ex.bound) {
|
||||
some(val) { llbbs += [ex.from]; vals += [val]; }
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -767,7 +767,7 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef,
|
||||
let val = Load(bcx, val);
|
||||
bcx = bind_irrefutable_pat(bcx, inner, val, true);
|
||||
}
|
||||
ast::pat_wild. | ast::pat_lit(_) | ast::pat_range(_, _) { }
|
||||
ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) { }
|
||||
}
|
||||
ret bcx;
|
||||
}
|
||||
|
@ -137,8 +137,8 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
|
||||
|
||||
fn mk_tydesc_ty(tcx: ty::ctxt, ck: ty::closure_kind) -> ty::t {
|
||||
ret alt ck {
|
||||
ty::ck_block. | ty::ck_box. { ty::mk_type(tcx) }
|
||||
ty::ck_uniq. { ty::mk_send_type(tcx) }
|
||||
ty::ck_block | ty::ck_box { ty::mk_type(tcx) }
|
||||
ty::ck_uniq { ty::mk_send_type(tcx) }
|
||||
};
|
||||
}
|
||||
|
||||
@ -237,15 +237,15 @@ fn allocate_cbox(bcx: @block_ctxt,
|
||||
// Allocate the box:
|
||||
let temp_cleanups = [];
|
||||
let (bcx, box, rc) = alt ck {
|
||||
ty::ck_box. {
|
||||
ty::ck_box {
|
||||
let (bcx, box) = alloc_in_heap(bcx, false, temp_cleanups);
|
||||
(bcx, box, 1)
|
||||
}
|
||||
ty::ck_uniq. {
|
||||
ty::ck_uniq {
|
||||
let (bcx, box) = alloc_in_heap(bcx, true, temp_cleanups);
|
||||
(bcx, box, 0x12345678) // use arbitrary value for debugging
|
||||
}
|
||||
ty::ck_block. {
|
||||
ty::ck_block {
|
||||
let {bcx, val: box} = trans::alloc_ty(bcx, cbox_ty);
|
||||
(bcx, box, 0x12345678) // use arbitrary value for debugging
|
||||
}
|
||||
@ -289,10 +289,10 @@ fn store_environment(
|
||||
ck: ty::closure_kind,
|
||||
td: ValueRef) -> ValueRef {
|
||||
ret alt ck {
|
||||
ty::ck_block. | ty::ck_box. {
|
||||
ty::ck_block | ty::ck_box {
|
||||
td
|
||||
}
|
||||
ty::ck_uniq. {
|
||||
ty::ck_uniq {
|
||||
Call(bcx, bcx_ccx(bcx).upcalls.create_shared_type_desc, [td])
|
||||
}
|
||||
};
|
||||
@ -311,7 +311,7 @@ fn store_environment(
|
||||
|
||||
// store data tydesc.
|
||||
alt ck {
|
||||
ty::ck_box. | ty::ck_uniq. {
|
||||
ty::ck_box | ty::ck_uniq {
|
||||
let bound_tydesc = GEPi(bcx, llbox, [0, abi::cbox_elt_tydesc]);
|
||||
let ti = none;
|
||||
|
||||
@ -324,7 +324,7 @@ fn store_environment(
|
||||
let td = maybe_clone_tydesc(bcx, ck, closure_td.val);
|
||||
Store(bcx, td, bound_tydesc);
|
||||
}
|
||||
ty::ck_block. { /* skip this for blocks, not really relevant */ }
|
||||
ty::ck_block { /* skip this for blocks, not really relevant */ }
|
||||
}
|
||||
|
||||
// cbox_ty has the form of a tuple: (a, b, c) we want a ptr to a
|
||||
@ -371,28 +371,28 @@ fn store_environment(
|
||||
add_clean_temp_mem(bcx, bound_data, bound_tys[i]);
|
||||
temp_cleanups += [bound_data];
|
||||
}
|
||||
env_copy(val, ty, owned.) {
|
||||
env_copy(val, ty, owned) {
|
||||
let val1 = load_if_immediate(bcx, val, ty);
|
||||
bcx = trans::copy_val(bcx, INIT, bound_data, val1, ty);
|
||||
}
|
||||
env_copy(val, ty, owned_imm.) {
|
||||
env_copy(val, ty, owned_imm) {
|
||||
bcx = trans::copy_val(bcx, INIT, bound_data, val, ty);
|
||||
}
|
||||
env_copy(_, _, temporary.) {
|
||||
env_copy(_, _, temporary) {
|
||||
fail "Cannot capture temporary upvar";
|
||||
}
|
||||
env_move(val, ty, kind) {
|
||||
let src = {bcx:bcx, val:val, kind:kind};
|
||||
bcx = move_val(bcx, INIT, bound_data, src, ty);
|
||||
}
|
||||
env_ref(val, ty, owned.) {
|
||||
env_ref(val, ty, owned) {
|
||||
Store(bcx, val, bound_data);
|
||||
}
|
||||
env_ref(val, ty, owned_imm.) {
|
||||
env_ref(val, ty, owned_imm) {
|
||||
let addr = do_spill_noroot(bcx, val);
|
||||
Store(bcx, addr, bound_data);
|
||||
}
|
||||
env_ref(_, _, temporary.) {
|
||||
env_ref(_, _, temporary) {
|
||||
fail "Cannot capture temporary upvar";
|
||||
}
|
||||
}
|
||||
@ -489,8 +489,8 @@ fn load_environment(enclosing_cx: @block_ctxt,
|
||||
bcx = upvarptr.bcx;
|
||||
let llupvarptr = upvarptr.val;
|
||||
alt ck {
|
||||
ty::ck_block. { llupvarptr = Load(bcx, llupvarptr); }
|
||||
ty::ck_uniq. | ty::ck_box. { }
|
||||
ty::ck_block { llupvarptr = Load(bcx, llupvarptr); }
|
||||
ty::ck_uniq | ty::ck_box { }
|
||||
}
|
||||
let def_id = ast_util::def_id_of_def(cap_var.def);
|
||||
fcx.llupvars.insert(def_id.node, llupvarptr);
|
||||
@ -528,11 +528,11 @@ fn trans_expr_fn(bcx: @block_ctxt,
|
||||
};
|
||||
|
||||
let closure = alt proto {
|
||||
ast::proto_any. { fail "proto_any cannot appear in an expr"; }
|
||||
ast::proto_block. { trans_closure_env(ty::ck_block) }
|
||||
ast::proto_box. { trans_closure_env(ty::ck_box) }
|
||||
ast::proto_uniq. { trans_closure_env(ty::ck_uniq) }
|
||||
ast::proto_bare. {
|
||||
ast::proto_any { fail "proto_any cannot appear in an expr"; }
|
||||
ast::proto_block { trans_closure_env(ty::ck_block) }
|
||||
ast::proto_box { trans_closure_env(ty::ck_box) }
|
||||
ast::proto_uniq { trans_closure_env(ty::ck_uniq) }
|
||||
ast::proto_bare {
|
||||
let closure = C_null(T_opaque_cbox_ptr(ccx));
|
||||
trans_closure(sub_cx, sp, decl, body, llfn, no_self, [],
|
||||
id, {|_fcx|});
|
||||
@ -556,7 +556,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
|
||||
dest: dest) -> @block_ctxt {
|
||||
let bound: [@ast::expr] = [];
|
||||
for argopt: option::t<@ast::expr> in args {
|
||||
alt argopt { none. { } some(e) { bound += [e]; } }
|
||||
alt argopt { none { } some(e) { bound += [e]; } }
|
||||
}
|
||||
let bcx = f_res.bcx;
|
||||
if dest == ignore {
|
||||
@ -566,7 +566,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
|
||||
|
||||
// Figure out which tydescs we need to pass, if any.
|
||||
let (outgoing_fty_real, lltydescs, param_bounds) = alt f_res.generic {
|
||||
none. { (outgoing_fty, [], @[]) }
|
||||
none { (outgoing_fty, [], @[]) }
|
||||
some(ginfo) {
|
||||
let tds = [], orig = 0u;
|
||||
vec::iter2(ginfo.tydescs, *ginfo.param_bounds) {|td, bounds|
|
||||
@ -596,7 +596,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
|
||||
ret memmove_ty(bcx, get_dest_addr(dest), lv.val, pair_ty);
|
||||
}
|
||||
let closure = alt f_res.env {
|
||||
null_env. { none }
|
||||
null_env { none }
|
||||
_ { let (_, cl) = maybe_add_env(cx, f_res); some(cl) }
|
||||
};
|
||||
|
||||
@ -616,7 +616,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t,
|
||||
let src_loc = PointerCast(bcx, cl, llclosurety);
|
||||
([env_copy(src_loc, pair_ty, owned)], none)
|
||||
}
|
||||
none. { ([], some(f_res.val)) }
|
||||
none { ([], some(f_res.val)) }
|
||||
};
|
||||
|
||||
// Actually construct the closure
|
||||
@ -668,11 +668,11 @@ fn make_fn_glue(
|
||||
};
|
||||
|
||||
ret alt ty::struct(tcx, t) {
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare., _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_block., _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_any., _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_uniq., _}) { fn_env(ty::ck_uniq) }
|
||||
ty::ty_fn({proto: ast::proto_box., _}) { fn_env(ty::ck_box) }
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_block, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_any, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) }
|
||||
ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) }
|
||||
_ { fail "make_fn_glue invoked on non-function type" }
|
||||
};
|
||||
}
|
||||
@ -684,9 +684,9 @@ fn make_opaque_cbox_take_glue(
|
||||
-> @block_ctxt {
|
||||
// Easy cases:
|
||||
alt ck {
|
||||
ty::ck_block. { ret bcx; }
|
||||
ty::ck_box. { ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); }
|
||||
ty::ck_uniq. { /* hard case: */ }
|
||||
ty::ck_block { ret bcx; }
|
||||
ty::ck_box { ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); }
|
||||
ty::ck_uniq { /* hard case: */ }
|
||||
}
|
||||
|
||||
// Hard case, a deep copy:
|
||||
@ -722,12 +722,12 @@ fn make_opaque_cbox_drop_glue(
|
||||
cboxptr: ValueRef) // ptr to the opaque closure
|
||||
-> @block_ctxt {
|
||||
alt ck {
|
||||
ty::ck_block. { bcx }
|
||||
ty::ck_box. {
|
||||
ty::ck_block { bcx }
|
||||
ty::ck_box {
|
||||
decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr),
|
||||
ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
|
||||
}
|
||||
ty::ck_uniq. {
|
||||
ty::ck_uniq {
|
||||
free_ty(bcx, Load(bcx, cboxptr),
|
||||
ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
|
||||
}
|
||||
@ -740,8 +740,8 @@ fn make_opaque_cbox_free_glue(
|
||||
cbox: ValueRef) // ptr to the opaque closure
|
||||
-> @block_ctxt {
|
||||
alt ck {
|
||||
ty::ck_block. { ret bcx; }
|
||||
ty::ck_box. | ty::ck_uniq. { /* hard cases: */ }
|
||||
ty::ck_block { ret bcx; }
|
||||
ty::ck_box | ty::ck_uniq { /* hard cases: */ }
|
||||
}
|
||||
|
||||
let ccx = bcx_ccx(bcx);
|
||||
@ -768,11 +768,11 @@ fn make_opaque_cbox_free_glue(
|
||||
|
||||
// Free the ty descr (if necc) and the box itself
|
||||
alt ck {
|
||||
ty::ck_block. { fail "Impossible."; }
|
||||
ty::ck_box. {
|
||||
ty::ck_block { fail "Impossible"; }
|
||||
ty::ck_box {
|
||||
trans_free_if_not_gc(bcx, cbox)
|
||||
}
|
||||
ty::ck_uniq. {
|
||||
ty::ck_uniq {
|
||||
let bcx = free_ty(bcx, tydesc, mk_tydesc_ty(tcx, ck));
|
||||
trans_shared_free(bcx, cbox)
|
||||
}
|
||||
@ -858,7 +858,7 @@ fn trans_bind_thunk(cx: @local_ctxt,
|
||||
some(fptr) {
|
||||
(fptr, llvm::LLVMGetUndef(T_opaque_cbox_ptr(ccx)), 0)
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
// Silly check
|
||||
check type_is_tup_like(bcx, cbox_ty);
|
||||
let {bcx: cx, val: pair} =
|
||||
@ -915,7 +915,7 @@ fn trans_bind_thunk(cx: @local_ctxt,
|
||||
llargs += [dict];
|
||||
off += 1;
|
||||
dicts = some(alt dicts {
|
||||
none. { [dict] }
|
||||
none { [dict] }
|
||||
some(ds) { ds + [dict] }
|
||||
});
|
||||
}
|
||||
@ -961,7 +961,7 @@ fn trans_bind_thunk(cx: @local_ctxt,
|
||||
}
|
||||
|
||||
// Arg will be provided when the thunk is invoked.
|
||||
none. {
|
||||
none {
|
||||
let arg: ValueRef = llvm::LLVMGetParam(llthunk, a as c_uint);
|
||||
if ty::type_contains_params(cx.ccx.tcx, out_arg.ty) {
|
||||
arg = PointerCast(bcx, arg, llout_arg_ty);
|
||||
|
@ -33,7 +33,7 @@ fn new_namegen() -> namegen {
|
||||
type derived_tydesc_info = {lltydesc: ValueRef, escapes: bool};
|
||||
|
||||
tag tydesc_kind {
|
||||
tk_static; // Static (monomorphic) type descriptor.
|
||||
tk_static; // Static (monomorphic) type descriptor
|
||||
tk_param; // Type parameter.
|
||||
tk_derived; // Derived from a typaram or another derived tydesc.
|
||||
}
|
||||
@ -335,7 +335,7 @@ tag block_kind {
|
||||
|
||||
|
||||
// A scope block is a basic block created by translating a block { ... }
|
||||
// the the source language. Since these blocks create variable scope, any
|
||||
// in the source language. Since these blocks create variable scope, any
|
||||
// variables created in them that are still live at the end of the block
|
||||
// must be dropped and cleaned up when the block ends.
|
||||
SCOPE_BLOCK;
|
||||
@ -422,7 +422,7 @@ fn find_scope_cx(cx: @block_ctxt) -> @block_ctxt {
|
||||
if cx.kind != NON_SCOPE_BLOCK { ret cx; }
|
||||
alt cx.parent {
|
||||
parent_some(b) { ret find_scope_cx(b); }
|
||||
parent_none. {
|
||||
parent_none {
|
||||
cx.fcx.lcx.ccx.sess.bug("trans::find_scope_cx() " +
|
||||
"called on parentless block_ctxt");
|
||||
}
|
||||
@ -491,30 +491,30 @@ fn T_int(targ_cfg: @session::config) -> TypeRef {
|
||||
|
||||
fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef {
|
||||
alt t {
|
||||
ast::ty_i. { cx.int_type }
|
||||
ast::ty_char. { T_char() }
|
||||
ast::ty_i8. { T_i8() }
|
||||
ast::ty_i16. { T_i16() }
|
||||
ast::ty_i32. { T_i32() }
|
||||
ast::ty_i64. { T_i64() }
|
||||
ast::ty_i { cx.int_type }
|
||||
ast::ty_char { T_char() }
|
||||
ast::ty_i8 { T_i8() }
|
||||
ast::ty_i16 { T_i16() }
|
||||
ast::ty_i32 { T_i32() }
|
||||
ast::ty_i64 { T_i64() }
|
||||
}
|
||||
}
|
||||
|
||||
fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef {
|
||||
alt t {
|
||||
ast::ty_u. { cx.int_type }
|
||||
ast::ty_u8. { T_i8() }
|
||||
ast::ty_u16. { T_i16() }
|
||||
ast::ty_u32. { T_i32() }
|
||||
ast::ty_u64. { T_i64() }
|
||||
ast::ty_u { cx.int_type }
|
||||
ast::ty_u8 { T_i8() }
|
||||
ast::ty_u16 { T_i16() }
|
||||
ast::ty_u32 { T_i32() }
|
||||
ast::ty_u64 { T_i64() }
|
||||
}
|
||||
}
|
||||
|
||||
fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef {
|
||||
alt t {
|
||||
ast::ty_f. { cx.float_type }
|
||||
ast::ty_f32. { T_f32() }
|
||||
ast::ty_f64. { T_f64() }
|
||||
ast::ty_f { cx.float_type }
|
||||
ast::ty_f32 { T_f32() }
|
||||
ast::ty_f64 { T_f64() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ fn get_static_dict(bcx: @block_ctxt, origin: typeck::dict_origin)
|
||||
let id = dict_id(ccx.tcx, origin);
|
||||
alt ccx.dicts.find(id) {
|
||||
some(d) { ret d; }
|
||||
none. {}
|
||||
none {}
|
||||
}
|
||||
let ptrs = C_struct(get_dict_ptrs(bcx, origin).ptrs);
|
||||
let name = ccx.names("dict");
|
||||
|
@ -153,7 +153,7 @@ fn trans_append(cx: @block_ctxt, vec_ty: ty::t, lhsptr: ValueRef,
|
||||
(PointerCast(cx, lhsptr, T_ptr(T_ptr(ccx.opaque_vec_type))),
|
||||
PointerCast(cx, rhs, T_ptr(ccx.opaque_vec_type)));
|
||||
let strings = alt ty::struct(bcx_tcx(cx), vec_ty) {
|
||||
ty::ty_str. { true }
|
||||
ty::ty_str { true }
|
||||
ty::ty_vec(_) { false }
|
||||
};
|
||||
|
||||
@ -221,7 +221,7 @@ fn trans_add(bcx: @block_ctxt, vec_ty: ty::t, lhs: ValueRef,
|
||||
rhs: ValueRef, dest: dest) -> @block_ctxt {
|
||||
let ccx = bcx_ccx(bcx);
|
||||
let strings = alt ty::struct(bcx_tcx(bcx), vec_ty) {
|
||||
ty::ty_str. { true }
|
||||
ty::ty_str { true }
|
||||
ty::ty_vec(_) { false }
|
||||
};
|
||||
let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
|
||||
|
@ -240,7 +240,7 @@ fn implies(a: t, b: t) -> bool {
|
||||
}
|
||||
|
||||
fn trit_str(t: trit) -> str {
|
||||
alt t { dont_care. { "?" } ttrue. { "1" } tfalse. { "0" } }
|
||||
alt t { dont_care { "?" } ttrue { "1" } tfalse { "0" } }
|
||||
}
|
||||
//
|
||||
// Local Variables:
|
||||
|
@ -41,7 +41,7 @@ fn comma_str(args: [@constr_arg_use]) -> str {
|
||||
for a: @constr_arg_use in args {
|
||||
if comma { rslt += ", "; } else { comma = true; }
|
||||
alt a.node {
|
||||
carg_base. { rslt += "*"; }
|
||||
carg_base { rslt += "*"; }
|
||||
carg_ident(i) { rslt += i.ident; }
|
||||
carg_lit(l) { rslt += lit_to_str(l); }
|
||||
}
|
||||
@ -69,7 +69,7 @@ fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> str {
|
||||
let comma = false;
|
||||
for p: norm_constraint in constraints(fcx) {
|
||||
alt tritv_get(v, p.bit_num) {
|
||||
dont_care. { }
|
||||
dont_care { }
|
||||
tt {
|
||||
s +=
|
||||
if comma { ", " } else { comma = true; "" } +
|
||||
@ -310,7 +310,7 @@ fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option::t<ts_ann> {
|
||||
/********* utils ********/
|
||||
fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann {
|
||||
alt get_ts_ann(ccx, id) {
|
||||
none. {
|
||||
none {
|
||||
#error("node_id_to_ts_ann: no ts_ann for node_id %d", id);
|
||||
fail;
|
||||
}
|
||||
@ -507,7 +507,7 @@ fn constraints_expr(cx: ty::ctxt, e: @expr) -> [@ty::constr] {
|
||||
|
||||
fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def {
|
||||
alt cx.def_map.find(id) {
|
||||
none. {
|
||||
none {
|
||||
#error("node_id_to_def: node_id %d has no def", id);
|
||||
fail;
|
||||
}
|
||||
@ -565,7 +565,7 @@ fn match_args(fcx: fn_ctxt, occs: @mutable [pred_args],
|
||||
|
||||
fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id {
|
||||
alt tcx.def_map.find(t) {
|
||||
none. {
|
||||
none {
|
||||
tcx.sess.bug("node_id_for_constr: bad node_id " + int::str(t));
|
||||
}
|
||||
some(def_fn(i, _)) { ret i; }
|
||||
@ -658,7 +658,7 @@ fn substitute_arg(cx: ty::ctxt, actuals: [@expr], a: @constr_arg) ->
|
||||
cx.sess.span_fatal(a.span, "Constraint argument out of bounds");
|
||||
}
|
||||
}
|
||||
carg_base. { ret @respan(a.span, carg_base); }
|
||||
carg_base { ret @respan(a.span, carg_base); }
|
||||
carg_lit(l) { ret @respan(a.span, carg_lit(l)); }
|
||||
}
|
||||
}
|
||||
@ -675,7 +675,7 @@ fn pred_args_matches(pattern: [constr_arg_general_<inst>], desc: pred_args) ->
|
||||
_ { ret false; }
|
||||
}
|
||||
}
|
||||
carg_base. { if n != carg_base { ret false; } }
|
||||
carg_base { if n != carg_base { ret false; } }
|
||||
carg_lit(l) {
|
||||
alt n {
|
||||
carg_lit(m) { if !lit_eq(l, m) { ret false; } }
|
||||
@ -741,7 +741,7 @@ fn insts_to_str(stuff: [constr_arg_general_<inst>]) -> str {
|
||||
" " +
|
||||
alt i {
|
||||
carg_ident(p) { p.ident }
|
||||
carg_base. { "*" }
|
||||
carg_base { "*" }
|
||||
carg_lit(_) { "[lit]" }
|
||||
} + " ";
|
||||
}
|
||||
@ -794,7 +794,7 @@ fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) ->
|
||||
"local_node_id_to_def_id: id \
|
||||
isn't a local");
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
// should really be bug. span_bug()?
|
||||
fcx.ccx.tcx.sess.span_fatal(sp,
|
||||
"local_node_id_to_def_id: id \
|
||||
@ -848,8 +848,8 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
|
||||
ty: oper_type) {
|
||||
let subst;
|
||||
alt ty {
|
||||
oper_swap. { subst = [{from: dest, to: src}, {from: src, to: dest}]; }
|
||||
oper_assign_op. {
|
||||
oper_swap { subst = [{from: dest, to: src}, {from: src, to: dest}]; }
|
||||
oper_assign_op {
|
||||
ret; // Don't do any propagation
|
||||
}
|
||||
_ { subst = [{from: src, to: dest}]; }
|
||||
@ -1003,7 +1003,7 @@ fn vec_contains(v: @mutable [node_id], i: node_id) -> bool {
|
||||
}
|
||||
|
||||
fn op_to_oper_ty(io: init_op) -> oper_type {
|
||||
alt io { init_move. { oper_move } _ { oper_assign } }
|
||||
alt io { init_move { oper_move } _ { oper_assign } }
|
||||
}
|
||||
|
||||
// default function visitor
|
||||
@ -1021,7 +1021,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: [arg],
|
||||
actuals +=
|
||||
[@respan(a.span,
|
||||
alt a.node {
|
||||
carg_base. { carg_base }
|
||||
carg_base { carg_base }
|
||||
carg_ident(i) {
|
||||
if i < num_args {
|
||||
carg_ident({ident: args[i].ident,
|
||||
@ -1090,7 +1090,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [ty::mode] {
|
||||
|
||||
fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> [init_op] {
|
||||
fn mode_to_op(m: ty::mode) -> init_op {
|
||||
alt m { by_move. { init_move } _ { init_assign } }
|
||||
alt m { by_move { init_move } _ { init_assign } }
|
||||
}
|
||||
vec::map(callee_modes(fcx, callee), mode_to_op)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fn promises_(n: uint, p: poststate) -> bool { ret tritv_get(p, n) == ttrue; }
|
||||
|
||||
// v "happens after" u
|
||||
fn seq_trit(u: trit, v: trit) -> trit {
|
||||
alt v { ttrue. { ttrue } tfalse. { tfalse } dont_care. { u } }
|
||||
alt v { ttrue { ttrue } tfalse { tfalse } dont_care { u } }
|
||||
}
|
||||
|
||||
// idea: q "happens after" p -- so if something is
|
||||
|
@ -84,7 +84,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
|
||||
}
|
||||
}
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
let rslt: @mutable [pred_args] =
|
||||
@mutable [respan(c.span, {args: args, bit_num: next})];
|
||||
tbl.insert(d_id, cpred(p, rslt));
|
||||
|
@ -132,9 +132,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
||||
find_pre_post_expr(fcx, antec);
|
||||
find_pre_post_block(fcx, conseq);
|
||||
alt maybe_alt {
|
||||
none. {
|
||||
none {
|
||||
alt chck {
|
||||
if_check. {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
gen(fcx, antec.id, c.node);
|
||||
}
|
||||
@ -166,7 +166,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
||||
/* Be sure to set the bit for the check condition here,
|
||||
so that it's *not* set in the alternative. */
|
||||
alt chck {
|
||||
if_check. {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
gen(fcx, antec.id, c.node);
|
||||
}
|
||||
@ -219,14 +219,14 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr,
|
||||
let tmp = tritv_clone(post);
|
||||
|
||||
alt ty {
|
||||
oper_move. {
|
||||
oper_move {
|
||||
if is_path(rhs) { forget_in_postcond(fcx, parent.id, rhs.id); }
|
||||
}
|
||||
oper_swap. {
|
||||
oper_swap {
|
||||
forget_in_postcond_still_init(fcx, parent.id, lhs.id);
|
||||
forget_in_postcond_still_init(fcx, parent.id, rhs.id);
|
||||
}
|
||||
oper_assign. {
|
||||
oper_assign {
|
||||
forget_in_postcond_still_init(fcx, parent.id, lhs.id);
|
||||
}
|
||||
_ {
|
||||
@ -336,7 +336,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
|
||||
/* if this is a failing call, its postcondition sets everything */
|
||||
alt controlflow_expr(fcx.ccx, operator) {
|
||||
noreturn. { set_postcond_false(fcx.ccx, e.id); }
|
||||
noreturn { set_postcond_false(fcx.ccx, e.id); }
|
||||
_ { }
|
||||
}
|
||||
}
|
||||
@ -374,7 +374,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
}
|
||||
expr_rec(fields, maybe_base) {
|
||||
let es = field_exprs(fields);
|
||||
alt maybe_base { none. {/* no-op */ } some(b) { es += [b]; } }
|
||||
alt maybe_base { none {/* no-op */ } some(b) { es += [b]; } }
|
||||
find_pre_post_exprs(fcx, es, e.id);
|
||||
}
|
||||
expr_tup(elts) { find_pre_post_exprs(fcx, elts, e.id); }
|
||||
@ -395,7 +395,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
expr_lit(_) { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
expr_ret(maybe_val) {
|
||||
alt maybe_val {
|
||||
none. {
|
||||
none {
|
||||
clear_precond(fcx.ccx, e.id);
|
||||
set_postcond_false(fcx.ccx, e.id);
|
||||
}
|
||||
@ -503,7 +503,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
expr_fail(maybe_val) {
|
||||
let prestate;
|
||||
alt maybe_val {
|
||||
none. { prestate = empty_prestate(num_local_vars); }
|
||||
none { prestate = empty_prestate(num_local_vars); }
|
||||
some(fail_val) {
|
||||
find_pre_post_expr(fcx, fail_val);
|
||||
prestate = expr_precond(fcx.ccx, fail_val);
|
||||
@ -542,7 +542,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
let i = 0;
|
||||
for expr_opt: option::t<@expr> in maybe_args {
|
||||
alt expr_opt {
|
||||
none. {/* no-op */ }
|
||||
none {/* no-op */ }
|
||||
some(expr) { modes += [cmodes[i]]; args += [expr]; }
|
||||
}
|
||||
i += 1;
|
||||
@ -551,8 +551,8 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
||||
forget_args_moved_in(fcx, e, modes, args);
|
||||
find_pre_post_exprs(fcx, args, e.id);
|
||||
}
|
||||
expr_break. { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
expr_cont. { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
expr_break { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
expr_cont { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
expr_mac(_) { fcx.ccx.tcx.sess.bug("unexpanded macro"); }
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
||||
node: an_init.expr.id},
|
||||
op_to_oper_ty(an_init.op));
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
gen(fcx, id, ninit(pat.id, ident));
|
||||
};
|
||||
@ -631,7 +631,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
||||
copy_pre_post_(fcx.ccx, id, prev_pp.precondition,
|
||||
prev_pp.postcondition);
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
pat_bindings(alocal.node.pat) {|p|
|
||||
clear_pp(node_id_to_ts_ann(fcx.ccx, p.id).conditions);
|
||||
};
|
||||
@ -689,7 +689,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) {
|
||||
let pps: [pre_and_post] = [];
|
||||
for s: @stmt in b.node.stmts { pps += [stmt_pp(fcx.ccx, *s)]; }
|
||||
alt b.node.expr {
|
||||
none. {/* no-op */ }
|
||||
none {/* no-op */ }
|
||||
some(e) { pps += [expr_pp(fcx.ccx, e)]; }
|
||||
}
|
||||
|
||||
@ -721,7 +721,7 @@ fn find_pre_post_fn(fcx: fn_ctxt, body: blk) {
|
||||
// Treat the tail expression as a return statement
|
||||
alt body.node.expr {
|
||||
some(tailexpr) { set_postcond_false(fcx.ccx, tailexpr.id); }
|
||||
none. {/* fallthrough */ }
|
||||
none {/* fallthrough */ }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import driver::session::session;
|
||||
|
||||
fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) {
|
||||
alt t {
|
||||
oper_move. {
|
||||
oper_move {
|
||||
alt local_node_id_to_def(fcx, rhs_id) {
|
||||
some(def_upvar(_, _, _)) {
|
||||
fcx.ccx.tcx.sess.span_err(sp,
|
||||
@ -94,7 +94,7 @@ fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr,
|
||||
|
||||
let post = tritv_clone(expr_poststate(fcx.ccx, e));
|
||||
alt c {
|
||||
none. { }
|
||||
none { }
|
||||
some(c1) { set_in_poststate_(bit_num(fcx, c1), post); }
|
||||
}
|
||||
|
||||
@ -123,11 +123,11 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
|
||||
let tmp = tritv_clone(post);
|
||||
|
||||
alt ty {
|
||||
oper_move. {
|
||||
oper_move {
|
||||
if is_path(rhs) { forget_in_poststate(fcx, post, rhs.id); }
|
||||
forget_in_poststate_still_init(fcx, post, lhs.id);
|
||||
}
|
||||
oper_swap. {
|
||||
oper_swap {
|
||||
forget_in_poststate_still_init(fcx, post, lhs.id);
|
||||
forget_in_poststate_still_init(fcx, post, rhs.id);
|
||||
}
|
||||
@ -187,7 +187,7 @@ fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id,
|
||||
let changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres);
|
||||
/* if this is a failing call, it sets everything as initialized */
|
||||
alt cf {
|
||||
noreturn. {
|
||||
noreturn {
|
||||
let post = false_postcond(num_constraints(fcx.enclosing));
|
||||
changed |= set_poststate_ann(fcx.ccx, id, post);
|
||||
}
|
||||
@ -265,9 +265,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
||||
*/
|
||||
|
||||
alt maybe_alt {
|
||||
none. {
|
||||
none {
|
||||
alt chk {
|
||||
if_check. {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
let conseq_prestate = tritv_clone(expr_poststate(fcx.ccx, antec));
|
||||
tritv_set(bit_num(fcx, c.node), conseq_prestate, ttrue);
|
||||
@ -292,7 +292,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
||||
|
||||
let conseq_prestate = expr_poststate(fcx.ccx, antec);
|
||||
alt chk {
|
||||
if_check. {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
conseq_prestate = tritv_clone(conseq_prestate);
|
||||
tritv_set(bit_num(fcx, c.node), conseq_prestate, ttrue);
|
||||
@ -360,7 +360,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
let i = 0;
|
||||
for a_opt: option::t<@expr> in maybe_args {
|
||||
alt a_opt {
|
||||
none. {/* no-op */ }
|
||||
none {/* no-op */ }
|
||||
some(a) { ops += [callee_ops[i]]; args += [a]; }
|
||||
}
|
||||
i += 1;
|
||||
@ -390,7 +390,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
vec::len(fields)),
|
||||
field_exprs(fields), return_val);
|
||||
alt maybe_base {
|
||||
none. {/* do nothing */ }
|
||||
none {/* do nothing */ }
|
||||
some(base) {
|
||||
changed |=
|
||||
find_pre_post_state_expr(fcx, pres, base) |
|
||||
@ -431,7 +431,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
set_poststate_ann(fcx.ccx, e.id, post);
|
||||
|
||||
alt maybe_ret_val {
|
||||
none. {/* do nothing */ }
|
||||
none {/* do nothing */ }
|
||||
some(ret_val) {
|
||||
changed |= find_pre_post_state_expr(fcx, pres, ret_val);
|
||||
}
|
||||
@ -586,13 +586,13 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
woo! */
|
||||
let post = false_postcond(num_constrs);
|
||||
alt fcx.enclosing.cf {
|
||||
noreturn. { kill_poststate_(fcx, ninit(fcx.id, fcx.name), post); }
|
||||
noreturn { kill_poststate_(fcx, ninit(fcx.id, fcx.name), post); }
|
||||
_ { }
|
||||
}
|
||||
ret set_prestate_ann(fcx.ccx, e.id, pres) |
|
||||
set_poststate_ann(fcx.ccx, e.id, post) |
|
||||
alt maybe_fail_val {
|
||||
none. { false }
|
||||
none { false }
|
||||
some(fail_val) {
|
||||
find_pre_post_state_expr(fcx, pres, fail_val)
|
||||
}
|
||||
@ -609,8 +609,8 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
expr_if_check(p, conseq, maybe_alt) {
|
||||
ret join_then_else(fcx, p, conseq, maybe_alt, e.id, if_check, pres);
|
||||
}
|
||||
expr_break. { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
expr_cont. { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
expr_break { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
expr_cont { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -704,7 +704,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool {
|
||||
}
|
||||
let post = pres;
|
||||
alt b.node.expr {
|
||||
none. { }
|
||||
none { }
|
||||
some(e) {
|
||||
changed |= find_pre_post_state_expr(fcx, pres, e);
|
||||
post = expr_poststate(fcx.ccx, e);
|
||||
@ -767,7 +767,7 @@ fn find_pre_post_state_fn(fcx: fn_ctxt,
|
||||
set_poststate_ann(fcx.ccx, f_body.node.id, post);
|
||||
}
|
||||
}
|
||||
none. {/* fallthrough */ }
|
||||
none {/* fallthrough */ }
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -49,25 +49,25 @@ fn trit_minus(a: trit, b: trit) -> trit {
|
||||
0 - anything else - 0
|
||||
*/
|
||||
alt a {
|
||||
dont_care. { dont_care }
|
||||
ttrue. {
|
||||
dont_care { dont_care }
|
||||
ttrue {
|
||||
alt b {
|
||||
ttrue. { dont_care }
|
||||
tfalse. { ttrue }
|
||||
ttrue { dont_care }
|
||||
tfalse { ttrue }
|
||||
|
||||
|
||||
|
||||
|
||||
/* internally contradictory, but
|
||||
I guess it'll get flagged? */
|
||||
dont_care. {
|
||||
dont_care {
|
||||
ttrue
|
||||
}
|
||||
}
|
||||
}
|
||||
tfalse. {
|
||||
tfalse {
|
||||
alt b {
|
||||
ttrue. { tfalse }
|
||||
ttrue { tfalse }
|
||||
|
||||
|
||||
|
||||
@ -83,11 +83,11 @@ fn trit_minus(a: trit, b: trit) -> trit {
|
||||
|
||||
fn trit_or(a: trit, b: trit) -> trit {
|
||||
alt a {
|
||||
dont_care. { b }
|
||||
ttrue. { ttrue }
|
||||
tfalse. {
|
||||
dont_care { b }
|
||||
ttrue { ttrue }
|
||||
tfalse {
|
||||
alt b {
|
||||
ttrue. { dont_care }
|
||||
ttrue { dont_care }
|
||||
|
||||
|
||||
|
||||
@ -108,21 +108,21 @@ fn trit_or(a: trit, b: trit) -> trit {
|
||||
// (we consider a constraint false until proven true), too.
|
||||
fn trit_and(a: trit, b: trit) -> trit {
|
||||
alt a {
|
||||
dont_care. { b }
|
||||
dont_care { b }
|
||||
|
||||
|
||||
|
||||
|
||||
// also seems wrong for case b = ttrue
|
||||
ttrue. {
|
||||
ttrue {
|
||||
alt b {
|
||||
dont_care. { ttrue }
|
||||
dont_care { ttrue }
|
||||
|
||||
|
||||
|
||||
|
||||
// ??? Seems wrong
|
||||
ttrue. {
|
||||
ttrue {
|
||||
ttrue
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ fn trit_and(a: trit, b: trit) -> trit {
|
||||
// (Rationale: it's always safe to assume that
|
||||
// a var is uninitialized or that a constraint
|
||||
// needs to be re-established)
|
||||
tfalse. {
|
||||
tfalse {
|
||||
tfalse
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ fn trit_and(a: trit, b: trit) -> trit {
|
||||
|
||||
// Rationale: if it's uninit on one path,
|
||||
// we can consider it as uninit on all paths
|
||||
tfalse. {
|
||||
tfalse {
|
||||
tfalse
|
||||
}
|
||||
}
|
||||
@ -214,12 +214,12 @@ fn tritv_get(v: t, i: uint) -> trit {
|
||||
fn tritv_set(i: uint, v: t, t: trit) -> bool {
|
||||
let old = tritv_get(v, i);
|
||||
alt t {
|
||||
dont_care. {
|
||||
dont_care {
|
||||
bitv::set(v.uncertain, i, true);
|
||||
bitv::set(v.val, i, false);
|
||||
}
|
||||
ttrue. { bitv::set(v.uncertain, i, false); bitv::set(v.val, i, true); }
|
||||
tfalse. {
|
||||
ttrue { bitv::set(v.uncertain, i, false); bitv::set(v.val, i, true); }
|
||||
tfalse {
|
||||
bitv::set(v.uncertain, i, false);
|
||||
bitv::set(v.val, i, false);
|
||||
}
|
||||
@ -273,9 +273,9 @@ fn to_vec(v: t) -> [uint] {
|
||||
while i < v.nbits {
|
||||
rslt +=
|
||||
[alt tritv_get(v, i) {
|
||||
dont_care. { 2u }
|
||||
ttrue. { 1u }
|
||||
tfalse. { 0u }
|
||||
dont_care { 2u }
|
||||
ttrue { 1u }
|
||||
tfalse { 0u }
|
||||
}];
|
||||
i += 1u;
|
||||
}
|
||||
@ -288,9 +288,9 @@ fn to_str(v: t) -> str {
|
||||
while i < v.nbits {
|
||||
rs +=
|
||||
alt tritv_get(v, i) {
|
||||
dont_care. { "?" }
|
||||
ttrue. { "1" }
|
||||
tfalse. { "0" }
|
||||
dont_care { "?" }
|
||||
ttrue { "1" }
|
||||
tfalse { "0" }
|
||||
};
|
||||
i += 1u;
|
||||
}
|
||||
|
@ -313,10 +313,10 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind {
|
||||
let kind = kind_noncopyable;
|
||||
for bound in *bounds {
|
||||
alt bound {
|
||||
bound_copy. {
|
||||
bound_copy {
|
||||
if kind != kind_sendable { kind = kind_copyable; }
|
||||
}
|
||||
bound_send. { kind = kind_sendable; }
|
||||
bound_send { kind = kind_sendable; }
|
||||
_ {}
|
||||
}
|
||||
}
|
||||
@ -468,8 +468,8 @@ fn mk_raw_ty(cx: ctxt, st: sty) -> @raw_t {
|
||||
derive_flags_t(cx, has_params, has_vars, tt);
|
||||
}
|
||||
alt st {
|
||||
ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_str. | ty_send_type. | ty_type. | ty_native(_) |
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_str | ty_send_type | ty_type | ty_native(_) |
|
||||
ty_opaque_closure_ptr(_) {
|
||||
/* no-op */
|
||||
}
|
||||
@ -535,30 +535,30 @@ fn mk_uint(_cx: ctxt) -> t { ret idx_uint; }
|
||||
|
||||
fn mk_mach_int(_cx: ctxt, tm: ast::int_ty) -> t {
|
||||
alt tm {
|
||||
ast::ty_i. { ret idx_int; }
|
||||
ast::ty_char. { ret idx_char; }
|
||||
ast::ty_i8. { ret idx_i8; }
|
||||
ast::ty_i16. { ret idx_i16; }
|
||||
ast::ty_i32. { ret idx_i32; }
|
||||
ast::ty_i64. { ret idx_i64; }
|
||||
ast::ty_i { ret idx_int; }
|
||||
ast::ty_char { ret idx_char; }
|
||||
ast::ty_i8 { ret idx_i8; }
|
||||
ast::ty_i16 { ret idx_i16; }
|
||||
ast::ty_i32 { ret idx_i32; }
|
||||
ast::ty_i64 { ret idx_i64; }
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_mach_uint(_cx: ctxt, tm: ast::uint_ty) -> t {
|
||||
alt tm {
|
||||
ast::ty_u. { ret idx_uint; }
|
||||
ast::ty_u8. { ret idx_u8; }
|
||||
ast::ty_u16. { ret idx_u16; }
|
||||
ast::ty_u32. { ret idx_u32; }
|
||||
ast::ty_u64. { ret idx_u64; }
|
||||
ast::ty_u { ret idx_uint; }
|
||||
ast::ty_u8 { ret idx_u8; }
|
||||
ast::ty_u16 { ret idx_u16; }
|
||||
ast::ty_u32 { ret idx_u32; }
|
||||
ast::ty_u64 { ret idx_u64; }
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_mach_float(_cx: ctxt, tm: ast::float_ty) -> t {
|
||||
alt tm {
|
||||
ast::ty_f. { ret idx_float; }
|
||||
ast::ty_f32. { ret idx_f32; }
|
||||
ast::ty_f64. { ret idx_f64; }
|
||||
ast::ty_f { ret idx_float; }
|
||||
ast::ty_f32 { ret idx_f32; }
|
||||
ast::ty_f64 { ret idx_f64; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,9 +659,9 @@ pure fn mach_struct(cx: ctxt, cfg: @session::config, typ: t) -> sty {
|
||||
// Converts s to its machine type equivalent
|
||||
pure fn mach_sty(cfg: @session::config, s: sty) -> sty {
|
||||
alt s {
|
||||
ty_int(ast::ty_i.) { ty_int(cfg.int_type) }
|
||||
ty_uint(ast::ty_u.) { ty_uint(cfg.uint_type) }
|
||||
ty_float(ast::ty_f.) { ty_float(cfg.float_type) }
|
||||
ty_int(ast::ty_i) { ty_int(cfg.int_type) }
|
||||
ty_uint(ast::ty_u) { ty_uint(cfg.uint_type) }
|
||||
ty_float(ast::ty_f) { ty_float(cfg.float_type) }
|
||||
s { s }
|
||||
}
|
||||
}
|
||||
@ -679,8 +679,8 @@ type ty_walk = fn@(t);
|
||||
|
||||
fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
|
||||
alt struct(cx, ty) {
|
||||
ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_str. | ty_send_type. | ty_type. | ty_native(_) |
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_str | ty_send_type | ty_type | ty_native(_) |
|
||||
ty_opaque_closure_ptr(_) {
|
||||
/* no-op */
|
||||
}
|
||||
@ -728,8 +728,8 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
|
||||
fm_general(_) {/* no fast path */ }
|
||||
}
|
||||
alt interner::get(*cx.ts, ty).struct {
|
||||
ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_str. | ty_send_type. | ty_type. | ty_native(_) |
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_str | ty_send_type | ty_type | ty_native(_) |
|
||||
ty_opaque_closure_ptr(_) {
|
||||
/* no-op */
|
||||
}
|
||||
@ -813,15 +813,15 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
|
||||
// Type utilities
|
||||
|
||||
fn type_is_nil(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) { ty_nil. { ret true; } _ { ret false; } }
|
||||
alt struct(cx, ty) { ty_nil { ret true; } _ { ret false; } }
|
||||
}
|
||||
|
||||
fn type_is_bot(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) { ty_bot. { ret true; } _ { ret false; } }
|
||||
alt struct(cx, ty) { ty_bot { ret true; } _ { ret false; } }
|
||||
}
|
||||
|
||||
fn type_is_bool(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) { ty_bool. { ret true; } _ { ret false; } }
|
||||
alt struct(cx, ty) { ty_bool { ret true; } _ { ret false; } }
|
||||
}
|
||||
|
||||
fn type_is_structural(cx: ctxt, ty: t) -> bool {
|
||||
@ -838,19 +838,19 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool {
|
||||
|
||||
fn type_is_sequence(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) {
|
||||
ty_str. { ret true; }
|
||||
ty_str { ret true; }
|
||||
ty_vec(_) { ret true; }
|
||||
_ { ret false; }
|
||||
}
|
||||
}
|
||||
|
||||
fn type_is_str(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) { ty_str. { ret true; } _ { ret false; } }
|
||||
alt struct(cx, ty) { ty_str { ret true; } _ { ret false; } }
|
||||
}
|
||||
|
||||
fn sequence_element_type(cx: ctxt, ty: t) -> t {
|
||||
alt struct(cx, ty) {
|
||||
ty_str. { ret mk_mach_uint(cx, ast::ty_u8); }
|
||||
ty_str { ret mk_mach_uint(cx, ast::ty_u8); }
|
||||
ty_vec(mt) { ret mt.ty; }
|
||||
_ { cx.sess.bug("sequence_element_type called on non-sequence value"); }
|
||||
}
|
||||
@ -907,7 +907,7 @@ pure fn type_is_unsafe_ptr(cx: ctxt, ty: t) -> bool {
|
||||
pure fn type_is_vec(cx: ctxt, ty: t) -> bool {
|
||||
ret alt struct(cx, ty) {
|
||||
ty_vec(_) { true }
|
||||
ty_str. { true }
|
||||
ty_str { true }
|
||||
_ { false }
|
||||
};
|
||||
}
|
||||
@ -916,15 +916,15 @@ pure fn type_is_unique(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) {
|
||||
ty_uniq(_) { ret true; }
|
||||
ty_vec(_) { true }
|
||||
ty_str. { true }
|
||||
ty_str { true }
|
||||
_ { ret false; }
|
||||
}
|
||||
}
|
||||
|
||||
pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) {
|
||||
ty_nil. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_send_type. | ty_type. | ty_native(_) | ty_ptr(_) { true }
|
||||
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
@ -938,14 +938,14 @@ fn type_is_immediate(cx: ctxt, ty: t) -> bool {
|
||||
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||
alt cx.needs_drop_cache.find(ty) {
|
||||
some(result) { ret result; }
|
||||
none. {/* fall through */ }
|
||||
none {/* fall through */ }
|
||||
}
|
||||
|
||||
let accum = false;
|
||||
let result = alt struct(cx, ty) {
|
||||
// scalar types
|
||||
ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_type. | ty_native(_) | ty_ptr(_) { false }
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_type | ty_native(_) | ty_ptr(_) { false }
|
||||
ty_rec(flds) {
|
||||
for f in flds { if type_needs_drop(cx, f.mt.ty) { accum = true; } }
|
||||
accum
|
||||
@ -980,35 +980,35 @@ tag kind { kind_sendable; kind_copyable; kind_noncopyable; }
|
||||
// future.
|
||||
pure fn kind_can_be_copied(k: kind) -> bool {
|
||||
ret alt k {
|
||||
kind_sendable. { true }
|
||||
kind_copyable. { true }
|
||||
kind_noncopyable. { false }
|
||||
kind_sendable { true }
|
||||
kind_copyable { true }
|
||||
kind_noncopyable { false }
|
||||
};
|
||||
}
|
||||
|
||||
pure fn kind_can_be_sent(k: kind) -> bool {
|
||||
ret alt k {
|
||||
kind_sendable. { true }
|
||||
kind_copyable. { false }
|
||||
kind_noncopyable. { false }
|
||||
kind_sendable { true }
|
||||
kind_copyable { false }
|
||||
kind_noncopyable { false }
|
||||
};
|
||||
}
|
||||
|
||||
fn proto_kind(p: proto) -> kind {
|
||||
alt p {
|
||||
ast::proto_any. { kind_noncopyable }
|
||||
ast::proto_block. { kind_noncopyable }
|
||||
ast::proto_box. { kind_copyable }
|
||||
ast::proto_uniq. { kind_sendable }
|
||||
ast::proto_bare. { kind_sendable }
|
||||
ast::proto_any { kind_noncopyable }
|
||||
ast::proto_block { kind_noncopyable }
|
||||
ast::proto_box { kind_copyable }
|
||||
ast::proto_uniq { kind_sendable }
|
||||
ast::proto_bare { kind_sendable }
|
||||
}
|
||||
}
|
||||
|
||||
fn kind_lteq(a: kind, b: kind) -> bool {
|
||||
alt a {
|
||||
kind_noncopyable. { true }
|
||||
kind_copyable. { b != kind_noncopyable }
|
||||
kind_sendable. { b == kind_sendable }
|
||||
kind_noncopyable { true }
|
||||
kind_copyable { b != kind_noncopyable }
|
||||
kind_sendable { b == kind_sendable }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1019,7 +1019,7 @@ fn lower_kind(a: kind, b: kind) -> kind {
|
||||
fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
alt cx.kind_cache.find(ty) {
|
||||
some(result) { ret result; }
|
||||
none. {/* fall through */ }
|
||||
none {/* fall through */ }
|
||||
}
|
||||
|
||||
// Insert a default in case we loop back on self recursively.
|
||||
@ -1027,14 +1027,14 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
|
||||
let result = alt struct(cx, ty) {
|
||||
// Scalar and unique types are sendable
|
||||
ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_native(_) | ty_ptr(_) |
|
||||
ty_send_type. | ty_str. | ty_native_fn(_, _) { kind_sendable }
|
||||
ty_type. { kind_copyable }
|
||||
ty_send_type | ty_str | ty_native_fn(_, _) { kind_sendable }
|
||||
ty_type { kind_copyable }
|
||||
ty_fn(f) { proto_kind(f.proto) }
|
||||
ty_opaque_closure_ptr(ck_block.) { kind_noncopyable }
|
||||
ty_opaque_closure_ptr(ck_box.) { kind_copyable }
|
||||
ty_opaque_closure_ptr(ck_uniq.) { kind_sendable }
|
||||
ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
|
||||
ty_opaque_closure_ptr(ck_box) { kind_copyable }
|
||||
ty_opaque_closure_ptr(ck_uniq) { kind_sendable }
|
||||
// Those with refcounts-to-inner raise pinned to shared,
|
||||
// lower unique to shared. Therefore just set result to shared.
|
||||
ty_box(_) | ty_iface(_, _) { kind_copyable }
|
||||
@ -1164,7 +1164,7 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
|
||||
ret alt sty {
|
||||
ty_uniq(_) { ret true; }
|
||||
ty_vec(_) { true }
|
||||
ty_str. { true }
|
||||
ty_str { true }
|
||||
_ { ret false; }
|
||||
};
|
||||
});
|
||||
@ -1172,7 +1172,7 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
|
||||
|
||||
fn type_is_integral(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) {
|
||||
ty_int(_) | ty_uint(_) | ty_bool. { true }
|
||||
ty_int(_) | ty_uint(_) | ty_bool { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
@ -1201,10 +1201,10 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
||||
let result = true;
|
||||
alt struct(cx, ty) {
|
||||
// Scalar types
|
||||
ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_send_type. | ty_type. | ty_native(_) | ty_ptr(_) { result = true; }
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { result = true; }
|
||||
// Boxed types
|
||||
ty_str. | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
|
||||
ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
|
||||
ty_native_fn(_, _) | ty_iface(_, _) { result = false; }
|
||||
// Structural types
|
||||
ty_tag(did, tps) {
|
||||
@ -1334,7 +1334,7 @@ fn hash_type_structure(st: sty) -> uint {
|
||||
let h = id;
|
||||
for a: @ty_constr_arg in args {
|
||||
alt a.node {
|
||||
carg_base. { h += h << 5u; }
|
||||
carg_base { h += h << 5u; }
|
||||
carg_lit(_) {
|
||||
// FIXME
|
||||
fail "lit args not implemented yet";
|
||||
@ -1355,23 +1355,23 @@ fn hash_type_structure(st: sty) -> uint {
|
||||
ret h;
|
||||
}
|
||||
alt st {
|
||||
ty_nil. { 0u } ty_bool. { 1u }
|
||||
ty_nil { 0u } ty_bool { 1u }
|
||||
ty_int(t) {
|
||||
alt t {
|
||||
ast::ty_i. { 2u } ast::ty_char. { 3u } ast::ty_i8. { 4u }
|
||||
ast::ty_i16. { 5u } ast::ty_i32. { 6u } ast::ty_i64. { 7u }
|
||||
ast::ty_i { 2u } ast::ty_char { 3u } ast::ty_i8 { 4u }
|
||||
ast::ty_i16 { 5u } ast::ty_i32 { 6u } ast::ty_i64 { 7u }
|
||||
}
|
||||
}
|
||||
ty_uint(t) {
|
||||
alt t {
|
||||
ast::ty_u. { 8u } ast::ty_u8. { 9u } ast::ty_u16. { 10u }
|
||||
ast::ty_u32. { 11u } ast::ty_u64. { 12u }
|
||||
ast::ty_u { 8u } ast::ty_u8 { 9u } ast::ty_u16 { 10u }
|
||||
ast::ty_u32 { 11u } ast::ty_u64 { 12u }
|
||||
}
|
||||
}
|
||||
ty_float(t) {
|
||||
alt t { ast::ty_f. { 13u } ast::ty_f32. { 14u } ast::ty_f64. { 15u } }
|
||||
alt t { ast::ty_f { 13u } ast::ty_f32 { 14u } ast::ty_f64 { 15u } }
|
||||
}
|
||||
ty_str. { ret 17u; }
|
||||
ty_str { ret 17u; }
|
||||
ty_tag(did, tys) {
|
||||
let h = hash_def(18u, did);
|
||||
for typ: t in tys { h += (h << 5u) + typ; }
|
||||
@ -1391,9 +1391,9 @@ fn hash_type_structure(st: sty) -> uint {
|
||||
ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); }
|
||||
ty_var(v) { ret hash_uint(30u, v as uint); }
|
||||
ty_param(pid, _) { ret hash_uint(31u, pid); }
|
||||
ty_type. { ret 32u; }
|
||||
ty_type { ret 32u; }
|
||||
ty_native(did) { ret hash_def(33u, did); }
|
||||
ty_bot. { ret 34u; }
|
||||
ty_bot { ret 34u; }
|
||||
ty_ptr(mt) { ret hash_subty(35u, mt.ty); }
|
||||
ty_res(did, sub, tps) {
|
||||
let h = hash_subty(hash_def(18u, did), sub);
|
||||
@ -1405,16 +1405,16 @@ fn hash_type_structure(st: sty) -> uint {
|
||||
ret h;
|
||||
}
|
||||
ty_uniq(mt) { ret hash_subty(37u, mt.ty); }
|
||||
ty_send_type. { ret 38u; }
|
||||
ty_send_type { ret 38u; }
|
||||
ty_named(t, name) { (str::hash(*name) << 5u) + hash_subty(39u, t) }
|
||||
ty_iface(did, tys) {
|
||||
let h = hash_def(40u, did);
|
||||
for typ: t in tys { h = hash_subty(h, typ); }
|
||||
ret h;
|
||||
}
|
||||
ty_opaque_closure_ptr(ck_block.) { ret 41u; }
|
||||
ty_opaque_closure_ptr(ck_box.) { ret 42u; }
|
||||
ty_opaque_closure_ptr(ck_uniq.) { ret 43u; }
|
||||
ty_opaque_closure_ptr(ck_block) { ret 41u; }
|
||||
ty_opaque_closure_ptr(ck_box) { ret 42u; }
|
||||
ty_opaque_closure_ptr(ck_uniq) { ret 43u; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1425,8 +1425,8 @@ fn arg_eq<T>(eq: block(T, T) -> bool,
|
||||
b: @sp_constr_arg<T>)
|
||||
-> bool {
|
||||
alt a.node {
|
||||
ast::carg_base. {
|
||||
alt b.node { ast::carg_base. { ret true; } _ { ret false; } }
|
||||
ast::carg_base {
|
||||
alt b.node { ast::carg_base { ret true; } _ { ret false; } }
|
||||
}
|
||||
ast::carg_ident(s) {
|
||||
alt b.node { ast::carg_ident(t) { ret eq(s, t); } _ { ret false; } }
|
||||
@ -1469,7 +1469,7 @@ fn node_id_to_ty_param_substs_opt_and_ty(cx: ctxt, id: ast::node_id) ->
|
||||
ty_param_substs_opt_and_ty {
|
||||
// Pull out the node type table.
|
||||
alt smallintmap::find(*cx.node_types, id as uint) {
|
||||
none. {
|
||||
none {
|
||||
cx.sess.bug("node_id_to_ty_param_substs_opt_and_ty() called on " +
|
||||
"an untyped node (" + int::to_str(id, 10u) +
|
||||
")");
|
||||
@ -1484,7 +1484,7 @@ fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
||||
|
||||
fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> [t] {
|
||||
alt node_id_to_ty_param_substs_opt_and_ty(cx, id).substs {
|
||||
none. { ret []; }
|
||||
none { ret []; }
|
||||
some(tps) { ret tps; }
|
||||
}
|
||||
}
|
||||
@ -1494,19 +1494,19 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
|
||||
}
|
||||
|
||||
|
||||
// Returns a type with type parameter substitutions performed if applicable.
|
||||
// Returns a type with type parameter substitutions performed if applicable
|
||||
fn ty_param_substs_opt_and_ty_to_monotype(cx: ctxt,
|
||||
tpot: ty_param_substs_opt_and_ty) ->
|
||||
t {
|
||||
alt tpot.substs {
|
||||
none. { ret tpot.ty; }
|
||||
none { ret tpot.ty; }
|
||||
some(tps) { ret substitute_type_params(cx, tps, tpot.ty); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Returns the type of an annotation, with type parameter substitutions
|
||||
// performed if applicable.
|
||||
// performed if applicable
|
||||
fn node_id_to_monotype(cx: ctxt, id: ast::node_id) -> t {
|
||||
let tpot = node_id_to_ty_param_substs_opt_and_ty(cx, id);
|
||||
ret ty_param_substs_opt_and_ty_to_monotype(cx, tpot);
|
||||
@ -1643,7 +1643,7 @@ fn expr_has_ty_params(cx: ctxt, expr: @ast::expr) -> bool {
|
||||
fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool {
|
||||
alt e.node {
|
||||
ast::expr_path(_) | ast::expr_index(_, _) |
|
||||
ast::expr_unary(ast::deref., _) { true }
|
||||
ast::expr_unary(ast::deref, _) { true }
|
||||
ast::expr_field(base, ident, _) { !method_map.contains_key(e.id) }
|
||||
_ { false }
|
||||
}
|
||||
@ -1771,15 +1771,15 @@ mod unify {
|
||||
|
||||
|
||||
alt smallintmap::find(vb.types, root_a) {
|
||||
none. {
|
||||
none {
|
||||
alt smallintmap::find(vb.types, root_b) {
|
||||
none. { ufind::union(vb.sets, set_a, set_b); ret unres_ok; }
|
||||
none { ufind::union(vb.sets, set_a, set_b); ret unres_ok; }
|
||||
some(t_b) { replace_type(vb, t_b); ret unres_ok; }
|
||||
}
|
||||
}
|
||||
some(t_a) {
|
||||
alt smallintmap::find(vb.types, root_b) {
|
||||
none. { replace_type(vb, t_a); ret unres_ok; }
|
||||
none { replace_type(vb, t_a); ret unres_ok; }
|
||||
some(t_b) {
|
||||
alt unify_step(cx, t_a, t_b, variance) {
|
||||
ures_ok(t_c) { replace_type(vb, t_c); ret unres_ok; }
|
||||
@ -1818,7 +1818,7 @@ mod unify {
|
||||
rs { ret rs; }
|
||||
}
|
||||
}
|
||||
none. {/* fall through */ }
|
||||
none {/* fall through */ }
|
||||
}
|
||||
smallintmap::insert::<t>(vb.types, root, result_type);
|
||||
ret ures_ok(typ);
|
||||
@ -1866,8 +1866,8 @@ mod unify {
|
||||
for a: @ty_constr_arg in expected.node.args {
|
||||
actual = actual_constr.node.args[i];
|
||||
alt a.node {
|
||||
carg_base. {
|
||||
alt actual.node { carg_base. { } _ { ret err_res; } }
|
||||
carg_base {
|
||||
alt actual.node { carg_base { } _ { ret err_res; } }
|
||||
}
|
||||
carg_lit(l) {
|
||||
alt actual.node {
|
||||
@ -1895,7 +1895,7 @@ mod unify {
|
||||
// If you're unifying on something mutable then we have to
|
||||
// be invariant on the inner type
|
||||
let newvariance = alt expected {
|
||||
ast::mut. {
|
||||
ast::mut {
|
||||
variance_transform(variance, invariant)
|
||||
}
|
||||
_ {
|
||||
@ -1929,9 +1929,9 @@ mod unify {
|
||||
// subtype).
|
||||
fn sub_proto(p_sub: ast::proto, p_sup: ast::proto) -> bool {
|
||||
ret alt (p_sub, p_sup) {
|
||||
(_, ast::proto_any.) { true }
|
||||
(_, ast::proto_block.) { true } /* NDM temporary */
|
||||
(ast::proto_bare., _) { true }
|
||||
(_, ast::proto_any) { true }
|
||||
(_, ast::proto_block) { true } /* NDM temporary */
|
||||
(ast::proto_bare, _) { true }
|
||||
|
||||
// Equal prototypes are always subprotos:
|
||||
(_, _) { p_sub == p_sup }
|
||||
@ -1939,9 +1939,9 @@ mod unify {
|
||||
}
|
||||
|
||||
ret alt variance {
|
||||
invariant. if e_proto == a_proto { none }
|
||||
covariant. if sub_proto(a_proto, e_proto) { none }
|
||||
contravariant. if sub_proto(e_proto, a_proto) { none }
|
||||
invariant if e_proto == a_proto { none }
|
||||
covariant if sub_proto(a_proto, e_proto) { none }
|
||||
contravariant if sub_proto(e_proto, a_proto) { none }
|
||||
_ { some(ures_err(terr_mismatch)) }
|
||||
};
|
||||
}
|
||||
@ -1981,7 +1981,7 @@ mod unify {
|
||||
-> result {
|
||||
alt unify_fn_proto(e_f.proto, a_f.proto, variance) {
|
||||
some(err) { ret err; }
|
||||
none. { /* fall through */ }
|
||||
none { /* fall through */ }
|
||||
}
|
||||
|
||||
if a_f.ret_style != ast::noreturn && a_f.ret_style != e_f.ret_style {
|
||||
@ -2032,7 +2032,7 @@ mod unify {
|
||||
if vid as uint >= ufind::set_count(vb.sets) { ret fix_err(vid); }
|
||||
let root_id = ufind::find(vb.sets, vid as uint);
|
||||
alt smallintmap::find::<t>(vb.types, root_id) {
|
||||
none. { ret fix_err(vid); }
|
||||
none { ret fix_err(vid); }
|
||||
some(rt) { ret fix_ok(rt); }
|
||||
}
|
||||
}
|
||||
@ -2058,25 +2058,25 @@ mod unify {
|
||||
// read the paper (yet).
|
||||
fn variance_transform(a: variance, b: variance) -> variance {
|
||||
alt a {
|
||||
covariant. {
|
||||
covariant {
|
||||
alt b {
|
||||
covariant. { covariant }
|
||||
contravariant. { contravariant }
|
||||
invariant. { invariant }
|
||||
covariant { covariant }
|
||||
contravariant { contravariant }
|
||||
invariant { invariant }
|
||||
}
|
||||
}
|
||||
contravariant. {
|
||||
contravariant {
|
||||
alt b {
|
||||
covariant. { contravariant }
|
||||
contravariant. { covariant }
|
||||
invariant. { invariant }
|
||||
covariant { contravariant }
|
||||
contravariant { covariant }
|
||||
invariant { invariant }
|
||||
}
|
||||
}
|
||||
invariant. {
|
||||
invariant {
|
||||
alt b {
|
||||
covariant. { invariant }
|
||||
contravariant. { invariant }
|
||||
invariant. { invariant }
|
||||
covariant { invariant }
|
||||
contravariant { invariant }
|
||||
invariant { invariant }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2108,7 +2108,7 @@ mod unify {
|
||||
if expected == actual { ret ures_ok(expected); }
|
||||
|
||||
// Stage 1: Handle the cases in which one side or another is a type
|
||||
// variable.
|
||||
// variable
|
||||
|
||||
alt struct(cx.tcx, actual) {
|
||||
// If the RHS is a variable type, then just do the
|
||||
@ -2119,7 +2119,7 @@ mod unify {
|
||||
ty::ty_var(expected_id) {
|
||||
let expected_n = expected_id as uint;
|
||||
alt union(cx, expected_n, actual_n, variance) {
|
||||
unres_ok. {/* fall through */ }
|
||||
unres_ok {/* fall through */ }
|
||||
unres_err(t_e) { ret ures_err(t_e); }
|
||||
}
|
||||
}
|
||||
@ -2152,17 +2152,17 @@ mod unify {
|
||||
// Stage 2: Handle all other cases.
|
||||
|
||||
alt struct(cx.tcx, actual) {
|
||||
ty::ty_bot. { ret ures_ok(expected); }
|
||||
ty::ty_bot { ret ures_ok(expected); }
|
||||
_ {/* fall through */ }
|
||||
}
|
||||
alt struct(cx.tcx, expected) {
|
||||
ty::ty_nil. { ret struct_cmp(cx, expected, actual); }
|
||||
ty::ty_nil { ret struct_cmp(cx, expected, actual); }
|
||||
// _|_ unifies with anything
|
||||
ty::ty_bot. {
|
||||
ty::ty_bot {
|
||||
ret ures_ok(actual);
|
||||
}
|
||||
ty::ty_bool. | ty::ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty::ty_str. | ty::ty_type. | ty::ty_send_type. {
|
||||
ty::ty_bool | ty::ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty::ty_str | ty::ty_type | ty::ty_send_type {
|
||||
ret struct_cmp(cx, expected, actual);
|
||||
}
|
||||
ty::ty_native(ex_id) {
|
||||
@ -2216,7 +2216,7 @@ mod unify {
|
||||
ty::ty_box(actual_mt) {
|
||||
let (mutt, var) = alt unify_mut(
|
||||
expected_mt.mut, actual_mt.mut, variance) {
|
||||
none. { ret ures_err(terr_box_mutability); }
|
||||
none { ret ures_err(terr_box_mutability); }
|
||||
some(mv) { mv }
|
||||
};
|
||||
let result = unify_step(
|
||||
@ -2237,7 +2237,7 @@ mod unify {
|
||||
ty::ty_uniq(actual_mt) {
|
||||
let (mutt, var) = alt unify_mut(
|
||||
expected_mt.mut, actual_mt.mut, variance) {
|
||||
none. { ret ures_err(terr_box_mutability); }
|
||||
none { ret ures_err(terr_box_mutability); }
|
||||
some(mv) { mv }
|
||||
};
|
||||
let result = unify_step(
|
||||
@ -2258,7 +2258,7 @@ mod unify {
|
||||
ty::ty_vec(actual_mt) {
|
||||
let (mutt, var) = alt unify_mut(
|
||||
expected_mt.mut, actual_mt.mut, variance) {
|
||||
none. { ret ures_err(terr_vec_mutability); }
|
||||
none { ret ures_err(terr_vec_mutability); }
|
||||
some(mv) { mv }
|
||||
};
|
||||
let result = unify_step(
|
||||
@ -2279,7 +2279,7 @@ mod unify {
|
||||
ty::ty_ptr(actual_mt) {
|
||||
let (mutt, var) = alt unify_mut(
|
||||
expected_mt.mut, actual_mt.mut, variance) {
|
||||
none. { ret ures_err(terr_vec_mutability); }
|
||||
none { ret ures_err(terr_vec_mutability); }
|
||||
some(mv) { mv }
|
||||
};
|
||||
let result = unify_step(
|
||||
@ -2344,7 +2344,7 @@ mod unify {
|
||||
let (mutt, var) = alt unify_mut(
|
||||
expected_field.mt.mut, actual_field.mt.mut, variance)
|
||||
{
|
||||
none. { ret ures_err(terr_record_mutability); }
|
||||
none { ret ures_err(terr_record_mutability); }
|
||||
some(mv) { mv }
|
||||
};
|
||||
if !str::eq(expected_field.ident, actual_field.ident) {
|
||||
@ -2462,7 +2462,7 @@ mod unify {
|
||||
}
|
||||
let typespec;
|
||||
alt smallintmap::find::<t>(vb.types, i) {
|
||||
none. { typespec = ""; }
|
||||
none { typespec = ""; }
|
||||
some(typ) { typespec = " =" + ty_to_str(tcx, typ); }
|
||||
}
|
||||
#error("set %u:%s%s", i, typespec, sets);
|
||||
@ -2486,7 +2486,7 @@ mod unify {
|
||||
}
|
||||
let root_id = ufind::find(vb.sets, vid as uint);
|
||||
alt smallintmap::find::<t>(vb.types, root_id) {
|
||||
none. { *unresolved = some(vid); ret ty::mk_var(tcx, vid); }
|
||||
none { *unresolved = some(vid); ret ty::mk_var(tcx, vid); }
|
||||
some(rt) {
|
||||
if occurs_check_fails(tcx, sp, vid, rt) {
|
||||
// Return the type unchanged, so we can error out
|
||||
@ -2505,7 +2505,7 @@ mod unify {
|
||||
typ);
|
||||
let ur = *unresolved;
|
||||
alt ur {
|
||||
none. { ret fix_ok(rty); }
|
||||
none { ret fix_ok(rty); }
|
||||
some(var_id) { ret fix_err(var_id); }
|
||||
}
|
||||
}
|
||||
@ -2514,7 +2514,7 @@ mod unify {
|
||||
if vid as uint >= ufind::set_count(vb.sets) { ret fix_err(vid); }
|
||||
let root_id = ufind::find(vb.sets, vid as uint);
|
||||
alt smallintmap::find::<t>(vb.types, root_id) {
|
||||
none. { ret fix_err(vid); }
|
||||
none { ret fix_err(vid); }
|
||||
some(rt) { ret fixup_vars(tcx, sp, vb, rt); }
|
||||
}
|
||||
}
|
||||
@ -2529,19 +2529,19 @@ fn same_type(cx: ctxt, a: t, b: t) -> bool {
|
||||
|
||||
fn type_err_to_str(err: ty::type_err) -> str {
|
||||
alt err {
|
||||
terr_mismatch. { ret "types differ"; }
|
||||
terr_mismatch { ret "types differ"; }
|
||||
terr_ret_style_mismatch(expect, actual) {
|
||||
fn to_str(s: ast::ret_style) -> str {
|
||||
alt s {
|
||||
ast::noreturn. { "non-returning" }
|
||||
ast::noreturn { "non-returning" }
|
||||
ast::return_val. { "return-by-value" }
|
||||
}
|
||||
}
|
||||
ret to_str(actual) + " function found where " + to_str(expect) +
|
||||
" function was expected";
|
||||
}
|
||||
terr_box_mutability. { ret "boxed values differ in mutability"; }
|
||||
terr_vec_mutability. { ret "vectors differ in mutability"; }
|
||||
terr_box_mutability { ret "boxed values differ in mutability"; }
|
||||
terr_vec_mutability { ret "vectors differ in mutability"; }
|
||||
terr_tuple_size(e_sz, a_sz) {
|
||||
ret "expected a tuple with " + uint::to_str(e_sz, 10u) +
|
||||
" elements but found one with " + uint::to_str(a_sz, 10u) +
|
||||
@ -2552,12 +2552,12 @@ fn type_err_to_str(err: ty::type_err) -> str {
|
||||
" fields but found one with " + uint::to_str(a_sz, 10u) +
|
||||
" fields";
|
||||
}
|
||||
terr_record_mutability. { ret "record elements differ in mutability"; }
|
||||
terr_record_mutability { ret "record elements differ in mutability"; }
|
||||
terr_record_fields(e_fld, a_fld) {
|
||||
ret "expected a record with field '" + e_fld +
|
||||
"' but found one with field '" + a_fld + "'";
|
||||
}
|
||||
terr_arg_count. { ret "incorrect number of function parameters"; }
|
||||
terr_arg_count { ret "incorrect number of function parameters"; }
|
||||
terr_mode_mismatch(e_mode, a_mode) {
|
||||
ret "expected argument mode " + mode_str(e_mode) + " but found " +
|
||||
mode_str(a_mode);
|
||||
@ -2701,7 +2701,7 @@ fn lookup_item_type(cx: ctxt, did: ast::def_id) -> ty_param_bounds_and_ty {
|
||||
}
|
||||
alt cx.tcache.find(did) {
|
||||
some(tpt) { ret tpt; }
|
||||
none. {
|
||||
none {
|
||||
let tyt = csearch::get_type(cx, did);
|
||||
cx.tcache.insert(did, tyt);
|
||||
ret tyt;
|
||||
@ -2735,40 +2735,40 @@ fn is_binopable(cx: ctxt, ty: t, op: ast::binop) -> bool {
|
||||
|
||||
fn opcat(op: ast::binop) -> int {
|
||||
alt op {
|
||||
ast::add. { opcat_add }
|
||||
ast::subtract. { opcat_sub }
|
||||
ast::mul. { opcat_mult }
|
||||
ast::div. { opcat_mult }
|
||||
ast::rem. { opcat_mult }
|
||||
ast::and. { opcat_logic }
|
||||
ast::or. { opcat_logic }
|
||||
ast::bitxor. { opcat_bit }
|
||||
ast::bitand. { opcat_bit }
|
||||
ast::bitor. { opcat_bit }
|
||||
ast::lsl. { opcat_shift }
|
||||
ast::lsr. { opcat_shift }
|
||||
ast::asr. { opcat_shift }
|
||||
ast::eq. { opcat_eq }
|
||||
ast::ne. { opcat_eq }
|
||||
ast::lt. { opcat_rel }
|
||||
ast::le. { opcat_rel }
|
||||
ast::ge. { opcat_rel }
|
||||
ast::gt. { opcat_rel }
|
||||
ast::add { opcat_add }
|
||||
ast::subtract { opcat_sub }
|
||||
ast::mul { opcat_mult }
|
||||
ast::div { opcat_mult }
|
||||
ast::rem { opcat_mult }
|
||||
ast::and { opcat_logic }
|
||||
ast::or { opcat_logic }
|
||||
ast::bitxor { opcat_bit }
|
||||
ast::bitand { opcat_bit }
|
||||
ast::bitor { opcat_bit }
|
||||
ast::lsl { opcat_shift }
|
||||
ast::lsr { opcat_shift }
|
||||
ast::asr { opcat_shift }
|
||||
ast::eq { opcat_eq }
|
||||
ast::ne { opcat_eq }
|
||||
ast::lt { opcat_rel }
|
||||
ast::le { opcat_rel }
|
||||
ast::ge { opcat_rel }
|
||||
ast::gt { opcat_rel }
|
||||
}
|
||||
}
|
||||
|
||||
fn tycat(cx: ctxt, ty: t) -> int {
|
||||
alt struct(cx, ty) {
|
||||
ty_bool. { tycat_bool }
|
||||
ty_bool { tycat_bool }
|
||||
ty_int(_) { tycat_int }
|
||||
ty_uint(_) { tycat_int }
|
||||
ty_float(_) { tycat_float }
|
||||
ty_str. { tycat_str }
|
||||
ty_str { tycat_str }
|
||||
ty_vec(_) { tycat_vec }
|
||||
ty_rec(_) { tycat_struct }
|
||||
ty_tup(_) { tycat_struct }
|
||||
ty_tag(_, _) { tycat_struct }
|
||||
ty_bot. { tycat_bot }
|
||||
ty_bot { tycat_bot }
|
||||
_ { tycat_other }
|
||||
}
|
||||
}
|
||||
@ -2798,7 +2798,7 @@ fn is_binopable(cx: ctxt, ty: t, op: ast::binop) -> bool {
|
||||
fn ast_constr_to_constr<T>(tcx: ty::ctxt, c: @ast::constr_general<T>) ->
|
||||
@ty::constr_general<T> {
|
||||
alt tcx.def_map.find(c.node.id) {
|
||||
some(ast::def_fn(pred_id, ast::pure_fn.)) {
|
||||
some(ast::def_fn(pred_id, ast::pure_fn)) {
|
||||
ret @ast_util::respan(c.span,
|
||||
{path: c.node.path,
|
||||
args: c.node.args,
|
||||
|
@ -218,7 +218,7 @@ fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
|
||||
fn default_arg_mode_for_ty(tcx: ty::ctxt, m: ast::mode,
|
||||
ty: ty::t) -> ast::mode {
|
||||
alt m {
|
||||
ast::mode_infer. {
|
||||
ast::mode_infer {
|
||||
alt ty::struct(tcx, ty) {
|
||||
ty::ty_var(_) { ast::mode_infer }
|
||||
_ {
|
||||
@ -237,8 +237,8 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
|
||||
fn getter(tcx: ty::ctxt, mode: mode, id: ast::def_id)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
alt mode {
|
||||
m_check. | m_check_tyvar(_) { ty::lookup_item_type(tcx, id) }
|
||||
m_collect. {
|
||||
m_check | m_check_tyvar(_) { ty::lookup_item_type(tcx, id) }
|
||||
m_collect {
|
||||
if id.crate != ast::local_crate { csearch::get_type(tcx, id) }
|
||||
else {
|
||||
alt tcx.items.find(id.node) {
|
||||
@ -260,13 +260,13 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
|
||||
}
|
||||
alt tcx.ast_ty_to_ty_cache.find(ast_ty) {
|
||||
some(some(ty)) { ret ty; }
|
||||
some(none.) {
|
||||
some(none) {
|
||||
tcx.sess.span_fatal(ast_ty.span,
|
||||
"illegal recursive type \
|
||||
insert a tag in the cycle, \
|
||||
if this is desired)");
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
} /* go on */
|
||||
|
||||
tcx.ast_ty_to_ty_cache.insert(ast_ty, none::<ty::t>);
|
||||
@ -299,13 +299,13 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
|
||||
}
|
||||
let typ;
|
||||
alt ast_ty.node {
|
||||
ast::ty_nil. { typ = ty::mk_nil(tcx); }
|
||||
ast::ty_bot. { typ = ty::mk_bot(tcx); }
|
||||
ast::ty_bool. { typ = ty::mk_bool(tcx); }
|
||||
ast::ty_nil { typ = ty::mk_nil(tcx); }
|
||||
ast::ty_bot { typ = ty::mk_bot(tcx); }
|
||||
ast::ty_bool { typ = ty::mk_bool(tcx); }
|
||||
ast::ty_int(it) { typ = ty::mk_mach_int(tcx, it); }
|
||||
ast::ty_uint(uit) { typ = ty::mk_mach_uint(tcx, uit); }
|
||||
ast::ty_float(ft) { typ = ty::mk_mach_float(tcx, ft); }
|
||||
ast::ty_str. { typ = ty::mk_str(tcx); }
|
||||
ast::ty_str { typ = ty::mk_str(tcx); }
|
||||
ast::ty_box(mt) {
|
||||
typ = ty::mk_box(tcx, ast_mt_to_mt(tcx, mode, mt));
|
||||
}
|
||||
@ -385,7 +385,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
|
||||
ast::item_ty(t, tps) {
|
||||
alt tcx.tcache.find(local_def(it.id)) {
|
||||
some(tpt) { ret tpt; }
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
// Tell ast_ty_to_ty() that we want to perform a recursive
|
||||
// call to resolve any named types.
|
||||
@ -434,10 +434,10 @@ fn ty_of_native_item(tcx: ty::ctxt, mode: mode, it: @ast::native_item)
|
||||
ret ty_of_native_fn_decl(tcx, mode, fn_decl, params,
|
||||
ast_util::local_def(it.id));
|
||||
}
|
||||
ast::native_item_ty. {
|
||||
ast::native_item_ty {
|
||||
alt tcx.tcache.find(local_def(it.id)) {
|
||||
some(tpt) { ret tpt; }
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
let t = ty::mk_native(tcx, ast_util::local_def(it.id));
|
||||
let t = ty::mk_named(tcx, t, @it.ident);
|
||||
@ -491,12 +491,12 @@ fn ty_param_bounds(tcx: ty::ctxt, mode: mode, params: [ast::ty_param])
|
||||
for param in params {
|
||||
result += [alt tcx.ty_param_bounds.find(param.id) {
|
||||
some(bs) { bs }
|
||||
none. {
|
||||
none {
|
||||
let bounds = [];
|
||||
for b in *param.bounds {
|
||||
bounds += [alt b {
|
||||
ast::bound_send. { ty::bound_send }
|
||||
ast::bound_copy. { ty::bound_copy }
|
||||
ast::bound_send { ty::bound_send }
|
||||
ast::bound_copy { ty::bound_copy }
|
||||
ast::bound_iface(t) {
|
||||
let ity = ast_ty_to_ty(tcx, mode, t);
|
||||
alt ty::struct(tcx, ity) {
|
||||
@ -545,7 +545,7 @@ fn ast_ty_to_ty_crate_infer(ccx: @crate_ctxt, &&ast_ty: @ast::ty) ->
|
||||
}
|
||||
|
||||
|
||||
// Functions that write types into the node type table.
|
||||
// Functions that write types into the node type table
|
||||
mod write {
|
||||
fn inner(ntt: node_type_table, node_id: ast::node_id,
|
||||
tpot: ty_param_substs_opt_and_ty) {
|
||||
@ -713,7 +713,7 @@ mod collect {
|
||||
compare_impl_method(cx.tcx, t.span, m,
|
||||
vec::len(tps), if_m, tys);
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
cx.tcx.sess.span_err(t.span, "missing method `" +
|
||||
if_m.ident + "`");
|
||||
}
|
||||
@ -773,7 +773,7 @@ mod collect {
|
||||
// table.
|
||||
let tpt = ty_of_native_item(cx.tcx, m_collect, i);
|
||||
alt i.node {
|
||||
ast::native_item_ty. {
|
||||
ast::native_item_ty {
|
||||
// FIXME: Native types have no annotation. Should they? --pcw
|
||||
}
|
||||
ast::native_item_fn(_, _) {
|
||||
@ -975,17 +975,17 @@ mod writeback {
|
||||
let new_ty =
|
||||
alt resolve_type_vars_in_type(fcx, sp, tpot.ty) {
|
||||
some(t) { t }
|
||||
none. { wbcx.success = false; ret }
|
||||
none { wbcx.success = false; ret }
|
||||
};
|
||||
let new_substs_opt;
|
||||
alt tpot.substs {
|
||||
none. { new_substs_opt = none; }
|
||||
none { new_substs_opt = none; }
|
||||
some(substs) {
|
||||
let new_substs: [ty::t] = [];
|
||||
for subst: ty::t in substs {
|
||||
alt resolve_type_vars_in_type(fcx, sp, subst) {
|
||||
some(t) { new_substs += [t]; }
|
||||
none. { wbcx.success = false; ret; }
|
||||
none { wbcx.success = false; ret; }
|
||||
}
|
||||
}
|
||||
new_substs_opt = some(new_substs);
|
||||
@ -1095,7 +1095,7 @@ fn gather_locals(ccx: @crate_ctxt,
|
||||
old_fcx: option::t<@fn_ctxt>) -> gather_result {
|
||||
let {vb: vb, locals: locals, nvi: nvi} =
|
||||
alt old_fcx {
|
||||
none. {
|
||||
none {
|
||||
{vb: ty::unify::mk_var_bindings(),
|
||||
locals: new_int_hash::<int>(),
|
||||
nvi: @mutable 0}
|
||||
@ -1113,7 +1113,7 @@ fn gather_locals(ccx: @crate_ctxt,
|
||||
let var_id = next_var_id();
|
||||
locals.insert(nid, var_id);
|
||||
alt ty_opt {
|
||||
none. {/* nothing to do */ }
|
||||
none {/* nothing to do */ }
|
||||
some(typ) {
|
||||
ty::unify::unify(ty::mk_var(tcx, var_id), typ,
|
||||
ty::unify::in_bindings(vb), tcx);
|
||||
@ -1171,7 +1171,7 @@ fn check_lit(ccx: @crate_ctxt, lit: @ast::lit) -> ty::t {
|
||||
ast::lit_int(_, t) { ty::mk_mach_int(ccx.tcx, t) }
|
||||
ast::lit_uint(_, t) { ty::mk_mach_uint(ccx.tcx, t) }
|
||||
ast::lit_float(_, t) { ty::mk_mach_float(ccx.tcx, t) }
|
||||
ast::lit_nil. { ty::mk_nil(ccx.tcx) }
|
||||
ast::lit_nil { ty::mk_nil(ccx.tcx) }
|
||||
ast::lit_bool(_) { ty::mk_bool(ccx.tcx) }
|
||||
}
|
||||
}
|
||||
@ -1185,7 +1185,7 @@ fn valid_range_bounds(from: @ast::expr, to: @ast::expr) -> bool {
|
||||
fn check_pat(fcx: @fn_ctxt, map: pat_util::pat_id_map, pat: @ast::pat,
|
||||
expected: ty::t) {
|
||||
alt normalize_pat(fcx.ccx.tcx, pat).node {
|
||||
ast::pat_wild. {
|
||||
ast::pat_wild {
|
||||
alt structure_of(fcx, pat.span, expected) {
|
||||
ty::ty_tag(_, expected_tps) {
|
||||
let path_tpt = {substs: some(expected_tps),
|
||||
@ -1337,7 +1337,7 @@ fn check_pat(fcx: @fn_ctxt, map: pat_util::pat_id_map, pat: @ast::pat,
|
||||
for f: ast::field_pat in fields {
|
||||
alt vec::find(ex_fields, bind matches(f.ident, _)) {
|
||||
some(field) { check_pat(fcx, map, f.pat, field.mt.ty); }
|
||||
none. {
|
||||
none {
|
||||
fcx.ccx.tcx.sess.span_fatal(pat.span,
|
||||
#fmt["mismatched types: did not \
|
||||
expect a record with a field `%s`",
|
||||
@ -1402,7 +1402,7 @@ fn check_pat(fcx: @fn_ctxt, map: pat_util::pat_id_map, pat: @ast::pat,
|
||||
|
||||
fn require_unsafe(sess: session, f_purity: ast::purity, sp: span) {
|
||||
alt f_purity {
|
||||
ast::unsafe_fn. { ret; }
|
||||
ast::unsafe_fn { ret; }
|
||||
_ {
|
||||
sess.span_err(
|
||||
sp,
|
||||
@ -1413,9 +1413,9 @@ fn require_unsafe(sess: session, f_purity: ast::purity, sp: span) {
|
||||
|
||||
fn require_impure(sess: session, f_purity: ast::purity, sp: span) {
|
||||
alt f_purity {
|
||||
ast::unsafe_fn. { ret; }
|
||||
ast::impure_fn. { ret; }
|
||||
ast::pure_fn. {
|
||||
ast::unsafe_fn { ret; }
|
||||
ast::impure_fn { ret; }
|
||||
ast::pure_fn {
|
||||
sess.span_err(sp, "Found impure expression in pure function decl");
|
||||
}
|
||||
}
|
||||
@ -1424,11 +1424,11 @@ fn require_impure(sess: session, f_purity: ast::purity, sp: span) {
|
||||
fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
|
||||
callee: @ast::expr, sp: span) {
|
||||
alt caller_purity {
|
||||
ast::unsafe_fn. { ret; }
|
||||
ast::impure_fn. {
|
||||
ast::unsafe_fn { ret; }
|
||||
ast::impure_fn {
|
||||
alt ccx.tcx.def_map.find(callee.id) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn.)) |
|
||||
some(ast::def_native_fn(_, ast::unsafe_fn.)) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn)) |
|
||||
some(ast::def_native_fn(_, ast::unsafe_fn)) {
|
||||
ccx.tcx.sess.span_err(
|
||||
sp,
|
||||
"safe function calls function marked unsafe");
|
||||
@ -1438,10 +1438,10 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
|
||||
}
|
||||
ret;
|
||||
}
|
||||
ast::pure_fn. {
|
||||
ast::pure_fn {
|
||||
alt ccx.tcx.def_map.find(callee.id) {
|
||||
some(ast::def_fn(_, ast::pure_fn.)) |
|
||||
some(ast::def_native_fn(_, ast::pure_fn.)) |
|
||||
some(ast::def_fn(_, ast::pure_fn)) |
|
||||
some(ast::def_native_fn(_, ast::pure_fn)) |
|
||||
some(ast::def_variant(_, _)) { ret; }
|
||||
_ {
|
||||
ccx.tcx.sess.span_err
|
||||
@ -1677,7 +1677,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
arg_tys[i].ty);
|
||||
}
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
@ -1772,7 +1772,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
};
|
||||
(if_t, thn_bot & els_bot)
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
check_block_no_value(fcx, thn);
|
||||
(ty::mk_nil(fcx.ccx.tcx), false)
|
||||
}
|
||||
@ -1814,12 +1814,12 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
|
||||
let t =
|
||||
alt binop {
|
||||
ast::eq. { ty::mk_bool(tcx) }
|
||||
ast::lt. { ty::mk_bool(tcx) }
|
||||
ast::le. { ty::mk_bool(tcx) }
|
||||
ast::ne. { ty::mk_bool(tcx) }
|
||||
ast::ge. { ty::mk_bool(tcx) }
|
||||
ast::gt. { ty::mk_bool(tcx) }
|
||||
ast::eq { ty::mk_bool(tcx) }
|
||||
ast::lt { ty::mk_bool(tcx) }
|
||||
ast::le { ty::mk_bool(tcx) }
|
||||
ast::ne { ty::mk_bool(tcx) }
|
||||
ast::ge { ty::mk_bool(tcx) }
|
||||
ast::gt { ty::mk_bool(tcx) }
|
||||
_ { lhs_t }
|
||||
};
|
||||
write::ty_only_fixup(fcx, id, t);
|
||||
@ -1832,7 +1832,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
ast::uniq(mut) {
|
||||
oper_t = ty::mk_uniq(tcx, {ty: oper_t, mut: mut});
|
||||
}
|
||||
ast::deref. {
|
||||
ast::deref {
|
||||
alt structure_of(fcx, expr.span, oper_t) {
|
||||
ty::ty_box(inner) { oper_t = inner.ty; }
|
||||
ty::ty_uniq(inner) { oper_t = inner.ty; }
|
||||
@ -1861,7 +1861,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
}
|
||||
}
|
||||
}
|
||||
ast::not. {
|
||||
ast::not {
|
||||
if !type_is_integral(fcx, oper.span, oper_t) &&
|
||||
structure_of(fcx, oper.span, oper_t) != ty::ty_bool {
|
||||
tcx.sess.span_err(expr.span,
|
||||
@ -1870,7 +1870,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
ty_to_str(tcx, oper_t)]);
|
||||
}
|
||||
}
|
||||
ast::neg. {
|
||||
ast::neg {
|
||||
oper_t = structurally_resolved_type(fcx, oper.span, oper_t);
|
||||
if !(ty::type_is_integral(tcx, oper_t) ||
|
||||
ty::type_is_fp(tcx, oper_t)) {
|
||||
@ -1892,7 +1892,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
write::ty_fixup(fcx, id, path_tpot);
|
||||
} else {
|
||||
// The definition doesn't take type parameters. If the programmer
|
||||
// supplied some, that's an error.
|
||||
// supplied some, that's an error
|
||||
if vec::len::<@ast::ty>(pth.node.types) > 0u {
|
||||
tcx.sess.span_fatal(expr.span,
|
||||
"this kind of value does not \
|
||||
@ -1905,17 +1905,17 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
ast::expr_fail(expr_opt) {
|
||||
bot = true;
|
||||
alt expr_opt {
|
||||
none. {/* do nothing */ }
|
||||
none {/* do nothing */ }
|
||||
some(e) { check_expr_with(fcx, e, ty::mk_str(tcx)); }
|
||||
}
|
||||
write::bot_ty(tcx, id);
|
||||
}
|
||||
ast::expr_break. { write::bot_ty(tcx, id); bot = true; }
|
||||
ast::expr_cont. { write::bot_ty(tcx, id); bot = true; }
|
||||
ast::expr_break { write::bot_ty(tcx, id); bot = true; }
|
||||
ast::expr_cont { write::bot_ty(tcx, id); bot = true; }
|
||||
ast::expr_ret(expr_opt) {
|
||||
bot = true;
|
||||
alt expr_opt {
|
||||
none. {
|
||||
none {
|
||||
let nil = ty::mk_nil(tcx);
|
||||
if !are_compatible(fcx, fcx.ret_ty, nil) {
|
||||
tcx.sess.span_err(expr.span,
|
||||
@ -1989,7 +1989,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
let ety = expr_ty(tcx, seq);
|
||||
alt structure_of(fcx, expr.span, ety) {
|
||||
ty::ty_vec(vec_elt_ty) { elt_ty = vec_elt_ty.ty; }
|
||||
ty::ty_str. { elt_ty = ty::mk_mach_uint(tcx, ast::ty_u8); }
|
||||
ty::ty_str { elt_ty = ty::mk_mach_uint(tcx, ast::ty_u8); }
|
||||
_ {
|
||||
tcx.sess.span_fatal(expr.span,
|
||||
"mismatched types: expected vector or string "
|
||||
@ -2026,7 +2026,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
for arm: ast::arm in arms {
|
||||
alt arm.guard {
|
||||
some(e) { check_expr_with(fcx, e, ty::mk_bool(tcx)); }
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
if !check_block(fcx, arm.body) { arm_non_bot = true; }
|
||||
let bty = block_ty(tcx, arm.body);
|
||||
@ -2065,7 +2065,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
let typ =
|
||||
alt b.node.expr {
|
||||
some(expr) { expr_ty(tcx, expr) }
|
||||
none. { ty::mk_nil(tcx) }
|
||||
none { ty::mk_nil(tcx) }
|
||||
};
|
||||
write::ty_only_fixup(fcx, id, typ);
|
||||
}
|
||||
@ -2103,7 +2103,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
while i < vec::len(args) {
|
||||
alt args[i] {
|
||||
some(_) {/* no-op */ }
|
||||
none. { out_args += [arg_tys[i]]; }
|
||||
none { out_args += [arg_tys[i]]; }
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
@ -2112,7 +2112,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
fn lower_bound_proto(proto: ast::proto) -> ast::proto {
|
||||
// FIXME: This is right for bare fns, possibly not others
|
||||
alt proto {
|
||||
ast::proto_bare. { ast::proto_box }
|
||||
ast::proto_bare { ast::proto_box }
|
||||
_ { proto }
|
||||
}
|
||||
}
|
||||
@ -2176,7 +2176,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
write::ty_only_fixup(fcx, id, typ);
|
||||
}
|
||||
ast::expr_rec(fields, base) {
|
||||
alt base { none. {/* no-op */ } some(b_0) { check_expr(fcx, b_0); } }
|
||||
alt base { none {/* no-op */ } some(b_0) { check_expr(fcx, b_0); } }
|
||||
let fields_t: [spanned<field>] = [];
|
||||
for f: ast::field in fields {
|
||||
bot |= check_expr(fcx, f.node.expr);
|
||||
@ -2189,7 +2189,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
{ident: f.node.ident, mt: expr_mt})];
|
||||
}
|
||||
alt base {
|
||||
none. {
|
||||
none {
|
||||
fn get_node(f: spanned<field>) -> field { f.node }
|
||||
let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node));
|
||||
write::ty_only_fixup(fcx, id, typ);
|
||||
@ -2279,7 +2279,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
}
|
||||
fcx.ccx.method_map.insert(id, origin);
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
let t_err = resolve_type_vars_if_possible(fcx, expr_t);
|
||||
let msg = #fmt["attempted access of field %s on type %s, but \
|
||||
no method implementation was found",
|
||||
@ -2303,7 +2303,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
}
|
||||
alt structure_of(fcx, expr.span, base_t) {
|
||||
ty::ty_vec(mt) { write::ty_only_fixup(fcx, id, mt.ty); }
|
||||
ty::ty_str. {
|
||||
ty::ty_str {
|
||||
let typ = ty::mk_mach_uint(tcx, ast::ty_u8);
|
||||
write::ty_only_fixup(fcx, id, typ);
|
||||
}
|
||||
@ -2427,7 +2427,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
||||
bot |= check_stmt(fcx, s);
|
||||
}
|
||||
alt blk.node.expr {
|
||||
none. { write::nil_ty(fcx.ccx.tcx, blk.node.id); }
|
||||
none { write::nil_ty(fcx.ccx.tcx, blk.node.id); }
|
||||
some(e) {
|
||||
if bot && !warned {
|
||||
fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression");
|
||||
@ -2490,7 +2490,7 @@ fn check_tag_variants(ccx: @crate_ctxt, _sp: span, vs: [ast::variant],
|
||||
// FIXME: issue #1417
|
||||
// Also, check_expr (from check_const pass) doesn't guarantee that
|
||||
// the expression in an form that eval_const_expr can handle, so
|
||||
// we may still get an internal compiler error.
|
||||
// we may still get an internal compiler error
|
||||
alt syntax::ast_util::eval_const_expr(e) {
|
||||
syntax::ast_util::const_int(val) {
|
||||
disr_val = val as int;
|
||||
@ -2530,7 +2530,7 @@ fn check_pred_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
|
||||
alt operator.node {
|
||||
ast::expr_path(oper_name) {
|
||||
alt fcx.ccx.tcx.def_map.find(operator.id) {
|
||||
some(ast::def_fn(_, ast::pure_fn.)) {
|
||||
some(ast::def_fn(_, ast::pure_fn)) {
|
||||
// do nothing
|
||||
}
|
||||
_ {
|
||||
@ -2577,7 +2577,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr], args: [ast::arg]) {
|
||||
that's my justification.
|
||||
*/
|
||||
@alt a.node {
|
||||
ast::carg_base. {
|
||||
ast::carg_base {
|
||||
fcx.ccx.tcx.sess.span_bug(a.span,
|
||||
"check_constraints:\
|
||||
unexpected carg_base");
|
||||
@ -2630,7 +2630,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
// If old_fcx is some(...), this is a block fn { |x| ... }.
|
||||
// In that case, the purity is inherited from the context.
|
||||
let purity = alt old_fcx {
|
||||
none. { decl.purity }
|
||||
none { decl.purity }
|
||||
some(f) { assert decl.purity == ast::impure_fn; f.purity }
|
||||
};
|
||||
|
||||
@ -2656,7 +2656,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
let tail_expr_ty = expr_ty(ccx.tcx, tail_expr);
|
||||
demand::simple(fcx, tail_expr.span, fcx.ret_ty, tail_expr_ty);
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
|
||||
let args = ty::ty_fn_args(ccx.tcx, ty::node_id_to_type(ccx.tcx, id));
|
||||
@ -2684,12 +2684,12 @@ fn check_native_fn(ccx: @crate_ctxt, decl: ast::fn_decl) {
|
||||
let tys = vec::map(decl.inputs) {|a| a.ty };
|
||||
for ty in (tys + [decl.output]) {
|
||||
alt ty.node {
|
||||
ast::ty_int(ast::ty_i.) {
|
||||
ast::ty_int(ast::ty_i) {
|
||||
ccx.tcx.sess.span_warn(
|
||||
ty.span, "found rust type `int` in native module, while " +
|
||||
"ctypes::c_int or ctypes::long should be used");
|
||||
}
|
||||
ast::ty_uint(ast::ty_u.) {
|
||||
ast::ty_uint(ast::ty_u) {
|
||||
ccx.tcx.sess.span_warn(
|
||||
ty.span, "found rust type `uint` in native module, while " +
|
||||
"ctypes::c_uint or ctypes::ulong should be used");
|
||||
@ -2733,7 +2733,7 @@ fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool {
|
||||
ty::ty_vec(mt) {
|
||||
if mt.mut != ast::imm { ret false; }
|
||||
alt ty::struct(tcx, mt.ty) {
|
||||
ty::ty_str. { ret true; }
|
||||
ty::ty_str { ret true; }
|
||||
_ { ret false; }
|
||||
}
|
||||
}
|
||||
@ -2744,7 +2744,7 @@ fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool {
|
||||
fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
|
||||
let main_t = ty::node_id_to_monotype(tcx, main_id);
|
||||
alt ty::struct(tcx, main_t) {
|
||||
ty::ty_fn({proto: ast::proto_bare., inputs, output,
|
||||
ty::ty_fn({proto: ast::proto_bare, inputs, output,
|
||||
ret_style: ast::return_val., constraints}) {
|
||||
let ok = vec::len(constraints) == 0u;
|
||||
ok &= ty::type_is_nil(tcx, output);
|
||||
@ -2771,7 +2771,7 @@ fn check_for_main_fn(tcx: ty::ctxt, crate: @ast::crate) {
|
||||
if !tcx.sess.building_library {
|
||||
alt tcx.sess.main_fn {
|
||||
some(id) { check_main_fn_ty(tcx, id); }
|
||||
none. { tcx.sess.span_err(crate.span, "main function not found"); }
|
||||
none { tcx.sess.span_err(crate.span, "main function not found"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,8 +129,8 @@ tag proto {
|
||||
|
||||
pure fn is_blockish(p: ast::proto) -> bool {
|
||||
alt p {
|
||||
proto_any. | proto_block. { true }
|
||||
proto_bare. | proto_uniq. | proto_box. { false }
|
||||
proto_any | proto_block { true }
|
||||
proto_bare | proto_uniq | proto_box { false }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,39 +35,39 @@ fn def_id_of_def(d: def) -> def_id {
|
||||
|
||||
fn binop_to_str(op: binop) -> str {
|
||||
alt op {
|
||||
add. { ret "+"; }
|
||||
subtract. { ret "-"; }
|
||||
mul. { ret "*"; }
|
||||
div. { ret "/"; }
|
||||
rem. { ret "%"; }
|
||||
and. { ret "&&"; }
|
||||
or. { ret "||"; }
|
||||
bitxor. { ret "^"; }
|
||||
bitand. { ret "&"; }
|
||||
bitor. { ret "|"; }
|
||||
lsl. { ret "<<"; }
|
||||
lsr. { ret ">>"; }
|
||||
asr. { ret ">>>"; }
|
||||
eq. { ret "=="; }
|
||||
lt. { ret "<"; }
|
||||
le. { ret "<="; }
|
||||
ne. { ret "!="; }
|
||||
ge. { ret ">="; }
|
||||
gt. { ret ">"; }
|
||||
add { ret "+"; }
|
||||
subtract { ret "-"; }
|
||||
mul { ret "*"; }
|
||||
div { ret "/"; }
|
||||
rem { ret "%"; }
|
||||
and { ret "&&"; }
|
||||
or { ret "||"; }
|
||||
bitxor { ret "^"; }
|
||||
bitand { ret "&"; }
|
||||
bitor { ret "|"; }
|
||||
lsl { ret "<<"; }
|
||||
lsr { ret ">>"; }
|
||||
asr { ret ">>>"; }
|
||||
eq { ret "=="; }
|
||||
lt { ret "<"; }
|
||||
le { ret "<="; }
|
||||
ne { ret "!="; }
|
||||
ge { ret ">="; }
|
||||
gt { ret ">"; }
|
||||
}
|
||||
}
|
||||
|
||||
pure fn lazy_binop(b: binop) -> bool {
|
||||
alt b { and. { true } or. { true } _ { false } }
|
||||
alt b { and { true } or { true } _ { false } }
|
||||
}
|
||||
|
||||
fn unop_to_str(op: unop) -> str {
|
||||
alt op {
|
||||
box(mt) { if mt == mut { ret "@mutable "; } ret "@"; }
|
||||
uniq(mt) { if mt == mut { ret "~mutable "; } ret "~"; }
|
||||
deref. { ret "*"; }
|
||||
not. { ret "!"; }
|
||||
neg. { ret "-"; }
|
||||
deref { ret "*"; }
|
||||
not { ret "!"; }
|
||||
neg { ret "-"; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,38 +77,38 @@ fn is_path(e: @expr) -> bool {
|
||||
|
||||
fn int_ty_to_str(t: int_ty) -> str {
|
||||
alt t {
|
||||
ty_i. { "" } ty_i8. { "i8" } ty_i16. { "i16" }
|
||||
ty_i32. { "i32" } ty_i64. { "i64" }
|
||||
ty_i { "" } ty_i8 { "i8" } ty_i16 { "i16" }
|
||||
ty_i32 { "i32" } ty_i64 { "i64" }
|
||||
}
|
||||
}
|
||||
|
||||
fn int_ty_max(t: int_ty) -> u64 {
|
||||
alt t {
|
||||
ty_i8. { 0x80u64 }
|
||||
ty_i16. { 0x800u64 }
|
||||
ty_char. | ty_i32. { 0x80000000u64 }
|
||||
ty_i64. { 0x8000000000000000u64 }
|
||||
ty_i8 { 0x80u64 }
|
||||
ty_i16 { 0x800u64 }
|
||||
ty_char | ty_i32 { 0x80000000u64 }
|
||||
ty_i64 { 0x8000000000000000u64 }
|
||||
}
|
||||
}
|
||||
|
||||
fn uint_ty_to_str(t: uint_ty) -> str {
|
||||
alt t {
|
||||
ty_u. { "u" } ty_u8. { "u8" } ty_u16. { "u16" }
|
||||
ty_u32. { "u32" } ty_u64. { "u64" }
|
||||
ty_u { "u" } ty_u8 { "u8" } ty_u16 { "u16" }
|
||||
ty_u32 { "u32" } ty_u64 { "u64" }
|
||||
}
|
||||
}
|
||||
|
||||
fn uint_ty_max(t: uint_ty) -> u64 {
|
||||
alt t {
|
||||
ty_u8. { 0xffu64 }
|
||||
ty_u16. { 0xffffu64 }
|
||||
ty_u32. { 0xffffffffu64 }
|
||||
ty_u64. { 0xffffffffffffffffu64 }
|
||||
ty_u8 { 0xffu64 }
|
||||
ty_u16 { 0xffffu64 }
|
||||
ty_u32 { 0xffffffffu64 }
|
||||
ty_u64 { 0xffffffffffffffffu64 }
|
||||
}
|
||||
}
|
||||
|
||||
fn float_ty_to_str(t: float_ty) -> str {
|
||||
alt t { ty_f. { "" } ty_f32. { "f32" } ty_f64. { "f64" } }
|
||||
alt t { ty_f { "" } ty_f32 { "f32" } ty_f64 { "f64" } }
|
||||
}
|
||||
|
||||
fn is_exported(i: ident, m: _mod) -> bool {
|
||||
@ -212,14 +212,14 @@ tag const_val {
|
||||
fn eval_const_expr(e: @expr) -> const_val {
|
||||
fn fromb(b: bool) -> const_val { const_int(b as i64) }
|
||||
alt e.node {
|
||||
expr_unary(neg., inner) {
|
||||
expr_unary(neg, inner) {
|
||||
alt eval_const_expr(inner) {
|
||||
const_float(f) { const_float(-f) }
|
||||
const_int(i) { const_int(-i) }
|
||||
const_uint(i) { const_uint(-i) }
|
||||
}
|
||||
}
|
||||
expr_unary(not., inner) {
|
||||
expr_unary(not, inner) {
|
||||
alt eval_const_expr(inner) {
|
||||
const_int(i) { const_int(!i) }
|
||||
const_uint(i) { const_uint(!i) }
|
||||
@ -229,33 +229,33 @@ fn eval_const_expr(e: @expr) -> const_val {
|
||||
alt (eval_const_expr(a), eval_const_expr(b)) {
|
||||
(const_float(a), const_float(b)) {
|
||||
alt op {
|
||||
add. { const_float(a + b) } subtract. { const_float(a - b) }
|
||||
mul. { const_float(a * b) } div. { const_float(a / b) }
|
||||
rem. { const_float(a % b) } eq. { fromb(a == b) }
|
||||
lt. { fromb(a < b) } le. { fromb(a <= b) } ne. { fromb(a != b) }
|
||||
ge. { fromb(a >= b) } gt. { fromb(a > b) }
|
||||
add { const_float(a + b) } subtract { const_float(a - b) }
|
||||
mul { const_float(a * b) } div { const_float(a / b) }
|
||||
rem { const_float(a % b) } eq { fromb(a == b) }
|
||||
lt { fromb(a < b) } le { fromb(a <= b) } ne { fromb(a != b) }
|
||||
ge { fromb(a >= b) } gt { fromb(a > b) }
|
||||
}
|
||||
}
|
||||
(const_int(a), const_int(b)) {
|
||||
alt op {
|
||||
add. { const_int(a + b) } subtract. { const_int(a - b) }
|
||||
mul. { const_int(a * b) } div. { const_int(a / b) }
|
||||
rem. { const_int(a % b) } and. | bitand. { const_int(a & b) }
|
||||
or. | bitor. { const_int(a | b) } bitxor. { const_int(a ^ b) }
|
||||
eq. { fromb(a == b) } lt. { fromb(a < b) }
|
||||
le. { fromb(a <= b) } ne. { fromb(a != b) }
|
||||
ge. { fromb(a >= b) } gt. { fromb(a > b) }
|
||||
add { const_int(a + b) } subtract { const_int(a - b) }
|
||||
mul { const_int(a * b) } div { const_int(a / b) }
|
||||
rem { const_int(a % b) } and | bitand { const_int(a & b) }
|
||||
or | bitor { const_int(a | b) } bitxor { const_int(a ^ b) }
|
||||
eq { fromb(a == b) } lt { fromb(a < b) }
|
||||
le { fromb(a <= b) } ne { fromb(a != b) }
|
||||
ge { fromb(a >= b) } gt { fromb(a > b) }
|
||||
}
|
||||
}
|
||||
(const_uint(a), const_uint(b)) {
|
||||
alt op {
|
||||
add. { const_uint(a + b) } subtract. { const_uint(a - b) }
|
||||
mul. { const_uint(a * b) } div. { const_uint(a / b) }
|
||||
rem. { const_uint(a % b) } and. | bitand. { const_uint(a & b) }
|
||||
or. | bitor. { const_uint(a | b) } bitxor. { const_uint(a ^ b) }
|
||||
eq. { fromb(a == b) } lt. { fromb(a < b) }
|
||||
le. { fromb(a <= b) } ne. { fromb(a != b) }
|
||||
ge. { fromb(a >= b) } gt. { fromb(a > b) }
|
||||
add { const_uint(a + b) } subtract { const_uint(a - b) }
|
||||
mul { const_uint(a * b) } div { const_uint(a / b) }
|
||||
rem { const_uint(a % b) } and | bitand { const_uint(a & b) }
|
||||
or | bitor { const_uint(a | b) } bitxor { const_uint(a ^ b) }
|
||||
eq { fromb(a == b) } lt { fromb(a < b) }
|
||||
le { fromb(a <= b) } ne { fromb(a != b) }
|
||||
ge { fromb(a >= b) } gt { fromb(a > b) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,7 +270,7 @@ fn lit_to_const(lit: @lit) -> const_val {
|
||||
lit_int(n, _) { const_int(n) }
|
||||
lit_uint(n, _) { const_uint(n) }
|
||||
lit_float(n, _) { const_float(float::from_str(n)) }
|
||||
lit_nil. { const_int(0i64) }
|
||||
lit_nil { const_int(0i64) }
|
||||
lit_bool(b) { const_int(b as i64) }
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ fn span_to_str(sp: span, cm: codemap) -> str {
|
||||
"-"
|
||||
} else { lo.filename }, lo.line, lo.col, hi.line, hi.col];
|
||||
alt cur.expanded_from {
|
||||
os_none. { break; }
|
||||
os_none { break; }
|
||||
os_some(new_sp) {
|
||||
cur = *new_sp;
|
||||
prev_file = some(lo.filename);
|
||||
|
@ -26,7 +26,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
||||
|
||||
let var = expr_to_str(cx, args[0], "#env requires a string");
|
||||
alt generic_os::getenv(var) {
|
||||
option::none. { ret make_new_str(cx, sp, ""); }
|
||||
option::none { ret make_new_str(cx, sp, ""); }
|
||||
option::some(s) { ret make_new_str(cx, sp, s); }
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, e: expr_,
|
||||
assert (vec::len(pth.node.idents) > 0u);
|
||||
let extname = pth.node.idents[0];
|
||||
alt exts.find(extname) {
|
||||
none. {
|
||||
none {
|
||||
cx.span_fatal(pth.span,
|
||||
#fmt["macro undefined: '%s'", extname])
|
||||
}
|
||||
|
@ -112,11 +112,11 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
for f: flag in flags {
|
||||
let fstr;
|
||||
alt f {
|
||||
flag_left_justify. { fstr = "flag_left_justify"; }
|
||||
flag_left_zero_pad. { fstr = "flag_left_zero_pad"; }
|
||||
flag_space_for_sign. { fstr = "flag_space_for_sign"; }
|
||||
flag_sign_always. { fstr = "flag_sign_always"; }
|
||||
flag_alternate. { fstr = "flag_alternate"; }
|
||||
flag_left_justify { fstr = "flag_left_justify"; }
|
||||
flag_left_zero_pad { fstr = "flag_left_zero_pad"; }
|
||||
flag_space_for_sign { fstr = "flag_space_for_sign"; }
|
||||
flag_sign_always { fstr = "flag_sign_always"; }
|
||||
flag_alternate { fstr = "flag_alternate"; }
|
||||
}
|
||||
flagexprs += [make_rt_path_expr(cx, sp, fstr)];
|
||||
}
|
||||
@ -131,7 +131,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
}
|
||||
fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr {
|
||||
alt cnt {
|
||||
count_implied. {
|
||||
count_implied {
|
||||
ret make_rt_path_expr(cx, sp, "count_implied");
|
||||
}
|
||||
count_is(c) {
|
||||
@ -148,12 +148,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
alt t {
|
||||
ty_hex(c) {
|
||||
alt c {
|
||||
case_upper. { rt_type = "ty_hex_upper"; }
|
||||
case_lower. { rt_type = "ty_hex_lower"; }
|
||||
case_upper { rt_type = "ty_hex_upper"; }
|
||||
case_lower { rt_type = "ty_hex_lower"; }
|
||||
}
|
||||
}
|
||||
ty_bits. { rt_type = "ty_bits"; }
|
||||
ty_octal. { rt_type = "ty_octal"; }
|
||||
ty_bits { rt_type = "ty_bits"; }
|
||||
ty_octal { rt_type = "ty_octal"; }
|
||||
_ { rt_type = "ty_default"; }
|
||||
}
|
||||
ret make_rt_path_expr(cx, sp, rt_type);
|
||||
@ -189,65 +189,65 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
fn is_signed_type(cnv: conv) -> bool {
|
||||
alt cnv.ty {
|
||||
ty_int(s) {
|
||||
alt s { signed. { ret true; } unsigned. { ret false; } }
|
||||
alt s { signed { ret true; } unsigned { ret false; } }
|
||||
}
|
||||
ty_float. { ret true; }
|
||||
ty_float { ret true; }
|
||||
_ { ret false; }
|
||||
}
|
||||
}
|
||||
let unsupported = "conversion not supported in #fmt string";
|
||||
alt cnv.param {
|
||||
option::none. { }
|
||||
option::none { }
|
||||
_ { cx.span_unimpl(sp, unsupported); }
|
||||
}
|
||||
for f: flag in cnv.flags {
|
||||
alt f {
|
||||
flag_left_justify. { }
|
||||
flag_sign_always. {
|
||||
flag_left_justify { }
|
||||
flag_sign_always {
|
||||
if !is_signed_type(cnv) {
|
||||
cx.span_fatal(sp,
|
||||
"+ flag only valid in " +
|
||||
"signed #fmt conversion");
|
||||
}
|
||||
}
|
||||
flag_space_for_sign. {
|
||||
flag_space_for_sign {
|
||||
if !is_signed_type(cnv) {
|
||||
cx.span_fatal(sp,
|
||||
"space flag only valid in " +
|
||||
"signed #fmt conversions");
|
||||
}
|
||||
}
|
||||
flag_left_zero_pad. { }
|
||||
flag_left_zero_pad { }
|
||||
_ { cx.span_unimpl(sp, unsupported); }
|
||||
}
|
||||
}
|
||||
alt cnv.width {
|
||||
count_implied. { }
|
||||
count_implied { }
|
||||
count_is(_) { }
|
||||
_ { cx.span_unimpl(sp, unsupported); }
|
||||
}
|
||||
alt cnv.precision {
|
||||
count_implied. { }
|
||||
count_implied { }
|
||||
count_is(_) { }
|
||||
_ { cx.span_unimpl(sp, unsupported); }
|
||||
}
|
||||
alt cnv.ty {
|
||||
ty_str. { ret make_conv_call(cx, arg.span, "str", cnv, arg); }
|
||||
ty_str { ret make_conv_call(cx, arg.span, "str", cnv, arg); }
|
||||
ty_int(sign) {
|
||||
alt sign {
|
||||
signed. { ret make_conv_call(cx, arg.span, "int", cnv, arg); }
|
||||
unsigned. {
|
||||
signed { ret make_conv_call(cx, arg.span, "int", cnv, arg); }
|
||||
unsigned {
|
||||
ret make_conv_call(cx, arg.span, "uint", cnv, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
ty_bool. { ret make_conv_call(cx, arg.span, "bool", cnv, arg); }
|
||||
ty_char. { ret make_conv_call(cx, arg.span, "char", cnv, arg); }
|
||||
ty_bool { ret make_conv_call(cx, arg.span, "bool", cnv, arg); }
|
||||
ty_char { ret make_conv_call(cx, arg.span, "char", cnv, arg); }
|
||||
ty_hex(_) { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
||||
ty_bits. { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
||||
ty_octal. { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
||||
ty_float. { ret make_conv_call(cx, arg.span, "float", cnv, arg); }
|
||||
ty_poly. { ret make_conv_call(cx, arg.span, "poly", cnv, arg); }
|
||||
ty_bits { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
||||
ty_octal { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
||||
ty_float { ret make_conv_call(cx, arg.span, "float", cnv, arg); }
|
||||
ty_poly { ret make_conv_call(cx, arg.span, "poly", cnv, arg); }
|
||||
_ { cx.span_unimpl(sp, unsupported); }
|
||||
}
|
||||
}
|
||||
@ -258,11 +258,11 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
}
|
||||
for f: flag in c.flags {
|
||||
alt f {
|
||||
flag_left_justify. { #debug("flag: left justify"); }
|
||||
flag_left_zero_pad. { #debug("flag: left zero pad"); }
|
||||
flag_space_for_sign. { #debug("flag: left space pad"); }
|
||||
flag_sign_always. { #debug("flag: sign always"); }
|
||||
flag_alternate. { #debug("flag: alternate"); }
|
||||
flag_left_justify { #debug("flag: left justify"); }
|
||||
flag_left_zero_pad { #debug("flag: left zero pad"); }
|
||||
flag_space_for_sign { #debug("flag: left space pad"); }
|
||||
flag_sign_always { #debug("flag: sign always"); }
|
||||
flag_alternate { #debug("flag: alternate"); }
|
||||
}
|
||||
}
|
||||
alt c.width {
|
||||
@ -272,8 +272,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
log(debug,
|
||||
"width: count is param " + int::to_str(i, 10u));
|
||||
}
|
||||
count_is_next_param. { #debug("width: count is next param"); }
|
||||
count_implied. { #debug("width: count is implied"); }
|
||||
count_is_next_param { #debug("width: count is next param"); }
|
||||
count_implied { #debug("width: count is implied"); }
|
||||
}
|
||||
alt c.precision {
|
||||
count_is(i) { log(debug,
|
||||
@ -282,29 +282,29 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
|
||||
log(debug,
|
||||
"prec: count is param " + int::to_str(i, 10u));
|
||||
}
|
||||
count_is_next_param. { #debug("prec: count is next param"); }
|
||||
count_implied. { #debug("prec: count is implied"); }
|
||||
count_is_next_param { #debug("prec: count is next param"); }
|
||||
count_implied { #debug("prec: count is implied"); }
|
||||
}
|
||||
alt c.ty {
|
||||
ty_bool. { #debug("type: bool"); }
|
||||
ty_str. { #debug("type: str"); }
|
||||
ty_char. { #debug("type: char"); }
|
||||
ty_bool { #debug("type: bool"); }
|
||||
ty_str { #debug("type: str"); }
|
||||
ty_char { #debug("type: char"); }
|
||||
ty_int(s) {
|
||||
alt s {
|
||||
signed. { #debug("type: signed"); }
|
||||
unsigned. { #debug("type: unsigned"); }
|
||||
signed { #debug("type: signed"); }
|
||||
unsigned { #debug("type: unsigned"); }
|
||||
}
|
||||
}
|
||||
ty_bits. { #debug("type: bits"); }
|
||||
ty_bits { #debug("type: bits"); }
|
||||
ty_hex(cs) {
|
||||
alt cs {
|
||||
case_upper. { #debug("type: uhex"); }
|
||||
case_lower. { #debug("type: lhex"); }
|
||||
case_upper { #debug("type: uhex"); }
|
||||
case_lower { #debug("type: lhex"); }
|
||||
}
|
||||
}
|
||||
ty_octal. { #debug("type: octal"); }
|
||||
ty_float. { #debug("type: float"); }
|
||||
ty_poly. { #debug("type: poly"); }
|
||||
ty_octal { #debug("type: octal"); }
|
||||
ty_float { #debug("type: float"); }
|
||||
ty_poly { #debug("type: poly"); }
|
||||
}
|
||||
}
|
||||
let fmt_sp = args[0].span;
|
||||
|
@ -60,7 +60,7 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: str) -> ! {
|
||||
cx.span_fatal(x.span,
|
||||
"this argument is a block, expected " + expected);
|
||||
}
|
||||
match_exact. { cx.bug("what is a match_exact doing in a bindings?"); }
|
||||
match_exact { cx.bug("what is a match_exact doing in a bindings?"); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
|
||||
alt elt.node {
|
||||
expr_mac(m) {
|
||||
alt m.node {
|
||||
ast::mac_ellipsis. {
|
||||
ast::mac_ellipsis {
|
||||
if res != none {
|
||||
cx.span_fatal(m.span, "only one ellipsis allowed");
|
||||
}
|
||||
@ -99,7 +99,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: [@expr]) ->
|
||||
}
|
||||
ret alt res {
|
||||
some(val) { val }
|
||||
none. { {pre: elts, rep: none, post: []} }
|
||||
none { {pre: elts, rep: none, post: []} }
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option::t<U>, v: [T]) ->
|
||||
option::t<[U]> {
|
||||
let res = [];
|
||||
for elem: T in v {
|
||||
alt f(elem) { none. { ret none; } some(fv) { res += [fv]; } }
|
||||
alt f(elem) { none { ret none; } some(fv) { res += [fv]; } }
|
||||
}
|
||||
ret some(res);
|
||||
}
|
||||
@ -117,7 +117,7 @@ fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result {
|
||||
leaf(x) { ret f(x); }
|
||||
seq(ads, span) {
|
||||
alt option_flatten_map(bind a_d_map(_, f), *ads) {
|
||||
none. { ret none; }
|
||||
none { ret none; }
|
||||
some(ts) { ret some(seq(@ts, span)); }
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result {
|
||||
fn compose_sels(s1: selector, s2: selector) -> selector {
|
||||
fn scomp(s1: selector, s2: selector, m: matchable) -> match_result {
|
||||
ret alt s1(m) {
|
||||
none. { none }
|
||||
none { none }
|
||||
some(matches) { a_d_map(matches, s2) }
|
||||
}
|
||||
}
|
||||
@ -168,12 +168,12 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> option::t<bindings> {
|
||||
let res = new_str_hash::<arb_depth<matchable>>();
|
||||
//need to do this first, to check vec lengths.
|
||||
for sel: selector in b.literal_ast_matchers {
|
||||
alt sel(match_expr(e)) { none. { ret none; } _ { } }
|
||||
alt sel(match_expr(e)) { none { ret none; } _ { } }
|
||||
}
|
||||
let never_mind: bool = false;
|
||||
b.real_binders.items {|key, val|
|
||||
alt val(match_expr(e)) {
|
||||
none. { never_mind = true; }
|
||||
none { never_mind = true; }
|
||||
some(mtc) { res.insert(key, mtc); }
|
||||
}
|
||||
};
|
||||
@ -226,7 +226,7 @@ fn follow(m: arb_depth<matchable>, idx_path: @mutable [uint]) ->
|
||||
fn follow_for_trans(cx: ext_ctxt, mmaybe: option::t<arb_depth<matchable>>,
|
||||
idx_path: @mutable [uint]) -> option::t<matchable> {
|
||||
alt mmaybe {
|
||||
none. { ret none }
|
||||
none { ret none }
|
||||
some(m) {
|
||||
ret alt follow(m, idx_path) {
|
||||
seq(_, sp) {
|
||||
@ -267,7 +267,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
{pre: pre, rep: repeat_me_maybe, post: post} {
|
||||
let res = vec::map(pre, recur);
|
||||
alt repeat_me_maybe {
|
||||
none. { }
|
||||
none { }
|
||||
some(repeat_me) {
|
||||
let repeat: option::t<{rep_count: uint, name: ident}> = none;
|
||||
/* we need to walk over all the free vars in lockstep, except for
|
||||
@ -278,7 +278,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
leaf(_) { }
|
||||
seq(ms, _) {
|
||||
alt repeat {
|
||||
none. {
|
||||
none {
|
||||
repeat = some({rep_count: vec::len(*ms), name: fv});
|
||||
}
|
||||
some({rep_count: old_len, name: old_name}) {
|
||||
@ -296,7 +296,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
}
|
||||
};
|
||||
alt repeat {
|
||||
none. {
|
||||
none {
|
||||
cx.span_fatal(repeat_me.span,
|
||||
"'...' surrounds an expression without any" +
|
||||
" repeating syntax variables");
|
||||
@ -328,7 +328,7 @@ fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
ret alt follow_for_trans(cx, b.find(i), idx_path) {
|
||||
some(match_ident(a_id)) { a_id.node }
|
||||
some(m) { match_error(cx, m, "an identifier") }
|
||||
none. { i }
|
||||
none { i }
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
}
|
||||
some(match_path(a_pth)) { a_pth.node }
|
||||
some(m) { match_error(cx, m, "a path") }
|
||||
none. { p }
|
||||
none { p }
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
some(match_path(a_pth)) { expr_path(a_pth) }
|
||||
some(match_expr(a_exp)) { a_exp.node }
|
||||
some(m) { match_error(cx, m, "an expression") }
|
||||
none. { orig(e, fld) }
|
||||
none { orig(e, fld) }
|
||||
}
|
||||
}
|
||||
_ { orig(e, fld) }
|
||||
@ -385,10 +385,10 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
alt follow_for_trans(cx, b.find(id), idx_path) {
|
||||
some(match_ty(ty)) { ty.node }
|
||||
some(m) { match_error(cx, m, "a type") }
|
||||
none. { orig(t, fld) }
|
||||
none { orig(t, fld) }
|
||||
}
|
||||
}
|
||||
none. { orig(t, fld) }
|
||||
none { orig(t, fld) }
|
||||
}
|
||||
}
|
||||
_ { orig(t, fld) }
|
||||
@ -415,10 +415,10 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
|
||||
some(m) {
|
||||
match_error(cx, m, "a block")
|
||||
}
|
||||
none. { orig(blk, fld) }
|
||||
none { orig(blk, fld) }
|
||||
}
|
||||
}
|
||||
none. { orig(blk, fld) }
|
||||
none { orig(blk, fld) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) {
|
||||
"matching after `...` not yet supported");
|
||||
}
|
||||
}
|
||||
{pre: pre, rep: none., post: post} {
|
||||
{pre: pre, rep: none, post: post} {
|
||||
if post != [] {
|
||||
cx.bug("elts_to_ell provided an invalid result");
|
||||
}
|
||||
@ -491,7 +491,7 @@ fn specialize_match(m: matchable) -> matchable {
|
||||
expr_path(pth) {
|
||||
alt path_to_ident(pth) {
|
||||
some(id) { match_ident(respan(pth.span, id)) }
|
||||
none. { match_path(pth) }
|
||||
none { match_path(pth) }
|
||||
}
|
||||
}
|
||||
_ { m }
|
||||
@ -516,7 +516,7 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) {
|
||||
}
|
||||
b.real_binders.insert(p_id, compose_sels(s, bind select(cx, _)));
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ fn block_to_ident(blk: blk_) -> option::t<ident> {
|
||||
some(expr) {
|
||||
alt expr.node { expr_path(pth) { path_to_ident(pth) } _ { none } }
|
||||
}
|
||||
none. { none }
|
||||
none { none }
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,7 +544,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) {
|
||||
cx.span_fatal(sp, "destructuring " + syn + " is not yet supported");
|
||||
}
|
||||
alt mac.node {
|
||||
ast::mac_ellipsis. { cx.span_fatal(mac.span, "misused `...`"); }
|
||||
ast::mac_ellipsis { cx.span_fatal(mac.span, "misused `...`"); }
|
||||
ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); }
|
||||
ast::mac_embed_type(ty) {
|
||||
alt ty.node {
|
||||
@ -561,7 +561,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) {
|
||||
let final_step = bind select_pt_1(cx, _, select_pt_2);
|
||||
b.real_binders.insert(id, compose_sels(s, final_step));
|
||||
}
|
||||
none. { no_des(cx, pth.span, "under `#<>`"); }
|
||||
none { no_des(cx, pth.span, "under `#<>`"); }
|
||||
}
|
||||
}
|
||||
_ { no_des(cx, ty.span, "under `#<>`"); }
|
||||
@ -581,7 +581,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) {
|
||||
let final_step = bind select_pt_1(cx, _, select_pt_2);
|
||||
b.real_binders.insert(id, compose_sels(s, final_step));
|
||||
}
|
||||
none. { no_des(cx, blk.span, "under `#{}`"); }
|
||||
none { no_des(cx, blk.span, "under `#{}`"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -693,7 +693,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr,
|
||||
alt path_to_ident(pth) {
|
||||
some(id) {
|
||||
alt macro_name {
|
||||
none. { macro_name = some(id); }
|
||||
none { macro_name = some(id); }
|
||||
some(other_id) {
|
||||
if id != other_id {
|
||||
cx.span_fatal(pth.span,
|
||||
@ -703,7 +703,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr,
|
||||
}
|
||||
}
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
cx.span_fatal(pth.span,
|
||||
"macro name must not be a path");
|
||||
}
|
||||
@ -735,7 +735,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr,
|
||||
ret {ident:
|
||||
alt macro_name {
|
||||
some(id) { id }
|
||||
none. {
|
||||
none {
|
||||
cx.span_fatal(sp,
|
||||
"macro definition must have " +
|
||||
"at least one clause")
|
||||
@ -748,7 +748,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: @expr,
|
||||
for c: @clause in clauses {
|
||||
alt use_selectors_to_bind(c.params, arg) {
|
||||
some(bindings) { ret transcribe(cx, bindings, c.body); }
|
||||
none. { cont; }
|
||||
none { cont; }
|
||||
}
|
||||
}
|
||||
cx.span_fatal(sp, "no clauses match macro invocation");
|
||||
|
@ -137,7 +137,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
||||
}
|
||||
mac_embed_type(ty) { mac_embed_type(fld.fold_ty(ty)) }
|
||||
mac_embed_block(blk) { mac_embed_block(fld.fold_block(blk)) }
|
||||
mac_ellipsis. { mac_ellipsis }
|
||||
mac_ellipsis { mac_ellipsis }
|
||||
},
|
||||
span: m.span};
|
||||
}
|
||||
@ -189,7 +189,7 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
|
||||
attrs: vec::map(ni.attrs, fold_attribute),
|
||||
node:
|
||||
alt ni.node {
|
||||
native_item_ty. { native_item_ty }
|
||||
native_item_ty { native_item_ty }
|
||||
native_item_fn(fdec, typms) {
|
||||
native_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
|
||||
output: fld.fold_ty(fdec.output),
|
||||
@ -273,7 +273,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
|
||||
|
||||
fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
ret alt p {
|
||||
pat_wild. { p }
|
||||
pat_wild { p }
|
||||
pat_ident(pth, sub) {
|
||||
pat_ident(fld.fold_path(pth), option::map(sub, fld.fold_pat))
|
||||
}
|
||||
@ -391,7 +391,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
}
|
||||
expr_path(pth) { expr_path(fld.fold_path(pth)) }
|
||||
expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) }
|
||||
expr_break. | expr_cont. { e }
|
||||
expr_break | expr_cont { e }
|
||||
expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) }
|
||||
expr_be(e) { expr_be(fld.fold_expr(e)) }
|
||||
expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv),
|
||||
@ -434,7 +434,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
let args = vec::map(v.args, fold_variant_arg);
|
||||
let de = alt v.disr_expr {
|
||||
some(e) {some(fld.fold_expr(e))}
|
||||
none. {none}
|
||||
none {none}
|
||||
};
|
||||
ret {name: v.name, args: args, id: v.id,
|
||||
disr_expr: de};
|
||||
|
@ -58,7 +58,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option::t<str>)
|
||||
fn companion_file(prefix: str, suffix: option::t<str>) -> str {
|
||||
ret alt suffix {
|
||||
option::some(s) { fs::connect(prefix, s) }
|
||||
option::none. { prefix }
|
||||
option::none { prefix }
|
||||
} + ".rs";
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ fn cdir_path_opt(id: str, attrs: [ast::attribute]) -> str {
|
||||
some(d) {
|
||||
ret d;
|
||||
}
|
||||
none. { ret id; }
|
||||
none { ret id; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ fn scan_number(c: char, rdr: reader) -> token::token {
|
||||
is_float = true;
|
||||
num_str += s;
|
||||
}
|
||||
none. {}
|
||||
none {}
|
||||
}
|
||||
if rdr.curr == 'f' {
|
||||
rdr.bump();
|
||||
|
@ -489,7 +489,7 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
|
||||
} else if eat_word(p, "fn") {
|
||||
let proto = parse_fn_ty_proto(p);
|
||||
alt proto {
|
||||
ast::proto_bare. { p.warn("fn is deprecated, use native fn"); }
|
||||
ast::proto_bare { p.warn("fn is deprecated, use native fn"); }
|
||||
_ { /* fallthrough */ }
|
||||
}
|
||||
t = parse_ty_fn(proto, p);
|
||||
@ -625,7 +625,7 @@ fn lit_from_token(p: parser, tok: token::token) -> ast::lit_ {
|
||||
token::LIT_UINT(u, ut) { ast::lit_uint(u, ut) }
|
||||
token::LIT_FLOAT(s, ft) { ast::lit_float(p.get_str(s), ft) }
|
||||
token::LIT_STR(s) { ast::lit_str(p.get_str(s)) }
|
||||
token::LPAREN. { expect(p, token::RPAREN); ast::lit_nil }
|
||||
token::LPAREN { expect(p, token::RPAREN); ast::lit_nil }
|
||||
_ { unexpected(p, tok); }
|
||||
}
|
||||
}
|
||||
@ -703,7 +703,7 @@ fn mk_mac_expr(p: parser, lo: uint, hi: uint, m: ast::mac_) -> @ast::expr {
|
||||
}
|
||||
|
||||
fn is_bar(t: token::token) -> bool {
|
||||
alt t { token::BINOP(token::OR.) | token::OROR. { true } _ { false } }
|
||||
alt t { token::BINOP(token::OR) | token::OROR { true } _ { false } }
|
||||
}
|
||||
|
||||
fn mk_lit_u32(p: parser, i: u32) -> @ast::expr {
|
||||
@ -797,8 +797,8 @@ fn parse_bottom_expr(p: parser) -> pexpr {
|
||||
} else if eat_word(p, "fn") {
|
||||
let proto = parse_fn_ty_proto(p);
|
||||
alt proto {
|
||||
ast::proto_bare. { p.fatal("fn expr are deprecated, use fn@"); }
|
||||
ast::proto_any. { p.fatal("fn* cannot be used in an expression"); }
|
||||
ast::proto_bare { p.fatal("fn expr are deprecated, use fn@"); }
|
||||
ast::proto_any { p.fatal("fn* cannot be used in an expression"); }
|
||||
_ { /* fallthrough */ }
|
||||
}
|
||||
ret pexpr(parse_fn_expr(p, proto));
|
||||
@ -836,7 +836,7 @@ fn parse_bottom_expr(p: parser) -> pexpr {
|
||||
let e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS);
|
||||
fn parse_expr_opt(p: parser) -> option::t<@ast::expr> {
|
||||
alt p.token {
|
||||
token::UNDERSCORE. { p.bump(); ret none; }
|
||||
token::UNDERSCORE { p.bump(); ret none; }
|
||||
_ { ret some(parse_expr(p)); }
|
||||
}
|
||||
}
|
||||
@ -971,7 +971,7 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
|
||||
while !expr_is_complete(p, e) {
|
||||
alt p.token {
|
||||
// expr(...)
|
||||
token::LPAREN. if permits_call(p) {
|
||||
token::LPAREN if permits_call(p) {
|
||||
let es = parse_seq(token::LPAREN, token::RPAREN,
|
||||
seq_sep(token::COMMA), parse_expr, p);
|
||||
hi = es.span.hi;
|
||||
@ -980,7 +980,7 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
|
||||
}
|
||||
|
||||
// expr {|| ... }
|
||||
token::LBRACE. if is_bar(p.look_ahead(1u)) && permits_call(p) {
|
||||
token::LBRACE if is_bar(p.look_ahead(1u)) && permits_call(p) {
|
||||
p.bump();
|
||||
let blk = parse_fn_block_expr(p);
|
||||
alt e.node {
|
||||
@ -996,7 +996,7 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
|
||||
}
|
||||
|
||||
// expr[...]
|
||||
token::LBRACKET. {
|
||||
token::LBRACKET {
|
||||
p.bump();
|
||||
let ix = parse_expr(p);
|
||||
hi = ix.span.hi;
|
||||
@ -1005,7 +1005,7 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
|
||||
}
|
||||
|
||||
// expr.f
|
||||
token::DOT. {
|
||||
token::DOT {
|
||||
p.bump();
|
||||
alt p.token {
|
||||
token::IDENT(i, _) {
|
||||
@ -1037,7 +1037,7 @@ fn parse_prefix_expr(p: parser) -> pexpr {
|
||||
|
||||
let ex;
|
||||
alt p.token {
|
||||
token::NOT. {
|
||||
token::NOT {
|
||||
p.bump();
|
||||
let e = to_expr(parse_prefix_expr(p));
|
||||
hi = e.span.hi;
|
||||
@ -1045,13 +1045,13 @@ fn parse_prefix_expr(p: parser) -> pexpr {
|
||||
}
|
||||
token::BINOP(b) {
|
||||
alt b {
|
||||
token::MINUS. {
|
||||
token::MINUS {
|
||||
p.bump();
|
||||
let e = to_expr(parse_prefix_expr(p));
|
||||
hi = e.span.hi;
|
||||
ex = ast::expr_unary(ast::neg, e);
|
||||
}
|
||||
token::STAR. {
|
||||
token::STAR {
|
||||
p.bump();
|
||||
let e = to_expr(parse_prefix_expr(p));
|
||||
hi = e.span.hi;
|
||||
@ -1060,14 +1060,14 @@ fn parse_prefix_expr(p: parser) -> pexpr {
|
||||
_ { ret parse_dot_or_call_expr(p); }
|
||||
}
|
||||
}
|
||||
token::AT. {
|
||||
token::AT {
|
||||
p.bump();
|
||||
let m = parse_mutability(p);
|
||||
let e = to_expr(parse_prefix_expr(p));
|
||||
hi = e.span.hi;
|
||||
ex = ast::expr_unary(ast::box(m), e);
|
||||
}
|
||||
token::TILDE. {
|
||||
token::TILDE {
|
||||
p.bump();
|
||||
let m = parse_mutability(p);
|
||||
let e = to_expr(parse_prefix_expr(p));
|
||||
@ -1157,7 +1157,7 @@ fn parse_assign_expr(p: parser) -> @ast::expr {
|
||||
let lo = p.span.lo;
|
||||
let lhs = parse_ternary(p);
|
||||
alt p.token {
|
||||
token::EQ. {
|
||||
token::EQ {
|
||||
p.bump();
|
||||
let rhs = parse_expr(p);
|
||||
ret mk_expr(p, lo, rhs.span.hi, ast::expr_assign(lhs, rhs));
|
||||
@ -1167,26 +1167,26 @@ fn parse_assign_expr(p: parser) -> @ast::expr {
|
||||
let rhs = parse_expr(p);
|
||||
let aop = ast::add;
|
||||
alt op {
|
||||
token::PLUS. { aop = ast::add; }
|
||||
token::MINUS. { aop = ast::subtract; }
|
||||
token::STAR. { aop = ast::mul; }
|
||||
token::SLASH. { aop = ast::div; }
|
||||
token::PERCENT. { aop = ast::rem; }
|
||||
token::CARET. { aop = ast::bitxor; }
|
||||
token::AND. { aop = ast::bitand; }
|
||||
token::OR. { aop = ast::bitor; }
|
||||
token::LSL. { aop = ast::lsl; }
|
||||
token::LSR. { aop = ast::lsr; }
|
||||
token::ASR. { aop = ast::asr; }
|
||||
token::PLUS { aop = ast::add; }
|
||||
token::MINUS { aop = ast::subtract; }
|
||||
token::STAR { aop = ast::mul; }
|
||||
token::SLASH { aop = ast::div; }
|
||||
token::PERCENT { aop = ast::rem; }
|
||||
token::CARET { aop = ast::bitxor; }
|
||||
token::AND { aop = ast::bitand; }
|
||||
token::OR { aop = ast::bitor; }
|
||||
token::LSL { aop = ast::lsl; }
|
||||
token::LSR { aop = ast::lsr; }
|
||||
token::ASR { aop = ast::asr; }
|
||||
}
|
||||
ret mk_expr(p, lo, rhs.span.hi, ast::expr_assign_op(aop, lhs, rhs));
|
||||
}
|
||||
token::LARROW. {
|
||||
token::LARROW {
|
||||
p.bump();
|
||||
let rhs = parse_expr(p);
|
||||
ret mk_expr(p, lo, rhs.span.hi, ast::expr_move(lhs, rhs));
|
||||
}
|
||||
token::DARROW. {
|
||||
token::DARROW {
|
||||
p.bump();
|
||||
let rhs = parse_expr(p);
|
||||
ret mk_expr(p, lo, rhs.span.hi, ast::expr_swap(lhs, rhs));
|
||||
@ -1363,11 +1363,11 @@ fn parse_expr_res(p: parser, r: restriction) -> @ast::expr {
|
||||
|
||||
fn parse_initializer(p: parser) -> option::t<ast::initializer> {
|
||||
alt p.token {
|
||||
token::EQ. {
|
||||
token::EQ {
|
||||
p.bump();
|
||||
ret some({op: ast::init_assign, expr: parse_expr(p)});
|
||||
}
|
||||
token::LARROW. {
|
||||
token::LARROW {
|
||||
p.bump();
|
||||
ret some({op: ast::init_move, expr: parse_expr(p)});
|
||||
}
|
||||
@ -1398,20 +1398,20 @@ fn parse_pat(p: parser) -> @ast::pat {
|
||||
let hi = p.span.hi;
|
||||
let pat;
|
||||
alt p.token {
|
||||
token::UNDERSCORE. { p.bump(); pat = ast::pat_wild; }
|
||||
token::AT. {
|
||||
token::UNDERSCORE { p.bump(); pat = ast::pat_wild; }
|
||||
token::AT {
|
||||
p.bump();
|
||||
let sub = parse_pat(p);
|
||||
pat = ast::pat_box(sub);
|
||||
hi = sub.span.hi;
|
||||
}
|
||||
token::TILDE. {
|
||||
token::TILDE {
|
||||
p.bump();
|
||||
let sub = parse_pat(p);
|
||||
pat = ast::pat_uniq(sub);
|
||||
hi = sub.span.hi;
|
||||
}
|
||||
token::LBRACE. {
|
||||
token::LBRACE {
|
||||
p.bump();
|
||||
let fields = [];
|
||||
let etc = false;
|
||||
@ -1452,7 +1452,7 @@ fn parse_pat(p: parser) -> @ast::pat {
|
||||
p.bump();
|
||||
pat = ast::pat_rec(fields, etc);
|
||||
}
|
||||
token::LPAREN. {
|
||||
token::LPAREN {
|
||||
p.bump();
|
||||
if p.token == token::RPAREN {
|
||||
hi = p.span.hi;
|
||||
@ -1486,9 +1486,9 @@ fn parse_pat(p: parser) -> @ast::pat {
|
||||
} else if is_plain_ident(p) &&
|
||||
alt p.look_ahead(1u) {
|
||||
// Take this out once the libraries change
|
||||
token::DOT. |
|
||||
token::LPAREN. | token::LBRACKET. |
|
||||
token::LT. {
|
||||
token::DOT |
|
||||
token::LPAREN | token::LBRACKET |
|
||||
token::LT {
|
||||
false
|
||||
}
|
||||
_ { true }
|
||||
@ -1501,7 +1501,7 @@ fn parse_pat(p: parser) -> @ast::pat {
|
||||
hi = tag_path.span.hi;
|
||||
let args: [@ast::pat];
|
||||
alt p.token {
|
||||
token::LPAREN. {
|
||||
token::LPAREN {
|
||||
let a =
|
||||
parse_seq(token::LPAREN, token::RPAREN,
|
||||
seq_sep(token::COMMA), parse_pat, p);
|
||||
@ -1565,7 +1565,7 @@ fn parse_stmt(p: parser, first_item_attrs: [ast::attribute]) -> @ast::stmt {
|
||||
} else {
|
||||
let item_attrs;
|
||||
alt parse_outer_attrs_or_ext(p, first_item_attrs) {
|
||||
none. { item_attrs = []; }
|
||||
none { item_attrs = []; }
|
||||
some(left(attrs)) { item_attrs = attrs; }
|
||||
some(right(ext)) {
|
||||
ret @spanned(lo, ext.span.hi, ast::stmt_expr(ext, p.get_id()));
|
||||
@ -1692,7 +1692,7 @@ fn parse_block_tail_(p: parser, lo: uint, s: ast::blk_check_mode,
|
||||
|
||||
while p.token != token::RBRACE {
|
||||
alt p.token {
|
||||
token::SEMI. {
|
||||
token::SEMI {
|
||||
p.bump(); // empty
|
||||
}
|
||||
_ {
|
||||
@ -1701,11 +1701,11 @@ fn parse_block_tail_(p: parser, lo: uint, s: ast::blk_check_mode,
|
||||
alt stmt.node {
|
||||
ast::stmt_expr(e, stmt_id) { // Expression without semicolon:
|
||||
alt p.token {
|
||||
token::SEMI. {
|
||||
token::SEMI {
|
||||
p.bump();
|
||||
stmts += [@{node: ast::stmt_semi(e, stmt_id) with *stmt}];
|
||||
}
|
||||
token::RBRACE. {
|
||||
token::RBRACE {
|
||||
expr = some(e);
|
||||
}
|
||||
t {
|
||||
@ -1856,7 +1856,7 @@ fn parse_item_impl(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
} else { none };
|
||||
let ident = alt ident {
|
||||
some(name) { name }
|
||||
none. { expect_word(p, "of"); fail; }
|
||||
none { expect_word(p, "of"); fail; }
|
||||
};
|
||||
expect_word(p, "for");
|
||||
let ty = parse_ty(p, false), meths = [];
|
||||
@ -2059,7 +2059,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
let vhi = p.span.hi;
|
||||
let disr_expr = none;
|
||||
alt p.token {
|
||||
token::LPAREN. {
|
||||
token::LPAREN {
|
||||
all_nullary = false;
|
||||
let arg_tys = parse_seq(token::LPAREN, token::RPAREN,
|
||||
seq_sep(token::COMMA),
|
||||
@ -2069,7 +2069,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
}
|
||||
vhi = arg_tys.span.hi;
|
||||
}
|
||||
token::EQ. {
|
||||
token::EQ {
|
||||
have_disr = true;
|
||||
p.bump();
|
||||
disr_expr = some(parse_expr(p));
|
||||
@ -2078,11 +2078,11 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
}
|
||||
|
||||
alt p.token {
|
||||
token::SEMI. | token::COMMA. {
|
||||
token::SEMI | token::COMMA {
|
||||
p.bump();
|
||||
if p.token == token::RBRACE { done = true; }
|
||||
}
|
||||
token::RBRACE. { done = true; }
|
||||
token::RBRACE { done = true; }
|
||||
_ { /* fall through */ }
|
||||
}
|
||||
|
||||
@ -2107,19 +2107,19 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
|
||||
fn parse_fn_ty_proto(p: parser) -> ast::proto {
|
||||
alt p.token {
|
||||
token::AT. {
|
||||
token::AT {
|
||||
p.bump();
|
||||
ast::proto_box
|
||||
}
|
||||
token::TILDE. {
|
||||
token::TILDE {
|
||||
p.bump();
|
||||
ast::proto_uniq
|
||||
}
|
||||
token::BINOP(token::AND.) {
|
||||
token::BINOP(token::AND) {
|
||||
p.bump();
|
||||
ast::proto_block
|
||||
}
|
||||
token::BINOP(token::STAR.) {
|
||||
token::BINOP(token::STAR) {
|
||||
p.bump(); // temporary: fn* for any closure
|
||||
ast::proto_any
|
||||
}
|
||||
@ -2131,7 +2131,7 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
|
||||
|
||||
fn fn_expr_lookahead(tok: token::token) -> bool {
|
||||
alt tok {
|
||||
token::LPAREN. | token::AT. | token::TILDE. | token::BINOP(_) {
|
||||
token::LPAREN | token::AT | token::TILDE | token::BINOP(_) {
|
||||
true
|
||||
}
|
||||
_ {
|
||||
@ -2255,13 +2255,13 @@ fn parse_meta_item(p: parser) -> @ast::meta_item {
|
||||
let lo = p.span.lo;
|
||||
let ident = parse_ident(p);
|
||||
alt p.token {
|
||||
token::EQ. {
|
||||
token::EQ {
|
||||
p.bump();
|
||||
let lit = parse_lit(p);
|
||||
let hi = p.span.hi;
|
||||
ret @spanned(lo, hi, ast::meta_name_value(ident, lit));
|
||||
}
|
||||
token::LPAREN. {
|
||||
token::LPAREN {
|
||||
let inner_items = parse_meta_seq(p);
|
||||
let hi = p.span.hi;
|
||||
ret @spanned(lo, hi, ast::meta_list(ident, inner_items));
|
||||
@ -2279,7 +2279,7 @@ fn parse_meta_seq(p: parser) -> [@ast::meta_item] {
|
||||
}
|
||||
|
||||
fn parse_optional_meta(p: parser) -> [@ast::meta_item] {
|
||||
alt p.token { token::LPAREN. { ret parse_meta_seq(p); } _ { ret []; } }
|
||||
alt p.token { token::LPAREN { ret parse_meta_seq(p); } _ { ret []; } }
|
||||
}
|
||||
|
||||
fn parse_use(p: parser) -> ast::view_item_ {
|
||||
@ -2296,8 +2296,8 @@ fn parse_rest_import_name(p: parser, first: ast::ident,
|
||||
let from_idents = option::none::<[ast::import_ident]>;
|
||||
while true {
|
||||
alt p.token {
|
||||
token::SEMI. { break; }
|
||||
token::MOD_SEP. {
|
||||
token::SEMI { break; }
|
||||
token::MOD_SEP {
|
||||
if glob { p.fatal("cannot path into a glob"); }
|
||||
if option::is_some(from_idents) {
|
||||
p.fatal("cannot path into import list");
|
||||
@ -2314,7 +2314,7 @@ fn parse_rest_import_name(p: parser, first: ast::ident,
|
||||
|
||||
|
||||
//the lexer can't tell the different kinds of stars apart ) :
|
||||
token::BINOP(token::STAR.) {
|
||||
token::BINOP(token::STAR) {
|
||||
glob = true;
|
||||
p.bump();
|
||||
}
|
||||
@ -2323,7 +2323,7 @@ fn parse_rest_import_name(p: parser, first: ast::ident,
|
||||
|
||||
|
||||
|
||||
token::LBRACE. {
|
||||
token::LBRACE {
|
||||
fn parse_import_ident(p: parser) -> ast::import_ident {
|
||||
let lo = p.span.lo;
|
||||
let ident = parse_ident(p);
|
||||
@ -2388,7 +2388,7 @@ fn parse_import(p: parser) -> ast::view_item_ {
|
||||
token::IDENT(i, _) {
|
||||
p.bump();
|
||||
alt p.token {
|
||||
token::EQ. {
|
||||
token::EQ {
|
||||
p.bump();
|
||||
ret parse_full_import_name(p, p.get_str(i));
|
||||
}
|
||||
@ -2523,13 +2523,13 @@ fn parse_crate_directive(p: parser, first_outer_attr: [ast::attribute]) ->
|
||||
let id = parse_ident(p);
|
||||
alt p.token {
|
||||
// mod x = "foo.rs";
|
||||
token::SEMI. {
|
||||
token::SEMI {
|
||||
let hi = p.span.hi;
|
||||
p.bump();
|
||||
ret spanned(lo, hi, ast::cdir_src_mod(id, outer_attrs));
|
||||
}
|
||||
// mod x = "foo_dir" { ...directives... }
|
||||
token::LBRACE. {
|
||||
token::LBRACE {
|
||||
p.bump();
|
||||
let inner_attrs = parse_inner_attrs_and_next(p);
|
||||
let mod_attrs = outer_attrs + inner_attrs.inner;
|
||||
|
@ -74,62 +74,62 @@ tag token {
|
||||
|
||||
fn binop_to_str(o: binop) -> str {
|
||||
alt o {
|
||||
PLUS. { ret "+"; }
|
||||
MINUS. { ret "-"; }
|
||||
STAR. { ret "*"; }
|
||||
SLASH. { ret "/"; }
|
||||
PERCENT. { ret "%"; }
|
||||
CARET. { ret "^"; }
|
||||
AND. { ret "&"; }
|
||||
OR. { ret "|"; }
|
||||
LSL. { ret "<<"; }
|
||||
LSR. { ret ">>"; }
|
||||
ASR. { ret ">>>"; }
|
||||
PLUS { ret "+"; }
|
||||
MINUS { ret "-"; }
|
||||
STAR { ret "*"; }
|
||||
SLASH { ret "/"; }
|
||||
PERCENT { ret "%"; }
|
||||
CARET { ret "^"; }
|
||||
AND { ret "&"; }
|
||||
OR { ret "|"; }
|
||||
LSL { ret "<<"; }
|
||||
LSR { ret ">>"; }
|
||||
ASR { ret ">>>"; }
|
||||
}
|
||||
}
|
||||
|
||||
fn to_str(r: reader, t: token) -> str {
|
||||
alt t {
|
||||
EQ. { ret "="; }
|
||||
LT. { ret "<"; }
|
||||
LE. { ret "<="; }
|
||||
EQEQ. { ret "=="; }
|
||||
NE. { ret "!="; }
|
||||
GE. { ret ">="; }
|
||||
GT. { ret ">"; }
|
||||
NOT. { ret "!"; }
|
||||
TILDE. { ret "~"; }
|
||||
OROR. { ret "||"; }
|
||||
ANDAND. { ret "&&"; }
|
||||
EQ { ret "="; }
|
||||
LT { ret "<"; }
|
||||
LE { ret "<="; }
|
||||
EQEQ { ret "=="; }
|
||||
NE { ret "!="; }
|
||||
GE { ret ">="; }
|
||||
GT { ret ">"; }
|
||||
NOT { ret "!"; }
|
||||
TILDE { ret "~"; }
|
||||
OROR { ret "||"; }
|
||||
ANDAND { ret "&&"; }
|
||||
BINOP(op) { ret binop_to_str(op); }
|
||||
BINOPEQ(op) { ret binop_to_str(op) + "="; }
|
||||
|
||||
/* Structural symbols */
|
||||
AT. {
|
||||
AT {
|
||||
ret "@";
|
||||
}
|
||||
DOT. { ret "."; }
|
||||
ELLIPSIS. { ret "..."; }
|
||||
COMMA. { ret ","; }
|
||||
SEMI. { ret ";"; }
|
||||
COLON. { ret ":"; }
|
||||
MOD_SEP. { ret "::"; }
|
||||
QUES. { ret "?"; }
|
||||
RARROW. { ret "->"; }
|
||||
LARROW. { ret "<-"; }
|
||||
DARROW. { ret "<->"; }
|
||||
LPAREN. { ret "("; }
|
||||
RPAREN. { ret ")"; }
|
||||
LBRACKET. { ret "["; }
|
||||
RBRACKET. { ret "]"; }
|
||||
LBRACE. { ret "{"; }
|
||||
RBRACE. { ret "}"; }
|
||||
POUND. { ret "#"; }
|
||||
POUND_LBRACE. { ret "#{"; }
|
||||
POUND_LT. { ret "#<"; }
|
||||
DOT { ret "."; }
|
||||
ELLIPSIS { ret "..."; }
|
||||
COMMA { ret ","; }
|
||||
SEMI { ret ";"; }
|
||||
COLON { ret ":"; }
|
||||
MOD_SEP { ret "::"; }
|
||||
QUES { ret "?"; }
|
||||
RARROW { ret "->"; }
|
||||
LARROW { ret "<-"; }
|
||||
DARROW { ret "<->"; }
|
||||
LPAREN { ret "("; }
|
||||
RPAREN { ret ")"; }
|
||||
LBRACKET { ret "["; }
|
||||
RBRACKET { ret "]"; }
|
||||
LBRACE { ret "{"; }
|
||||
RBRACE { ret "}"; }
|
||||
POUND { ret "#"; }
|
||||
POUND_LBRACE { ret "#{"; }
|
||||
POUND_LT { ret "#<"; }
|
||||
|
||||
/* Literals */
|
||||
LIT_INT(c, ast::ty_char.) {
|
||||
LIT_INT(c, ast::ty_char) {
|
||||
// FIXME: escape.
|
||||
let tmp = "'";
|
||||
str::push_char(tmp, c as char);
|
||||
@ -156,31 +156,31 @@ fn to_str(r: reader, t: token) -> str {
|
||||
ret interner::get::<str>(*r.interner, s);
|
||||
}
|
||||
IDX(i) { ret "_" + int::to_str(i, 10u); }
|
||||
UNDERSCORE. { ret "_"; }
|
||||
UNDERSCORE { ret "_"; }
|
||||
BRACEQUOTE(_) { ret "<bracequote>"; }
|
||||
EOF. { ret "<eof>"; }
|
||||
EOF { ret "<eof>"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pure fn can_begin_expr(t: token) -> bool {
|
||||
alt t {
|
||||
LPAREN. { true }
|
||||
LBRACE. { true }
|
||||
LBRACKET. { true }
|
||||
LPAREN { true }
|
||||
LBRACE { true }
|
||||
LBRACKET { true }
|
||||
IDENT(_, _) { true }
|
||||
UNDERSCORE. { true }
|
||||
TILDE. { true }
|
||||
UNDERSCORE { true }
|
||||
TILDE { true }
|
||||
LIT_INT(_, _) { true }
|
||||
LIT_UINT(_, _) { true }
|
||||
LIT_FLOAT(_, _) { true }
|
||||
LIT_STR(_) { true }
|
||||
POUND. { true }
|
||||
AT. { true }
|
||||
NOT. { true }
|
||||
BINOP(MINUS.) { true }
|
||||
BINOP(STAR.) { true }
|
||||
MOD_SEP. { true }
|
||||
POUND { true }
|
||||
AT { true }
|
||||
NOT { true }
|
||||
BINOP(MINUS) { true }
|
||||
BINOP(STAR) { true }
|
||||
MOD_SEP { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ fn tok_str(t: token) -> str {
|
||||
STRING(s, len) { ret #fmt["STR(%s,%d)", s, len]; }
|
||||
BREAK(_) { ret "BREAK"; }
|
||||
BEGIN(_) { ret "BEGIN"; }
|
||||
END. { ret "END"; }
|
||||
EOF. { ret "EOF"; }
|
||||
END { ret "END"; }
|
||||
EOF { ret "EOF"; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ impl printer for printer {
|
||||
fn pretty_print(t: token) {
|
||||
#debug("pp [%u,%u]", self.left, self.right);
|
||||
alt t {
|
||||
EOF. {
|
||||
EOF {
|
||||
if !self.scan_stack_empty {
|
||||
self.check_stack(0);
|
||||
self.advance_left(self.token[self.left],
|
||||
@ -256,7 +256,7 @@ impl printer for printer {
|
||||
self.size[self.right] = -self.right_total;
|
||||
self.scan_push(self.right);
|
||||
}
|
||||
END. {
|
||||
END {
|
||||
if self.scan_stack_empty {
|
||||
#debug("pp END/print [%u,%u]", self.left, self.right);
|
||||
self.print(t, 0);
|
||||
@ -378,7 +378,7 @@ impl printer for printer {
|
||||
self.check_stack(k - 1);
|
||||
}
|
||||
}
|
||||
END. {
|
||||
END {
|
||||
// paper says + not =, but that makes no sense.
|
||||
self.size[self.scan_pop()] = 1;
|
||||
self.check_stack(k + 1);
|
||||
@ -428,7 +428,7 @@ impl printer for printer {
|
||||
self.print_stack += [{offset: 0, pbreak: fits}];
|
||||
}
|
||||
}
|
||||
END. {
|
||||
END {
|
||||
#debug("print END -> pop END");
|
||||
assert (vec::len(self.print_stack) != 0u);
|
||||
vec::pop(self.print_stack);
|
||||
@ -436,17 +436,17 @@ impl printer for printer {
|
||||
BREAK(b) {
|
||||
let top = self.get_top();
|
||||
alt top.pbreak {
|
||||
fits. {
|
||||
fits {
|
||||
#debug("print BREAK in fitting block");
|
||||
self.space -= b.blank_space;
|
||||
self.indent(b.blank_space);
|
||||
}
|
||||
broken(consistent.) {
|
||||
broken(consistent) {
|
||||
#debug("print BREAK in consistent block");
|
||||
self.print_newline(top.offset + b.offset);
|
||||
self.space = self.margin - (top.offset + b.offset);
|
||||
}
|
||||
broken(inconsistent.) {
|
||||
broken(inconsistent) {
|
||||
if L > self.space {
|
||||
#debug("print BREAK w/ newline in inconsistent");
|
||||
self.print_newline(top.offset + b.offset);
|
||||
@ -466,7 +466,7 @@ impl printer for printer {
|
||||
self.space -= len;
|
||||
self.write_str(s);
|
||||
}
|
||||
EOF. {
|
||||
EOF {
|
||||
// EOF should never get here.
|
||||
fail;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ fn is_begin(s: ps) -> bool {
|
||||
}
|
||||
|
||||
fn is_end(s: ps) -> bool {
|
||||
alt s.s.last_token() { pp::END. { true } _ { false } }
|
||||
alt s.s.last_token() { pp::END { true } _ { false } }
|
||||
}
|
||||
|
||||
fn is_bol(s: ps) -> bool {
|
||||
@ -251,25 +251,25 @@ fn print_type(s: ps, &&ty: @ast::ty) {
|
||||
maybe_print_comment(s, ty.span.lo);
|
||||
ibox(s, 0u);
|
||||
alt ty.node {
|
||||
ast::ty_nil. { word(s.s, "()"); }
|
||||
ast::ty_bool. { word(s.s, "bool"); }
|
||||
ast::ty_bot. { word(s.s, "!"); }
|
||||
ast::ty_int(ast::ty_i.) { word(s.s, "int"); }
|
||||
ast::ty_int(ast::ty_char.) { word(s.s, "char"); }
|
||||
ast::ty_nil { word(s.s, "()"); }
|
||||
ast::ty_bool { word(s.s, "bool"); }
|
||||
ast::ty_bot { word(s.s, "!"); }
|
||||
ast::ty_int(ast::ty_i) { word(s.s, "int"); }
|
||||
ast::ty_int(ast::ty_char) { word(s.s, "char"); }
|
||||
ast::ty_int(t) { word(s.s, ast_util::int_ty_to_str(t)); }
|
||||
ast::ty_uint(ast::ty_u.) { word(s.s, "uint"); }
|
||||
ast::ty_uint(ast::ty_u) { word(s.s, "uint"); }
|
||||
ast::ty_uint(t) { word(s.s, ast_util::uint_ty_to_str(t)); }
|
||||
ast::ty_float(ast::ty_f.) { word(s.s, "float"); }
|
||||
ast::ty_float(ast::ty_f) { word(s.s, "float"); }
|
||||
ast::ty_float(t) { word(s.s, ast_util::float_ty_to_str(t)); }
|
||||
ast::ty_str. { word(s.s, "str"); }
|
||||
ast::ty_str { word(s.s, "str"); }
|
||||
ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); }
|
||||
ast::ty_uniq(mt) { word(s.s, "~"); print_mt(s, mt); }
|
||||
ast::ty_vec(mt) {
|
||||
word(s.s, "[");
|
||||
alt mt.mut {
|
||||
ast::mut. { word_space(s, "mutable"); }
|
||||
ast::maybe_mut. { word_space(s, "const"); }
|
||||
ast::imm. { }
|
||||
ast::mut { word_space(s, "mutable"); }
|
||||
ast::maybe_mut { word_space(s, "const"); }
|
||||
ast::imm { }
|
||||
}
|
||||
print_type(s, mt.ty);
|
||||
word(s.s, "]");
|
||||
@ -309,7 +309,7 @@ fn print_type(s: ps, &&ty: @ast::ty) {
|
||||
print_ty_fn(s, some(proto), d, none, none);
|
||||
}
|
||||
ast::ty_path(path, _) { print_path(s, path, false); }
|
||||
ast::ty_type. { word(s.s, "type"); }
|
||||
ast::ty_type { word(s.s, "type"); }
|
||||
ast::ty_constr(t, cs) {
|
||||
print_type(s, t);
|
||||
space(s.s);
|
||||
@ -324,7 +324,7 @@ fn print_native_item(s: ps, item: @ast::native_item) {
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
print_outer_attributes(s, item.attrs);
|
||||
alt item.node {
|
||||
ast::native_item_ty. {
|
||||
ast::native_item_ty {
|
||||
ibox(s, indent_unit);
|
||||
ibox(s, 0u);
|
||||
word_nbsp(s, "type");
|
||||
@ -585,9 +585,9 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
|
||||
let ann_node = node_block(s, blk);
|
||||
s.ann.pre(ann_node);
|
||||
alt embedded {
|
||||
block_macro. { word(s.s, "#{"); end(s); }
|
||||
block_block_fn. { end(s); }
|
||||
block_normal. { bopen(s); }
|
||||
block_macro { word(s.s, "#{"); end(s); }
|
||||
block_block_fn { end(s); }
|
||||
block_normal { bopen(s); }
|
||||
}
|
||||
|
||||
print_inner_attributes(s, attrs);
|
||||
@ -612,7 +612,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type,
|
||||
// alt, do, & while unambiguously without being parenthesized
|
||||
fn print_maybe_parens_discrim(s: ps, e: @ast::expr) {
|
||||
let disambig = alt e.node {
|
||||
ast::expr_ret(none.) | ast::expr_fail(none.) { true }
|
||||
ast::expr_ret(none) | ast::expr_fail(none) { true }
|
||||
_ { false }
|
||||
};
|
||||
if disambig { popen(s); }
|
||||
@ -683,7 +683,7 @@ fn print_mac(s: ps, m: ast::mac) {
|
||||
ast::mac_embed_block(blk) {
|
||||
print_possibly_embedded_block(s, blk, block_normal, indent_unit);
|
||||
}
|
||||
ast::mac_ellipsis. { word(s.s, "..."); }
|
||||
ast::mac_ellipsis { word(s.s, "..."); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
space(s.s);
|
||||
alt arm.guard {
|
||||
some(e) { word_space(s, "if"); print_expr(s, e); space(s.s); }
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
print_possibly_embedded_block(s, arm.body, block_normal,
|
||||
alt_indent_unit);
|
||||
@ -923,8 +923,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
_ { }
|
||||
}
|
||||
}
|
||||
ast::expr_break. { word(s.s, "break"); }
|
||||
ast::expr_cont. { word(s.s, "cont"); }
|
||||
ast::expr_break { word(s.s, "break"); }
|
||||
ast::expr_cont { word(s.s, "cont"); }
|
||||
ast::expr_ret(result) {
|
||||
word(s.s, "ret");
|
||||
alt result {
|
||||
@ -1011,8 +1011,8 @@ fn print_decl(s: ps, decl: @ast::decl) {
|
||||
some(init) {
|
||||
nbsp(s);
|
||||
alt init.op {
|
||||
ast::init_assign. { word_space(s, "="); }
|
||||
ast::init_move. { word_space(s, "<-"); }
|
||||
ast::init_assign { word_space(s, "="); }
|
||||
ast::init_move { word_space(s, "<-"); }
|
||||
}
|
||||
print_expr(s, init.expr);
|
||||
}
|
||||
@ -1058,7 +1058,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
|
||||
/* Pat isn't normalized, but the beauty of it
|
||||
is that it doesn't matter */
|
||||
alt pat.node {
|
||||
ast::pat_wild. { word(s.s, "_"); }
|
||||
ast::pat_wild { word(s.s, "_"); }
|
||||
ast::pat_ident(path, sub) {
|
||||
print_path(s, path, true);
|
||||
alt sub {
|
||||
@ -1112,9 +1112,9 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
|
||||
fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident,
|
||||
typarams: [ast::ty_param]) {
|
||||
alt decl.purity {
|
||||
ast::impure_fn. { head(s, "fn"); }
|
||||
ast::unsafe_fn. { head(s, "unsafe fn"); }
|
||||
ast::pure_fn. { head(s, "pure fn"); }
|
||||
ast::impure_fn { head(s, "fn"); }
|
||||
ast::unsafe_fn { head(s, "unsafe fn"); }
|
||||
ast::pure_fn { head(s, "pure fn"); }
|
||||
}
|
||||
word(s.s, name);
|
||||
print_type_params(s, typarams);
|
||||
@ -1188,12 +1188,12 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl) {
|
||||
|
||||
fn print_arg_mode(s: ps, m: ast::mode) {
|
||||
alt m {
|
||||
ast::by_mut_ref. { word(s.s, "&"); }
|
||||
ast::by_move. { word(s.s, "-"); }
|
||||
ast::by_ref. { word(s.s, "&&"); }
|
||||
ast::by_val. { word(s.s, "++"); }
|
||||
ast::by_copy. { word(s.s, "+"); }
|
||||
ast::mode_infer. {}
|
||||
ast::by_mut_ref { word(s.s, "&"); }
|
||||
ast::by_move { word(s.s, "-"); }
|
||||
ast::by_ref { word(s.s, "&&"); }
|
||||
ast::by_val { word(s.s, "++"); }
|
||||
ast::by_copy { word(s.s, "+"); }
|
||||
ast::mode_infer {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1203,8 +1203,8 @@ fn print_bounds(s: ps, bounds: @[ast::ty_param_bound]) {
|
||||
for bound in *bounds {
|
||||
nbsp(s);
|
||||
alt bound {
|
||||
ast::bound_copy. { word(s.s, "copy"); }
|
||||
ast::bound_send. { word(s.s, "send"); }
|
||||
ast::bound_copy { word(s.s, "copy"); }
|
||||
ast::bound_send { word(s.s, "send"); }
|
||||
ast::bound_iface(t) { print_type(s, t); }
|
||||
}
|
||||
}
|
||||
@ -1335,9 +1335,9 @@ fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: int) {
|
||||
|
||||
fn print_mutability(s: ps, mut: ast::mutability) {
|
||||
alt mut {
|
||||
ast::mut. { word_nbsp(s, "mutable"); }
|
||||
ast::maybe_mut. { word_nbsp(s, "const"); }
|
||||
ast::imm. {/* nothing */ }
|
||||
ast::mut { word_nbsp(s, "mutable"); }
|
||||
ast::maybe_mut { word_nbsp(s, "const"); }
|
||||
ast::imm {/* nothing */ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1387,7 +1387,7 @@ fn maybe_print_trailing_comment(s: ps, span: codemap::span,
|
||||
let span_line = codemap::lookup_char_pos(cm, span.hi);
|
||||
let comment_line = codemap::lookup_char_pos(cm, cmnt.pos);
|
||||
let next = cmnt.pos + 1u;
|
||||
alt next_pos { none. { } some(p) { next = p; } }
|
||||
alt next_pos { none { } some(p) { next = p; } }
|
||||
if span.hi < cmnt.pos && cmnt.pos < next &&
|
||||
span_line.line == comment_line.line {
|
||||
print_comment(s, cmnt);
|
||||
@ -1427,7 +1427,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
|
||||
}
|
||||
alt lit.node {
|
||||
ast::lit_str(st) { print_string(s, st); }
|
||||
ast::lit_int(ch, ast::ty_char.) {
|
||||
ast::lit_int(ch, ast::ty_char) {
|
||||
word(s.s, "'" + escape_str(str::from_char(ch as char), '\'') + "'");
|
||||
}
|
||||
ast::lit_int(i, t) {
|
||||
@ -1439,7 +1439,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
|
||||
ast::lit_float(f, t) {
|
||||
word(s.s, f + ast_util::float_ty_to_str(t));
|
||||
}
|
||||
ast::lit_nil. { word(s.s, "()"); }
|
||||
ast::lit_nil { word(s.s, "()"); }
|
||||
ast::lit_bool(val) {
|
||||
if val { word(s.s, "true"); } else { word(s.s, "false"); }
|
||||
}
|
||||
@ -1508,7 +1508,7 @@ fn print_comment(s: ps, cmnt: lexer::cmnt) {
|
||||
end(s);
|
||||
}
|
||||
}
|
||||
lexer::blank_line. {
|
||||
lexer::blank_line {
|
||||
// We need to do at least one, possibly two hardbreaks.
|
||||
let is_semi =
|
||||
alt s.s.last_token() {
|
||||
@ -1585,7 +1585,7 @@ fn constr_args_to_str<T>(f: fn@(T) -> str, args: [@ast::sp_constr_arg<T>]) ->
|
||||
fn constr_arg_to_str<T>(f: fn@(T) -> str, c: ast::constr_arg_general_<T>) ->
|
||||
str {
|
||||
alt c {
|
||||
ast::carg_base. { ret "*"; }
|
||||
ast::carg_base { ret "*"; }
|
||||
ast::carg_ident(i) { ret f(i); }
|
||||
ast::carg_lit(l) { ret lit_to_str(l); }
|
||||
}
|
||||
@ -1635,18 +1635,18 @@ fn ast_fn_constrs_str(decl: ast::fn_decl, constrs: [@ast::constr]) -> str {
|
||||
|
||||
fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {
|
||||
alt opt_p {
|
||||
none. { "fn" }
|
||||
none { "fn" }
|
||||
some(p) { proto_to_str(p) }
|
||||
}
|
||||
}
|
||||
|
||||
fn proto_to_str(p: ast::proto) -> str {
|
||||
ret alt p {
|
||||
ast::proto_bare. { "native fn" }
|
||||
ast::proto_any. { "fn*" }
|
||||
ast::proto_block. { "fn&" }
|
||||
ast::proto_uniq. { "fn~" }
|
||||
ast::proto_box. { "fn@" }
|
||||
ast::proto_bare { "native fn" }
|
||||
ast::proto_any { "fn*" }
|
||||
ast::proto_block { "fn&" }
|
||||
ast::proto_uniq { "fn~" }
|
||||
ast::proto_box { "fn@" }
|
||||
};
|
||||
}
|
||||
|
||||
@ -1671,7 +1671,7 @@ fn ast_ty_constrs_str(constrs: [@ast::ty_constr]) -> str {
|
||||
|
||||
fn ends_in_lit_int(ex: @ast::expr) -> bool {
|
||||
alt ex.node {
|
||||
ast::expr_lit(@{node: ast::lit_int(_, ast::ty_i.), _}) { true }
|
||||
ast::expr_lit(@{node: ast::lit_int(_, ast::ty_i), _}) { true }
|
||||
ast::expr_binary(_, _, sub) | ast::expr_unary(_, sub) |
|
||||
ast::expr_ternary(_, _, sub) | ast::expr_move(_, sub) |
|
||||
ast::expr_copy(sub) | ast::expr_assign(_, sub) | ast::expr_be(sub) |
|
||||
|
@ -20,7 +20,7 @@ fn mk<T: copy>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
|
||||
fn intern<T: copy>(itr: interner<T>, val: T) -> uint {
|
||||
alt itr.map.find(val) {
|
||||
some(idx) { ret idx; }
|
||||
none. {
|
||||
none {
|
||||
let new_idx = vec::len::<T>(itr.vect);
|
||||
itr.map.insert(val, new_idx);
|
||||
itr.vect += [val];
|
||||
|
@ -26,14 +26,14 @@ tag fn_kind {
|
||||
fn name_of_fn(fk: fn_kind) -> ident {
|
||||
alt fk {
|
||||
fk_item_fn(name, _) | fk_method(name, _) | fk_res(name, _) { name }
|
||||
fk_anon(_) | fk_fn_block. { "anon" }
|
||||
fk_anon(_) | fk_fn_block { "anon" }
|
||||
}
|
||||
}
|
||||
|
||||
fn tps_of_fn(fk: fn_kind) -> [ty_param] {
|
||||
alt fk {
|
||||
fk_item_fn(_, tps) | fk_method(_, tps) | fk_res(_, tps) { tps }
|
||||
fk_anon(_) | fk_fn_block. { [] }
|
||||
fk_anon(_) | fk_fn_block { [] }
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { }
|
||||
fn visit_local<E>(loc: @local, e: E, v: vt<E>) {
|
||||
v.visit_pat(loc.node.pat, e, v);
|
||||
v.visit_ty(loc.node.ty, e, v);
|
||||
alt loc.node.init { none. { } some(i) { v.visit_expr(i.expr, e, v); } }
|
||||
alt loc.node.init { none { } some(i) { v.visit_expr(i.expr, e, v); } }
|
||||
}
|
||||
|
||||
fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
||||
@ -165,7 +165,7 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
|
||||
v.visit_ty(decl.output, e, v);
|
||||
}
|
||||
ty_path(p, _) { visit_path(p, e, v); }
|
||||
ty_type. {/* no-op */ }
|
||||
ty_type {/* no-op */ }
|
||||
ty_constr(t, cs) {
|
||||
v.visit_ty(t, e, v);
|
||||
for tc: @spanned<constr_general_<@path, node_id>> in cs {
|
||||
@ -212,7 +212,7 @@ fn visit_native_item<E>(ni: @native_item, e: E, v: vt<E>) {
|
||||
v.visit_ty_params(tps, e, v);
|
||||
visit_fn_decl(fd, e, v);
|
||||
}
|
||||
native_item_ty. { }
|
||||
native_item_ty { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ fn visit_decl<E>(d: @decl, e: E, v: vt<E>) {
|
||||
}
|
||||
|
||||
fn visit_expr_opt<E>(eo: option::t<@expr>, e: E, v: vt<E>) {
|
||||
alt eo { none. { } some(ex) { v.visit_expr(ex, e, v); } }
|
||||
alt eo { none { } some(ex) { v.visit_expr(ex, e, v); } }
|
||||
}
|
||||
|
||||
fn visit_exprs<E>(exprs: [@expr], e: E, v: vt<E>) {
|
||||
@ -278,7 +278,7 @@ fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
|
||||
ast::mac_invoc(pth, arg, body) { visit_expr(arg, e, v); }
|
||||
ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); }
|
||||
ast::mac_embed_block(blk) { v.visit_block(blk, e, v); }
|
||||
ast::mac_ellipsis. { }
|
||||
ast::mac_ellipsis { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,8 +350,8 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
|
||||
expr_index(a, b) { v.visit_expr(a, e, v); v.visit_expr(b, e, v); }
|
||||
expr_path(p) { visit_path(p, e, v); }
|
||||
expr_fail(eo) { visit_expr_opt(eo, e, v); }
|
||||
expr_break. { }
|
||||
expr_cont. { }
|
||||
expr_break { }
|
||||
expr_cont { }
|
||||
expr_ret(eo) { visit_expr_opt(eo, e, v); }
|
||||
expr_be(x) { v.visit_expr(x, e, v); }
|
||||
expr_log(_, lv, x) {
|
||||
|
@ -73,8 +73,8 @@ fn has_nonlocal_exits(b: ast::blk) -> bool {
|
||||
let has_exits = @mutable false;
|
||||
fn visit_expr(flag: @mutable bool, e: @ast::expr) {
|
||||
alt e.node {
|
||||
ast::expr_break. { *flag = true; }
|
||||
ast::expr_cont. { *flag = true; }
|
||||
ast::expr_break { *flag = true; }
|
||||
ast::expr_cont { *flag = true; }
|
||||
_ { }
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ fn make_target_lib_path(sysroot: fs::path,
|
||||
fn get_default_sysroot() -> fs::path {
|
||||
alt os::get_exe_path() {
|
||||
option::some(p) { fs::normalize(fs::connect(p, "..")) }
|
||||
option::none. {
|
||||
option::none {
|
||||
fail "can't determine value for sysroot";
|
||||
}
|
||||
}
|
||||
@ -105,17 +105,17 @@ fn get_default_sysroot() -> fs::path {
|
||||
fn get_sysroot(maybe_sysroot: option::t<fs::path>) -> fs::path {
|
||||
alt maybe_sysroot {
|
||||
option::some(sr) { sr }
|
||||
option::none. { get_default_sysroot() }
|
||||
option::none { get_default_sysroot() }
|
||||
}
|
||||
}
|
||||
|
||||
fn get_cargo_root() -> result::t<fs::path, str> {
|
||||
alt generic_os::getenv("CARGO_ROOT") {
|
||||
some(_p) { result::ok(_p) }
|
||||
none. {
|
||||
none {
|
||||
alt fs::homedir() {
|
||||
some(_q) { result::ok(fs::connect(_q, ".cargo")) }
|
||||
none. { result::err("no CARGO_ROOT or home directory") }
|
||||
none { result::err("no CARGO_ROOT or home directory") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ import middle::ast_map;
|
||||
|
||||
fn mode_str(m: ty::mode) -> str {
|
||||
alt m {
|
||||
ast::by_ref. { "&&" }
|
||||
ast::by_val. { "++" }
|
||||
ast::by_mut_ref. { "&" }
|
||||
ast::by_move. { "-" }
|
||||
ast::by_copy. { "+" }
|
||||
ast::by_ref { "&&" }
|
||||
ast::by_val { "++" }
|
||||
ast::by_mut_ref { "&" }
|
||||
ast::by_move { "-" }
|
||||
ast::by_copy { "+" }
|
||||
_ { "" }
|
||||
}
|
||||
}
|
||||
@ -23,10 +23,10 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
fn fn_input_to_str(cx: ctxt, input: {mode: middle::ty::mode, ty: t}) ->
|
||||
str {
|
||||
let modestr = alt input.mode {
|
||||
ast::by_ref. {
|
||||
ast::by_ref {
|
||||
ty::type_is_immediate(cx, input.ty) ? "&&" : ""
|
||||
}
|
||||
ast::by_val. {
|
||||
ast::by_val {
|
||||
ty::type_is_immediate(cx, input.ty) ? "" : "++"
|
||||
}
|
||||
_ { mode_str(input.mode) }
|
||||
@ -46,7 +46,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
if struct(cx, output) != ty_nil {
|
||||
s += " -> ";
|
||||
alt cf {
|
||||
ast::noreturn. { s += "!"; }
|
||||
ast::noreturn { s += "!"; }
|
||||
ast::return_val. { s += ty_to_str(cx, output); }
|
||||
}
|
||||
}
|
||||
@ -63,9 +63,9 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
fn mt_to_str(cx: ctxt, m: mt) -> str {
|
||||
let mstr;
|
||||
alt m.mut {
|
||||
ast::mut. { mstr = "mutable "; }
|
||||
ast::imm. { mstr = ""; }
|
||||
ast::maybe_mut. { mstr = "const "; }
|
||||
ast::mut { mstr = "mutable "; }
|
||||
ast::imm { mstr = ""; }
|
||||
ast::maybe_mut { mstr = "const "; }
|
||||
}
|
||||
ret mstr + ty_to_str(cx, m.ty);
|
||||
}
|
||||
@ -86,22 +86,22 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
}
|
||||
ret alt struct(cx, typ) {
|
||||
ty_native(_) { "native" }
|
||||
ty_nil. { "()" }
|
||||
ty_bot. { "_|_" }
|
||||
ty_bool. { "bool" }
|
||||
ty_int(ast::ty_i.) { "int" }
|
||||
ty_int(ast::ty_char.) { "char" }
|
||||
ty_nil { "()" }
|
||||
ty_bot { "_|_" }
|
||||
ty_bool { "bool" }
|
||||
ty_int(ast::ty_i) { "int" }
|
||||
ty_int(ast::ty_char) { "char" }
|
||||
ty_int(t) { ast_util::int_ty_to_str(t) }
|
||||
ty_uint(ast::ty_u.) { "uint" }
|
||||
ty_uint(ast::ty_u) { "uint" }
|
||||
ty_uint(t) { ast_util::uint_ty_to_str(t) }
|
||||
ty_float(ast::ty_f.) { "float" }
|
||||
ty_float(ast::ty_f) { "float" }
|
||||
ty_float(t) { ast_util::float_ty_to_str(t) }
|
||||
ty_str. { "str" }
|
||||
ty_str { "str" }
|
||||
ty_box(tm) { "@" + mt_to_str(cx, tm) }
|
||||
ty_uniq(tm) { "~" + mt_to_str(cx, tm) }
|
||||
ty_ptr(tm) { "*" + mt_to_str(cx, tm) }
|
||||
ty_vec(tm) { "[" + mt_to_str(cx, tm) + "]" }
|
||||
ty_type. { "type" }
|
||||
ty_type { "type" }
|
||||
ty_rec(elems) {
|
||||
let strs: [str] = [];
|
||||
for fld: field in elems { strs += [field_to_str(cx, fld)]; }
|
||||
|
@ -85,7 +85,7 @@ fn log_config(config: config) {
|
||||
}
|
||||
|
||||
fn opt_str(maybestr: option::t<str>) -> str {
|
||||
alt maybestr { option::some(s) { s } option::none. { "(none)" } }
|
||||
alt maybestr { option::some(s) { s } option::none { "(none)" } }
|
||||
}
|
||||
|
||||
fn str_opt(maybestr: str) -> option::t<str> {
|
||||
@ -104,10 +104,10 @@ fn str_mode(s: str) -> mode {
|
||||
|
||||
fn mode_str(mode: mode) -> str {
|
||||
alt mode {
|
||||
mode_compile_fail. { "compile-fail" }
|
||||
mode_run_fail. { "run-fail" }
|
||||
mode_run_pass. { "run-pass" }
|
||||
mode_pretty. { "pretty" }
|
||||
mode_compile_fail { "compile-fail" }
|
||||
mode_run_fail { "run-fail" }
|
||||
mode_run_pass { "run-pass" }
|
||||
mode_pretty { "pretty" }
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ fn test_opts(config: config) -> test::test_opts {
|
||||
{filter:
|
||||
alt config.filter {
|
||||
option::some(s) { option::some(s) }
|
||||
option::none. { option::none }
|
||||
option::none { option::none }
|
||||
},
|
||||
run_ignored: config.run_ignored}
|
||||
}
|
||||
@ -151,7 +151,7 @@ fn make_tests(cx: cx) -> tests_and_conv_fn {
|
||||
fn is_test(config: config, testfile: str) -> bool {
|
||||
// Pretty-printer does not work with .rc files yet
|
||||
let valid_extensions =
|
||||
alt config.mode { mode_pretty. { [".rs"] } _ { [".rc", ".rs"] } };
|
||||
alt config.mode { mode_pretty { [".rs"] } _ { [".rc", ".rs"] } };
|
||||
let invalid_prefixes = [".", "#", "~"];
|
||||
let name = fs::basename(testfile);
|
||||
|
||||
|
@ -28,7 +28,7 @@ fn load_props(testfile: str) -> test_props {
|
||||
iter_header(testfile) {|ln|
|
||||
alt parse_error_pattern(ln) {
|
||||
option::some(ep) { error_patterns += [ep]; }
|
||||
option::none. { }
|
||||
option::none { }
|
||||
};
|
||||
|
||||
if option::is_none(compile_flags) {
|
||||
@ -89,7 +89,7 @@ fn parse_compile_flags(line: str) -> option::t<str> {
|
||||
fn parse_pp_exact(line: str, testfile: str) -> option::t<str> {
|
||||
alt parse_name_value_directive(line, "pp-exact") {
|
||||
option::some(s) { option::some(s) }
|
||||
option::none. {
|
||||
option::none {
|
||||
if parse_name_directive(line, "pp-exact") {
|
||||
option::some(fs::basename(testfile))
|
||||
} else {
|
||||
|
@ -119,7 +119,7 @@ fn worker(p: port<request>) {
|
||||
args: clone_vecu8str(args),
|
||||
respchan: respchan}
|
||||
}
|
||||
stop. { ret }
|
||||
stop { ret }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -24,10 +24,10 @@ fn run(cx: cx, -_testfile: [u8]) {
|
||||
#debug("running %s", testfile);
|
||||
let props = load_props(testfile);
|
||||
alt cx.config.mode {
|
||||
mode_compile_fail. { run_cfail_test(cx, props, testfile); }
|
||||
mode_run_fail. { run_rfail_test(cx, props, testfile); }
|
||||
mode_run_pass. { run_rpass_test(cx, props, testfile); }
|
||||
mode_pretty. { run_pretty_test(cx, props, testfile); }
|
||||
mode_compile_fail { run_cfail_test(cx, props, testfile); }
|
||||
mode_run_fail { run_rfail_test(cx, props, testfile); }
|
||||
mode_run_pass { run_rpass_test(cx, props, testfile); }
|
||||
mode_pretty { run_pretty_test(cx, props, testfile); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ fn run_pretty_test(cx: cx, props: test_props, testfile: str) {
|
||||
} else { logv(cx.config, "testing for converging pretty-printing"); }
|
||||
|
||||
let rounds =
|
||||
alt props.pp_exact { option::some(_) { 1 } option::none. { 2 } };
|
||||
alt props.pp_exact { option::some(_) { 1 } option::none { 2 } };
|
||||
|
||||
let srcs = [result::get(io::read_whole_file_str(testfile))];
|
||||
|
||||
@ -120,7 +120,7 @@ fn run_pretty_test(cx: cx, props: test_props, testfile: str) {
|
||||
let filepath = fs::connect(fs::dirname(testfile), file);
|
||||
result::get(io::read_whole_file_str(filepath))
|
||||
}
|
||||
option::none. { srcs[vec::len(srcs) - 2u] }
|
||||
option::none { srcs[vec::len(srcs) - 2u] }
|
||||
};
|
||||
let actual = srcs[vec::len(srcs) - 1u];
|
||||
|
||||
@ -326,7 +326,7 @@ fn make_run_args(config: config, _props: test_props, testfile: str) ->
|
||||
let runtool =
|
||||
alt config.runtool {
|
||||
option::some(s) { option::some(s) }
|
||||
option::none. { option::none }
|
||||
option::none { option::none }
|
||||
};
|
||||
split_maybe_args(runtool)
|
||||
};
|
||||
@ -351,7 +351,7 @@ fn split_maybe_args(argstr: option::t<str>) -> [str] {
|
||||
|
||||
alt argstr {
|
||||
option::some(s) { rm_whitespace(str::split(s, ' ' as u8)) }
|
||||
option::none. { [] }
|
||||
option::none { [] }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ fn make_new_path(path: str) -> str {
|
||||
option::some(curr) {
|
||||
#fmt["%s%s%s", path, path_div(), curr]
|
||||
}
|
||||
option::none. { path }
|
||||
option::none { path }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
|
||||
|
||||
pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
|
||||
alt tm {
|
||||
tm_converge. {
|
||||
tm_converge {
|
||||
alt e.node {
|
||||
// If the fuzzer moves a block-ending-in-semicolon into callee position,
|
||||
// the pretty-printer can't preserve this even by parenthesizing!!
|
||||
@ -83,8 +83,8 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
|
||||
ast::expr_assign(_, _) { false }
|
||||
ast::expr_assign_op(_, _, _) { false }
|
||||
|
||||
ast::expr_fail(option::none.) { false }
|
||||
ast::expr_ret(option::none.) { false }
|
||||
ast::expr_fail(option::none) { false }
|
||||
ast::expr_ret(option::none) { false }
|
||||
|
||||
// https://github.com/graydon/rust/issues/953
|
||||
ast::expr_fail(option::some(_)) { false }
|
||||
@ -102,7 +102,7 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
|
||||
_ { true }
|
||||
}
|
||||
}
|
||||
tm_run. { true }
|
||||
tm_run { true }
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
|
||||
fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
|
||||
alt t {
|
||||
ast::ty_infer. { false } // always implicit, always top level
|
||||
ast::ty_bot. { false } // in source, can only appear as the out type of a function
|
||||
ast::ty_bot { false } // in source, can only appear as the out type of a function
|
||||
ast::ty_mac(_) { false }
|
||||
_ { true }
|
||||
}
|
||||
@ -268,10 +268,10 @@ fn check_variants_T<T: copy>(
|
||||
io::string_reader(""), _,
|
||||
pprust::no_ann()));
|
||||
alt cx.mode {
|
||||
tm_converge. {
|
||||
tm_converge {
|
||||
check_roundtrip_convergence(str3, 1u);
|
||||
}
|
||||
tm_run. {
|
||||
tm_run {
|
||||
let file_label = #fmt("rusttmp/%s_%s_%u_%u", last_part(filename), thing_label, i, j);
|
||||
let safe_to_run = !(content_is_dangerous_to_run(str3) || has_raw_pointers(*crate2));
|
||||
check_whole_compiler(str3, file_label, safe_to_run);
|
||||
@ -301,12 +301,12 @@ fn check_whole_compiler(code: str, suggested_filename_prefix: str, allow_running
|
||||
let compile_result = check_compiling(filename);
|
||||
|
||||
let run_result = alt (compile_result, allow_running) {
|
||||
(passed., true) { check_running(suggested_filename_prefix) }
|
||||
(passed, true) { check_running(suggested_filename_prefix) }
|
||||
(h, _) { h }
|
||||
};
|
||||
|
||||
alt run_result {
|
||||
passed. | cleanly_rejected(_) | known_bug(_) {
|
||||
passed | cleanly_rejected(_) | known_bug(_) {
|
||||
removeIfExists(suggested_filename_prefix);
|
||||
removeIfExists(suggested_filename_prefix + ".rs");
|
||||
removeDirIfExists(suggested_filename_prefix + ".dSYM");
|
||||
|
@ -95,7 +95,7 @@ pure fn is_alphanumeric(c: char) -> bool {
|
||||
pure fn to_digit(c: char) -> u8 unsafe {
|
||||
alt maybe_digit(c) {
|
||||
option::some(x) { x }
|
||||
option::none. { fail; }
|
||||
option::none { fail; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ mod ct {
|
||||
if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; }
|
||||
let n = c - ('0' as u8) as uint;
|
||||
ret alt peek_num(s, i + 1u, lim) {
|
||||
none. { some({num: n, next: i + 1u}) }
|
||||
none { some({num: n, next: i + 1u}) }
|
||||
some(next) {
|
||||
let m = next.num;
|
||||
let j = next.next;
|
||||
@ -148,7 +148,7 @@ mod ct {
|
||||
if i >= lim { ret {param: none, next: i}; }
|
||||
let num = peek_num(s, i, lim);
|
||||
ret alt num {
|
||||
none. { {param: none, next: i} }
|
||||
none { {param: none, next: i} }
|
||||
some(t) {
|
||||
let n = t.num;
|
||||
let j = t.next;
|
||||
@ -194,13 +194,13 @@ mod ct {
|
||||
let param = parse_parameter(s, i + 1u, lim);
|
||||
let j = param.next;
|
||||
alt param.param {
|
||||
none. { {count: count_is_next_param, next: j} }
|
||||
none { {count: count_is_next_param, next: j} }
|
||||
some(n) { {count: count_is_param(n), next: j} }
|
||||
}
|
||||
} else {
|
||||
let num = peek_num(s, i, lim);
|
||||
alt num {
|
||||
none. { {count: count_implied, next: i} }
|
||||
none { {count: count_implied, next: i} }
|
||||
some(num) {
|
||||
{count: count_is(num.num as int), next: num.next}
|
||||
}
|
||||
@ -218,7 +218,7 @@ mod ct {
|
||||
// If there were no digits specified, i.e. the precision
|
||||
// was ".", then the precision is 0
|
||||
alt count.count {
|
||||
count_implied. { {count: count_is(0), next: count.next} }
|
||||
count_implied { {count: count_is(0), next: count.next} }
|
||||
_ { count }
|
||||
}
|
||||
} else { {count: count_implied, next: i} };
|
||||
@ -300,11 +300,11 @@ mod rt {
|
||||
let prec = get_int_precision(cv);
|
||||
let rs =
|
||||
alt cv.ty {
|
||||
ty_default. { uint_to_str_prec(u, 10u, prec) }
|
||||
ty_hex_lower. { uint_to_str_prec(u, 16u, prec) }
|
||||
ty_hex_upper. { str::to_upper(uint_to_str_prec(u, 16u, prec)) }
|
||||
ty_bits. { uint_to_str_prec(u, 2u, prec) }
|
||||
ty_octal. { uint_to_str_prec(u, 8u, prec) }
|
||||
ty_default { uint_to_str_prec(u, 10u, prec) }
|
||||
ty_hex_lower { uint_to_str_prec(u, 16u, prec) }
|
||||
ty_hex_upper { str::to_upper(uint_to_str_prec(u, 16u, prec)) }
|
||||
ty_bits { uint_to_str_prec(u, 2u, prec) }
|
||||
ty_octal { uint_to_str_prec(u, 8u, prec) }
|
||||
};
|
||||
ret pad(cv, rs, pad_unsigned);
|
||||
}
|
||||
@ -325,7 +325,7 @@ mod rt {
|
||||
// FIXME: substr works on bytes, not chars!
|
||||
let unpadded =
|
||||
alt cv.precision {
|
||||
count_implied. { s }
|
||||
count_implied { s }
|
||||
count_is(max) {
|
||||
if max as uint < str::char_len(s) {
|
||||
str::substr(s, 0u, max as uint)
|
||||
@ -337,7 +337,7 @@ mod rt {
|
||||
fn conv_float(cv: conv, f: float) -> str {
|
||||
let (to_str, digits) = alt cv.precision {
|
||||
count_is(c) { (float::to_str_exact, c as uint) }
|
||||
count_implied. { (float::to_str, 6u) }
|
||||
count_implied { (float::to_str, 6u) }
|
||||
};
|
||||
let s = to_str(f, digits);
|
||||
if 0.0 <= f {
|
||||
@ -381,7 +381,7 @@ mod rt {
|
||||
fn get_int_precision(cv: conv) -> uint {
|
||||
ret alt cv.precision {
|
||||
count_is(c) { c as uint }
|
||||
count_implied. { 1u }
|
||||
count_implied { 1u }
|
||||
};
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ mod rt {
|
||||
fn pad(cv: conv, s: str, mode: pad_mode) -> str {
|
||||
let uwidth;
|
||||
alt cv.width {
|
||||
count_implied. { ret s; }
|
||||
count_implied { ret s; }
|
||||
count_is(width) {
|
||||
// FIXME: Maybe width should be uint
|
||||
|
||||
@ -413,15 +413,15 @@ mod rt {
|
||||
let might_zero_pad = false;
|
||||
let signed = false;
|
||||
alt mode {
|
||||
pad_nozero. {
|
||||
pad_nozero {
|
||||
// fallthrough
|
||||
|
||||
}
|
||||
pad_signed. { might_zero_pad = true; signed = true; }
|
||||
pad_unsigned. { might_zero_pad = true; }
|
||||
pad_signed { might_zero_pad = true; signed = true; }
|
||||
pad_unsigned { might_zero_pad = true; }
|
||||
}
|
||||
fn have_precision(cv: conv) -> bool {
|
||||
ret alt cv.precision { count_implied. { false } _ { true } };
|
||||
ret alt cv.precision { count_implied { false } _ { true } };
|
||||
}
|
||||
let zero_padding = false;
|
||||
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
|
||||
|
@ -31,13 +31,13 @@ Failure:
|
||||
Fails if the value equals `none`.
|
||||
*/
|
||||
pure fn get<T: copy>(opt: t<T>) -> T {
|
||||
alt opt { some(x) { ret x; } none. { fail "option none"; } }
|
||||
alt opt { some(x) { ret x; } none { fail "option none"; } }
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
fn map<T, U: copy>(opt: t<T>, f: block(T) -> U) -> t<U> {
|
||||
alt opt { some(x) { some(f(x)) } none. { none } }
|
||||
alt opt { some(x) { some(f(x)) } none { none } }
|
||||
}
|
||||
|
||||
/*
|
||||
@ -46,7 +46,7 @@ Function: is_none
|
||||
Returns true if the option equals none
|
||||
*/
|
||||
pure fn is_none<T>(opt: t<T>) -> bool {
|
||||
alt opt { none. { true } some(_) { false } }
|
||||
alt opt { none { true } some(_) { false } }
|
||||
}
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@ Function: from_maybe
|
||||
Returns the contained value or a default
|
||||
*/
|
||||
pure fn from_maybe<T: copy>(def: T, opt: t<T>) -> T {
|
||||
alt opt { some(x) { x } none. { def } }
|
||||
alt opt { some(x) { x } none { def } }
|
||||
}
|
||||
|
||||
/*
|
||||
@ -71,7 +71,7 @@ Function: maybe
|
||||
Applies a function to the contained value or returns a default
|
||||
*/
|
||||
fn maybe<T, U: copy>(def: U, opt: t<T>, f: block(T) -> U) -> U {
|
||||
alt opt { none. { def } some(t) { f(t) } }
|
||||
alt opt { none { def } some(t) { f(t) } }
|
||||
}
|
||||
|
||||
// FIXME: Can be defined in terms of the above when/if we have const bind.
|
||||
@ -81,7 +81,7 @@ Function: may
|
||||
Performs an operation on the contained value or does nothing
|
||||
*/
|
||||
fn may<T>(opt: t<T>, f: block(T)) {
|
||||
alt opt { none. {/* nothing */ } some(t) { f(t); } }
|
||||
alt opt { none {/* nothing */ } some(t) { f(t); } }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -369,8 +369,8 @@ fn try<T:send>(+f: fn~() -> T) -> result::t<T,()> {
|
||||
unsupervise();
|
||||
comm::send(ch, f());
|
||||
}) {
|
||||
tr_success. { result::ok(comm::recv(p)) }
|
||||
tr_failure. { result::err(()) }
|
||||
tr_success { result::ok(comm::recv(p)) }
|
||||
tr_failure { result::err(()) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ mod tests {
|
||||
|
||||
let t = spawn_joinable {|| winner();};
|
||||
alt join(t) {
|
||||
tr_success. {/* yay! */ }
|
||||
tr_success {/* yay! */ }
|
||||
_ { fail "invalid task status received" }
|
||||
}
|
||||
}
|
||||
@ -418,7 +418,7 @@ mod tests {
|
||||
|
||||
let t = spawn_joinable {|| failer();};
|
||||
alt join(t) {
|
||||
tr_failure. {/* yay! */ }
|
||||
tr_failure {/* yay! */ }
|
||||
_ { fail "invalid task status received" }
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ tag t<T> {
|
||||
|
||||
resource dtor_res(dtor: option::t<fn@()>) {
|
||||
alt dtor {
|
||||
option::none. { }
|
||||
option::none { }
|
||||
option::some(f) { f(); }
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ fn maybe_get_doc(d: doc, tg: uint) -> option::t<doc> {
|
||||
fn get_doc(d: doc, tg: uint) -> doc {
|
||||
alt maybe_get_doc(d, tg) {
|
||||
some(d) { ret d; }
|
||||
none. {
|
||||
none {
|
||||
#error("failed to find block with tag %u", tg);
|
||||
fail;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ mod ct {
|
||||
if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; }
|
||||
let n = c - ('0' as u8) as uint;
|
||||
ret alt peek_num(s, i + 1u, lim) {
|
||||
none. { some({num: n, next: i + 1u}) }
|
||||
none { some({num: n, next: i + 1u}) }
|
||||
some(next) {
|
||||
let m = next.num;
|
||||
let j = next.next;
|
||||
@ -147,7 +147,7 @@ mod ct {
|
||||
if i >= lim { ret {param: none, next: i}; }
|
||||
let num = peek_num(s, i, lim);
|
||||
ret alt num {
|
||||
none. { {param: none, next: i} }
|
||||
none { {param: none, next: i} }
|
||||
some(t) {
|
||||
let n = t.num;
|
||||
let j = t.next;
|
||||
@ -193,13 +193,13 @@ mod ct {
|
||||
let param = parse_parameter(s, i + 1u, lim);
|
||||
let j = param.next;
|
||||
alt param.param {
|
||||
none. { {count: count_is_next_param, next: j} }
|
||||
none { {count: count_is_next_param, next: j} }
|
||||
some(n) { {count: count_is_param(n), next: j} }
|
||||
}
|
||||
} else {
|
||||
let num = peek_num(s, i, lim);
|
||||
alt num {
|
||||
none. { {count: count_implied, next: i} }
|
||||
none { {count: count_implied, next: i} }
|
||||
some(num) {
|
||||
{count: count_is(num.num as int), next: num.next}
|
||||
}
|
||||
@ -217,7 +217,7 @@ mod ct {
|
||||
// If there were no digits specified, i.e. the precision
|
||||
// was ".", then the precision is 0
|
||||
alt count.count {
|
||||
count_implied. { {count: count_is(0), next: count.next} }
|
||||
count_implied { {count: count_is(0), next: count.next} }
|
||||
_ { count }
|
||||
}
|
||||
} else { {count: count_implied, next: i} };
|
||||
@ -297,11 +297,11 @@ mod rt {
|
||||
let prec = get_int_precision(cv);
|
||||
let rs =
|
||||
alt cv.ty {
|
||||
ty_default. { uint_to_str_prec(u, 10u, prec) }
|
||||
ty_hex_lower. { uint_to_str_prec(u, 16u, prec) }
|
||||
ty_hex_upper. { str::to_upper(uint_to_str_prec(u, 16u, prec)) }
|
||||
ty_bits. { uint_to_str_prec(u, 2u, prec) }
|
||||
ty_octal. { uint_to_str_prec(u, 8u, prec) }
|
||||
ty_default { uint_to_str_prec(u, 10u, prec) }
|
||||
ty_hex_lower { uint_to_str_prec(u, 16u, prec) }
|
||||
ty_hex_upper { str::to_upper(uint_to_str_prec(u, 16u, prec)) }
|
||||
ty_bits { uint_to_str_prec(u, 2u, prec) }
|
||||
ty_octal { uint_to_str_prec(u, 8u, prec) }
|
||||
};
|
||||
ret pad(cv, rs, pad_unsigned);
|
||||
}
|
||||
@ -322,7 +322,7 @@ mod rt {
|
||||
// FIXME: substr works on bytes, not chars!
|
||||
let unpadded =
|
||||
alt cv.precision {
|
||||
count_implied. { s }
|
||||
count_implied { s }
|
||||
count_is(max) {
|
||||
if max as uint < str::char_len(s) {
|
||||
str::substr(s, 0u, max as uint)
|
||||
@ -334,7 +334,7 @@ mod rt {
|
||||
fn conv_float(cv: conv, f: float) -> str {
|
||||
let (to_str, digits) = alt cv.precision {
|
||||
count_is(c) { (float::to_str_exact, c as uint) }
|
||||
count_implied. { (float::to_str, 6u) }
|
||||
count_implied { (float::to_str, 6u) }
|
||||
};
|
||||
let s = to_str(f, digits);
|
||||
if 0.0 <= f {
|
||||
@ -374,7 +374,7 @@ mod rt {
|
||||
fn get_int_precision(cv: conv) -> uint {
|
||||
ret alt cv.precision {
|
||||
count_is(c) { c as uint }
|
||||
count_implied. { 1u }
|
||||
count_implied { 1u }
|
||||
};
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ mod rt {
|
||||
fn pad(cv: conv, s: str, mode: pad_mode) -> str {
|
||||
let uwidth;
|
||||
alt cv.width {
|
||||
count_implied. { ret s; }
|
||||
count_implied { ret s; }
|
||||
count_is(width) {
|
||||
// FIXME: Maybe width should be uint
|
||||
|
||||
@ -406,15 +406,15 @@ mod rt {
|
||||
let might_zero_pad = false;
|
||||
let signed = false;
|
||||
alt mode {
|
||||
pad_nozero. {
|
||||
pad_nozero {
|
||||
// fallthrough
|
||||
|
||||
}
|
||||
pad_signed. { might_zero_pad = true; signed = true; }
|
||||
pad_unsigned. { might_zero_pad = true; }
|
||||
pad_signed { might_zero_pad = true; signed = true; }
|
||||
pad_unsigned { might_zero_pad = true; }
|
||||
}
|
||||
fn have_precision(cv: conv) -> bool {
|
||||
ret alt cv.precision { count_implied. { false } _ { true } };
|
||||
ret alt cv.precision { count_implied { false } _ { true } };
|
||||
}
|
||||
let zero_padding = false;
|
||||
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
|
||||
|
@ -433,7 +433,7 @@ fn homedir() -> option<path> {
|
||||
secondary()
|
||||
}
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
secondary()
|
||||
}
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ Insert a value into the map
|
||||
*/
|
||||
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) -> treemap<K, V> {
|
||||
@alt m {
|
||||
@empty. { node(@k, @v, @empty, @empty) }
|
||||
@empty { node(@k, @v, @empty, @empty) }
|
||||
@node(@kk, vv, left, right) {
|
||||
if k < kk {
|
||||
node(@kk, vv, insert(left, k, v), right)
|
||||
@ -70,7 +70,7 @@ Find a value based on the key
|
||||
*/
|
||||
fn find<K, V: copy>(m: treemap<K, V>, k: K) -> option<V> {
|
||||
alt *m {
|
||||
empty. { none }
|
||||
empty { none }
|
||||
node(@kk, @v, left, right) {
|
||||
if k == kk {
|
||||
some(v)
|
||||
@ -86,7 +86,7 @@ Visit all pairs in the map in order.
|
||||
*/
|
||||
fn traverse<K, V: copy>(m: treemap<K, V>, f: block(K, V)) {
|
||||
alt *m {
|
||||
empty. { }
|
||||
empty { }
|
||||
node(@k, @v, _, _) {
|
||||
// copy v to make aliases work out
|
||||
let v1 = v;
|
||||
|
@ -255,16 +255,16 @@ fn getopts(args: [str], opts: [opt]) -> result {
|
||||
let optid;
|
||||
alt find_opt(opts, nm) {
|
||||
some(id) { optid = id; }
|
||||
none. { ret err(unrecognized_option(name_str(nm))); }
|
||||
none { ret err(unrecognized_option(name_str(nm))); }
|
||||
}
|
||||
alt opts[optid].hasarg {
|
||||
no. {
|
||||
no {
|
||||
if !option::is_none::<str>(i_arg) {
|
||||
ret err(unexpected_argument(name_str(nm)));
|
||||
}
|
||||
vals[optid] += [given];
|
||||
}
|
||||
maybe. {
|
||||
maybe {
|
||||
if !option::is_none::<str>(i_arg) {
|
||||
vals[optid] += [val(option::get(i_arg))];
|
||||
} else if name_pos < vec::len::<name>(names) ||
|
||||
@ -272,7 +272,7 @@ fn getopts(args: [str], opts: [opt]) -> result {
|
||||
vals[optid] += [given];
|
||||
} else { i += 1u; vals[optid] += [val(args[i])]; }
|
||||
}
|
||||
yes. {
|
||||
yes {
|
||||
if !option::is_none::<str>(i_arg) {
|
||||
vals[optid] += [val(option::get::<str>(i_arg))];
|
||||
} else if i + 1u == l {
|
||||
@ -306,7 +306,7 @@ fn getopts(args: [str], opts: [opt]) -> result {
|
||||
fn opt_vals(m: match, nm: str) -> [optval] {
|
||||
ret alt find_opt(m.opts, mkname(nm)) {
|
||||
some(id) { m.vals[id] }
|
||||
none. { #error("No option '%s' defined", nm); fail }
|
||||
none { #error("No option '%s' defined", nm); fail }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -160,9 +160,9 @@ impl reader_util for reader {
|
||||
|
||||
fn convert_whence(whence: seek_style) -> i32 {
|
||||
ret alt whence {
|
||||
seek_set. { 0i32 }
|
||||
seek_cur. { 1i32 }
|
||||
seek_end. { 2i32 }
|
||||
seek_set { 0i32 }
|
||||
seek_cur { 1i32 }
|
||||
seek_end { 2i32 }
|
||||
};
|
||||
}
|
||||
|
||||
@ -347,10 +347,10 @@ fn mk_file_writer(path: str, flags: [fileflag])
|
||||
os::libc_constants::O_WRONLY | os::libc_constants::O_BINARY;
|
||||
for f: fileflag in flags {
|
||||
alt f {
|
||||
append. { fflags |= os::libc_constants::O_APPEND; }
|
||||
create. { fflags |= os::libc_constants::O_CREAT; }
|
||||
truncate. { fflags |= os::libc_constants::O_TRUNC; }
|
||||
none. { }
|
||||
append { fflags |= os::libc_constants::O_APPEND; }
|
||||
create { fflags |= os::libc_constants::O_CREAT; }
|
||||
truncate { fflags |= os::libc_constants::O_TRUNC; }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
let fd = str::as_buf(path, {|pathbuf|
|
||||
@ -469,9 +469,9 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
|
||||
let bpos = pos as int;
|
||||
let blen = len as int;
|
||||
alt whence {
|
||||
seek_set. { bpos = offset; }
|
||||
seek_cur. { bpos += offset; }
|
||||
seek_end. { bpos = blen + offset; }
|
||||
seek_set { bpos = offset; }
|
||||
seek_cur { bpos += offset; }
|
||||
seek_end { bpos = blen + offset; }
|
||||
}
|
||||
if bpos < 0 { bpos = 0; } else if bpos > blen { bpos = blen; }
|
||||
ret bpos as uint;
|
||||
@ -512,7 +512,7 @@ mod fsync {
|
||||
// Resource of artifacts that need to fsync on destruction
|
||||
resource res<t>(arg: arg<t>) {
|
||||
alt arg.opt_level {
|
||||
option::none. { }
|
||||
option::none { }
|
||||
option::some(level) {
|
||||
// fail hard if not succesful
|
||||
assert(arg.fsync_fn(arg.val, level) != -1);
|
||||
|
@ -67,9 +67,9 @@ fn find<T: copy, U: copy>(ls: list<T>, f: block(T) -> option::t<U>)
|
||||
while true {
|
||||
alt ls {
|
||||
cons(hd, tl) {
|
||||
alt f(hd) { none. { ls = *tl; } some(rs) { ret some(rs); } }
|
||||
alt f(hd) { none { ls = *tl; } some(rs) { ret some(rs); } }
|
||||
}
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
ret none;
|
||||
@ -85,7 +85,7 @@ fn has<T: copy>(ls: list<T>, elt: T) -> bool {
|
||||
while true {
|
||||
alt ls {
|
||||
cons(hd, tl) { if elt == hd { ret true; } else { ls = *tl; } }
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
ret false;
|
||||
@ -98,7 +98,7 @@ Returns true if the list is empty.
|
||||
*/
|
||||
pure fn is_empty<T: copy>(ls: list<T>) -> bool {
|
||||
alt ls {
|
||||
nil. { true }
|
||||
nil { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ Returns all but the first element of a list
|
||||
pure fn tail<T: copy>(ls: list<T>) : is_not_empty(ls) -> list<T> {
|
||||
alt ls {
|
||||
cons(_, tl) { ret *tl; }
|
||||
nil. { fail "list empty" }
|
||||
nil { fail "list empty" }
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ Returns the first element of a list
|
||||
pure fn head<T: copy>(ls: list<T>) : is_not_empty(ls) -> T {
|
||||
alt ls {
|
||||
cons(hd, _) { ret hd; }
|
||||
nil. { fail "list empty" }
|
||||
nil { fail "list empty" }
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ Appends one list to another
|
||||
*/
|
||||
pure fn append<T: copy>(l: list<T>, m: list<T>) -> list<T> {
|
||||
alt l {
|
||||
nil. { ret m; }
|
||||
nil { ret m; }
|
||||
cons(x, xs) { let rest = append(*xs, m); ret cons(x, @rest); }
|
||||
}
|
||||
}
|
||||
@ -175,11 +175,11 @@ fn iter<T>(l: list<T>, f: block(T)) {
|
||||
f(hd);
|
||||
cur = tl;
|
||||
}
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
nil. {}
|
||||
nil {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ mod chained {
|
||||
let comp = 1u; // for logging
|
||||
while true {
|
||||
alt e0.next {
|
||||
absent. {
|
||||
absent {
|
||||
#debug("search_tbl: absent, comp %u, hash %u, idx %u",
|
||||
comp, h, idx);
|
||||
ret not_found;
|
||||
@ -162,7 +162,7 @@ mod chained {
|
||||
tbl: t<K,V>, k: K, h: uint) -> search_result<K,V> {
|
||||
let idx = h % vec::len(tbl.chains);
|
||||
alt tbl.chains[idx] {
|
||||
absent. {
|
||||
absent {
|
||||
#debug("search_tbl: absent, comp %u, hash %u, idx %u",
|
||||
0u, h, idx);
|
||||
ret not_found;
|
||||
@ -183,7 +183,7 @@ mod chained {
|
||||
fn insert<K: copy, V: copy>(tbl: t<K,V>, k: K, v: V) -> bool {
|
||||
let hash = tbl.hasher(k);
|
||||
alt search_tbl(tbl, k, hash) {
|
||||
not_found. {
|
||||
not_found {
|
||||
tbl.size += 1u;
|
||||
let idx = hash % vec::len(tbl.chains);
|
||||
let old_chain = tbl.chains[idx];
|
||||
@ -207,7 +207,7 @@ mod chained {
|
||||
|
||||
fn get<K: copy, V: copy>(tbl: t<K,V>, k: K) -> core::option::t<V> {
|
||||
alt search_tbl(tbl, k, tbl.hasher(k)) {
|
||||
not_found. {
|
||||
not_found {
|
||||
ret core::option::none;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ mod chained {
|
||||
|
||||
fn remove<K: copy, V: copy>(tbl: t<K,V>, k: K) -> core::option::t<V> {
|
||||
alt search_tbl(tbl, k, tbl.hasher(k)) {
|
||||
not_found. {
|
||||
not_found {
|
||||
ret core::option::none;
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ mod chained {
|
||||
let chain = chain0;
|
||||
while true {
|
||||
alt chain {
|
||||
absent. { ret; }
|
||||
absent { ret; }
|
||||
present(entry) {
|
||||
let next = entry.next;
|
||||
blk(entry); // may modify entry.next!
|
||||
@ -569,7 +569,7 @@ mod tests {
|
||||
let v = hm.remove(i);
|
||||
alt v {
|
||||
option::some(u) { assert (u == i * i); }
|
||||
option::none. { fail; }
|
||||
option::none { fail; }
|
||||
}
|
||||
i += 2u;
|
||||
}
|
||||
|
@ -156,10 +156,10 @@ Concatenate two ropes
|
||||
*/
|
||||
fn append_rope(left: rope, right: rope) -> rope {
|
||||
alt(left) {
|
||||
node::empty. { ret right; }
|
||||
node::empty { ret right; }
|
||||
node::content(left_content) {
|
||||
alt(right) {
|
||||
node::empty. { ret left; }
|
||||
node::empty { ret left; }
|
||||
node::content(right_content) {
|
||||
ret node::content(node::concat2(left_content, right_content));
|
||||
}
|
||||
@ -224,10 +224,10 @@ to rebalance your rope at some point, before using it for other purposes.
|
||||
*/
|
||||
fn bal(rope:rope) -> rope {
|
||||
alt(rope) {
|
||||
node::empty. { ret rope }
|
||||
node::empty { ret rope }
|
||||
node::content(x) {
|
||||
alt(node::bal(x)) {
|
||||
option::none. { rope }
|
||||
option::none { rope }
|
||||
option::some(y) { node::content(y) }
|
||||
}
|
||||
}
|
||||
@ -255,7 +255,7 @@ valid positions in rope
|
||||
fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope {
|
||||
if char_len == 0u { ret node::empty; }
|
||||
alt(rope) {
|
||||
node::empty. { fail }
|
||||
node::empty { fail }
|
||||
node::content(node) {
|
||||
if char_len > node::char_len(node) { fail }
|
||||
else {
|
||||
@ -281,7 +281,7 @@ valid positions in rope
|
||||
fn sub_bytes(rope: rope, byte_offset: uint, byte_len: uint) -> rope {
|
||||
if byte_len == 0u { ret node::empty; }
|
||||
alt(rope) {
|
||||
node::empty. { fail }
|
||||
node::empty { fail }
|
||||
node::content(node) {
|
||||
if byte_len > node::byte_len(node) { fail }
|
||||
else {
|
||||
@ -309,9 +309,9 @@ value if `left > right`
|
||||
*/
|
||||
fn cmp(left: rope, right: rope) -> int {
|
||||
alt((left, right)) {
|
||||
(node::empty., node::empty.) { ret 0; }
|
||||
(node::empty., _) { ret -1;}
|
||||
(_, node::empty.) { ret 1;}
|
||||
(node::empty, node::empty) { ret 0; }
|
||||
(node::empty, _) { ret -1;}
|
||||
(_, node::empty) { ret 1;}
|
||||
(node::content(a), node::content(b)) {
|
||||
ret node::cmp(a, b);
|
||||
}
|
||||
@ -421,7 +421,7 @@ that is if `it` returned `false` at any point.
|
||||
*/
|
||||
fn loop_chars(rope: rope, it: block(char) -> bool) -> bool {
|
||||
alt(rope) {
|
||||
node::empty. { ret true }
|
||||
node::empty { ret true }
|
||||
node::content(x) { ret node::loop_chars(x, it) }
|
||||
}
|
||||
}
|
||||
@ -432,7 +432,7 @@ Function: iter_chars
|
||||
Loop through a rope, char by char, until the end.
|
||||
|
||||
Parameters:
|
||||
rope - A rope to traverse. It may be empty.
|
||||
rope - A rope to traverse. It may be empty
|
||||
it - A block to execute with each consecutive character of the rope.
|
||||
*/
|
||||
fn iter_chars(rope: rope, it: block(char)) {
|
||||
@ -457,9 +457,9 @@ use `traverse`.
|
||||
|
||||
Parameters:
|
||||
|
||||
rope - A rope to traverse. It may be empty.
|
||||
rope - A rope to traverse. It may be empty
|
||||
it - A block to execute with each consecutive string component of the rope.
|
||||
Return `true` to continue, `false` to stop.
|
||||
Return `true` to continue, `false` to stop
|
||||
|
||||
Returns:
|
||||
|
||||
@ -468,7 +468,7 @@ that is if `it` returned `false` at any point.
|
||||
*/
|
||||
fn loop_leaves(rope: rope, it: block(node::leaf) -> bool) -> bool{
|
||||
alt(rope) {
|
||||
node::empty. { ret true }
|
||||
node::empty { ret true }
|
||||
node::content(x) {ret node::loop_leaves(x, it)}
|
||||
}
|
||||
}
|
||||
@ -477,7 +477,7 @@ mod iterator {
|
||||
mod leaf {
|
||||
fn start(rope: rope) -> node::leaf_iterator::t {
|
||||
alt(rope) {
|
||||
node::empty. { ret node::leaf_iterator::empty() }
|
||||
node::empty { ret node::leaf_iterator::empty() }
|
||||
node::content(x) { ret node::leaf_iterator::start(x) }
|
||||
}
|
||||
}
|
||||
@ -488,7 +488,7 @@ mod iterator {
|
||||
mod char {
|
||||
fn start(rope: rope) -> node::char_iterator::t {
|
||||
alt(rope) {
|
||||
node::empty. { ret node::char_iterator::empty() }
|
||||
node::empty { ret node::char_iterator::empty() }
|
||||
node::content(x) { ret node::char_iterator::start(x) }
|
||||
}
|
||||
}
|
||||
@ -513,7 +513,7 @@ finding the leaf in which a character is contained.
|
||||
*/
|
||||
fn height(rope: rope) -> uint {
|
||||
alt(rope) {
|
||||
node::empty. { ret 0u; }
|
||||
node::empty { ret 0u; }
|
||||
node::content(x) { ret node::height(x); }
|
||||
}
|
||||
}
|
||||
@ -529,7 +529,7 @@ fn height(rope: rope) -> uint {
|
||||
*/
|
||||
pure fn char_len(rope: rope) -> uint {
|
||||
alt(rope) {
|
||||
node::empty. { ret 0u; }
|
||||
node::empty { ret 0u; }
|
||||
node::content(x) { ret node::char_len(x) }
|
||||
}
|
||||
}
|
||||
@ -543,7 +543,7 @@ pure fn char_len(rope: rope) -> uint {
|
||||
*/
|
||||
pure fn byte_len(rope: rope) -> uint {
|
||||
alt(rope) {
|
||||
node::empty. { ret 0u; }
|
||||
node::empty { ret 0u; }
|
||||
node::content(x) { ret node::byte_len(x) }
|
||||
}
|
||||
}
|
||||
@ -565,7 +565,7 @@ pure fn byte_len(rope: rope) -> uint {
|
||||
*/
|
||||
fn char_at(rope: rope, pos: uint) -> char {
|
||||
alt(rope) {
|
||||
node::empty. { fail }
|
||||
node::empty { fail }
|
||||
node::content(x) { ret node::char_at(x, pos) }
|
||||
}
|
||||
}
|
||||
@ -730,7 +730,7 @@ mod node {
|
||||
|
||||
If the slice is longer than `max_leaf_char_len`, it is logically split
|
||||
between as many leaves as necessary. Regardless, the string itself
|
||||
is not copied.
|
||||
is not copied
|
||||
|
||||
Parameters:
|
||||
byte_start - The byte offset where the slice of `str` starts.
|
||||
@ -752,7 +752,7 @@ mod node {
|
||||
|
||||
If the slice is longer than `max_leaf_char_len`, it is logically split
|
||||
between as many leaves as necessary. Regardless, the string itself
|
||||
is not copied.
|
||||
is not copied
|
||||
|
||||
byte_start - The byte offset where the slice of `str` starts.
|
||||
byte_len - The number of bytes from `str` to use.
|
||||
@ -897,7 +897,7 @@ mod node {
|
||||
let it = leaf_iterator::start(node);
|
||||
while true {
|
||||
alt(leaf_iterator::next(it)) {
|
||||
option::none. { break; }
|
||||
option::none { break; }
|
||||
option::some(x) {
|
||||
//TODO: Replace with memcpy or something similar
|
||||
let local_buf: [u8] = unsafe::reinterpret_cast(*x.content);
|
||||
@ -959,7 +959,7 @@ mod node {
|
||||
let it = leaf_iterator::start(node);
|
||||
while true {
|
||||
alt (leaf_iterator::next(it)) {
|
||||
option::none. { break; }
|
||||
option::none { break; }
|
||||
option::some(x) { forest += [mutable @leaf(x)]; }
|
||||
}
|
||||
}
|
||||
@ -1117,7 +1117,7 @@ mod node {
|
||||
let pos = 0u;
|
||||
while result == 0 {
|
||||
alt((char_iterator::next(ita), char_iterator::next(itb))) {
|
||||
(option::none., option::none.) {
|
||||
(option::none, option::none) {
|
||||
break;
|
||||
}
|
||||
(option::some(chara), option::some(charb)) {
|
||||
@ -1152,7 +1152,7 @@ mod node {
|
||||
|
||||
rope - A node to traverse.
|
||||
it - A block to execute with each consecutive leaf of the node.
|
||||
Return `true` to continue, `false` to stop.
|
||||
Return `true` to continue, `false` to stop
|
||||
|
||||
Returns:
|
||||
|
||||
@ -1277,11 +1277,11 @@ mod node {
|
||||
fn next(it: t) -> option::t<char> {
|
||||
while true {
|
||||
alt(get_current_or_next_leaf(it)) {
|
||||
option::none. { ret option::none; }
|
||||
option::none { ret option::none; }
|
||||
option::some(_) {
|
||||
let next_char = get_next_char_in_leaf(it);
|
||||
alt(next_char) {
|
||||
option::none. {
|
||||
option::none {
|
||||
cont;
|
||||
}
|
||||
option::some(_) {
|
||||
@ -1297,10 +1297,10 @@ mod node {
|
||||
fn get_current_or_next_leaf(it: t) -> option::t<leaf> {
|
||||
alt(it.leaf) {
|
||||
option::some(_) { ret it.leaf }
|
||||
option::none. {
|
||||
option::none {
|
||||
let next = leaf_iterator::next(it.leaf_iterator);
|
||||
alt(next) {
|
||||
option::none. { ret option::none }
|
||||
option::none { ret option::none }
|
||||
option::some(_) {
|
||||
it.leaf = next;
|
||||
it.leaf_byte_pos = 0u;
|
||||
@ -1313,7 +1313,7 @@ mod node {
|
||||
|
||||
fn get_next_char_in_leaf(it: t) -> option::t<char> {
|
||||
alt(it.leaf) {
|
||||
option::none. { ret option::none }
|
||||
option::none { ret option::none }
|
||||
option::some(aleaf) {
|
||||
if it.leaf_byte_pos >= aleaf.byte_len {
|
||||
//We are actually past the end of the leaf
|
||||
@ -1338,7 +1338,7 @@ mod tests {
|
||||
//Utility function, used for sanity check
|
||||
fn rope_to_string(r: rope) -> str {
|
||||
alt(r) {
|
||||
node::empty. { ret "" }
|
||||
node::empty { ret "" }
|
||||
node::content(x) {
|
||||
let str = @mutable "";
|
||||
fn aux(str: @mutable str, node: @node::node) {
|
||||
@ -1392,7 +1392,7 @@ mod tests {
|
||||
let pos = 0u;
|
||||
while equal {
|
||||
alt(node::char_iterator::next(rope_iter)) {
|
||||
option::none. {
|
||||
option::none {
|
||||
if string_iter < string_len {
|
||||
equal = false;
|
||||
} break; }
|
||||
@ -1420,7 +1420,7 @@ mod tests {
|
||||
let it = iterator::char::start(r);
|
||||
while true {
|
||||
alt(node::char_iterator::next(it)) {
|
||||
option::none. { break; }
|
||||
option::none { break; }
|
||||
option::some(_) { len += 1u; }
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ fn insert<T: copy>(m: smallintmap<T>, key: uint, val: T) {
|
||||
Function: find
|
||||
|
||||
Get the value for the specified key. If the key does not exist
|
||||
in the map then returns none.
|
||||
in the map then returns none
|
||||
*/
|
||||
fn find<T: copy>(m: smallintmap<T>, key: uint) -> option::t<T> {
|
||||
if key < vec::len::<option::t<T>>(m.v) { ret m.v[key]; }
|
||||
@ -56,7 +56,7 @@ If the key does not exist in the map
|
||||
*/
|
||||
fn get<T: copy>(m: smallintmap<T>, key: uint) -> T {
|
||||
alt find(m, key) {
|
||||
none. { #error("smallintmap::get(): key not present"); fail; }
|
||||
none { #error("smallintmap::get(): key not present"); fail; }
|
||||
some(v) { ret v; }
|
||||
}
|
||||
}
|
||||
@ -117,7 +117,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
|
||||
some(elt) {
|
||||
it(idx, elt);
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
idx += 1u;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ fn color_supported() -> bool {
|
||||
}
|
||||
false
|
||||
}
|
||||
option::none. { false }
|
||||
option::none { false }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -131,18 +131,18 @@ fn run_tests_console_<T: copy>(opts: test_opts, tests: [test_desc<T>],
|
||||
te_wait(test) { st.out.write_str(#fmt["test %s ... ", test.name]); }
|
||||
te_result(test, result) {
|
||||
alt result {
|
||||
tr_ok. {
|
||||
tr_ok {
|
||||
st.passed += 1u;
|
||||
write_ok(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
}
|
||||
tr_failed. {
|
||||
tr_failed {
|
||||
st.failed += 1u;
|
||||
write_failed(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
st.failures += [test];
|
||||
}
|
||||
tr_ignored. {
|
||||
tr_ignored {
|
||||
st.ignored += 1u;
|
||||
write_ignored(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
@ -260,7 +260,7 @@ fn filter_tests<T: copy>(opts: test_opts,
|
||||
let filter_str =
|
||||
alt opts.filter {
|
||||
option::some(f) { f }
|
||||
option::none. { "" }
|
||||
option::none { "" }
|
||||
};
|
||||
|
||||
fn filter_fn<T: copy>(test: test_desc<T>, filter_str: str) ->
|
||||
@ -315,11 +315,11 @@ fn run_test<T: copy>(test: test_desc<T>,
|
||||
ret {test: test,
|
||||
wait: fn@() -> test_result {
|
||||
alt task::join(test_task) {
|
||||
task::tr_success. {
|
||||
task::tr_success {
|
||||
if test.should_fail { tr_failed }
|
||||
else { tr_ok }
|
||||
}
|
||||
task::tr_failure. {
|
||||
task::tr_failure {
|
||||
if test.should_fail { tr_ok }
|
||||
else { tr_failed }
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ Insert a value into the map
|
||||
*/
|
||||
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) {
|
||||
alt m {
|
||||
@empty. { *m = node(@k, @v, @mutable empty, @mutable empty); }
|
||||
@empty { *m = node(@k, @v, @mutable empty, @mutable empty); }
|
||||
@node(@kk, _, _, _) {
|
||||
|
||||
// We have to name left and right individually, because
|
||||
@ -65,7 +65,7 @@ Find a value based on the key
|
||||
*/
|
||||
fn find<K: copy, V: copy>(m: treemap<K, V>, k: K) -> option<V> {
|
||||
alt *m {
|
||||
empty. { none }
|
||||
empty { none }
|
||||
node(@kk, @v, _, _) {
|
||||
if k == kk {
|
||||
some(v)
|
||||
@ -85,7 +85,7 @@ Visit all pairs in the map in order.
|
||||
*/
|
||||
fn traverse<K, V>(m: treemap<K, V>, f: block(K, V)) {
|
||||
alt *m {
|
||||
empty. { }
|
||||
empty { }
|
||||
node(k, v, _, _) {
|
||||
let k1 = k, v1 = v;
|
||||
alt *m { node(_, _, left, _) { traverse(left, f); } }
|
||||
|
@ -27,7 +27,7 @@ fn grow(ufnd: ufind, n: uint) {
|
||||
|
||||
fn find(ufnd: ufind, n: uint) -> uint {
|
||||
alt ufnd.nodes[n] {
|
||||
none. { ret n; }
|
||||
none { ret n; }
|
||||
some(m) { let m_ = m; be find(ufnd, m_); }
|
||||
}
|
||||
}
|
||||
|
@ -157,21 +157,21 @@ fn parse_short_doc_or<T>(
|
||||
some(meta) {
|
||||
alt attr::get_meta_item_value_str(meta) {
|
||||
some(desc) { handle_short(some(desc)) }
|
||||
none. {
|
||||
none {
|
||||
alt attr::get_meta_item_list(meta) {
|
||||
some(list) {
|
||||
let brief = attr::meta_item_value_from_list(list, "brief");
|
||||
let desc = attr::meta_item_value_from_list(list, "desc");
|
||||
parse_long(list, brief, desc)
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
handle_short(none)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
handle_short(none)
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ fn parse_fn_long_doc(
|
||||
}
|
||||
}
|
||||
}
|
||||
none. { [] }
|
||||
none { [] }
|
||||
};
|
||||
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ fn write_brief(
|
||||
ctxt.w.write_line(brief);
|
||||
ctxt.w.write_line("");
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ fn write_desc(
|
||||
ctxt.w.write_line(desc);
|
||||
ctxt.w.write_line("");
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,13 +208,13 @@ fn write_return(
|
||||
some(d) {
|
||||
ctxt.w.write_line(d);
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
none. { fail "unimplemented"; }
|
||||
none { fail "unimplemented"; }
|
||||
}
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,13 @@ tag bottle { none; dual; single; multiple(int); }
|
||||
|
||||
fn show(b: bottle) {
|
||||
alt b {
|
||||
none. {
|
||||
none {
|
||||
#debug("No more bottles of beer on the wall, \
|
||||
no more bottles of beer,");
|
||||
#debug("Go to the store and buy some more, \
|
||||
99 bottles of beer on the wall.");
|
||||
}
|
||||
single. {
|
||||
single {
|
||||
#debug("1 bottle of beer on the wall, 1 bottle of beer,");
|
||||
#debug("Take one down and pass it around, \
|
||||
no more bottles of beer on the wall.");
|
||||
@ -38,8 +38,8 @@ fn show(b: bottle) {
|
||||
|
||||
fn next(b: bottle) -> bottle {
|
||||
alt b {
|
||||
none. { ret none; }
|
||||
single. { ret none; }
|
||||
none { ret none; }
|
||||
single { ret none; }
|
||||
dual. { ret single; }
|
||||
multiple(3) { ret dual; }
|
||||
multiple(n) { ret multiple(n - 1); }
|
||||
@ -48,7 +48,7 @@ fn next(b: bottle) -> bottle {
|
||||
|
||||
|
||||
// Won't need this when tags can be compared with ==
|
||||
fn more(b: bottle) -> bool { alt b { none. { ret false; } _ { ret true; } } }
|
||||
fn more(b: bottle) -> bool { alt b { none { ret false; } _ { ret true; } } }
|
||||
|
||||
fn main() {
|
||||
let b: bottle = multiple(99);
|
||||
|
@ -5,7 +5,7 @@ tag tree { nil; node(~tree, ~tree, int); }
|
||||
|
||||
fn item_check(t: ~tree) -> int {
|
||||
alt *t {
|
||||
nil. { ret 0; }
|
||||
nil { ret 0; }
|
||||
node(left, right, item) {
|
||||
ret item + item_check(left) - item_check(right);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ fn map(&&filename: [u8], emit: map_reduce::putter<[u8], int>) {
|
||||
while true {
|
||||
alt read_word(f) {
|
||||
some(w) { emit(str::bytes(w), 1); }
|
||||
none. { break; }
|
||||
none { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,7 +45,7 @@ fn map(&&filename: [u8], emit: map_reduce::putter<[u8], int>) {
|
||||
fn reduce(&&_word: [u8], get: map_reduce::getter<int>) {
|
||||
let count = 0;
|
||||
|
||||
while true { alt get() { some(_) { count += 1; } none. { break; } } }
|
||||
while true { alt get() { some(_) { count += 1; } none { break; } } }
|
||||
}
|
||||
|
||||
mod map_reduce {
|
||||
@ -97,7 +97,7 @@ mod map_reduce {
|
||||
let c;
|
||||
alt treemap::find(im, key) {
|
||||
some(_c) { c = _c; }
|
||||
none. {
|
||||
none {
|
||||
let p = port();
|
||||
send(ctrl, find_reducer(key, chan(p)));
|
||||
c = recv(p);
|
||||
@ -136,7 +136,7 @@ mod map_reduce {
|
||||
// #error("received %d", v);
|
||||
ret some(v);
|
||||
}
|
||||
done. {
|
||||
done {
|
||||
// #error("all done");
|
||||
is_done = true;
|
||||
}
|
||||
@ -166,7 +166,7 @@ mod map_reduce {
|
||||
|
||||
while num_mappers > 0 {
|
||||
alt recv(ctrl) {
|
||||
mapper_done. {
|
||||
mapper_done {
|
||||
// #error("received mapper terminated.");
|
||||
num_mappers -= 1;
|
||||
}
|
||||
@ -179,7 +179,7 @@ mod map_reduce {
|
||||
// "reusing existing reducer for " + k);
|
||||
c = _c;
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
// log(error, "creating new reducer for " + k);
|
||||
let p = port();
|
||||
let ch = chan(p);
|
||||
|
@ -26,14 +26,14 @@ fn map(input: str, emit: map_reduce::putter) {
|
||||
|
||||
|
||||
while true {
|
||||
alt read_word(f) { some(w) { emit(w, 1); } none. { break; } }
|
||||
alt read_word(f) { some(w) { emit(w, 1); } none { break; } }
|
||||
}
|
||||
}
|
||||
|
||||
fn reduce(_word: str, get: map_reduce::getter) {
|
||||
let count = 0;
|
||||
|
||||
while true { alt get() { some(_) { count += 1; } none. { break; } } }
|
||||
while true { alt get() { some(_) { count += 1; } none { break; } } }
|
||||
}
|
||||
|
||||
mod map_reduce {
|
||||
@ -78,7 +78,7 @@ mod map_reduce {
|
||||
some(_c) {
|
||||
c = _c;
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
let p = port();
|
||||
send(ctrl, find_reducer(key, chan(p)));
|
||||
c = recv(p);
|
||||
@ -112,7 +112,7 @@ mod map_reduce {
|
||||
// #error("received %d", v);
|
||||
ret some(v);
|
||||
}
|
||||
done. {
|
||||
done {
|
||||
// #error("all done");
|
||||
state.is_done = true;
|
||||
}
|
||||
@ -141,7 +141,7 @@ mod map_reduce {
|
||||
|
||||
while num_mappers > 0 {
|
||||
alt recv(ctrl) {
|
||||
mapper_done. {
|
||||
mapper_done {
|
||||
// #error("received mapper terminated.");
|
||||
num_mappers -= 1;
|
||||
}
|
||||
@ -154,7 +154,7 @@ mod map_reduce {
|
||||
// "reusing existing reducer for " + k);
|
||||
c = _c;
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
// log(error, "creating new reducer for " + k);
|
||||
let p = port();
|
||||
let ch = chan(p);
|
||||
|
@ -46,7 +46,7 @@ mod map_reduce {
|
||||
let c;
|
||||
alt im.find(key) {
|
||||
some(_c) { c = _c }
|
||||
none. {
|
||||
none {
|
||||
let p = port();
|
||||
#error("sending find_reducer");
|
||||
send(ctrl, find_reducer(str::bytes(key), chan(p)));
|
||||
@ -78,12 +78,12 @@ mod map_reduce {
|
||||
|
||||
while num_mappers > 0 {
|
||||
alt recv(ctrl) {
|
||||
mapper_done. { num_mappers -= 1; }
|
||||
mapper_done { num_mappers -= 1; }
|
||||
find_reducer(k, cc) {
|
||||
let c;
|
||||
alt reducers.find(str::unsafe_from_bytes(k)) {
|
||||
some(_c) { c = _c; }
|
||||
none. { c = 0; }
|
||||
none { c = 0; }
|
||||
}
|
||||
send(cc, c);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ iface to_str {
|
||||
impl <T: to_str> of to_str for option<T> {
|
||||
fn to_str() -> str {
|
||||
alt self {
|
||||
none. { "none" }
|
||||
none { "none" }
|
||||
some(t) { "some(" + t.to_str() + ")" }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use std;
|
||||
import std::list::*;
|
||||
|
||||
pure fn pure_length_go<T: copy>(ls: list<T>, acc: uint) -> uint {
|
||||
alt ls { nil. { acc } cons(_, tl) { pure_length_go(*tl, acc + 1u) } }
|
||||
alt ls { nil { acc } cons(_, tl) { pure_length_go(*tl, acc + 1u) } }
|
||||
}
|
||||
|
||||
pure fn pure_length<T: copy>(ls: list<T>) -> uint { pure_length_go(ls, 0u) }
|
||||
|
@ -9,7 +9,7 @@ import std::list::*;
|
||||
// no syntax for specifying that f is pure.
|
||||
fn pure_foldl<T: copy, U: copy>(ls: list<T>, u: U, f: block(T, U) -> U) -> U {
|
||||
alt ls {
|
||||
nil. { u }
|
||||
nil { u }
|
||||
cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user