1
Fork 0

Port the compiler to the typaram foo<T> syntax.

This commit is contained in:
Erick Tryzelaar 2011-08-12 07:15:18 -07:00 committed by Graydon Hoare
parent f764f9a8cf
commit e4a0f997fb
51 changed files with 568 additions and 568 deletions

View file

@ -33,7 +33,7 @@ The 3 central data structures:
structure: structure:
- Many -- though not all -- nodes within this data structure are - Many -- though not all -- nodes within this data structure are
wrapped in the type spanned[T], meaning that the front-end has wrapped in the type spanned<T>, meaning that the front-end has
marked the input coordinates of that node. The member .node is marked the input coordinates of that node. The member .node is
the data itself, the member .span is the input location (file, the data itself, the member .span is the input location (file,
line, column; both low and high). line, column; both low and high).

View file

@ -285,14 +285,14 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
sha: sha1) -> link_meta { sha: sha1) -> link_meta {
type provided_metas = type provided_metas =
{name: option::t[str], {name: option::t<str>,
vers: option::t[str], vers: option::t<str>,
cmh_items: [@ast::meta_item]}; cmh_items: [@ast::meta_item]};
fn provided_link_metas(sess: &session::session, c: &ast::crate) -> fn provided_link_metas(sess: &session::session, c: &ast::crate) ->
provided_metas { provided_metas {
let name: option::t[str] = none; let name: option::t<str> = none;
let vers: option::t[str] = none; let vers: option::t<str> = none;
let cmh_items: [@ast::meta_item] = ~[]; let cmh_items: [@ast::meta_item] = ~[];
let linkage_metas = attr::find_linkage_metas(c.node.attrs); let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess, linkage_metas); attr::require_unique_names(sess, linkage_metas);

View file

@ -437,7 +437,7 @@ fn opts() -> [getopts::opt] {
optflag("lib"), optflag("static"), optflag("gc")]; optflag("lib"), optflag("static"), optflag("gc")];
} }
fn main(args: vec[str]) { fn main(args: vec<str>) {
let args_ivec = vec::from_vec(args); let args_ivec = vec::from_vec(args);
let binary = vec::shift(args_ivec); let binary = vec::shift(args_ivec);
let binary_dir = fs::dirname(binary); let binary_dir = fs::dirname(binary);

View file

@ -54,7 +54,7 @@ obj session(targ_cfg: @config,
parse_sess: parse_sess, parse_sess: parse_sess,
// For a library crate, this is always none // For a library crate, this is always none
mutable main_fn: option::t[node_id], mutable main_fn: option::t<node_id>,
mutable err_count: uint) { mutable err_count: uint) {
fn get_targ_cfg() -> @config { ret targ_cfg; } fn get_targ_cfg() -> @config { ret targ_cfg; }
fn get_opts() -> @options { ret opts; } fn get_opts() -> @options { ret opts; }
@ -111,7 +111,7 @@ obj session(targ_cfg: @config,
ret codemap::span_to_str(sp, self.get_codemap()); ret codemap::span_to_str(sp, self.get_codemap());
} }
fn set_main_id(d: node_id) { main_fn = some(d); } fn set_main_id(d: node_id) { main_fn = some(d); }
fn get_main_id() -> option::t[node_id] { main_fn } fn get_main_id() -> option::t<node_id> { main_fn }
} }
// Local Variables: // Local Variables:
// fill-column: 78; // fill-column: 78;

View file

@ -45,7 +45,7 @@ fn find_attrs_by_name(attrs: &[ast::attribute], name: ast::ident) ->
[ast::attribute] { [ast::attribute] {
let filter = let filter =
bind fn (a: &ast::attribute, name: ast::ident) -> bind fn (a: &ast::attribute, name: ast::ident) ->
option::t[ast::attribute] { option::t<ast::attribute> {
if get_attr_name(a) == name { if get_attr_name(a) == name {
option::some(a) option::some(a)
} else { option::none } } else { option::none }
@ -61,7 +61,7 @@ fn find_meta_items_by_name(metas: &[@ast::meta_item], name: ast::ident) ->
[@ast::meta_item] { [@ast::meta_item] {
let filter = let filter =
bind fn (m: &@ast::meta_item, name: ast::ident) -> bind fn (m: &@ast::meta_item, name: ast::ident) ->
option::t[@ast::meta_item] { option::t<@ast::meta_item> {
if get_meta_item_name(m) == name { if get_meta_item_name(m) == name {
option::some(m) option::some(m)
} else { option::none } } else { option::none }
@ -79,7 +79,7 @@ fn get_meta_item_name(meta: &@ast::meta_item) -> ast::ident {
// Gets the string value if the meta_item is a meta_name_value variant // Gets the string value if the meta_item is a meta_name_value variant
// containing a string, otherwise none // containing a string, otherwise none
fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t[str] { fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t<str> {
alt meta.node { alt meta.node {
ast::meta_name_value(_, v) { ast::meta_name_value(_, v) {
alt v.node { alt v.node {
@ -167,7 +167,7 @@ fn remove_meta_items_by_name(items: &[@ast::meta_item], name: str) ->
let filter = let filter =
bind fn (item: &@ast::meta_item, name: str) -> bind fn (item: &@ast::meta_item, name: str) ->
option::t[@ast::meta_item] { option::t<@ast::meta_item> {
if get_meta_item_name(item) != name { if get_meta_item_name(item) != name {
option::some(item) option::some(item)
} else { option::none } } else { option::none }
@ -189,7 +189,7 @@ fn require_unique_names(sess: &session::session,
} }
} }
fn span[T](item: &T) -> ast::spanned[T] { fn span[T](item: &T) -> ast::spanned<T> {
ret {node: item, span: ast::mk_sp(0u, 0u)}; ret {node: item, span: ast::mk_sp(0u, 0u)};
} }

View file

@ -25,7 +25,7 @@ fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
} }
fn filter_item(cfg: &ast::crate_cfg, item: &@ast::item) -> fn filter_item(cfg: &ast::crate_cfg, item: &@ast::item) ->
option::t[@ast::item] { option::t<@ast::item> {
if item_in_cfg(cfg, item) { option::some(item) } else { option::none } if item_in_cfg(cfg, item) { option::some(item) } else { option::none }
} }
@ -38,7 +38,7 @@ fn fold_mod(cfg: &ast::crate_cfg, m: &ast::_mod, fld: fold::ast_fold) ->
} }
fn filter_native_item(cfg: &ast::crate_cfg, item: &@ast::native_item) -> fn filter_native_item(cfg: &ast::crate_cfg, item: &@ast::native_item) ->
option::t[@ast::native_item] { option::t<@ast::native_item> {
if native_item_in_cfg(cfg, item) { if native_item_in_cfg(cfg, item) {
option::some(item) option::some(item)
} else { option::none } } else { option::none }
@ -55,7 +55,7 @@ fn fold_native_mod(cfg: &ast::crate_cfg, nm: &ast::native_mod,
} }
fn filter_stmt(cfg: &ast::crate_cfg, stmt: &@ast::stmt) -> fn filter_stmt(cfg: &ast::crate_cfg, stmt: &@ast::stmt) ->
option::t[@ast::stmt] { option::t<@ast::stmt> {
alt stmt.node { alt stmt.node {
ast::stmt_decl(decl, _) { ast::stmt_decl(decl, _) {
alt decl.node { alt decl.node {

View file

@ -57,7 +57,7 @@ fn fold_mod(cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod {
// the one we're going to add. FIXME: This is sloppy. Instead we should // the one we're going to add. FIXME: This is sloppy. Instead we should
// have some mechanism to indicate to the translation pass which function // have some mechanism to indicate to the translation pass which function
// we want to be main. // we want to be main.
fn nomain(item: &@ast::item) -> option::t[@ast::item] { fn nomain(item: &@ast::item) -> option::t<@ast::item> {
alt item.node { alt item.node {
ast::item_fn(f, _) { ast::item_fn(f, _) {
if item.ident == "main" { if item.ident == "main" {
@ -167,7 +167,7 @@ fn mk_test_module(cx: &test_ctxt) -> @ast::item {
ret @item; ret @item;
} }
fn nospan[T](t: &T) -> ast::spanned[T] { fn nospan[T](t: &T) -> ast::spanned<T> {
ret {node: t, span: ast::dummy_sp()}; ret {node: t, span: ast::dummy_sp()};
} }

View file

@ -1420,8 +1420,8 @@ fn new_builder(llbb: BasicBlockRef) -> builder {
/* Memory-managed object interface to type handles. */ /* Memory-managed object interface to type handles. */
obj type_names(type_names: std::map::hashmap[TypeRef, str], obj type_names(type_names: std::map::hashmap<TypeRef, str>,
named_types: std::map::hashmap[str, TypeRef]) { named_types: std::map::hashmap<str, TypeRef>) {
fn associate(s: str, t: TypeRef) { fn associate(s: str, t: TypeRef) {
assert (!named_types.contains_key(s)); assert (!named_types.contains_key(s));
@ -1446,8 +1446,8 @@ fn mk_type_names() -> type_names {
fn eq(a: &TypeRef, b: &TypeRef) -> bool { ret a as uint == b as uint; } fn eq(a: &TypeRef, b: &TypeRef) -> bool { ret a as uint == b as uint; }
let hasher: std::map::hashfn[TypeRef] = hash; let hasher: std::map::hashfn<TypeRef> = hash;
let eqer: std::map::eqfn[TypeRef] = eq; let eqer: std::map::eqfn<TypeRef> = eq;
let tn = std::map::mk_hashmap[TypeRef, str](hasher, eqer); let tn = std::map::mk_hashmap[TypeRef, str](hasher, eqer);
ret type_names(tn, nt); ret type_names(tn, nt);

View file

@ -45,7 +45,7 @@ fn read_crates(sess: session::session, crate: &ast::crate) {
type env = type env =
@{sess: session::session, @{sess: session::session,
crate_cache: @hashmap[str, int], crate_cache: @hashmap<str, int>,
library_search_paths: [str], library_search_paths: [str],
mutable next_crate_num: ast::crate_num}; mutable next_crate_num: ast::crate_num};
@ -118,7 +118,7 @@ fn default_native_lib_naming(sess: session::session, static: bool) ->
fn find_library_crate(sess: &session::session, ident: &ast::ident, fn find_library_crate(sess: &session::session, ident: &ast::ident,
metas: &[@ast::meta_item], metas: &[@ast::meta_item],
library_search_paths: &[str]) -> library_search_paths: &[str]) ->
option::t[{ident: str, data: @[u8]}] { option::t<{ident: str, data: @[u8]}> {
attr::require_unique_names(sess, metas); attr::require_unique_names(sess, metas);
@ -148,7 +148,7 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str, fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
metas: &[@ast::meta_item], metas: &[@ast::meta_item],
library_search_paths: &[str]) -> library_search_paths: &[str]) ->
option::t[{ident: str, data: @[u8]}] { option::t<{ident: str, data: @[u8]}> {
let prefix: str = nn.prefix + crate_name; let prefix: str = nn.prefix + crate_name;
// FIXME: we could probably use a 'glob' function in std::fs but it will // FIXME: we could probably use a 'glob' function in std::fs but it will
// be much easier to write once the unsafe module knows more about FFI // be much easier to write once the unsafe module knows more about FFI
@ -183,7 +183,7 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
ret none; ret none;
} }
fn get_metadata_section(filename: str) -> option::t[@[u8]] { fn get_metadata_section(filename: str) -> option::t<@[u8]> {
let b = str::buf(filename); let b = str::buf(filename);
let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(b); let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(b);
if mb as int == 0 { ret option::none[@[u8]]; } if mb as int == 0 { ret option::none[@[u8]]; }

View file

@ -27,7 +27,7 @@ export get_use_stmt_cnum;
// local crate numbers (as generated during this session). Each external // local crate numbers (as generated during this session). Each external
// crate may refer to types in other external crates, and each has their // crate may refer to types in other external crates, and each has their
// own crate numbers. // own crate numbers.
type cnum_map = map::hashmap[ast::crate_num, ast::crate_num]; type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>;
type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map}; type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map};
@ -39,14 +39,14 @@ type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map};
tag cstore { private(cstore_private); } tag cstore { private(cstore_private); }
type cstore_private = type cstore_private =
@{metas: map::hashmap[ast::crate_num, crate_metadata], @{metas: map::hashmap<ast::crate_num, crate_metadata>,
use_crate_map: use_crate_map, use_crate_map: use_crate_map,
mutable used_crate_files: [str], mutable used_crate_files: [str],
mutable used_libraries: [str], mutable used_libraries: [str],
mutable used_link_args: [str]}; mutable used_link_args: [str]};
// Map from node_id's of local use statements to crate numbers // Map from node_id's of local use statements to crate numbers
type use_crate_map = map::hashmap[ast::node_id, ast::crate_num]; type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
// Internal method to retrieve the data from the cstore // Internal method to retrieve the data from the cstore
fn p(cstore: &cstore) -> cstore_private { alt cstore { private(p) { p } } } fn p(cstore: &cstore) -> cstore_private { alt cstore { private(p) { p } } }

View file

@ -56,7 +56,7 @@ fn lookup_hash(d: &ebml::doc, eq_fn: fn(&[u8]) -> bool , hash: uint) ->
} }
fn maybe_find_item(item_id: int, items: &ebml::doc) -> fn maybe_find_item(item_id: int, items: &ebml::doc) ->
option::t[ebml::doc] { option::t<ebml::doc> {
fn eq_item(bytes: &[u8], item_id: int) -> bool { fn eq_item(bytes: &[u8], item_id: int) -> bool {
ret ebml::be_uint_from_bytes(@bytes, 0u, 4u) as int == item_id; ret ebml::be_uint_from_bytes(@bytes, 0u, 4u) as int == item_id;
} }

View file

@ -19,7 +19,7 @@ import front::attr;
export encode_metadata; export encode_metadata;
export encoded_ty; export encoded_ty;
type abbrev_map = map::hashmap[ty::t, tyencode::ty_abbrev]; type abbrev_map = map::hashmap<ty::t, tyencode::ty_abbrev>;
type encode_ctxt = {ccx: @crate_ctxt, type_abbrevs: abbrev_map}; type encode_ctxt = {ccx: @crate_ctxt, type_abbrevs: abbrev_map};
@ -39,7 +39,7 @@ fn encode_def_id(ebml_w: &ebml::writer, id: &def_id) {
type entry[T] = {val: T, pos: uint}; type entry[T] = {val: T, pos: uint};
fn encode_tag_variant_paths(ebml_w: &ebml::writer, variants: &[variant], fn encode_tag_variant_paths(ebml_w: &ebml::writer, variants: &[variant],
path: &[str], index: &mutable [entry[str]]) { path: &[str], index: &mutable [entry<str>]) {
for variant: variant in variants { for variant: variant in variants {
add_to_index(ebml_w, path, index, variant.node.name); add_to_index(ebml_w, path, index, variant.node.name);
ebml::start_tag(ebml_w, tag_paths_data_item); ebml::start_tag(ebml_w, tag_paths_data_item);
@ -50,7 +50,7 @@ fn encode_tag_variant_paths(ebml_w: &ebml::writer, variants: &[variant],
} }
fn add_to_index(ebml_w: &ebml::writer, path: &[str], fn add_to_index(ebml_w: &ebml::writer, path: &[str],
index: &mutable [entry[str]], name: &str) { index: &mutable [entry<str>], name: &str) {
let full_path = path + ~[name]; let full_path = path + ~[name];
index += index +=
~[{val: str::connect(full_path, "::"), ~[{val: str::connect(full_path, "::"),
@ -59,7 +59,7 @@ fn add_to_index(ebml_w: &ebml::writer, path: &[str],
fn encode_native_module_item_paths(ebml_w: &ebml::writer, fn encode_native_module_item_paths(ebml_w: &ebml::writer,
nmod: &native_mod, path: &[str], nmod: &native_mod, path: &[str],
index: &mutable [entry[str]]) { index: &mutable [entry<str>]) {
for nitem: @native_item in nmod.items { for nitem: @native_item in nmod.items {
add_to_index(ebml_w, path, index, nitem.ident); add_to_index(ebml_w, path, index, nitem.ident);
ebml::start_tag(ebml_w, tag_paths_data_item); ebml::start_tag(ebml_w, tag_paths_data_item);
@ -70,7 +70,7 @@ fn encode_native_module_item_paths(ebml_w: &ebml::writer,
} }
fn encode_module_item_paths(ebml_w: &ebml::writer, module: &_mod, fn encode_module_item_paths(ebml_w: &ebml::writer, module: &_mod,
path: &[str], index: &mutable [entry[str]]) { path: &[str], index: &mutable [entry<str>]) {
for it: @item in module.items { for it: @item in module.items {
if !is_exported(it.ident, module) { cont; } if !is_exported(it.ident, module) { cont; }
alt it.node { alt it.node {
@ -149,8 +149,8 @@ fn encode_module_item_paths(ebml_w: &ebml::writer, module: &_mod,
} }
fn encode_item_paths(ebml_w: &ebml::writer, crate: &@crate) -> fn encode_item_paths(ebml_w: &ebml::writer, crate: &@crate) ->
[entry[str]] { [entry<str>] {
let index: [entry[str]] = ~[]; let index: [entry<str>] = ~[];
let path: [str] = ~[]; let path: [str] = ~[];
ebml::start_tag(ebml_w, tag_paths); ebml::start_tag(ebml_w, tag_paths);
encode_module_item_paths(ebml_w, crate.node.module, path, index); encode_module_item_paths(ebml_w, crate.node.module, path, index);
@ -226,7 +226,7 @@ fn encode_tag_id(ebml_w: &ebml::writer, id: &def_id) {
fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebml::writer, fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
id: node_id, variants: &[variant], id: node_id, variants: &[variant],
index: &mutable [entry[int]], index: &mutable [entry<int>],
ty_params: &[ty_param]) { ty_params: &[ty_param]) {
for variant: variant in variants { for variant: variant in variants {
index += ~[{val: variant.node.id, pos: ebml_w.writer.tell()}]; index += ~[{val: variant.node.id, pos: ebml_w.writer.tell()}];
@ -246,7 +246,7 @@ fn encode_tag_variant_info(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
} }
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: &ebml::writer, fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: &ebml::writer,
item: @item, index: &mutable [entry[int]]) { item: @item, index: &mutable [entry<int>]) {
alt item.node { alt item.node {
item_const(_, _) { item_const(_, _) {
ebml::start_tag(ebml_w, tag_items_data_item); ebml::start_tag(ebml_w, tag_items_data_item);
@ -368,8 +368,8 @@ fn encode_info_for_native_item(ecx: &@encode_ctxt, ebml_w: &ebml::writer,
} }
fn encode_info_for_items(ecx: &@encode_ctxt, ebml_w: &ebml::writer) -> fn encode_info_for_items(ecx: &@encode_ctxt, ebml_w: &ebml::writer) ->
[entry[int]] { [entry<int>] {
let index: [entry[int]] = ~[]; let index: [entry<int>] = ~[];
ebml::start_tag(ebml_w, tag_items_data); ebml::start_tag(ebml_w, tag_items_data);
for each kvp: @{key: node_id, val: middle::ast_map::ast_node} in for each kvp: @{key: node_id, val: middle::ast_map::ast_node} in
ecx.ccx.ast_map.items() { ecx.ccx.ast_map.items() {
@ -392,32 +392,32 @@ fn encode_info_for_items(ecx: &@encode_ctxt, ebml_w: &ebml::writer) ->
// Path and definition ID indexing // Path and definition ID indexing
fn create_index[T](index: &[entry[T]], hash_fn: fn(&T) -> uint ) -> fn create_index[T](index: &[entry<T>], hash_fn: fn(&T) -> uint ) ->
[@[entry[T]]] { [@[entry<T>]] {
let buckets: [@mutable [entry[T]]] = ~[]; let buckets: [@mutable [entry<T>]] = ~[];
for each i: uint in uint::range(0u, 256u) { buckets += ~[@mutable ~[]]; } for each i: uint in uint::range(0u, 256u) { buckets += ~[@mutable ~[]]; }
for elt: entry[T] in index { for elt: entry<T> in index {
let h = hash_fn(elt.val); let h = hash_fn(elt.val);
*buckets.(h % 256u) += ~[elt]; *buckets.(h % 256u) += ~[elt];
} }
let buckets_frozen = ~[]; let buckets_frozen = ~[];
for bucket: @mutable [entry[T]] in buckets { for bucket: @mutable [entry<T>] in buckets {
buckets_frozen += ~[@*bucket]; buckets_frozen += ~[@*bucket];
} }
ret buckets_frozen; ret buckets_frozen;
} }
fn encode_index[T](ebml_w: &ebml::writer, buckets: &[@[entry[T]]], fn encode_index[T](ebml_w: &ebml::writer, buckets: &[@[entry<T>]],
write_fn: fn(&io::writer, &T) ) { write_fn: fn(&io::writer, &T) ) {
let writer = io::new_writer_(ebml_w.writer); let writer = io::new_writer_(ebml_w.writer);
ebml::start_tag(ebml_w, tag_index); ebml::start_tag(ebml_w, tag_index);
let bucket_locs: [uint] = ~[]; let bucket_locs: [uint] = ~[];
ebml::start_tag(ebml_w, tag_index_buckets); ebml::start_tag(ebml_w, tag_index_buckets);
for bucket: @[entry[T]] in buckets { for bucket: @[entry<T>] in buckets {
bucket_locs += ~[ebml_w.writer.tell()]; bucket_locs += ~[ebml_w.writer.tell()];
ebml::start_tag(ebml_w, tag_index_buckets_bucket); ebml::start_tag(ebml_w, tag_index_buckets_bucket);
for elt: entry[T] in *bucket { for elt: entry<T> in *bucket {
ebml::start_tag(ebml_w, tag_index_buckets_bucket_elt); ebml::start_tag(ebml_w, tag_index_buckets_bucket_elt);
writer.write_be_uint(elt.pos, 4u); writer.write_be_uint(elt.pos, 4u);
write_fn(writer, elt.val); write_fn(writer, elt.val);

View file

@ -115,7 +115,7 @@ fn parse_path(st: @pstate, sd: str_def) -> ast::path {
fail "parse_path: ill-formed path"; fail "parse_path: ill-formed path";
} }
type arg_parser[T] = fn(@pstate, str_def) -> ast::constr_arg_general_[T] ; type arg_parser[T] = fn(@pstate, str_def) -> ast::constr_arg_general_<T> ;
fn parse_constr_arg(st: @pstate, sd: str_def) -> ast::fn_constr_arg { fn parse_constr_arg(st: @pstate, sd: str_def) -> ast::fn_constr_arg {
alt peek(st) as char { alt peek(st) as char {
@ -143,22 +143,22 @@ fn parse_constr_arg(st: @pstate, sd: str_def) -> ast::fn_constr_arg {
} }
fn parse_ty_constr_arg(st: @pstate, sd: str_def) -> fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
ast::constr_arg_general_[path] { ast::constr_arg_general_<path> {
alt peek(st) as char { alt peek(st) as char {
'*' { st.pos += 1u; ret ast::carg_base; } '*' { st.pos += 1u; ret ast::carg_base; }
c { ret ast::carg_ident(parse_path(st, sd)); } c { ret ast::carg_ident(parse_path(st, sd)); }
} }
} }
fn parse_constr[@T](st: @pstate, sd: str_def, pser: arg_parser[T]) -> fn parse_constr[@T](st: @pstate, sd: str_def, pser: arg_parser<T>) ->
@ty::constr_general[T] { @ty::constr_general<T> {
let sp = ast::dummy_sp(); // FIXME: use a real span let sp = ast::dummy_sp(); // FIXME: use a real span
let args: [@sp_constr_arg[T]] = ~[]; let args: [@sp_constr_arg<T>] = ~[];
let pth: path = parse_path(st, sd); let pth: path = parse_path(st, sd);
let ignore: char = next(st) as char; let ignore: char = next(st) as char;
assert (ignore as char == '('); assert (ignore as char == '(');
let def = parse_def(st, sd); let def = parse_def(st, sd);
let an_arg: constr_arg_general_[T]; let an_arg: constr_arg_general_<T>;
do { do {
an_arg = pser(st, sd); an_arg = pser(st, sd);
// FIXME use a real span // FIXME use a real span

View file

@ -26,7 +26,7 @@ type ctxt = // Def -> str Callback:
// Whatever format you choose should not contain pipe characters. // Whatever format you choose should not contain pipe characters.
type ty_abbrev = {pos: uint, len: uint, s: str}; type ty_abbrev = {pos: uint, len: uint, s: str};
tag abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap[ty::t, ty_abbrev]); } tag abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap<ty::t, ty_abbrev>); }
fn cx_uses_abbrevs(cx: &@ctxt) -> bool { fn cx_uses_abbrevs(cx: &@ctxt) -> bool {
alt cx.abbrevs { alt cx.abbrevs {

View file

@ -36,7 +36,7 @@ type scope = @[restrict];
tag local_info { arg(ast::mode); objfield(ast::mutability); } tag local_info { arg(ast::mode); objfield(ast::mutability); }
type ctx = {tcx: ty::ctxt, local_map: std::map::hashmap[node_id, local_info]}; type ctx = {tcx: ty::ctxt, local_map: std::map::hashmap<node_id, local_info>};
fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) { fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) {
// Stores information about object fields and function // Stores information about object fields and function
@ -52,7 +52,7 @@ fn check_crate(tcx: ty::ctxt, crate: &@ast::crate) {
} }
fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &[ast::ty_param], sp: &span, fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
name: &fn_ident, id: ast::node_id, sc: &scope, v: &vt[scope]) { name: &fn_ident, id: ast::node_id, sc: &scope, v: &vt<scope>) {
visit::visit_fn_decl(f.decl, sc, v); visit::visit_fn_decl(f.decl, sc, v);
for arg_: ast::arg in f.decl.inputs { for arg_: ast::arg in f.decl.inputs {
cx.local_map.insert(arg_.id, arg(arg_.mode)); cx.local_map.insert(arg_.id, arg(arg_.mode));
@ -82,7 +82,7 @@ fn visit_fn(cx: &@ctx, f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
v.visit_block(f.body, scope, v); v.visit_block(f.body, scope, v);
} }
fn visit_item(cx: &@ctx, i: &@ast::item, sc: &scope, v: &vt[scope]) { fn visit_item(cx: &@ctx, i: &@ast::item, sc: &scope, v: &vt<scope>) {
alt i.node { alt i.node {
ast::item_obj(o, _, _) { ast::item_obj(o, _, _) {
for f: ast::obj_field in o.fields { for f: ast::obj_field in o.fields {
@ -94,7 +94,7 @@ fn visit_item(cx: &@ctx, i: &@ast::item, sc: &scope, v: &vt[scope]) {
visit::visit_item(i, sc, v); visit::visit_item(i, sc, v);
} }
fn visit_expr(cx: &@ctx, ex: &@ast::expr, sc: &scope, v: &vt[scope]) { fn visit_expr(cx: &@ctx, ex: &@ast::expr, sc: &scope, v: &vt<scope>) {
let handled = true; let handled = true;
alt ex.node { alt ex.node {
ast::expr_call(f, args) { ast::expr_call(f, args) {
@ -145,7 +145,7 @@ fn visit_expr(cx: &@ctx, ex: &@ast::expr, sc: &scope, v: &vt[scope]) {
if !handled { visit::visit_expr(ex, sc, v); } if !handled { visit::visit_expr(ex, sc, v); }
} }
fn visit_decl(cx: &@ctx, d: &@ast::decl, sc: &scope, v: &vt[scope]) { fn visit_decl(cx: &@ctx, d: &@ast::decl, sc: &scope, v: &vt<scope>) {
visit::visit_decl(d, sc, v); visit::visit_decl(d, sc, v);
alt d.node { alt d.node {
ast::decl_local(locs) { ast::decl_local(locs) {
@ -309,7 +309,7 @@ fn check_tail_call(cx: &ctx, call: &@ast::expr) {
} }
fn check_alt(cx: &ctx, input: &@ast::expr, arms: &[ast::arm], sc: &scope, fn check_alt(cx: &ctx, input: &@ast::expr, arms: &[ast::arm], sc: &scope,
v: &vt[scope]) { v: &vt<scope>) {
visit::visit_expr(input, sc, v); visit::visit_expr(input, sc, v);
let root = expr_root(cx, input, true); let root = expr_root(cx, input, true);
let roots = let roots =
@ -336,7 +336,7 @@ fn arm_defnums(arm: &ast::arm) -> [node_id] {
} }
fn check_for_each(cx: &ctx, local: &@ast::local, call: &@ast::expr, fn check_for_each(cx: &ctx, local: &@ast::local, call: &@ast::expr,
blk: &ast::blk, sc: &scope, v: &vt[scope]) { blk: &ast::blk, sc: &scope, v: &vt<scope>) {
visit::visit_expr(call, sc, v); visit::visit_expr(call, sc, v);
alt call.node { alt call.node {
ast::expr_call(f, args) { ast::expr_call(f, args) {
@ -354,7 +354,7 @@ fn check_for_each(cx: &ctx, local: &@ast::local, call: &@ast::expr,
} }
fn check_for(cx: &ctx, local: &@ast::local, seq: &@ast::expr, blk: &ast::blk, fn check_for(cx: &ctx, local: &@ast::local, seq: &@ast::expr, blk: &ast::blk,
sc: &scope, v: &vt[scope]) { sc: &scope, v: &vt<scope>) {
visit::visit_expr(seq, sc, v); visit::visit_expr(seq, sc, v);
let root = expr_root(cx, seq, false); let root = expr_root(cx, seq, false);
let root_def = let root_def =
@ -405,7 +405,7 @@ fn check_var(cx: &ctx, ex: &@ast::expr, p: &ast::path, id: ast::node_id,
} }
} }
fn check_lval(cx: &@ctx, dest: &@ast::expr, sc: &scope, v: &vt[scope]) { fn check_lval(cx: &@ctx, dest: &@ast::expr, sc: &scope, v: &vt<scope>) {
alt dest.node { alt dest.node {
ast::expr_path(p) { ast::expr_path(p) {
let dnum = ast::def_id_of_def(cx.tcx.def_map.get(dest.id)).node; let dnum = ast::def_id_of_def(cx.tcx.def_map.get(dest.id)).node;
@ -440,7 +440,7 @@ fn check_lval(cx: &@ctx, dest: &@ast::expr, sc: &scope, v: &vt[scope]) {
} }
} }
fn check_move_rhs(cx: &@ctx, src: &@ast::expr, sc: &scope, v: &vt[scope]) { fn check_move_rhs(cx: &@ctx, src: &@ast::expr, sc: &scope, v: &vt<scope>) {
alt src.node { alt src.node {
ast::expr_path(p) { ast::expr_path(p) {
alt cx.tcx.def_map.get(src.id) { alt cx.tcx.def_map.get(src.id) {
@ -464,7 +464,7 @@ fn check_move_rhs(cx: &@ctx, src: &@ast::expr, sc: &scope, v: &vt[scope]) {
} }
fn check_assign(cx: &@ctx, dest: &@ast::expr, src: &@ast::expr, sc: &scope, fn check_assign(cx: &@ctx, dest: &@ast::expr, src: &@ast::expr, sc: &scope,
v: &vt[scope]) { v: &vt<scope>) {
visit_expr(cx, src, sc, v); visit_expr(cx, src, sc, v);
check_lval(cx, dest, sc, v); check_lval(cx, dest, sc, v);
} }
@ -630,19 +630,19 @@ fn mut_field(ds: &@[deref]) -> bool {
ret false; ret false;
} }
fn inner_mut(ds: &@[deref]) -> option::t[ty::t] { fn inner_mut(ds: &@[deref]) -> option::t<ty::t> {
for d: deref in *ds { if d.mut { ret some(d.outer_t); } } for d: deref in *ds { if d.mut { ret some(d.outer_t); } }
ret none; ret none;
} }
fn path_def(cx: &ctx, ex: &@ast::expr) -> option::t[ast::def] { fn path_def(cx: &ctx, ex: &@ast::expr) -> option::t<ast::def> {
ret alt ex.node { ret alt ex.node {
ast::expr_path(_) { some(cx.tcx.def_map.get(ex.id)) } ast::expr_path(_) { some(cx.tcx.def_map.get(ex.id)) }
_ { none } _ { none }
} }
} }
fn path_def_id(cx: &ctx, ex: &@ast::expr) -> option::t[ast::def_id] { fn path_def_id(cx: &ctx, ex: &@ast::expr) -> option::t<ast::def_id> {
alt ex.node { alt ex.node {
ast::expr_path(_) { ast::expr_path(_) {
ret some(ast::def_id_of_def(cx.tcx.def_map.get(ex.id))); ret some(ast::def_id_of_def(cx.tcx.def_map.get(ex.id)));

View file

@ -12,7 +12,7 @@ tag ast_node {
node_expr(@expr); node_expr(@expr);
} }
type map = std::map::hashmap[node_id, ast_node]; type map = std::map::hashmap<node_id, ast_node>;
fn map_crate(c: &crate) -> map { fn map_crate(c: &crate) -> map {
// FIXME: This is using an adapter to convert the smallintmap // FIXME: This is using an adapter to convert the smallintmap
@ -29,7 +29,7 @@ fn map_crate(c: &crate) -> map {
ret map; ret map;
} }
fn map_item(map: &map, i: &@item, e: &(), v: &vt[()]) { fn map_item(map: &map, i: &@item, e: &(), v: &vt<()>) {
map.insert(i.id, node_item(i)); map.insert(i.id, node_item(i));
alt i.node { alt i.node {
item_obj(_, _, ctor_id) { map.insert(ctor_id, node_obj_ctor(i)); } item_obj(_, _, ctor_id) { map.insert(ctor_id, node_obj_ctor(i)); }
@ -38,17 +38,17 @@ fn map_item(map: &map, i: &@item, e: &(), v: &vt[()]) {
visit::visit_item(i, e, v); visit::visit_item(i, e, v);
} }
fn map_native_item(map: &map, i: &@native_item, e: &(), v: &vt[()]) { fn map_native_item(map: &map, i: &@native_item, e: &(), v: &vt<()>) {
map.insert(i.id, node_native_item(i)); map.insert(i.id, node_native_item(i));
visit::visit_native_item(i, e, v); visit::visit_native_item(i, e, v);
} }
fn map_expr(map: &map, ex: &@expr, e: &(), v: &vt[()]) { fn map_expr(map: &map, ex: &@expr, e: &(), v: &vt<()>) {
map.insert(ex.id, node_expr(ex)); map.insert(ex.id, node_expr(ex));
visit::visit_expr(ex, e, v); visit::visit_expr(ex, e, v);
} }
fn new_smallintmap_int_adapter[@V]() -> std::map::hashmap[int, V] { fn new_smallintmap_int_adapter[@V]() -> std::map::hashmap<int, V> {
let key_idx = fn (key: &int) -> uint { key as uint }; let key_idx = fn (key: &int) -> uint { key as uint };
let idx_key = fn (idx: &uint) -> int { idx as int }; let idx_key = fn (idx: &uint) -> int { idx as int };
ret new_smallintmap_adapter(key_idx, idx_key); ret new_smallintmap_adapter(key_idx, idx_key);
@ -62,10 +62,10 @@ fn new_smallintmap_int_adapter[@V]() -> std::map::hashmap[int, V] {
fn new_smallintmap_adapter[@K, fn new_smallintmap_adapter[@K,
@V](key_idx: fn(&K) -> uint , @V](key_idx: fn(&K) -> uint ,
idx_key: fn(&uint) -> K ) -> idx_key: fn(&uint) -> K ) ->
std::map::hashmap[K, V] { std::map::hashmap<K, V> {
obj adapter[@K, obj adapter[@K,
@V](map: smallintmap::smallintmap[V], @V](map: smallintmap::smallintmap<V>,
key_idx: fn(&K) -> uint , key_idx: fn(&K) -> uint ,
idx_key: fn(&uint) -> K ) { idx_key: fn(&uint) -> K ) {
@ -83,17 +83,17 @@ fn new_smallintmap_adapter[@K,
fn get(key: &K) -> V { ret smallintmap::get(map, key_idx(key)); } fn get(key: &K) -> V { ret smallintmap::get(map, key_idx(key)); }
fn find(key: &K) -> option::t[V] { fn find(key: &K) -> option::t<V> {
ret smallintmap::find(map, key_idx(key)); ret smallintmap::find(map, key_idx(key));
} }
fn remove(key: &K) -> option::t[V] { fail } fn remove(key: &K) -> option::t<V> { fail }
fn rehash() { fail } fn rehash() { fail }
iter items() -> @{key: K, val: V} { iter items() -> @{key: K, val: V} {
let idx = 0u; let idx = 0u;
for item: option::t[V] in map.v { for item: option::t<V> in map.v {
alt item { alt item {
option::some(elt) { option::some(elt) {
let value = elt; let value = elt;

View file

@ -10,7 +10,7 @@ fn check_crate(tcx: &ty::ctxt, crate: &@crate) {
tcx.sess.abort_if_errors(); tcx.sess.abort_if_errors();
} }
fn check_expr(tcx: &ty::ctxt, ex: &@expr, s: &(), v: &visit::vt[()]) { fn check_expr(tcx: &ty::ctxt, ex: &@expr, s: &(), v: &visit::vt<()>) {
visit::visit_expr(ex, s, v); visit::visit_expr(ex, s, v);
alt ex.node { expr_alt(_, arms) { check_arms(tcx, arms); } _ { } } alt ex.node { expr_alt(_, arms) { check_arms(tcx, arms); } _ { } }
} }
@ -99,7 +99,7 @@ fn pattern_supersedes(tcx: &ty::ctxt, a: &@pat, b: &@pat) -> bool {
} }
} }
fn check_local(tcx: &ty::ctxt, loc: &@local, s: &(), v: &visit::vt[()]) { fn check_local(tcx: &ty::ctxt, loc: &@local, s: &(), v: &visit::vt<()>) {
visit::visit_local(loc, s, v); visit::visit_local(loc, s, v);
if is_refutable(tcx, loc.node.pat) { if is_refutable(tcx, loc.node.pat) {
tcx.sess.span_err(loc.node.pat.span, tcx.sess.span_err(loc.node.pat.span,

View file

@ -28,9 +28,9 @@ export def_lookup;
// "canonical" referencing node_id per free variable. The set is useful for // "canonical" referencing node_id per free variable. The set is useful for
// testing membership, the list of referencing sites is what you want for most // testing membership, the list of referencing sites is what you want for most
// other things. // other things.
type freevar_set = hashset[ast::node_id]; type freevar_set = hashset<ast::node_id>;
type freevar_info = {defs: freevar_set, refs: @[ast::node_id]}; type freevar_info = {defs: freevar_set, refs: @[ast::node_id]};
type freevar_map = hashmap[ast::node_id, freevar_info]; type freevar_map = hashmap<ast::node_id, freevar_info>;
// Searches through part of the AST for all references to locals or // Searches through part of the AST for all references to locals or
// upvars in this frame and returns the list of definition IDs thus found. // upvars in this frame and returns the list of definition IDs thus found.
@ -38,7 +38,7 @@ type freevar_map = hashmap[ast::node_id, freevar_info];
// of the AST, we take a walker function that we invoke with a visitor // of the AST, we take a walker function that we invoke with a visitor
// in order to start the search. // in order to start the search.
fn collect_freevars(def_map: &resolve::def_map, sess: &session::session, fn collect_freevars(def_map: &resolve::def_map, sess: &session::session,
walker: &fn(&visit::vt[()]) , walker: &fn(&visit::vt<()>) ,
initial_decls: [ast::node_id]) -> freevar_info { initial_decls: [ast::node_id]) -> freevar_info {
let decls = new_int_hash(); let decls = new_int_hash();
for decl: ast::node_id in initial_decls { set_add(decls, decl); } for decl: ast::node_id in initial_decls { set_add(decls, decl); }
@ -108,7 +108,7 @@ fn annotate_freevars(sess: &session::session, def_map: &resolve::def_map,
let walk_fn = lambda(f: &ast::_fn, tps: &[ast::ty_param], sp: &span, let walk_fn = lambda(f: &ast::_fn, tps: &[ast::ty_param], sp: &span,
i: &ast::fn_ident, nid: ast::node_id) { i: &ast::fn_ident, nid: ast::node_id) {
let start_walk = lambda(v: &visit::vt[()]) { let start_walk = lambda(v: &visit::vt<()>) {
v.visit_fn(f, tps, sp, i, nid, (), v); v.visit_fn(f, tps, sp, i, nid, (), v);
}; };
let vars = collect_freevars(def_map, sess, start_walk, ~[]); let vars = collect_freevars(def_map, sess, start_walk, ~[]);
@ -117,7 +117,7 @@ fn annotate_freevars(sess: &session::session, def_map: &resolve::def_map,
let walk_expr = lambda(expr: &@ast::expr) { let walk_expr = lambda(expr: &@ast::expr) {
alt expr.node { alt expr.node {
ast::expr_for_each(local, _, body) { ast::expr_for_each(local, _, body) {
let start_walk = lambda(v: &visit::vt[()]) { let start_walk = lambda(v: &visit::vt<()>) {
v.visit_block(body, (), v); v.visit_block(body, (), v);
}; };
let bound = ast::pat_binding_ids(local.node.pat); let bound = ast::pat_binding_ids(local.node.pat);
@ -157,7 +157,7 @@ fn is_freevar_of(tcx: &ty::ctxt, def: ast::node_id, f: ast::node_id) -> bool {
ret get_freevar_defs(tcx, f).contains_key(def); ret get_freevar_defs(tcx, f).contains_key(def);
} }
fn def_lookup(tcx: &ty::ctxt, f: ast::node_id, id: ast::node_id) -> fn def_lookup(tcx: &ty::ctxt, f: ast::node_id, id: ast::node_id) ->
option::t[ast::def] { option::t<ast::def> {
alt tcx.def_map.find(id) { alt tcx.def_map.find(id) {
none. { ret none; } none. { ret none; }
some(d) { some(d) {

View file

@ -57,20 +57,20 @@ tag scope {
scope_arm(ast::arm); scope_arm(ast::arm);
} }
type scopes = list[scope]; type scopes = list<scope>;
tag import_state { tag import_state {
todo(@ast::view_item, scopes); // only used for explicit imports todo(@ast::view_item, scopes); // only used for explicit imports
resolving(span); resolving(span);
resolved(option::t[def], resolved(option::t<def>,
/* value */ /* value */
option::t[def], option::t<def>,
/* type */ /* type */
option::t[def]); /* module */ option::t<def>); /* module */
} }
type ext_hash = hashmap[{did: def_id, ident: str, ns: namespace}, def]; type ext_hash = hashmap<{did: def_id, ident: str, ns: namespace}, def>;
fn new_ext_hash() -> ext_hash { fn new_ext_hash() -> ext_hash {
type key = {did: def_id, ident: str, ns: namespace}; type key = {did: def_id, ident: str, ns: namespace};
@ -96,30 +96,30 @@ tag mod_index_entry {
mie_tag_variant(/* tag item */@ast::item, /* variant index */uint); mie_tag_variant(/* tag item */@ast::item, /* variant index */uint);
} }
type mod_index = hashmap[ident, list[mod_index_entry]]; type mod_index = hashmap<ident, list<mod_index_entry>>;
// A tuple of an imported def and the import stmt that brung it // A tuple of an imported def and the import stmt that brung it
type glob_imp_def = {def: def, item: @ast::view_item}; type glob_imp_def = {def: def, item: @ast::view_item};
type indexed_mod = type indexed_mod =
{m: option::t[ast::_mod], {m: option::t<ast::_mod>,
index: mod_index, index: mod_index,
mutable glob_imports: [glob_imp_def], mutable glob_imports: [glob_imp_def],
glob_imported_names: hashmap[str, import_state]}; glob_imported_names: hashmap<str, import_state>};
/* native modules can't contain tags, and we don't store their ASTs because we /* native modules can't contain tags, and we don't store their ASTs because we
only need to look at them to determine exports, which they can't control.*/ only need to look at them to determine exports, which they can't control.*/
type def_map = hashmap[node_id, def]; type def_map = hashmap<node_id, def>;
type env = type env =
{cstore: cstore::cstore, {cstore: cstore::cstore,
def_map: def_map, def_map: def_map,
ast_map: ast_map::map, ast_map: ast_map::map,
imports: hashmap[ast::node_id, import_state], imports: hashmap<ast::node_id, import_state>,
mod_map: hashmap[ast::node_id, @indexed_mod], mod_map: hashmap<ast::node_id, @indexed_mod>,
ext_map: hashmap[def_id, [ident]], ext_map: hashmap<def_id, [ident]>,
ext_cache: ext_hash, ext_cache: ext_hash,
mutable reported: [{ident: str, sc: scope}], mutable reported: [{ident: str, sc: scope}],
sess: session}; sess: session};
@ -168,7 +168,7 @@ fn map_crate(e: &@env, c: &@ast::crate) {
index: index_mod(c.node.module), index: index_mod(c.node.module),
mutable glob_imports: ~[], mutable glob_imports: ~[],
glob_imported_names: new_str_hash[import_state]()}); glob_imported_names: new_str_hash[import_state]()});
fn index_vi(e: @env, i: &@ast::view_item, sc: &scopes, v: &vt[scopes]) { fn index_vi(e: @env, i: &@ast::view_item, sc: &scopes, v: &vt<scopes>) {
alt i.node { alt i.node {
ast::view_item_import(_, ids, id) { ast::view_item_import(_, ids, id) {
e.imports.insert(id, todo(i, sc)); e.imports.insert(id, todo(i, sc));
@ -176,7 +176,7 @@ fn map_crate(e: &@env, c: &@ast::crate) {
_ { } _ { }
} }
} }
fn index_i(e: @env, i: &@ast::item, sc: &scopes, v: &vt[scopes]) { fn index_i(e: @env, i: &@ast::item, sc: &scopes, v: &vt<scopes>) {
visit_item_with_scope(i, sc, v); visit_item_with_scope(i, sc, v);
alt i.node { alt i.node {
ast::item_mod(md) { ast::item_mod(md) {
@ -206,7 +206,7 @@ fn map_crate(e: &@env, c: &@ast::crate) {
with *visit::default_visitor[scopes]()}; with *visit::default_visitor[scopes]()};
visit::visit_crate(*c, cons(scope_crate, @nil), visit::visit_crate(*c, cons(scope_crate, @nil),
visit::mk_vt(v_link_glob)); visit::mk_vt(v_link_glob));
fn link_glob(e: @env, vi: &@ast::view_item, sc: &scopes, v: &vt[scopes]) { fn link_glob(e: @env, vi: &@ast::view_item, sc: &scopes, v: &vt<scopes>) {
fn find_mod(e: @env, sc: scopes) -> @indexed_mod { fn find_mod(e: @env, sc: scopes) -> @indexed_mod {
alt sc { alt sc {
cons(scope_item(i), tl) { cons(scope_item(i), tl) {
@ -265,7 +265,7 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v)); visit::visit_crate(*c, cons(scope_crate, @nil), visit::mk_vt(v));
e.sess.abort_if_errors(); e.sess.abort_if_errors();
fn walk_expr(e: @env, exp: &@ast::expr, sc: &scopes, v: &vt[scopes]) { fn walk_expr(e: @env, exp: &@ast::expr, sc: &scopes, v: &vt<scopes>) {
visit_expr_with_scope(exp, sc, v); visit_expr_with_scope(exp, sc, v);
alt exp.node { alt exp.node {
ast::expr_path(p) { ast::expr_path(p) {
@ -276,7 +276,7 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
_ { } _ { }
} }
} }
fn walk_ty(e: @env, t: &@ast::ty, sc: &scopes, v: &vt[scopes]) { fn walk_ty(e: @env, t: &@ast::ty, sc: &scopes, v: &vt<scopes>) {
visit::visit_ty(t, sc, v); visit::visit_ty(t, sc, v);
alt t.node { alt t.node {
ast::ty_path(p, id) { ast::ty_path(p, id) {
@ -287,13 +287,13 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
} }
} }
fn walk_constr(e: @env, p: &ast::path, sp: &span, id: node_id, fn walk_constr(e: @env, p: &ast::path, sp: &span, id: node_id,
sc: &scopes, v: &vt[scopes]) { sc: &scopes, v: &vt<scopes>) {
maybe_insert(e, id, lookup_path_strict(*e, sc, sp, p.node, ns_value)); maybe_insert(e, id, lookup_path_strict(*e, sc, sp, p.node, ns_value));
} }
fn walk_arm(e: @env, a: &ast::arm, sc: &scopes, v: &vt[scopes]) { fn walk_arm(e: @env, a: &ast::arm, sc: &scopes, v: &vt<scopes>) {
visit_arm_with_scope(a, sc, v); visit_arm_with_scope(a, sc, v);
} }
fn walk_pat(e: &@env, pat: &@ast::pat, sc: &scopes, v: &vt[scopes]) { fn walk_pat(e: &@env, pat: &@ast::pat, sc: &scopes, v: &vt<scopes>) {
visit::visit_pat(pat, sc, v); visit::visit_pat(pat, sc, v);
alt pat.node { alt pat.node {
ast::pat_tag(p, _) { ast::pat_tag(p, _) {
@ -312,25 +312,25 @@ fn resolve_names(e: &@env, c: &@ast::crate) {
} }
} }
fn maybe_insert(e: @env, id: node_id, def: option::t[def]) { fn maybe_insert(e: @env, id: node_id, def: option::t<def>) {
if option::is_some(def) { e.def_map.insert(id, option::get(def)); } if option::is_some(def) { e.def_map.insert(id, option::get(def)); }
} }
} }
// Visit helper functions // Visit helper functions
fn visit_item_with_scope(i: &@ast::item, sc: &scopes, v: &vt[scopes]) { fn visit_item_with_scope(i: &@ast::item, sc: &scopes, v: &vt<scopes>) {
visit::visit_item(i, cons(scope_item(i), @sc), v); visit::visit_item(i, cons(scope_item(i), @sc), v);
} }
fn visit_native_item_with_scope(ni: &@ast::native_item, sc: &scopes, fn visit_native_item_with_scope(ni: &@ast::native_item, sc: &scopes,
v: &vt[scopes]) { v: &vt<scopes>) {
visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v); visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v);
} }
fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &[ast::ty_param], fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &[ast::ty_param],
sp: &span, name: &fn_ident, id: node_id, sc: &scopes, sp: &span, name: &fn_ident, id: node_id, sc: &scopes,
v: &vt[scopes]) { v: &vt<scopes>) {
// is this a main fn declaration? // is this a main fn declaration?
alt name { alt name {
some(nm) { some(nm) {
@ -353,7 +353,7 @@ fn visit_fn_with_scope(e: &@env, f: &ast::_fn, tp: &[ast::ty_param],
cons(scope_fn(f.decl, f.proto, tp), @sc), v); cons(scope_fn(f.decl, f.proto, tp), @sc), v);
} }
fn visit_block_with_scope(b: &ast::blk, sc: &scopes, v: &vt[scopes]) { fn visit_block_with_scope(b: &ast::blk, sc: &scopes, v: &vt<scopes>) {
let pos = @mutable 0u, loc = @mutable 0u; let pos = @mutable 0u, loc = @mutable 0u;
let block_sc = cons(scope_block(b, pos, loc), @sc); let block_sc = cons(scope_block(b, pos, loc), @sc);
for stmt in b.node.stmts { for stmt in b.node.stmts {
@ -364,7 +364,7 @@ fn visit_block_with_scope(b: &ast::blk, sc: &scopes, v: &vt[scopes]) {
visit::visit_expr_opt(b.node.expr, block_sc, v); visit::visit_expr_opt(b.node.expr, block_sc, v);
} }
fn visit_decl_with_scope(d: &@decl, sc: &scopes, v: &vt[scopes]) { fn visit_decl_with_scope(d: &@decl, sc: &scopes, v: &vt<scopes>) {
let loc_pos = alt list::car(sc) { let loc_pos = alt list::car(sc) {
scope_block(_, _, pos) { pos } scope_block(_, _, pos) { pos }
_ { @mutable 0u } _ { @mutable 0u }
@ -380,11 +380,11 @@ fn visit_decl_with_scope(d: &@decl, sc: &scopes, v: &vt[scopes]) {
} }
} }
fn visit_arm_with_scope(a: &ast::arm, sc: &scopes, v: &vt[scopes]) { fn visit_arm_with_scope(a: &ast::arm, sc: &scopes, v: &vt<scopes>) {
visit::visit_arm(a, cons(scope_arm(a), @sc), v); visit::visit_arm(a, cons(scope_arm(a), @sc), v);
} }
fn visit_expr_with_scope(x: &@ast::expr, sc: &scopes, v: &vt[scopes]) { fn visit_expr_with_scope(x: &@ast::expr, sc: &scopes, v: &vt<scopes>) {
alt x.node { alt x.node {
ast::expr_for(decl, coll, blk) | ast::expr_for_each(decl, coll, blk) { ast::expr_for(decl, coll, blk) | ast::expr_for_each(decl, coll, blk) {
let new_sc = cons[scope](scope_loop(decl), @sc); let new_sc = cons[scope](scope_loop(decl), @sc);
@ -400,7 +400,7 @@ fn visit_expr_with_scope(x: &@ast::expr, sc: &scopes, v: &vt[scopes]) {
} }
fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) -> fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) ->
option::t[def] { option::t<def> {
let path_len = vec::len(path); let path_len = vec::len(path);
let dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module); let dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module);
let i = 1u; let i = 1u;
@ -425,7 +425,7 @@ fn follow_import(e: &env, sc: &scopes, path: &[ident], sp: &span) ->
} }
fn resolve_constr(e: @env, id: node_id, c: &@ast::constr, sc: &scopes, fn resolve_constr(e: @env, id: node_id, c: &@ast::constr, sc: &scopes,
v: &vt[scopes]) { v: &vt<scopes>) {
let new_def = let new_def =
lookup_path_strict(*e, sc, c.span, c.node.path.node, ns_value); lookup_path_strict(*e, sc, c.span, c.node.path.node, ns_value);
if option::is_some(new_def) { if option::is_some(new_def) {
@ -506,13 +506,13 @@ fn resolve_import(e: &env, it: &@ast::view_item, sc_in: &scopes) {
} }
} }
fn register(e: &env, defid: def_id, sp: &span, name: &ident, sc: &scopes, fn register(e: &env, defid: def_id, sp: &span, name: &ident, sc: &scopes,
val: &option::t[def], typ: &option::t[def], val: &option::t<def>, typ: &option::t<def>,
md: &option::t[def]) { md: &option::t<def>) {
if is_none(val) && is_none(typ) && is_none(md) { if is_none(val) && is_none(typ) && is_none(md) {
unresolved_err(e, sc, sp, name, "import"); unresolved_err(e, sc, sp, name, "import");
} else { e.imports.insert(defid.node, resolved(val, typ, md)); } } else { e.imports.insert(defid.node, resolved(val, typ, md)); }
} }
fn remove_if_unresolved(imports: hashmap[ast::node_id, import_state], fn remove_if_unresolved(imports: hashmap<ast::node_id, import_state>,
node_id: ast::node_id) { node_id: ast::node_id) {
// If we couldn't resolve the import, don't leave it in a partially // If we couldn't resolve the import, don't leave it in a partially
@ -572,7 +572,7 @@ fn mk_unresolved_msg(id: &ident, kind: &str) -> str {
// Lookup helpers // Lookup helpers
fn lookup_path_strict(e: &env, sc: &scopes, sp: &span, pth: &ast::path_, fn lookup_path_strict(e: &env, sc: &scopes, sp: &span, pth: &ast::path_,
ns: namespace) -> option::t[def] { ns: namespace) -> option::t<def> {
let n_idents = vec::len(pth.idents); let n_idents = vec::len(pth.idents);
let headns = if n_idents == 1u { ns } else { ns_module }; let headns = if n_idents == 1u { ns } else { ns_module };
@ -596,7 +596,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, fn lookup_in_scope_strict(e: &env, sc: scopes, sp: &span, name: &ident,
ns: namespace) -> option::t[def] { ns: namespace) -> option::t<def> {
alt lookup_in_scope(e, sc, sp, name, ns) { alt lookup_in_scope(e, sc, sp, name, ns) {
none. { unresolved_err(e, sc, sp, name, ns_name(ns)); ret none; } none. { unresolved_err(e, sc, sp, name, ns_name(ns)); ret none; }
some(d) { ret some(d); } some(d) { ret some(d); }
@ -629,9 +629,9 @@ fn def_is_ty_arg(d: &def) -> bool {
} }
fn lookup_in_scope(e: &env, sc: scopes, sp: &span, name: &ident, fn lookup_in_scope(e: &env, sc: scopes, sp: &span, name: &ident,
ns: namespace) -> option::t[def] { ns: namespace) -> option::t<def> {
fn in_scope(e: &env, sp: &span, name: &ident, s: &scope, ns: namespace) -> fn in_scope(e: &env, sp: &span, name: &ident, s: &scope, ns: namespace) ->
option::t[def] { option::t<def> {
alt s { alt s {
scope_crate. { scope_crate. {
ret lookup_in_local_mod(e, -1, sp, name, ns, inside); ret lookup_in_local_mod(e, -1, sp, name, ns, inside);
@ -728,7 +728,7 @@ fn lookup_in_scope(e: &env, sc: scopes, sp: &span, name: &ident,
} }
fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) -> fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) ->
option::t[def] { option::t<def> {
let i = 0u; let i = 0u;
for tp: ast::ty_param in ty_params { for tp: ast::ty_param in ty_params {
if str::eq(tp.ident, name) { ret some(ast::def_ty_arg(i,tp.kind)); } if str::eq(tp.ident, name) { ret some(ast::def_ty_arg(i,tp.kind)); }
@ -737,7 +737,7 @@ fn lookup_in_ty_params(name: &ident, ty_params: &[ast::ty_param]) ->
ret none[def]; ret none[def];
} }
fn lookup_in_pat(name: &ident, pat: &@ast::pat) -> option::t[def_id] { fn lookup_in_pat(name: &ident, pat: &@ast::pat) -> option::t<def_id> {
let found = none; let found = none;
for each bound in ast::pat_bindings(pat) { for each bound in ast::pat_bindings(pat) {
let p_name = alt bound.node { ast::pat_bind(n) { n } }; let p_name = alt bound.node { ast::pat_bind(n) { n } };
@ -750,7 +750,7 @@ fn lookup_in_pat(name: &ident, pat: &@ast::pat) -> option::t[def_id] {
fn lookup_in_fn(name: &ident, decl: &ast::fn_decl, fn lookup_in_fn(name: &ident, decl: &ast::fn_decl,
ty_params: &[ast::ty_param], ns: namespace) -> ty_params: &[ast::ty_param], ns: namespace) ->
option::t[def] { option::t<def> {
alt ns { alt ns {
ns_value. { ns_value. {
for a: ast::arg in decl.inputs { for a: ast::arg in decl.inputs {
@ -766,7 +766,7 @@ fn lookup_in_fn(name: &ident, decl: &ast::fn_decl,
} }
fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param], fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param],
ns: namespace) -> option::t[def] { ns: namespace) -> option::t<def> {
alt ns { alt ns {
ns_value. { ns_value. {
for f: ast::obj_field in ob.fields { for f: ast::obj_field in ob.fields {
@ -782,7 +782,7 @@ fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param],
} }
fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint, fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint,
ns: namespace) -> option::t[def] { ns: namespace) -> option::t<def> {
let i = vec::len(b.stmts); let i = vec::len(b.stmts);
while i > 0u { while i > 0u {
i -= 1u; i -= 1u;
@ -838,7 +838,7 @@ fn lookup_in_block(name: &ident, b: &ast::blk_, pos: uint, loc_pos: uint,
ret none[def]; ret none[def];
} }
fn found_def_item(i: &@ast::item, ns: namespace) -> option::t[def] { fn found_def_item(i: &@ast::item, ns: namespace) -> option::t<def> {
alt i.node { alt i.node {
ast::item_const(_, _) { ast::item_const(_, _) {
if ns == ns_value { ret some(ast::def_const(local_def(i.id))); } if ns == ns_value { ret some(ast::def_const(local_def(i.id))); }
@ -884,7 +884,7 @@ fn found_def_item(i: &@ast::item, ns: namespace) -> option::t[def] {
} }
fn lookup_in_mod_strict(e: &env, sc: &scopes, m: def, sp: &span, name: &ident, fn lookup_in_mod_strict(e: &env, sc: &scopes, m: def, sp: &span, name: &ident,
ns: namespace, dr: dir) -> option::t[def] { ns: namespace, dr: dir) -> option::t<def> {
alt lookup_in_mod(e, m, sp, name, ns, dr) { alt lookup_in_mod(e, m, sp, name, ns, dr) {
none. { unresolved_err(e, sc, sp, name, ns_name(ns)); ret none; } none. { unresolved_err(e, sc, sp, name, ns_name(ns)); ret none; }
some(d) { ret some(d); } some(d) { ret some(d); }
@ -892,7 +892,7 @@ fn lookup_in_mod_strict(e: &env, sc: &scopes, m: def, sp: &span, name: &ident,
} }
fn lookup_in_mod(e: &env, m: &def, sp: &span, name: &ident, ns: namespace, fn lookup_in_mod(e: &env, m: &def, sp: &span, name: &ident, ns: namespace,
dr: dir) -> option::t[def] { dr: dir) -> option::t<def> {
let defid = ast::def_id_of_def(m); let defid = ast::def_id_of_def(m);
if defid.crate != ast::local_crate { if defid.crate != ast::local_crate {
// examining a module in an external crate // examining a module in an external crate
@ -919,7 +919,7 @@ fn lookup_in_mod(e: &env, m: &def, sp: &span, name: &ident, ns: namespace,
} }
fn found_view_item(e: &env, vi: @ast::view_item, ns: namespace) -> fn found_view_item(e: &env, vi: @ast::view_item, ns: namespace) ->
option::t[def] { option::t<def> {
alt vi.node { alt vi.node {
ast::view_item_use(_, _, id) { ast::view_item_use(_, _, id) {
let cnum = cstore::get_use_stmt_cnum(e.cstore, id); let cnum = cstore::get_use_stmt_cnum(e.cstore, id);
@ -935,7 +935,7 @@ fn found_view_item(e: &env, vi: @ast::view_item, ns: namespace) ->
} }
} }
fn lookup_import(e: &env, defid: def_id, ns: namespace) -> option::t[def] { fn lookup_import(e: &env, defid: def_id, ns: namespace) -> option::t<def> {
alt e.imports.get(defid.node) { alt e.imports.get(defid.node) {
todo(item, sc) { todo(item, sc) {
resolve_import(e, item, sc); resolve_import(e, item, sc);
@ -949,12 +949,12 @@ fn lookup_import(e: &env, defid: def_id, ns: namespace) -> option::t[def] {
} }
fn lookup_in_local_native_mod(e: &env, node_id: node_id, sp: &span, fn lookup_in_local_native_mod(e: &env, node_id: node_id, sp: &span,
id: &ident, ns: namespace) -> option::t[def] { id: &ident, ns: namespace) -> option::t<def> {
ret lookup_in_local_mod(e, node_id, sp, id, ns, inside); ret lookup_in_local_mod(e, node_id, sp, id, ns, inside);
} }
fn lookup_in_local_mod(e: &env, node_id: node_id, sp: &span, id: &ident, fn lookup_in_local_mod(e: &env, node_id: node_id, sp: &span, id: &ident,
ns: namespace, dr: dir) -> option::t[def] { ns: namespace, dr: dir) -> option::t<def> {
let info = e.mod_map.get(node_id); let info = e.mod_map.get(node_id);
if dr == outside && !ast::is_exported(id, option::get(info.m)) { if dr == outside && !ast::is_exported(id, option::get(info.m)) {
// if we're in a native mod, then dr==inside, so info.m is some _mod // if we're in a native mod, then dr==inside, so info.m is some _mod
@ -984,13 +984,13 @@ fn lookup_in_local_mod(e: &env, node_id: node_id, sp: &span, id: &ident,
} }
fn lookup_glob_in_mod(e: &env, info: @indexed_mod, sp: &span, id: &ident, fn lookup_glob_in_mod(e: &env, info: @indexed_mod, sp: &span, id: &ident,
wanted_ns: namespace, dr: dir) -> option::t[def] { wanted_ns: namespace, dr: dir) -> option::t<def> {
fn per_ns(e: &env, info: @indexed_mod, sp: &span, id: &ident, fn per_ns(e: &env, info: @indexed_mod, sp: &span, id: &ident,
ns: namespace, dr: dir) -> option::t[def] { ns: namespace, dr: dir) -> option::t<def> {
fn lookup_in_mod_(e: &env, def: &glob_imp_def, sp: &span, fn lookup_in_mod_(e: &env, def: &glob_imp_def, sp: &span,
name: &ident, ns: namespace, dr: dir) -> name: &ident, ns: namespace, dr: dir) ->
option::t[glob_imp_def] { option::t<glob_imp_def> {
alt lookup_in_mod(e, def.def, sp, name, ns, dr) { alt lookup_in_mod(e, def.def, sp, name, ns, dr) {
option::some(d) { option::some({def: d, item: def.item}) } option::some(d) { option::some({def: d, item: def.item}) }
option::none. { option::none } option::none. { option::none }
@ -1041,7 +1041,7 @@ fn lookup_glob_in_mod(e: &env, info: @indexed_mod, sp: &span, id: &ident,
} }
fn lookup_in_mie(e: &env, mie: &mod_index_entry, ns: namespace) -> fn lookup_in_mie(e: &env, mie: &mod_index_entry, ns: namespace) ->
option::t[def] { option::t<def> {
alt mie { alt mie {
mie_view_item(view_item) { ret found_view_item(e, view_item, ns); } mie_view_item(view_item) { ret found_view_item(e, view_item, ns); }
mie_item(item) { ret found_def_item(item, ns); } mie_item(item) { ret found_def_item(item, ns); }
@ -1077,7 +1077,7 @@ fn lookup_in_mie(e: &env, mie: &mod_index_entry, ns: namespace) ->
// Module indexing // Module indexing
fn add_to_index(index: &hashmap[ident, list[mod_index_entry]], id: &ident, fn add_to_index(index: &hashmap<ident, list<mod_index_entry>>, id: &ident,
ent: &mod_index_entry) { ent: &mod_index_entry) {
alt index.find(id) { alt index.find(id) {
none. { index.insert(id, cons(ent, @nil[mod_index_entry])); } none. { index.insert(id, cons(ent, @nil[mod_index_entry])); }
@ -1086,7 +1086,7 @@ fn add_to_index(index: &hashmap[ident, list[mod_index_entry]], id: &ident,
} }
fn index_mod(md: &ast::_mod) -> mod_index { fn index_mod(md: &ast::_mod) -> mod_index {
let index = new_str_hash[list[mod_index_entry]](); let index = new_str_hash[list<mod_index_entry>]();
for it: @ast::view_item in md.view_items { for it: @ast::view_item in md.view_items {
alt it.node { alt it.node {
ast::view_item_import(ident, _, _) | ast::view_item_use(ident, _, _) ast::view_item_import(ident, _, _) | ast::view_item_use(ident, _, _)
@ -1121,7 +1121,7 @@ fn index_mod(md: &ast::_mod) -> mod_index {
} }
fn index_nmod(md: &ast::native_mod) -> mod_index { fn index_nmod(md: &ast::native_mod) -> mod_index {
let index = new_str_hash[list[mod_index_entry]](); let index = new_str_hash[list<mod_index_entry>]();
for it: @ast::view_item in md.view_items { for it: @ast::view_item in md.view_items {
alt it.node { alt it.node {
ast::view_item_use(ident, _, _) | ast::view_item_import(ident, _, _) ast::view_item_use(ident, _, _) | ast::view_item_import(ident, _, _)
@ -1158,7 +1158,7 @@ fn ns_for_def(d: def) -> namespace {
} }
fn lookup_external(e: &env, cnum: int, ids: &[ident], ns: namespace) -> fn lookup_external(e: &env, cnum: int, ids: &[ident], ns: namespace) ->
option::t[def] { option::t<def> {
for d: def in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids) { for d: def in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids) {
e.ext_map.insert(ast::def_id_of_def(d), ids); e.ext_map.insert(ast::def_id_of_def(d), ids);
if ns == ns_for_def(d) { ret some(d); } if ns == ns_for_def(d) { ret some(d); }
@ -1173,7 +1173,7 @@ fn check_for_collisions(e: &@env, c: &ast::crate) {
// name for multiple entities in the same namespace. // name for multiple entities in the same namespace.
for each m: @{key: ast::node_id, val: @indexed_mod} for each m: @{key: ast::node_id, val: @indexed_mod}
in e.mod_map.items() { in e.mod_map.items() {
for each name: @{key: ident, val: list[mod_index_entry]} for each name: @{key: ident, val: list<mod_index_entry>}
in m.val.index.items() { in m.val.index.items() {
check_mod_name(*e, name.key, name.val); check_mod_name(*e, name.key, name.val);
} }
@ -1188,7 +1188,7 @@ fn check_for_collisions(e: &@env, c: &ast::crate) {
visit::visit_crate(c, (), visit::mk_vt(v)); visit::visit_crate(c, (), visit::mk_vt(v));
} }
fn check_mod_name(e: &env, name: &ident, entries: list[mod_index_entry]) { fn check_mod_name(e: &env, name: &ident, entries: list<mod_index_entry>) {
let saw_mod = false; let saw_mod = false;
let saw_type = false; let saw_type = false;
let saw_value = false; let saw_value = false;
@ -1229,7 +1229,7 @@ fn mie_span(mie: &mod_index_entry) -> span {
}; };
} }
fn check_item(e: &@env, i: &@ast::item, x: &(), v: &vt[()]) { fn check_item(e: &@env, i: &@ast::item, x: &(), v: &vt<()>) {
fn typaram_names(tps: &[ast::ty_param]) -> [ident] { fn typaram_names(tps: &[ast::ty_param]) -> [ident] {
let x: [ast::ident] = ~[]; let x: [ast::ident] = ~[];
for tp: ast::ty_param in tps { x += ~[tp.ident] } for tp: ast::ty_param in tps { x += ~[tp.ident] }
@ -1266,7 +1266,7 @@ fn check_pat(ch: checker, p: &@ast::pat) {
} }
} }
fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt[()]) { fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt<()>) {
visit::visit_arm(a, x, v); visit::visit_arm(a, x, v);
let ch0 = checker(*e, "binding"); let ch0 = checker(*e, "binding");
check_pat(ch0, a.pats.(0)); check_pat(ch0, a.pats.(0));
@ -1296,7 +1296,7 @@ fn check_arm(e: &@env, a: &ast::arm, x: &(), v: &vt[()]) {
} }
} }
fn check_block(e: &@env, b: &ast::blk, x: &(), v: &vt[()]) { fn check_block(e: &@env, b: &ast::blk, x: &(), v: &vt<()>) {
visit::visit_block(b, x, v); visit::visit_block(b, x, v);
let values = checker(*e, "value"); let values = checker(*e, "value");
let types = checker(*e, "type"); let types = checker(*e, "type");
@ -1349,7 +1349,7 @@ fn check_fn(e: &env, sp: &span, f: &ast::_fn) {
ensure_unique(e, sp, f.decl.inputs, arg_name, "argument"); ensure_unique(e, sp, f.decl.inputs, arg_name, "argument");
} }
fn check_expr(e: &@env, ex: &@ast::expr, x: &(), v: &vt[()]) { fn check_expr(e: &@env, ex: &@ast::expr, x: &(), v: &vt<()>) {
alt ex.node { alt ex.node {
ast::expr_rec(fields, _) { ast::expr_rec(fields, _) {
fn field_name(f: &ast::field) -> ident { ret f.node.ident; } fn field_name(f: &ast::field) -> ident { ret f.node.ident; }
@ -1360,7 +1360,7 @@ fn check_expr(e: &@env, ex: &@ast::expr, x: &(), v: &vt[()]) {
visit::visit_expr(ex, x, v); visit::visit_expr(ex, x, v);
} }
fn check_ty(e: &@env, ty: &@ast::ty, x: &(), v: &vt[()]) { fn check_ty(e: &@env, ty: &@ast::ty, x: &(), v: &vt<()>) {
alt ty.node { alt ty.node {
ast::ty_rec(fields) { ast::ty_rec(fields) {
fn field_name(f: &ast::ty_field) -> ident { ret f.node.ident; } fn field_name(f: &ast::ty_field) -> ident { ret f.node.ident; }

View file

@ -39,9 +39,9 @@ type res_info = { did: ast::def_id, t: ty::t };
type ctxt = { type ctxt = {
mutable next_tag_id: u16, mutable next_tag_id: u16,
pad: u16, pad: u16,
tag_id_to_index: hashmap[ast::def_id,u16], tag_id_to_index: hashmap<ast::def_id,u16>,
mutable tag_order: [ast::def_id], mutable tag_order: [ast::def_id],
resources: interner::interner[res_info], resources: interner::interner<res_info>,
llshapetablesty: TypeRef, llshapetablesty: TypeRef,
llshapetables: ValueRef llshapetables: ValueRef
}; };

View file

@ -361,7 +361,7 @@ fn decl_glue(llmod: ModuleRef, cx: &crate_ctxt, s: &str) -> ValueRef {
ret decl_cdecl_fn(llmod, s, T_fn(~[T_taskptr(cx)], T_void())); ret decl_cdecl_fn(llmod, s, T_fn(~[T_taskptr(cx)], T_void()));
} }
fn get_extern_fn(externs: &hashmap[str, ValueRef], llmod: ModuleRef, fn get_extern_fn(externs: &hashmap<str, ValueRef>, llmod: ModuleRef,
name: &str, cc: uint, ty: TypeRef) -> ValueRef { name: &str, cc: uint, ty: TypeRef) -> ValueRef {
if externs.contains_key(name) { ret externs.get(name); } if externs.contains_key(name) { ret externs.get(name); }
let f = decl_fn(llmod, name, cc, ty); let f = decl_fn(llmod, name, cc, ty);
@ -369,7 +369,7 @@ fn get_extern_fn(externs: &hashmap[str, ValueRef], llmod: ModuleRef,
ret f; ret f;
} }
fn get_extern_const(externs: &hashmap[str, ValueRef], llmod: ModuleRef, fn get_extern_const(externs: &hashmap<str, ValueRef>, llmod: ModuleRef,
name: &str, ty: TypeRef) -> ValueRef { name: &str, ty: TypeRef) -> ValueRef {
if externs.contains_key(name) { ret externs.get(name); } if externs.contains_key(name) { ret externs.get(name); }
let c = llvm::LLVMAddGlobal(llmod, ty, str::buf(name)); let c = llvm::LLVMAddGlobal(llmod, ty, str::buf(name));
@ -377,7 +377,7 @@ fn get_extern_const(externs: &hashmap[str, ValueRef], llmod: ModuleRef,
ret c; ret c;
} }
fn get_simple_extern_fn(externs: &hashmap[str, ValueRef], llmod: ModuleRef, fn get_simple_extern_fn(externs: &hashmap<str, ValueRef>, llmod: ModuleRef,
name: &str, n_args: int) -> ValueRef { name: &str, n_args: int) -> ValueRef {
let inputs = std::vec::init_elt[TypeRef](T_int(), n_args as uint); let inputs = std::vec::init_elt[TypeRef](T_int(), n_args as uint);
let output = T_int(); let output = T_int();
@ -386,7 +386,7 @@ fn get_simple_extern_fn(externs: &hashmap[str, ValueRef], llmod: ModuleRef,
} }
fn trans_native_call(b: &builder, glues: @glue_fns, lltaskptr: ValueRef, fn trans_native_call(b: &builder, glues: @glue_fns, lltaskptr: ValueRef,
externs: &hashmap[str, ValueRef], tn: &type_names, externs: &hashmap<str, ValueRef>, tn: &type_names,
llmod: ModuleRef, name: &str, pass_task: bool, llmod: ModuleRef, name: &str, pass_task: bool,
args: &[ValueRef]) -> ValueRef { args: &[ValueRef]) -> ValueRef {
let n: int = std::vec::len[ValueRef](args) as int; let n: int = std::vec::len[ValueRef](args) as int;
@ -939,7 +939,7 @@ fn trans_stack_local_derived_tydesc(cx: &@block_ctxt, llsz: ValueRef,
} }
fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool, fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool,
static_ti: &mutable option::t[@tydesc_info]) -> result { static_ti: &mutable option::t<@tydesc_info>) -> result {
alt cx.fcx.derived_tydescs.find(t) { alt cx.fcx.derived_tydescs.find(t) {
some(info) { some(info) {
@ -1007,7 +1007,7 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool,
} }
fn get_tydesc(cx: &@block_ctxt, orig_t: &ty::t, escapes: bool, fn get_tydesc(cx: &@block_ctxt, orig_t: &ty::t, escapes: bool,
static_ti: &mutable option::t[@tydesc_info]) -> result { static_ti: &mutable option::t<@tydesc_info>) -> result {
let t = ty::strip_cname(bcx_tcx(cx), orig_t); let t = ty::strip_cname(bcx_tcx(cx), orig_t);
@ -1470,7 +1470,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id,
~[C_int(0), C_int(abi::fn_field_box)])); ~[C_int(0), C_int(abi::fn_field_box)]));
let args = ~[cx.fcx.llretptr, cx.fcx.lltaskptr, dtor_env]; let args = ~[cx.fcx.llretptr, cx.fcx.lltaskptr, dtor_env];
for tp: ty::t in tps { for tp: ty::t in tps {
let ti: option::t[@tydesc_info] = none; let ti: option::t<@tydesc_info> = none;
let td = get_tydesc(cx, tp, false, ti); let td = get_tydesc(cx, tp, false, ti);
args += ~[td.val]; args += ~[td.val];
cx = td.bcx; cx = td.bcx;
@ -1983,7 +1983,7 @@ fn iter_sequence(cx: @block_ctxt, v: ValueRef, t: &ty::t, f: &val_and_ty_fn)
} }
fn lazily_emit_all_tydesc_glue(cx: &@block_ctxt, fn lazily_emit_all_tydesc_glue(cx: &@block_ctxt,
static_ti: &option::t[@tydesc_info]) { static_ti: &option::t<@tydesc_info>) {
lazily_emit_tydesc_glue(cx, abi::tydesc_field_copy_glue, static_ti); lazily_emit_tydesc_glue(cx, abi::tydesc_field_copy_glue, static_ti);
lazily_emit_tydesc_glue(cx, abi::tydesc_field_drop_glue, static_ti); lazily_emit_tydesc_glue(cx, abi::tydesc_field_drop_glue, static_ti);
lazily_emit_tydesc_glue(cx, abi::tydesc_field_free_glue, static_ti); lazily_emit_tydesc_glue(cx, abi::tydesc_field_free_glue, static_ti);
@ -1992,13 +1992,13 @@ fn lazily_emit_all_tydesc_glue(cx: &@block_ctxt,
fn lazily_emit_all_generic_info_tydesc_glues(cx: &@block_ctxt, fn lazily_emit_all_generic_info_tydesc_glues(cx: &@block_ctxt,
gi: &generic_info) { gi: &generic_info) {
for ti: option::t[@tydesc_info] in gi.static_tis { for ti: option::t<@tydesc_info> in gi.static_tis {
lazily_emit_all_tydesc_glue(cx, ti); lazily_emit_all_tydesc_glue(cx, ti);
} }
} }
fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int, fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
static_ti: &option::t[@tydesc_info]) { static_ti: &option::t<@tydesc_info>) {
alt static_ti { alt static_ti {
none. { } none. { }
some(ti) { some(ti) {
@ -2073,7 +2073,7 @@ fn lazily_emit_tydesc_glue(cx: &@block_ctxt, field: int,
} }
fn call_tydesc_glue_full(cx: &@block_ctxt, v: ValueRef, tydesc: ValueRef, fn call_tydesc_glue_full(cx: &@block_ctxt, v: ValueRef, tydesc: ValueRef,
field: int, static_ti: &option::t[@tydesc_info]) { field: int, static_ti: &option::t<@tydesc_info>) {
lazily_emit_tydesc_glue(cx, field, static_ti); lazily_emit_tydesc_glue(cx, field, static_ti);
let static_glue_fn = none; let static_glue_fn = none;
@ -2114,7 +2114,7 @@ fn call_tydesc_glue_full(cx: &@block_ctxt, v: ValueRef, tydesc: ValueRef,
fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t, field: int) -> fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t, field: int) ->
result { result {
let ti: option::t[@tydesc_info] = none[@tydesc_info]; let ti: option::t<@tydesc_info> = none[@tydesc_info];
let td = get_tydesc(cx, t, false, ti); let td = get_tydesc(cx, t, false, ti);
call_tydesc_glue_full(td.bcx, spill_if_immediate(td.bcx, v, t), td.val, call_tydesc_glue_full(td.bcx, spill_if_immediate(td.bcx, v, t), td.val,
field, ti); field, ti);
@ -3376,7 +3376,7 @@ fn join_branches(parent_cx: &@block_ctxt, ins: &[result]) -> @block_ctxt {
tag out_method { return; save_in(ValueRef); } tag out_method { return; save_in(ValueRef); }
fn trans_if(cx: &@block_ctxt, cond: &@ast::expr, thn: &ast::blk, fn trans_if(cx: &@block_ctxt, cond: &@ast::expr, thn: &ast::blk,
els: &option::t[@ast::expr], id: ast::node_id, els: &option::t<@ast::expr>, id: ast::node_id,
output: &out_method) -> result { output: &out_method) -> result {
let cond_res = trans_expr(cx, cond); let cond_res = trans_expr(cx, cond);
@ -3778,15 +3778,15 @@ fn trans_do_while(cx: &@block_ctxt, body: &ast::blk, cond: &@ast::expr) ->
type generic_info = type generic_info =
{item_type: ty::t, {item_type: ty::t,
static_tis: [option::t[@tydesc_info]], static_tis: [option::t<@tydesc_info>],
tydescs: [ValueRef]}; tydescs: [ValueRef]};
type lval_result = type lval_result =
{res: result, {res: result,
is_mem: bool, is_mem: bool,
generic: option::t[generic_info], generic: option::t<generic_info>,
llobj: option::t[ValueRef], llobj: option::t<ValueRef>,
method_ty: option::t[ty::t]}; method_ty: option::t<ty::t>};
fn lval_mem(cx: &@block_ctxt, val: ValueRef) -> lval_result { fn lval_mem(cx: &@block_ctxt, val: ValueRef) -> lval_result {
ret {res: rslt(cx, val), ret {res: rslt(cx, val),
@ -3827,7 +3827,7 @@ fn lval_generic_fn(cx: &@block_ctxt, tpt: &ty::ty_param_kinds_and_ty,
if std::vec::len[ty::t](tys) != 0u { if std::vec::len[ty::t](tys) != 0u {
let bcx = lv.res.bcx; let bcx = lv.res.bcx;
let tydescs: [ValueRef] = ~[]; let tydescs: [ValueRef] = ~[];
let tis: [option::t[@tydesc_info]] = ~[]; let tis: [option::t<@tydesc_info>] = ~[];
for t: ty::t in tys { for t: ty::t in tys {
// TODO: Doesn't always escape. // TODO: Doesn't always escape.
@ -4213,10 +4213,10 @@ fn trans_cast(cx: &@block_ctxt, e: &@ast::expr, id: ast::node_id) -> result {
} }
fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t, fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
outgoing_fty: &ty::t, args: &[option::t[@ast::expr]], outgoing_fty: &ty::t, args: &[option::t<@ast::expr>],
env_ty: &ty::t, bound_tys: &[ty::t], env_ty: &ty::t, bound_tys: &[ty::t],
ty_param_count: uint, ty_param_count: uint,
target_fn: &option::t[ValueRef]) -> target_fn: &option::t<ValueRef>) ->
{val: ValueRef, ty: TypeRef} { {val: ValueRef, ty: TypeRef} {
// Here we're not necessarily constructing a thunk in the sense of // Here we're not necessarily constructing a thunk in the sense of
@ -4330,7 +4330,7 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
let outgoing_arg_index: uint = 0u; let outgoing_arg_index: uint = 0u;
let llout_arg_tys: [TypeRef] = let llout_arg_tys: [TypeRef] =
type_of_explicit_args(cx.ccx, sp, outgoing_args); type_of_explicit_args(cx.ccx, sp, outgoing_args);
for arg: option::t[@ast::expr] in args { for arg: option::t<@ast::expr> in args {
let out_arg = outgoing_args.(outgoing_arg_index); let out_arg = outgoing_args.(outgoing_arg_index);
let llout_arg_ty = llout_arg_tys.(outgoing_arg_index); let llout_arg_ty = llout_arg_tys.(outgoing_arg_index);
let is_val = out_arg.mode == ty::mo_val; let is_val = out_arg.mode == ty::mo_val;
@ -4405,16 +4405,16 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t,
} }
fn trans_bind(cx: &@block_ctxt, f: &@ast::expr, fn trans_bind(cx: &@block_ctxt, f: &@ast::expr,
args: &[option::t[@ast::expr]], id: ast::node_id) -> result { args: &[option::t<@ast::expr>], id: ast::node_id) -> result {
let f_res = trans_lval_gen(cx, f); let f_res = trans_lval_gen(cx, f);
ret trans_bind_1(cx, f, f_res, args, id); ret trans_bind_1(cx, f, f_res, args, id);
} }
fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result, fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
args: &[option::t[@ast::expr]], id: ast::node_id) -> args: &[option::t<@ast::expr>], id: ast::node_id) ->
result { result {
let bound: [@ast::expr] = ~[]; let bound: [@ast::expr] = ~[];
for argopt: option::t[@ast::expr] in args { for argopt: option::t<@ast::expr> in args {
alt argopt { none. { } some(e) { bound += ~[e]; } } alt argopt { none. { } some(e) { bound += ~[e]; } }
} }
@ -4561,7 +4561,7 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg,
// - new_fn_ctxt // - new_fn_ctxt
// - trans_args // - trans_args
fn trans_args(cx: &@block_ctxt, llenv: ValueRef, fn trans_args(cx: &@block_ctxt, llenv: ValueRef,
gen: &option::t[generic_info], lliterbody: &option::t[ValueRef], gen: &option::t<generic_info>, lliterbody: &option::t<ValueRef>,
es: &[@ast::expr], fn_ty: &ty::t) -> es: &[@ast::expr], fn_ty: &ty::t) ->
{bcx: @block_ctxt, {bcx: @block_ctxt,
args: [ValueRef], args: [ValueRef],
@ -4645,7 +4645,7 @@ fn trans_args(cx: &@block_ctxt, llenv: ValueRef,
} }
fn trans_call(cx: &@block_ctxt, f: &@ast::expr, fn trans_call(cx: &@block_ctxt, f: &@ast::expr,
lliterbody: &option::t[ValueRef], args: &[@ast::expr], lliterbody: &option::t<ValueRef>, args: &[@ast::expr],
id: ast::node_id) -> result { id: ast::node_id) -> result {
// NB: 'f' isn't necessarily a function; it might be an entire self-call // NB: 'f' isn't necessarily a function; it might be an entire self-call
// expression because of the hack that allows us to process self-calls // expression because of the hack that allows us to process self-calls
@ -4910,7 +4910,7 @@ fn trans_ivec(bcx: @block_ctxt, args: &[@ast::expr], id: ast::node_id) ->
} }
fn trans_rec(cx: &@block_ctxt, fields: &[ast::field], fn trans_rec(cx: &@block_ctxt, fields: &[ast::field],
base: &option::t[@ast::expr], id: ast::node_id) -> result { base: &option::t<@ast::expr>, id: ast::node_id) -> result {
let bcx = cx; let bcx = cx;
let t = node_id_type(bcx_ccx(bcx), id); let t = node_id_type(bcx_ccx(bcx), id);
let rec_res = alloc_ty(bcx, t); let rec_res = alloc_ty(bcx, t);
@ -5263,8 +5263,8 @@ fn trans_check_expr(cx: &@block_ctxt, e: &@ast::expr, s: &str) -> result {
ret rslt(next_cx, C_nil()); ret rslt(next_cx, C_nil());
} }
fn trans_fail_expr(cx: &@block_ctxt, sp_opt: &option::t[span], fn trans_fail_expr(cx: &@block_ctxt, sp_opt: &option::t<span>,
fail_expr: &option::t[@ast::expr]) -> result { fail_expr: &option::t<@ast::expr>) -> result {
let bcx = cx; let bcx = cx;
alt fail_expr { alt fail_expr {
some(expr) { some(expr) {
@ -5290,13 +5290,13 @@ fn trans_fail_expr(cx: &@block_ctxt, sp_opt: &option::t[span],
} }
} }
fn trans_fail(cx: &@block_ctxt, sp_opt: &option::t[span], fail_str: &str) -> fn trans_fail(cx: &@block_ctxt, sp_opt: &option::t<span>, fail_str: &str) ->
result { result {
let V_fail_str = C_cstr(bcx_ccx(cx), fail_str); let V_fail_str = C_cstr(bcx_ccx(cx), fail_str);
ret trans_fail_value(cx, sp_opt, V_fail_str); ret trans_fail_value(cx, sp_opt, V_fail_str);
} }
fn trans_fail_value(cx: &@block_ctxt, sp_opt: &option::t[span], fn trans_fail_value(cx: &@block_ctxt, sp_opt: &option::t<span>,
V_fail_str: &ValueRef) -> result { V_fail_str: &ValueRef) -> result {
let V_filename; let V_filename;
let V_line; let V_line;
@ -5316,7 +5316,7 @@ fn trans_fail_value(cx: &@block_ctxt, sp_opt: &option::t[span],
ret rslt(cx, C_nil()); ret rslt(cx, C_nil());
} }
fn trans_put(cx: &@block_ctxt, e: &option::t[@ast::expr]) -> result { fn trans_put(cx: &@block_ctxt, e: &option::t<@ast::expr>) -> result {
let llcallee = C_nil(); let llcallee = C_nil();
let llenv = C_nil(); let llenv = C_nil();
alt { cx.fcx.lliterbody } { alt { cx.fcx.lliterbody } {
@ -5415,7 +5415,7 @@ fn trans_cont(sp: &span, cx: &@block_ctxt) -> result {
ret trans_break_cont(sp, cx, false); ret trans_break_cont(sp, cx, false);
} }
fn trans_ret(cx: &@block_ctxt, e: &option::t[@ast::expr]) -> result { fn trans_ret(cx: &@block_ctxt, e: &option::t<@ast::expr>) -> result {
let bcx = cx; let bcx = cx;
alt e { alt e {
some(x) { some(x) {
@ -5552,7 +5552,7 @@ fn new_scope_block_ctxt(bcx: &@block_ctxt, n: &str) -> @block_ctxt {
} }
fn new_loop_scope_block_ctxt(bcx: &@block_ctxt, fn new_loop_scope_block_ctxt(bcx: &@block_ctxt,
_cont: &option::t[@block_ctxt], _cont: &option::t<@block_ctxt>,
_break: &@block_ctxt, n: &str) -> @block_ctxt { _break: &@block_ctxt, n: &str) -> @block_ctxt {
ret new_block_ctxt(bcx.fcx, parent_some(bcx), ret new_block_ctxt(bcx.fcx, parent_some(bcx),
LOOP_SCOPE_BLOCK(_cont, _break), n); LOOP_SCOPE_BLOCK(_cont, _break), n);
@ -5788,11 +5788,11 @@ fn new_fn_ctxt_w_id(cx: @local_ctxt, sp: &span, llfndecl: ValueRef,
let llretptr: ValueRef = llvm::LLVMGetParam(llfndecl, 0u); let llretptr: ValueRef = llvm::LLVMGetParam(llfndecl, 0u);
let lltaskptr: ValueRef = llvm::LLVMGetParam(llfndecl, 1u); let lltaskptr: ValueRef = llvm::LLVMGetParam(llfndecl, 1u);
let llenv: ValueRef = llvm::LLVMGetParam(llfndecl, 2u); let llenv: ValueRef = llvm::LLVMGetParam(llfndecl, 2u);
let llargs: hashmap[ast::node_id, ValueRef] = new_int_hash[ValueRef](); let llargs: hashmap<ast::node_id, ValueRef> = new_int_hash[ValueRef]();
let llobjfields: hashmap[ast::node_id, ValueRef] = let llobjfields: hashmap<ast::node_id, ValueRef> =
new_int_hash[ValueRef](); new_int_hash[ValueRef]();
let lllocals: hashmap[ast::node_id, ValueRef] = new_int_hash[ValueRef](); let lllocals: hashmap<ast::node_id, ValueRef> = new_int_hash[ValueRef]();
let llupvars: hashmap[ast::node_id, ValueRef] = new_int_hash[ValueRef](); let llupvars: hashmap<ast::node_id, ValueRef> = new_int_hash[ValueRef]();
let derived_tydescs = let derived_tydescs =
map::mk_hashmap[ty::t, derived_tydesc_info](ty::hash_ty, ty::eq_ty); map::mk_hashmap[ty::t, derived_tydesc_info](ty::hash_ty, ty::eq_ty);
let llbbs = mk_standard_basic_blocks(llfndecl); let llbbs = mk_standard_basic_blocks(llfndecl);
@ -5838,7 +5838,7 @@ fn new_fn_ctxt(cx: @local_ctxt, sp: &span, llfndecl: ValueRef) -> @fn_ctxt {
// the function's fn_ctxt). create_llargs_for_fn_args populates the llargs // the function's fn_ctxt). create_llargs_for_fn_args populates the llargs
// field of the fn_ctxt with // field of the fn_ctxt with
fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto, fn create_llargs_for_fn_args(cx: &@fn_ctxt, proto: ast::proto,
ty_self: option::t[ty::t], ret_ty: ty::t, ty_self: option::t<ty::t>, ret_ty: ty::t,
args: &[ast::arg], ty_params: &[ast::ty_param]) { args: &[ast::arg], ty_params: &[ast::ty_param]) {
// Skip the implicit arguments 0, 1, and 2. TODO: Pull out 3u and define // Skip the implicit arguments 0, 1, and 2. TODO: Pull out 3u and define
// it as a constant, since we're using it in several places in trans this // it as a constant, since we're using it in several places in trans this
@ -5997,11 +5997,11 @@ fn finish_fn(fcx: &@fn_ctxt, lltop: BasicBlockRef) {
// trans_closure: Builds an LLVM function out of a source function. // trans_closure: Builds an LLVM function out of a source function.
// If the function closes over its environment a closure will be // If the function closes over its environment a closure will be
// returned. // returned.
fn trans_closure(bcx_maybe: &option::t[@block_ctxt], fn trans_closure(bcx_maybe: &option::t<@block_ctxt>,
llfnty: &option::t[TypeRef], cx: @local_ctxt, sp: &span, llfnty: &option::t<TypeRef>, cx: @local_ctxt, sp: &span,
f: &ast::_fn, llfndecl: ValueRef, ty_self: option::t[ty::t], f: &ast::_fn, llfndecl: ValueRef, ty_self: option::t<ty::t>,
ty_params: &[ast::ty_param], id: ast::node_id) ty_params: &[ast::ty_param], id: ast::node_id)
-> option::t[{fn_pair: ValueRef, bcx: @block_ctxt}] { -> option::t<{fn_pair: ValueRef, bcx: @block_ctxt}> {
set_uwtable(llfndecl); set_uwtable(llfndecl);
// Set up arguments to the function. // Set up arguments to the function.
@ -6068,7 +6068,7 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
} }
fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn, fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn,
llfndecl: ValueRef, ty_self: option::t[ty::t], llfndecl: ValueRef, ty_self: option::t<ty::t>,
ty_params: &[ast::ty_param], id: ast::node_id) { ty_params: &[ast::ty_param], id: ast::node_id) {
trans_closure(none, none, cx, sp, f, llfndecl, ty_self, ty_params, id); trans_closure(none, none, cx, sp, f, llfndecl, ty_self, ty_params, id);
} }
@ -6077,7 +6077,7 @@ fn trans_fn_inner(cx: @local_ctxt, sp: &span, f: &ast::_fn,
// trans_fn: creates an LLVM function corresponding to a source language // trans_fn: creates an LLVM function corresponding to a source language
// function. // function.
fn trans_fn(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef, fn trans_fn(cx: @local_ctxt, sp: &span, f: &ast::_fn, llfndecl: ValueRef,
ty_self: option::t[ty::t], ty_params: &[ast::ty_param], ty_self: option::t<ty::t>, ty_params: &[ast::ty_param],
id: ast::node_id) { id: ast::node_id) {
if !cx.ccx.sess.get_opts().stats { if !cx.ccx.sess.get_opts().stats {
trans_fn_inner(cx, sp, f, llfndecl, ty_self, ty_params, id); trans_fn_inner(cx, sp, f, llfndecl, ty_self, ty_params, id);
@ -6747,7 +6747,7 @@ fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str],
fn item_path(item: &@ast::item) -> [str] { ret ~[item.ident]; } fn item_path(item: &@ast::item) -> [str] { ret ~[item.ident]; }
fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &[str], fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &[str],
v: &vt[[str]]) { v: &vt<[str]>) {
alt i.node { alt i.node {
ast::native_item_fn(_, _, _) { ast::native_item_fn(_, _, _) {
if !ccx.obj_methods.contains_key(i.id) { if !ccx.obj_methods.contains_key(i.id) {
@ -6759,7 +6759,7 @@ fn collect_native_item(ccx: @crate_ctxt, i: &@ast::native_item, pt: &[str],
} }
fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str],
v: &vt[[str]]) { v: &vt<[str]>) {
visit::visit_item(i, pt + item_path(i), v); visit::visit_item(i, pt + item_path(i), v);
alt i.node { alt i.node {
ast::item_const(_, _) { ast::item_const(_, _) {
@ -6778,7 +6778,7 @@ fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str],
} }
fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &[str], fn collect_item_2(ccx: &@crate_ctxt, i: &@ast::item, pt: &[str],
v: &vt[[str]]) { v: &vt<[str]>) {
let new_pt = pt + item_path(i); let new_pt = pt + item_path(i);
visit::visit_item(i, new_pt, v); visit::visit_item(i, new_pt, v);
alt i.node { alt i.node {
@ -6818,7 +6818,7 @@ fn collect_items(ccx: &@crate_ctxt, crate: @ast::crate) {
} }
fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], fn collect_tag_ctor(ccx: @crate_ctxt, i: &@ast::item, pt: &[str],
v: &vt[[str]]) { v: &vt<[str]>) {
let new_pt = pt + item_path(i); let new_pt = pt + item_path(i);
visit::visit_item(i, new_pt, v); visit::visit_item(i, new_pt, v);
alt i.node { alt i.node {
@ -6844,7 +6844,7 @@ fn collect_tag_ctors(ccx: &@crate_ctxt, crate: @ast::crate) {
// The constant translation pass. // The constant translation pass.
fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[str], fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[str],
v: &vt[[str]]) { v: &vt<[str]>) {
let new_pt = pt + item_path(it); let new_pt = pt + item_path(it);
visit::visit_item(it, new_pt, v); visit::visit_item(it, new_pt, v);
alt it.node { alt it.node {
@ -6891,7 +6891,7 @@ fn i2p(v: ValueRef, t: TypeRef) -> ValueRef {
ret llvm::LLVMConstIntToPtr(v, t); ret llvm::LLVMConstIntToPtr(v, t);
} }
fn declare_intrinsics(llmod: ModuleRef) -> hashmap[str, ValueRef] { fn declare_intrinsics(llmod: ModuleRef) -> hashmap<str, ValueRef> {
let T_memmove32_args: [TypeRef] = let T_memmove32_args: [TypeRef] =
~[T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()]; ~[T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()];
let T_memmove64_args: [TypeRef] = let T_memmove64_args: [TypeRef] =

View file

@ -77,7 +77,7 @@ fn bind_for_pat(p: &@ast::pat, br: &match_branch, val: ValueRef) {
} }
} }
type enter_pat = fn(&@ast::pat) -> option::t[[@ast::pat]] ; type enter_pat = fn(&@ast::pat) -> option::t<[@ast::pat]> ;
fn enter_match(m: &match, col: uint, val: ValueRef, e: &enter_pat) -> match { fn enter_match(m: &match, col: uint, val: ValueRef, e: &enter_pat) -> match {
let result = ~[]; let result = ~[];
@ -98,7 +98,7 @@ fn enter_match(m: &match, col: uint, val: ValueRef, e: &enter_pat) -> match {
} }
fn enter_default(m: &match, col: uint, val: ValueRef) -> match { fn enter_default(m: &match, col: uint, val: ValueRef) -> match {
fn e(p: &@ast::pat) -> option::t[[@ast::pat]] { fn e(p: &@ast::pat) -> option::t<[@ast::pat]> {
ret if matches_always(p) { some(~[]) } else { none }; ret if matches_always(p) { some(~[]) } else { none };
} }
ret enter_match(m, col, val, e); ret enter_match(m, col, val, e);
@ -108,7 +108,7 @@ fn enter_opt(ccx: &@crate_ctxt, m: &match, opt: &opt, col: uint,
tag_size: uint, val: ValueRef) -> match { tag_size: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
fn e(ccx: &@crate_ctxt, dummy: &@ast::pat, opt: &opt, size: uint, fn e(ccx: &@crate_ctxt, dummy: &@ast::pat, opt: &opt, size: uint,
p: &@ast::pat) -> option::t[[@ast::pat]] { p: &@ast::pat) -> option::t<[@ast::pat]> {
alt p.node { alt p.node {
ast::pat_tag(ctor, subpats) { ast::pat_tag(ctor, subpats) {
ret if opt_eq(variant_opt(ccx, p.id), opt) { ret if opt_eq(variant_opt(ccx, p.id), opt) {
@ -128,7 +128,7 @@ fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
match { match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
fn e(dummy: &@ast::pat, fields: &[ast::ident], p: &@ast::pat) -> fn e(dummy: &@ast::pat, fields: &[ast::ident], p: &@ast::pat) ->
option::t[[@ast::pat]] { option::t<[@ast::pat]> {
alt p.node { alt p.node {
ast::pat_rec(fpats, _) { ast::pat_rec(fpats, _) {
let pats = ~[]; let pats = ~[];
@ -150,7 +150,7 @@ fn enter_rec(m: &match, col: uint, fields: &[ast::ident], val: ValueRef) ->
fn enter_tup(m: &match, col: uint, val: ValueRef, n_elts: uint) -> match { fn enter_tup(m: &match, col: uint, val: ValueRef, n_elts: uint) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
fn e(dummy: &@ast::pat, n_elts: uint, p: &@ast::pat) fn e(dummy: &@ast::pat, n_elts: uint, p: &@ast::pat)
-> option::t[[@ast::pat]] { -> option::t<[@ast::pat]> {
alt p.node { alt p.node {
ast::pat_tup(elts) { ret some(elts); } ast::pat_tup(elts) { ret some(elts); }
_ { ret some(vec::init_elt(dummy, n_elts)); } _ { ret some(vec::init_elt(dummy, n_elts)); }
@ -161,7 +161,7 @@ fn enter_tup(m: &match, col: uint, val: ValueRef, n_elts: uint) -> match {
fn enter_box(m: &match, col: uint, val: ValueRef) -> match { fn enter_box(m: &match, col: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t[[@ast::pat]] { fn e(dummy: &@ast::pat, p: &@ast::pat) -> option::t<[@ast::pat]> {
alt p.node { alt p.node {
ast::pat_box(sub) { ret some(~[sub]); } ast::pat_box(sub) { ret some(~[sub]); }
_ { ret some(~[dummy]); } _ { ret some(~[dummy]); }
@ -431,7 +431,7 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
// Returns false for unreachable blocks // Returns false for unreachable blocks
fn make_phi_bindings(bcx: &@block_ctxt, map: &[exit_node], fn make_phi_bindings(bcx: &@block_ctxt, map: &[exit_node],
ids: &ast::pat_id_map) -> bool { ids: &ast::pat_id_map) -> bool {
fn assoc(key: str, list: &bind_map) -> option::t[ValueRef] { fn assoc(key: str, list: &bind_map) -> option::t<ValueRef> {
for elt: {ident: ast::ident, val: ValueRef} in list { for elt: {ident: ast::ident, val: ValueRef} in list {
if str::eq(elt.ident, key) { ret some(elt.val); } if str::eq(elt.ident, key) { ret some(elt.val); }
} }
@ -486,7 +486,7 @@ fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &[ast::arm],
// Cached fail-on-fallthrough block // Cached fail-on-fallthrough block
let fail_cx = @mutable none; let fail_cx = @mutable none;
fn mk_fail(cx: &@block_ctxt, sp: &span, fn mk_fail(cx: &@block_ctxt, sp: &span,
done: @mutable option::t[BasicBlockRef]) -> BasicBlockRef { done: @mutable option::t<BasicBlockRef>) -> BasicBlockRef {
alt *done { some(bb) { ret bb; } _ { } } alt *done { some(bb) { ret bb; } _ { } }
let fail_cx = new_sub_block_ctxt(cx, "case_fallthrough"); let fail_cx = new_sub_block_ctxt(cx, "case_fallthrough");
trans::trans_fail(fail_cx, some(sp), "non-exhaustive match failure"); trans::trans_fail(fail_cx, some(sp), "non-exhaustive match failure");
@ -517,7 +517,7 @@ fn trans_alt(cx: &@block_ctxt, expr: &@ast::expr, arms: &[ast::arm],
// Not alt-related, but similar to the pattern-munging code above // Not alt-related, but similar to the pattern-munging code above
fn bind_irrefutable_pat(bcx: @block_ctxt, pat: &@ast::pat, val: ValueRef, fn bind_irrefutable_pat(bcx: @block_ctxt, pat: &@ast::pat, val: ValueRef,
table: hashmap[ast::node_id, ValueRef], table: hashmap<ast::node_id, ValueRef>,
make_copy: bool) make_copy: bool)
-> @block_ctxt { -> @block_ctxt {
let ccx = bcx.fcx.lcx.ccx; let ccx = bcx.fcx.lcx.ccx;

View file

@ -75,10 +75,10 @@ type tydesc_info =
tydesc: ValueRef, tydesc: ValueRef,
size: ValueRef, size: ValueRef,
align: ValueRef, align: ValueRef,
mutable copy_glue: option::t[ValueRef], mutable copy_glue: option::t<ValueRef>,
mutable drop_glue: option::t[ValueRef], mutable drop_glue: option::t<ValueRef>,
mutable free_glue: option::t[ValueRef], mutable free_glue: option::t<ValueRef>,
mutable cmp_glue: option::t[ValueRef], mutable cmp_glue: option::t<ValueRef>,
ty_params: [uint]}; ty_params: [uint]};
/* /*
@ -110,32 +110,32 @@ type crate_ctxt = {
llmod: ModuleRef, llmod: ModuleRef,
td: target_data, td: target_data,
tn: type_names, tn: type_names,
externs: hashmap[str, ValueRef], externs: hashmap<str, ValueRef>,
intrinsics: hashmap[str, ValueRef], intrinsics: hashmap<str, ValueRef>,
// A mapping from the def_id of each item in this crate to the address // A mapping from the def_id of each item in this crate to the address
// of the first instruction of the item's definition in the executable // of the first instruction of the item's definition in the executable
// we're generating. // we're generating.
item_ids: hashmap[ast::node_id, ValueRef], item_ids: hashmap<ast::node_id, ValueRef>,
ast_map: ast_map::map, ast_map: ast_map::map,
item_symbols: hashmap[ast::node_id, str], item_symbols: hashmap<ast::node_id, str>,
mutable main_fn: option::t[ValueRef], mutable main_fn: option::t<ValueRef>,
link_meta: link::link_meta, link_meta: link::link_meta,
// TODO: hashmap[tup(tag_id,subtys), @tag_info] // TODO: hashmap<tup(tag_id,subtys), @tag_info>
tag_sizes: hashmap[ty::t, uint], tag_sizes: hashmap<ty::t, uint>,
discrims: hashmap[ast::node_id, ValueRef], discrims: hashmap<ast::node_id, ValueRef>,
discrim_symbols: hashmap[ast::node_id, str], discrim_symbols: hashmap<ast::node_id, str>,
fn_pairs: hashmap[ast::node_id, ValueRef], fn_pairs: hashmap<ast::node_id, ValueRef>,
consts: hashmap[ast::node_id, ValueRef], consts: hashmap<ast::node_id, ValueRef>,
obj_methods: hashmap[ast::node_id, ()], obj_methods: hashmap<ast::node_id, ()>,
tydescs: hashmap[ty::t, @tydesc_info], tydescs: hashmap<ty::t, @tydesc_info>,
module_data: hashmap[str, ValueRef], module_data: hashmap<str, ValueRef>,
lltypes: hashmap[ty::t, TypeRef], lltypes: hashmap<ty::t, TypeRef>,
glues: @glue_fns, glues: @glue_fns,
names: namegen, names: namegen,
sha: std::sha1::sha1, sha: std::sha1::sha1,
type_sha1s: hashmap[ty::t, str], type_sha1s: hashmap<ty::t, str>,
type_short_names: hashmap[ty::t, str], type_short_names: hashmap<ty::t, str>,
tcx: ty::ctxt, tcx: ty::ctxt,
stats: stats, stats: stats,
upcalls: @upcall::upcalls, upcalls: @upcall::upcalls,
@ -216,37 +216,37 @@ type fn_ctxt = {
// The 'self' object currently in use in this function, if there // The 'self' object currently in use in this function, if there
// is one. // is one.
mutable llself: option::t[val_self_pair], mutable llself: option::t<val_self_pair>,
// If this function is actually a iter, a block containing the // If this function is actually a iter, a block containing the
// code called whenever the iter calls 'put'. // code called whenever the iter calls 'put'.
mutable lliterbody: option::t[ValueRef], mutable lliterbody: option::t<ValueRef>,
// If this function is actually a iter, the type of the function // If this function is actually a iter, the type of the function
// that that we call when we call 'put'. Having to track this is // that that we call when we call 'put'. Having to track this is
// pretty irritating. We have to do it because we need the type if // pretty irritating. We have to do it because we need the type if
// we are going to put the iterbody into a closure (if it appears // we are going to put the iterbody into a closure (if it appears
// in a for-each inside of an iter). // in a for-each inside of an iter).
mutable iterbodyty: option::t[ty::t], mutable iterbodyty: option::t<ty::t>,
// The next four items: hash tables mapping from AST def_ids to // The next four items: hash tables mapping from AST def_ids to
// LLVM-stuff-in-the-frame. // LLVM-stuff-in-the-frame.
// Maps arguments to allocas created for them in llallocas. // Maps arguments to allocas created for them in llallocas.
llargs: hashmap[ast::node_id, ValueRef], llargs: hashmap<ast::node_id, ValueRef>,
// Maps fields in objects to pointers into the interior of // Maps fields in objects to pointers into the interior of
// llself's body. // llself's body.
llobjfields: hashmap[ast::node_id, ValueRef], llobjfields: hashmap<ast::node_id, ValueRef>,
// Maps the def_ids for local variables to the allocas created for // Maps the def_ids for local variables to the allocas created for
// them in llallocas. // them in llallocas.
lllocals: hashmap[ast::node_id, ValueRef], lllocals: hashmap<ast::node_id, ValueRef>,
// The same as above, but for variables accessed via the frame // The same as above, but for variables accessed via the frame
// pointer we pass into an iter, for access to the static // pointer we pass into an iter, for access to the static
// environment of the iter-calling frame. // environment of the iter-calling frame.
llupvars: hashmap[ast::node_id, ValueRef], llupvars: hashmap<ast::node_id, ValueRef>,
// For convenience, a vector of the incoming tydescs for each of // For convenience, a vector of the incoming tydescs for each of
// this functions type parameters, fetched via llvm::LLVMGetParam. // this functions type parameters, fetched via llvm::LLVMGetParam.
@ -263,7 +263,7 @@ type fn_ctxt = {
// when information about both "[T]" and "T" are available. When // when information about both "[T]" and "T" are available. When
// such a tydesc is created, we cache it in the derived_tydescs // such a tydesc is created, we cache it in the derived_tydescs
// table for the next time that such a tydesc is needed. // table for the next time that such a tydesc is needed.
derived_tydescs: hashmap[ty::t, derived_tydesc_info], derived_tydescs: hashmap<ty::t, derived_tydesc_info>,
// The node_id of the function, or -1 if it doesn't correspond to // The node_id of the function, or -1 if it doesn't correspond to
// a user-defined function. // a user-defined function.
@ -350,7 +350,7 @@ tag block_kind {
// which block to jump to in the case of "continue" or "break", with the // which block to jump to in the case of "continue" or "break", with the
// "continue" block optional, because "while" and "do while" don't support // "continue" block optional, because "while" and "do while" don't support
// "continue" (TODO: is this intentional?) // "continue" (TODO: is this intentional?)
LOOP_SCOPE_BLOCK(option::t[@block_ctxt], @block_ctxt); LOOP_SCOPE_BLOCK(option::t<@block_ctxt>, @block_ctxt);
// A non-scope block is a basic block created as a translation artifact // A non-scope block is a basic block created as a translation artifact
@ -397,7 +397,7 @@ type block_ctxt = {
fcx: @fn_ctxt fcx: @fn_ctxt
}; };
// FIXME: we should be able to use option::t[@block_parent] here but // FIXME: we should be able to use option::t<@block_parent> here but
// the infinite-tag check in rustboot gets upset. // the infinite-tag check in rustboot gets upset.
tag block_parent { parent_none; parent_some(@block_ctxt); } tag block_parent { parent_none; parent_some(@block_ctxt); }

View file

@ -423,7 +423,7 @@ fn vtbl_mthd_lteq(a: &vtbl_mthd, b: &vtbl_mthd) -> bool {
// ones that we don't need forwarding slots for. // ones that we don't need forwarding slots for.
fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd, fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd,
addtl_meths: [@ast::method]) -> addtl_meths: [@ast::method]) ->
option::t[vtbl_mthd] { option::t<vtbl_mthd> {
// Since m is a fwding_mthd, and we're checking to see if it's in // Since m is a fwding_mthd, and we're checking to see if it's in
// addtl_meths (which only contains normal_mthds), we can't just check if // addtl_meths (which only contains normal_mthds), we can't just check if
@ -448,7 +448,7 @@ fn filtering_fn(cx: @local_ctxt, m: &vtbl_mthd,
// object, and return a pointer to it. // object, and return a pointer to it.
fn create_vtbl(cx: @local_ctxt, sp: &span, outer_obj_ty: ty::t, fn create_vtbl(cx: @local_ctxt, sp: &span, outer_obj_ty: ty::t,
ob: &ast::_obj, ty_params: &[ast::ty_param], ob: &ast::_obj, ty_params: &[ast::ty_param],
inner_obj_ty: option::t[ty::t], inner_obj_ty: option::t<ty::t>,
additional_field_tys: &[ty::t]) -> ValueRef { additional_field_tys: &[ty::t]) -> ValueRef {
let llmethods: [ValueRef] = ~[]; let llmethods: [ValueRef] = ~[];
@ -892,7 +892,7 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method,
// object body: [tydesc, [typaram, ...], [field, ...], inner_obj]. // object body: [tydesc, [typaram, ...], [field, ...], inner_obj].
fn create_object_body_type(tcx: &ty::ctxt, fields_ty: &[ty::t], fn create_object_body_type(tcx: &ty::ctxt, fields_ty: &[ty::t],
typarams_ty: &[ty::t], typarams_ty: &[ty::t],
maybe_inner_obj_ty: option::t[ty::t]) -> ty::t { maybe_inner_obj_ty: option::t<ty::t>) -> ty::t {
let tydesc_ty: ty::t = ty::mk_type(tcx); let tydesc_ty: ty::t = ty::mk_type(tcx);
let typarams_ty_tup: ty::t = ty::mk_tup(tcx, typarams_ty); let typarams_ty_tup: ty::t = ty::mk_tup(tcx, typarams_ty);

View file

@ -208,11 +208,11 @@ Both types store an ident and span, for error-logging purposes.
*/ */
type pred_args_ = {args: [@constr_arg_use], bit_num: uint}; type pred_args_ = {args: [@constr_arg_use], bit_num: uint};
type pred_args = spanned[pred_args_]; type pred_args = spanned<pred_args_>;
// The attached node ID is the *defining* node ID // The attached node ID is the *defining* node ID
// for this local. // for this local.
type constr_arg_use = spanned[constr_arg_general_[inst]]; type constr_arg_use = spanned<constr_arg_general_<inst>>;
tag constraint { tag constraint {
cinit(uint, span, ident); cinit(uint, span, ident);
@ -232,11 +232,11 @@ tag tsconstr {
npred(path, def_id, [@constr_arg_use]); npred(path, def_id, [@constr_arg_use]);
} }
type sp_constr = spanned[tsconstr]; type sp_constr = spanned<tsconstr>;
type norm_constraint = {bit_num: uint, c: sp_constr}; type norm_constraint = {bit_num: uint, c: sp_constr};
type constr_map = @std::map::hashmap[def_id, constraint]; type constr_map = @std::map::hashmap<def_id, constraint>;
/* Contains stuff that has to be computed up front */ /* Contains stuff that has to be computed up front */
type fn_info = type fn_info =
@ -295,7 +295,7 @@ type node_ann_table = @mutable [mutable ts_ann];
/* mapping from function name to fn_info map */ /* mapping from function name to fn_info map */
type fn_info_map = @std::map::hashmap[node_id, fn_info]; type fn_info_map = @std::map::hashmap<node_id, fn_info>;
type fn_ctxt = type fn_ctxt =
{enclosing: fn_info, {enclosing: fn_info,
@ -318,7 +318,7 @@ fn add_node(ccx: &crate_ctxt, i: node_id, a: &ts_ann) {
ccx.node_anns.(i) = a; ccx.node_anns.(i) = a;
} }
fn get_ts_ann(ccx: &crate_ctxt, i: node_id) -> option::t[ts_ann] { fn get_ts_ann(ccx: &crate_ctxt, i: node_id) -> option::t<ts_ann> {
if i as uint < vec::len(*ccx.node_anns) { if i as uint < vec::len(*ccx.node_anns) {
ret some[ts_ann](ccx.node_anns.(i)); ret some[ts_ann](ccx.node_anns.(i));
} else { ret none[ts_ann]; } } else { ret none[ts_ann]; }
@ -547,10 +547,10 @@ fn node_id_to_def_strict(cx: &ty::ctxt, id: node_id) -> def {
} }
} }
fn node_id_to_def(ccx: &crate_ctxt, id: node_id) -> option::t[def] { fn node_id_to_def(ccx: &crate_ctxt, id: node_id) -> option::t<def> {
ret ccx.tcx.def_map.find(id); ret ccx.tcx.def_map.find(id);
} }
fn node_id_to_def_upvar(cx: &fn_ctxt, id: node_id) -> option::t[def] { fn node_id_to_def_upvar(cx: &fn_ctxt, id: node_id) -> option::t<def> {
ret freevars::def_lookup(cx.ccx.tcx, cx.id, id); ret freevars::def_lookup(cx.ccx.tcx, cx.id, id);
} }
@ -704,7 +704,7 @@ fn substitute_arg(cx: &ty::ctxt, actuals: &[@expr], a: @constr_arg) ->
} }
} }
fn pred_args_matches(pattern: &[constr_arg_general_[inst]], fn pred_args_matches(pattern: &[constr_arg_general_<inst>],
desc: &pred_args) -> bool { desc: &pred_args) -> bool {
let i = 0u; let i = 0u;
for c: @constr_arg_use in desc.node.args { for c: @constr_arg_use in desc.node.args {
@ -729,8 +729,8 @@ fn pred_args_matches(pattern: &[constr_arg_general_[inst]],
ret true; ret true;
} }
fn find_instance_(pattern: &[constr_arg_general_[inst]], fn find_instance_(pattern: &[constr_arg_general_<inst>],
descs: &[pred_args]) -> option::t[uint] { descs: &[pred_args]) -> option::t<uint> {
for d: pred_args in descs { for d: pred_args in descs {
if pred_args_matches(pattern, d) { ret some(d.node.bit_num); } if pred_args_matches(pattern, d) { ret some(d.node.bit_num); }
} }
@ -764,7 +764,7 @@ fn find_instances(fcx: &fn_ctxt, subst: &subst, c: &constraint) ->
rslt rslt
} }
fn find_in_subst(id: node_id, s: &subst) -> option::t[inst] { fn find_in_subst(id: node_id, s: &subst) -> option::t<inst> {
for p: {from: inst, to: inst} in s { for p: {from: inst, to: inst} in s {
if id == p.from.node { ret some(p.to); } if id == p.from.node { ret some(p.to); }
} }
@ -775,9 +775,9 @@ fn find_in_subst_bool(s: &subst, id: node_id) -> bool {
is_some(find_in_subst(id, s)) is_some(find_in_subst(id, s))
} }
fn insts_to_str(stuff: &[constr_arg_general_[inst]]) -> str { fn insts_to_str(stuff: &[constr_arg_general_<inst>]) -> str {
let rslt = "<"; let rslt = "<";
for i: constr_arg_general_[inst] in stuff { for i: constr_arg_general_<inst> in stuff {
rslt += rslt +=
" " + " " +
alt i { alt i {
@ -790,8 +790,8 @@ fn insts_to_str(stuff: &[constr_arg_general_[inst]]) -> str {
rslt rslt
} }
fn replace(subst: subst, d: pred_args) -> [constr_arg_general_[inst]] { fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>] {
let rslt: [constr_arg_general_[inst]] = ~[]; let rslt: [constr_arg_general_<inst>] = ~[];
for c: @constr_arg_use in d.node.args { for c: @constr_arg_use in d.node.args {
alt c.node { alt c.node {
carg_ident(p) { carg_ident(p) {
@ -808,7 +808,7 @@ fn replace(subst: subst, d: pred_args) -> [constr_arg_general_[inst]] {
} }
/* /*
for (constr_arg_general_[tup(ident, def_id)] p in rslt) { for (constr_arg_general_<tup(ident, def_id)> p in rslt) {
alt (p) { alt (p) {
case (carg_ident(?p)) { case (carg_ident(?p)) {
log_err p._0; log_err p._0;
@ -849,11 +849,11 @@ fn local_node_id_to_def_id_strict(fcx: &fn_ctxt, sp: &span, i: &node_id) ->
} }
} }
fn local_node_id_to_def(fcx: &fn_ctxt, i: &node_id) -> option::t[def] { fn local_node_id_to_def(fcx: &fn_ctxt, i: &node_id) -> option::t<def> {
fcx.ccx.tcx.def_map.find(i) fcx.ccx.tcx.def_map.find(i)
} }
fn local_node_id_to_def_id(fcx: &fn_ctxt, i: &node_id) -> option::t[def_id] { fn local_node_id_to_def_id(fcx: &fn_ctxt, i: &node_id) -> option::t<def_id> {
alt local_node_id_to_def(fcx, i) { alt local_node_id_to_def(fcx, i) {
some(def_local(d_id)) { some(d_id) } some(def_local(d_id)) { some(d_id) }
some(def_arg(a_id)) { some(a_id) } some(def_arg(a_id)) { some(a_id) }
@ -862,7 +862,7 @@ fn local_node_id_to_def_id(fcx: &fn_ctxt, i: &node_id) -> option::t[def_id] {
} }
fn local_node_id_to_local_def_id(fcx: &fn_ctxt, i: &node_id) -> fn local_node_id_to_local_def_id(fcx: &fn_ctxt, i: &node_id) ->
option::t[node_id] { option::t<node_id> {
alt local_node_id_to_def(fcx, i) { alt local_node_id_to_def(fcx, i) {
some(def_local(d_id)) { some(d_id.node) } some(def_local(d_id)) { some(d_id.node) }
some(def_arg(a_id)) { some(a_id.node) } some(def_arg(a_id)) { some(a_id.node) }
@ -1052,7 +1052,7 @@ fn op_to_oper_ty(io: init_op) -> oper_type {
// default function visitor // default function visitor
fn do_nothing[T](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, fn do_nothing[T](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident,
iid: node_id, cx: &T, v: &visit::vt[T]) { iid: node_id, cx: &T, v: &visit::vt<T>) {
} }
@ -1077,7 +1077,7 @@ fn ast_constr_to_sp_constr(tcx: &ty::ctxt, args: &[arg], c: &@constr) ->
ret respan(c.span, tconstr); ret respan(c.span, tconstr);
} }
type binding = {lhs: [inst], rhs: option::t[initializer]}; type binding = {lhs: [inst], rhs: option::t<initializer>};
fn local_to_bindings(loc : &@local) -> binding { fn local_to_bindings(loc : &@local) -> binding {
let lhs = ~[]; let lhs = ~[];

View file

@ -139,13 +139,13 @@ fn declare_var(fcx: &fn_ctxt, c: &tsconstr, pre: prestate) -> prestate {
} }
fn relax_precond_expr(e: &@expr, cx: &relax_ctxt, fn relax_precond_expr(e: &@expr, cx: &relax_ctxt,
vt: &visit::vt[relax_ctxt]) { vt: &visit::vt<relax_ctxt>) {
relax_precond(cx.i as uint, expr_precond(cx.fcx.ccx, e)); relax_precond(cx.i as uint, expr_precond(cx.fcx.ccx, e));
visit::visit_expr(e, cx, vt); visit::visit_expr(e, cx, vt);
} }
fn relax_precond_stmt(s: &@stmt, cx: &relax_ctxt, fn relax_precond_stmt(s: &@stmt, cx: &relax_ctxt,
vt: &visit::vt[relax_ctxt]) { vt: &visit::vt<relax_ctxt>) {
relax_precond(cx.i as uint, stmt_precond(cx.fcx.ccx, *s)); relax_precond(cx.i as uint, stmt_precond(cx.fcx.ccx, *s));
visit::visit_stmt(s, cx, vt); visit::visit_stmt(s, cx, vt);
} }
@ -153,7 +153,7 @@ fn relax_precond_stmt(s: &@stmt, cx: &relax_ctxt,
type relax_ctxt = {fcx:fn_ctxt, i:node_id}; type relax_ctxt = {fcx:fn_ctxt, i:node_id};
fn relax_precond_block_inner(b: &blk, cx: &relax_ctxt, fn relax_precond_block_inner(b: &blk, cx: &relax_ctxt,
vt: &visit::vt[relax_ctxt]) { vt: &visit::vt<relax_ctxt>) {
relax_precond(cx.i as uint, block_precond(cx.fcx.ccx, b)); relax_precond(cx.i as uint, block_precond(cx.fcx.ccx, b));
visit::visit_block(b, cx, vt); visit::visit_block(b, cx, vt);
} }
@ -166,7 +166,7 @@ fn relax_precond_block(fcx: &fn_ctxt, i: node_id, b:&blk) {
visit_expr: relax_precond_expr, visit_expr: relax_precond_expr,
visit_stmt: relax_precond_stmt, visit_stmt: relax_precond_stmt,
visit_item: (fn (i: &@item, cx: &relax_ctxt, visit_item: (fn (i: &@item, cx: &relax_ctxt,
vt: &visit::vt[relax_ctxt]) {}) vt: &visit::vt<relax_ctxt>) {})
with *visitor}; with *visitor};
let v1 = visit::mk_vt(visitor); let v1 = visit::mk_vt(visitor);
v1.visit_block(b, cx, v1); v1.visit_block(b, cx, v1);

View file

@ -61,7 +61,7 @@ fn check_unused_vars(fcx: &fn_ctxt) {
} }
} }
fn check_states_expr(e: &@expr, fcx: &fn_ctxt, v: &visit::vt[fn_ctxt]) { fn check_states_expr(e: &@expr, fcx: &fn_ctxt, v: &visit::vt<fn_ctxt>) {
visit::visit_expr(e, fcx, v); visit::visit_expr(e, fcx, v);
let prec: precond = expr_precond(fcx.ccx, e); let prec: precond = expr_precond(fcx.ccx, e);
@ -92,7 +92,7 @@ fn check_states_expr(e: &@expr, fcx: &fn_ctxt, v: &visit::vt[fn_ctxt]) {
} }
} }
fn check_states_stmt(s: &@stmt, fcx: &fn_ctxt, v: &visit::vt[fn_ctxt]) { fn check_states_stmt(s: &@stmt, fcx: &fn_ctxt, v: &visit::vt<fn_ctxt>) {
visit::visit_stmt(s, fcx, v); visit::visit_stmt(s, fcx, v);
let a = stmt_to_ann(fcx.ccx, *s); let a = stmt_to_ann(fcx.ccx, *s);
@ -184,7 +184,7 @@ fn check_fn_states(fcx: &fn_ctxt, f: &_fn, tps: &[ast::ty_param], id: node_id,
} }
fn fn_states(f: &_fn, tps: &[ast::ty_param], sp: &span, i: &fn_ident, fn fn_states(f: &_fn, tps: &[ast::ty_param], sp: &span, i: &fn_ident,
id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) { id: node_id, ccx: &crate_ctxt, v: &visit::vt<crate_ctxt>) {
visit::visit_fn(f, tps, sp, i, id, ccx, v); visit::visit_fn(f, tps, sp, i, id, ccx, v);
/* Look up the var-to-bit-num map for this function */ /* Look up the var-to-bit-num map for this function */

View file

@ -13,7 +13,7 @@ import syntax::ast::respan;
type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt}; type ctxt = {cs: @mutable [sp_constr], tcx: ty::ctxt};
fn collect_local(loc: &@local, cx: &ctxt, v: &visit::vt[ctxt]) { fn collect_local(loc: &@local, cx: &ctxt, v: &visit::vt<ctxt>) {
for each p: @pat in pat_bindings(loc.node.pat) { for each p: @pat in pat_bindings(loc.node.pat) {
let ident = alt p.node { pat_bind(id) { id } }; let ident = alt p.node { pat_bind(id) { id } };
log "collect_local: pushing " + ident; log "collect_local: pushing " + ident;
@ -22,7 +22,7 @@ fn collect_local(loc: &@local, cx: &ctxt, v: &visit::vt[ctxt]) {
visit::visit_local(loc, cx, v); visit::visit_local(loc, cx, v);
} }
fn collect_pred(e: &@expr, cx: &ctxt, v: &visit::vt[ctxt]) { fn collect_pred(e: &@expr, cx: &ctxt, v: &visit::vt<ctxt>) {
alt e.node { alt e.node {
expr_check(_, ch) { *cx.cs += ~[expr_to_constr(cx.tcx, ch)]; } expr_check(_, ch) { *cx.cs += ~[expr_to_constr(cx.tcx, ch)]; }
expr_if_check(ex, _, _) { *cx.cs += ~[expr_to_constr(cx.tcx, ex)]; } expr_if_check(ex, _, _) { *cx.cs += ~[expr_to_constr(cx.tcx, ex)]; }

View file

@ -157,7 +157,7 @@ fn find_pre_post_loop(fcx: &fn_ctxt, l: &@local, index: &@expr, body: &blk,
// annotation for an if-expression with consequent conseq // annotation for an if-expression with consequent conseq
// and alternative maybe_alt // and alternative maybe_alt
fn join_then_else(fcx: &fn_ctxt, antec: &@expr, conseq: &blk, fn join_then_else(fcx: &fn_ctxt, antec: &@expr, conseq: &blk,
maybe_alt: &option::t[@expr], id: node_id, chck: &if_ty) { maybe_alt: &option::t<@expr>, id: node_id, chck: &if_ty) {
find_pre_post_expr(fcx, antec); find_pre_post_expr(fcx, antec);
find_pre_post_block(fcx, conseq); find_pre_post_block(fcx, conseq);
alt maybe_alt { alt maybe_alt {
@ -553,7 +553,7 @@ fn find_pre_post_expr(fcx: &fn_ctxt, e: @expr) {
let cmodes = callee_modes(fcx, operator.id); let cmodes = callee_modes(fcx, operator.id);
let modes = ~[]; let modes = ~[];
let i = 0; let i = 0;
for expr_opt: option::t[@expr] in maybe_args { for expr_opt: option::t<@expr> in maybe_args {
alt expr_opt { alt expr_opt {
none. {/* no-op */ } none. {/* no-op */ }
some(expr) { some(expr) {
@ -723,7 +723,7 @@ fn find_pre_post_fn(fcx: &fn_ctxt, f: &_fn) {
} }
fn fn_pre_post(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident, fn fn_pre_post(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident,
id: node_id, ccx: &crate_ctxt, v: &visit::vt[crate_ctxt]) { id: node_id, ccx: &crate_ctxt, v: &visit::vt<crate_ctxt>) {
visit::visit_fn(f, tps, sp, i, id, ccx, v); visit::visit_fn(f, tps, sp, i, id, ccx, v);
assert (ccx.fm.contains_key(id)); assert (ccx.fm.contains_key(id));
let fcx = let fcx =

View file

@ -84,7 +84,7 @@ fn seq_states(fcx: &fn_ctxt, pres: &prestate, bindings: &[binding])
} }
fn find_pre_post_state_sub(fcx: &fn_ctxt, pres: &prestate, e: &@expr, fn find_pre_post_state_sub(fcx: &fn_ctxt, pres: &prestate, e: &@expr,
parent: node_id, c: option::t[tsconstr]) -> bool { parent: node_id, c: option::t<tsconstr>) -> bool {
let changed = find_pre_post_state_expr(fcx, pres, e); let changed = find_pre_post_state_expr(fcx, pres, e);
changed = set_prestate_ann(fcx.ccx, parent, pres) || changed; changed = set_prestate_ann(fcx.ccx, parent, pres) || changed;
@ -238,7 +238,7 @@ fn gen_if_local(fcx: &fn_ctxt, p: &poststate, e: &@expr) -> bool {
} }
fn join_then_else(fcx: &fn_ctxt, antec: &@expr, conseq: &blk, fn join_then_else(fcx: &fn_ctxt, antec: &@expr, conseq: &blk,
maybe_alt: &option::t[@expr], id: node_id, chk: &if_ty, maybe_alt: &option::t<@expr>, id: node_id, chk: &if_ty,
pres: &prestate) -> bool { pres: &prestate) -> bool {
let changed = let changed =
set_prestate_ann(fcx.ccx, id, pres) | set_prestate_ann(fcx.ccx, id, pres) |
@ -328,7 +328,7 @@ fn find_pre_post_state_expr(fcx: &fn_ctxt, pres: &prestate, e: @expr) ->
let callee_ops = callee_arg_init_ops(fcx, operator.id); let callee_ops = callee_arg_init_ops(fcx, operator.id);
let ops = ~[]; let ops = ~[];
let i = 0; let i = 0;
for a_opt: option::t[@expr] in maybe_args { for a_opt: option::t<@expr> in maybe_args {
alt a_opt { alt a_opt {
none. {/* no-op */ } none. {/* no-op */ }
some(a) { some(a) {

View file

@ -199,14 +199,14 @@ type method =
cf: controlflow, cf: controlflow,
constrs: [@constr]}; constrs: [@constr]};
type constr_table = hashmap[ast::node_id, [constr]]; type constr_table = hashmap<ast::node_id, [constr]>;
type mt = {ty: t, mut: ast::mutability}; type mt = {ty: t, mut: ast::mutability};
// Contains information needed to resolve types and (in the future) look up // Contains information needed to resolve types and (in the future) look up
// the types of AST nodes. // the types of AST nodes.
type creader_cache = hashmap[{cnum: int, pos: uint, len: uint}, ty::t]; type creader_cache = hashmap<{cnum: int, pos: uint, len: uint}, ty::t>;
type ctxt = type ctxt =
@ -219,11 +219,11 @@ type ctxt =
freevars: freevars::freevar_map, freevars: freevars::freevar_map,
tcache: type_cache, tcache: type_cache,
rcache: creader_cache, rcache: creader_cache,
short_names_cache: hashmap[t, str], short_names_cache: hashmap<t, str>,
has_pointer_cache: hashmap[t, bool], has_pointer_cache: hashmap<t, bool>,
kind_cache: hashmap[t, ast::kind], kind_cache: hashmap<t, ast::kind>,
owns_heap_mem_cache: hashmap[t, bool], owns_heap_mem_cache: hashmap<t, bool>,
ast_ty_to_ty_cache: hashmap[@ast::ty, option::t[t]]}; ast_ty_to_ty_cache: hashmap<@ast::ty, option::t<t>>};
type ty_ctxt = ctxt; type ty_ctxt = ctxt;
@ -239,7 +239,7 @@ fn method_ty_to_fn_ty(cx: &ctxt, m: method) -> t {
// Never construct these manually. These are interned. // Never construct these manually. These are interned.
type raw_t = type raw_t =
{struct: sty, {struct: sty,
cname: option::t[str], cname: option::t<str>,
hash: uint, hash: uint,
has_params: bool, has_params: bool,
has_vars: bool}; has_vars: bool};
@ -284,9 +284,9 @@ tag sty {
// In the middle end, constraints have a def_id attached, referring // In the middle end, constraints have a def_id attached, referring
// to the definition of the operator in the constraint. // to the definition of the operator in the constraint.
type constr_general[ARG] = spanned[constr_general_[ARG, def_id]]; type constr_general[ARG] = spanned<constr_general_<ARG, def_id>>;
type type_constr = constr_general[path]; type type_constr = constr_general<path>;
type constr = constr_general[uint]; type constr = constr_general<uint>;
// Data structures used in type unification // Data structures used in type unification
tag type_err { tag type_err {
@ -308,7 +308,7 @@ tag type_err {
type ty_param_kinds_and_ty = {kinds: [ast::kind], ty: t}; type ty_param_kinds_and_ty = {kinds: [ast::kind], ty: t};
type type_cache = hashmap[ast::def_id, ty_param_kinds_and_ty]; type type_cache = hashmap<ast::def_id, ty_param_kinds_and_ty>;
const idx_nil: uint = 0u; const idx_nil: uint = 0u;
@ -352,12 +352,12 @@ const idx_bot: uint = 19u;
const idx_first_others: uint = 20u; const idx_first_others: uint = 20u;
type type_store = interner::interner[@raw_t]; type type_store = interner::interner<@raw_t>;
type ty_param_substs_opt_and_ty = {substs: option::t[[ty::t]], ty: ty::t}; type ty_param_substs_opt_and_ty = {substs: option::t<[ty::t]>, ty: ty::t};
type node_type_table = type node_type_table =
@smallintmap::smallintmap[ty::ty_param_substs_opt_and_ty]; @smallintmap::smallintmap<ty::ty_param_substs_opt_and_ty>;
fn populate_type_store(cx: &ctxt) { fn populate_type_store(cx: &ctxt) {
intern(cx, ty_nil, none); intern(cx, ty_nil, none);
@ -421,7 +421,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
// Type constructors // Type constructors
fn mk_raw_ty(cx: &ctxt, st: &sty, in_cname: &option::t[str]) -> @raw_t { fn mk_raw_ty(cx: &ctxt, st: &sty, in_cname: &option::t<str>) -> @raw_t {
let cname = none; let cname = none;
let h = hash_type_info(st, cname); let h = hash_type_info(st, cname);
let has_params: bool = false; let has_params: bool = false;
@ -502,11 +502,11 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, in_cname: &option::t[str]) -> @raw_t {
has_vars: has_vars}; has_vars: has_vars};
} }
fn intern(cx: &ctxt, st: &sty, cname: &option::t[str]) { fn intern(cx: &ctxt, st: &sty, cname: &option::t<str>) {
interner::intern(*cx.ts, mk_raw_ty(cx, st, cname)); interner::intern(*cx.ts, mk_raw_ty(cx, st, cname));
} }
fn gen_ty_full(cx: &ctxt, st: &sty, cname: &option::t[str]) -> t { fn gen_ty_full(cx: &ctxt, st: &sty, cname: &option::t<str>) -> t {
let raw_type = mk_raw_ty(cx, st, cname); let raw_type = mk_raw_ty(cx, st, cname);
ret interner::intern(*cx.ts, raw_type); ret interner::intern(*cx.ts, raw_type);
} }
@ -621,7 +621,7 @@ fn struct(cx: &ctxt, typ: &t) -> sty {
// Returns the canonical name of the given type. // Returns the canonical name of the given type.
fn cname(cx: &ctxt, typ: &t) -> option::t[str] { fn cname(cx: &ctxt, typ: &t) -> option::t<str> {
ret interner::get(*cx.ts, typ).cname; ret interner::get(*cx.ts, typ).cname;
} }
@ -1363,7 +1363,7 @@ fn type_is_pod(cx : &ctxt, ty : &t) -> bool {
ret result; ret result;
} }
fn type_param(cx: &ctxt, ty: &t) -> option::t[uint] { fn type_param(cx: &ctxt, ty: &t) -> option::t<uint> {
alt struct(cx, ty) { alt struct(cx, ty) {
ty_param(id,_) { ret some(id); } ty_param(id,_) { ret some(id); }
_ {/* fall through */ } _ {/* fall through */ }
@ -1536,7 +1536,7 @@ fn hash_type_structure(st: &sty) -> uint {
} }
} }
fn hash_type_info(st: &sty, cname_opt: &option::t[str]) -> uint { fn hash_type_info(st: &sty, cname_opt: &option::t<str>) -> uint {
let h = hash_type_structure(st); let h = hash_type_structure(st);
alt cname_opt { alt cname_opt {
none. {/* no-op */ } none. {/* no-op */ }
@ -1554,8 +1554,8 @@ fn hash_ty(typ: &t) -> uint { ret typ; }
// users should use `eq_ty()` instead. // users should use `eq_ty()` instead.
fn eq_int(x: &uint, y: &uint) -> bool { ret x == y; } fn eq_int(x: &uint, y: &uint) -> bool { ret x == y; }
fn arg_eq[T](eq: &fn(&T, &T) -> bool , a: @sp_constr_arg[T], fn arg_eq[T](eq: &fn(&T, &T) -> bool , a: @sp_constr_arg<T>,
b: @sp_constr_arg[T]) -> bool { b: @sp_constr_arg<T>) -> bool {
alt a.node { alt a.node {
ast::carg_base. { ast::carg_base. {
alt b.node { ast::carg_base. { ret true; } _ { ret false; } } alt b.node { ast::carg_base. { ret true; } _ { ret false; } }
@ -1569,10 +1569,10 @@ fn arg_eq[T](eq: &fn(&T, &T) -> bool , a: @sp_constr_arg[T],
} }
} }
fn args_eq[T](eq: fn(&T, &T) -> bool , a: &[@sp_constr_arg[T]], fn args_eq[T](eq: fn(&T, &T) -> bool , a: &[@sp_constr_arg<T>],
b: &[@sp_constr_arg[T]]) -> bool { b: &[@sp_constr_arg<T>]) -> bool {
let i: uint = 0u; let i: uint = 0u;
for arg: @sp_constr_arg[T] in a { for arg: @sp_constr_arg<T> in a {
if !arg_eq(eq, arg, b.(i)) { ret false; } if !arg_eq(eq, arg, b.(i)) { ret false; }
i += 1u; i += 1u;
} }
@ -2008,7 +2008,7 @@ fn is_lval(expr: &@ast::expr) -> bool {
} }
} }
fn occurs_check_fails(tcx: &ctxt, sp: &option::t[span], vid: int, rt: &t) fn occurs_check_fails(tcx: &ctxt, sp: &option::t<span>, vid: int, rt: &t)
-> bool { -> bool {
if (!type_contains_vars(tcx, rt)) { if (!type_contains_vars(tcx, rt)) {
// Fast path // Fast path
@ -2066,7 +2066,7 @@ mod unify {
} }
type var_bindings = type var_bindings =
{sets: ufind::ufind, types: smallintmap::smallintmap[t]}; {sets: ufind::ufind, types: smallintmap::smallintmap<t>};
type ctxt = {vb: @var_bindings, tcx: ty_ctxt}; type ctxt = {vb: @var_bindings, tcx: ty_ctxt};
@ -2198,7 +2198,7 @@ mod unify {
// Unifies two mutability flags. // Unifies two mutability flags.
fn unify_mut(expected: ast::mutability, actual: ast::mutability) -> fn unify_mut(expected: ast::mutability, actual: ast::mutability) ->
option::t[ast::mutability] { option::t<ast::mutability> {
if expected == actual { ret some(expected); } if expected == actual { ret some(expected); }
if expected == ast::maybe_mut { ret some(actual); } if expected == ast::maybe_mut { ret some(actual); }
if actual == ast::maybe_mut { ret some(expected); } if actual == ast::maybe_mut { ret some(expected); }
@ -2736,7 +2736,7 @@ mod unify {
while i < vec::len[ufind::node](vb.sets.nodes) { while i < vec::len[ufind::node](vb.sets.nodes) {
let sets = ""; let sets = "";
let j = 0u; let j = 0u;
while j < vec::len[option::t[uint]](vb.sets.nodes) { while j < vec::len[option::t<uint>](vb.sets.nodes) {
if ufind::find(vb.sets, j) == i { if ufind::find(vb.sets, j) == i {
sets += #fmt(" %u", j); sets += #fmt(" %u", j);
} }
@ -2756,10 +2756,10 @@ mod unify {
// Takes an optional span - complain about occurs check violations // Takes an optional span - complain about occurs check violations
// iff the span is present (so that if we already know we're going // iff the span is present (so that if we already know we're going
// to error anyway, we don't complain) // to error anyway, we don't complain)
fn fixup_vars(tcx: ty_ctxt, sp: &option::t[span], fn fixup_vars(tcx: ty_ctxt, sp: &option::t<span>,
vb: @var_bindings, typ: t) -> fixup_result { vb: @var_bindings, typ: t) -> fixup_result {
fn subst_vars(tcx: ty_ctxt, sp: &option::t[span], vb: @var_bindings, fn subst_vars(tcx: ty_ctxt, sp: &option::t<span>, vb: @var_bindings,
unresolved: @mutable option::t[int], vid: int) -> t { unresolved: @mutable option::t<int>, vid: int) -> t {
// Should really return a fixup_result instead of a t, but fold_ty // Should really return a fixup_result instead of a t, but fold_ty
// doesn't allow returning anything but a t. // doesn't allow returning anything but a t.
if vid as uint >= ufind::set_count(vb.sets) { if vid as uint >= ufind::set_count(vb.sets) {
@ -2789,7 +2789,7 @@ mod unify {
some(var_id) { ret fix_err(var_id); } some(var_id) { ret fix_err(var_id); }
} }
} }
fn resolve_type_var(tcx: &ty_ctxt, sp: &option::t[span], fn resolve_type_var(tcx: &ty_ctxt, sp: &option::t<span>,
vb: &@var_bindings, vid: int) -> vb: &@var_bindings, vid: int) ->
fixup_result { fixup_result {
if vid as uint >= ufind::set_count(vb.sets) { ret fix_err(vid); } if vid as uint >= ufind::set_count(vb.sets) { ret fix_err(vid); }
@ -3090,8 +3090,8 @@ fn is_binopable(cx: &ctxt, ty: t, op: ast::binop) -> bool {
ret tbl.(tycat(cx, ty)).(opcat(op)); ret tbl.(tycat(cx, ty)).(opcat(op));
} }
fn ast_constr_to_constr[T](tcx: ty::ctxt, c: &@ast::constr_general[T]) -> fn ast_constr_to_constr[T](tcx: ty::ctxt, c: &@ast::constr_general<T>) ->
@ty::constr_general[T] { @ty::constr_general<T> {
alt tcx.def_map.find(c.node.id) { 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 @respan(c.span, ret @respan(c.span,

View file

@ -49,7 +49,7 @@ import syntax::print::pprust::*;
export check_crate; export check_crate;
type ty_table = hashmap[ast::def_id, ty::t]; type ty_table = hashmap<ast::def_id, ty::t>;
// Used for typechecking the methods of an object. // Used for typechecking the methods of an object.
tag obj_info { tag obj_info {
@ -57,7 +57,7 @@ tag obj_info {
regular_obj([ast::obj_field], ast::node_id); regular_obj([ast::obj_field], ast::node_id);
// Anonymous objects only have a type at compile time. It's optional // Anonymous objects only have a type at compile time. It's optional
// because not all anonymous objects have a inner_obj to attach to. // because not all anonymous objects have a inner_obj to attach to.
anon_obj([ast::obj_field], option::t[ty::sty]); anon_obj([ast::obj_field], option::t<ty::sty>);
} }
type crate_ctxt = {mutable obj_infos: [obj_info], tcx: ty::ctxt}; type crate_ctxt = {mutable obj_infos: [obj_info], tcx: ty::ctxt};
@ -70,8 +70,8 @@ type fn_ctxt =
purity: ast::purity, purity: ast::purity,
proto: ast::proto, proto: ast::proto,
var_bindings: @ty::unify::var_bindings, var_bindings: @ty::unify::var_bindings,
locals: hashmap[ast::node_id, int], locals: hashmap<ast::node_id, int>,
local_names: hashmap[ast::node_id, ast::ident], local_names: hashmap<ast::node_id, ast::ident>,
next_var_id: @mutable int, next_var_id: @mutable int,
mutable fixups: [ast::node_id], mutable fixups: [ast::node_id],
ccx: @crate_ctxt}; ccx: @crate_ctxt};
@ -235,7 +235,7 @@ fn structure_of(fcx: &@fn_ctxt, sp: &span, typ: ty::t) -> ty::sty {
// Returns the one-level-deep structure of the given type or none if it // Returns the one-level-deep structure of the given type or none if it
// is not known yet. // is not known yet.
fn structure_of_maybe(fcx: &@fn_ctxt, sp: &span, typ: ty::t) -> fn structure_of_maybe(fcx: &@fn_ctxt, sp: &span, typ: ty::t) ->
option::t[ty::sty] { option::t<ty::sty> {
let r = let r =
ty::unify::resolve_type_structure(fcx.ccx.tcx, fcx.var_bindings, typ); ty::unify::resolve_type_structure(fcx.ccx.tcx, fcx.var_bindings, typ);
ret alt r { ret alt r {
@ -433,7 +433,7 @@ fn ast_ty_to_ty_crate(ccx: @crate_ctxt, ast_ty: &@ast::ty) -> ty::t {
// A wrapper around ast_ty_to_ty_crate that handles ty_infer. // A wrapper around ast_ty_to_ty_crate that handles ty_infer.
fn ast_ty_to_ty_crate_infer(ccx: @crate_ctxt, ast_ty: &@ast::ty) fn ast_ty_to_ty_crate_infer(ccx: @crate_ctxt, ast_ty: &@ast::ty)
-> option::t[ty::t] { -> option::t<ty::t> {
alt ast_ty.node { alt ast_ty.node {
ast::ty_infer. { none } ast::ty_infer. { none }
_ { some(ast_ty_to_ty_crate(ccx, ast_ty)) } _ { some(ast_ty_to_ty_crate(ccx, ast_ty)) }
@ -544,7 +544,7 @@ mod collect {
fn ty_of_fn_decl(cx: &@ctxt, convert: &fn(&@ast::ty) -> ty::t , fn ty_of_fn_decl(cx: &@ctxt, convert: &fn(&@ast::ty) -> ty::t ,
ty_of_arg: &fn(&ast::arg) -> arg , decl: &ast::fn_decl, ty_of_arg: &fn(&ast::arg) -> arg , decl: &ast::fn_decl,
proto: ast::proto, ty_params: &[ast::ty_param], proto: ast::proto, ty_params: &[ast::ty_param],
def_id: &option::t[ast::def_id]) -> def_id: &option::t<ast::def_id>) ->
ty::ty_param_kinds_and_ty { ty::ty_param_kinds_and_ty {
let input_tys = ~[]; let input_tys = ~[];
for a: ast::arg in decl.inputs { input_tys += ~[ty_of_arg(a)]; } for a: ast::arg in decl.inputs { input_tys += ~[ty_of_arg(a)]; }
@ -775,7 +775,7 @@ mod collect {
} }
ret meths; ret meths;
} }
fn convert(cx: @ctxt, abi: @mutable option::t[ast::native_abi], fn convert(cx: @ctxt, abi: @mutable option::t<ast::native_abi>,
it: &@ast::item) { it: &@ast::item) {
alt it.node { alt it.node {
ast::item_mod(_) { ast::item_mod(_) {
@ -850,7 +850,7 @@ mod collect {
} }
} }
} }
fn convert_native(cx: @ctxt, abi: @mutable option::t[ast::native_abi], fn convert_native(cx: @ctxt, abi: @mutable option::t<ast::native_abi>,
i: &@ast::native_item) { i: &@ast::native_item) {
// As above, this call populates the type table with the converted // As above, this call populates the type table with the converted
// type of the native item. We simply write it into the node type // type of the native item. We simply write it into the node type
@ -1077,7 +1077,7 @@ mod writeback {
export resolve_type_vars_in_expr; export resolve_type_vars_in_expr;
fn resolve_type_vars_in_type(fcx: &@fn_ctxt, sp: &span, typ: ty::t) -> fn resolve_type_vars_in_type(fcx: &@fn_ctxt, sp: &span, typ: ty::t) ->
option::t[ty::t] { option::t<ty::t> {
if !ty::type_contains_vars(fcx.ccx.tcx, typ) { ret some(typ); } if !ty::type_contains_vars(fcx.ccx.tcx, typ) { ret some(typ); }
alt ty::unify::fixup_vars(fcx.ccx.tcx, some(sp), alt ty::unify::fixup_vars(fcx.ccx.tcx, some(sp),
fcx.var_bindings, typ) { fcx.var_bindings, typ) {
@ -1120,7 +1120,7 @@ mod writeback {
// As soon as we hit an error we have to stop resolving // As soon as we hit an error we have to stop resolving
// the entire function // the entire function
{fcx: @fn_ctxt, mutable success: bool}; {fcx: @fn_ctxt, mutable success: bool};
type wb_vt = visit::vt[wb_ctxt]; type wb_vt = visit::vt<wb_ctxt>;
fn visit_stmt(s: &@ast::stmt, wbcx: &wb_ctxt, v: &wb_vt) { fn visit_stmt(s: &@ast::stmt, wbcx: &wb_ctxt, v: &wb_vt) {
if !wbcx.success { ret; } if !wbcx.success { ret; }
@ -1197,13 +1197,13 @@ mod writeback {
// for them before typechecking the function. // for them before typechecking the function.
type gather_result = type gather_result =
{var_bindings: @ty::unify::var_bindings, {var_bindings: @ty::unify::var_bindings,
locals: hashmap[ast::node_id, int], locals: hashmap<ast::node_id, int>,
local_names: hashmap[ast::node_id, ast::ident], local_names: hashmap<ast::node_id, ast::ident>,
next_var_id: @mutable int}; next_var_id: @mutable int};
// Used only as a helper for check_fn. // Used only as a helper for check_fn.
fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id, fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
old_fcx: &option::t[@fn_ctxt]) -> gather_result { old_fcx: &option::t<@fn_ctxt>) -> gather_result {
let {vb, locals, local_names, nvi} = alt old_fcx { let {vb, locals, local_names, nvi} = alt old_fcx {
none. { none. {
{ vb: ty::unify::mk_var_bindings(), { vb: ty::unify::mk_var_bindings(),
@ -1226,7 +1226,7 @@ fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
ret rv; ret rv;
}; };
let assign = lambda(nid: ast::node_id, ident: &ast::ident, let assign = lambda(nid: ast::node_id, ident: &ast::ident,
ty_opt: option::t[ty::t]) { ty_opt: option::t<ty::t>) {
let var_id = next_var_id(); let var_id = next_var_id();
locals.insert(nid, var_id); locals.insert(nid, var_id);
local_names.insert(nid, ident); local_names.insert(nid, ident);
@ -1263,14 +1263,14 @@ fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
} }
// Add explicitly-declared locals. // Add explicitly-declared locals.
let visit_local = lambda(local: &@ast::local, e: &(), v: &visit::vt[()]) { let visit_local = lambda(local: &@ast::local, e: &(), v: &visit::vt<()>) {
let local_ty = ast_ty_to_ty_crate_infer(ccx, local.node.ty); let local_ty = ast_ty_to_ty_crate_infer(ccx, local.node.ty);
assign(local.node.id, ident_for_local(local), local_ty); assign(local.node.id, ident_for_local(local), local_ty);
visit::visit_local(local, e, v); visit::visit_local(local, e, v);
}; };
// Add pattern bindings. // Add pattern bindings.
let visit_pat = lambda(p: &@ast::pat, e: &(), v: &visit::vt[()]) { let visit_pat = lambda(p: &@ast::pat, e: &(), v: &visit::vt<()>) {
alt p.node { alt p.node {
ast::pat_bind(ident) { ast::pat_bind(ident) {
assign(p.id, ident, none); assign(p.id, ident, none);
@ -1283,8 +1283,8 @@ fn gather_locals(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
// Don't descend into fns and items // Don't descend into fns and items
fn visit_fn[E](f: &ast::_fn, tp: &[ast::ty_param], sp: &span, fn visit_fn[E](f: &ast::_fn, tp: &[ast::ty_param], sp: &span,
i: &ast::fn_ident, id: ast::node_id, e: &E, i: &ast::fn_ident, id: ast::node_id, e: &E,
v: &visit::vt[E]) { } v: &visit::vt<E>) { }
fn visit_item[E](i: &@ast::item, e: &E, v: &visit::vt[E]) { } fn visit_item[E](i: &@ast::item, e: &E, v: &visit::vt<E>) { }
let visit = let visit =
@{visit_local: visit_local, @{visit_local: visit_local,
@ -1538,7 +1538,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
// A generic function to factor out common logic from call and bind // A generic function to factor out common logic from call and bind
// expressions. // expressions.
fn check_call_or_bind(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr, fn check_call_or_bind(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr,
args: &[option::t[@ast::expr]], args: &[option::t<@ast::expr>],
call_kind: call_kind) -> bool { call_kind: call_kind) -> bool {
// Check the function. // Check the function.
let bot = check_expr(fcx, f); let bot = check_expr(fcx, f);
@ -1587,7 +1587,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
// Check that the correct number of arguments were supplied. // Check that the correct number of arguments were supplied.
let expected_arg_count = vec::len[ty::arg](arg_tys); let expected_arg_count = vec::len[ty::arg](arg_tys);
let supplied_arg_count = vec::len[option::t[@ast::expr]](args); let supplied_arg_count = vec::len[option::t<@ast::expr>](args);
if expected_arg_count != supplied_arg_count { if expected_arg_count != supplied_arg_count {
fcx.ccx.tcx.sess.span_fatal(sp, fcx.ccx.tcx.sess.span_fatal(sp,
#fmt("this function takes %u \ #fmt("this function takes %u \
@ -1612,7 +1612,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
let check_args = lambda(check_blocks: bool) -> bool { let check_args = lambda(check_blocks: bool) -> bool {
let i = 0u; let i = 0u;
let bot = false; let bot = false;
for a_opt: option::t[@ast::expr] in args { for a_opt: option::t<@ast::expr> in args {
alt a_opt { alt a_opt {
some(a) { some(a) {
let is_block = let is_block =
@ -1647,7 +1647,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
// A generic function for checking call expressions // A generic function for checking call expressions
fn check_call(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr, fn check_call(fcx: &@fn_ctxt, sp: &span, f: &@ast::expr,
args: &[@ast::expr], call_kind: call_kind) -> bool { args: &[@ast::expr], call_kind: call_kind) -> bool {
let args_opt_0: [option::t[@ast::expr]] = ~[]; let args_opt_0: [option::t<@ast::expr>] = ~[];
for arg: @ast::expr in args { for arg: @ast::expr in args {
args_opt_0 += ~[some[@ast::expr](arg)]; args_opt_0 += ~[some[@ast::expr](arg)];
} }
@ -1745,7 +1745,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
// A generic function for checking the then and else in an if // A generic function for checking the then and else in an if
// or if-check // or if-check
fn check_then_else(fcx: &@fn_ctxt, thn: &ast::blk, fn check_then_else(fcx: &@fn_ctxt, thn: &ast::blk,
elsopt: &option::t[@ast::expr], id: ast::node_id, elsopt: &option::t<@ast::expr>, id: ast::node_id,
sp: &span) -> bool { sp: &span) -> bool {
let then_bot = check_block(fcx, thn); let then_bot = check_block(fcx, thn);
let els_bot = false; let els_bot = false;
@ -2093,7 +2093,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
// For each blank argument, add the type of that argument // For each blank argument, add the type of that argument
// to the resulting function type. // to the resulting function type.
let i = 0u; let i = 0u;
while i < vec::len[option::t[@ast::expr]](args) { while i < vec::len[option::t<@ast::expr>](args) {
alt args.(i) { alt args.(i) {
some(_) {/* no-op */ } some(_) {/* no-op */ }
none. { arg_tys_1 += ~[arg_tys.(i)]; } none. { arg_tys_1 += ~[arg_tys.(i)]; }
@ -2113,9 +2113,9 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
} }
ast::expr_self_method(ident) { ast::expr_self_method(ident) {
let t = ty::mk_nil(tcx); let t = ty::mk_nil(tcx);
let this_obj_sty: option::t[ty::sty] = let this_obj_sty: option::t<ty::sty> =
some(structure_of(fcx, expr.span, ty::mk_nil(tcx))); some(structure_of(fcx, expr.span, ty::mk_nil(tcx)));
let this_obj_info: option::t[obj_info] = get_obj_info(fcx.ccx); let this_obj_info: option::t<obj_info> = get_obj_info(fcx.ccx);
alt this_obj_info { alt this_obj_info {
some(oinfo) { some(oinfo) {
alt oinfo { alt oinfo {
@ -2205,7 +2205,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
} }
ast::expr_rec(fields, base) { 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]] = ~[]; let fields_t: [spanned<field>] = ~[];
for f: ast::field in fields { for f: ast::field in fields {
bot |= check_expr(fcx, f.node.expr); bot |= check_expr(fcx, f.node.expr);
let expr_t = expr_ty(tcx, f.node.expr); let expr_t = expr_ty(tcx, f.node.expr);
@ -2218,7 +2218,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
} }
alt base { alt base {
none. { none. {
fn get_node(f: &spanned[field]) -> field { f.node } fn get_node(f: &spanned<field>) -> field { f.node }
let typ = ty::mk_rec(tcx, vec::map(get_node, fields_t)); let typ = ty::mk_rec(tcx, vec::map(get_node, fields_t));
write::ty_only_fixup(fcx, id, typ); write::ty_only_fixup(fcx, id, typ);
} }
@ -2234,7 +2234,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
} }
} }
write::ty_only_fixup(fcx, id, bexpr_t); write::ty_only_fixup(fcx, id, bexpr_t);
for f: spanned[ty::field] in fields_t { for f: spanned<ty::field> in fields_t {
let found = false; let found = false;
for bf: ty::field in base_fields { for bf: ty::field in base_fields {
if str::eq(f.node.ident, bf.ident) { if str::eq(f.node.ident, bf.ident) {
@ -2362,7 +2362,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
// type. // type.
let inner_obj_methods: [ty::method] = ~[]; let inner_obj_methods: [ty::method] = ~[];
let inner_obj_ty: ty::t = ty::mk_nil(tcx); let inner_obj_ty: ty::t = ty::mk_nil(tcx);
let inner_obj_sty: option::t[ty::sty] = none; let inner_obj_sty: option::t<ty::sty> = none;
alt ao.inner_obj { alt ao.inner_obj {
none. { } none. { }
some(e) { some(e) {
@ -2399,7 +2399,7 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
fn filtering_fn(ccx: @crate_ctxt, fn filtering_fn(ccx: @crate_ctxt,
m: &ty::method, m: &ty::method,
outer_obj_methods: [@ast::method]) -> outer_obj_methods: [@ast::method]) ->
option::t[ty::method] { option::t<ty::method> {
for om: @ast::method in outer_obj_methods { for om: @ast::method in outer_obj_methods {
if str::eq(om.node.ident, m.ident) { if str::eq(om.node.ident, m.ident) {
@ -2473,7 +2473,7 @@ fn next_ty_var(fcx: &@fn_ctxt) -> ty::t {
ret ty::mk_var(fcx.ccx.tcx, next_ty_var_id(fcx)); ret ty::mk_var(fcx.ccx.tcx, next_ty_var_id(fcx));
} }
fn get_obj_info(ccx: &@crate_ctxt) -> option::t[obj_info] { fn get_obj_info(ccx: &@crate_ctxt) -> option::t<obj_info> {
ret vec::last[obj_info](ccx.obj_infos); ret vec::last[obj_info](ccx.obj_infos);
} }
@ -2578,7 +2578,7 @@ fn check_const(ccx: &@crate_ctxt, sp: &span, e: &@ast::expr,
} }
fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id, fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
old_fcx: &option::t[@fn_ctxt]) { old_fcx: &option::t<@fn_ctxt>) {
let decl = f.decl; let decl = f.decl;
let body = f.body; let body = f.body;
let gather_result = gather_locals(ccx, f, id, old_fcx); let gather_result = gather_locals(ccx, f, id, old_fcx);

View file

@ -6,7 +6,7 @@ import codemap::span;
import codemap::filename; import codemap::filename;
type spanned[T] = {node: T, span: span}; type spanned[T] = {node: T, span: span};
fn respan[T](sp: &span, t: &T) -> spanned[T] { ret {node: t, span: sp}; } fn respan[T](sp: &span, t: &T) -> spanned<T> { ret {node: t, span: sp}; }
/* assuming that we're not in macro expansion */ /* assuming that we're not in macro expansion */
fn mk_sp(lo: uint, hi: uint) -> span { fn mk_sp(lo: uint, hi: uint) -> span {
@ -18,14 +18,14 @@ fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
type ident = str; type ident = str;
// Functions may or may not have names. // Functions may or may not have names.
type fn_ident = option::t[ident]; type fn_ident = option::t<ident>;
// FIXME: with typestate constraint, could say // FIXME: with typestate constraint, could say
// idents and types are the same length, and are // idents and types are the same length, and are
// non-empty // non-empty
type path_ = {global: bool, idents: [ident], types: [@ty]}; type path_ = {global: bool, idents: [ident], types: [@ty]};
type path = spanned[path_]; type path = spanned<path_>;
fn path_name(p: &path) -> str { path_name_i(p.node.idents) } fn path_name(p: &path) -> str { path_name_i(p.node.idents) }
@ -90,7 +90,7 @@ fn def_id_of_def(d: def) -> def_id {
// used to drive conditional compilation // used to drive conditional compilation
type crate_cfg = [@meta_item]; type crate_cfg = [@meta_item];
type crate = spanned[crate_]; type crate = spanned<crate_>;
type crate_ = type crate_ =
{directives: [@crate_directive], {directives: [@crate_directive],
@ -99,9 +99,9 @@ type crate_ =
config: crate_cfg}; config: crate_cfg};
tag crate_directive_ { tag crate_directive_ {
cdir_src_mod(ident, option::t[filename], [attribute]); cdir_src_mod(ident, option::t<filename>, [attribute]);
cdir_dir_mod(ident, cdir_dir_mod(ident,
option::t[filename], option::t<filename>,
[@crate_directive], [@crate_directive],
[attribute]); [attribute]);
cdir_view_item(@view_item); cdir_view_item(@view_item);
@ -109,9 +109,9 @@ tag crate_directive_ {
cdir_auth(path, _auth); cdir_auth(path, _auth);
} }
type crate_directive = spanned[crate_directive_]; type crate_directive = spanned<crate_directive_>;
type meta_item = spanned[meta_item_]; type meta_item = spanned<meta_item_>;
tag meta_item_ { tag meta_item_ {
meta_word(ident); meta_word(ident);
@ -119,9 +119,9 @@ tag meta_item_ {
meta_name_value(ident, lit); meta_name_value(ident, lit);
} }
type blk = spanned[blk_]; type blk = spanned<blk_>;
type blk_ = {stmts: [@stmt], expr: option::t[@expr], id: node_id}; type blk_ = {stmts: [@stmt], expr: option::t<@expr>, id: node_id};
type pat = {id: node_id, node: pat_, span: span}; type pat = {id: node_id, node: pat_, span: span};
@ -137,7 +137,7 @@ tag pat_ {
pat_box(@pat); pat_box(@pat);
} }
type pat_id_map = std::map::hashmap[str, ast::node_id]; type pat_id_map = std::map::hashmap<str, ast::node_id>;
// This is used because same-named variables in alternative patterns need to // This is used because same-named variables in alternative patterns need to
// use the node_id of their namesake in the first pattern. // use the node_id of their namesake in the first pattern.
@ -252,7 +252,7 @@ fn unop_to_str(op: unop) -> str {
tag mode { val; alias(bool); move; } tag mode { val; alias(bool); move; }
type stmt = spanned[stmt_]; type stmt = spanned<stmt_>;
tag stmt_ { tag stmt_ {
stmt_decl(@decl, node_id); stmt_decl(@decl, node_id);
@ -267,12 +267,12 @@ type initializer = {op: init_op, expr: @expr};
type local_ = {ty: @ty, type local_ = {ty: @ty,
pat: @pat, pat: @pat,
init: option::t[initializer], init: option::t<initializer>,
id: node_id}; id: node_id};
type local = spanned[local_]; type local = spanned<local_>;
type decl = spanned[decl_]; type decl = spanned<decl_>;
tag decl_ { decl_local([@local]); decl_item(@item); } tag decl_ { decl_local([@local]); decl_item(@item); }
@ -280,7 +280,7 @@ type arm = {pats: [@pat], body: blk};
type field_ = {mut: mutability, ident: ident, expr: @expr}; type field_ = {mut: mutability, ident: ident, expr: @expr};
type field = spanned[field_]; type field = spanned<field_>;
tag spawn_dom { dom_implicit; dom_thread; } tag spawn_dom { dom_implicit; dom_thread; }
@ -293,16 +293,16 @@ type expr = {id: node_id, node: expr_, span: span};
tag expr_ { tag expr_ {
expr_vec([@expr], mutability, seq_kind); expr_vec([@expr], mutability, seq_kind);
expr_rec([field], option::t[@expr]); expr_rec([field], option::t<@expr>);
expr_call(@expr, [@expr]); expr_call(@expr, [@expr]);
expr_tup([@expr]); expr_tup([@expr]);
expr_self_method(ident); expr_self_method(ident);
expr_bind(@expr, [option::t[@expr]]); expr_bind(@expr, [option::t<@expr>]);
expr_binary(binop, @expr, @expr); expr_binary(binop, @expr, @expr);
expr_unary(unop, @expr); expr_unary(unop, @expr);
expr_lit(@lit); expr_lit(@lit);
expr_cast(@expr, @ty); expr_cast(@expr, @ty);
expr_if(@expr, blk, option::t[@expr]); expr_if(@expr, blk, option::t<@expr>);
expr_ternary(@expr, @expr, @expr); expr_ternary(@expr, @expr, @expr);
expr_while(@expr, blk); expr_while(@expr, blk);
expr_for(@local, @expr, blk); expr_for(@local, @expr, blk);
@ -323,11 +323,11 @@ tag expr_ {
expr_field(@expr, ident); expr_field(@expr, ident);
expr_index(@expr, @expr); expr_index(@expr, @expr);
expr_path(path); expr_path(path);
expr_fail(option::t[@expr]); expr_fail(option::t<@expr>);
expr_break; expr_break;
expr_cont; expr_cont;
expr_ret(option::t[@expr]); expr_ret(option::t<@expr>);
expr_put(option::t[@expr]); expr_put(option::t<@expr>);
expr_be(@expr); expr_be(@expr);
expr_log(int, @expr); expr_log(int, @expr);
/* just an assert, no significance to typestate */ /* just an assert, no significance to typestate */
@ -336,22 +336,22 @@ tag expr_ {
expr_check(check_mode, @expr); expr_check(check_mode, @expr);
/* FIXME Would be nice if expr_check desugared /* FIXME Would be nice if expr_check desugared
to expr_if_check. */ to expr_if_check. */
expr_if_check(@expr, blk, option::t[@expr]); expr_if_check(@expr, blk, option::t<@expr>);
expr_anon_obj(anon_obj); expr_anon_obj(anon_obj);
expr_mac(mac); expr_mac(mac);
expr_uniq(@expr); expr_uniq(@expr);
} }
type mac = spanned[mac_]; type mac = spanned<mac_>;
tag mac_ { tag mac_ {
mac_invoc(path, @expr, option::t[str]); mac_invoc(path, @expr, option::t<str>);
mac_embed_type(@ty); mac_embed_type(@ty);
mac_embed_block(blk); mac_embed_block(blk);
mac_ellipsis; mac_ellipsis;
} }
type lit = spanned[lit_]; type lit = spanned<lit_>;
tag lit_ { tag lit_ {
lit_str(str, seq_kind); lit_str(str, seq_kind);
@ -386,11 +386,11 @@ type ty_method_ =
cf: controlflow, cf: controlflow,
constrs: [@constr]}; constrs: [@constr]};
type ty_field = spanned[ty_field_]; type ty_field = spanned<ty_field_>;
type ty_arg = spanned[ty_arg_]; type ty_arg = spanned<ty_arg_>;
type ty_method = spanned[ty_method_]; type ty_method = spanned<ty_method_>;
tag ty_mach { tag ty_mach {
ty_i8; ty_i8;
@ -420,7 +420,7 @@ fn ty_mach_to_str(tm: ty_mach) -> str {
} }
} }
type ty = spanned[ty_]; type ty = spanned<ty_>;
tag ty_ { tag ty_ {
ty_nil; ty_nil;
@ -470,10 +470,10 @@ declarations, and ident for uses.
*/ */
tag constr_arg_general_[T] { carg_base; carg_ident(T); carg_lit(@lit); } tag constr_arg_general_[T] { carg_base; carg_ident(T); carg_lit(@lit); }
type fn_constr_arg = constr_arg_general_[uint]; type fn_constr_arg = constr_arg_general_<uint>;
type sp_constr_arg[T] = spanned[constr_arg_general_[T]]; type sp_constr_arg[T] = spanned<constr_arg_general_<T>>;
type ty_constr_arg = sp_constr_arg[path]; type ty_constr_arg = sp_constr_arg<path>;
type constr_arg = spanned[fn_constr_arg]; type constr_arg = spanned<fn_constr_arg>;
// Constrained types' args are parameterized by paths, since // Constrained types' args are parameterized by paths, since
// we refer to paths directly and not by indices. // we refer to paths directly and not by indices.
@ -481,15 +481,15 @@ type constr_arg = spanned[fn_constr_arg];
// constrained type, is * (referring to the base record) // constrained type, is * (referring to the base record)
type constr_general_[ARG, ID] = type constr_general_[ARG, ID] =
{path: path, args: [@spanned[constr_arg_general_[ARG]]], id: ID}; {path: path, args: [@spanned<constr_arg_general_<ARG>>], id: ID};
// In the front end, constraints have a node ID attached. // In the front end, constraints have a node ID attached.
// Typeck turns this to a def_id, using the output of resolve. // Typeck turns this to a def_id, using the output of resolve.
type constr_general[ARG] = spanned[constr_general_[ARG, node_id]]; type constr_general[ARG] = spanned<constr_general_<ARG, node_id>>;
type constr_ = constr_general_[uint, node_id]; type constr_ = constr_general_<uint, node_id>;
type constr = spanned[constr_general_[uint, node_id]]; type constr = spanned<constr_general_<uint, node_id>>;
type ty_constr_ = ast::constr_general_[ast::path, ast::node_id]; type ty_constr_ = ast::constr_general_<ast::path, ast::node_id>;
type ty_constr = spanned[ty_constr_]; type ty_constr = spanned<ty_constr_>;
/* The parser generates ast::constrs; resolve generates /* The parser generates ast::constrs; resolve generates
a mapping from each function to a list of ty::constr_defs, a mapping from each function to a list of ty::constr_defs,
@ -521,7 +521,7 @@ type _fn = {decl: fn_decl, proto: proto, body: blk};
type method_ = {ident: ident, meth: _fn, id: node_id}; type method_ = {ident: ident, meth: _fn, id: node_id};
type method = spanned[method_]; type method = spanned<method_>;
type obj_field = {mut: mutability, ty: @ty, ident: ident, id: node_id}; type obj_field = {mut: mutability, ty: @ty, ident: ident, id: node_id};
type anon_obj_field = type anon_obj_field =
@ -531,10 +531,10 @@ type _obj = {fields: [obj_field], methods: [@method]};
type anon_obj = type anon_obj =
// New fields and methods, if they exist. // New fields and methods, if they exist.
{fields: option::t[[anon_obj_field]], {fields: option::t<[anon_obj_field]>,
methods: [@method], methods: [@method],
// inner_obj: the original object being extended, if it exists. // inner_obj: the original object being extended, if it exists.
inner_obj: option::t[@expr]}; inner_obj: option::t<@expr>};
type _mod = {view_items: [@view_item], items: [@item]}; type _mod = {view_items: [@view_item], items: [@item]};
@ -556,9 +556,9 @@ type variant_arg = {ty: @ty, id: node_id};
type variant_ = {name: str, args: [variant_arg], id: node_id}; type variant_ = {name: str, args: [variant_arg], id: node_id};
type variant = spanned[variant_]; type variant = spanned<variant_>;
type view_item = spanned[view_item_]; type view_item = spanned<view_item_>;
tag view_item_ { tag view_item_ {
view_item_use(ident, [@meta_item], node_id); view_item_use(ident, [@meta_item], node_id);
@ -571,7 +571,7 @@ type obj_def_ids = {ty: node_id, ctor: node_id};
// Meta-data associated with an item // Meta-data associated with an item
type attribute = spanned[attribute_]; type attribute = spanned<attribute_>;
// Distinguishes between attributes that decorate items and attributes that // Distinguishes between attributes that decorate items and attributes that
@ -607,7 +607,7 @@ type native_item =
tag native_item_ { tag native_item_ {
native_item_ty; native_item_ty;
native_item_fn(option::t[str], fn_decl, [ty_param]); native_item_fn(option::t<str>, fn_decl, [ty_param]);
} }
fn is_exported(i: ident, m: _mod) -> bool { fn is_exported(i: ident, m: _mod) -> bool {

View file

@ -95,10 +95,10 @@ fn span_to_str(sp: &span, cm: &codemap) -> str {
ret res; ret res;
} }
fn emit_diagnostic(sp: &option::t[span], msg: &str, kind: &str, color: u8, fn emit_diagnostic(sp: &option::t<span>, msg: &str, kind: &str, color: u8,
cm: &codemap) { cm: &codemap) {
let ss = "<input>:0:0:0:0"; let ss = "<input>:0:0:0:0";
let maybe_lines: option::t[@file_lines] = none; let maybe_lines: option::t<@file_lines> = none;
alt sp { alt sp {
some(ssp) { some(ssp) {
ss = span_to_str(ssp, cm); ss = span_to_str(ssp, cm);
@ -119,8 +119,8 @@ fn emit_diagnostic(sp: &option::t[span], msg: &str, kind: &str, color: u8,
maybe_highlight_lines(sp, cm, maybe_lines); maybe_highlight_lines(sp, cm, maybe_lines);
} }
fn maybe_highlight_lines(sp: &option::t[span], cm: &codemap, fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
maybe_lines: option::t[@file_lines]) { maybe_lines: option::t<@file_lines>) {
alt maybe_lines { alt maybe_lines {
some(lines) { some(lines) {
@ -187,13 +187,13 @@ fn maybe_highlight_lines(sp: &option::t[span], cm: &codemap,
} }
} }
fn emit_warning(sp: &option::t[span], msg: &str, cm: &codemap) { fn emit_warning(sp: &option::t<span>, msg: &str, cm: &codemap) {
emit_diagnostic(sp, msg, "warning", 11u8, cm); emit_diagnostic(sp, msg, "warning", 11u8, cm);
} }
fn emit_error(sp: &option::t[span], msg: &str, cm: &codemap) { fn emit_error(sp: &option::t<span>, msg: &str, cm: &codemap) {
emit_diagnostic(sp, msg, "error", 9u8, cm); emit_diagnostic(sp, msg, "error", 9u8, cm);
} }
fn emit_note(sp: &option::t[span], msg: &str, cm: &codemap) { fn emit_note(sp: &option::t<span>, msg: &str, cm: &codemap) {
emit_diagnostic(sp, msg, "note", 10u8, cm); emit_diagnostic(sp, msg, "note", 10u8, cm);
} }

View file

@ -7,10 +7,10 @@ import std::map::new_str_hash;
import codemap; import codemap;
type syntax_expander = type syntax_expander =
fn(&ext_ctxt, span, @ast::expr, option::t[str]) -> @ast::expr ; fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> @ast::expr ;
type macro_def = {ident: str, ext: syntax_extension}; type macro_def = {ident: str, ext: syntax_extension};
type macro_definer = type macro_definer =
fn(&ext_ctxt, span, @ast::expr, option::t[str]) -> macro_def ; fn(&ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def ;
tag syntax_extension { tag syntax_extension {
normal(syntax_expander); normal(syntax_expander);
@ -19,7 +19,7 @@ tag syntax_extension {
// A temporary hard-coded map of methods for expanding syntax extension // A temporary hard-coded map of methods for expanding syntax extension
// AST nodes into full ASTs // AST nodes into full ASTs
fn syntax_expander_table() -> hashmap[str, syntax_extension] { fn syntax_expander_table() -> hashmap<str, syntax_extension> {
let syntax_expanders = new_str_hash[syntax_extension](); let syntax_expanders = new_str_hash[syntax_extension]();
syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext)); syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext));
syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext)); syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext));

View file

@ -3,7 +3,7 @@ import base::*;
import syntax::ast; import syntax::ast;
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr { body: option::t<str>) -> @ast::expr {
let args: [@ast::expr] = alt arg.node { let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts } ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#concat_idents requires a vector argument .") } _ { cx.span_fatal(sp, "#concat_idents requires a vector argument .") }

View file

@ -11,7 +11,7 @@ import base::*;
export expand_syntax_ext; export expand_syntax_ext;
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr { body: option::t<str>) -> @ast::expr {
let args: [@ast::expr] = alt arg.node { let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts } ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#env requires arguments of the form `[...]`.") } _ { cx.span_fatal(sp, "#env requires arguments of the form `[...]`.") }
@ -20,7 +20,7 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
cx.span_fatal(sp, "malformed #env call"); cx.span_fatal(sp, "malformed #env call");
} }
// FIXME: if this was more thorough it would manufacture an // FIXME: if this was more thorough it would manufacture an
// option::t[str] rather than just an maybe-empty string. // option::t<str> rather than just an maybe-empty string.
let var = expr_to_str(cx, args.(0), "#env requires a string"); let var = expr_to_str(cx, args.(0), "#env requires a string");
alt generic_os::getenv(var) { alt generic_os::getenv(var) {

View file

@ -14,7 +14,7 @@ import syntax::fold::*;
import syntax::ext::base::*; import syntax::ext::base::*;
fn expand_expr(exts: &hashmap[str, syntax_extension], cx: &ext_ctxt, fn expand_expr(exts: &hashmap<str, syntax_extension>, cx: &ext_ctxt,
e: &expr_, fld: ast_fold, e: &expr_, fld: ast_fold,
orig: &fn(&expr_, ast_fold) -> expr_ ) -> expr_ { orig: &fn(&expr_, ast_fold) -> expr_ ) -> expr_ {
ret alt e { ret alt e {

View file

@ -16,7 +16,7 @@ import codemap::span;
export expand_syntax_ext; export expand_syntax_ext;
fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr, fn expand_syntax_ext(cx: &ext_ctxt, sp: span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr { body: option::t<str>) -> @ast::expr {
let args: [@ast::expr] = alt arg.node { let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts } ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#fmt requires arguments of the form `[...]`.") } _ { cx.span_fatal(sp, "#fmt requires arguments of the form `[...]`.") }

View file

@ -4,7 +4,7 @@ import base::*;
import syntax::ast; import syntax::ast;
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr { body: option::t<str>) -> @ast::expr {
let args: [@ast::expr] = alt arg.node { let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts } ast::expr_vec(elts, _, _) { elts }
_ { cx.span_fatal(sp, "#ident_to_str requires a vector argument .") } _ { cx.span_fatal(sp, "#ident_to_str requires a vector argument .") }

View file

@ -3,7 +3,7 @@ import base::*;
import syntax::ast; import syntax::ast;
fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr, fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
body: option::t[str]) -> @ast::expr { body: option::t<str>) -> @ast::expr {
cx.print_backtrace(); cx.print_backtrace();
std::io::stdout().write_line(print::pprust::expr_to_str(arg)); std::io::stdout().write_line(print::pprust::expr_to_str(arg));

View file

@ -32,7 +32,7 @@ import ast::mac_invoc;
export add_new_extension; export add_new_extension;
fn path_to_ident(pth: &path) -> option::t[ident] { fn path_to_ident(pth: &path) -> option::t<ident> {
if vec::len(pth.node.idents) == 1u && vec::len(pth.node.types) == 0u { if vec::len(pth.node.idents) == 1u && vec::len(pth.node.types) == 0u {
ret some(pth.node.idents.(0u)); ret some(pth.node.idents.(0u));
} }
@ -43,13 +43,13 @@ fn path_to_ident(pth: &path) -> option::t[ident] {
type clause = {params: binders, body: @expr}; type clause = {params: binders, body: @expr};
/* logically, an arb_depth should contain only one kind of matchable */ /* logically, an arb_depth should contain only one kind of matchable */
tag arb_depth[T] { leaf(T); seq(@[arb_depth[T]], span); } tag arb_depth[T] { leaf(T); seq(@[arb_depth<T>], span); }
tag matchable { tag matchable {
match_expr(@expr); match_expr(@expr);
match_path(path); match_path(path);
match_ident(ast::spanned[ident]); match_ident(ast::spanned<ident>);
match_ty(@ty); match_ty(@ty);
match_block(ast::blk); match_block(ast::blk);
match_exact; /* don't bind anything, just verify the AST traversal */ match_exact; /* don't bind anything, just verify the AST traversal */
@ -88,11 +88,11 @@ fn match_error(cx: &ext_ctxt, m: &matchable, expected: &str) -> ! {
// If we want better match failure error messages (like in Fortifying Syntax), // If we want better match failure error messages (like in Fortifying Syntax),
// we'll want to return something indicating amount of progress and location // we'll want to return something indicating amount of progress and location
// of failure instead of `none`. // of failure instead of `none`.
type match_result = option::t[arb_depth[matchable]]; type match_result = option::t<arb_depth<matchable>>;
type selector = fn(&matchable) -> match_result ; type selector = fn(&matchable) -> match_result ;
fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr]) fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr])
-> {pre: [@expr], rep: option::t[@expr], post: [@expr]} { -> {pre: [@expr], rep: option::t<@expr>, post: [@expr]} {
let idx: uint = 0u; let idx: uint = 0u;
let res = none; let res = none;
for elt: @expr in elts { for elt: @expr in elts {
@ -121,8 +121,8 @@ fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr])
} }
} }
fn option_flatten_map[T, U](f: &fn(&T) -> option::t[U] , v: &[T]) -> fn option_flatten_map[T, U](f: &fn(&T) -> option::t<U>, v: &[T]) ->
option::t[[U]] { option::t<[U]> {
let res = ~[]; let res = ~[];
for elem: T in v { 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]; } }
@ -130,7 +130,7 @@ fn option_flatten_map[T, U](f: &fn(&T) -> option::t[U] , v: &[T]) ->
ret some(res); ret some(res);
} }
fn a_d_map(ad: &arb_depth[matchable], f: &selector) -> match_result { fn a_d_map(ad: &arb_depth<matchable>, f: &selector) -> match_result {
alt ad { alt ad {
leaf(x) { ret f(x); } leaf(x) { ret f(x); }
seq(ads, span) { seq(ads, span) {
@ -155,9 +155,9 @@ fn compose_sels(s1: selector, s2: selector) -> selector {
type binders = type binders =
{real_binders: hashmap[ident, selector], {real_binders: hashmap<ident, selector>,
mutable literal_ast_matchers: [selector]}; mutable literal_ast_matchers: [selector]};
type bindings = hashmap[ident, arb_depth[matchable]]; type bindings = hashmap<ident, arb_depth<matchable>>;
fn acumm_bindings(cx: &ext_ctxt, b_dest: &bindings, b_src: &bindings) { } fn acumm_bindings(cx: &ext_ctxt, b_dest: &bindings, b_src: &bindings) { }
@ -182,8 +182,8 @@ fn pattern_to_selectors(cx: &ext_ctxt, e: @expr) -> binders {
bindings. Most of the work is done in p_t_s, which generates the bindings. Most of the work is done in p_t_s, which generates the
selectors. */ selectors. */
fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t[bindings] { fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t<bindings> {
let res = new_str_hash[arb_depth[matchable]](); let res = new_str_hash[arb_depth<matchable>]();
//need to do this first, to check vec lengths. //need to do this first, to check vec lengths.
for sel: selector in b.literal_ast_matchers { for sel: selector in b.literal_ast_matchers {
alt sel(match_expr(e)) { none. { ret none; } _ { } } alt sel(match_expr(e)) { none. { ret none; } _ { } }
@ -230,9 +230,9 @@ fn transcribe(cx: &ext_ctxt, b: &bindings, body: @expr) -> @expr {
/* helper: descend into a matcher */ /* helper: descend into a matcher */
fn follow(m: &arb_depth[matchable], idx_path: @mutable [uint]) -> fn follow(m: &arb_depth<matchable>, idx_path: @mutable [uint]) ->
arb_depth[matchable] { arb_depth<matchable> {
let res: arb_depth[matchable] = m; let res: arb_depth<matchable> = m;
for idx: uint in *idx_path { for idx: uint in *idx_path {
alt res { alt res {
leaf(_) { ret res;/* end of the line */ } leaf(_) { ret res;/* end of the line */ }
@ -242,8 +242,8 @@ fn follow(m: &arb_depth[matchable], idx_path: @mutable [uint]) ->
ret res; ret res;
} }
fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t[arb_depth[matchable]], fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t<arb_depth<matchable>>,
idx_path: @mutable [uint]) -> option::t[matchable] { idx_path: @mutable [uint]) -> option::t<matchable> {
alt mmaybe { alt mmaybe {
none. { ret none } none. { ret none }
some(m) { some(m) {
@ -262,9 +262,9 @@ fn follow_for_trans(cx: &ext_ctxt, mmaybe: &option::t[arb_depth[matchable]],
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */ /* helper for transcribe_exprs: what vars from `b` occur in `e`? */
iter free_vars(b: &bindings, e: @expr) -> ident { iter free_vars(b: &bindings, e: @expr) -> ident {
let idents: hashmap[ident, ()] = new_str_hash[()](); let idents: hashmap<ident, ()> = new_str_hash[()]();
fn mark_ident(i: &ident, fld: ast_fold, b: &bindings, fn mark_ident(i: &ident, fld: ast_fold, b: &bindings,
idents: &hashmap[ident, ()]) -> ident { idents: &hashmap<ident, ()>) -> ident {
if b.contains_key(i) { idents.insert(i, ()); } if b.contains_key(i) { idents.insert(i, ()); }
ret i; ret i;
} }
@ -290,7 +290,7 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
alt repeat_me_maybe { alt repeat_me_maybe {
none. {} none. {}
some(repeat_me) { some(repeat_me) {
let repeat: option::t[{rep_count: uint, name: ident}] = none; let repeat: option::t<{rep_count: uint, name: ident}> = none;
/* we need to walk over all the free vars in lockstep, except for /* we need to walk over all the free vars in lockstep, except for
the leaves, which are just duplicated */ the leaves, which are just duplicated */
for each fv: ident in free_vars(b, repeat_me) { for each fv: ident in free_vars(b, repeat_me) {
@ -533,7 +533,7 @@ fn p_t_s_r_path(cx: &ext_ctxt, p: &path, s: &selector, b: &binders) {
} }
} }
fn block_to_ident(blk: &blk_) -> option::t[ident] { fn block_to_ident(blk: &blk_) -> option::t<ident> {
if vec::len(blk.stmts) != 0u { ret none; } if vec::len(blk.stmts) != 0u { ret none; }
ret alt blk.expr { ret alt blk.expr {
some(expr) { some(expr) {
@ -676,7 +676,7 @@ fn p_t_s_r_actual_vector(cx: &ext_ctxt, elts: [@expr], repeat_after: bool,
} }
fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr, fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
body: option::t[str]) -> base::macro_def { body: option::t<str>) -> base::macro_def {
let args: [@ast::expr] = alt arg.node { let args: [@ast::expr] = alt arg.node {
ast::expr_vec(elts, _, _) { elts } ast::expr_vec(elts, _, _) { elts }
_ { _ {
@ -684,7 +684,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
} }
}; };
let macro_name: option::t[str] = none; let macro_name: option::t<str> = none;
let clauses: [@clause] = ~[]; let clauses: [@clause] = ~[];
for arg: @expr in args { for arg: @expr in args {
alt arg.node { alt arg.node {
@ -753,7 +753,7 @@ fn add_new_extension(cx: &ext_ctxt, sp: span, arg: @expr,
ext: normal(ext)}; ext: normal(ext)};
fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr, fn generic_extension(cx: &ext_ctxt, sp: span, arg: @expr,
body: option::t[str], clauses: [@clause]) -> @expr { body: option::t<str>, clauses: [@clause]) -> @expr {
for c: @clause in clauses { for c: @clause in clauses {
alt use_selectors_to_bind(c.params, arg) { alt use_selectors_to_bind(c.params, arg) {
some(bindings) { some(bindings) {

View file

@ -497,7 +497,7 @@ fn noop_fold_local(l: &local_, fld: ast_fold) -> local_ {
id: l.id}; id: l.id};
} }
/* temporarily eta-expand because of a compiler bug with using `fn[T]` as a /* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
value */ value */
fn noop_map_exprs(f: fn(&@expr) -> @expr , es: [@expr]) -> [@expr] { fn noop_map_exprs(f: fn(&@expr) -> @expr , es: [@expr]) -> [@expr] {
ret vec::map(f, es); ret vec::map(f, es);

View file

@ -20,7 +20,7 @@ type reader =
fn init() ; fn init() ;
fn bump() ; fn bump() ;
fn get_str_from(uint) -> str ; fn get_str_from(uint) -> str ;
fn get_interner() -> @interner::interner[str] ; fn get_interner() -> @interner::interner<str> ;
fn get_chpos() -> uint ; fn get_chpos() -> uint ;
fn get_byte_pos() -> uint ; fn get_byte_pos() -> uint ;
fn get_col() -> uint ; fn get_col() -> uint ;
@ -29,7 +29,7 @@ type reader =
}; };
fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap, fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap,
itr: @interner::interner[str]) -> reader { itr: @interner::interner<str>) -> reader {
obj reader(cm: codemap::codemap, obj reader(cm: codemap::codemap,
src: str, src: str,
len: uint, len: uint,
@ -39,7 +39,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap,
mutable chpos: uint, mutable chpos: uint,
mutable strs: [str], mutable strs: [str],
fm: codemap::filemap, fm: codemap::filemap,
itr: @interner::interner[str]) { itr: @interner::interner<str>) {
fn is_eof() -> bool { ret ch == -1 as char; } fn is_eof() -> bool { ret ch == -1 as char; }
fn get_str_from(start: uint) -> str { fn get_str_from(start: uint) -> str {
// I'm pretty skeptical about this subtraction. What if there's a // I'm pretty skeptical about this subtraction. What if there's a
@ -74,7 +74,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap,
ch = next.ch; ch = next.ch;
} else { ch = -1 as char; } } else { ch = -1 as char; }
} }
fn get_interner() -> @interner::interner[str] { ret itr; } fn get_interner() -> @interner::interner<str> { ret itr; }
fn get_col() -> uint { ret col; } fn get_col() -> uint { ret col; }
fn get_filemap() -> codemap::filemap { ret fm; } fn get_filemap() -> codemap::filemap { ret fm; }
fn err(m: str) { fn err(m: str) {
@ -173,7 +173,7 @@ fn digits_to_string(s: str) -> int {
ret accum_int; ret accum_int;
} }
fn scan_exponent(rdr: &reader) -> option::t[str] { fn scan_exponent(rdr: &reader) -> option::t<str> {
let c = rdr.curr(); let c = rdr.curr();
let rslt = ""; let rslt = "";
if c == 'e' || c == 'E' { if c == 'e' || c == 'E' {

View file

@ -52,7 +52,7 @@ type parser =
fn get_str(token::str_num) -> str ; fn get_str(token::str_num) -> str ;
fn get_reader() -> lexer::reader ; fn get_reader() -> lexer::reader ;
fn get_filemap() -> codemap::filemap ; fn get_filemap() -> codemap::filemap ;
fn get_bad_expr_words() -> hashmap[str, ()] ; fn get_bad_expr_words() -> hashmap<str, ()> ;
fn get_chpos() -> uint ; fn get_chpos() -> uint ;
fn get_byte_pos() -> uint ; fn get_byte_pos() -> uint ;
fn get_id() -> node_id ; fn get_id() -> node_id ;
@ -84,7 +84,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
mutable restr: restriction, mutable restr: restriction,
rdr: lexer::reader, rdr: lexer::reader,
precs: @[op_spec], precs: @[op_spec],
bad_words: hashmap[str, ()]) { bad_words: hashmap<str, ()>) {
fn peek() -> token::token { ret tok; } fn peek() -> token::token { ret tok; }
fn bump() { fn bump() {
last_tok_span = tok_span; last_tok_span = tok_span;
@ -132,7 +132,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
} }
fn get_reader() -> lexer::reader { ret rdr; } fn get_reader() -> lexer::reader { ret rdr; }
fn get_filemap() -> codemap::filemap { ret rdr.get_filemap(); } fn get_filemap() -> codemap::filemap { ret rdr.get_filemap(); }
fn get_bad_expr_words() -> hashmap[str, ()] { ret bad_words; } fn get_bad_expr_words() -> hashmap<str, ()> { ret bad_words; }
fn get_chpos() -> uint { ret rdr.get_chpos(); } fn get_chpos() -> uint { ret rdr.get_chpos(); }
fn get_byte_pos() -> uint { ret rdr.get_byte_pos(); } fn get_byte_pos() -> uint { ret rdr.get_byte_pos(); }
fn get_id() -> node_id { ret next_node_id(sess); } fn get_id() -> node_id { ret next_node_id(sess); }
@ -148,7 +148,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
// These are the words that shouldn't be allowed as value identifiers, // These are the words that shouldn't be allowed as value identifiers,
// because, if used at the start of a line, they will cause the line to be // because, if used at the start of a line, they will cause the line to be
// interpreted as a specific kind of statement, which would be confusing. // interpreted as a specific kind of statement, which would be confusing.
fn bad_expr_word_table() -> hashmap[str, ()] { fn bad_expr_word_table() -> hashmap<str, ()> {
let words = new_str_hash(); let words = new_str_hash();
words.insert("mod", ()); words.insert("mod", ());
words.insert("if", ()); words.insert("if", ());
@ -224,7 +224,7 @@ fn expect_gt(p: &parser) {
} }
} }
fn spanned[T](lo: uint, hi: uint, node: &T) -> spanned[T] { fn spanned[T](lo: uint, hi: uint, node: &T) -> spanned<T> {
ret {node: node, span: ast::mk_sp(lo, hi)}; ret {node: node, span: ast::mk_sp(lo, hi)};
} }
@ -429,9 +429,9 @@ fn parse_constr_in_type(p: &parser) -> @ast::ty_constr {
} }
fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general[T] , p: &parser) fn parse_constrs[T](pser: fn(&parser) -> @ast::constr_general<T>, p: &parser)
-> [@ast::constr_general[T]] { -> [@ast::constr_general<T>] {
let constrs: [@ast::constr_general[T]] = ~[]; let constrs: [@ast::constr_general<T>] = ~[];
while true { while true {
let constr = pser(p); let constr = pser(p);
constrs += ~[constr]; constrs += ~[constr];
@ -643,7 +643,7 @@ fn parse_fn_block_arg(p: &parser) -> ast::arg {
ret {mode: m, ty: t, ident: i, id: p.get_id()}; ret {mode: m, ty: t, ident: i, id: p.get_id()};
} }
fn parse_seq_to_before_gt[T](sep: option::t[token::token], fn parse_seq_to_before_gt[T](sep: option::t<token::token>,
f: fn(&parser) -> T, p: &parser) -> [T] { f: fn(&parser) -> T, p: &parser) -> [T] {
let first = true; let first = true;
let v = ~[]; let v = ~[];
@ -660,7 +660,7 @@ fn parse_seq_to_before_gt[T](sep: option::t[token::token],
ret v; ret v;
} }
fn parse_seq_to_gt[T](sep: option::t[token::token], f: fn(&parser) -> T, fn parse_seq_to_gt[T](sep: option::t<token::token>, f: fn(&parser) -> T,
p: &parser) -> [T] { p: &parser) -> [T] {
let v = parse_seq_to_before_gt(sep, f, p); let v = parse_seq_to_before_gt(sep, f, p);
expect_gt(p); expect_gt(p);
@ -668,8 +668,8 @@ fn parse_seq_to_gt[T](sep: option::t[token::token], f: fn(&parser) -> T,
ret v; ret v;
} }
fn parse_seq_lt_gt[T](sep: option::t[token::token], f: fn(&parser) -> T, fn parse_seq_lt_gt[T](sep: option::t<token::token>, f: fn(&parser) -> T,
p: &parser) -> spanned[[T]] { p: &parser) -> spanned<[T]> {
let lo = p.get_lo_pos(); let lo = p.get_lo_pos();
expect(p, token::LT); expect(p, token::LT);
let result = parse_seq_to_before_gt[T](sep, f, p); let result = parse_seq_to_before_gt[T](sep, f, p);
@ -678,14 +678,14 @@ fn parse_seq_lt_gt[T](sep: option::t[token::token], f: fn(&parser) -> T,
ret spanned(lo, hi, result); ret spanned(lo, hi, result);
} }
fn parse_seq_to_end[T](ket: token::token, sep: option::t[token::token], fn parse_seq_to_end[T](ket: token::token, sep: option::t<token::token>,
f: fn(&parser) -> T , p: &parser) -> [T] { f: fn(&parser) -> T , p: &parser) -> [T] {
let val = parse_seq_to_before_end(ket, sep, f, p); let val = parse_seq_to_before_end(ket, sep, f, p);
p.bump(); p.bump();
ret val; ret val;
} }
fn parse_seq_to_before_end[T](ket: token::token, sep: option::t[token::token], fn parse_seq_to_before_end[T](ket: token::token, sep: option::t<token::token>,
f: fn(&parser) -> T , p: &parser) -> [T] { f: fn(&parser) -> T , p: &parser) -> [T] {
let first: bool = true; let first: bool = true;
let v: [T] = ~[]; let v: [T] = ~[];
@ -701,8 +701,8 @@ fn parse_seq_to_before_end[T](ket: token::token, sep: option::t[token::token],
fn parse_seq[T](bra: token::token, ket: token::token, fn parse_seq[T](bra: token::token, ket: token::token,
sep: option::t[token::token], f: fn(&parser) -> T , sep: option::t<token::token>, f: fn(&parser) -> T ,
p: &parser) -> spanned[[T]] { p: &parser) -> spanned<[T]> {
let lo = p.get_lo_pos(); let lo = p.get_lo_pos();
expect(p, bra); expect(p, bra);
let result = parse_seq_to_before_end[T](ket, sep, f, p); let result = parse_seq_to_before_end[T](ket, sep, f, p);
@ -955,7 +955,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
// Anonymous object // Anonymous object
// Only make people type () if they're actually adding new fields // Only make people type () if they're actually adding new fields
let fields: option::t[[ast::anon_obj_field]] = none; let fields: option::t<[ast::anon_obj_field]> = none;
if p.peek() == token::LPAREN { if p.peek() == token::LPAREN {
p.bump(); p.bump();
fields = fields =
@ -963,7 +963,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
parse_anon_obj_field, p)); parse_anon_obj_field, p));
} }
let meths: [@ast::method] = ~[]; let meths: [@ast::method] = ~[];
let inner_obj: option::t[@ast::expr] = none; let inner_obj: option::t<@ast::expr> = none;
expect(p, token::LBRACE); expect(p, token::LBRACE);
while p.peek() != token::RBRACE { while p.peek() != token::RBRACE {
if eat_word(p, "with") { if eat_word(p, "with") {
@ -982,7 +982,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
ex = ast::expr_anon_obj(ob); ex = ast::expr_anon_obj(ob);
} else if (eat_word(p, "bind")) { } else if (eat_word(p, "bind")) {
let e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS); let e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS);
fn parse_expr_opt(p: &parser) -> option::t[@ast::expr] { fn parse_expr_opt(p: &parser) -> option::t<@ast::expr> {
alt p.peek() { alt p.peek() {
token::UNDERSCORE. { p.bump(); ret none; } token::UNDERSCORE. { p.bump(); ret none; }
_ { ret some(parse_expr(p)); } _ { ret some(parse_expr(p)); }
@ -1329,13 +1329,13 @@ fn parse_assign_expr(p: &parser) -> @ast::expr {
fn parse_if_expr_1(p: &parser) -> fn parse_if_expr_1(p: &parser) ->
{cond: @ast::expr, {cond: @ast::expr,
then: ast::blk, then: ast::blk,
els: option::t[@ast::expr], els: option::t<@ast::expr>,
lo: uint, lo: uint,
hi: uint} { hi: uint} {
let lo = p.get_last_lo_pos(); let lo = p.get_last_lo_pos();
let cond = parse_expr(p); let cond = parse_expr(p);
let thn = parse_block(p); let thn = parse_block(p);
let els: option::t[@ast::expr] = none; let els: option::t<@ast::expr> = none;
let hi = thn.span.hi; let hi = thn.span.hi;
if eat_word(p, "else") { if eat_word(p, "else") {
let elexpr = parse_else_expr(p); let elexpr = parse_else_expr(p);
@ -1437,7 +1437,7 @@ fn parse_expr_res(p: &parser, r: restriction) -> @ast::expr {
ret e; ret e;
} }
fn parse_initializer(p: &parser) -> option::t[ast::initializer] { fn parse_initializer(p: &parser) -> option::t<ast::initializer> {
alt p.peek() { alt p.peek() {
token::EQ. { token::EQ. {
p.bump(); p.bump();
@ -1653,7 +1653,7 @@ fn parse_source_stmt(p: &parser) -> @ast::stmt {
} }
} }
fn stmt_to_expr(stmt: @ast::stmt) -> option::t[@ast::expr] { fn stmt_to_expr(stmt: @ast::stmt) -> option::t<@ast::expr> {
ret alt stmt.node { ast::stmt_expr(e, _) { some(e) } _ { none } }; ret alt stmt.node { ast::stmt_expr(e, _) { some(e) } _ { none } };
} }
@ -1724,7 +1724,7 @@ fn parse_block(p: &parser) -> ast::blk {
// some blocks start with "#{"... // some blocks start with "#{"...
fn parse_block_tail(p: &parser, lo: uint) -> ast::blk { fn parse_block_tail(p: &parser, lo: uint) -> ast::blk {
let stmts: [@ast::stmt] = ~[]; let stmts: [@ast::stmt] = ~[];
let expr: option::t[@ast::expr] = none; let expr: option::t<@ast::expr> = none;
while p.peek() != token::RBRACE { while p.peek() != token::RBRACE {
alt p.peek() { alt p.peek() {
token::SEMI. { token::SEMI. {
@ -1796,7 +1796,7 @@ fn parse_ty_params(p: &parser) -> [ast::ty_param] {
fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness) fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness)
-> ast::fn_decl { -> ast::fn_decl {
let inputs: ast::spanned[[ast::arg]] = let inputs: ast::spanned<[ast::arg]> =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg, parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg,
p); p);
let rslt: ty_or_bang; let rslt: ty_or_bang;
@ -1835,7 +1835,7 @@ fn parse_fn_decl(p: &parser, purity: ast::purity, il: ast::inlineness)
} }
fn parse_fn_block_decl(p: &parser) -> ast::fn_decl { fn parse_fn_block_decl(p: &parser) -> ast::fn_decl {
let inputs: ast::spanned[[ast::arg]] = let inputs: ast::spanned<[ast::arg]> =
parse_seq(token::BINOP(token::OR), token::BINOP(token::OR), parse_seq(token::BINOP(token::OR), token::BINOP(token::OR),
some(token::COMMA), parse_fn_block_arg, p); some(token::COMMA), parse_fn_block_arg, p);
ret {inputs: inputs.node, ret {inputs: inputs.node,
@ -1910,7 +1910,7 @@ fn parse_item_obj(p: &parser, attrs: &[ast::attribute]) ->
let lo = p.get_last_lo_pos(); let lo = p.get_last_lo_pos();
let ident = parse_value_ident(p); let ident = parse_value_ident(p);
let ty_params = parse_ty_params(p); let ty_params = parse_ty_params(p);
let fields: ast::spanned[[ast::obj_field]] = let fields: ast::spanned<[ast::obj_field]> =
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
parse_obj_field, p); parse_obj_field, p);
let meths: [@ast::method] = ~[]; let meths: [@ast::method] = ~[];
@ -2171,7 +2171,7 @@ fn parse_auth(p: &parser) -> ast::_auth {
} else { unexpected(p, p.peek()); } } else { unexpected(p, p.peek()); }
} }
fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t[@ast::item] { fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t<@ast::item> {
if eat_word(p, "const") { if eat_word(p, "const") {
ret some(parse_item_const(p, attrs)); ret some(parse_item_const(p, attrs));
} else if (eat_word(p, "inline")) { } else if (eat_word(p, "inline")) {
@ -2207,7 +2207,7 @@ fn parse_item(p: &parser, attrs: &[ast::attribute]) -> option::t[@ast::item] {
// A type to distingush between the parsing of item attributes or syntax // A type to distingush between the parsing of item attributes or syntax
// extensions, which both begin with token.POUND // extensions, which both begin with token.POUND
type attr_or_ext = option::t[either::t[[ast::attribute], @ast::expr]]; type attr_or_ext = option::t<either::t<[ast::attribute], @ast::expr>>;
fn parse_outer_attrs_or_ext(p: &parser) -> attr_or_ext { fn parse_outer_attrs_or_ext(p: &parser) -> attr_or_ext {
if p.peek() == token::POUND { if p.peek() == token::POUND {
@ -2311,7 +2311,7 @@ fn parse_use(p: &parser) -> ast::view_item_ {
} }
fn parse_rest_import_name(p: &parser, first: ast::ident, fn parse_rest_import_name(p: &parser, first: ast::ident,
def_ident: option::t[ast::ident]) -> def_ident: option::t<ast::ident>) ->
ast::view_item_ { ast::view_item_ {
let identifiers: [ast::ident] = ~[first]; let identifiers: [ast::ident] = ~[first];
let glob: bool = false; let glob: bool = false;

View file

@ -40,9 +40,9 @@ fn no_ann() -> pp_ann {
type ps = type ps =
@{s: pp::printer, @{s: pp::printer,
cm: option::t[codemap], cm: option::t<codemap>,
comments: option::t[[lexer::cmnt]], comments: option::t<[lexer::cmnt]>,
literals: option::t[[lexer::lit]], literals: option::t<[lexer::lit]>,
mutable cur_cmnt: uint, mutable cur_cmnt: uint,
mutable cur_lit: uint, mutable cur_lit: uint,
mutable boxes: [pp::breaks], mutable boxes: [pp::breaks],
@ -619,7 +619,7 @@ fn print_possibly_embedded_block(s: &ps, blk: &ast::blk, embedded: embed_type,
// followed by a unary op statement. In those cases we have to add an // followed by a unary op statement. In those cases we have to add an
// extra semi to make sure the unop is not parsed as a binop with the // extra semi to make sure the unop is not parsed as a binop with the
// if/alt/block expression. // if/alt/block expression.
fn maybe_protect_unop(s: &ps, last: &option::t[@ast::stmt], fn maybe_protect_unop(s: &ps, last: &option::t<@ast::stmt>,
next: &expr_or_stmt) { next: &expr_or_stmt) {
let last_expr_is_block = alt last { let last_expr_is_block = alt last {
option::some(@{node: ast::stmt_expr(e, _), _}) { option::some(@{node: ast::stmt_expr(e, _), _}) {
@ -651,13 +651,13 @@ fn print_possibly_embedded_block(s: &ps, blk: &ast::blk, embedded: embed_type,
} }
fn print_if(s: &ps, test: &@ast::expr, blk: &ast::blk, fn print_if(s: &ps, test: &@ast::expr, blk: &ast::blk,
elseopt: &option::t[@ast::expr], chk: bool) { elseopt: &option::t<@ast::expr>, chk: bool) {
head(s, "if"); head(s, "if");
if chk { word_nbsp(s, "check"); } if chk { word_nbsp(s, "check"); }
print_expr(s, test); print_expr(s, test);
space(s.s); space(s.s);
print_block(s, blk); print_block(s, blk);
fn do_else(s: &ps, els: option::t[@ast::expr]) { fn do_else(s: &ps, els: option::t<@ast::expr>) {
alt els { alt els {
some(_else) { some(_else) {
alt _else.node { alt _else.node {
@ -773,7 +773,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
print_ident(s, ident); print_ident(s, ident);
} }
ast::expr_bind(func, args) { ast::expr_bind(func, args) {
fn print_opt(s: &ps, expr: &option::t[@ast::expr]) { fn print_opt(s: &ps, expr: &option::t<@ast::expr>) {
alt expr { alt expr {
some(expr) { print_expr(s, expr); } some(expr) { print_expr(s, expr); }
_ { word(s.s, "_"); } _ { word(s.s, "_"); }
@ -1325,7 +1325,7 @@ fn print_mt(s: &ps, mt: &ast::mt) {
print_type(s, mt.ty); print_type(s, mt.ty);
} }
fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str], fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t<str>,
inputs: &[ast::ty_arg], output: &@ast::ty, inputs: &[ast::ty_arg], output: &@ast::ty,
cf: &ast::controlflow, constrs: &[@ast::constr]) { cf: &ast::controlflow, constrs: &[@ast::constr]) {
ibox(s, indent_unit); ibox(s, indent_unit);
@ -1355,7 +1355,7 @@ fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str],
} }
fn maybe_print_trailing_comment(s: &ps, span: codemap::span, fn maybe_print_trailing_comment(s: &ps, span: codemap::span,
next_pos: option::t[uint]) { next_pos: option::t<uint>) {
let cm; let cm;
alt s.cm { some(ccm) { cm = ccm; } _ { ret; } } alt s.cm { some(ccm) { cm = ccm; } _ { ret; } }
alt next_comment(s) { alt next_comment(s) {
@ -1431,7 +1431,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
fn lit_to_str(l: &@ast::lit) -> str { be to_str(l, print_literal); } fn lit_to_str(l: &@ast::lit) -> str { be to_str(l, print_literal); }
fn next_lit(s: &ps) -> option::t[lexer::lit] { fn next_lit(s: &ps) -> option::t<lexer::lit> {
alt s.literals { alt s.literals {
some(lits) { some(lits) {
if s.cur_lit < vec::len(lits) { if s.cur_lit < vec::len(lits) {
@ -1523,7 +1523,7 @@ fn to_str[T](t: &T, f: fn(&ps, &T) ) -> str {
ret writer.get_str(); ret writer.get_str();
} }
fn next_comment(s: &ps) -> option::t[lexer::cmnt] { fn next_comment(s: &ps) -> option::t<lexer::cmnt> {
alt s.comments { alt s.comments {
some(cmnts) { some(cmnts) {
if s.cur_cmnt < vec::len(cmnts) { if s.cur_cmnt < vec::len(cmnts) {
@ -1537,10 +1537,10 @@ fn next_comment(s: &ps) -> option::t[lexer::cmnt] {
// Removing the aliases from the type of f in the next two functions // Removing the aliases from the type of f in the next two functions
// triggers memory corruption, but I haven't isolated the bug yet. FIXME // triggers memory corruption, but I haven't isolated the bug yet. FIXME
fn constr_args_to_str[T](f: &fn(&T) -> str , fn constr_args_to_str[T](f: &fn(&T) -> str ,
args: &[@ast::sp_constr_arg[T]]) -> str { args: &[@ast::sp_constr_arg<T>]) -> str {
let comma = false; let comma = false;
let s = "("; let s = "(";
for a: @ast::sp_constr_arg[T] in args { for a: @ast::sp_constr_arg<T> in args {
if comma { s += ", "; } else { comma = true; } if comma { s += ", "; } else { comma = true; }
s += constr_arg_to_str[T](f, a.node); s += constr_arg_to_str[T](f, a.node);
} }
@ -1548,7 +1548,7 @@ fn constr_args_to_str[T](f: &fn(&T) -> str ,
ret s; ret s;
} }
fn constr_arg_to_str[T](f: &fn(&T) -> str , c: &ast::constr_arg_general_[T]) fn constr_arg_to_str[T](f: &fn(&T) -> str, c: &ast::constr_arg_general_<T>)
-> str { -> str {
alt c { alt c {
ast::carg_base. { ret "*"; } ast::carg_base. { ret "*"; }

View file

@ -9,9 +9,9 @@ import codemap::span;
import codemap::filename; import codemap::filename;
tag ast_node { tag ast_node {
branch(node_name, option::t[span], (@ast_node)[]); branch(node_name, option::t<span>, (@ast_node)[]);
i_seq((@ast_node)[]); i_seq((@ast_node)[]);
i_opt(option::t[@ast_node]); i_opt(option::t<@ast_node>);
l_bool(bool); l_bool(bool);
l_ident(ident); l_ident(ident);
l_fn_ident(fn_ident); l_fn_ident(fn_ident);
@ -44,8 +44,8 @@ tag ast_node {
l_attr_style; l_attr_style;
// these could be avoided, at the cost of making #br_* more convoluted // these could be avoided, at the cost of making #br_* more convoluted
l_optional_filename(option::t[filename]); l_optional_filename(option::t<filename>);
l_optional_string(option::t[str]); l_optional_string(option::t<str>);
l_seq_ident(ident[]); l_seq_ident(ident[]);
l_seq_ty_param(ty_param[]); l_seq_ty_param(ty_param[]);
@ -245,7 +245,7 @@ type ctx = {
/** Type of failure function: to be invoked if typification fails. /** Type of failure function: to be invoked if typification fails.
It's hopefully a bug for this to be invoked without a span. */ It's hopefully a bug for this to be invoked without a span. */
type ff = fn(sp: option::t[span], msg: str) -> !; type ff = fn(sp: option::t<span>, msg: str) -> !;
fn dummy() { fn dummy() {
@ -384,8 +384,8 @@ fn seq_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
} }
fn opt_cv[T](conversion: fn (&ctx, &@ast_node) -> T) fn opt_cv[T](conversion: fn (&ctx, &@ast_node) -> T)
-> fn (&ctx, @ast_node) -> option::t[T] { -> fn (&ctx, @ast_node) -> option::t<T> {
ret lambda(ctx: &ctx, ut: @ast_node) -> option::t[T] { ret lambda(ctx: &ctx, ut: @ast_node) -> option::t<T> {
ret alt *ut { ret alt *ut {
i_opt(ut_maybe) { option::map(bind conversion(ctx, _), ut_maybe) } i_opt(ut_maybe) { option::map(bind conversion(ctx, _), ut_maybe) }
branch(_, sp, _) { branch(_, sp, _) {

View file

@ -11,17 +11,17 @@ import std::option::none;
import std::option::some; import std::option::some;
type interner[T] = type interner[T] =
{map: hashmap[T, uint], {map: hashmap<T, uint>,
mutable vect: [T], mutable vect: [T],
hasher: hashfn[T], hasher: hashfn<T>,
eqer: eqfn[T]}; eqer: eqfn<T>};
fn mk[@T](hasher: hashfn[T], eqer: eqfn[T]) -> interner[T] { fn mk[@T](hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
let m = map::mk_hashmap[T, uint](hasher, eqer); let m = map::mk_hashmap[T, uint](hasher, eqer);
ret {map: m, mutable vect: ~[], hasher: hasher, eqer: eqer}; ret {map: m, mutable vect: ~[], hasher: hasher, eqer: eqer};
} }
fn intern[@T](itr: &interner[T], val: &T) -> uint { fn intern[@T](itr: &interner<T>, val: &T) -> uint {
alt itr.map.find(val) { alt itr.map.find(val) {
some(idx) { ret idx; } some(idx) { ret idx; }
none. { none. {
@ -33,7 +33,7 @@ fn intern[@T](itr: &interner[T], val: &T) -> uint {
} }
} }
fn get[T](itr: &interner[T], idx: uint) -> T { ret itr.vect.(idx); } fn get[T](itr: &interner<T>, idx: uint) -> T { ret itr.vect.(idx); }
fn len[T](itr : &interner[T]) -> uint { ret vec::len(itr.vect); } fn len[T](itr : &interner<T>) -> uint { ret vec::len(itr.vect); }

View file

@ -14,28 +14,28 @@ import codemap::span;
// Our typesystem doesn't do circular types, so the visitor record can not // Our typesystem doesn't do circular types, so the visitor record can not
// hold functions that take visitors. A vt tag is used to break the cycle. // hold functions that take visitors. A vt tag is used to break the cycle.
tag vt[E] { mk_vt(visitor[E]); } tag vt[E] { mk_vt(visitor<E>); }
type visitor[E] = type visitor[E] =
// takes the components so that one function can be // takes the components so that one function can be
// generic over constr and ty_constr // generic over constr and ty_constr
@{visit_mod: fn(&_mod, &span, &E, &vt[E]) , @{visit_mod: fn(&_mod, &span, &E, &vt<E>),
visit_view_item: fn(&@view_item, &E, &vt[E]) , visit_view_item: fn(&@view_item, &E, &vt<E>),
visit_native_item: fn(&@native_item, &E, &vt[E]) , visit_native_item: fn(&@native_item, &E, &vt<E>),
visit_item: fn(&@item, &E, &vt[E]) , visit_item: fn(&@item, &E, &vt<E>),
visit_local: fn(&@local, &E, &vt[E]) , visit_local: fn(&@local, &E, &vt<E>),
visit_block: fn(&ast::blk, &E, &vt[E]) , visit_block: fn(&ast::blk, &E, &vt<E>),
visit_stmt: fn(&@stmt, &E, &vt[E]) , visit_stmt: fn(&@stmt, &E, &vt<E>),
visit_arm: fn(&arm, &E, &vt[E]) , visit_arm: fn(&arm, &E, &vt<E>),
visit_pat: fn(&@pat, &E, &vt[E]) , visit_pat: fn(&@pat, &E, &vt<E>),
visit_decl: fn(&@decl, &E, &vt[E]) , visit_decl: fn(&@decl, &E, &vt<E>),
visit_expr: fn(&@expr, &E, &vt[E]) , visit_expr: fn(&@expr, &E, &vt<E>),
visit_ty: fn(&@ty, &E, &vt[E]) , visit_ty: fn(&@ty, &E, &vt<E>),
visit_constr: fn(&path, &span, node_id, &E, &vt[E]) , visit_constr: fn(&path, &span, node_id, &E, &vt<E>),
visit_fn: visit_fn:
fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt[E]) }; fn(&_fn, &[ty_param], &span, &fn_ident, node_id, &E, &vt<E>) };
fn default_visitor[E]() -> visitor[E] { fn default_visitor[E]() -> visitor<E> {
ret @{visit_mod: bind visit_mod[E](_, _, _, _), ret @{visit_mod: bind visit_mod[E](_, _, _, _),
visit_view_item: bind visit_view_item[E](_, _, _), visit_view_item: bind visit_view_item[E](_, _, _),
visit_native_item: bind visit_native_item[E](_, _, _), visit_native_item: bind visit_native_item[E](_, _, _),
@ -52,11 +52,11 @@ fn default_visitor[E]() -> visitor[E] {
visit_fn: bind visit_fn[E](_, _, _, _, _, _, _)}; visit_fn: bind visit_fn[E](_, _, _, _, _, _, _)};
} }
fn visit_crate[E](c: &crate, e: &E, v: &vt[E]) { fn visit_crate[E](c: &crate, e: &E, v: &vt<E>) {
v.visit_mod(c.node.module, c.span, e, v); v.visit_mod(c.node.module, c.span, e, v);
} }
fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt[E]) { fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt<E>) {
alt cd.node { alt cd.node {
cdir_src_mod(_, _, _) { } cdir_src_mod(_, _, _) { }
cdir_dir_mod(_, _, cdirs, _) { cdir_dir_mod(_, _, cdirs, _) {
@ -70,20 +70,20 @@ fn visit_crate_directive[E](cd: &@crate_directive, e: &E, v: &vt[E]) {
} }
} }
fn visit_mod[E](m: &_mod, sp: &span, e: &E, v: &vt[E]) { fn visit_mod[E](m: &_mod, sp: &span, e: &E, v: &vt<E>) {
for vi: @view_item in m.view_items { v.visit_view_item(vi, e, v); } for vi: @view_item in m.view_items { v.visit_view_item(vi, e, v); }
for i: @item in m.items { v.visit_item(i, e, v); } for i: @item in m.items { v.visit_item(i, e, v); }
} }
fn visit_view_item[E](vi: &@view_item, e: &E, v: &vt[E]) { } fn visit_view_item[E](vi: &@view_item, e: &E, v: &vt<E>) { }
fn visit_local[E](loc: &@local, 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_pat(loc.node.pat, e, v);
v.visit_ty(loc.node.ty, 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]) { fn visit_item[E](i: &@item, e: &E, v: &vt<E>) {
alt i.node { alt i.node {
item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); } item_const(t, ex) { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); }
item_fn(f, tp) { v.visit_fn(f, tp, i.span, some(i.ident), i.id, e, v); } item_fn(f, tp) { v.visit_fn(f, tp, i.span, some(i.ident), i.id, e, v); }
@ -111,7 +111,7 @@ fn visit_item[E](i: &@item, e: &E, v: &vt[E]) {
} }
} }
fn visit_ty[E](t: &@ty, e: &E, v: &vt[E]) { fn visit_ty[E](t: &@ty, e: &E, v: &vt<E>) {
alt t.node { alt t.node {
ty_nil. {/* no-op */ } ty_nil. {/* no-op */ }
ty_bot. {/* no-op */ } ty_bot. {/* no-op */ }
@ -153,7 +153,7 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt[E]) {
ty_type. {/* no-op */ } ty_type. {/* no-op */ }
ty_constr(t, cs) { ty_constr(t, cs) {
v.visit_ty(t, e, v); v.visit_ty(t, e, v);
for tc: @spanned[constr_general_[path, node_id]] in cs { for tc: @spanned<constr_general_<path, node_id>> in cs {
v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v); v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v);
} }
} }
@ -162,11 +162,11 @@ fn visit_ty[E](t: &@ty, e: &E, v: &vt[E]) {
} }
fn visit_constr[E](operator: &path, sp: &span, id: node_id, e: &E, fn visit_constr[E](operator: &path, sp: &span, id: node_id, e: &E,
v: &vt[E]) { v: &vt<E>) {
// default // default
} }
fn visit_pat[E](p: &@pat, e: &E, v: &vt[E]) { fn visit_pat[E](p: &@pat, e: &E, v: &vt<E>) {
alt p.node { alt p.node {
pat_tag(path, children) { pat_tag(path, children) {
for tp: @ty in path.node.types { v.visit_ty(tp, e, v); } for tp: @ty in path.node.types { v.visit_ty(tp, e, v); }
@ -183,14 +183,14 @@ fn visit_pat[E](p: &@pat, e: &E, v: &vt[E]) {
} }
} }
fn visit_native_item[E](ni: &@native_item, e: &E, v: &vt[E]) { fn visit_native_item[E](ni: &@native_item, e: &E, v: &vt<E>) {
alt ni.node { alt ni.node {
native_item_fn(_, fd, _) { visit_fn_decl(fd, e, v); } native_item_fn(_, fd, _) { visit_fn_decl(fd, e, v); }
native_item_ty. { } native_item_ty. { }
} }
} }
fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt[E]) { fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt<E>) {
for a: arg in fd.inputs { v.visit_ty(a.ty, e, v); } for a: arg in fd.inputs { v.visit_ty(a.ty, e, v); }
for c: @constr in fd.constraints { for c: @constr in fd.constraints {
v.visit_constr(c.node.path, c.span, c.node.id, e, v); v.visit_constr(c.node.path, c.span, c.node.id, e, v);
@ -199,17 +199,17 @@ fn visit_fn_decl[E](fd: &fn_decl, e: &E, v: &vt[E]) {
} }
fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id, fn visit_fn[E](f: &_fn, tp: &[ty_param], sp: &span, i: &fn_ident, id: node_id,
e: &E, v: &vt[E]) { e: &E, v: &vt<E>) {
visit_fn_decl(f.decl, e, v); visit_fn_decl(f.decl, e, v);
v.visit_block(f.body, e, v); v.visit_block(f.body, e, v);
} }
fn visit_block[E](b: &ast::blk, e: &E, v: &vt[E]) { fn visit_block[E](b: &ast::blk, e: &E, v: &vt<E>) {
for s: @stmt in b.node.stmts { v.visit_stmt(s, e, v); } for s: @stmt in b.node.stmts { v.visit_stmt(s, e, v); }
visit_expr_opt(b.node.expr, e, v); visit_expr_opt(b.node.expr, e, v);
} }
fn visit_stmt[E](s: &@stmt, e: &E, v: &vt[E]) { fn visit_stmt[E](s: &@stmt, e: &E, v: &vt<E>) {
alt s.node { alt s.node {
stmt_decl(d, _) { v.visit_decl(d, e, v); } stmt_decl(d, _) { v.visit_decl(d, e, v); }
stmt_expr(ex, _) { v.visit_expr(ex, e, v); } stmt_expr(ex, _) { v.visit_expr(ex, e, v); }
@ -217,7 +217,7 @@ fn visit_stmt[E](s: &@stmt, e: &E, v: &vt[E]) {
} }
} }
fn visit_decl[E](d: &@decl, e: &E, v: &vt[E]) { fn visit_decl[E](d: &@decl, e: &E, v: &vt<E>) {
alt d.node { alt d.node {
decl_local(locs) { decl_local(locs) {
for loc: @ast::local in locs { v.visit_local(loc, e, v); } for loc: @ast::local in locs { v.visit_local(loc, e, v); }
@ -226,15 +226,15 @@ 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]) { 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]) { fn visit_exprs[E](exprs: &[@expr], e: &E, v: &vt<E>) {
for ex: @expr in exprs { v.visit_expr(ex, e, v); } for ex: @expr in exprs { v.visit_expr(ex, e, v); }
} }
fn visit_mac[E](m: mac, e: &E, v: &vt[E]) { fn visit_mac[E](m: mac, e: &E, v: &vt<E>) {
alt m.node { alt m.node {
ast::mac_invoc(pth, arg, body) { visit_expr(arg, e, v); } 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_type(ty) { v.visit_ty(ty, e, v); }
@ -243,7 +243,7 @@ fn visit_mac[E](m: mac, e: &E, v: &vt[E]) {
} }
} }
fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) { fn visit_expr[E](ex: &@expr, e: &E, v: &vt<E>) {
alt ex.node { alt ex.node {
expr_vec(es, _, _) { visit_exprs(es, e, v); } expr_vec(es, _, _) { visit_exprs(es, e, v); }
expr_rec(flds, base) { expr_rec(flds, base) {
@ -260,7 +260,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) {
expr_self_method(_) { } expr_self_method(_) { }
expr_bind(callee, args) { expr_bind(callee, args) {
v.visit_expr(callee, e, v); v.visit_expr(callee, e, v);
for eo: option::t[@expr] in args { visit_expr_opt(eo, e, v); } for eo: option::t<@expr> in args { visit_expr_opt(eo, e, v); }
} }
expr_binary(_, a, b) { v.visit_expr(a, e, v); v.visit_expr(b, e, v); } expr_binary(_, a, b) { v.visit_expr(a, e, v); v.visit_expr(b, e, v); }
expr_unary(_, a) { v.visit_expr(a, e, v); } expr_unary(_, a) { v.visit_expr(a, e, v); }
@ -338,7 +338,7 @@ fn visit_expr[E](ex: &@expr, e: &E, v: &vt[E]) {
} }
} }
fn visit_arm[E](a: &arm, e: &E, v: &vt[E]) { fn visit_arm[E](a: &arm, e: &E, v: &vt<E>) {
for p: @pat in a.pats { v.visit_pat(p, e, v); } for p: @pat in a.pats { v.visit_pat(p, e, v); }
v.visit_block(a.body, e, v); v.visit_block(a.body, e, v);
} }
@ -384,64 +384,64 @@ fn default_simple_visitor() -> simple_visitor {
}}; }};
} }
fn mk_simple_visitor(v: &simple_visitor) -> vt[()] { fn mk_simple_visitor(v: &simple_visitor) -> vt<()> {
fn v_mod(f: fn(&_mod, &span) , m: &_mod, sp: &span, e: &(), v: &vt[()]) { fn v_mod(f: fn(&_mod, &span) , m: &_mod, sp: &span, e: &(), v: &vt<()>) {
f(m, sp); f(m, sp);
visit_mod(m, sp, e, v); visit_mod(m, sp, e, v);
} }
fn v_view_item(f: fn(&@view_item) , vi: &@view_item, e: &(), v: &vt[()]) { fn v_view_item(f: fn(&@view_item) , vi: &@view_item, e: &(), v: &vt<()>) {
f(vi); f(vi);
visit_view_item(vi, e, v); visit_view_item(vi, e, v);
} }
fn v_native_item(f: fn(&@native_item) , ni: &@native_item, e: &(), fn v_native_item(f: fn(&@native_item) , ni: &@native_item, e: &(),
v: &vt[()]) { v: &vt<()>) {
f(ni); f(ni);
visit_native_item(ni, e, v); visit_native_item(ni, e, v);
} }
fn v_item(f: fn(&@item) , i: &@item, e: &(), v: &vt[()]) { fn v_item(f: fn(&@item) , i: &@item, e: &(), v: &vt<()>) {
f(i); f(i);
visit_item(i, e, v); visit_item(i, e, v);
} }
fn v_local(f: fn(&@local) , l: &@local, e: &(), v: &vt[()]) { fn v_local(f: fn(&@local) , l: &@local, e: &(), v: &vt<()>) {
f(l); f(l);
visit_local(l, e, v); visit_local(l, e, v);
} }
fn v_block(f: fn(&ast::blk) , bl: &ast::blk, e: &(), v: &vt[()]) { fn v_block(f: fn(&ast::blk) , bl: &ast::blk, e: &(), v: &vt<()>) {
f(bl); f(bl);
visit_block(bl, e, v); visit_block(bl, e, v);
} }
fn v_stmt(f: fn(&@stmt) , st: &@stmt, e: &(), v: &vt[()]) { fn v_stmt(f: fn(&@stmt) , st: &@stmt, e: &(), v: &vt<()>) {
f(st); f(st);
visit_stmt(st, e, v); visit_stmt(st, e, v);
} }
fn v_arm(f: fn(&arm) , a: &arm, e: &(), v: &vt[()]) { fn v_arm(f: fn(&arm) , a: &arm, e: &(), v: &vt<()>) {
f(a); f(a);
visit_arm(a, e, v); visit_arm(a, e, v);
} }
fn v_pat(f: fn(&@pat) , p: &@pat, e: &(), v: &vt[()]) { fn v_pat(f: fn(&@pat) , p: &@pat, e: &(), v: &vt<()>) {
f(p); f(p);
visit_pat(p, e, v); visit_pat(p, e, v);
} }
fn v_decl(f: fn(&@decl) , d: &@decl, e: &(), v: &vt[()]) { fn v_decl(f: fn(&@decl) , d: &@decl, e: &(), v: &vt<()>) {
f(d); f(d);
visit_decl(d, e, v); visit_decl(d, e, v);
} }
fn v_expr(f: fn(&@expr) , ex: &@expr, e: &(), v: &vt[()]) { fn v_expr(f: fn(&@expr) , ex: &@expr, e: &(), v: &vt<()>) {
f(ex); f(ex);
visit_expr(ex, e, v); visit_expr(ex, e, v);
} }
fn v_ty(f: fn(&@ty) , ty: &@ty, e: &(), v: &vt[()]) { fn v_ty(f: fn(&@ty) , ty: &@ty, e: &(), v: &vt<()>) {
f(ty); f(ty);
visit_ty(ty, e, v); visit_ty(ty, e, v);
} }
fn v_constr(f: fn(&path, &span, node_id) , pt: &path, sp: &span, fn v_constr(f: fn(&path, &span, node_id) , pt: &path, sp: &span,
id: node_id, e: &(), v: &vt[()]) { id: node_id, e: &(), v: &vt<()>) {
f(pt, sp, id); f(pt, sp, id);
visit_constr(pt, sp, id, e, v); visit_constr(pt, sp, id, e, v);
} }
fn v_fn(f: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) , ff: &_fn, fn v_fn(f: fn(&_fn, &[ty_param], &span, &fn_ident, node_id) , ff: &_fn,
tps: &[ty_param], sp: &span, ident: &fn_ident, id: node_id, tps: &[ty_param], sp: &span, ident: &fn_ident, id: node_id,
e: &(), v: &vt[()]) { e: &(), v: &vt<()>) {
f(ff, tps, sp, ident, id); f(ff, tps, sp, ident, id);
visit_fn(ff, tps, sp, ident, id, e, v); visit_fn(ff, tps, sp, ident, id, e, v);
} }

View file

@ -28,7 +28,7 @@ import print::pprust::print_type;
import print::pprust::print_literal; import print::pprust::print_literal;
import print::pp::mk_printer; import print::pp::mk_printer;
type flag = hashmap[str, ()]; type flag = hashmap<str, ()>;
fn def_eq(a: &ast::def_id, b: &ast::def_id) -> bool { fn def_eq(a: &ast::def_id, b: &ast::def_id) -> bool {
ret a.crate == b.crate && a.node == b.node; ret a.crate == b.crate && a.node == b.node;
@ -41,9 +41,9 @@ fn hash_def(d: &ast::def_id) -> uint {
ret h; ret h;
} }
fn new_def_hash[@V]() -> std::map::hashmap[ast::def_id, V] { fn new_def_hash[@V]() -> std::map::hashmap<ast::def_id, V> {
let hasher: std::map::hashfn[ast::def_id] = hash_def; let hasher: std::map::hashfn<ast::def_id> = hash_def;
let eqer: std::map::eqfn[ast::def_id] = def_eq; let eqer: std::map::eqfn<ast::def_id> = def_eq;
ret std::map::mk_hashmap[ast::def_id, V](hasher, eqer); ret std::map::mk_hashmap[ast::def_id, V](hasher, eqer);
} }

View file

@ -41,7 +41,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
let s = mode_str(input.mode); let s = mode_str(input.mode);
ret s + ty_to_str(cx, input.ty); ret s + ty_to_str(cx, input.ty);
} }
fn fn_to_str(cx: &ctxt, proto: ast::proto, ident: option::t[ast::ident], fn fn_to_str(cx: &ctxt, proto: ast::proto, ident: option::t<ast::ident>,
inputs: &[arg], output: t, cf: ast::controlflow, inputs: &[arg], output: t, cf: ast::controlflow,
constrs: &[@constr]) -> str { constrs: &[@constr]) -> str {
let s = proto_to_str(proto); let s = proto_to_str(proto);
@ -92,7 +92,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
ty_istr. { s += "istr"; } ty_istr. { s += "istr"; }
ty_box(tm) { s += "@" + mt_to_str(cx, tm); } ty_box(tm) { s += "@" + mt_to_str(cx, tm); }
ty_uniq(t) { s += "~" + ty_to_str(cx, t); } ty_uniq(t) { s += "~" + ty_to_str(cx, t); }
ty_vec(tm) { s += "vec[" + mt_to_str(cx, tm) + "]"; } ty_vec(tm) { s += "vec<" + mt_to_str(cx, tm) + ">"; }
ty_ivec(tm) { s += "[" + mt_to_str(cx, tm) + "]"; } ty_ivec(tm) { s += "[" + mt_to_str(cx, tm) + "]"; }
ty_type. { s += "type"; } ty_type. { s += "type"; }
ty_rec(elems) { ty_rec(elems) {
@ -162,7 +162,7 @@ fn constrs_str(constrs: &[@constr]) -> str {
ret s; ret s;
} }
fn ty_constr_to_str[Q](c: &@ast::spanned[ast::constr_general_[ast::path, Q]]) fn ty_constr_to_str[Q](c: &@ast::spanned<ast::constr_general_<ast::path, Q>>)
-> str { -> str {
ret path_to_str(c.node.path) + ret path_to_str(c.node.path) +
constr_args_to_str[ast::path](path_to_str, c.node.args); constr_args_to_str[ast::path](path_to_str, c.node.args);