aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-12 17:24:54 +0200
committerMarijn Haverbeke <[email protected]>2011-05-12 21:30:44 +0200
commit3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2 (patch)
tree508982ed2f789aedd89eebd529343d9dc88b8e01 /src/comp/middle
parentTransitional change to make extfmt output lowercase module name (diff)
downloadrust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.tar.xz
rust-3816e57fd2a8ab19e4ac6d4b3ddd5b49d5973ff2.zip
Downcase std modules again, move to :: for module dereferencing
This should be a snapshot transition.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/capture.rs86
-rw-r--r--src/comp/middle/fold.rs749
-rw-r--r--src/comp/middle/metadata.rs514
-rw-r--r--src/comp/middle/resolve.rs446
-rw-r--r--src/comp/middle/trans.rs2875
-rw-r--r--src/comp/middle/ty.rs800
-rw-r--r--src/comp/middle/typeck.rs2017
-rw-r--r--src/comp/middle/typestate_check.rs725
-rw-r--r--src/comp/middle/walk.rs314
9 files changed, 4276 insertions, 4250 deletions
diff --git a/src/comp/middle/capture.rs b/src/comp/middle/capture.rs
index 7aa64fdb..7124554a 100644
--- a/src/comp/middle/capture.rs
+++ b/src/comp/middle/capture.rs
@@ -1,73 +1,73 @@
-import driver.session;
-import front.ast;
-import std.Map.hashmap;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
-import std.Int;
-import std.Vec;
-import util.common;
-import resolve.def_map;
+import driver::session;
+import front::ast;
+import std::map::hashmap;
+import std::option;
+import std::option::some;
+import std::option::none;
+import std::_int;
+import std::_vec;
+import util::common;
+import resolve::def_map;
-type fn_id_of_local = std.Map.hashmap[ast.def_id, ast.def_id];
-type env = rec(mutable vec[ast.def_id] current_context, // fn or obj
+type fn_id_of_local = std::map::hashmap[ast::def_id, ast::def_id];
+type env = rec(mutable vec[ast::def_id] current_context, // fn or obj
def_map def_map,
fn_id_of_local idmap,
- session.session sess);
+ session::session sess);
-fn current_context(&env e) -> ast.def_id {
- ret e.current_context.(Vec.len(e.current_context) - 1u);
+fn current_context(&env e) -> ast::def_id {
+ ret e.current_context.(_vec::len(e.current_context) - 1u);
}
-fn enter_item(@env e, &@ast.item i) {
+fn enter_item(@env e, &@ast::item i) {
alt (i.node) {
- case (ast.item_fn(?name, _, _, ?id, _)) {
- Vec.push(e.current_context, id);
+ case (ast::item_fn(?name, _, _, ?id, _)) {
+ _vec::push(e.current_context, id);
}
- case (ast.item_obj(?name, _, _, ?ids, _)) {
- Vec.push(e.current_context, ids.ty);
+ case (ast::item_obj(?name, _, _, ?ids, _)) {
+ _vec::push(e.current_context, ids.ty);
}
case (_) {}
}
}
-fn leave_item(@env e, &@ast.item i) {
+fn leave_item(@env e, &@ast::item i) {
alt (i.node) {
- case (ast.item_fn(?name, _, _, ?id, _)) {
- Vec.pop(e.current_context);
+ case (ast::item_fn(?name, _, _, ?id, _)) {
+ _vec::pop(e.current_context);
}
- case (ast.item_obj(_, _, _, ?ids, _)) {
- Vec.pop(e.current_context);
+ case (ast::item_obj(_, _, _, ?ids, _)) {
+ _vec::pop(e.current_context);
}
case (_) {}
}
}
-fn walk_expr(@env e, &@ast.expr x) {
+fn walk_expr(@env e, &@ast::expr x) {
alt (x.node) {
- case (ast.expr_for(?d, _, _, _)) {
+ case (ast::expr_for(?d, _, _, _)) {
alt (d.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
e.idmap.insert(local.id, current_context(*e));
}
case (_) { }
}
}
- case (ast.expr_for_each(?d, _, _, _)) {
+ case (ast::expr_for_each(?d, _, _, _)) {
alt (d.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
e.idmap.insert(local.id, current_context(*e));
}
case (_) { }
}
}
- case (ast.expr_path(?pt, ?ann)) {
+ case (ast::expr_path(?pt, ?ann)) {
auto local_id;
- alt (e.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_local(?id)) { local_id = id; }
+ alt (e.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_local(?id)) { local_id = id; }
case (_) { ret; }
}
- auto df = ast.def_id_of_def(e.def_map.get(ast.ann_tag(ann)));
+ auto df = ast::def_id_of_def(e.def_map.get(ast::ann_tag(ann)));
auto def_context = e.idmap.get(df);
if (current_context(*e) != def_context) {
@@ -79,12 +79,12 @@ fn walk_expr(@env e, &@ast.expr x) {
}
}
-fn walk_block(@env e, &ast.block b) {
- for (@ast.stmt st in b.node.stmts) {
+fn walk_block(@env e, &ast::block b) {
+ for (@ast::stmt st in b.node.stmts) {
alt (st.node) {
- case (ast.stmt_decl(?d,_)) {
+ case (ast::stmt_decl(?d,_)) {
alt (d.node) {
- case (ast.decl_local(?loc)) {
+ case (ast::decl_local(?loc)) {
e.idmap.insert(loc.id, current_context(*e));
}
case (_) { }
@@ -95,18 +95,18 @@ fn walk_block(@env e, &ast.block b) {
}
}
-fn check_for_captures(session.session sess, @ast.crate crate, def_map dm) {
- let vec[ast.def_id] curctx = vec();
+fn check_for_captures(session::session sess, @ast::crate crate, def_map dm) {
+ let vec[ast::def_id] curctx = vec();
auto env = @rec(mutable current_context = curctx,
def_map = dm,
- idmap = common.new_def_hash[ast.def_id](),
+ idmap = common::new_def_hash[ast::def_id](),
sess = sess);
auto visitor = rec(visit_item_pre = bind enter_item(env, _),
visit_item_post = bind leave_item(env, _),
visit_block_pre = bind walk_block(env, _),
visit_expr_pre = bind walk_expr(env, _)
- with walk.default_visitor());
- walk.walk_crate(visitor, *crate);
+ with walk::default_visitor());
+ walk::walk_crate(visitor, *crate);
}
// Local Variables:
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs
index d3426684..5af85f14 100644
--- a/src/comp/middle/fold.rs
+++ b/src/comp/middle/fold.rs
@@ -1,45 +1,45 @@
-import std.Map.hashmap;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
-
-import util.common.new_str_hash;
-import util.common.spanned;
-import util.common.span;
-import util.common.ty_mach;
-import util.typestate_ann.ts_ann;
-
-import front.ast;
-import front.ast.fn_decl;
-import front.ast.ident;
-import front.ast.path;
-import front.ast.mutability;
-import front.ast.ty;
-import front.ast.expr;
-import front.ast.stmt;
-import front.ast.block;
-import front.ast.item;
-import front.ast.view_item;
-import front.ast.meta_item;
-import front.ast.native_item;
-import front.ast.arg;
-import front.ast.pat;
-import front.ast.decl;
-import front.ast.arm;
-import front.ast.def;
-import front.ast.def_id;
-import front.ast.ann;
-import front.ast.mt;
-import front.ast.purity;
-
-import std.UInt;
-import std.Vec;
+import std::map::hashmap;
+import std::option;
+import std::option::some;
+import std::option::none;
+
+import util::common::new_str_hash;
+import util::common::spanned;
+import util::common::span;
+import util::common::ty_mach;
+import util::typestate_ann::ts_ann;
+
+import front::ast;
+import front::ast::fn_decl;
+import front::ast::ident;
+import front::ast::path;
+import front::ast::mutability;
+import front::ast::ty;
+import front::ast::expr;
+import front::ast::stmt;
+import front::ast::block;
+import front::ast::item;
+import front::ast::view_item;
+import front::ast::meta_item;
+import front::ast::native_item;
+import front::ast::arg;
+import front::ast::pat;
+import front::ast::decl;
+import front::ast::arm;
+import front::ast::def;
+import front::ast::def_id;
+import front::ast::ann;
+import front::ast::mt;
+import front::ast::purity;
+
+import std::_uint;
+import std::_vec;
type ast_fold[ENV] =
@rec
(
- // Path fold.
- (fn(&ENV e, &span sp, &ast.path_ p) -> path) fold_path,
+ // Path fold:
+ (fn(&ENV e, &span sp, &ast::path_ p) -> path) fold_path,
// Type folds.
(fn(&ENV e, &span sp) -> @ty) fold_ty_nil,
@@ -56,17 +56,17 @@ type ast_fold[ENV] =
(fn(&ENV e, &span sp, &vec[mt] elts) -> @ty) fold_ty_tup,
(fn(&ENV e, &span sp,
- &vec[ast.ty_field] elts) -> @ty) fold_ty_rec,
+ &vec[ast::ty_field] elts) -> @ty) fold_ty_rec,
(fn(&ENV e, &span sp,
- &vec[ast.ty_method] meths) -> @ty) fold_ty_obj,
+ &vec[ast::ty_method] meths) -> @ty) fold_ty_obj,
(fn(&ENV e, &span sp,
- ast.proto proto,
- &vec[rec(ast.mode mode, @ty ty)] inputs,
+ ast::proto proto,
+ &vec[rec(ast::mode mode, @ty ty)] inputs,
&@ty output) -> @ty) fold_ty_fn,
- (fn(&ENV e, &span sp, &ast.path p,
+ (fn(&ENV e, &span sp, &ast::path p,
&ann a) -> @ty) fold_ty_path,
(fn(&ENV e, &span sp, &@ty t) -> @ty) fold_ty_chan,
@@ -74,15 +74,15 @@ type ast_fold[ENV] =
// Expr folds.
(fn(&ENV e, &span sp,
- &vec[@expr] es, ast.mutability mut,
+ &vec[@expr] es, ast::mutability mut,
&ann a) -> @expr) fold_expr_vec,
(fn(&ENV e, &span sp,
- &vec[ast.elt] es, &ann a) -> @expr) fold_expr_tup,
+ &vec[ast::elt] es, &ann a) -> @expr) fold_expr_tup,
(fn(&ENV e, &span sp,
- &vec[ast.field] fields,
- &Option.t[@expr] base, &ann a) -> @expr) fold_expr_rec,
+ &vec[ast::field] fields,
+ &option::t[@expr] base, &ann a) -> @expr) fold_expr_rec,
(fn(&ENV e, &span sp,
&@expr f, &vec[@expr] args,
@@ -92,33 +92,33 @@ type ast_fold[ENV] =
&ident id, &ann a) -> @expr) fold_expr_self_method,
(fn(&ENV e, &span sp,
- &@expr f, &vec[Option.t[@expr]] args,
+ &@expr f, &vec[option::t[@expr]] args,
&ann a) -> @expr) fold_expr_bind,
(fn(&ENV e, &span sp,
- ast.spawn_dom dom, &Option.t[str] name,
+ ast::spawn_dom dom, &option::t[str] name,
&@expr f, &vec[@expr] args,
&ann a) -> @expr) fold_expr_spawn,
(fn(&ENV e, &span sp,
- ast.binop,
+ ast::binop,
&@expr lhs, &@expr rhs,
&ann a) -> @expr) fold_expr_binary,
(fn(&ENV e, &span sp,
- ast.unop, &@expr e,
+ ast::unop, &@expr e,
&ann a) -> @expr) fold_expr_unary,
(fn(&ENV e, &span sp,
- &@ast.lit, &ann a) -> @expr) fold_expr_lit,
+ &@ast::lit, &ann a) -> @expr) fold_expr_lit,
(fn(&ENV e, &span sp,
- &@ast.expr e, &@ast.ty ty,
+ &@ast::expr e, &@ast::ty ty,
&ann a) -> @expr) fold_expr_cast,
(fn(&ENV e, &span sp,
&@expr cond, &block thn,
- &Option.t[@expr] els,
+ &option::t[@expr] els,
&ann a) -> @expr) fold_expr_if,
(fn(&ENV e, &span sp,
@@ -149,7 +149,7 @@ type ast_fold[ENV] =
&ann a) -> @expr) fold_expr_assign,
(fn(&ENV e, &span sp,
- ast.binop,
+ ast::binop,
&@expr lhs, &@expr rhs,
&ann a) -> @expr) fold_expr_assign_op,
@@ -175,7 +175,7 @@ type ast_fold[ENV] =
(fn(&ENV e, &span sp,
&path p, &vec[@expr] args,
- &Option.t[str] body,
+ &option::t[str] body,
&@expr expanded,
&ann a) -> @expr) fold_expr_ext,
@@ -186,10 +186,10 @@ type ast_fold[ENV] =
(fn(&ENV e, &span sp, &ann a) -> @expr) fold_expr_cont,
(fn(&ENV e, &span sp,
- &Option.t[@expr] rv, &ann a) -> @expr) fold_expr_ret,
+ &option::t[@expr] rv, &ann a) -> @expr) fold_expr_ret,
(fn(&ENV e, &span sp,
- &Option.t[@expr] rv, &ann a) -> @expr) fold_expr_put,
+ &option::t[@expr] rv, &ann a) -> @expr) fold_expr_put,
(fn(&ENV e, &span sp,
&@expr e, &ann a) -> @expr) fold_expr_be,
@@ -212,7 +212,7 @@ type ast_fold[ENV] =
// Decl folds.
(fn(&ENV e, &span sp,
- &@ast.local local) -> @decl) fold_decl_local,
+ &@ast::local local) -> @decl) fold_decl_local,
(fn(&ENV e, &span sp,
&@item item) -> @decl) fold_decl_item,
@@ -223,7 +223,7 @@ type ast_fold[ENV] =
&ann a) -> @pat) fold_pat_wild,
(fn(&ENV e, &span sp,
- &@ast.lit lit, &ann a) -> @pat) fold_pat_lit,
+ &@ast::lit lit, &ann a) -> @pat) fold_pat_lit,
(fn(&ENV e, &span sp,
&ident i, &def_id did, &ann a) -> @pat) fold_pat_bind,
@@ -248,44 +248,44 @@ type ast_fold[ENV] =
&def_id id, &ann a) -> @item) fold_item_const,
(fn(&ENV e, &span sp, &ident ident,
- &ast._fn f,
- &vec[ast.ty_param] ty_params,
+ &ast::_fn f,
+ &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item) fold_item_fn,
(fn(&ENV e, &span sp, &ident ident,
- &Option.t[str] link_name,
- &ast.fn_decl decl,
- &vec[ast.ty_param] ty_params,
+ &option::t[str] link_name,
+ &ast::fn_decl decl,
+ &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @native_item) fold_native_item_fn,
(fn(&ENV e, &span sp, &ident ident,
- &ast._mod m, &def_id id) -> @item) fold_item_mod,
+ &ast::_mod m, &def_id id) -> @item) fold_item_mod,
(fn(&ENV e, &span sp, &ident ident,
- &ast.native_mod m, &def_id id) -> @item) fold_item_native_mod,
+ &ast::native_mod m, &def_id id) -> @item) fold_item_native_mod,
(fn(&ENV e, &span sp, &ident ident,
- &@ty t, &vec[ast.ty_param] ty_params,
+ &@ty t, &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item) fold_item_ty,
(fn(&ENV e, &span sp, &ident ident,
&def_id id) -> @native_item) fold_native_item_ty,
(fn(&ENV e, &span sp, &ident ident,
- &vec[ast.variant] variants,
- &vec[ast.ty_param] ty_params,
+ &vec[ast::variant] variants,
+ &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item) fold_item_tag,
(fn(&ENV e, &span sp, &ident ident,
- &ast._obj ob,
- &vec[ast.ty_param] ty_params,
- &ast.obj_def_ids odid, &ann a) -> @item) fold_item_obj,
+ &ast::_obj ob,
+ &vec[ast::ty_param] ty_params,
+ &ast::obj_def_ids odid, &ann a) -> @item) fold_item_obj,
// View Item folds.
(fn(&ENV e, &span sp, &ident ident,
&vec[@meta_item] meta_items,
&def_id id,
- &Option.t[int]) -> @view_item) fold_view_item_use,
+ &option::t[int]) -> @view_item) fold_view_item_use,
(fn(&ENV e, &span sp, &ident i,
&vec[ident] idents,
@@ -300,30 +300,30 @@ type ast_fold[ENV] =
// Additional nodes.
(fn(&ENV e, &fn_decl decl,
- ast.proto proto,
- &block body) -> ast._fn) fold_fn,
+ ast::proto proto,
+ &block body) -> ast::_fn) fold_fn,
(fn(&ENV e,
&vec[arg] inputs,
&@ty output,
- &purity p) -> ast.fn_decl) fold_fn_decl,
+ &purity p) -> ast::fn_decl) fold_fn_decl,
- (fn(&ENV e, &ast._mod m) -> ast._mod) fold_mod,
+ (fn(&ENV e, &ast::_mod m) -> ast::_mod) fold_mod,
- (fn(&ENV e, &ast.native_mod m) -> ast.native_mod) fold_native_mod,
+ (fn(&ENV e, &ast::native_mod m) -> ast::native_mod) fold_native_mod,
(fn(&ENV e, &span sp,
- &vec[@ast.crate_directive] cdirs,
- &ast._mod m) -> @ast.crate) fold_crate,
+ &vec[@ast::crate_directive] cdirs,
+ &ast::_mod m) -> @ast::crate) fold_crate,
(fn(&ENV e,
- &vec[ast.obj_field] fields,
- &vec[@ast.method] methods,
- &Option.t[@ast.method] dtor)
- -> ast._obj) fold_obj,
+ &vec[ast::obj_field] fields,
+ &vec[@ast::method] methods,
+ &option::t[@ast::method] dtor)
+ -> ast::_obj) fold_obj,
// Env updates.
- (fn(&ENV e, &@ast.crate c) -> ENV) update_env_for_crate,
+ (fn(&ENV e, &@ast::crate c) -> ENV) update_env_for_crate,
(fn(&ENV e, &@item i) -> ENV) update_env_for_item,
(fn(&ENV e, &@native_item i) -> ENV) update_env_for_native_item,
(fn(&ENV e, &@view_item i) -> ENV) update_env_for_view_item,
@@ -343,11 +343,11 @@ type ast_fold[ENV] =
//// Fold drivers.
fn fold_path[ENV](&ENV env, &ast_fold[ENV] fld, &path p) -> path {
- let vec[@ast.ty] tys_ = vec();
- for (@ast.ty t in p.node.types) {
- Vec.push[@ast.ty](tys_, fold_ty(env, fld, t));
+ let vec[@ast::ty] tys_ = vec();
+ for (@ast::ty t in p.node.types) {
+ _vec::push[@ast::ty](tys_, fold_ty(env, fld, t));
}
- let ast.path_ p_ = rec(idents=p.node.idents, types=tys_);
+ let ast::path_ p_ = rec(idents=p.node.idents, types=tys_);
ret fld.fold_path(env, p.span, p_);
}
@@ -359,56 +359,56 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
}
alt (t.node) {
- case (ast.ty_nil) { ret fld.fold_ty_nil(env_, t.span); }
- case (ast.ty_bool) { ret fld.fold_ty_bool(env_, t.span); }
- case (ast.ty_int) { ret fld.fold_ty_int(env_, t.span); }
- case (ast.ty_uint) { ret fld.fold_ty_uint(env_, t.span); }
- case (ast.ty_float) { ret fld.fold_ty_float(env_, t.span); }
+ case (ast::ty_nil) { ret fld.fold_ty_nil(env_, t.span); }
+ case (ast::ty_bool) { ret fld.fold_ty_bool(env_, t.span); }
+ case (ast::ty_int) { ret fld.fold_ty_int(env_, t.span); }
+ case (ast::ty_uint) { ret fld.fold_ty_uint(env_, t.span); }
+ case (ast::ty_float) { ret fld.fold_ty_float(env_, t.span); }
- case (ast.ty_machine(?m)) {
+ case (ast::ty_machine(?m)) {
ret fld.fold_ty_machine(env_, t.span, m);
}
- case (ast.ty_char) { ret fld.fold_ty_char(env_, t.span); }
- case (ast.ty_str) { ret fld.fold_ty_str(env_, t.span); }
+ case (ast::ty_char) { ret fld.fold_ty_char(env_, t.span); }
+ case (ast::ty_str) { ret fld.fold_ty_str(env_, t.span); }
- case (ast.ty_box(?tm)) {
+ case (ast::ty_box(?tm)) {
auto ty_ = fold_ty(env, fld, tm.ty);
ret fld.fold_ty_box(env_, t.span, rec(ty=ty_, mut=tm.mut));
}
- case (ast.ty_vec(?tm)) {
+ case (ast::ty_vec(?tm)) {
auto ty_ = fold_ty(env, fld, tm.ty);
ret fld.fold_ty_vec(env_, t.span, rec(ty=ty_, mut=tm.mut));
}
- case (ast.ty_tup(?elts)) {
+ case (ast::ty_tup(?elts)) {
let vec[mt] elts_ = vec();
for (mt elt in elts) {
auto ty_ = fold_ty(env, fld, elt.ty);
- Vec.push[mt](elts_, rec(ty=ty_, mut=elt.mut));
+ _vec::push[mt](elts_, rec(ty=ty_, mut=elt.mut));
}
ret fld.fold_ty_tup(env_, t.span, elts_);
}
- case (ast.ty_rec(?flds)) {
- let vec[ast.ty_field] flds_ = vec();
- for (ast.ty_field f in flds) {
+ case (ast::ty_rec(?flds)) {
+ let vec[ast::ty_field] flds_ = vec();
+ for (ast::ty_field f in flds) {
auto ty_ = fold_ty(env, fld, f.mt.ty);
- Vec.push[ast.ty_field]
+ _vec::push[ast::ty_field]
(flds_, rec(mt=rec(ty=ty_, mut=f.mt.mut) with f));
}
ret fld.fold_ty_rec(env_, t.span, flds_);
}
- case (ast.ty_obj(?meths)) {
- let vec[ast.ty_method] meths_ = vec();
- for (ast.ty_method m in meths) {
+ case (ast::ty_obj(?meths)) {
+ let vec[ast::ty_method] meths_ = vec();
+ for (ast::ty_method m in meths) {
auto tfn = fold_ty_fn(env_, fld, t.span, m.proto,
m.inputs, m.output);
alt (tfn.node) {
- case (ast.ty_fn(?p, ?ins, ?out)) {
- Vec.push[ast.ty_method]
+ case (ast::ty_fn(?p, ?ins, ?out)) {
+ _vec::push[ast::ty_method]
(meths_, rec(proto=p, inputs=ins,
output=out with m));
}
@@ -417,21 +417,21 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
ret fld.fold_ty_obj(env_, t.span, meths_);
}
- case (ast.ty_path(?pth, ?ann)) {
+ case (ast::ty_path(?pth, ?ann)) {
auto pth_ = fold_path(env, fld, pth);
ret fld.fold_ty_path(env_, t.span, pth_, ann);
}
- case (ast.ty_fn(?proto, ?inputs, ?output)) {
+ case (ast::ty_fn(?proto, ?inputs, ?output)) {
ret fold_ty_fn(env_, fld, t.span, proto, inputs, output);
}
- case (ast.ty_chan(?ty)) {
+ case (ast::ty_chan(?ty)) {
auto ty_ = fold_ty(env, fld, ty);
ret fld.fold_ty_chan(env_, t.span, ty_);
}
- case (ast.ty_port(?ty)) {
+ case (ast::ty_port(?ty)) {
auto ty_ = fold_ty(env, fld, ty);
ret fld.fold_ty_port(env_, t.span, ty_);
}
@@ -439,12 +439,12 @@ fn fold_ty[ENV](&ENV env, &ast_fold[ENV] fld, &@ty t) -> @ty {
}
fn fold_ty_fn[ENV](&ENV env, &ast_fold[ENV] fld, &span sp,
- ast.proto proto,
- &vec[rec(ast.mode mode, @ty ty)] inputs,
+ ast::proto proto,
+ &vec[rec(ast::mode mode, @ty ty)] inputs,
&@ty output) -> @ty {
auto output_ = fold_ty(env, fld, output);
- let vec[rec(ast.mode mode, @ty ty)] inputs_ = vec();
- for (rec(ast.mode mode, @ty ty) input in inputs) {
+ let vec[rec(ast::mode mode, @ty ty)] inputs_ = vec();
+ for (rec(ast::mode mode, @ty ty) input in inputs) {
auto ty_ = fold_ty(env, fld, input.ty);
auto input_ = rec(ty=ty_ with input);
inputs_ += vec(input_);
@@ -460,29 +460,29 @@ fn fold_decl[ENV](&ENV env, &ast_fold[ENV] fld, &@decl d) -> @decl {
}
alt (d.node) {
- case (ast.decl_local(?local)) {
- auto ty_ = none[@ast.ty];
- auto init_ = none[ast.initializer];
+ case (ast::decl_local(?local)) {
+ auto ty_ = none[@ast::ty];
+ auto init_ = none[ast::initializer];
alt (local.ty) {
- case (some[@ast.ty](?t)) {
- ty_ = some[@ast.ty](fold_ty(env, fld, t));
+ case (some[@ast::ty](?t)) {
+ ty_ = some[@ast::ty](fold_ty(env, fld, t));
}
case (_) { /* fall through */ }
}
alt (local.init) {
- case (some[ast.initializer](?init)) {
+ case (some[ast::initializer](?init)) {
auto e = fold_expr(env, fld, init.expr);
- init_ = some[ast.initializer](rec(expr = e with init));
+ init_ = some[ast::initializer](rec(expr = e with init));
}
case (_) { /* fall through */ }
}
auto ann_ = fld.fold_ann(env_, local.ann);
- let @ast.local local_ =
+ let @ast::local local_ =
@rec(ty=ty_, init=init_, ann=ann_ with *local);
ret fld.fold_decl_local(env_, d.span, local_);
}
- case (ast.decl_item(?item)) {
+ case (ast::decl_item(?item)) {
auto item_ = fold_item(env_, fld, item);
ret fld.fold_decl_item(env_, d.span, item_);
}
@@ -491,7 +491,7 @@ fn fold_decl[ENV](&ENV env, &ast_fold[ENV] fld, &@decl d) -> @decl {
fail;
}
-fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast.pat p) -> @ast.pat {
+fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast::pat p) -> @ast::pat {
let ENV env_ = fld.update_env_for_pat(env, p);
if (!fld.keep_going(env_)) {
@@ -499,18 +499,18 @@ fn fold_pat[ENV](&ENV env, &ast_fold[ENV] fld, &@ast.pat p) -> @ast.pat {
}
alt (p.node) {
- case (ast.pat_wild(?t)) { ret fld.fold_pat_wild(env_, p.span, t); }
- case (ast.pat_lit(?lt, ?t)) {
+ case (ast::pat_wild(?t)) { ret fld.fold_pat_wild(env_, p.span, t); }
+ case (ast::pat_lit(?lt, ?t)) {
ret fld.fold_pat_lit(env_, p.span, lt, t);
}
- case (ast.pat_bind(?id, ?did, ?t)) {
+ case (ast::pat_bind(?id, ?did, ?t)) {
ret fld.fold_pat_bind(env_, p.span, id, did, t);
}
- case (ast.pat_tag(?path, ?pats, ?t)) {
+ case (ast::pat_tag(?path, ?pats, ?t)) {
auto ppath = fold_path(env, fld, path);
- let vec[@ast.pat] ppats = vec();
- for (@ast.pat pat in pats) {
+ let vec[@ast::pat] ppats = vec();
+ for (@ast::pat pat in pats) {
ppats += vec(fold_pat(env_, fld, pat));
}
@@ -523,17 +523,17 @@ fn fold_exprs[ENV](&ENV env, &ast_fold[ENV] fld,
&vec[@expr] es) -> vec[@expr] {
let vec[@expr] exprs = vec();
for (@expr e in es) {
- Vec.push[@expr](exprs, fold_expr(env, fld, e));
+ _vec::push[@expr](exprs, fold_expr(env, fld, e));
}
ret exprs;
}
-fn fold_tup_elt[ENV](&ENV env, &ast_fold[ENV] fld, &ast.elt e) -> ast.elt {
+fn fold_tup_elt[ENV](&ENV env, &ast_fold[ENV] fld, &ast::elt e) -> ast::elt {
ret rec(expr=fold_expr(env, fld, e.expr) with e);
}
-fn fold_rec_field[ENV](&ENV env, &ast_fold[ENV] fld, &ast.field f)
- -> ast.field {
+fn fold_rec_field[ENV](&ENV env, &ast_fold[ENV] fld, &ast::field f)
+ -> ast::field {
ret rec(expr=fold_expr(env, fld, f.expr) with f);
}
@@ -546,30 +546,30 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
}
alt (e.node) {
- case (ast.expr_vec(?es, ?mut, ?t)) {
+ case (ast::expr_vec(?es, ?mut, ?t)) {
auto ees = fold_exprs(env_, fld, es);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_vec(env_, e.span, ees, mut, t2);
}
- case (ast.expr_tup(?es, ?t)) {
- let vec[ast.elt] elts = vec();
- for (ast.elt e in es) {
+ case (ast::expr_tup(?es, ?t)) {
+ let vec[ast::elt] elts = vec();
+ for (ast::elt e in es) {
elts += vec(fold_tup_elt[ENV](env, fld, e));
}
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_tup(env_, e.span, elts, t2);
}
- case (ast.expr_rec(?fs, ?base, ?t)) {
- let vec[ast.field] fields = vec();
- let Option.t[@expr] b = none[@expr];
- for (ast.field f in fs) {
+ case (ast::expr_rec(?fs, ?base, ?t)) {
+ let vec[ast::field] fields = vec();
+ let option::t[@expr] b = none[@expr];
+ for (ast::field f in fs) {
fields += vec(fold_rec_field(env, fld, f));
}
alt (base) {
- case (none[@ast.expr]) { }
- case (some[@ast.expr](?eb)) {
+ case (none[@ast::expr]) { }
+ case (some[@ast::expr](?eb)) {
b = some[@expr](fold_expr(env_, fld, eb));
}
}
@@ -577,69 +577,69 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_rec(env_, e.span, fields, b, t2);
}
- case (ast.expr_call(?f, ?args, ?t)) {
+ case (ast::expr_call(?f, ?args, ?t)) {
auto ff = fold_expr(env_, fld, f);
auto aargs = fold_exprs(env_, fld, args);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_call(env_, e.span, ff, aargs, t2);
}
- case (ast.expr_self_method(?ident, ?t)) {
+ case (ast::expr_self_method(?ident, ?t)) {
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_self_method(env_, e.span, ident, t2);
}
- case (ast.expr_bind(?f, ?args_opt, ?t)) {
+ case (ast::expr_bind(?f, ?args_opt, ?t)) {
auto ff = fold_expr(env_, fld, f);
- let vec[Option.t[@ast.expr]] aargs_opt = vec();
- for (Option.t[@ast.expr] t_opt in args_opt) {
+ let vec[option::t[@ast::expr]] aargs_opt = vec();
+ for (option::t[@ast::expr] t_opt in args_opt) {
alt (t_opt) {
- case (none[@ast.expr]) {
- aargs_opt += vec(none[@ast.expr]);
+ case (none[@ast::expr]) {
+ aargs_opt += vec(none[@ast::expr]);
}
- case (some[@ast.expr](?e)) {
+ case (some[@ast::expr](?e)) {
aargs_opt += vec(some(fold_expr(env_, fld, e)));
}
- case (none[@ast.expr]) { /* empty */ }
+ case (none[@ast::expr]) { /* empty */ }
}
}
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_bind(env_, e.span, ff, aargs_opt, t2);
}
- case (ast.expr_spawn(?dom, ?name, ?f, ?args, ?t)) {
+ case (ast::expr_spawn(?dom, ?name, ?f, ?args, ?t)) {
auto ff = fold_expr(env_, fld, f);
auto aargs = fold_exprs(env_, fld, args);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_spawn(env_, e.span, dom, name, ff, aargs, t2);
}
- case (ast.expr_binary(?op, ?a, ?b, ?t)) {
+ case (ast::expr_binary(?op, ?a, ?b, ?t)) {
auto aa = fold_expr(env_, fld, a);
auto bb = fold_expr(env_, fld, b);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_binary(env_, e.span, op, aa, bb, t2);
}
- case (ast.expr_unary(?op, ?a, ?t)) {
+ case (ast::expr_unary(?op, ?a, ?t)) {
auto aa = fold_expr(env_, fld, a);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_unary(env_, e.span, op, aa, t2);
}
- case (ast.expr_lit(?lit, ?t)) {
+ case (ast::expr_lit(?lit, ?t)) {
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_lit(env_, e.span, lit, t2);
}
- case (ast.expr_cast(?e, ?t, ?at)) {
+ case (ast::expr_cast(?e, ?t, ?at)) {
auto ee = fold_expr(env_, fld, e);
auto tt = fold_ty(env, fld, t);
auto at2 = fld.fold_ann(env_, at);
ret fld.fold_expr_cast(env_, e.span, ee, tt, at2);
}
- case (ast.expr_if(?cnd, ?thn, ?els, ?t)) {
+ case (ast::expr_if(?cnd, ?thn, ?els, ?t)) {
auto ccnd = fold_expr(env_, fld, cnd);
auto tthn = fold_block(env_, fld, thn);
auto eels = none[@expr];
@@ -653,7 +653,7 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_if(env_, e.span, ccnd, tthn, eels, t2);
}
- case (ast.expr_for(?decl, ?seq, ?body, ?t)) {
+ case (ast::expr_for(?decl, ?seq, ?body, ?t)) {
auto ddecl = fold_decl(env_, fld, decl);
auto sseq = fold_expr(env_, fld, seq);
auto bbody = fold_block(env_, fld, body);
@@ -661,7 +661,7 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_for(env_, e.span, ddecl, sseq, bbody, t2);
}
- case (ast.expr_for_each(?decl, ?seq, ?body, ?t)) {
+ case (ast::expr_for_each(?decl, ?seq, ?body, ?t)) {
auto ddecl = fold_decl(env_, fld, decl);
auto sseq = fold_expr(env_, fld, seq);
auto bbody = fold_block(env_, fld, body);
@@ -669,84 +669,84 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_for_each(env_, e.span, ddecl, sseq, bbody, t2);
}
- case (ast.expr_while(?cnd, ?body, ?t)) {
+ case (ast::expr_while(?cnd, ?body, ?t)) {
auto ccnd = fold_expr(env_, fld, cnd);
auto bbody = fold_block(env_, fld, body);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_while(env_, e.span, ccnd, bbody, t2);
}
- case (ast.expr_do_while(?body, ?cnd, ?t)) {
+ case (ast::expr_do_while(?body, ?cnd, ?t)) {
auto bbody = fold_block(env_, fld, body);
auto ccnd = fold_expr(env_, fld, cnd);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_do_while(env_, e.span, bbody, ccnd, t2);
}
- case (ast.expr_alt(?expr, ?arms, ?t)) {
+ case (ast::expr_alt(?expr, ?arms, ?t)) {
auto eexpr = fold_expr(env_, fld, expr);
- let vec[ast.arm] aarms = vec();
- for (ast.arm a in arms) {
+ let vec[ast::arm] aarms = vec();
+ for (ast::arm a in arms) {
aarms += vec(fold_arm(env_, fld, a));
}
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_alt(env_, e.span, eexpr, aarms, t2);
}
- case (ast.expr_block(?b, ?t)) {
+ case (ast::expr_block(?b, ?t)) {
auto bb = fold_block(env_, fld, b);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_block(env_, e.span, bb, t2);
}
- case (ast.expr_assign(?lhs, ?rhs, ?t)) {
+ case (ast::expr_assign(?lhs, ?rhs, ?t)) {
auto llhs = fold_expr(env_, fld, lhs);
auto rrhs = fold_expr(env_, fld, rhs);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_assign(env_, e.span, llhs, rrhs, t2);
}
- case (ast.expr_assign_op(?op, ?lhs, ?rhs, ?t)) {
+ case (ast::expr_assign_op(?op, ?lhs, ?rhs, ?t)) {
auto llhs = fold_expr(env_, fld, lhs);
auto rrhs = fold_expr(env_, fld, rhs);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_assign_op(env_, e.span, op, llhs, rrhs, t2);
}
- case (ast.expr_send(?lhs, ?rhs, ?t)) {
+ case (ast::expr_send(?lhs, ?rhs, ?t)) {
auto llhs = fold_expr(env_, fld, lhs);
auto rrhs = fold_expr(env_, fld, rhs);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_send(env_, e.span, llhs, rrhs, t2);
}
- case (ast.expr_recv(?lhs, ?rhs, ?t)) {
+ case (ast::expr_recv(?lhs, ?rhs, ?t)) {
auto llhs = fold_expr(env_, fld, lhs);
auto rrhs = fold_expr(env_, fld, rhs);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_recv(env_, e.span, llhs, rrhs, t2);
}
- case (ast.expr_field(?e, ?i, ?t)) {
+ case (ast::expr_field(?e, ?i, ?t)) {
auto ee = fold_expr(env_, fld, e);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_field(env_, e.span, ee, i, t2);
}
- case (ast.expr_index(?e, ?ix, ?t)) {
+ case (ast::expr_index(?e, ?ix, ?t)) {
auto ee = fold_expr(env_, fld, e);
auto iix = fold_expr(env_, fld, ix);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_index(env_, e.span, ee, iix, t2);
}
- case (ast.expr_path(?p, ?t)) {
+ case (ast::expr_path(?p, ?t)) {
auto p_ = fold_path(env_, fld, p);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_path(env_, e.span, p_, t2);
}
- case (ast.expr_ext(?p, ?args, ?body, ?expanded, ?t)) {
+ case (ast::expr_ext(?p, ?args, ?body, ?expanded, ?t)) {
// Only fold the expanded expression, not the
// expressions involved in syntax extension
auto exp = fold_expr(env_, fld, expanded);
@@ -755,22 +755,22 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
exp, t2);
}
- case (ast.expr_fail(?t)) {
+ case (ast::expr_fail(?t)) {
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_fail(env_, e.span, t2);
}
- case (ast.expr_break(?t)) {
+ case (ast::expr_break(?t)) {
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_break(env_, e.span, t2);
}
- case (ast.expr_cont(?t)) {
+ case (ast::expr_cont(?t)) {
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_cont(env_, e.span, t2);
}
- case (ast.expr_ret(?oe, ?t)) {
+ case (ast::expr_ret(?oe, ?t)) {
auto oee = none[@expr];
alt (oe) {
case (some[@expr](?x)) {
@@ -782,7 +782,7 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_ret(env_, e.span, oee, t2);
}
- case (ast.expr_put(?oe, ?t)) {
+ case (ast::expr_put(?oe, ?t)) {
auto oee = none[@expr];
alt (oe) {
case (some[@expr](?x)) {
@@ -794,36 +794,36 @@ fn fold_expr[ENV](&ENV env, &ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_put(env_, e.span, oee, t2);
}
- case (ast.expr_be(?x, ?t)) {
+ case (ast::expr_be(?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_be(env_, e.span, ee, t2);
}
- case (ast.expr_log(?l, ?x, ?t)) {
+ case (ast::expr_log(?l, ?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_log(env_, e.span, l, ee, t2);
}
- case (ast.expr_check(?x, ?t)) {
+ case (ast::expr_check(?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_check(env_, e.span, ee, t2);
}
- case (ast.expr_assert(?x, ?t)) {
+ case (ast::expr_assert(?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_assert(env_, e.span, ee, t2);
}
- case (ast.expr_port(?t)) {
+ case (ast::expr_port(?t)) {
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_port(env_, e.span, t2);
}
- case (ast.expr_chan(?x, ?t)) {
+ case (ast::expr_chan(?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_chan(env_, e.span, ee, t2);
@@ -843,13 +843,13 @@ fn fold_stmt[ENV](&ENV env, &ast_fold[ENV] fld, &@stmt s) -> @stmt {
}
alt (s.node) {
- case (ast.stmt_decl(?d, ?a)) {
+ case (ast::stmt_decl(?d, ?a)) {
auto dd = fold_decl(env_, fld, d);
auto aa = fld.fold_ann(env_, a);
ret fld.fold_stmt_decl(env_, s.span, dd, aa);
}
- case (ast.stmt_expr(?e, ?a)) {
+ case (ast::stmt_expr(?e, ?a)) {
auto ee = fold_expr(env_, fld, e);
auto aa = fld.fold_ann(env_, a);
ret fld.fold_stmt_expr(env_, s.span, ee, aa);
@@ -866,18 +866,18 @@ fn fold_block[ENV](&ENV env, &ast_fold[ENV] fld, &block blk) -> block {
ret blk;
}
- let vec[@ast.stmt] stmts = vec();
- for (@ast.stmt s in blk.node.stmts) {
+ let vec[@ast::stmt] stmts = vec();
+ for (@ast::stmt s in blk.node.stmts) {
auto new_stmt = fold_stmt[ENV](env_, fld, s);
- Vec.push[@ast.stmt](stmts, new_stmt);
+ _vec::push[@ast::stmt](stmts, new_stmt);
}
- auto expr = none[@ast.expr];
+ auto expr = none[@ast::expr];
alt (blk.node.expr) {
- case (some[@ast.expr](?e)) {
- expr = some[@ast.expr](fold_expr[ENV](env_, fld, e));
+ case (some[@ast::expr](?e)) {
+ expr = some[@ast::expr](fold_expr[ENV](env_, fld, e));
}
- case (none[@ast.expr]) {
+ case (none[@ast::expr]) {
// empty
}
}
@@ -899,16 +899,16 @@ fn fold_arg[ENV](&ENV env, &ast_fold[ENV] fld, &arg a) -> arg {
}
fn fold_fn_decl[ENV](&ENV env, &ast_fold[ENV] fld,
- &ast.fn_decl decl) -> ast.fn_decl {
- let vec[ast.arg] inputs = vec();
- for (ast.arg a in decl.inputs) {
+ &ast::fn_decl decl) -> ast::fn_decl {
+ let vec[ast::arg] inputs = vec();
+ for (ast::arg a in decl.inputs) {
inputs += vec(fold_arg(env, fld, a));
}
auto output = fold_ty[ENV](env, fld, decl.output);
ret fld.fold_fn_decl(env, inputs, output, decl.purity);
}
-fn fold_fn[ENV](&ENV env, &ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
+fn fold_fn[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_fn f) -> ast::_fn {
auto decl = fold_fn_decl(env, fld, f.decl);
auto body = fold_block[ENV](env, fld, f.body);
@@ -918,46 +918,46 @@ fn fold_fn[ENV](&ENV env, &ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
fn fold_obj_field[ENV](&ENV env, &ast_fold[ENV] fld,
- &ast.obj_field f) -> ast.obj_field {
+ &ast::obj_field f) -> ast::obj_field {
auto ty = fold_ty(env, fld, f.ty);
ret rec(ty=ty with f);
}
fn fold_method[ENV](&ENV env, &ast_fold[ENV] fld,
- &@ast.method m) -> @ast.method {
+ &@ast::method m) -> @ast::method {
auto meth = fold_fn(env, fld, m.node.meth);
ret @rec(node=rec(meth=meth with m.node) with *m);
}
-fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast._obj ob) -> ast._obj {
+fn fold_obj[ENV](&ENV env, &ast_fold[ENV] fld, &ast::_obj ob) -> ast::_obj {
- let vec[ast.obj_field] fields = vec();
- let vec[@ast.method] meths = vec();
- for (ast.obj_field f in ob.fields) {
+ let vec[ast::obj_field] fields = vec();
+ let vec[@ast::method] meths = vec();
+ for (ast::obj_field f in ob.fields) {
fields += vec(fold_obj_field(env, fld, f));
}
- let Option.t[@ast.method] dtor = none[@ast.method];
+ let option::t[@ast::method] dtor = none[@ast::method];
alt (ob.dtor) {
- case (none[@ast.method]) { }
- case (some[@ast.method](?m)) {
- dtor = some[@ast.method](fold_method[ENV](env, fld, m));
+ case (none[@ast::method]) { }
+ case (some[@ast::method](?m)) {
+ dtor = some[@ast::method](fold_method[ENV](env, fld, m));
}
}
- let vec[ast.ty_param] tp = vec();
- for (@ast.method m in ob.methods) {
- // Fake-up an ast.item for this method.
+ let vec[ast::ty_param] tp = vec();
+ for (@ast::method m in ob.methods) {
+ // Fake-up an ast::item for this method.
// FIXME: this is kinda awful. Maybe we should reformulate
// the way we store methods in the AST?
- let @ast.item i = @rec(node=ast.item_fn(m.node.ident,
+ let @ast::item i = @rec(node=ast::item_fn(m.node.ident,
m.node.meth,
tp,
m.node.id,
m.node.ann),
span=m.span);
let ENV _env = fld.update_env_for_item(env, i);
- Vec.push[@ast.method](meths, fold_method(_env, fld, m));
+ _vec::push[@ast::method](meths, fold_method(_env, fld, m));
}
ret fld.fold_obj(env, fields, meths, dtor);
}
@@ -972,16 +972,16 @@ fn fold_view_item[ENV](&ENV env, &ast_fold[ENV] fld, &@view_item vi)
}
alt (vi.node) {
- case (ast.view_item_use(?ident, ?meta_items, ?def_id, ?cnum)) {
+ case (ast::view_item_use(?ident, ?meta_items, ?def_id, ?cnum)) {
ret fld.fold_view_item_use(env_, vi.span, ident, meta_items,
def_id, cnum);
}
- case (ast.view_item_import(?def_ident, ?idents, ?def_id)) {
+ case (ast::view_item_import(?def_ident, ?idents, ?def_id)) {
ret fld.fold_view_item_import(env_, vi.span, def_ident, idents,
def_id);
}
- case (ast.view_item_export(?def_ident)) {
+ case (ast::view_item_export(?def_ident)) {
ret fld.fold_view_item_export(env_, vi.span, def_ident);
}
}
@@ -999,50 +999,50 @@ fn fold_item[ENV](&ENV env, &ast_fold[ENV] fld, &@item i) -> @item {
alt (i.node) {
- case (ast.item_const(?ident, ?t, ?e, ?id, ?ann)) {
- let @ast.ty t_ = fold_ty[ENV](env_, fld, t);
- let @ast.expr e_ = fold_expr(env_, fld, e);
+ case (ast::item_const(?ident, ?t, ?e, ?id, ?ann)) {
+ let @ast::ty t_ = fold_ty[ENV](env_, fld, t);
+ let @ast::expr e_ = fold_expr(env_, fld, e);
ret fld.fold_item_const(env_, i.span, ident, t_, e_, id, ann);
}
- case (ast.item_fn(?ident, ?ff, ?tps, ?id, ?ann)) {
- let ast._fn ff_ = fold_fn[ENV](env_, fld, ff);
+ case (ast::item_fn(?ident, ?ff, ?tps, ?id, ?ann)) {
+ let ast::_fn ff_ = fold_fn[ENV](env_, fld, ff);
ret fld.fold_item_fn(env_, i.span, ident, ff_, tps, id, ann);
}
- case (ast.item_mod(?ident, ?mm, ?id)) {
- let ast._mod mm_ = fold_mod[ENV](env_, fld, mm);
+ case (ast::item_mod(?ident, ?mm, ?id)) {
+ let ast::_mod mm_ = fold_mod[ENV](env_, fld, mm);
ret fld.fold_item_mod(env_, i.span, ident, mm_, id);
}
- case (ast.item_native_mod(?ident, ?mm, ?id)) {
- let ast.native_mod mm_ = fold_native_mod[ENV](env_, fld, mm);
+ case (ast::item_native_mod(?ident, ?mm, ?id)) {
+ let ast::native_mod mm_ = fold_native_mod[ENV](env_, fld, mm);
ret fld.fold_item_native_mod(env_, i.span, ident, mm_, id);
}
- case (ast.item_ty(?ident, ?ty, ?params, ?id, ?ann)) {
- let @ast.ty ty_ = fold_ty[ENV](env_, fld, ty);
+ case (ast::item_ty(?ident, ?ty, ?params, ?id, ?ann)) {
+ let @ast::ty ty_ = fold_ty[ENV](env_, fld, ty);
ret fld.fold_item_ty(env_, i.span, ident, ty_, params, id, ann);
}
- case (ast.item_tag(?ident, ?variants, ?ty_params, ?id, ?ann)) {
- let vec[ast.variant] new_variants = vec();
- for (ast.variant v in variants) {
- let vec[ast.variant_arg] new_args = vec();
- for (ast.variant_arg va in v.node.args) {
+ case (ast::item_tag(?ident, ?variants, ?ty_params, ?id, ?ann)) {
+ let vec[ast::variant] new_variants = vec();
+ for (ast::variant v in variants) {
+ let vec[ast::variant_arg] new_args = vec();
+ for (ast::variant_arg va in v.node.args) {
auto new_ty = fold_ty[ENV](env_, fld, va.ty);
new_args += vec(rec(ty=new_ty, id=va.id));
}
auto new_v = rec(name=v.node.name, args=new_args,
id=v.node.id, ann=v.node.ann);
- new_variants += vec(respan[ast.variant_](v.span, new_v));
+ new_variants += vec(respan[ast::variant_](v.span, new_v));
}
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
ty_params, id, ann);
}
- case (ast.item_obj(?ident, ?ob, ?tps, ?odid, ?ann)) {
- let ast._obj ob_ = fold_obj[ENV](env_, fld, ob);
+ case (ast::item_obj(?ident, ?ob, ?tps, ?odid, ?ann)) {
+ let ast::_obj ob_ = fold_obj[ENV](env_, fld, ob);
ret fld.fold_item_obj(env_, i.span, ident, ob_, tps, odid, ann);
}
@@ -1051,19 +1051,19 @@ fn fold_item[ENV](&ENV env, &ast_fold[ENV] fld, &@item i) -> @item {
fail;
}
-fn fold_mod[ENV](&ENV e, &ast_fold[ENV] fld, &ast._mod m) -> ast._mod {
+fn fold_mod[ENV](&ENV e, &ast_fold[ENV] fld, &ast::_mod m) -> ast::_mod {
let vec[@view_item] view_items = vec();
let vec[@item] items = vec();
for (@view_item vi in m.view_items) {
auto new_vi = fold_view_item[ENV](e, fld, vi);
- Vec.push[@view_item](view_items, new_vi);
+ _vec::push[@view_item](view_items, new_vi);
}
for (@item i in m.items) {
auto new_item = fold_item[ENV](e, fld, i);
- Vec.push[@item](items, new_item);
+ _vec::push[@item](items, new_item);
}
ret fld.fold_mod(e, rec(view_items=view_items, items=items));
@@ -1077,10 +1077,10 @@ fn fold_native_item[ENV](&ENV env, &ast_fold[ENV] fld,
ret i;
}
alt (i.node) {
- case (ast.native_item_ty(?ident, ?id)) {
+ case (ast::native_item_ty(?ident, ?id)) {
ret fld.fold_native_item_ty(env_, i.span, ident, id);
}
- case (ast.native_item_fn(?ident, ?lname, ?fn_decl,
+ case (ast::native_item_fn(?ident, ?lname, ?fn_decl,
?ty_params, ?id, ?ann)) {
auto d = fold_fn_decl[ENV](env_, fld, fn_decl);
ret fld.fold_native_item_fn(env_, i.span, ident, lname, d,
@@ -1090,18 +1090,18 @@ fn fold_native_item[ENV](&ENV env, &ast_fold[ENV] fld,
}
fn fold_native_mod[ENV](&ENV e, &ast_fold[ENV] fld,
- &ast.native_mod m) -> ast.native_mod {
+ &ast::native_mod m) -> ast::native_mod {
let vec[@view_item] view_items = vec();
let vec[@native_item] items = vec();
for (@view_item vi in m.view_items) {
auto new_vi = fold_view_item[ENV](e, fld, vi);
- Vec.push[@view_item](view_items, new_vi);
+ _vec::push[@view_item](view_items, new_vi);
}
for (@native_item i in m.items) {
auto new_item = fold_native_item[ENV](e, fld, i);
- Vec.push[@native_item](items, new_item);
+ _vec::push[@native_item](items, new_item);
}
ret fld.fold_native_mod(e, rec(native_name=m.native_name,
@@ -1111,12 +1111,12 @@ fn fold_native_mod[ENV](&ENV e, &ast_fold[ENV] fld,
}
fn fold_crate[ENV](&ENV env, &ast_fold[ENV] fld,
- &@ast.crate c) -> @ast.crate {
+ &@ast::crate c) -> @ast::crate {
// FIXME: possibly fold the directives so you process any expressions
- // within them? Not clear. After front/eval.rs, nothing else should look
+ // within them? Not clear. After front/eval::rs, nothing else should look
// at crate directives.
let ENV env_ = fld.update_env_for_crate(env, c);
- let ast._mod m = fold_mod[ENV](env_, fld, c.node.module);
+ let ast::_mod m = fold_mod[ENV](env_, fld, c.node.module);
ret fld.fold_crate(env_, c.span, c.node.directives, m);
}
@@ -1129,319 +1129,319 @@ fn respan[T](&span sp, &T t) -> spanned[T] {
// Path identity.
-fn identity_fold_path[ENV](&ENV env, &span sp, &ast.path_ p) -> path {
+fn identity_fold_path[ENV](&ENV env, &span sp, &ast::path_ p) -> path {
ret respan(sp, p);
}
// Type identities.
fn identity_fold_ty_nil[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_nil);
+ ret @respan(sp, ast::ty_nil);
}
fn identity_fold_ty_bool[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_bool);
+ ret @respan(sp, ast::ty_bool);
}
fn identity_fold_ty_int[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_int);
+ ret @respan(sp, ast::ty_int);
}
fn identity_fold_ty_uint[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_uint);
+ ret @respan(sp, ast::ty_uint);
}
fn identity_fold_ty_float[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_float);
+ ret @respan(sp, ast::ty_float);
}
fn identity_fold_ty_machine[ENV](&ENV env, &span sp,
ty_mach tm) -> @ty {
- ret @respan(sp, ast.ty_machine(tm));
+ ret @respan(sp, ast::ty_machine(tm));
}
fn identity_fold_ty_char[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_char);
+ ret @respan(sp, ast::ty_char);
}
fn identity_fold_ty_str[ENV](&ENV env, &span sp) -> @ty {
- ret @respan(sp, ast.ty_str);
+ ret @respan(sp, ast::ty_str);
}
fn identity_fold_ty_box[ENV](&ENV env, &span sp, &mt tm) -> @ty {
- ret @respan(sp, ast.ty_box(tm));
+ ret @respan(sp, ast::ty_box(tm));
}
fn identity_fold_ty_vec[ENV](&ENV env, &span sp, &mt tm) -> @ty {
- ret @respan(sp, ast.ty_vec(tm));
+ ret @respan(sp, ast::ty_vec(tm));
}
fn identity_fold_ty_tup[ENV](&ENV env, &span sp,
&vec[mt] elts) -> @ty {
- ret @respan(sp, ast.ty_tup(elts));
+ ret @respan(sp, ast::ty_tup(elts));
}
fn identity_fold_ty_rec[ENV](&ENV env, &span sp,
- &vec[ast.ty_field] elts) -> @ty {
- ret @respan(sp, ast.ty_rec(elts));
+ &vec[ast::ty_field] elts) -> @ty {
+ ret @respan(sp, ast::ty_rec(elts));
}
fn identity_fold_ty_obj[ENV](&ENV env, &span sp,
- &vec[ast.ty_method] meths) -> @ty {
- ret @respan(sp, ast.ty_obj(meths));
+ &vec[ast::ty_method] meths) -> @ty {
+ ret @respan(sp, ast::ty_obj(meths));
}
fn identity_fold_ty_fn[ENV](&ENV env, &span sp,
- ast.proto proto,
- &vec[rec(ast.mode mode, @ty ty)] inputs,
+ ast::proto proto,
+ &vec[rec(ast::mode mode, @ty ty)] inputs,
&@ty output) -> @ty {
- ret @respan(sp, ast.ty_fn(proto, inputs, output));
+ ret @respan(sp, ast::ty_fn(proto, inputs, output));
}
-fn identity_fold_ty_path[ENV](&ENV env, &span sp, &ast.path p,
+fn identity_fold_ty_path[ENV](&ENV env, &span sp, &ast::path p,
&ann a) -> @ty {
- ret @respan(sp, ast.ty_path(p, a));
+ ret @respan(sp, ast::ty_path(p, a));
}
fn identity_fold_ty_chan[ENV](&ENV env, &span sp, &@ty t) -> @ty {
- ret @respan(sp, ast.ty_chan(t));
+ ret @respan(sp, ast::ty_chan(t));
}
fn identity_fold_ty_port[ENV](&ENV env, &span sp, &@ty t) -> @ty {
- ret @respan(sp, ast.ty_port(t));
+ ret @respan(sp, ast::ty_port(t));
}
// Expr identities.
fn identity_fold_expr_vec[ENV](&ENV env, &span sp, &vec[@expr] es,
- ast.mutability mut, &ann a) -> @expr {
- ret @respan(sp, ast.expr_vec(es, mut, a));
+ ast::mutability mut, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_vec(es, mut, a));
}
fn identity_fold_expr_tup[ENV](&ENV env, &span sp,
- &vec[ast.elt] es, &ann a) -> @expr {
- ret @respan(sp, ast.expr_tup(es, a));
+ &vec[ast::elt] es, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_tup(es, a));
}
fn identity_fold_expr_rec[ENV](&ENV env, &span sp,
- &vec[ast.field] fields,
- &Option.t[@expr] base, &ann a) -> @expr {
- ret @respan(sp, ast.expr_rec(fields, base, a));
+ &vec[ast::field] fields,
+ &option::t[@expr] base, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_rec(fields, base, a));
}
fn identity_fold_expr_call[ENV](&ENV env, &span sp, &@expr f,
&vec[@expr] args, &ann a) -> @expr {
- ret @respan(sp, ast.expr_call(f, args, a));
+ ret @respan(sp, ast::expr_call(f, args, a));
}
fn identity_fold_expr_self_method[ENV](&ENV env, &span sp, &ident id,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_self_method(id, a));
+ ret @respan(sp, ast::expr_self_method(id, a));
}
fn identity_fold_expr_bind[ENV](&ENV env, &span sp, &@expr f,
- &vec[Option.t[@expr]] args_opt, &ann a)
+ &vec[option::t[@expr]] args_opt, &ann a)
-> @expr {
- ret @respan(sp, ast.expr_bind(f, args_opt, a));
+ ret @respan(sp, ast::expr_bind(f, args_opt, a));
}
fn identity_fold_expr_spawn[ENV](&ENV env, &span sp,
- ast.spawn_dom dom, &Option.t[str] name,
+ ast::spawn_dom dom, &option::t[str] name,
&@expr f, &vec[@expr] args,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_spawn(dom, name, f, args, a));
+ ret @respan(sp, ast::expr_spawn(dom, name, f, args, a));
}
-fn identity_fold_expr_binary[ENV](&ENV env, &span sp, ast.binop b,
+fn identity_fold_expr_binary[ENV](&ENV env, &span sp, ast::binop b,
&@expr lhs, &@expr rhs,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_binary(b, lhs, rhs, a));
+ ret @respan(sp, ast::expr_binary(b, lhs, rhs, a));
}
fn identity_fold_expr_unary[ENV](&ENV env, &span sp,
- ast.unop u, &@expr e, &ann a)
+ ast::unop u, &@expr e, &ann a)
-> @expr {
- ret @respan(sp, ast.expr_unary(u, e, a));
+ ret @respan(sp, ast::expr_unary(u, e, a));
}
-fn identity_fold_expr_lit[ENV](&ENV env, &span sp, &@ast.lit lit,
+fn identity_fold_expr_lit[ENV](&ENV env, &span sp, &@ast::lit lit,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_lit(lit, a));
+ ret @respan(sp, ast::expr_lit(lit, a));
}
-fn identity_fold_expr_cast[ENV](&ENV env, &span sp, &@ast.expr e,
- &@ast.ty t, &ann a) -> @expr {
- ret @respan(sp, ast.expr_cast(e, t, a));
+fn identity_fold_expr_cast[ENV](&ENV env, &span sp, &@ast::expr e,
+ &@ast::ty t, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_cast(e, t, a));
}
fn identity_fold_expr_if[ENV](&ENV env, &span sp,
&@expr cond, &block thn,
- &Option.t[@expr] els, &ann a) -> @expr {
- ret @respan(sp, ast.expr_if(cond, thn, els, a));
+ &option::t[@expr] els, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_if(cond, thn, els, a));
}
fn identity_fold_expr_for[ENV](&ENV env, &span sp,
&@decl d, &@expr seq,
&block body, &ann a) -> @expr {
- ret @respan(sp, ast.expr_for(d, seq, body, a));
+ ret @respan(sp, ast::expr_for(d, seq, body, a));
}
fn identity_fold_expr_for_each[ENV](&ENV env, &span sp,
&@decl d, &@expr seq,
&block body, &ann a) -> @expr {
- ret @respan(sp, ast.expr_for_each(d, seq, body, a));
+ ret @respan(sp, ast::expr_for_each(d, seq, body, a));
}
fn identity_fold_expr_while[ENV](&ENV env, &span sp,
&@expr cond, &block body, &ann a) -> @expr {
- ret @respan(sp, ast.expr_while(cond, body, a));
+ ret @respan(sp, ast::expr_while(cond, body, a));
}
fn identity_fold_expr_do_while[ENV](&ENV env, &span sp,
&block body, &@expr cond,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_do_while(body, cond, a));
+ ret @respan(sp, ast::expr_do_while(body, cond, a));
}
fn identity_fold_expr_alt[ENV](&ENV env, &span sp,
&@expr e, &vec[arm] arms,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_alt(e, arms, a));
+ ret @respan(sp, ast::expr_alt(e, arms, a));
}
fn identity_fold_expr_block[ENV](&ENV env, &span sp, &block blk,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_block(blk, a));
+ ret @respan(sp, ast::expr_block(blk, a));
}
fn identity_fold_expr_assign[ENV](&ENV env, &span sp,
&@expr lhs, &@expr rhs, &ann a)
-> @expr {
- ret @respan(sp, ast.expr_assign(lhs, rhs, a));
+ ret @respan(sp, ast::expr_assign(lhs, rhs, a));
}
-fn identity_fold_expr_assign_op[ENV](&ENV env, &span sp, ast.binop op,
+fn identity_fold_expr_assign_op[ENV](&ENV env, &span sp, ast::binop op,
&@expr lhs, &@expr rhs, &ann a)
-> @expr {
- ret @respan(sp, ast.expr_assign_op(op, lhs, rhs, a));
+ ret @respan(sp, ast::expr_assign_op(op, lhs, rhs, a));
}
fn identity_fold_expr_send[ENV](&ENV e, &span sp,
&@expr lhs, &@expr rhs, &ann a) -> @expr {
- ret @respan(sp, ast.expr_send(lhs, rhs, a));
+ ret @respan(sp, ast::expr_send(lhs, rhs, a));
}
fn identity_fold_expr_recv[ENV](&ENV e, &span sp,
&@expr lhs, &@expr rhs, &ann a) -> @expr {
- ret @respan(sp, ast.expr_recv(lhs, rhs, a));
+ ret @respan(sp, ast::expr_recv(lhs, rhs, a));
}
fn identity_fold_expr_field[ENV](&ENV env, &span sp,
&@expr e, &ident i, &ann a) -> @expr {
- ret @respan(sp, ast.expr_field(e, i, a));
+ ret @respan(sp, ast::expr_field(e, i, a));
}
fn identity_fold_expr_index[ENV](&ENV env, &span sp,
&@expr e, &@expr ix, &ann a) -> @expr {
- ret @respan(sp, ast.expr_index(e, ix, a));
+ ret @respan(sp, ast::expr_index(e, ix, a));
}
fn identity_fold_expr_path[ENV](&ENV env, &span sp,
&path p, &ann a) -> @expr {
- ret @respan(sp, ast.expr_path(p, a));
+ ret @respan(sp, ast::expr_path(p, a));
}
fn identity_fold_expr_ext[ENV](&ENV env, &span sp,
&path p, &vec[@expr] args,
- &Option.t[str] body,
+ &option::t[str] body,
&@expr expanded,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_ext(p, args, body, expanded, a));
+ ret @respan(sp, ast::expr_ext(p, args, body, expanded, a));
}
fn identity_fold_expr_fail[ENV](&ENV env, &span sp, &ann a) -> @expr {
- ret @respan(sp, ast.expr_fail(a));
+ ret @respan(sp, ast::expr_fail(a));
}
fn identity_fold_expr_break[ENV](&ENV env, &span sp, &ann a) -> @expr {
- ret @respan(sp, ast.expr_break(a));
+ ret @respan(sp, ast::expr_break(a));
}
fn identity_fold_expr_cont[ENV](&ENV env, &span sp, &ann a) -> @expr {
- ret @respan(sp, ast.expr_cont(a));
+ ret @respan(sp, ast::expr_cont(a));
}
fn identity_fold_expr_ret[ENV](&ENV env, &span sp,
- &Option.t[@expr] rv, &ann a) -> @expr {
- ret @respan(sp, ast.expr_ret(rv, a));
+ &option::t[@expr] rv, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_ret(rv, a));
}
fn identity_fold_expr_put[ENV](&ENV env, &span sp,
- &Option.t[@expr] rv, &ann a) -> @expr {
- ret @respan(sp, ast.expr_put(rv, a));
+ &option::t[@expr] rv, &ann a) -> @expr {
+ ret @respan(sp, ast::expr_put(rv, a));
}
fn identity_fold_expr_be[ENV](&ENV env, &span sp,
&@expr x, &ann a) -> @expr {
- ret @respan(sp, ast.expr_be(x, a));
+ ret @respan(sp, ast::expr_be(x, a));
}
fn identity_fold_expr_log[ENV](&ENV e, &span sp, int lvl, &@expr x,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_log(lvl, x, a));
+ ret @respan(sp, ast::expr_log(lvl, x, a));
}
fn identity_fold_expr_check[ENV](&ENV e, &span sp, &@expr x, &ann a)
-> @expr {
- ret @respan(sp, ast.expr_check(x, a));
+ ret @respan(sp, ast::expr_check(x, a));
}
fn identity_fold_expr_assert[ENV](&ENV e, &span sp, &@expr x, &ann a)
-> @expr {
- ret @respan(sp, ast.expr_assert(x, a));
+ ret @respan(sp, ast::expr_assert(x, a));
}
fn identity_fold_expr_port[ENV](&ENV e, &span sp, &ann a) -> @expr {
- ret @respan(sp, ast.expr_port(a));
+ ret @respan(sp, ast::expr_port(a));
}
fn identity_fold_expr_chan[ENV](&ENV e, &span sp, &@expr x,
&ann a) -> @expr {
- ret @respan(sp, ast.expr_chan(x, a));
+ ret @respan(sp, ast::expr_chan(x, a));
}
// Decl identities.
fn identity_fold_decl_local[ENV](&ENV e, &span sp,
- &@ast.local local) -> @decl {
- ret @respan(sp, ast.decl_local(local));
+ &@ast::local local) -> @decl {
+ ret @respan(sp, ast::decl_local(local));
}
fn identity_fold_decl_item[ENV](&ENV e, &span sp, &@item i) -> @decl {
- ret @respan(sp, ast.decl_item(i));
+ ret @respan(sp, ast::decl_item(i));
}
// Pat identities.
fn identity_fold_pat_wild[ENV](&ENV e, &span sp, &ann a) -> @pat {
- ret @respan(sp, ast.pat_wild(a));
+ ret @respan(sp, ast::pat_wild(a));
}
fn identity_fold_pat_lit[ENV](&ENV e, &span sp,
- &@ast.lit lit, &ann a) -> @pat {
- ret @respan(sp, ast.pat_lit(lit, a));
+ &@ast::lit lit, &ann a) -> @pat {
+ ret @respan(sp, ast::pat_lit(lit, a));
}
fn identity_fold_pat_bind[ENV](&ENV e, &span sp, &ident i,
&def_id did, &ann a)
-> @pat {
- ret @respan(sp, ast.pat_bind(i, did, a));
+ ret @respan(sp, ast::pat_bind(i, did, a));
}
fn identity_fold_pat_tag[ENV](&ENV e, &span sp, &path p, &vec[@pat] args,
&ann a) -> @pat {
- ret @respan(sp, ast.pat_tag(p, args, a));
+ ret @respan(sp, ast::pat_tag(p, args, a));
}
@@ -1449,12 +1449,12 @@ fn identity_fold_pat_tag[ENV](&ENV e, &span sp, &path p, &vec[@pat] args,
fn identity_fold_stmt_decl[ENV](&ENV env, &span sp,
&@decl d, &ann a) -> @stmt {
- ret @respan(sp, ast.stmt_decl(d, a));
+ ret @respan(sp, ast::stmt_decl(d, a));
}
fn identity_fold_stmt_expr[ENV](&ENV e, &span sp,
&@expr x, &ann a) -> @stmt {
- ret @respan(sp, ast.stmt_expr(x, a));
+ ret @respan(sp, ast::stmt_expr(x, a));
}
@@ -1463,76 +1463,77 @@ fn identity_fold_stmt_expr[ENV](&ENV e, &span sp,
fn identity_fold_item_const[ENV](&ENV e, &span sp, &ident i,
&@ty t, &@expr ex,
&def_id id, &ann a) -> @item {
- ret @respan(sp, ast.item_const(i, t, ex, id, a));
+ ret @respan(sp, ast::item_const(i, t, ex, id, a));
}
fn identity_fold_item_fn[ENV](&ENV e, &span sp, &ident i,
- &ast._fn f, &vec[ast.ty_param] ty_params,
+ &ast::_fn f, &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item {
- ret @respan(sp, ast.item_fn(i, f, ty_params, id, a));
+ ret @respan(sp, ast::item_fn(i, f, ty_params, id, a));
}
fn identity_fold_native_item_fn[ENV](&ENV e, &span sp, &ident i,
- &Option.t[str] link_name,
- &ast.fn_decl decl,
- &vec[ast.ty_param] ty_params,
+ &option::t[str] link_name,
+ &ast::fn_decl decl,
+ &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @native_item {
- ret @respan(sp, ast.native_item_fn(i, link_name, decl, ty_params, id, a));
+ ret @respan(sp, ast::native_item_fn(i, link_name, decl, ty_params,
+ id, a));
}
fn identity_fold_item_mod[ENV](&ENV e, &span sp, &ident i,
- &ast._mod m, &def_id id) -> @item {
- ret @respan(sp, ast.item_mod(i, m, id));
+ &ast::_mod m, &def_id id) -> @item {
+ ret @respan(sp, ast::item_mod(i, m, id));
}
fn identity_fold_item_native_mod[ENV](&ENV e, &span sp, &ident i,
- &ast.native_mod m,
+ &ast::native_mod m,
&def_id id) -> @item {
- ret @respan(sp, ast.item_native_mod(i, m, id));
+ ret @respan(sp, ast::item_native_mod(i, m, id));
}
fn identity_fold_item_ty[ENV](&ENV e, &span sp, &ident i,
- &@ty t, &vec[ast.ty_param] ty_params,
+ &@ty t, &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item {
- ret @respan(sp, ast.item_ty(i, t, ty_params, id, a));
+ ret @respan(sp, ast::item_ty(i, t, ty_params, id, a));
}
fn identity_fold_native_item_ty[ENV](&ENV e, &span sp, &ident i,
&def_id id) -> @native_item {
- ret @respan(sp, ast.native_item_ty(i, id));
+ ret @respan(sp, ast::native_item_ty(i, id));
}
fn identity_fold_item_tag[ENV](&ENV e, &span sp, &ident i,
- &vec[ast.variant] variants,
- &vec[ast.ty_param] ty_params,
+ &vec[ast::variant] variants,
+ &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item {
- ret @respan(sp, ast.item_tag(i, variants, ty_params, id, a));
+ ret @respan(sp, ast::item_tag(i, variants, ty_params, id, a));
}
fn identity_fold_item_obj[ENV](&ENV e, &span sp, &ident i,
- &ast._obj ob, &vec[ast.ty_param] ty_params,
- &ast.obj_def_ids odid, &ann a) -> @item {
- ret @respan(sp, ast.item_obj(i, ob, ty_params, odid, a));
+ &ast::_obj ob, &vec[ast::ty_param] ty_params,
+ &ast::obj_def_ids odid, &ann a) -> @item {
+ ret @respan(sp, ast::item_obj(i, ob, ty_params, odid, a));
}
// View Item folds.
fn identity_fold_view_item_use[ENV](&ENV e, &span sp, &ident i,
&vec[@meta_item] meta_items,
- &def_id id, &Option.t[int] cnum)
+ &def_id id, &option::t[int] cnum)
-> @view_item {
- ret @respan(sp, ast.view_item_use(i, meta_items, id, cnum));
+ ret @respan(sp, ast::view_item_use(i, meta_items, id, cnum));
}
fn identity_fold_view_item_import[ENV](&ENV e, &span sp, &ident i,
&vec[ident] is, &def_id id)
-> @view_item {
- ret @respan(sp, ast.view_item_import(i, is, id));
+ ret @respan(sp, ast::view_item_import(i, is, id));
}
fn identity_fold_view_item_export[ENV](&ENV e, &span sp, &ident i)
-> @view_item {
- ret @respan(sp, ast.view_item_export(i));
+ ret @respan(sp, ast::view_item_export(i));
}
// Annotation folding.
@@ -1543,50 +1544,50 @@ fn identity_fold_ann[ENV](&ENV e, &ann a) -> ann {
// Additional identities.
-fn identity_fold_block[ENV](&ENV e, &span sp, &ast.block_ blk) -> block {
+fn identity_fold_block[ENV](&ENV e, &span sp, &ast::block_ blk) -> block {
ret respan(sp, blk);
}
fn identity_fold_fn_decl[ENV](&ENV e,
&vec[arg] inputs,
&@ty output,
- &purity p) -> ast.fn_decl {
+ &purity p) -> ast::fn_decl {
ret rec(inputs=inputs, output=output, purity=p);
}
fn identity_fold_fn[ENV](&ENV e,
&fn_decl decl,
- ast.proto proto,
- &block body) -> ast._fn {
+ ast::proto proto,
+ &block body) -> ast::_fn {
ret rec(decl=decl, proto=proto, body=body);
}
-fn identity_fold_mod[ENV](&ENV e, &ast._mod m) -> ast._mod {
+fn identity_fold_mod[ENV](&ENV e, &ast::_mod m) -> ast::_mod {
ret m;
}
fn identity_fold_native_mod[ENV](&ENV e,
- &ast.native_mod m) -> ast.native_mod {
+ &ast::native_mod m) -> ast::native_mod {
ret m;
}
fn identity_fold_crate[ENV](&ENV e, &span sp,
- &vec[@ast.crate_directive] cdirs,
- &ast._mod m) -> @ast.crate {
+ &vec[@ast::crate_directive] cdirs,
+ &ast::_mod m) -> @ast::crate {
ret @respan(sp, rec(directives=cdirs, module=m));
}
fn identity_fold_obj[ENV](&ENV e,
- &vec[ast.obj_field] fields,
- &vec[@ast.method] methods,
- &Option.t[@ast.method] dtor) -> ast._obj {
+ &vec[ast::obj_field] fields,
+ &vec[@ast::method] methods,
+ &option::t[@ast::method] dtor) -> ast::_obj {
ret rec(fields=fields, methods=methods, dtor=dtor);
}
// Env update identities.
-fn identity_update_env_for_crate[ENV](&ENV e, &@ast.crate c) -> ENV {
+fn identity_update_env_for_crate[ENV](&ENV e, &@ast::crate c) -> ENV {
ret e;
}
diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs
index ee628643..e10f2e73 100644
--- a/src/comp/middle/metadata.rs
+++ b/src/comp/middle/metadata.rs
@@ -1,23 +1,23 @@
-import std.Str;
-import std.UInt;
-import std.Vec;
-import std.Map.hashmap;
-import std.EBML;
-import std.IO;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
-
-import front.ast;
-import middle.fold;
-import middle.trans;
-import middle.ty;
-import back.x86;
-import util.common;
-
-import lib.llvm.llvm;
-import lib.llvm.llvm.ValueRef;
-import lib.llvm.False;
+import std::_str;
+import std::_uint;
+import std::_vec;
+import std::map::hashmap;
+import std::ebml;
+import std::io;
+import std::option;
+import std::option::some;
+import std::option::none;
+
+import front::ast;
+import middle::fold;
+import middle::trans;
+import middle::ty;
+import back::x86;
+import util::common;
+
+import lib::llvm::llvm;
+import lib::llvm::llvm::ValueRef;
+import lib::llvm::False;
const uint tag_paths = 0x01u;
const uint tag_items = 0x02u;
@@ -55,14 +55,14 @@ type ty_abbrev = rec(uint pos, uint len, str s);
tag abbrev_ctxt {
ac_no_abbrevs;
- ac_use_abbrevs(hashmap[ty.t, ty_abbrev]);
+ ac_use_abbrevs(hashmap[ty::t, ty_abbrev]);
}
mod Encode {
type ctxt = rec(
- fn(&ast.def_id) -> str ds, // Def -> str Callback.
- ty.ctxt tcx, // The type context.
+ fn(&ast::def_id) -> str ds, // Def -> str Callback:
+ ty::ctxt tcx, // The type context.
abbrev_ctxt abbrevs
);
@@ -73,22 +73,22 @@ mod Encode {
}
}
- fn ty_str(&@ctxt cx, &ty.t t) -> str {
+ fn ty_str(&@ctxt cx, &ty::t t) -> str {
assert (!cx_uses_abbrevs(cx));
- auto sw = IO.string_writer();
+ auto sw = io::string_writer();
enc_ty(sw.get_writer(), cx, t);
ret sw.get_str();
}
- fn enc_ty(&IO.writer w, &@ctxt cx, &ty.t t) {
+ fn enc_ty(&io::writer w, &@ctxt cx, &ty::t t) {
alt (cx.abbrevs) {
case (ac_no_abbrevs) {
auto result_str;
alt (cx.tcx.short_names_cache.find(t)) {
case (some[str](?s)) { result_str = s; }
case (none[str]) {
- auto sw = IO.string_writer();
- enc_sty(sw.get_writer(), cx, ty.struct(cx.tcx, t));
+ auto sw = io::string_writer();
+ enc_sty(sw.get_writer(), cx, ty::struct(cx.tcx, t));
result_str = sw.get_str();
cx.tcx.short_names_cache.insert(t, result_str);
}
@@ -103,7 +103,7 @@ mod Encode {
}
case (none[ty_abbrev]) {
auto pos = w.get_buf_writer().tell();
- auto ss = enc_sty(w, cx, ty.struct(cx.tcx, t));
+ auto ss = enc_sty(w, cx, ty::struct(cx.tcx, t));
auto end = w.get_buf_writer().tell();
auto len = end-pos;
fn estimate_sz(uint u) -> uint {
@@ -121,8 +121,8 @@ mod Encode {
if (abbrev_len < len) {
// I.e. it's actually an abbreviation.
auto s = ("#"
- + UInt.to_str(pos, 16u) + ":"
- + UInt.to_str(len, 16u) + "#");
+ + _uint::to_str(pos, 16u) + ":"
+ + _uint::to_str(len, 16u) + "#");
auto a = rec(pos=pos, len=len, s=s);
abbrevs.insert(t, a);
}
@@ -133,127 +133,127 @@ mod Encode {
}
}
- fn enc_mt(&IO.writer w, &@ctxt cx, &ty.mt mt) {
+ fn enc_mt(&io::writer w, &@ctxt cx, &ty::mt mt) {
alt (mt.mut) {
- case (ast.imm) { }
- case (ast.mut) { w.write_char('m'); }
- case (ast.maybe_mut) { w.write_char('?'); }
+ case (ast::imm) { }
+ case (ast::mut) { w.write_char('m'); }
+ case (ast::maybe_mut) { w.write_char('?'); }
}
enc_ty(w, cx, mt.ty);
}
- fn enc_sty(&IO.writer w, &@ctxt cx, &ty.sty st) {
+ fn enc_sty(&io::writer w, &@ctxt cx, &ty::sty st) {
alt (st) {
- case (ty.ty_nil) { w.write_char('n'); }
- case (ty.ty_bool) { w.write_char('b'); }
- case (ty.ty_int) { w.write_char('i'); }
- case (ty.ty_uint) { w.write_char('u'); }
- case (ty.ty_float) { w.write_char('l'); }
- case (ty.ty_machine(?mach)) {
+ case (ty::ty_nil) { w.write_char('n'); }
+ case (ty::ty_bool) { w.write_char('b'); }
+ case (ty::ty_int) { w.write_char('i'); }
+ case (ty::ty_uint) { w.write_char('u'); }
+ case (ty::ty_float) { w.write_char('l'); }
+ case (ty::ty_machine(?mach)) {
alt (mach) {
- case (common.ty_u8) { w.write_str("Mb"); }
- case (common.ty_u16) { w.write_str("Mw"); }
- case (common.ty_u32) { w.write_str("Ml"); }
- case (common.ty_u64) { w.write_str("Md"); }
- case (common.ty_i8) { w.write_str("MB"); }
- case (common.ty_i16) { w.write_str("MW"); }
- case (common.ty_i32) { w.write_str("ML"); }
- case (common.ty_i64) { w.write_str("MD"); }
- case (common.ty_f32) { w.write_str("Mf"); }
- case (common.ty_f64) { w.write_str("MF"); }
+ case (common::ty_u8) { w.write_str("Mb"); }
+ case (common::ty_u16) { w.write_str("Mw"); }
+ case (common::ty_u32) { w.write_str("Ml"); }
+ case (common::ty_u64) { w.write_str("Md"); }
+ case (common::ty_i8) { w.write_str("MB"); }
+ case (common::ty_i16) { w.write_str("MW"); }
+ case (common::ty_i32) { w.write_str("ML"); }
+ case (common::ty_i64) { w.write_str("MD"); }
+ case (common::ty_f32) { w.write_str("Mf"); }
+ case (common::ty_f64) { w.write_str("MF"); }
}
}
- case (ty.ty_char) {w.write_char('c');}
- case (ty.ty_str) {w.write_char('s');}
- case (ty.ty_tag(?def,?tys)) { // TODO restore def_id
+ case (ty::ty_char) {w.write_char('c');}
+ case (ty::ty_str) {w.write_char('s');}
+ case (ty::ty_tag(?def,?tys)) { // TODO restore def_id
w.write_str("t[");
w.write_str(cx.ds(def));
w.write_char('|');
- for (ty.t t in tys) {
+ for (ty::t t in tys) {
enc_ty(w, cx, t);
}
w.write_char(']');
}
- case (ty.ty_box(?mt)) {w.write_char('@'); enc_mt(w, cx, mt); }
- case (ty.ty_vec(?mt)) {w.write_char('V'); enc_mt(w, cx, mt); }
- case (ty.ty_port(?t)) {w.write_char('P'); enc_ty(w, cx, t); }
- case (ty.ty_chan(?t)) {w.write_char('C'); enc_ty(w, cx, t); }
- case (ty.ty_tup(?mts)) {
+ case (ty::ty_box(?mt)) {w.write_char('@'); enc_mt(w, cx, mt); }
+ case (ty::ty_vec(?mt)) {w.write_char('V'); enc_mt(w, cx, mt); }
+ case (ty::ty_port(?t)) {w.write_char('P'); enc_ty(w, cx, t); }
+ case (ty::ty_chan(?t)) {w.write_char('C'); enc_ty(w, cx, t); }
+ case (ty::ty_tup(?mts)) {
w.write_str("T[");
- for (ty.mt mt in mts) {
+ for (ty::mt mt in mts) {
enc_mt(w, cx, mt);
}
w.write_char(']');
}
- case (ty.ty_rec(?fields)) {
+ case (ty::ty_rec(?fields)) {
w.write_str("R[");
- for (ty.field field in fields) {
+ for (ty::field field in fields) {
w.write_str(field.ident);
w.write_char('=');
enc_mt(w, cx, field.mt);
}
w.write_char(']');
}
- case (ty.ty_fn(?proto,?args,?out)) {
+ case (ty::ty_fn(?proto,?args,?out)) {
enc_proto(w, proto);
enc_ty_fn(w, cx, args, out);
}
- case (ty.ty_native_fn(?abi,?args,?out)) {
+ case (ty::ty_native_fn(?abi,?args,?out)) {
w.write_char('N');
alt (abi) {
- case (ast.native_abi_rust) { w.write_char('r'); }
- case (ast.native_abi_rust_intrinsic) {
+ case (ast::native_abi_rust) { w.write_char('r'); }
+ case (ast::native_abi_rust_intrinsic) {
w.write_char('i');
}
- case (ast.native_abi_cdecl) { w.write_char('c'); }
- case (ast.native_abi_llvm) { w.write_char('l'); }
+ case (ast::native_abi_cdecl) { w.write_char('c'); }
+ case (ast::native_abi_llvm) { w.write_char('l'); }
}
enc_ty_fn(w, cx, args, out);
}
- case (ty.ty_obj(?methods)) {
+ case (ty::ty_obj(?methods)) {
w.write_str("O[");
- for (ty.method m in methods) {
+ for (ty::method m in methods) {
enc_proto(w, m.proto);
w.write_str(m.ident);
enc_ty_fn(w, cx, m.inputs, m.output);
}
w.write_char(']');
}
- case (ty.ty_var(?id)) {
+ case (ty::ty_var(?id)) {
w.write_char('X');
- w.write_str(common.istr(id));
+ w.write_str(common::istr(id));
}
- case (ty.ty_native) {w.write_char('E');}
- case (ty.ty_param(?id)) {
+ case (ty::ty_native) {w.write_char('E');}
+ case (ty::ty_param(?id)) {
w.write_char('p');
- w.write_str(common.uistr(id));
+ w.write_str(common::uistr(id));
}
- case (ty.ty_type) {w.write_char('Y');}
+ case (ty::ty_type) {w.write_char('Y');}
// These two don't appear in crate metadata, but are here because
// `hash_ty()` uses this function.
- case (ty.ty_bound_param(?id)) {
+ case (ty::ty_bound_param(?id)) {
w.write_char('o');
- w.write_str(common.uistr(id));
+ w.write_str(common::uistr(id));
}
- case (ty.ty_local(?def)) {
+ case (ty::ty_local(?def)) {
w.write_char('L');
w.write_str(cx.ds(def));
}
}
}
- fn enc_proto(&IO.writer w, ast.proto proto) {
+ fn enc_proto(&io::writer w, ast::proto proto) {
alt (proto) {
- case (ast.proto_iter) { w.write_char('W'); }
- case (ast.proto_fn) { w.write_char('F'); }
+ case (ast::proto_iter) { w.write_char('W'); }
+ case (ast::proto_fn) { w.write_char('F'); }
}
}
- fn enc_ty_fn(&IO.writer w, &@ctxt cx, &vec[ty.arg] args, &ty.t out) {
+ fn enc_ty_fn(&io::writer w, &@ctxt cx, &vec[ty::arg] args, &ty::t out) {
w.write_char('[');
- for (ty.arg arg in args) {
- if (arg.mode == ty.mo_alias) { w.write_char('&'); }
+ for (ty::arg arg in args) {
+ if (arg.mode == ty::mo_alias) { w.write_char('&'); }
enc_ty(w, cx, arg.ty);
}
w.write_char(']');
@@ -263,338 +263,338 @@ mod Encode {
}
-// Returns a Plain Old LLVM String.
+// Returns a Plain Old LLVM String:
fn C_postr(&str s) -> ValueRef {
- ret llvm.LLVMConstString(Str.buf(s), Str.byte_len(s), False);
+ ret llvm::LLVMConstString(_str::buf(s), _str::byte_len(s), False);
}
// Path table encoding
-fn encode_name(&EBML.writer ebml_w, &str name) {
- EBML.start_tag(ebml_w, tag_paths_data_name);
- ebml_w.writer.write(Str.bytes(name));
- EBML.end_tag(ebml_w);
+fn encode_name(&ebml::writer ebml_w, &str name) {
+ ebml::start_tag(ebml_w, tag_paths_data_name);
+ ebml_w.writer.write(_str::bytes(name));
+ ebml::end_tag(ebml_w);
}
-fn encode_def_id(&EBML.writer ebml_w, &ast.def_id id) {
- EBML.start_tag(ebml_w, tag_def_id);
- ebml_w.writer.write(Str.bytes(def_to_str(id)));
- EBML.end_tag(ebml_w);
+fn encode_def_id(&ebml::writer ebml_w, &ast::def_id id) {
+ ebml::start_tag(ebml_w, tag_def_id);
+ ebml_w.writer.write(_str::bytes(def_to_str(id)));
+ ebml::end_tag(ebml_w);
}
-fn encode_tag_variant_paths(&EBML.writer ebml_w,
- &vec[ast.variant] variants,
+fn encode_tag_variant_paths(&ebml::writer ebml_w,
+ &vec[ast::variant] variants,
&vec[str] path,
&mutable vec[tup(str, uint)] index) {
- for (ast.variant variant in variants) {
+ for (ast::variant variant in variants) {
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);
encode_name(ebml_w, variant.node.name);
encode_def_id(ebml_w, variant.node.id);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
}
-fn add_to_index(&EBML.writer ebml_w,
+fn add_to_index(&ebml::writer ebml_w,
&vec[str] path,
&mutable vec[tup(str, uint)] index,
&str name) {
auto full_path = path + vec(name);
- index += vec(tup(Str.connect(full_path, "::"), ebml_w.writer.tell()));
+ index += vec(tup(_str::connect(full_path, "::"), ebml_w.writer.tell()));
}
-fn encode_native_module_item_paths(&EBML.writer ebml_w,
- &ast.native_mod nmod,
+fn encode_native_module_item_paths(&ebml::writer ebml_w,
+ &ast::native_mod nmod,
&vec[str] path,
&mutable vec[tup(str, uint)] index) {
- for (@ast.native_item nitem in nmod.items) {
+ for (@ast::native_item nitem in nmod.items) {
alt (nitem.node) {
- case (ast.native_item_ty(?id, ?did)) {
+ case (ast::native_item_ty(?id, ?did)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.native_item_fn(?id, _, _, _, ?did, _)) {
+ case (ast::native_item_fn(?id, _, _, _, ?did, _)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
}
}
}
-fn encode_module_item_paths(&EBML.writer ebml_w,
- &ast._mod module,
+fn encode_module_item_paths(&ebml::writer ebml_w,
+ &ast::_mod module,
&vec[str] path,
&mutable vec[tup(str, uint)] index) {
// TODO: only encode exported items
- for (@ast.item it in module.items) {
+ for (@ast::item it in module.items) {
alt (it.node) {
- case (ast.item_const(?id, _, ?tps, ?did, ?ann)) {
+ case (ast::item_const(?id, _, ?tps, ?did, ?ann)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_fn(?id, _, ?tps, ?did, ?ann)) {
+ case (ast::item_fn(?id, _, ?tps, ?did, ?ann)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_mod(?id, ?_mod, ?did)) {
+ case (ast::item_mod(?id, ?_mod, ?did)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_mod);
+ ebml::start_tag(ebml_w, tag_paths_data_mod);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
encode_module_item_paths(ebml_w, _mod, path + vec(id), index);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_native_mod(?id, ?nmod, ?did)) {
+ case (ast::item_native_mod(?id, ?nmod, ?did)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_mod);
+ ebml::start_tag(ebml_w, tag_paths_data_mod);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
encode_native_module_item_paths(ebml_w, nmod, path + vec(id),
index);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_ty(?id, _, ?tps, ?did, ?ann)) {
+ case (ast::item_ty(?id, _, ?tps, ?did, ?ann)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_tag(?id, ?variants, ?tps, ?did, _)) {
+ case (ast::item_tag(?id, ?variants, ?tps, ?did, _)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
encode_tag_variant_paths(ebml_w, variants, path, index);
}
- case (ast.item_obj(?id, _, ?tps, ?odid, ?ann)) {
+ case (ast::item_obj(?id, _, ?tps, ?odid, ?ann)) {
add_to_index(ebml_w, path, index, id);
- EBML.start_tag(ebml_w, tag_paths_data_item);
+ ebml::start_tag(ebml_w, tag_paths_data_item);
encode_name(ebml_w, id);
encode_def_id(ebml_w, odid.ctor);
encode_obj_type_id(ebml_w, odid.ty);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
}
}
}
-fn encode_item_paths(&EBML.writer ebml_w, &@ast.crate crate)
+fn encode_item_paths(&ebml::writer ebml_w, &@ast::crate crate)
-> vec[tup(str, uint)] {
let vec[tup(str, uint)] index = vec();
let vec[str] path = vec();
- 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);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
ret index;
}
// Item info table encoding
-fn encode_kind(&EBML.writer ebml_w, u8 c) {
- EBML.start_tag(ebml_w, tag_items_data_item_kind);
+fn encode_kind(&ebml::writer ebml_w, u8 c) {
+ ebml::start_tag(ebml_w, tag_items_data_item_kind);
ebml_w.writer.write(vec(c));
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
-fn def_to_str(&ast.def_id did) -> str {
+fn def_to_str(&ast::def_id did) -> str {
ret #fmt("%d:%d", did._0, did._1);
}
-fn encode_type_param_count(&EBML.writer ebml_w, &vec[ast.ty_param] tps) {
- EBML.start_tag(ebml_w, tag_items_data_item_ty_param_count);
- EBML.write_vint(ebml_w.writer, Vec.len[ast.ty_param](tps));
- EBML.end_tag(ebml_w);
+fn encode_type_param_count(&ebml::writer ebml_w, &vec[ast::ty_param] tps) {
+ ebml::start_tag(ebml_w, tag_items_data_item_ty_param_count);
+ ebml::write_vint(ebml_w.writer, _vec::len[ast::ty_param](tps));
+ ebml::end_tag(ebml_w);
}
-fn encode_variant_id(&EBML.writer ebml_w, &ast.def_id vid) {
- EBML.start_tag(ebml_w, tag_items_data_item_variant);
- ebml_w.writer.write(Str.bytes(def_to_str(vid)));
- EBML.end_tag(ebml_w);
+fn encode_variant_id(&ebml::writer ebml_w, &ast::def_id vid) {
+ ebml::start_tag(ebml_w, tag_items_data_item_variant);
+ ebml_w.writer.write(_str::bytes(def_to_str(vid)));
+ ebml::end_tag(ebml_w);
}
-fn encode_type(&@trans.crate_ctxt cx, &EBML.writer ebml_w, &ty.t typ) {
- EBML.start_tag(ebml_w, tag_items_data_item_type);
+fn encode_type(&@trans::crate_ctxt cx, &ebml::writer ebml_w, &ty::t typ) {
+ ebml::start_tag(ebml_w, tag_items_data_item_type);
auto f = def_to_str;
auto ty_str_ctxt = @rec(ds=f, tcx=cx.tcx,
abbrevs=ac_use_abbrevs(cx.type_abbrevs));
- Encode.enc_ty(IO.new_writer_(ebml_w.writer), ty_str_ctxt, typ);
- EBML.end_tag(ebml_w);
+ Encode::enc_ty(io::new_writer_(ebml_w.writer), ty_str_ctxt, typ);
+ ebml::end_tag(ebml_w);
}
-fn encode_symbol(&@trans.crate_ctxt cx, &EBML.writer ebml_w,
- &ast.def_id did) {
- EBML.start_tag(ebml_w, tag_items_data_item_symbol);
- ebml_w.writer.write(Str.bytes(cx.item_symbols.get(did)));
- EBML.end_tag(ebml_w);
+fn encode_symbol(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
+ &ast::def_id did) {
+ ebml::start_tag(ebml_w, tag_items_data_item_symbol);
+ ebml_w.writer.write(_str::bytes(cx.item_symbols.get(did)));
+ ebml::end_tag(ebml_w);
}
-fn encode_discriminant(&@trans.crate_ctxt cx, &EBML.writer ebml_w,
- &ast.def_id did) {
- EBML.start_tag(ebml_w, tag_items_data_item_symbol);
- ebml_w.writer.write(Str.bytes(cx.discrim_symbols.get(did)));
- EBML.end_tag(ebml_w);
+fn encode_discriminant(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
+ &ast::def_id did) {
+ ebml::start_tag(ebml_w, tag_items_data_item_symbol);
+ ebml_w.writer.write(_str::bytes(cx.discrim_symbols.get(did)));
+ ebml::end_tag(ebml_w);
}
-fn encode_tag_id(&EBML.writer ebml_w, &ast.def_id id) {
- EBML.start_tag(ebml_w, tag_items_data_item_tag_id);
- ebml_w.writer.write(Str.bytes(def_to_str(id)));
- EBML.end_tag(ebml_w);
+fn encode_tag_id(&ebml::writer ebml_w, &ast::def_id id) {
+ ebml::start_tag(ebml_w, tag_items_data_item_tag_id);
+ ebml_w.writer.write(_str::bytes(def_to_str(id)));
+ ebml::end_tag(ebml_w);
}
-fn encode_obj_type_id(&EBML.writer ebml_w, &ast.def_id id) {
- EBML.start_tag(ebml_w, tag_items_data_item_obj_type_id);
- ebml_w.writer.write(Str.bytes(def_to_str(id)));
- EBML.end_tag(ebml_w);
+fn encode_obj_type_id(&ebml::writer ebml_w, &ast::def_id id) {
+ ebml::start_tag(ebml_w, tag_items_data_item_obj_type_id);
+ ebml_w.writer.write(_str::bytes(def_to_str(id)));
+ ebml::end_tag(ebml_w);
}
-fn encode_tag_variant_info(&@trans.crate_ctxt cx, &EBML.writer ebml_w,
- &ast.def_id did, &vec[ast.variant] variants,
+fn encode_tag_variant_info(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
+ &ast::def_id did, &vec[ast::variant] variants,
&mutable vec[tup(int, uint)] index,
- &vec[ast.ty_param] ty_params) {
- for (ast.variant variant in variants) {
+ &vec[ast::ty_param] ty_params) {
+ for (ast::variant variant in variants) {
index += vec(tup(variant.node.id._1, ebml_w.writer.tell()));
- EBML.start_tag(ebml_w, tag_items_data_item);
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, variant.node.id);
encode_kind(ebml_w, 'v' as u8);
encode_tag_id(ebml_w, did);
- encode_type(cx, ebml_w, trans.node_ann_type(cx, variant.node.ann));
- if (Vec.len[ast.variant_arg](variant.node.args) > 0u) {
+ encode_type(cx, ebml_w, trans::node_ann_type(cx, variant.node.ann));
+ if (_vec::len[ast::variant_arg](variant.node.args) > 0u) {
encode_symbol(cx, ebml_w, variant.node.id);
}
encode_discriminant(cx, ebml_w, variant.node.id);
encode_type_param_count(ebml_w, ty_params);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
}
-fn encode_info_for_item(@trans.crate_ctxt cx, &EBML.writer ebml_w,
- @ast.item item, &mutable vec[tup(int, uint)] index) {
+fn encode_info_for_item(@trans::crate_ctxt cx, &ebml::writer ebml_w,
+ @ast::item item, &mutable vec[tup(int, uint)] index) {
alt (item.node) {
- case (ast.item_const(_, _, _, ?did, ?ann)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_const(_, _, _, ?did, ?ann)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'c' as u8);
- encode_type(cx, ebml_w, trans.node_ann_type(cx, ann));
+ encode_type(cx, ebml_w, trans::node_ann_type(cx, ann));
encode_symbol(cx, ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_fn(_, _, ?tps, ?did, ?ann)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_fn(_, _, ?tps, ?did, ?ann)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'f' as u8);
encode_type_param_count(ebml_w, tps);
- encode_type(cx, ebml_w, trans.node_ann_type(cx, ann));
+ encode_type(cx, ebml_w, trans::node_ann_type(cx, ann));
encode_symbol(cx, ebml_w, did);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_mod(_, _, ?did)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_mod(_, _, ?did)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'm' as u8);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_native_mod(?id, _, ?did)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_native_mod(?id, _, ?did)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'n' as u8);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- case (ast.item_ty(?id, _, ?tps, ?did, ?ann)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_ty(?id, _, ?tps, ?did, ?ann)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'y' as u8);
encode_type_param_count(ebml_w, tps);
- encode_type(cx, ebml_w, trans.node_ann_type(cx, ann));
- EBML.end_tag(ebml_w);
+ encode_type(cx, ebml_w, trans::node_ann_type(cx, ann));
+ ebml::end_tag(ebml_w);
}
- case (ast.item_tag(?id, ?variants, ?tps, ?did, ?ann)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_tag(?id, ?variants, ?tps, ?did, ?ann)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 't' as u8);
encode_type_param_count(ebml_w, tps);
- encode_type(cx, ebml_w, trans.node_ann_type(cx, ann));
- for (ast.variant v in variants) {
+ encode_type(cx, ebml_w, trans::node_ann_type(cx, ann));
+ for (ast::variant v in variants) {
encode_variant_id(ebml_w, v.node.id);
}
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
encode_tag_variant_info(cx, ebml_w, did, variants, index, tps);
}
- case (ast.item_obj(?id, _, ?tps, ?odid, ?ann)) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+ case (ast::item_obj(?id, _, ?tps, ?odid, ?ann)) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, odid.ctor);
encode_kind(ebml_w, 'o' as u8);
encode_type_param_count(ebml_w, tps);
- auto fn_ty = trans.node_ann_type(cx, ann);
+ auto fn_ty = trans::node_ann_type(cx, ann);
encode_type(cx, ebml_w, fn_ty);
encode_symbol(cx, ebml_w, odid.ctor);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
- EBML.start_tag(ebml_w, tag_items_data_item);
+ ebml::start_tag(ebml_w, tag_items_data_item);
encode_def_id(ebml_w, odid.ty);
encode_kind(ebml_w, 'y' as u8);
encode_type_param_count(ebml_w, tps);
- encode_type(cx, ebml_w, ty.ty_fn_ret(cx.tcx, fn_ty));
- EBML.end_tag(ebml_w);
+ encode_type(cx, ebml_w, ty::ty_fn_ret(cx.tcx, fn_ty));
+ ebml::end_tag(ebml_w);
}
}
}
-fn encode_info_for_native_item(&@trans.crate_ctxt cx, &EBML.writer ebml_w,
- &@ast.native_item nitem) {
- EBML.start_tag(ebml_w, tag_items_data_item);
+fn encode_info_for_native_item(&@trans::crate_ctxt cx, &ebml::writer ebml_w,
+ &@ast::native_item nitem) {
+ ebml::start_tag(ebml_w, tag_items_data_item);
alt (nitem.node) {
- case (ast.native_item_ty(_, ?did)) {
+ case (ast::native_item_ty(_, ?did)) {
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'T' as u8);
- encode_type(cx, ebml_w, ty.mk_native(cx.tcx));
+ encode_type(cx, ebml_w, ty::mk_native(cx.tcx));
}
- case (ast.native_item_fn(_, _, _, ?tps, ?did, ?ann)) {
+ case (ast::native_item_fn(_, _, _, ?tps, ?did, ?ann)) {
encode_def_id(ebml_w, did);
encode_kind(ebml_w, 'F' as u8);
encode_type_param_count(ebml_w, tps);
- encode_type(cx, ebml_w, trans.node_ann_type(cx, ann));
+ encode_type(cx, ebml_w, trans::node_ann_type(cx, ann));
encode_symbol(cx, ebml_w, did);
}
}
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
-fn encode_info_for_items(&@trans.crate_ctxt cx, &EBML.writer ebml_w)
+fn encode_info_for_items(&@trans::crate_ctxt cx, &ebml::writer ebml_w)
-> vec[tup(int, uint)] {
let vec[tup(int, uint)] index = vec();
- EBML.start_tag(ebml_w, tag_items_data);
- for each (@tup(ast.def_id, @ast.item) kvp in cx.items.items()) {
+ ebml::start_tag(ebml_w, tag_items_data);
+ for each (@tup(ast::def_id, @ast::item) kvp in cx.items.items()) {
index += vec(tup(kvp._0._1, ebml_w.writer.tell()));
encode_info_for_item(cx, ebml_w, kvp._1, index);
}
- for each (@tup(ast.def_id, @ast.native_item) kvp in
+ for each (@tup(ast::def_id, @ast::native_item) kvp in
cx.native_items.items()) {
index += vec(tup(kvp._0._1, ebml_w.writer.tell()));
encode_info_for_native_item(cx, ebml_w, kvp._1);
}
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
ret index;
}
@@ -610,7 +610,7 @@ fn hash_def_num(&int def_num) -> uint {
fn hash_path(&str s) -> uint {
auto h = 5381u;
- for (u8 ch in Str.bytes(s)) {
+ for (u8 ch in _str::bytes(s)) {
h = ((h << 5u) + h) ^ (ch as uint);
}
ret h;
@@ -619,7 +619,7 @@ fn hash_path(&str s) -> uint {
fn create_index[T](&vec[tup(T, uint)] index, fn(&T) -> uint hash_fn)
-> vec[vec[tup(T, uint)]] {
let vec[vec[tup(T, uint)]] buckets = vec();
- for each (uint i in UInt.range(0u, 256u)) {
+ for each (uint i in _uint::range(0u, 256u)) {
let vec[tup(T, uint)] bucket = vec();
buckets += vec(bucket);
}
@@ -632,69 +632,69 @@ fn create_index[T](&vec[tup(T, uint)] index, fn(&T) -> uint hash_fn)
ret buckets;
}
-fn encode_index[T](&EBML.writer ebml_w, &vec[vec[tup(T, uint)]] buckets,
- fn(&IO.writer, &T) write_fn) {
- auto writer = IO.new_writer_(ebml_w.writer);
+fn encode_index[T](&ebml::writer ebml_w, &vec[vec[tup(T, uint)]] buckets,
+ fn(&io::writer, &T) write_fn) {
+ auto writer = io::new_writer_(ebml_w.writer);
- EBML.start_tag(ebml_w, tag_index);
+ ebml::start_tag(ebml_w, tag_index);
let vec[uint] bucket_locs = vec();
- EBML.start_tag(ebml_w, tag_index_buckets);
+ ebml::start_tag(ebml_w, tag_index_buckets);
for (vec[tup(T, uint)] bucket in buckets) {
bucket_locs += vec(ebml_w.writer.tell());
- EBML.start_tag(ebml_w, tag_index_buckets_bucket);
+ ebml::start_tag(ebml_w, tag_index_buckets_bucket);
for (tup(T, uint) elt 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._1, 4u);
write_fn(writer, elt._0);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
- EBML.start_tag(ebml_w, tag_index_table);
+ ebml::start_tag(ebml_w, tag_index_table);
for (uint pos in bucket_locs) {
writer.write_be_uint(pos, 4u);
}
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
}
-fn write_str(&IO.writer writer, &str s) {
+fn write_str(&io::writer writer, &str s) {
writer.write_str(s);
}
-fn write_int(&IO.writer writer, &int n) {
+fn write_int(&io::writer writer, &int n) {
writer.write_be_uint(n as uint, 4u);
}
-fn encode_metadata(&@trans.crate_ctxt cx, &@ast.crate crate)
+fn encode_metadata(&@trans::crate_ctxt cx, &@ast::crate crate)
-> ValueRef {
- auto string_w = IO.string_writer();
+ auto string_w = io::string_writer();
auto buf_w = string_w.get_writer().get_buf_writer();
- auto ebml_w = EBML.create_writer(buf_w);
+ auto ebml_w = ebml::create_writer(buf_w);
// Encode and index the paths.
- EBML.start_tag(ebml_w, tag_paths);
+ ebml::start_tag(ebml_w, tag_paths);
auto paths_index = encode_item_paths(ebml_w, crate);
auto str_writer = write_str;
auto path_hasher = hash_path;
auto paths_buckets = create_index[str](paths_index, path_hasher);
encode_index[str](ebml_w, paths_buckets, str_writer);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
// Encode and index the items.
- EBML.start_tag(ebml_w, tag_items);
+ ebml::start_tag(ebml_w, tag_items);
auto items_index = encode_info_for_items(cx, ebml_w);
auto int_writer = write_int;
auto item_hasher = hash_def_num;
auto items_buckets = create_index[int](items_index, item_hasher);
encode_index[int](ebml_w, items_buckets, int_writer);
- EBML.end_tag(ebml_w);
+ ebml::end_tag(ebml_w);
// Pad this, since something (LLVM, presumably) is cutting off the
// remaining % 4 bytes.
@@ -703,17 +703,17 @@ fn encode_metadata(&@trans.crate_ctxt cx, &@ast.crate crate)
ret C_postr(string_w.get_str());
}
-fn write_metadata(&@trans.crate_ctxt cx, &@ast.crate crate) {
+fn write_metadata(&@trans::crate_ctxt cx, &@ast::crate crate) {
auto llmeta = C_postr("");
if (cx.sess.get_opts().shared) {
llmeta = encode_metadata(cx, crate);
}
- auto llconst = trans.C_struct(vec(llmeta));
- auto llglobal = llvm.LLVMAddGlobal(cx.llmod, trans.val_ty(llconst),
- Str.buf("rust_metadata"));
- llvm.LLVMSetInitializer(llglobal, llconst);
- llvm.LLVMSetSection(llglobal, Str.buf(x86.get_meta_sect_name()));
+ auto llconst = trans::C_struct(vec(llmeta));
+ auto llglobal = llvm::LLVMAddGlobal(cx.llmod, trans::val_ty(llconst),
+ _str::buf("rust_metadata"));
+ llvm::LLVMSetInitializer(llglobal, llconst);
+ llvm::LLVMSetSection(llglobal, _str::buf(x86::get_meta_sect_name()));
}
//
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index 7b7d6369..c81d9030 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -1,26 +1,25 @@
-import front.ast;
-import front.ast.ident;
-import front.ast.def;
-import front.ast.def_id;
-import front.ast.ann;
-import front.creader;
-import driver.session.session;
-import util.common.new_def_hash;
-import util.common.new_int_hash;
-import util.common.new_uint_hash;
-import util.common.new_str_hash;
-import util.common.span;
-import util.typestate_ann.ts_ann;
-import std.Map.hashmap;
-import std.List;
-import std.List.list;
-import std.List.nil;
-import std.List.cons;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
-import std.Str;
-import std.Vec;
+import front::ast;
+import front::ast::ident;
+import front::ast::def;
+import front::ast::def_id;
+import front::ast::ann;
+import front::creader;
+import driver::session::session;
+import util::common::new_def_hash;
+import util::common::new_int_hash;
+import util::common::new_uint_hash;
+import util::common::new_str_hash;
+import util::common::span;
+import util::typestate_ann::ts_ann;
+import std::map::hashmap;
+import std::list::list;
+import std::list::nil;
+import std::list::cons;
+import std::option;
+import std::option::some;
+import std::option::none;
+import std::_str;
+import std::_vec;
// Resolving happens in two passes. The first pass collects defids of all
// (internal) imports and modules, so that they can be looked up when needed,
@@ -34,53 +33,53 @@ import std.Vec;
// isn't a const.)
tag scope {
- scope_crate(@ast.crate);
- scope_item(@ast.item);
- scope_native_item(@ast.native_item);
- scope_loop(@ast.decl); // there's only 1 decl per loop.
- scope_block(ast.block);
- scope_arm(ast.arm);
+ scope_crate(@ast::crate);
+ scope_item(@ast::item);
+ scope_native_item(@ast::native_item);
+ scope_loop(@ast::decl); // there's only 1 decl per loop.
+ scope_block(ast::block);
+ scope_arm(ast::arm);
}
tag import_state {
- todo(@ast.view_item, list[scope]);
+ todo(@ast::view_item, list[scope]);
resolving(span);
- resolved(Option.t[def] /* value */, Option.t[def] /* type */);
+ resolved(option::t[def] /* value */, option::t[def] /* type */);
}
type ext_hash = hashmap[tup(def_id,str),def];
fn new_ext_hash() -> ext_hash {
fn hash(&tup(def_id,str) v) -> uint {
- ret Str.hash(v._1) + util.common.hash_def(v._0);
+ ret _str::hash(v._1) + util::common::hash_def(v._0);
}
fn eq(&tup(def_id,str) v1, &tup(def_id,str) v2) -> bool {
- ret util.common.def_eq(v1._0, v2._0) &&
- Str.eq(v1._1, v2._1);
+ ret util::common::def_eq(v1._0, v2._0) &&
+ _str::eq(v1._1, v2._1);
}
- ret std.Map.mk_hashmap[tup(def_id,str),def](hash, eq);
+ ret std::map::mk_hashmap[tup(def_id,str),def](hash, eq);
}
tag mod_index_entry {
- mie_view_item(@ast.view_item);
- mie_item(@ast.item);
- mie_tag_variant(@ast.item /* tag item */, uint /* variant index */);
+ mie_view_item(@ast::view_item);
+ mie_item(@ast::item);
+ mie_tag_variant(@ast::item /* tag item */, uint /* variant index */);
}
type mod_index = hashmap[ident,mod_index_entry];
-type indexed_mod = rec(ast._mod m, mod_index index);
+type indexed_mod = rec(ast::_mod m, mod_index index);
tag native_mod_index_entry {
- nmie_view_item(@ast.view_item);
- nmie_item(@ast.native_item);
+ nmie_view_item(@ast::view_item);
+ nmie_item(@ast::native_item);
}
type nmod_index = hashmap[ident,native_mod_index_entry];
-type indexed_nmod = rec(ast.native_mod m, nmod_index index);
+type indexed_nmod = rec(ast::native_mod m, nmod_index index);
type def_map = hashmap[uint,def];
type env = rec(def_map def_map,
- hashmap[ast.def_num,import_state] imports,
- hashmap[ast.def_num,@indexed_mod] mod_map,
- hashmap[ast.def_num,@indexed_nmod] nmod_map,
+ hashmap[ast::def_num,import_state] imports,
+ hashmap[ast::def_num,@indexed_mod] mod_map,
+ hashmap[ast::def_num,@indexed_nmod] nmod_map,
hashmap[def_id,vec[ident]] ext_map,
ext_hash ext_cache,
session sess);
@@ -94,8 +93,8 @@ tag namespace {
ns_type;
}
-fn resolve_crate(session sess, @ast.crate crate)
- -> tup(@ast.crate, def_map) {
+fn resolve_crate(session sess, @ast::crate crate)
+ -> tup(@ast::crate, def_map) {
auto e = @rec(def_map = new_uint_hash[def](),
imports = new_int_hash[import_state](),
mod_map = new_int_hash[@indexed_mod](),
@@ -111,47 +110,47 @@ fn resolve_crate(session sess, @ast.crate crate)
// Locate all modules and imports and index them, so that the next passes can
// resolve through them.
-fn map_crate(&@env e, &ast.crate c) {
+fn map_crate(&@env e, &ast::crate c) {
auto cell = @mutable nil[scope];
auto v = rec(visit_crate_pre = bind push_env_for_crate(cell, _),
visit_crate_post = bind pop_env_for_crate(cell, _),
visit_view_item_pre = bind visit_view_item(e, cell, _),
visit_item_pre = bind push_env_for_item_map_mod(e, cell, _),
visit_item_post = bind pop_env_for_item(cell, _)
- with walk.default_visitor());
+ with walk::default_visitor());
// Register the top-level mod
e.mod_map.insert(-1, @rec(m=c.node.module,
index=index_mod(c.node.module)));
- walk.walk_crate(v, c);
+ walk::walk_crate(v, c);
// Helpers for this pass.
- fn push_env_for_crate(@mutable list[scope] sc, &ast.crate c) {
+ fn push_env_for_crate(@mutable list[scope] sc, &ast::crate c) {
*sc = cons[scope](scope_crate(@c), @*sc);
}
- fn pop_env_for_crate(@mutable list[scope] sc, &ast.crate c) {
- *sc = List.cdr(*sc);
+ fn pop_env_for_crate(@mutable list[scope] sc, &ast::crate c) {
+ *sc = std::list::cdr(*sc);
}
fn push_env_for_item_map_mod(@env e, @mutable list[scope] sc,
- &@ast.item i) {
+ &@ast::item i) {
*sc = cons[scope](scope_item(i), @*sc);
alt (i.node) {
- case (ast.item_mod(_, ?md, ?defid)) {
+ case (ast::item_mod(_, ?md, ?defid)) {
auto index = index_mod(md);
e.mod_map.insert(defid._1, @rec(m=md, index=index));
}
- case (ast.item_native_mod(_, ?nmd, ?defid)) {
+ case (ast::item_native_mod(_, ?nmd, ?defid)) {
auto index = index_nmod(nmd);
e.nmod_map.insert(defid._1, @rec(m=nmd, index=index));
}
case (_) {}
}
}
- fn pop_env_for_item(@mutable list[scope] sc, &@ast.item i) {
- *sc = List.cdr(*sc);
+ fn pop_env_for_item(@mutable list[scope] sc, &@ast::item i) {
+ *sc = std::list::cdr(*sc);
}
- fn visit_view_item(@env e, @mutable list[scope] sc, &@ast.view_item i) {
+ fn visit_view_item(@env e, @mutable list[scope] sc, &@ast::view_item i) {
alt (i.node) {
- case (ast.view_item_import(_, ?ids, ?defid)) {
+ case (ast::view_item_import(_, ?ids, ?defid)) {
e.imports.insert(defid._1, todo(i, *sc));
}
case (_) {}
@@ -160,7 +159,7 @@ fn map_crate(&@env e, &ast.crate c) {
}
fn resolve_imports(&env e) {
- for each (@tup(ast.def_num, import_state) it in e.imports.items()) {
+ for each (@tup(ast::def_num, import_state) it in e.imports.items()) {
alt (it._1) {
case (todo(?item, ?sc)) {
resolve_import(e, item, sc);
@@ -171,7 +170,7 @@ fn resolve_imports(&env e) {
}
// FIXME this should use walk (will need to add walk_arm)
-fn resolve_names(&@env e, &ast.crate c) -> @ast.crate {
+fn resolve_names(&@env e, &ast::crate c) -> @ast::crate {
auto fld = @rec(fold_pat_tag = bind fold_pat_tag(e,_,_,_,_,_),
fold_expr_path = bind fold_expr_path(e,_,_,_,_),
fold_ty_path = bind fold_ty_path(e,_,_,_,_),
@@ -182,41 +181,41 @@ fn resolve_names(&@env e, &ast.crate c) -> @ast.crate {
update_env_for_block = bind update_env_for_block(_,_),
update_env_for_arm = bind update_env_for_arm(_,_),
update_env_for_expr = bind update_env_for_expr(_,_)
- with *fold.new_identity_fold[list[scope]]());
- ret fold.fold_crate(nil[scope], fld, @c);
+ with *fold::new_identity_fold[list[scope]]());
+ ret fold::fold_crate(nil[scope], fld, @c);
// Helpers for this pass
- fn update_env_for_crate(&list[scope] sc, &@ast.crate c) -> list[scope] {
+ fn update_env_for_crate(&list[scope] sc, &@ast::crate c) -> list[scope] {
ret cons[scope](scope_crate(c), @sc);
}
- fn update_env_for_item(&list[scope] sc, &@ast.item i) -> list[scope] {
+ fn update_env_for_item(&list[scope] sc, &@ast::item i) -> list[scope] {
ret cons[scope](scope_item(i), @sc);
}
- fn update_env_for_native_item(&list[scope] sc, &@ast.native_item i)
+ fn update_env_for_native_item(&list[scope] sc, &@ast::native_item i)
-> list[scope] {
ret cons[scope](scope_native_item(i), @sc);
}
- fn update_env_for_block(&list[scope] sc, &ast.block b) -> list[scope] {
+ fn update_env_for_block(&list[scope] sc, &ast::block b) -> list[scope] {
ret cons[scope](scope_block(b), @sc);
}
- fn update_env_for_expr(&list[scope] sc, &@ast.expr x) -> list[scope] {
+ fn update_env_for_expr(&list[scope] sc, &@ast::expr x) -> list[scope] {
alt (x.node) {
- case (ast.expr_for(?d, _, _, _)) {
+ case (ast::expr_for(?d, _, _, _)) {
ret cons[scope](scope_loop(d), @sc);
}
- case (ast.expr_for_each(?d, _, _, _)) {
+ case (ast::expr_for_each(?d, _, _, _)) {
ret cons[scope](scope_loop(d), @sc);
}
case (_) { ret sc; }
}
}
- fn update_env_for_arm(&list[scope] sc, &ast.arm p) -> list[scope] {
+ fn update_env_for_arm(&list[scope] sc, &ast::arm p) -> list[scope] {
ret cons[scope](scope_arm(p), @sc);
}
}
-fn lookup_import(&env e, def_id defid, namespace ns) -> Option.t[def] {
+fn lookup_import(&env e, def_id defid, namespace ns) -> option::t[def] {
alt (e.imports.get(defid._1)) {
case (todo(?item, ?sc)) {
resolve_import(e, item, sc);
@@ -232,16 +231,16 @@ fn lookup_import(&env e, def_id defid, namespace ns) -> Option.t[def] {
}
}
-fn resolve_import(&env e, &@ast.view_item it, &list[scope] sc) {
+fn resolve_import(&env e, &@ast::view_item it, &list[scope] sc) {
auto defid; auto ids;
alt (it.node) {
- case (ast.view_item_import(_, ?_ids, ?_defid)) {
+ case (ast::view_item_import(_, ?_ids, ?_defid)) {
defid = _defid; ids = _ids;
}
}
e.imports.insert(defid._1, resolving(it.span));
- auto n_idents = Vec.len(ids);
+ auto n_idents = _vec::len(ids);
auto end_id = ids.(n_idents - 1u);
if (n_idents == 1u) {
@@ -270,7 +269,7 @@ fn resolve_import(&env e, &@ast.view_item it, &list[scope] sc) {
}
fn register(&env e, def_id defid, &span sp, ident id,
- Option.t[def] val, Option.t[def] typ) {
+ option::t[def] val, option::t[def] typ) {
if (val == none[def] && typ == none[def]) {
unresolved(e, sp, id, "import");
}
@@ -278,40 +277,40 @@ fn resolve_import(&env e, &@ast.view_item it, &list[scope] sc) {
}
}
-fn fold_expr_path(@env e, &list[scope] sc, &span sp, &ast.path p, &ann a)
- -> @ast.expr {
+fn fold_expr_path(@env e, &list[scope] sc, &span sp, &ast::path p, &ann a)
+ -> @ast::expr {
auto df = lookup_path_strict(*e, sc, sp, p.node.idents, ns_value);
- e.def_map.insert(ast.ann_tag(a), df);
- ret @fold.respan(sp, ast.expr_path(p, a));
+ e.def_map.insert(ast::ann_tag(a), df);
+ ret @fold::respan(sp, ast::expr_path(p, a));
}
-fn fold_pat_tag(@env e, &list[scope] sc, &span sp, &ast.path p,
- &vec[@ast.pat] args, &ann a) -> @ast.pat {
+fn fold_pat_tag(@env e, &list[scope] sc, &span sp, &ast::path p,
+ &vec[@ast::pat] args, &ann a) -> @ast::pat {
alt (lookup_path_strict(*e, sc, sp, p.node.idents, ns_value)) {
- case (ast.def_variant(?did, ?vid)) {
- e.def_map.insert(ast.ann_tag(a), ast.def_variant(did, vid));
- ret @fold.respan[ast.pat_](sp, ast.pat_tag(p, args, a));
+ case (ast::def_variant(?did, ?vid)) {
+ e.def_map.insert(ast::ann_tag(a), ast::def_variant(did, vid));
+ ret @fold::respan[ast::pat_](sp, ast::pat_tag(p, args, a));
}
case (_) {
e.sess.span_err(sp, "not a tag variant: " +
- Str.connect(p.node.idents, "::"));
+ _str::connect(p.node.idents, "::"));
fail;
}
}
}
-fn fold_ty_path(@env e, &list[scope] sc, &span sp, &ast.path p,
- &ast.ann a) -> @ast.ty {
+fn fold_ty_path(@env e, &list[scope] sc, &span sp, &ast::path p,
+ &ast::ann a) -> @ast::ty {
auto new_def = lookup_path_strict(*e, sc, sp, p.node.idents, ns_type);
- e.def_map.insert(ast.ann_tag(a), new_def);
- ret @fold.respan[ast.ty_](sp, ast.ty_path(p, a));
+ e.def_map.insert(ast::ann_tag(a), new_def);
+ ret @fold::respan[ast::ty_](sp, ast::ty_path(p, a));
}
fn is_module(def d) -> bool {
alt (d) {
- case (ast.def_mod(_)) { ret true; }
- case (ast.def_native_mod(_)) { ret true; }
+ case (ast::def_mod(_)) { ret true; }
+ case (ast::def_native_mod(_)) { ret true; }
case (_) { ret false; }
}
}
@@ -329,7 +328,7 @@ fn unresolved(&env e, &span sp, ident id, str kind) {
fn lookup_path_strict(&env e, &list[scope] sc, &span sp, vec[ident] idents,
namespace ns) -> def {
- auto n_idents = Vec.len(idents);
+ auto n_idents = _vec::len(idents);
auto dcur = lookup_in_scope_strict(e, sc, sp, idents.(0), ns);
auto i = 1u;
while (i < n_idents) {
@@ -341,7 +340,7 @@ fn lookup_path_strict(&env e, &list[scope] sc, &span sp, vec[ident] idents,
i += 1u;
}
if (is_module(dcur)) {
- e.sess.span_err(sp, Str.connect(idents, "::") +
+ e.sess.span_err(sp, _str::connect(idents, "::") +
" is a module, not a " + ns_name(ns));
}
ret dcur;
@@ -361,34 +360,34 @@ fn lookup_in_scope_strict(&env e, list[scope] sc, &span sp, ident id,
}
fn lookup_in_scope(&env e, list[scope] sc, ident id, namespace ns)
- -> Option.t[def] {
+ -> option::t[def] {
fn in_scope(&env e, ident id, &scope s, namespace ns)
- -> Option.t[def] {
+ -> option::t[def] {
alt (s) {
case (scope_crate(?c)) {
- auto defid = tup(ast.local_crate, -1);
+ auto defid = tup(ast::local_crate, -1);
ret lookup_in_regular_mod(e, defid, id, ns, inside);
}
case (scope_item(?it)) {
alt (it.node) {
- case (ast.item_fn(_, ?f, ?ty_params, _, _)) {
+ case (ast::item_fn(_, ?f, ?ty_params, _, _)) {
ret lookup_in_fn(id, f.decl, ty_params, ns);
}
- case (ast.item_obj(_, ?ob, ?ty_params, _, _)) {
+ case (ast::item_obj(_, ?ob, ?ty_params, _, _)) {
ret lookup_in_obj(id, ob, ty_params, ns);
}
- case (ast.item_tag(_, _, ?ty_params, _, _)) {
+ case (ast::item_tag(_, _, ?ty_params, _, _)) {
if (ns == ns_type) {
ret lookup_in_ty_params(id, ty_params);
}
}
- case (ast.item_mod(_, _, ?defid)) {
+ case (ast::item_mod(_, _, ?defid)) {
ret lookup_in_regular_mod(e, defid, id, ns, inside);
}
- case (ast.item_native_mod(_, ?m, ?defid)) {
+ case (ast::item_native_mod(_, ?m, ?defid)) {
ret lookup_in_native_mod(e, defid, id, ns);
}
- case (ast.item_ty(_, _, ?ty_params, _, _)) {
+ case (ast::item_ty(_, _, ?ty_params, _, _)) {
if (ns == ns_type) {
ret lookup_in_ty_params(id, ty_params);
}
@@ -399,7 +398,7 @@ fn lookup_in_scope(&env e, list[scope] sc, ident id, namespace ns)
case (scope_native_item(?it)) {
alt (it.node) {
- case (ast.native_item_fn(_, _, ?decl, ?ty_params, _, _)) {
+ case (ast::native_item_fn(_, _, ?decl, ?ty_params, _, _)){
ret lookup_in_fn(id, decl, ty_params, ns);
}
}
@@ -408,9 +407,9 @@ fn lookup_in_scope(&env e, list[scope] sc, ident id, namespace ns)
case (scope_loop(?d)) {
if (ns == ns_value) {
alt (d.node) {
- case (ast.decl_local(?local)) {
- if (Str.eq(local.ident, id)) {
- ret some(ast.def_local(local.id));
+ case (ast::decl_local(?local)) {
+ if (_str::eq(local.ident, id)) {
+ ret some(ast::def_local(local.id));
}
}
}
@@ -445,27 +444,27 @@ fn lookup_in_scope(&env e, list[scope] sc, ident id, namespace ns)
}
}
-fn lookup_in_ty_params(ident id, &vec[ast.ty_param] ty_params)
- -> Option.t[def] {
+fn lookup_in_ty_params(ident id, &vec[ast::ty_param] ty_params)
+ -> option::t[def] {
auto i = 0u;
- for (ast.ty_param tp in ty_params) {
- if (Str.eq(tp, id)) {
- ret some(ast.def_ty_arg(i));
+ for (ast::ty_param tp in ty_params) {
+ if (_str::eq(tp, id)) {
+ ret some(ast::def_ty_arg(i));
}
i += 1u;
}
ret none[def];
}
-fn lookup_in_pat(ident id, &ast.pat pat) -> Option.t[def] {
+fn lookup_in_pat(ident id, &ast::pat pat) -> option::t[def] {
alt (pat.node) {
- case (ast.pat_bind(?name, ?defid, _)) {
- if (Str.eq(name, id)) { ret some(ast.def_binding(defid)); }
+ case (ast::pat_bind(?name, ?defid, _)) {
+ if (_str::eq(name, id)) { ret some(ast::def_binding(defid)); }
}
- case (ast.pat_wild(_)) {}
- case (ast.pat_lit(_, _)) {}
- case (ast.pat_tag(_, ?pats, _)) {
- for (@ast.pat p in pats) {
+ case (ast::pat_wild(_)) {}
+ case (ast::pat_lit(_, _)) {}
+ case (ast::pat_tag(_, ?pats, _)) {
+ for (@ast::pat p in pats) {
auto found = lookup_in_pat(id, *p);
if (found != none[def]) { ret found; }
}
@@ -475,12 +474,12 @@ fn lookup_in_pat(ident id, &ast.pat pat) -> Option.t[def] {
}
-fn lookup_in_fn(ident id, &ast.fn_decl decl,
- &vec[ast.ty_param] ty_params, namespace ns) -> Option.t[def] {
+fn lookup_in_fn(ident id, &ast::fn_decl decl, &vec[ast::ty_param] ty_params,
+ namespace ns) -> option::t[def] {
if (ns == ns_value) {
- for (ast.arg a in decl.inputs) {
- if (Str.eq(a.ident, id)) {
- ret some(ast.def_arg(a.id));
+ for (ast::arg a in decl.inputs) {
+ if (_str::eq(a.ident, id)) {
+ ret some(ast::def_arg(a.id));
}
}
ret none[def];
@@ -489,12 +488,12 @@ fn lookup_in_fn(ident id, &ast.fn_decl decl,
}
}
-fn lookup_in_obj(ident id, &ast._obj ob, &vec[ast.ty_param] ty_params,
- namespace ns) -> Option.t[def] {
+fn lookup_in_obj(ident id, &ast::_obj ob, &vec[ast::ty_param] ty_params,
+ namespace ns) -> option::t[def] {
if (ns == ns_value) {
- for (ast.obj_field f in ob.fields) {
- if (Str.eq(f.ident, id)) {
- ret some(ast.def_obj_field(f.id));
+ for (ast::obj_field f in ob.fields) {
+ if (_str::eq(f.ident, id)) {
+ ret some(ast::def_obj_field(f.id));
}
}
ret none[def];
@@ -503,36 +502,36 @@ fn lookup_in_obj(ident id, &ast._obj ob, &vec[ast.ty_param] ty_params,
}
}
-fn lookup_in_block(ident id, &ast.block_ b, namespace ns)
- -> Option.t[def] {
- for (@ast.stmt st in b.stmts) {
+fn lookup_in_block(ident id, &ast::block_ b, namespace ns)
+ -> option::t[def] {
+ for (@ast::stmt st in b.stmts) {
alt (st.node) {
- case (ast.stmt_decl(?d,_)) {
+ case (ast::stmt_decl(?d,_)) {
alt (d.node) {
- case (ast.decl_local(?loc)) {
- if (ns == ns_value && Str.eq(id, loc.ident)) {
- ret some(ast.def_local(loc.id));
+ case (ast::decl_local(?loc)) {
+ if (ns == ns_value && _str::eq(id, loc.ident)) {
+ ret some(ast::def_local(loc.id));
}
}
- case (ast.decl_item(?it)) {
+ case (ast::decl_item(?it)) {
alt (it.node) {
- case (ast.item_tag(?name, ?variants, _,
+ case (ast::item_tag(?name, ?variants, _,
?defid, _)) {
if (ns == ns_type) {
- if (Str.eq(name, id)) {
- ret some(ast.def_ty(defid));
+ if (_str::eq(name, id)) {
+ ret some(ast::def_ty(defid));
}
} else {
- for (ast.variant v in variants) {
- if (Str.eq(v.node.name, id)) {
- ret some(ast.def_variant(
+ for (ast::variant v in variants) {
+ if (_str::eq(v.node.name, id)) {
+ ret some(ast::def_variant(
defid, v.node.id));
}
}
}
}
case (_) {
- if (Str.eq(ast.item_ident(it), id)) {
+ if (_str::eq(ast::item_ident(it), id)) {
auto found = found_def_item(it, ns);
if (found != none[def]) { ret found; }
}
@@ -547,29 +546,29 @@ fn lookup_in_block(ident id, &ast.block_ b, namespace ns)
ret none[def];
}
-fn found_def_item(@ast.item i, namespace ns) -> Option.t[def] {
+fn found_def_item(@ast::item i, namespace ns) -> option::t[def] {
alt (i.node) {
- case (ast.item_const(_, _, _, ?defid, _)) {
- if (ns == ns_value) { ret some(ast.def_const(defid)); }
+ case (ast::item_const(_, _, _, ?defid, _)) {
+ if (ns == ns_value) { ret some(ast::def_const(defid)); }
}
- case (ast.item_fn(_, _, _, ?defid, _)) {
- if (ns == ns_value) { ret some(ast.def_fn(defid)); }
+ case (ast::item_fn(_, _, _, ?defid, _)) {
+ if (ns == ns_value) { ret some(ast::def_fn(defid)); }
}
- case (ast.item_mod(_, _, ?defid)) {
- ret some(ast.def_mod(defid));
+ case (ast::item_mod(_, _, ?defid)) {
+ ret some(ast::def_mod(defid));
}
- case (ast.item_native_mod(_, _, ?defid)) {
- ret some(ast.def_native_mod(defid));
+ case (ast::item_native_mod(_, _, ?defid)) {
+ ret some(ast::def_native_mod(defid));
}
- case (ast.item_ty(_, _, _, ?defid, _)) {
- if (ns == ns_type) { ret some(ast.def_ty(defid)); }
+ case (ast::item_ty(_, _, _, ?defid, _)) {
+ if (ns == ns_type) { ret some(ast::def_ty(defid)); }
}
- case (ast.item_tag(_, _, _, ?defid, _)) {
- if (ns == ns_type) { ret some(ast.def_ty(defid)); }
+ case (ast::item_tag(_, _, _, ?defid, _)) {
+ if (ns == ns_type) { ret some(ast::def_ty(defid)); }
}
- case (ast.item_obj(_, _, _, ?odid, _)) {
- if (ns == ns_value) { ret some(ast.def_obj(odid.ctor)); }
- else { ret some(ast.def_obj(odid.ty)); }
+ case (ast::item_obj(_, _, _, ?odid, _)) {
+ if (ns == ns_value) { ret some(ast::def_obj(odid.ctor)); }
+ else { ret some(ast::def_obj(odid.ty)); }
}
case (_) { }
}
@@ -590,11 +589,11 @@ fn lookup_in_mod_strict(&env e, def m, &span sp, ident id,
}
fn lookup_in_mod(&env e, def m, ident id, namespace ns, dir dr)
- -> Option.t[def] {
- auto defid = ast.def_id_of_def(m);
- if (defid._0 != ast.local_crate) { // Not in this crate
+ -> option::t[def] {
+ auto defid = ast::def_id_of_def(m);
+ if (defid._0 != ast::local_crate) { // Not in this crate
auto cached = e.ext_cache.find(tup(defid,id));
- if (cached != none[def] && check_def_by_ns(Option.get(cached), ns)) {
+ if (cached != none[def] && check_def_by_ns(option::get(cached), ns)) {
ret cached;
}
auto path = vec(id);
@@ -603,40 +602,41 @@ fn lookup_in_mod(&env e, def m, ident id, namespace ns, dir dr)
}
auto fnd = lookup_external(e, defid._0, path, ns);
if (fnd != none[def]) {
- e.ext_cache.insert(tup(defid,id), Option.get(fnd));
+ e.ext_cache.insert(tup(defid,id), option::get(fnd));
}
ret fnd;
}
alt (m) {
- case (ast.def_mod(?defid)) {
+ case (ast::def_mod(?defid)) {
ret lookup_in_regular_mod(e, defid, id, ns, dr);
}
- case (ast.def_native_mod(?defid)) {
+ case (ast::def_native_mod(?defid)) {
ret lookup_in_native_mod(e, defid, id, ns);
}
}
}
-fn found_view_item(&env e, @ast.view_item vi, namespace ns) -> Option.t[def] {
+fn found_view_item(&env e, @ast::view_item vi, namespace ns)
+ -> option::t[def] {
alt (vi.node) {
- case (ast.view_item_use(_, _, _, ?cnum)) {
- ret some(ast.def_mod(tup(Option.get(cnum), -1)));
+ case (ast::view_item_use(_, _, _, ?cnum)) {
+ ret some(ast::def_mod(tup(option::get(cnum), -1)));
}
- case (ast.view_item_import(_, _, ?defid)) {
+ case (ast::view_item_import(_, _, ?defid)) {
ret lookup_import(e, defid, ns);
}
}
}
fn lookup_in_regular_mod(&env e, def_id defid, ident id, namespace ns, dir dr)
- -> Option.t[def] {
+ -> option::t[def] {
auto info = e.mod_map.get(defid._1);
auto found = info.index.find(id);
if (found == none[mod_index_entry] ||
- (dr == outside && !ast.is_exported(id, info.m))) {
+ (dr == outside && !ast::is_exported(id, info.m))) {
ret none[def];
}
- alt (Option.get(found)) {
+ alt (option::get(found)) {
case (mie_view_item(?view_item)) {
ret found_view_item(e, view_item, ns);
}
@@ -645,10 +645,10 @@ fn lookup_in_regular_mod(&env e, def_id defid, ident id, namespace ns, dir dr)
}
case (mie_tag_variant(?item, ?variant_idx)) {
alt (item.node) {
- case (ast.item_tag(_, ?variants, _, ?tid, _)) {
+ case (ast::item_tag(_, ?variants, _, ?tid, _)) {
if (ns == ns_value) {
auto vid = variants.(variant_idx).node.id;
- ret some(ast.def_variant(tid, vid));
+ ret some(ast::def_variant(tid, vid));
} else {
ret none[def];
}
@@ -659,26 +659,26 @@ fn lookup_in_regular_mod(&env e, def_id defid, ident id, namespace ns, dir dr)
}
fn lookup_in_native_mod(&env e, def_id defid, ident id, namespace ns)
- -> Option.t[def] {
+ -> option::t[def] {
auto info = e.nmod_map.get(defid._1);
auto found = info.index.find(id);
if (found == none[native_mod_index_entry]) {
ret none[def];
}
- alt (Option.get(found)) {
+ alt (option::get(found)) {
case (nmie_view_item(?view_item)) {
ret found_view_item(e, view_item, ns);
}
case (nmie_item(?item)) {
alt (item.node) {
- case (ast.native_item_ty(_, ?id)) {
+ case (ast::native_item_ty(_, ?id)) {
if (ns == ns_type) {
- ret some(ast.def_native_ty(id));
+ ret some(ast::def_native_ty(id));
}
}
- case (ast.native_item_fn(_, _, _, _, ?id, _)) {
+ case (ast::native_item_fn(_, _, _, _, ?id, _)) {
if (ns == ns_value) {
- ret some(ast.def_native_fn(id));
+ ret some(ast::def_native_fn(id));
}
}
}
@@ -690,48 +690,48 @@ fn lookup_in_native_mod(&env e, def_id defid, ident id, namespace ns)
// Module indexing
-fn index_mod(&ast._mod md) -> mod_index {
+fn index_mod(&ast::_mod md) -> mod_index {
auto index = new_str_hash[mod_index_entry]();
- for (@ast.view_item it in md.view_items) {
+ for (@ast::view_item it in md.view_items) {
alt (it.node) {
- case(ast.view_item_use(?id, _, _, _)) {
+ case(ast::view_item_use(?id, _, _, _)) {
index.insert(id, mie_view_item(it));
}
- case(ast.view_item_import(?def_ident,_,_)) {
+ case(ast::view_item_import(?def_ident,_,_)) {
index.insert(def_ident, mie_view_item(it));
}
- case(ast.view_item_export(_)) {}
+ case(ast::view_item_export(_)) {}
}
}
- for (@ast.item it in md.items) {
+ for (@ast::item it in md.items) {
alt (it.node) {
- case (ast.item_const(?id, _, _, _, _)) {
+ case (ast::item_const(?id, _, _, _, _)) {
index.insert(id, mie_item(it));
}
- case (ast.item_fn(?id, _, _, _, _)) {
+ case (ast::item_fn(?id, _, _, _, _)) {
index.insert(id, mie_item(it));
}
- case (ast.item_mod(?id, _, _)) {
+ case (ast::item_mod(?id, _, _)) {
index.insert(id, mie_item(it));
}
- case (ast.item_native_mod(?id, _, _)) {
+ case (ast::item_native_mod(?id, _, _)) {
index.insert(id, mie_item(it));
}
- case (ast.item_ty(?id, _, _, _, _)) {
+ case (ast::item_ty(?id, _, _, _, _)) {
index.insert(id, mie_item(it));
}
- case (ast.item_tag(?id, ?variants, _, _, _)) {
+ case (ast::item_tag(?id, ?variants, _, _, _)) {
index.insert(id, mie_item(it));
let uint variant_idx = 0u;
- for (ast.variant v in variants) {
+ for (ast::variant v in variants) {
index.insert(v.node.name,
mie_tag_variant(it, variant_idx));
variant_idx += 1u;
}
}
- case (ast.item_obj(?id, _, _, _, _)) {
+ case (ast::item_obj(?id, _, _, _, _)) {
index.insert(id, mie_item(it));
}
}
@@ -740,24 +740,24 @@ fn index_mod(&ast._mod md) -> mod_index {
ret index;
}
-fn index_nmod(&ast.native_mod md) -> nmod_index {
+fn index_nmod(&ast::native_mod md) -> nmod_index {
auto index = new_str_hash[native_mod_index_entry]();
- for (@ast.view_item it in md.view_items) {
+ for (@ast::view_item it in md.view_items) {
alt (it.node) {
- case(ast.view_item_import(?def_ident,_,_)) {
+ case(ast::view_item_import(?def_ident,_,_)) {
index.insert(def_ident, nmie_view_item(it));
}
- case(ast.view_item_export(_)) {}
+ case(ast::view_item_export(_)) {}
}
}
- for (@ast.native_item it in md.items) {
+ for (@ast::native_item it in md.items) {
alt (it.node) {
- case (ast.native_item_ty(?id, _)) {
+ case (ast::native_item_ty(?id, _)) {
index.insert(id, nmie_item(it));
}
- case (ast.native_item_fn(?id, _, _, _, _, _)) {
+ case (ast::native_item_fn(?id, _, _, _, _, _)) {
index.insert(id, nmie_item(it));
}
}
@@ -771,31 +771,31 @@ fn index_nmod(&ast.native_mod md) -> nmod_index {
// FIXME creader should handle multiple namespaces
fn check_def_by_ns(def d, namespace ns) -> bool {
ret alt (d) {
- case (ast.def_fn(?id)) { ns == ns_value }
- case (ast.def_obj(?id)) { ns == ns_value }
- case (ast.def_obj_field(?id)) { ns == ns_value }
- case (ast.def_mod(?id)) { true }
- case (ast.def_native_mod(?id)) { true }
- case (ast.def_const(?id)) { ns == ns_value }
- case (ast.def_arg(?id)) { ns == ns_value }
- case (ast.def_local(?id)) { ns == ns_value }
- case (ast.def_upvar(?id)) { ns == ns_value }
- case (ast.def_variant(_, ?id)) { ns == ns_value }
- case (ast.def_ty(?id)) { ns == ns_type }
- case (ast.def_binding(?id)) { ns == ns_type }
- case (ast.def_use(?id)) { true }
- case (ast.def_native_ty(?id)) { ns == ns_type }
- case (ast.def_native_fn(?id)) { ns == ns_value }
+ case (ast::def_fn(?id)) { ns == ns_value }
+ case (ast::def_obj(?id)) { ns == ns_value }
+ case (ast::def_obj_field(?id)) { ns == ns_value }
+ case (ast::def_mod(?id)) { true }
+ case (ast::def_native_mod(?id)) { true }
+ case (ast::def_const(?id)) { ns == ns_value }
+ case (ast::def_arg(?id)) { ns == ns_value }
+ case (ast::def_local(?id)) { ns == ns_value }
+ case (ast::def_upvar(?id)) { ns == ns_value }
+ case (ast::def_variant(_, ?id)) { ns == ns_value }
+ case (ast::def_ty(?id)) { ns == ns_type }
+ case (ast::def_binding(?id)) { ns == ns_type }
+ case (ast::def_use(?id)) { true }
+ case (ast::def_native_ty(?id)) { ns == ns_type }
+ case (ast::def_native_fn(?id)) { ns == ns_value }
};
}
fn lookup_external(&env e, int cnum, vec[ident] ids, namespace ns)
- -> Option.t[def] {
- auto found = creader.lookup_def(e.sess, cnum, ids);
+ -> option::t[def] {
+ auto found = creader::lookup_def(e.sess, cnum, ids);
if (found != none[def]) {
- auto d = Option.get(found);
+ auto d = option::get(found);
if (!check_def_by_ns(d, ns)) { ret none[def]; }
- e.ext_map.insert(ast.def_id_of_def(d), ids);
+ e.ext_map.insert(ast::def_id_of_def(d), ids);
}
ret found;
}
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index ecdf78cf..55f938d4 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1,49 +1,49 @@
-import std.Int;
-import std.Str;
-import std.UInt;
-import std.Vec;
-import std.Str.rustrt.sbuf;
-import std.Vec.rustrt.vbuf;
-import std.Map;
-import std.Map.hashmap;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
-
-import front.ast;
-import front.creader;
-import driver.session;
-import middle.ty;
-import back.Link;
-import back.x86;
-import back.abi;
-import back.upcall;
-
-import middle.ty.pat_ty;
-
-import util.common;
-import util.common.istr;
-import util.common.new_def_hash;
-import util.common.new_str_hash;
-
-import lib.llvm.llvm;
-import lib.llvm.builder;
-import lib.llvm.target_data;
-import lib.llvm.type_handle;
-import lib.llvm.type_names;
-import lib.llvm.mk_target_data;
-import lib.llvm.mk_type_handle;
-import lib.llvm.mk_type_names;
-import lib.llvm.llvm.ModuleRef;
-import lib.llvm.llvm.ValueRef;
-import lib.llvm.llvm.TypeRef;
-import lib.llvm.llvm.TypeHandleRef;
-import lib.llvm.llvm.BuilderRef;
-import lib.llvm.llvm.BasicBlockRef;
-
-import lib.llvm.False;
-import lib.llvm.True;
-import lib.llvm.Bool;
+import std::_int;
+import std::_str;
+import std::_uint;
+import std::_vec;
+import std::_str::rustrt::sbuf;
+import std::_vec::rustrt::vbuf;
+import std::map;
+import std::map::hashmap;
+import std::option;
+import std::option::some;
+import std::option::none;
+
+import front::ast;
+import front::creader;
+import driver::session;
+import middle::ty;
+import back::Link;
+import back::x86;
+import back::abi;
+import back::upcall;
+
+import middle::ty::pat_ty;
+
+import util::common;
+import util::common::istr;
+import util::common::new_def_hash;
+import util::common::new_str_hash;
+
+import lib::llvm::llvm;
+import lib::llvm::builder;
+import lib::llvm::target_data;
+import lib::llvm::type_handle;
+import lib::llvm::type_names;
+import lib::llvm::mk_target_data;
+import lib::llvm::mk_type_handle;
+import lib::llvm::mk_type_names;
+import lib::llvm::llvm::ModuleRef;
+import lib::llvm::llvm::ValueRef;
+import lib::llvm::llvm::TypeRef;
+import lib::llvm::llvm::TypeHandleRef;
+import lib::llvm::llvm::BuilderRef;
+import lib::llvm::llvm::BasicBlockRef;
+
+import lib::llvm::False;
+import lib::llvm::True;
+import lib::llvm::Bool;
state obj namegen(mutable int i) {
fn next(str prefix) -> str {
@@ -78,7 +78,7 @@ type tydesc_info = rec(ValueRef tydesc,
*
* A "native" is a combination of an extern that references C code, plus a
* glue-code stub that "looks like" a rust function, emitted here, plus a
- * generic N-ary bit of asm glue (found over in back/x86.rs) that performs a
+ * generic N-ary bit of asm glue (found over in back/x86::rs) that performs a
* control transfer into C from rust. Natives may be normal C library code.
*
* An upcall is a native call generated by the compiler (not corresponding to
@@ -87,46 +87,46 @@ type tydesc_info = rec(ValueRef tydesc,
*
*/
-state type crate_ctxt = rec(session.session sess,
+state type crate_ctxt = rec(session::session sess,
ModuleRef llmod,
target_data td,
type_names tn,
ValueRef crate_ptr,
hashmap[str, ValueRef] externs,
hashmap[str, ValueRef] intrinsics,
- hashmap[ast.def_id, ValueRef] item_ids,
- hashmap[ast.def_id, @ast.item] items,
- hashmap[ast.def_id,
- @ast.native_item] native_items,
- ty.type_cache type_cache,
- hashmap[ast.def_id, str] item_symbols,
+ hashmap[ast::def_id, ValueRef] item_ids,
+ hashmap[ast::def_id, @ast::item] items,
+ hashmap[ast::def_id,
+ @ast::native_item] native_items,
+ ty::type_cache type_cache,
+ hashmap[ast::def_id, str] item_symbols,
// TODO: hashmap[tup(tag_id,subtys), @tag_info]
- hashmap[ty.t, uint] tag_sizes,
- hashmap[ast.def_id, ValueRef] discrims,
- hashmap[ast.def_id, str] discrim_symbols,
- hashmap[ast.def_id, ValueRef] fn_pairs,
- hashmap[ast.def_id, ValueRef] consts,
- hashmap[ast.def_id,()] obj_methods,
- hashmap[ty.t, @tydesc_info] tydescs,
+ hashmap[ty::t, uint] tag_sizes,
+ hashmap[ast::def_id, ValueRef] discrims,
+ hashmap[ast::def_id, str] discrim_symbols,
+ hashmap[ast::def_id, ValueRef] fn_pairs,
+ hashmap[ast::def_id, ValueRef] consts,
+ hashmap[ast::def_id,()] obj_methods,
+ hashmap[ty::t, @tydesc_info] tydescs,
hashmap[str, ValueRef] module_data,
- hashmap[ty.t, TypeRef] lltypes,
+ hashmap[ty::t, TypeRef] lltypes,
@glue_fns glues,
namegen names,
- std.SHA1.sha1 sha,
- hashmap[ty.t, str] type_sha1s,
- hashmap[ty.t, metadata.ty_abbrev] type_abbrevs,
- hashmap[ty.t, str] type_short_names,
- ty.ctxt tcx,
- @upcall.upcalls upcalls);
+ std::sha1::sha1 sha,
+ hashmap[ty::t, str] type_sha1s,
+ hashmap[ty::t, metadata::ty_abbrev] type_abbrevs,
+ hashmap[ty::t, str] type_short_names,
+ ty::ctxt tcx,
+ @upcall::upcalls upcalls);
type local_ctxt = rec(vec[str] path,
vec[str] module_path,
- vec[ast.ty_param] obj_typarams,
- vec[ast.obj_field] obj_fields,
+ vec[ast::ty_param] obj_typarams,
+ vec[ast::obj_field] obj_fields,
@crate_ctxt ccx);
-type self_vt = rec(ValueRef v, ty.t t);
+type self_vt = rec(ValueRef v, ty::t t);
state type fn_ctxt = rec(ValueRef llfn,
ValueRef lltaskptr,
@@ -135,14 +135,14 @@ state type fn_ctxt = rec(ValueRef llfn,
mutable BasicBlockRef llallocas,
mutable BasicBlockRef llcopyargs,
mutable BasicBlockRef llderivedtydescs,
- mutable Option.t[self_vt] llself,
- mutable Option.t[ValueRef] lliterbody,
- hashmap[ast.def_id, ValueRef] llargs,
- hashmap[ast.def_id, ValueRef] llobjfields,
- hashmap[ast.def_id, ValueRef] lllocals,
- hashmap[ast.def_id, ValueRef] llupvars,
+ mutable option::t[self_vt] llself,
+ mutable option::t[ValueRef] lliterbody,
+ hashmap[ast::def_id, ValueRef] llargs,
+ hashmap[ast::def_id, ValueRef] llobjfields,
+ hashmap[ast::def_id, ValueRef] lllocals,
+ hashmap[ast::def_id, ValueRef] llupvars,
mutable vec[ValueRef] lltydescs,
- hashmap[ty.t, derived_tydesc_info] derived_tydescs,
+ hashmap[ty::t, derived_tydesc_info] derived_tydescs,
@local_ctxt lcx);
tag cleanup {
@@ -152,7 +152,7 @@ tag cleanup {
tag block_kind {
SCOPE_BLOCK;
- LOOP_SCOPE_BLOCK(Option.t[@block_ctxt], @block_ctxt);
+ LOOP_SCOPE_BLOCK(option::t[@block_ctxt], @block_ctxt);
NON_SCOPE_BLOCK;
}
@@ -163,7 +163,7 @@ state type block_ctxt = rec(BasicBlockRef llbb,
mutable vec[cleanup] cleanups,
@fn_ctxt fcx);
-// 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.
tag block_parent {
@@ -184,38 +184,40 @@ fn extend_path(@local_ctxt cx, &str name) -> @local_ctxt {
}
fn path_name(&vec[str] path) -> str {
- ret Str.connect(path, sep());
+ ret _str::connect(path, sep());
}
-fn get_type_sha1(&@crate_ctxt ccx, &ty.t t) -> str {
+fn get_type_sha1(&@crate_ctxt ccx, &ty::t t) -> str {
auto hash = "";
alt (ccx.type_sha1s.find(t)) {
case (some[str](?h)) { hash = h; }
case (none[str]) {
ccx.sha.reset();
- auto f = metadata.def_to_str;
+ auto f = metadata::def_to_str;
// NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate.
- auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata.ac_no_abbrevs);
+ auto cx = @rec(ds=f,
+ tcx=ccx.tcx,
+ abbrevs=metadata::ac_no_abbrevs);
- ccx.sha.input_str(metadata.Encode.ty_str(cx, t));
- hash = Str.substr(ccx.sha.result_str(), 0u, 16u);
+ ccx.sha.input_str(metadata::Encode::ty_str(cx, t));
+ hash = _str::substr(ccx.sha.result_str(), 0u, 16u);
ccx.type_sha1s.insert(t, hash);
}
}
ret hash;
}
-fn mangle_name_by_type(&@crate_ctxt ccx, &vec[str] path, &ty.t t) -> str {
+fn mangle_name_by_type(&@crate_ctxt ccx, &vec[str] path, &ty::t t) -> str {
auto hash = get_type_sha1(ccx, t);
ret sep() + "rust" + sep() + hash + sep() + path_name(path);
}
-fn mangle_name_by_type_only(&@crate_ctxt ccx, &ty.t t, &str name) -> str {
- auto f = metadata.def_to_str;
- auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata.ac_no_abbrevs);
- auto s = ty.ty_to_short_str(ccx.tcx, t);
+fn mangle_name_by_type_only(&@crate_ctxt ccx, &ty::t t, &str name) -> str {
+ auto f = metadata::def_to_str;
+ auto cx = @rec(ds=f, tcx=ccx.tcx, abbrevs=metadata::ac_no_abbrevs);
+ auto s = ty::ty_to_short_str(ccx.tcx, t);
auto hash = get_type_sha1(ccx, t);
ret sep() + "rust" + sep() + hash + sep() + name + "_" + s;
@@ -234,11 +236,11 @@ fn res(@block_ctxt bcx, ValueRef val) -> result {
}
fn ty_str(type_names tn, TypeRef t) -> str {
- ret lib.llvm.type_to_str(tn, t);
+ ret lib::llvm::type_to_str(tn, t);
}
fn val_ty(ValueRef v) -> TypeRef {
- ret llvm.LLVMTypeOf(v);
+ ret llvm::LLVMTypeOf(v);
}
fn val_str(type_names tn, ValueRef v) -> str {
@@ -259,40 +261,40 @@ fn T_void() -> TypeRef {
// zero). This makes the result incorrect for now -- things like a tuple
// of 10 nil values will have 10-bit size -- but it doesn't seem like we
// have any other options until it's fixed upstream.
- ret llvm.LLVMVoidType();
+ ret llvm::LLVMVoidType();
}
fn T_nil() -> TypeRef {
// NB: See above in T_void().
- ret llvm.LLVMInt1Type();
+ ret llvm::LLVMInt1Type();
}
fn T_i1() -> TypeRef {
- ret llvm.LLVMInt1Type();
+ ret llvm::LLVMInt1Type();
}
fn T_i8() -> TypeRef {
- ret llvm.LLVMInt8Type();
+ ret llvm::LLVMInt8Type();
}
fn T_i16() -> TypeRef {
- ret llvm.LLVMInt16Type();
+ ret llvm::LLVMInt16Type();
}
fn T_i32() -> TypeRef {
- ret llvm.LLVMInt32Type();
+ ret llvm::LLVMInt32Type();
}
fn T_i64() -> TypeRef {
- ret llvm.LLVMInt64Type();
+ ret llvm::LLVMInt64Type();
}
fn T_f32() -> TypeRef {
- ret llvm.LLVMFloatType();
+ ret llvm::LLVMFloatType();
}
fn T_f64() -> TypeRef {
- ret llvm.LLVMDoubleType();
+ ret llvm::LLVMDoubleType();
}
fn T_bool() -> TypeRef {
@@ -319,9 +321,9 @@ fn T_size_t() -> TypeRef {
}
fn T_fn(vec[TypeRef] inputs, TypeRef output) -> TypeRef {
- ret llvm.LLVMFunctionType(output,
- Vec.buf[TypeRef](inputs),
- Vec.len[TypeRef](inputs),
+ ret llvm::LLVMFunctionType(output,
+ _vec::buf[TypeRef](inputs),
+ _vec::len[TypeRef](inputs),
False);
}
@@ -331,17 +333,17 @@ fn T_fn_pair(&type_names tn, TypeRef tfn) -> TypeRef {
}
fn T_ptr(TypeRef t) -> TypeRef {
- ret llvm.LLVMPointerType(t, 0u);
+ ret llvm::LLVMPointerType(t, 0u);
}
fn T_struct(&vec[TypeRef] elts) -> TypeRef {
- ret llvm.LLVMStructType(Vec.buf[TypeRef](elts),
- Vec.len[TypeRef](elts),
+ ret llvm::LLVMStructType(_vec::buf[TypeRef](elts),
+ _vec::len[TypeRef](elts),
False);
}
fn T_opaque() -> TypeRef {
- ret llvm.LLVMOpaqueType();
+ ret llvm::LLVMOpaqueType();
}
fn T_task(&type_names tn) -> TypeRef {
@@ -366,10 +368,10 @@ fn T_task(&type_names tn) -> TypeRef {
fn T_tydesc_field(&type_names tn, int field) -> TypeRef {
// Bit of a kludge: pick the fn typeref out of the tydesc..
let vec[TypeRef] tydesc_elts =
- Vec.init_elt[TypeRef](T_nil(), abi.n_tydesc_fields as uint);
- llvm.LLVMGetStructElementTypes(T_tydesc(tn),
- Vec.buf[TypeRef](tydesc_elts));
- auto t = llvm.LLVMGetElementType(tydesc_elts.(field));
+ _vec::init_elt[TypeRef](T_nil(), abi::n_tydesc_fields as uint);
+ llvm::LLVMGetStructElementTypes(T_tydesc(tn),
+ _vec::buf[TypeRef](tydesc_elts));
+ auto t = llvm::LLVMGetElementType(tydesc_elts.(field));
ret t;
}
@@ -379,14 +381,14 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
ret tn.get_type(s);
}
- auto t = T_tydesc_field(tn, abi.tydesc_field_drop_glue);
+ auto t = T_tydesc_field(tn, abi::tydesc_field_drop_glue);
tn.associate(s, t);
ret t;
}
fn T_dtor(&@crate_ctxt ccx, TypeRef llself_ty) -> TypeRef {
- ret type_of_fn_full(ccx, ast.proto_fn, some[TypeRef](llself_ty),
- Vec.empty[ty.arg](), ty.mk_nil(ccx.tcx), 0u);
+ ret type_of_fn_full(ccx, ast::proto_fn, some[TypeRef](llself_ty),
+ _vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
}
fn T_cmp_glue_fn(&type_names tn) -> TypeRef {
@@ -395,7 +397,7 @@ fn T_cmp_glue_fn(&type_names tn) -> TypeRef {
ret tn.get_type(s);
}
- auto t = T_tydesc_field(tn, abi.tydesc_field_cmp_glue);
+ auto t = T_tydesc_field(tn, abi::tydesc_field_cmp_glue);
tn.associate(s, t);
ret t;
}
@@ -408,7 +410,7 @@ fn T_tydesc(&type_names tn) -> TypeRef {
}
auto th = mk_type_handle();
- auto abs_tydesc = llvm.LLVMResolveTypeHandle(th.llth);
+ auto abs_tydesc = llvm::LLVMResolveTypeHandle(th.llth);
auto tydescpp = T_ptr(T_ptr(abs_tydesc));
auto pvoid = T_ptr(T_i8());
auto glue_fn_ty = T_ptr(T_fn(vec(T_ptr(T_nil()),
@@ -435,15 +437,15 @@ fn T_tydesc(&type_names tn) -> TypeRef {
glue_fn_ty, // is_stateful
cmp_glue_fn_ty)); // cmp_glue
- llvm.LLVMRefineType(abs_tydesc, tydesc);
- auto t = llvm.LLVMResolveTypeHandle(th.llth);
+ llvm::LLVMRefineType(abs_tydesc, tydesc);
+ auto t = llvm::LLVMResolveTypeHandle(th.llth);
tn.associate(s, t);
ret t;
}
fn T_array(TypeRef t, uint n) -> TypeRef {
assert (n != 0u);
- ret llvm.LLVMArrayType(t, n);
+ ret llvm::LLVMArrayType(t, n);
}
fn T_vec(TypeRef t) -> TypeRef {
@@ -527,7 +529,7 @@ fn T_closure_ptr(&type_names tn,
uint n_ty_params) -> TypeRef {
// NB: keep this in sync with code in trans_bind; we're making
- // an LLVM typeref structure that has the same "shape" as the ty.t
+ // an LLVM typeref structure that has the same "shape" as the ty::t
// it constructs.
ret T_ptr(T_box(T_struct(vec(T_ptr(T_tydesc(tn)),
lltarget_ty,
@@ -550,7 +552,7 @@ fn T_opaque_closure_ptr(&type_names tn) -> TypeRef {
}
fn T_tag(&type_names tn, uint size) -> TypeRef {
- auto s = "tag_" + UInt.to_str(size, 10u);
+ auto s = "tag_" + _uint::to_str(size, 10u);
if (tn.name_has_type(s)) {
ret tn.get_type(s);
}
@@ -581,7 +583,7 @@ fn T_opaque_tag_ptr(&type_names tn) -> TypeRef {
}
fn T_captured_tydescs(&type_names tn, uint n) -> TypeRef {
- ret T_struct(Vec.init_elt[TypeRef](T_ptr(T_tydesc(tn)), n));
+ ret T_struct(_vec::init_elt[TypeRef](T_ptr(T_tydesc(tn)), n));
}
fn T_obj_ptr(&type_names tn, uint n_captured_tydescs) -> TypeRef {
@@ -608,10 +610,10 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
// return value was always meaningless in that case anyhow). Beware!
//
// TODO: Enforce via a predicate.
-fn type_of(&@crate_ctxt cx, &ty.t t) -> TypeRef {
- if (ty.type_has_dynamic_size(cx.tcx, t)) {
+fn type_of(&@crate_ctxt cx, &ty::t t) -> TypeRef {
+ if (ty::type_has_dynamic_size(cx.tcx, t)) {
log_err "type_of() called on a type with dynamic size: " +
- ty.ty_to_str(cx.tcx, t);
+ ty::ty_to_str(cx.tcx, t);
fail;
}
@@ -619,16 +621,16 @@ fn type_of(&@crate_ctxt cx, &ty.t t) -> TypeRef {
}
fn type_of_explicit_args(&@crate_ctxt cx,
- &vec[ty.arg] inputs) -> vec[TypeRef] {
+ &vec[ty::arg] inputs) -> vec[TypeRef] {
let vec[TypeRef] atys = vec();
- for (ty.arg arg in inputs) {
- if (ty.type_has_dynamic_size(cx.tcx, arg.ty)) {
- assert (arg.mode == ty.mo_alias);
+ for (ty::arg arg in inputs) {
+ if (ty::type_has_dynamic_size(cx.tcx, arg.ty)) {
+ assert (arg.mode == ty::mo_alias);
atys += vec(T_typaram_ptr(cx.tn));
} else {
let TypeRef t;
alt (arg.mode) {
- case (ty.mo_alias) {
+ case (ty::mo_alias) {
t = T_ptr(type_of_inner(cx, arg.ty));
}
case (_) {
@@ -649,21 +651,21 @@ fn type_of_explicit_args(&@crate_ctxt cx,
// - trans_args
fn type_of_fn_full(&@crate_ctxt cx,
- ast.proto proto,
- &Option.t[TypeRef] obj_self,
- &vec[ty.arg] inputs,
- &ty.t output,
+ ast::proto proto,
+ &option::t[TypeRef] obj_self,
+ &vec[ty::arg] inputs,
+ &ty::t output,
uint ty_param_count) -> TypeRef {
let vec[TypeRef] atys = vec();
// Arg 0: Output pointer.
- if (ty.type_has_dynamic_size(cx.tcx, output)) {
+ if (ty::type_has_dynamic_size(cx.tcx, output)) {
atys += vec(T_typaram_ptr(cx.tn));
} else {
atys += vec(T_ptr(type_of_inner(cx, output)));
}
- // Arg 1: Task pointer.
+ // Arg 1: task pointer.
atys += vec(T_taskptr(cx.tn));
// Arg 2: Env (closure-bindings / self-obj)
@@ -686,41 +688,41 @@ fn type_of_fn_full(&@crate_ctxt cx,
}
}
- if (proto == ast.proto_iter) {
+ if (proto == ast::proto_iter) {
// If it's an iter, the 'output' type of the iter is actually the
// *input* type of the function we're given as our iter-block
// argument.
atys +=
vec(T_fn_pair(cx.tn,
- type_of_fn_full(cx, ast.proto_fn, none[TypeRef],
- vec(rec(mode=ty.mo_alias,
+ type_of_fn_full(cx, ast::proto_fn, none[TypeRef],
+ vec(rec(mode=ty::mo_alias,
ty=output)),
- ty.mk_nil(cx.tcx), 0u)));
+ ty::mk_nil(cx.tcx), 0u)));
}
// ... then explicit args.
atys += type_of_explicit_args(cx, inputs);
- ret T_fn(atys, llvm.LLVMVoidType());
+ ret T_fn(atys, llvm::LLVMVoidType());
}
fn type_of_fn(&@crate_ctxt cx,
- ast.proto proto,
- &vec[ty.arg] inputs,
- &ty.t output,
+ ast::proto proto,
+ &vec[ty::arg] inputs,
+ &ty::t output,
uint ty_param_count) -> TypeRef {
ret type_of_fn_full(cx, proto, none[TypeRef], inputs, output,
ty_param_count);
}
-fn type_of_native_fn(&@crate_ctxt cx, ast.native_abi abi,
- &vec[ty.arg] inputs,
- &ty.t output,
+fn type_of_native_fn(&@crate_ctxt cx, ast::native_abi abi,
+ &vec[ty::arg] inputs,
+ &ty::t output,
uint ty_param_count) -> TypeRef {
let vec[TypeRef] atys = vec();
- if (abi == ast.native_abi_rust) {
+ if (abi == ast::native_abi_rust) {
atys += vec(T_taskptr(cx.tn));
- auto t = ty.ty_native_fn(abi, inputs, output);
+ auto t = ty::ty_native_fn(abi, inputs, output);
auto i = 0u;
while (i < ty_param_count) {
atys += vec(T_ptr(T_tydesc(cx.tn)));
@@ -731,7 +733,7 @@ fn type_of_native_fn(&@crate_ctxt cx, ast.native_abi abi,
ret T_fn(atys, type_of_inner(cx, output));
}
-fn type_of_inner(&@crate_ctxt cx, &ty.t t) -> TypeRef {
+fn type_of_inner(&@crate_ctxt cx, &ty::t t) -> TypeRef {
// Check the cache.
if (cx.lltypes.contains_key(t)) {
ret cx.lltypes.get(t);
@@ -739,76 +741,76 @@ fn type_of_inner(&@crate_ctxt cx, &ty.t t) -> TypeRef {
let TypeRef llty = 0 as TypeRef;
- alt (ty.struct(cx.tcx, t)) {
- case (ty.ty_native) { llty = T_ptr(T_i8()); }
- case (ty.ty_nil) { llty = T_nil(); }
- case (ty.ty_bool) { llty = T_bool(); }
- case (ty.ty_int) { llty = T_int(); }
- case (ty.ty_float) { llty = T_float(); }
- case (ty.ty_uint) { llty = T_int(); }
- case (ty.ty_machine(?tm)) {
+ alt (ty::struct(cx.tcx, t)) {
+ case (ty::ty_native) { llty = T_ptr(T_i8()); }
+ case (ty::ty_nil) { llty = T_nil(); }
+ case (ty::ty_bool) { llty = T_bool(); }
+ case (ty::ty_int) { llty = T_int(); }
+ case (ty::ty_float) { llty = T_float(); }
+ case (ty::ty_uint) { llty = T_int(); }
+ case (ty::ty_machine(?tm)) {
alt (tm) {
- case (common.ty_i8) { llty = T_i8(); }
- case (common.ty_u8) { llty = T_i8(); }
- case (common.ty_i16) { llty = T_i16(); }
- case (common.ty_u16) { llty = T_i16(); }
- case (common.ty_i32) { llty = T_i32(); }
- case (common.ty_u32) { llty = T_i32(); }
- case (common.ty_i64) { llty = T_i64(); }
- case (common.ty_u64) { llty = T_i64(); }
- case (common.ty_f32) { llty = T_f32(); }
- case (common.ty_f64) { llty = T_f64(); }
+ case (common::ty_i8) { llty = T_i8(); }
+ case (common::ty_u8) { llty = T_i8(); }
+ case (common::ty_i16) { llty = T_i16(); }
+ case (common::ty_u16) { llty = T_i16(); }
+ case (common::ty_i32) { llty = T_i32(); }
+ case (common::ty_u32) { llty = T_i32(); }
+ case (common::ty_i64) { llty = T_i64(); }
+ case (common::ty_u64) { llty = T_i64(); }
+ case (common::ty_f32) { llty = T_f32(); }
+ case (common::ty_f64) { llty = T_f64(); }
}
}
- case (ty.ty_char) { llty = T_char(); }
- case (ty.ty_str) { llty = T_ptr(T_str()); }
- case (ty.ty_tag(_, _)) {
- if (ty.type_has_dynamic_size(cx.tcx, t)) {
+ case (ty::ty_char) { llty = T_char(); }
+ case (ty::ty_str) { llty = T_ptr(T_str()); }
+ case (ty::ty_tag(_, _)) {
+ if (ty::type_has_dynamic_size(cx.tcx, t)) {
llty = T_opaque_tag(cx.tn);
} else {
auto size = static_size_of_tag(cx, t);
llty = T_tag(cx.tn, size);
}
}
- case (ty.ty_box(?mt)) {
+ case (ty::ty_box(?mt)) {
llty = T_ptr(T_box(type_of_inner(cx, mt.ty)));
}
- case (ty.ty_vec(?mt)) {
+ case (ty::ty_vec(?mt)) {
llty = T_ptr(T_vec(type_of_inner(cx, mt.ty)));
}
- case (ty.ty_port(?t)) {
+ case (ty::ty_port(?t)) {
llty = T_ptr(T_port(type_of_inner(cx, t)));
}
- case (ty.ty_chan(?t)) {
+ case (ty::ty_chan(?t)) {
llty = T_ptr(T_chan(type_of_inner(cx, t)));
}
- case (ty.ty_tup(?elts)) {
+ case (ty::ty_tup(?elts)) {
let vec[TypeRef] tys = vec();
- for (ty.mt elt in elts) {
+ for (ty::mt elt in elts) {
tys += vec(type_of_inner(cx, elt.ty));
}
llty = T_struct(tys);
}
- case (ty.ty_rec(?fields)) {
+ case (ty::ty_rec(?fields)) {
let vec[TypeRef] tys = vec();
- for (ty.field f in fields) {
+ for (ty::field f in fields) {
tys += vec(type_of_inner(cx, f.mt.ty));
}
llty = T_struct(tys);
}
- case (ty.ty_fn(?proto, ?args, ?out)) {
+ case (ty::ty_fn(?proto, ?args, ?out)) {
llty = T_fn_pair(cx.tn, type_of_fn(cx, proto, args, out, 0u));
}
- case (ty.ty_native_fn(?abi, ?args, ?out)) {
+ case (ty::ty_native_fn(?abi, ?args, ?out)) {
auto nft = native_fn_wrapper_type(cx, 0u, t);
llty = T_fn_pair(cx.tn, nft);
}
- case (ty.ty_obj(?meths)) {
+ case (ty::ty_obj(?meths)) {
auto th = mk_type_handle();
- auto self_ty = llvm.LLVMResolveTypeHandle(th.llth);
+ auto self_ty = llvm::LLVMResolveTypeHandle(th.llth);
let vec[TypeRef] mtys = vec(T_ptr(T_i8()));
- for (ty.method m in meths) {
+ for (ty::method m in meths) {
let TypeRef mty =
type_of_fn_full(cx, m.proto,
some[TypeRef](self_ty),
@@ -819,39 +821,39 @@ fn type_of_inner(&@crate_ctxt cx, &ty.t t) -> TypeRef {
let TypeRef pair = T_struct(vec(T_ptr(vtbl),
T_opaque_obj_ptr(cx.tn)));
- auto abs_pair = llvm.LLVMResolveTypeHandle(th.llth);
- llvm.LLVMRefineType(abs_pair, pair);
- abs_pair = llvm.LLVMResolveTypeHandle(th.llth);
+ auto abs_pair = llvm::LLVMResolveTypeHandle(th.llth);
+ llvm::LLVMRefineType(abs_pair, pair);
+ abs_pair = llvm::LLVMResolveTypeHandle(th.llth);
llty = abs_pair;
}
- case (ty.ty_var(_)) {
- log_err "ty_var in trans.type_of";
+ case (ty::ty_var(_)) {
+ log_err "ty_var in trans::type_of";
fail;
}
- case (ty.ty_param(_)) {
+ case (ty::ty_param(_)) {
llty = T_i8();
}
- case (ty.ty_bound_param(_)) {
- log_err "ty_bound_param in trans.type_of";
+ case (ty::ty_bound_param(_)) {
+ log_err "ty_bound_param in trans::type_of";
fail;
}
- case (ty.ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
+ case (ty::ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
}
assert (llty as int != 0);
if (cx.sess.get_opts().save_temps) {
- llvm.LLVMAddTypeName(cx.llmod,
- Str.buf(ty.ty_to_short_str(cx.tcx, t)),
+ llvm::LLVMAddTypeName(cx.llmod,
+ _str::buf(ty::ty_to_short_str(cx.tcx, t)),
llty);
}
cx.lltypes.insert(t, llty);
ret llty;
}
-fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
- alt (ty.struct(cx.ccx.tcx, arg.ty)) {
- case (ty.ty_param(_)) {
- if (arg.mode == ty.mo_alias) {
+fn type_of_arg(@local_ctxt cx, &ty::arg arg) -> TypeRef {
+ alt (ty::struct(cx.ccx.tcx, arg.ty)) {
+ case (ty::ty_param(_)) {
+ if (arg.mode == ty::mo_alias) {
ret T_typaram_ptr(cx.ccx.tn);
}
}
@@ -861,7 +863,7 @@ fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
}
auto typ;
- if (arg.mode == ty.mo_alias) {
+ if (arg.mode == ty::mo_alias) {
typ = T_ptr(type_of_inner(cx.ccx, arg.ty));
} else {
typ = type_of_inner(cx.ccx, arg.ty);
@@ -870,9 +872,9 @@ fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
}
fn type_of_ty_param_count_and_ty(@local_ctxt lcx,
- &ty.ty_param_count_and_ty tpt) -> TypeRef {
- alt (ty.struct(lcx.ccx.tcx, tpt._1)) {
- case (ty.ty_fn(?proto, ?inputs, ?output)) {
+ &ty::ty_param_count_and_ty tpt) -> TypeRef {
+ alt (ty::struct(lcx.ccx.tcx, tpt._1)) {
+ case (ty::ty_fn(?proto, ?inputs, ?output)) {
auto llfnty = type_of_fn(lcx.ccx, proto, inputs, output, tpt._0);
ret T_fn_pair(lcx.ccx.tn, llfnty);
}
@@ -903,7 +905,7 @@ fn sanitize(&str s) -> str {
c != (' ' as u8) && c != ('\t' as u8) &&
c != (';' as u8)) {
auto v = vec(c);
- result += Str.from_bytes(v);
+ result += _str::from_bytes(v);
}
}
}
@@ -915,24 +917,24 @@ fn sanitize(&str s) -> str {
// LLVM constant constructors.
fn C_null(TypeRef t) -> ValueRef {
- ret llvm.LLVMConstNull(t);
+ ret llvm::LLVMConstNull(t);
}
fn C_integral(TypeRef t, uint u, Bool sign_extend) -> ValueRef {
- // FIXME. We can't use LLVM.ULongLong with our existing minimal native
+ // FIXME: We can't use LLVM::ULongLong with our existing minimal native
// API, which only knows word-sized args.
//
- // ret llvm.LLVMConstInt(T_int(), t as LLVM.ULongLong, False);
+ // ret llvm::LLVMConstInt(T_int(), t as LLVM::ULongLong, False);
//
- ret llvm.LLVMRustConstSmallInt(t, u, sign_extend);
+ ret llvm::LLVMRustConstSmallInt(t, u, sign_extend);
}
fn C_float(&str s) -> ValueRef {
- ret llvm.LLVMConstRealOfString(T_float(), Str.buf(s));
+ ret llvm::LLVMConstRealOfString(T_float(), _str::buf(s));
}
fn C_floating(&str s, TypeRef t) -> ValueRef {
- ret llvm.LLVMConstRealOfString(t, Str.buf(s));
+ ret llvm::LLVMConstRealOfString(t, _str::buf(s));
}
fn C_nil() -> ValueRef {
@@ -959,32 +961,32 @@ fn C_u8(uint i) -> ValueRef {
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
fn C_cstr(&@crate_ctxt cx, &str s) -> ValueRef {
- auto sc = llvm.LLVMConstString(Str.buf(s), Str.byte_len(s), False);
- auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(sc),
- Str.buf(cx.names.next("str")));
- llvm.LLVMSetInitializer(g, sc);
- llvm.LLVMSetGlobalConstant(g, True);
- llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ auto sc = llvm::LLVMConstString(_str::buf(s), _str::byte_len(s), False);
+ auto g = llvm::LLVMAddGlobal(cx.llmod, val_ty(sc),
+ _str::buf(cx.names.next("str")));
+ llvm::LLVMSetInitializer(g, sc);
+ llvm::LLVMSetGlobalConstant(g, True);
+ llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ret g;
}
// A rust boxed-and-length-annotated string.
fn C_str(&@crate_ctxt cx, &str s) -> ValueRef {
- auto len = Str.byte_len(s);
- auto box = C_struct(vec(C_int(abi.const_refcount as int),
+ auto len = _str::byte_len(s);
+ auto box = C_struct(vec(C_int(abi::const_refcount as int),
C_int(len + 1u as int), // 'alloc'
C_int(len + 1u as int), // 'fill'
C_int(0), // 'pad'
- llvm.LLVMConstString(Str.buf(s),
+ llvm::LLVMConstString(_str::buf(s),
len, False)));
- auto g = llvm.LLVMAddGlobal(cx.llmod, val_ty(box),
- Str.buf(cx.names.next("str")));
- llvm.LLVMSetInitializer(g, box);
- llvm.LLVMSetGlobalConstant(g, True);
- llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
- ret llvm.LLVMConstPointerCast(g, T_ptr(T_str()));
+ auto g = llvm::LLVMAddGlobal(cx.llmod, val_ty(box),
+ _str::buf(cx.names.next("str")));
+ llvm::LLVMSetInitializer(g, box);
+ llvm::LLVMSetGlobalConstant(g, True);
+ llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
+ ret llvm::LLVMConstPointerCast(g, T_ptr(T_str()));
}
fn C_zero_byte_arr(uint size) -> ValueRef {
@@ -994,40 +996,41 @@ fn C_zero_byte_arr(uint size) -> ValueRef {
elts += vec(C_u8(0u));
i += 1u;
}
- ret llvm.LLVMConstArray(T_i8(), Vec.buf[ValueRef](elts),
- Vec.len[ValueRef](elts));
+ ret llvm::LLVMConstArray(T_i8(), _vec::buf[ValueRef](elts),
+ _vec::len[ValueRef](elts));
}
fn C_struct(&vec[ValueRef] elts) -> ValueRef {
- ret llvm.LLVMConstStruct(Vec.buf[ValueRef](elts),
- Vec.len[ValueRef](elts),
+ ret llvm::LLVMConstStruct(_vec::buf[ValueRef](elts),
+ _vec::len[ValueRef](elts),
False);
}
fn C_array(TypeRef ty, &vec[ValueRef] elts) -> ValueRef {
- ret llvm.LLVMConstArray(ty, Vec.buf[ValueRef](elts),
- Vec.len[ValueRef](elts));
+ ret llvm::LLVMConstArray(ty, _vec::buf[ValueRef](elts),
+ _vec::len[ValueRef](elts));
}
fn decl_fn(ModuleRef llmod, &str name, uint cc, TypeRef llty) -> ValueRef {
let ValueRef llfn =
- llvm.LLVMAddFunction(llmod, Str.buf(name), llty);
- llvm.LLVMSetFunctionCallConv(llfn, cc);
+ llvm::LLVMAddFunction(llmod, _str::buf(name), llty);
+ llvm::LLVMSetFunctionCallConv(llfn, cc);
ret llfn;
}
fn decl_cdecl_fn(ModuleRef llmod, &str name, TypeRef llty) -> ValueRef {
- ret decl_fn(llmod, name, lib.llvm.LLVMCCallConv, llty);
+ ret decl_fn(llmod, name, lib::llvm::LLVMCCallConv, llty);
}
fn decl_fastcall_fn(ModuleRef llmod, &str name, TypeRef llty) -> ValueRef {
- ret decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty);
+ ret decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
}
fn decl_internal_fastcall_fn(ModuleRef llmod,
&str name, TypeRef llty) -> ValueRef {
- auto llfn = decl_fn(llmod, name, lib.llvm.LLVMFastCallConv, llty);
- llvm.LLVMSetLinkage(llfn, lib.llvm.LLVMInternalLinkage as llvm.Linkage);
+ auto llfn = decl_fn(llmod, name, lib::llvm::LLVMFastCallConv, llty);
+ llvm::LLVMSetLinkage(llfn, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ret llfn;
}
@@ -1036,12 +1039,12 @@ fn decl_glue(ModuleRef llmod, type_names tn, &str s) -> ValueRef {
}
fn decl_native_glue(ModuleRef llmod, &type_names tn,
- abi.native_glue_type ngt, uint _n) -> ValueRef {
+ abi::native_glue_type ngt, uint _n) -> ValueRef {
let bool pass_task;
alt (ngt) {
- case (abi.ngt_rust) { pass_task = true; }
- case (abi.ngt_pure_rust) { pass_task = true; }
- case (abi.ngt_cdecl) { pass_task = false; }
+ case (abi::ngt_rust) { pass_task = true; }
+ case (abi::ngt_pure_rust) { pass_task = true; }
+ case (abi::ngt_cdecl) { pass_task = false; }
}
// It doesn't actually matter what type we come up with here, at the
@@ -1049,14 +1052,14 @@ fn decl_native_glue(ModuleRef llmod, &type_names tn,
// them to the indirect native-invocation glue. But eventually we'd like
// to call them directly, once we have a calling convention worked out.
let int n = _n as int;
- let str s = abi.native_glue_name(n, ngt);
+ let str s = abi::native_glue_name(n, ngt);
let vec[TypeRef] args = vec(T_int()); // callee
if (!pass_task) {
args += vec(T_int()); // taskptr, will not be passed
}
- args += Vec.init_elt[TypeRef](T_int(), n as uint);
+ args += _vec::init_elt[TypeRef](T_int(), n as uint);
ret decl_fastcall_fn(llmod, s, T_fn(args, T_int()));
}
@@ -1077,7 +1080,7 @@ fn get_extern_const(&hashmap[str, ValueRef] externs,
if (externs.contains_key(name)) {
ret externs.get(name);
}
- auto c = llvm.LLVMAddGlobal(llmod, ty, Str.buf(name));
+ auto c = llvm::LLVMAddGlobal(llmod, ty, _str::buf(name));
externs.insert(name, c);
ret c;
}
@@ -1085,19 +1088,19 @@ fn get_extern_const(&hashmap[str, ValueRef] externs,
fn get_simple_extern_fn(&hashmap[str, ValueRef] externs,
ModuleRef llmod, &str name,
int n_args) -> ValueRef {
- auto inputs = Vec.init_elt[TypeRef](T_int(), n_args as uint);
+ auto inputs = _vec::init_elt[TypeRef](T_int(), n_args as uint);
auto output = T_int();
auto t = T_fn(inputs, output);
- ret get_extern_fn(externs, llmod, name, lib.llvm.LLVMCCallConv, t);
+ ret get_extern_fn(externs, llmod, name, lib::llvm::LLVMCCallConv, t);
}
fn trans_native_call(&builder b, @glue_fns glues, ValueRef lltaskptr,
&hashmap[str, ValueRef] externs,
&type_names tn, ModuleRef llmod, &str name,
bool pass_task, &vec[ValueRef] args) -> ValueRef {
- let int n = (Vec.len[ValueRef](args) as int);
+ let int n = (_vec::len[ValueRef](args) as int);
let ValueRef llnative = get_simple_extern_fn(externs, llmod, name, n);
- llnative = llvm.LLVMConstPointerCast(llnative, T_int());
+ llnative = llvm::LLVMConstPointerCast(llnative, T_int());
let ValueRef llglue;
if (pass_task) {
@@ -1152,12 +1155,12 @@ fn find_outer_scope_cx(&@block_ctxt cx) -> @block_ctxt {
}
fn umax(&@block_ctxt cx, ValueRef a, ValueRef b) -> ValueRef {
- auto cond = cx.build.ICmp(lib.llvm.LLVMIntULT, a, b);
+ auto cond = cx.build.ICmp(lib::llvm::LLVMIntULT, a, b);
ret cx.build.Select(cond, b, a);
}
fn umin(&@block_ctxt cx, ValueRef a, ValueRef b) -> ValueRef {
- auto cond = cx.build.ICmp(lib.llvm.LLVMIntULT, a, b);
+ auto cond = cx.build.ICmp(lib::llvm::LLVMIntULT, a, b);
ret cx.build.Select(cond, a, b);
}
@@ -1169,26 +1172,28 @@ fn align_to(&@block_ctxt cx, ValueRef off, ValueRef align) -> ValueRef {
// Returns the real size of the given type for the current target.
fn llsize_of_real(&@crate_ctxt cx, TypeRef t) -> uint {
- ret llvm.LLVMStoreSizeOfType(cx.td.lltd, t);
+ ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t);
}
fn llsize_of(TypeRef t) -> ValueRef {
- ret llvm.LLVMConstIntCast(lib.llvm.llvm.LLVMSizeOf(t), T_int(), False);
+ ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t),
+ T_int(), False);
}
fn llalign_of(TypeRef t) -> ValueRef {
- ret llvm.LLVMConstIntCast(lib.llvm.llvm.LLVMAlignOf(t), T_int(), False);
+ ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMAlignOf(t),
+ T_int(), False);
}
-fn size_of(&@block_ctxt cx, &ty.t t) -> result {
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+fn size_of(&@block_ctxt cx, &ty::t t) -> result {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, llsize_of(type_of(cx.fcx.lcx.ccx, t)));
}
ret dynamic_size_of(cx, t);
}
-fn align_of(&@block_ctxt cx, &ty.t t) -> result {
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+fn align_of(&@block_ctxt cx, &ty::t t) -> result {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, llalign_of(type_of(cx.fcx.lcx.ccx, t)));
}
ret dynamic_align_of(cx, t);
@@ -1207,22 +1212,22 @@ fn array_alloca(&@block_ctxt cx, TypeRef t, ValueRef n) -> ValueRef {
// to have (a) the same size as the type that was passed in; (b) to be non-
// recursive. This is done by replacing all boxes in a type with boxed unit
// types.
-fn simplify_type(&@crate_ctxt ccx, &ty.t typ) -> ty.t {
- fn simplifier(@crate_ctxt ccx, ty.t typ) -> ty.t {
- alt (ty.struct(ccx.tcx, typ)) {
- case (ty.ty_box(_)) {
- ret ty.mk_imm_box(ccx.tcx, ty.mk_nil(ccx.tcx));
+fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
+ fn simplifier(@crate_ctxt ccx, ty::t typ) -> ty::t {
+ alt (ty::struct(ccx.tcx, typ)) {
+ case (ty::ty_box(_)) {
+ ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx));
}
case (_) { ret typ; }
}
}
auto f = bind simplifier(ccx, _);
- ret ty.fold_ty(ccx.tcx, f, typ);
+ ret ty::fold_ty(ccx.tcx, f, typ);
}
// Computes the size of the data part of a non-dynamically-sized tag.
-fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
- if (ty.type_has_dynamic_size(cx.tcx, t)) {
+fn static_size_of_tag(&@crate_ctxt cx, &ty::t t) -> uint {
+ if (ty::type_has_dynamic_size(cx.tcx, t)) {
log_err "dynamically sized type passed to static_size_of_tag()";
fail;
}
@@ -1232,9 +1237,9 @@ fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
}
auto tid;
- let vec[ty.t] subtys;
- alt (ty.struct(cx.tcx, t)) {
- case (ty.ty_tag(?tid_, ?subtys_)) {
+ let vec[ty::t] subtys;
+ alt (ty::struct(cx.tcx, t)) {
+ case (ty::ty_tag(?tid_, ?subtys_)) {
tid = tid_;
subtys = subtys_;
}
@@ -1248,11 +1253,11 @@ fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
auto max_size = 0u;
auto variants = tag_variants(cx, tid);
for (variant_info variant in variants) {
- auto tup_ty = simplify_type(cx, ty.mk_imm_tup(cx.tcx, variant.args));
+ auto tup_ty = simplify_type(cx, ty::mk_imm_tup(cx.tcx, variant.args));
// Perform any type parameter substitutions.
- tup_ty = ty.bind_params_in_type(cx.tcx, tup_ty);
- tup_ty = ty.substitute_type_params(cx.tcx, subtys, tup_ty);
+ tup_ty = ty::bind_params_in_type(cx.tcx, tup_ty);
+ tup_ty = ty::substitute_type_params(cx.tcx, subtys, tup_ty);
// Here we possibly do a recursive call.
auto this_size = llsize_of_real(cx, type_of(cx, tup_ty));
@@ -1266,8 +1271,8 @@ fn static_size_of_tag(&@crate_ctxt cx, &ty.t t) -> uint {
ret max_size;
}
-fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
- fn align_elements(&@block_ctxt cx, &vec[ty.t] elts) -> result {
+fn dynamic_size_of(&@block_ctxt cx, ty::t t) -> result {
+ fn align_elements(&@block_ctxt cx, &vec[ty::t] elts) -> result {
//
// C padding rules:
//
@@ -1279,7 +1284,7 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
auto off = C_int(0);
auto max_align = C_int(1);
auto bcx = cx;
- for (ty.t e in elts) {
+ for (ty::t e in elts) {
auto elt_align = align_of(bcx, e);
bcx = elt_align.bcx;
auto elt_size = size_of(bcx, e);
@@ -1292,26 +1297,27 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
ret res(bcx, off);
}
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_param(?p)) {
- auto szptr = field_of_tydesc(cx, t, false, abi.tydesc_field_size);
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_param(?p)) {
+ auto szptr = field_of_tydesc(cx, t, false,
+ abi::tydesc_field_size);
ret res(szptr.bcx, szptr.bcx.build.Load(szptr.val));
}
- case (ty.ty_tup(?elts)) {
- let vec[ty.t] tys = vec();
- for (ty.mt mt in elts) {
+ case (ty::ty_tup(?elts)) {
+ let vec[ty::t] tys = vec();
+ for (ty::mt mt in elts) {
tys += vec(mt.ty);
}
ret align_elements(cx, tys);
}
- case (ty.ty_rec(?flds)) {
- let vec[ty.t] tys = vec();
- for (ty.field f in flds) {
+ case (ty::ty_rec(?flds)) {
+ let vec[ty::t] tys = vec();
+ for (ty::field f in flds) {
tys += vec(f.mt.ty);
}
ret align_elements(cx, tys);
}
- case (ty.ty_tag(?tid, ?tps)) {
+ case (ty::ty_tag(?tid, ?tps)) {
auto bcx = cx;
// Compute max(variant sizes).
@@ -1321,12 +1327,13 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
auto variants = tag_variants(bcx.fcx.lcx.ccx, tid);
for (variant_info variant in variants) {
// Perform type substitution on the raw argument types.
- let vec[ty.t] raw_tys = variant.args;
- let vec[ty.t] tys = vec();
- for (ty.t raw_ty in raw_tys) {
- auto t = ty.bind_params_in_type(cx.fcx.lcx.ccx.tcx,
+ let vec[ty::t] raw_tys = variant.args;
+ let vec[ty::t] tys = vec();
+ for (ty::t raw_ty in raw_tys) {
+ auto t = ty::bind_params_in_type(cx.fcx.lcx.ccx.tcx,
raw_ty);
- t = ty.substitute_type_params(cx.fcx.lcx.ccx.tcx, tps, t);
+ t = ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, tps,
+ t);
tys += vec(t);
}
@@ -1345,33 +1352,34 @@ fn dynamic_size_of(&@block_ctxt cx, ty.t t) -> result {
}
}
-fn dynamic_align_of(&@block_ctxt cx, &ty.t t) -> result {
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_param(?p)) {
- auto aptr = field_of_tydesc(cx, t, false, abi.tydesc_field_align);
+fn dynamic_align_of(&@block_ctxt cx, &ty::t t) -> result {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_param(?p)) {
+ auto aptr = field_of_tydesc(cx, t, false,
+ abi::tydesc_field_align);
ret res(aptr.bcx, aptr.bcx.build.Load(aptr.val));
}
- case (ty.ty_tup(?elts)) {
+ case (ty::ty_tup(?elts)) {
auto a = C_int(1);
auto bcx = cx;
- for (ty.mt e in elts) {
+ for (ty::mt e in elts) {
auto align = align_of(bcx, e.ty);
bcx = align.bcx;
a = umax(bcx, a, align.val);
}
ret res(bcx, a);
}
- case (ty.ty_rec(?flds)) {
+ case (ty::ty_rec(?flds)) {
auto a = C_int(1);
auto bcx = cx;
- for (ty.field f in flds) {
+ for (ty::field f in flds) {
auto align = align_of(bcx, f.mt.ty);
bcx = align.bcx;
a = umax(bcx, a, align.val);
}
ret res(bcx, a);
}
- case (ty.ty_tag(_, _)) {
+ case (ty::ty_tag(_, _)) {
ret res(cx, C_int(1)); // FIXME: stub
}
}
@@ -1379,18 +1387,18 @@ fn dynamic_align_of(&@block_ctxt cx, &ty.t t) -> result {
// Replacement for the LLVM 'GEP' instruction when field-indexing into a
// tuple-like structure (tup, rec) with a static index. This one is driven off
-// ty.struct and knows what to do when it runs into a ty_param stuck in the
+// ty::struct and knows what to do when it runs into a ty_param stuck in the
// middle of the thing it's GEP'ing into. Much like size_of and align_of,
// above.
-fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
+fn GEP_tup_like(&@block_ctxt cx, &ty::t t,
ValueRef base, &vec[int] ixs) -> result {
- assert (ty.type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
+ assert (ty::type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
// It might be a static-known type. Handle this.
- if (! ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ if (! ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
let vec[ValueRef] v = vec();
for (int i in ixs) {
v += vec(C_int(i));
@@ -1415,12 +1423,12 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
// elements of the type and splitting the Xth off. Return the prefix as
// well as the innermost Xth type.
- fn split_type(&@crate_ctxt ccx, &ty.t t, &vec[int] ixs, uint n)
- -> rec(vec[ty.t] prefix, ty.t target) {
+ fn split_type(&@crate_ctxt ccx, &ty::t t, &vec[int] ixs, uint n)
+ -> rec(vec[ty::t] prefix, ty::t target) {
- let uint len = Vec.len[int](ixs);
+ let uint len = _vec::len[int](ixs);
- // We don't support 0-index or 1-index GEPs. The former is nonsense
+ // We don't support 0-index or 1-index GEPs: The former is nonsense
// and the latter would only be meaningful if we supported non-0
// values for the 0th index (we don't).
@@ -1437,15 +1445,15 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
assert (n < len);
let int ix = ixs.(n);
- let vec[ty.t] prefix = vec();
+ let vec[ty::t] prefix = vec();
let int i = 0;
while (i < ix) {
- Vec.push[ty.t](prefix,
- ty.get_element_type(ccx.tcx, t, i as uint));
+ _vec::push[ty::t](prefix,
+ ty::get_element_type(ccx.tcx, t, i as uint));
i += 1 ;
}
- auto selected = ty.get_element_type(ccx.tcx, t, i as uint);
+ auto selected = ty::get_element_type(ccx.tcx, t, i as uint);
if (n == len-1u) {
// We are at the innermost index.
@@ -1466,14 +1474,14 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
// flattened the incoming structure.
auto s = split_type(cx.fcx.lcx.ccx, t, ixs, 0u);
- auto prefix_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, s.prefix);
+ auto prefix_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, s.prefix);
auto bcx = cx;
auto sz = size_of(bcx, prefix_ty);
bcx = sz.bcx;
auto raw = bcx.build.PointerCast(base, T_ptr(T_i8()));
auto bumped = bcx.build.GEP(raw, vec(sz.val));
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, s.target)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, s.target)) {
ret res(bcx, bumped);
}
@@ -1487,9 +1495,9 @@ fn GEP_tup_like(&@block_ctxt cx, &ty.t t,
// meaningless, as it will be cast away.
fn GEP_tag(@block_ctxt cx,
ValueRef llblobptr,
- &ast.def_id tag_id,
- &ast.def_id variant_id,
- &vec[ty.t] ty_substs,
+ &ast::def_id tag_id,
+ &ast::def_id variant_id,
+ &vec[ty::t] ty_substs,
int ix)
-> result {
auto variant = tag_variant_with_id(cx.fcx.lcx.ccx, tag_id, variant_id);
@@ -1497,12 +1505,12 @@ fn GEP_tag(@block_ctxt cx,
// Synthesize a tuple type so that GEP_tup_like() can work its magic.
// Separately, store the type of the element we're interested in.
auto arg_tys = variant.args;
- auto elem_ty = ty.mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
+ auto elem_ty = ty::mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
auto i = 0;
- let vec[ty.t] true_arg_tys = vec();
- for (ty.t aty in arg_tys) {
- auto arg_ty = ty.bind_params_in_type(cx.fcx.lcx.ccx.tcx, aty);
- arg_ty = ty.substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs,
+ let vec[ty::t] true_arg_tys = vec();
+ for (ty::t aty in arg_tys) {
+ auto arg_ty = ty::bind_params_in_type(cx.fcx.lcx.ccx.tcx, aty);
+ arg_ty = ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs,
arg_ty);
true_arg_tys += vec(arg_ty);
if (i == ix) {
@@ -1512,12 +1520,12 @@ fn GEP_tag(@block_ctxt cx,
i += 1;
}
- auto tup_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, true_arg_tys);
+ auto tup_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, true_arg_tys);
// Cast the blob pointer to the appropriate type, if we need to (i.e. if
// the blob pointer isn't dynamically sized).
let ValueRef llunionptr;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, tup_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, tup_ty)) {
auto llty = type_of(cx.fcx.lcx.ccx, tup_ty);
llunionptr = cx.build.TruncOrBitCast(llblobptr, T_ptr(llty));
} else {
@@ -1529,7 +1537,7 @@ fn GEP_tag(@block_ctxt cx,
// Cast the result to the appropriate type, if necessary.
auto val;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elem_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elem_ty)) {
auto llelemty = type_of(rslt.bcx.fcx.lcx.ccx, elem_ty);
val = rslt.bcx.build.PointerCast(rslt.val, T_ptr(llelemty));
} else {
@@ -1549,12 +1557,12 @@ fn trans_raw_malloc(&@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
ret res(cx, cx.build.PointerCast(rval, llptr_ty));
}
-fn trans_malloc_boxed(&@block_ctxt cx, ty.t t) -> result {
+fn trans_malloc_boxed(&@block_ctxt cx, ty::t t) -> result {
// Synthesize a fake box type structurally so we have something
// to measure the size of.
- auto boxed_body = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
- vec(ty.mk_int(cx.fcx.lcx.ccx.tcx), t));
- auto box_ptr = ty.mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
+ auto boxed_body = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ vec(ty::mk_int(cx.fcx.lcx.ccx.tcx), t));
+ auto box_ptr = ty::mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
auto sz = size_of(cx, boxed_body);
auto llty = type_of(cx.fcx.lcx.ccx, box_ptr);
ret trans_raw_malloc(sz.bcx, llty, sz.val);
@@ -1566,7 +1574,7 @@ fn trans_malloc_boxed(&@block_ctxt cx, ty.t t) -> result {
// Given a type and a field index into its corresponding type descriptor,
// returns an LLVM ValueRef of that field from the tydesc, generating the
// tydesc if necessary.
-fn field_of_tydesc(&@block_ctxt cx, &ty.t t, bool escapes, int field)
+fn field_of_tydesc(&@block_ctxt cx, &ty::t t, bool escapes, int field)
-> result {
auto tydesc = get_tydesc(cx, t, escapes);
ret res(tydesc.bcx,
@@ -1577,7 +1585,7 @@ fn field_of_tydesc(&@block_ctxt cx, &ty.t t, bool escapes, int field)
// each of the ty params it uses (from the current frame) and a vector of the
// indices of the ty params present in the type. This is used solely for
// constructing derived tydescs.
-fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
+fn linearize_ty_params(&@block_ctxt cx, &ty::t t) ->
tup(vec[uint], vec[ValueRef]) {
let vec[ValueRef] param_vals = vec();
let vec[uint] param_defs = vec();
@@ -1585,9 +1593,9 @@ fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
mutable vec[ValueRef] vals,
mutable vec[uint] defs);
- fn linearizer(@rr r, ty.t t) {
- alt(ty.struct(r.cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_param(?pid)) {
+ fn linearizer(@rr r, ty::t t) {
+ alt(ty::struct(r.cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_param(?pid)) {
let bool seen = false;
for (uint d in r.defs) {
if (d == pid) {
@@ -1609,7 +1617,7 @@ fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
mutable defs = param_defs);
auto f = bind linearizer(x, _);
- ty.walk_ty(cx.fcx.lcx.ccx.tcx, f, t);
+ ty::walk_ty(cx.fcx.lcx.ccx.tcx, f, t);
ret tup(x.defs, x.vals);
}
@@ -1617,7 +1625,7 @@ fn linearize_ty_params(&@block_ctxt cx, &ty.t t) ->
fn trans_stack_local_derived_tydesc(&@block_ctxt cx, ValueRef llsz,
ValueRef llalign,
ValueRef llroottydesc,
- &Option.t[ValueRef] llparamtydescs)
+ &option::t[ValueRef] llparamtydescs)
-> ValueRef {
auto llmyroottydesc = alloca(cx, T_tydesc(cx.fcx.lcx.ccx.tn));
@@ -1650,7 +1658,7 @@ fn trans_stack_local_derived_tydesc(&@block_ctxt cx, ValueRef llsz,
ret llmyroottydesc;
}
-fn mk_derived_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
+fn mk_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes) -> result {
alt (cx.fcx.derived_tydescs.find(t)) {
case (some[derived_tydesc_info](?info)) {
// If the tydesc escapes in this context, the cached derived
@@ -1662,11 +1670,11 @@ fn mk_derived_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
auto bcx = new_raw_block_ctxt(cx.fcx, cx.fcx.llderivedtydescs);
- let uint n_params = ty.count_ty_params(bcx.fcx.lcx.ccx.tcx, t);
+ let uint n_params = ty::count_ty_params(bcx.fcx.lcx.ccx.tcx, t);
auto tys = linearize_ty_params(bcx, t);
- assert (n_params == Vec.len[uint](tys._0));
- assert (n_params == Vec.len[ValueRef](tys._1));
+ assert (n_params == _vec::len[uint](tys._0));
+ assert (n_params == _vec::len[ValueRef](tys._1));
auto root = get_static_tydesc(bcx, t, tys._0).tydesc;
@@ -1729,16 +1737,16 @@ fn mk_derived_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
ret res(cx, v);
}
-fn get_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
+fn get_tydesc(&@block_ctxt cx, &ty::t t, bool escapes) -> result {
// Is the supplied type a type param? If so, return the passed-in tydesc.
- alt (ty.type_param(cx.fcx.lcx.ccx.tcx, t)) {
+ alt (ty::type_param(cx.fcx.lcx.ccx.tcx, t)) {
case (some[uint](?id)) { ret res(cx, cx.fcx.lltydescs.(id)); }
case (none[uint]) { /* fall through */ }
}
// Does it contain a type param? If so, generate a derived tydesc.
- if (ty.type_contains_params(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, t)) {
ret mk_derived_tydesc(cx, t, escapes);
}
@@ -1749,7 +1757,7 @@ fn get_tydesc(&@block_ctxt cx, &ty.t t, bool escapes) -> result {
}
fn get_static_tydesc(&@block_ctxt cx,
- &ty.t t, &vec[uint] ty_params) -> @tydesc_info {
+ &ty::t t, &vec[uint] ty_params) -> @tydesc_info {
alt (cx.fcx.lcx.ccx.tydescs.find(t)) {
case (some[@tydesc_info](?info)) {
ret info;
@@ -1762,11 +1770,11 @@ fn get_static_tydesc(&@block_ctxt cx,
// in this file. Experiment with other approaches to this.
/*
- fn simplifier(ty.t typ) -> ty.t {
+ fn simplifier(ty::t typ) -> ty::t {
ret @rec(cname=none[str] with *typ);
}
auto f = simplifier;
- auto t_simplified = ty.fold_ty(cx.fcx.lcx.ccx.tcx, f, t);
+ auto t_simplified = ty::fold_ty(cx.fcx.lcx.ccx.tcx, f, t);
auto info = declare_tydesc(cx.fcx.lcx, t_simplified);
cx.fcx.lcx.ccx.tydescs.insert(t_simplified, info);
*/
@@ -1782,7 +1790,7 @@ fn get_static_tydesc(&@block_ctxt cx,
// Generates the declaration for (but doesn't fill in) a type descriptor. This
// needs to be separate from make_tydesc() below, because sometimes type glue
// functions needs to refer to their own type descriptors.
-fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
+fn declare_tydesc(&@local_ctxt cx, &ty::t t) -> @tydesc_info {
auto take_glue = declare_generic_glue(cx, t, T_glue_fn(cx.ccx.tn),
"take");
auto drop_glue = declare_generic_glue(cx, t, T_glue_fn(cx.ccx.tn),
@@ -1793,7 +1801,7 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
auto llsize;
auto llalign;
- if (!ty.type_has_dynamic_size(ccx.tcx, t)) {
+ if (!ty::type_has_dynamic_size(ccx.tcx, t)) {
auto llty = type_of(ccx, t);
llsize = llsize_of(llty);
llalign = llalign_of(llty);
@@ -1814,8 +1822,8 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
name = mangle_name_by_seq(cx.ccx, cx.path, "tydesc");
}
- auto gvar = llvm.LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn),
- Str.buf(name));
+ auto gvar = llvm::LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn),
+ _str::buf(name));
auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))),
llsize,
llalign,
@@ -1828,10 +1836,10 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
C_null(glue_fn_ty), // is_stateful
cmp_glue)); // cmp_glue
- llvm.LLVMSetInitializer(gvar, tydesc);
- llvm.LLVMSetGlobalConstant(gvar, True);
- llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ llvm::LLVMSetInitializer(gvar, tydesc);
+ llvm::LLVMSetGlobalConstant(gvar, True);
+ llvm::LLVMSetLinkage(gvar, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
auto info = @rec(
tydesc=gvar,
@@ -1844,12 +1852,12 @@ fn declare_tydesc(&@local_ctxt cx, &ty.t t) -> @tydesc_info {
}
tag make_generic_glue_helper_fn {
- mgghf_single(fn(&@block_ctxt cx, ValueRef v, &ty.t t));
+ mgghf_single(fn(&@block_ctxt cx, ValueRef v, &ty::t t));
mgghf_cmp;
}
// declare_tydesc() above must have been called first.
-fn define_tydesc(&@local_ctxt cx, &ty.t t, &vec[uint] ty_params) {
+fn define_tydesc(&@local_ctxt cx, &ty::t t, &vec[uint] ty_params) {
auto info = cx.ccx.tydescs.get(t);
auto gvar = info.tydesc;
@@ -1861,7 +1869,7 @@ fn define_tydesc(&@local_ctxt cx, &ty.t t, &vec[uint] ty_params) {
}
fn declare_generic_glue(&@local_ctxt cx,
- &ty.t t,
+ &ty::t t,
TypeRef llfnty,
&str name) -> ValueRef {
auto fn_nm;
@@ -1876,7 +1884,7 @@ fn declare_generic_glue(&@local_ctxt cx,
}
fn make_generic_glue(&@local_ctxt cx,
- &ty.t t,
+ &ty::t t,
ValueRef llfn,
&make_generic_glue_helper_fn helper,
&vec[uint] ty_params) -> ValueRef {
@@ -1888,34 +1896,34 @@ fn make_generic_glue(&@local_ctxt cx,
// passed by value.
auto llty;
- if (ty.type_has_dynamic_size(cx.ccx.tcx, t)) {
+ if (ty::type_has_dynamic_size(cx.ccx.tcx, t)) {
llty = T_ptr(T_i8());
} else {
llty = T_ptr(type_of(cx.ccx, t));
}
- auto ty_param_count = Vec.len[uint](ty_params);
+ auto ty_param_count = _vec::len[uint](ty_params);
- auto lltyparams = llvm.LLVMGetParam(llfn, 3u);
+ auto lltyparams = llvm::LLVMGetParam(llfn, 3u);
auto copy_args_bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
- auto lltydescs = Vec.empty_mut[ValueRef]();
+ auto lltydescs = _vec::empty_mut[ValueRef]();
auto p = 0u;
while (p < ty_param_count) {
auto llparam = copy_args_bcx.build.GEP(lltyparams,
vec(C_int(p as int)));
llparam = copy_args_bcx.build.Load(llparam);
- Vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
+ _vec::grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
llparam);
p += 1u;
}
- fcx.lltydescs = Vec.freeze[ValueRef](lltydescs);
+ fcx.lltydescs = _vec::freeze[ValueRef](lltydescs);
auto bcx = new_top_block_ctxt(fcx);
auto lltop = bcx.llbb;
- auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u);
+ auto llrawptr0 = llvm::LLVMGetParam(llfn, 4u);
auto llval0 = bcx.build.BitCast(llrawptr0, llty);
alt (helper) {
@@ -1923,10 +1931,10 @@ fn make_generic_glue(&@local_ctxt cx,
single_fn(bcx, llval0, t);
}
case (mgghf_cmp) {
- auto llrawptr1 = llvm.LLVMGetParam(llfn, 5u);
+ auto llrawptr1 = llvm::LLVMGetParam(llfn, 5u);
auto llval1 = bcx.build.BitCast(llrawptr1, llty);
- auto llcmpval = llvm.LLVMGetParam(llfn, 6u);
+ auto llcmpval = llvm::LLVMGetParam(llfn, 6u);
make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
}
@@ -1937,13 +1945,13 @@ fn make_generic_glue(&@local_ctxt cx,
ret llfn;
}
-fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty.t t) {
+fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty::t t) {
// NB: v is an *alias* of type t here, not a direct value.
auto bcx;
- if (ty.type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
bcx = incr_refcnt_of_boxed(cx, cx.build.Load(v)).bcx;
- } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
bcx = iter_structural_ty(cx, v, t,
bind take_ty(_, _, _)).bcx;
} else {
@@ -1954,14 +1962,14 @@ fn make_take_glue(&@block_ctxt cx, ValueRef v, &ty.t t) {
fn incr_refcnt_of_boxed(&@block_ctxt cx, ValueRef box_ptr) -> result {
auto rc_ptr = cx.build.GEP(box_ptr, vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto rc = cx.build.Load(rc_ptr);
auto rc_adj_cx = new_sub_block_ctxt(cx, "rc++");
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto const_test = cx.build.ICmp(lib.llvm.LLVMIntEQ,
- C_int(abi.const_refcount as int), rc);
+ auto const_test = cx.build.ICmp(lib::llvm::LLVMIntEQ,
+ C_int(abi::const_refcount as int), rc);
cx.build.CondBr(const_test, next_cx.llbb, rc_adj_cx.llbb);
rc = rc_adj_cx.build.Add(rc, C_int(1));
@@ -1971,11 +1979,11 @@ fn incr_refcnt_of_boxed(&@block_ctxt cx, ValueRef box_ptr) -> result {
ret res(next_cx, C_nil());
}
-fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
+fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
// NB: v0 is an *alias* of type t here, not a direct value.
auto rslt;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_str) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_str) {
auto v = cx.build.Load(v0);
rslt = decr_refcnt_and_if_zero
(cx, v, bind trans_non_gc_free(_, v),
@@ -1983,9 +1991,9 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_vec(_)) {
+ case (ty::ty_vec(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v,
- ty.t t) -> result {
+ ty::t t) -> result {
auto res = iter_sequence(cx, v, t,
bind drop_ty(_,_,_));
// FIXME: switch gc/non-gc on layer of the type.
@@ -1998,12 +2006,12 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_box(?body_mt)) {
+ case (ty::ty_box(?body_mt)) {
fn hit_zero(&@block_ctxt cx, ValueRef v,
- ty.t body_ty) -> result {
+ ty::t body_ty) -> result {
auto body = cx.build.GEP(v,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
auto body_val = load_if_immediate(cx, body, body_ty);
auto res = drop_ty(cx, body_val, body_ty);
@@ -2017,7 +2025,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_port(_)) {
+ case (ty::ty_port(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
cx.build.Call(cx.fcx.lcx.ccx.upcalls.del_port,
vec(cx.fcx.lltaskptr,
@@ -2031,7 +2039,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_chan(_)) {
+ case (ty::ty_chan(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
cx.build.Call(cx.fcx.lcx.ccx.upcalls.del_chan,
vec(cx.fcx.lltaskptr,
@@ -2045,23 +2053,23 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_obj(_)) {
+ case (ty::ty_obj(_)) {
fn hit_zero(&@block_ctxt cx, ValueRef b, ValueRef o) -> result {
auto body =
cx.build.GEP(b,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
auto tydescptr =
cx.build.GEP(body,
vec(C_int(0),
- C_int(abi.obj_body_elt_tydesc)));
+ C_int(abi::obj_body_elt_tydesc)));
auto tydesc = cx.build.Load(tydescptr);
auto cx_ = maybe_call_dtor(cx, o);
// Call through the obj's own fields-drop glue first.
call_tydesc_glue_full(cx_, body, tydesc,
- abi.tydesc_field_drop_glue);
+ abi::tydesc_field_drop_glue);
// Then free the body.
// FIXME: switch gc/non-gc on layer of the type.
@@ -2070,7 +2078,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
auto box_cell =
cx.build.GEP(v0,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
auto boxptr = cx.build.Load(box_cell);
@@ -2080,26 +2088,26 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
T_int(), C_int(0));
}
- case (ty.ty_fn(_,_,_)) {
+ case (ty::ty_fn(_,_,_)) {
fn hit_zero(&@block_ctxt cx, ValueRef v) -> result {
// Call through the closure's own fields-drop glue first.
auto body =
cx.build.GEP(v,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
auto bindings =
cx.build.GEP(body,
vec(C_int(0),
- C_int(abi.closure_elt_bindings)));
+ C_int(abi::closure_elt_bindings)));
auto tydescptr =
cx.build.GEP(body,
vec(C_int(0),
- C_int(abi.closure_elt_tydesc)));
+ C_int(abi::closure_elt_tydesc)));
call_tydesc_glue_full(cx, bindings, cx.build.Load(tydescptr),
- abi.tydesc_field_drop_glue);
+ abi::tydesc_field_drop_glue);
// Then free the body.
@@ -2109,7 +2117,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
auto box_cell =
cx.build.GEP(v0,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
auto boxptr = cx.build.Load(box_cell);
@@ -2120,13 +2128,13 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty.t t) {
}
case (_) {
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
rslt = iter_structural_ty(cx, v0, t,
bind drop_ty(_, _, _));
- } else if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
rslt = res(cx, C_nil());
} else {
rslt = res(cx, C_nil());
@@ -2154,17 +2162,17 @@ fn decr_refcnt_and_if_zero(&@block_ctxt cx,
auto rc_ptr = load_rc_cx.build.GEP(box_ptr,
vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto rc = load_rc_cx.build.Load(rc_ptr);
auto const_test =
- load_rc_cx.build.ICmp(lib.llvm.LLVMIntEQ,
- C_int(abi.const_refcount as int), rc);
+ load_rc_cx.build.ICmp(lib::llvm::LLVMIntEQ,
+ C_int(abi::const_refcount as int), rc);
load_rc_cx.build.CondBr(const_test, next_cx.llbb, rc_adj_cx.llbb);
rc = rc_adj_cx.build.Sub(rc, C_int(1));
rc_adj_cx.build.Store(rc, rc_ptr);
- auto zero_test = rc_adj_cx.build.ICmp(lib.llvm.LLVMIntEQ, C_int(0), rc);
+ auto zero_test = rc_adj_cx.build.ICmp(lib::llvm::LLVMIntEQ, C_int(0), rc);
rc_adj_cx.build.CondBr(zero_test, inner_cx.llbb, next_cx.llbb);
auto inner_res = inner(inner_cx);
@@ -2184,31 +2192,31 @@ fn decr_refcnt_and_if_zero(&@block_ctxt cx,
fn maybe_name_value(&@crate_ctxt cx, ValueRef v, &str s) {
if (cx.sess.get_opts().save_temps) {
- llvm.LLVMSetValueName(v, Str.buf(s));
+ llvm::LLVMSetValueName(v, _str::buf(s));
}
}
fn make_cmp_glue(&@block_ctxt cx,
ValueRef lhs0,
ValueRef rhs0,
- &ty.t t,
+ &ty::t t,
ValueRef llop) {
auto lhs = load_if_immediate(cx, lhs0, t);
auto rhs = load_if_immediate(cx, rhs0, t);
- if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
make_scalar_cmp_glue(cx, lhs, rhs, t, llop);
- } else if (ty.type_is_box(cx.fcx.lcx.ccx.tcx, t)) {
- lhs = cx.build.GEP(lhs, vec(C_int(0), C_int(abi.box_rc_field_body)));
- rhs = cx.build.GEP(rhs, vec(C_int(0), C_int(abi.box_rc_field_body)));
+ } else if (ty::type_is_box(cx.fcx.lcx.ccx.tcx, t)) {
+ lhs = cx.build.GEP(lhs, vec(C_int(0), C_int(abi::box_rc_field_body)));
+ rhs = cx.build.GEP(rhs, vec(C_int(0), C_int(abi::box_rc_field_body)));
auto rslt = call_cmp_glue(cx, lhs, rhs, t, llop);
rslt.bcx.build.Store(rslt.val, cx.fcx.llretptr);
rslt.bcx.build.RetVoid();
- } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)
- || ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)
+ || ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
auto scx = new_sub_block_ctxt(cx, "structural compare start");
auto next = new_sub_block_ctxt(cx, "structural compare end");
@@ -2222,7 +2230,7 @@ fn make_cmp_glue(&@block_ctxt cx,
* !=, < and >.
*
* We then move one element at a time through the structure checking
- * for pairwise element equality. If we have equality, our assumption
+ * for pairwise element equality: If we have equality, our assumption
* about overall sequence equality is not modified, so we have to move
* to the next element.
*
@@ -2242,7 +2250,7 @@ fn make_cmp_glue(&@block_ctxt cx,
maybe_name_value(cx.fcx.lcx.ccx, flag, "flag");
auto r;
- if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
// If we hit == all the way through the minimum-shared-length
// section, default to judging the relative sequence lengths.
@@ -2256,8 +2264,8 @@ fn make_cmp_glue(&@block_ctxt cx,
} else {
// == and <= default to true if they find == all the way. <
// defaults to false if it finds == all the way.
- auto result_if_equal = scx.build.ICmp(lib.llvm.LLVMIntNE, llop,
- C_u8(abi.cmp_glue_op_lt));
+ auto result_if_equal = scx.build.ICmp(lib::llvm::LLVMIntNE, llop,
+ C_u8(abi::cmp_glue_op_lt));
scx.build.Store(result_if_equal, flag);
r = res(scx, C_nil());
}
@@ -2269,7 +2277,7 @@ fn make_cmp_glue(&@block_ctxt cx,
&@block_ctxt cx,
ValueRef av0,
ValueRef bv0,
- ty.t t) -> result {
+ ty::t t) -> result {
auto cnt_cx = new_sub_block_ctxt(cx, "continue_comparison");
auto stop_cx = new_sub_block_ctxt(cx, "stop_comparison");
@@ -2281,7 +2289,7 @@ fn make_cmp_glue(&@block_ctxt cx,
// be i8, because the data part of a vector always has type
// i8[]. So we need to cast it to the proper type.
- if (!ty.type_has_dynamic_size(last_cx.fcx.lcx.ccx.tcx, t)) {
+ if (!ty::type_has_dynamic_size(last_cx.fcx.lcx.ccx.tcx, t)) {
auto llelemty = T_ptr(type_of(last_cx.fcx.lcx.ccx, t));
av = cx.build.PointerCast(av, llelemty);
bv = cx.build.PointerCast(bv, llelemty);
@@ -2293,7 +2301,7 @@ fn make_cmp_glue(&@block_ctxt cx,
// First 'eq' comparison: if so, continue to next elts.
auto eq_r = call_cmp_glue(cx, av, bv, t,
- C_u8(abi.cmp_glue_op_eq));
+ C_u8(abi::cmp_glue_op_eq));
eq_r.bcx.build.CondBr(eq_r.val, cnt_cx.llbb, stop_cx.llbb);
// Second 'op' comparison: find out how this elt-pair decides.
@@ -2303,7 +2311,7 @@ fn make_cmp_glue(&@block_ctxt cx,
ret res(cnt_cx, C_nil());
}
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
r = iter_structural_ty_full(r.bcx, lhs, rhs, t,
bind inner(next, false, flag, llop,
_, _, _, _));
@@ -2313,7 +2321,7 @@ fn make_cmp_glue(&@block_ctxt cx,
auto min_len = umin(r.bcx, vec_fill(r.bcx, lhs),
vec_fill(r.bcx, rhs));
auto rhs_lim = r.bcx.build.GEP(rhs_p0, vec(min_len));
- auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
+ auto elt_ty = ty::sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
r = size_of(r.bcx, elt_ty);
r = iter_sequence_raw(r.bcx, lhs_p0, rhs_p0, rhs_lim, r.val,
bind inner(next, true, flag, llop,
@@ -2329,61 +2337,61 @@ fn make_cmp_glue(&@block_ctxt cx,
} else {
// FIXME: compare obj, fn by pointer?
- trans_fail(cx, none[common.span],
+ trans_fail(cx, none[common::span],
"attempt to compare values of type " +
- ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
+ ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
}
}
// A helper function to create scalar comparison glue.
fn make_scalar_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
- &ty.t t, ValueRef llop) {
- if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
+ &ty::t t, ValueRef llop) {
+ if (ty::type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
make_fp_cmp_glue(cx, lhs, rhs, t, llop);
ret;
}
- if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_bool(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_bool(cx.fcx.lcx.ccx.tcx, t)) {
make_integral_cmp_glue(cx, lhs, rhs, t, llop);
ret;
}
- if (ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
cx.build.Store(C_bool(true), cx.fcx.llretptr);
cx.build.RetVoid();
ret;
}
- trans_fail(cx, none[common.span],
+ trans_fail(cx, none[common::span],
"attempt to compare values of type " +
- ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
+ ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
}
// A helper function to create floating point comparison glue.
fn make_fp_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
- &ty.t fptype, ValueRef llop) {
+ &ty::t fptype, ValueRef llop) {
auto last_cx = new_sub_block_ctxt(cx, "last");
auto eq_cx = new_sub_block_ctxt(cx, "eq");
- auto eq_result = eq_cx.build.FCmp(lib.llvm.LLVMRealUEQ, lhs, rhs);
+ auto eq_result = eq_cx.build.FCmp(lib::llvm::LLVMRealUEQ, lhs, rhs);
eq_cx.build.Br(last_cx.llbb);
auto lt_cx = new_sub_block_ctxt(cx, "lt");
- auto lt_result = lt_cx.build.FCmp(lib.llvm.LLVMRealULT, lhs, rhs);
+ auto lt_result = lt_cx.build.FCmp(lib::llvm::LLVMRealULT, lhs, rhs);
lt_cx.build.Br(last_cx.llbb);
auto le_cx = new_sub_block_ctxt(cx, "le");
- auto le_result = le_cx.build.FCmp(lib.llvm.LLVMRealULE, lhs, rhs);
+ auto le_result = le_cx.build.FCmp(lib::llvm::LLVMRealULE, lhs, rhs);
le_cx.build.Br(last_cx.llbb);
auto unreach_cx = new_sub_block_ctxt(cx, "unreach");
unreach_cx.build.Unreachable();
auto llswitch = cx.build.Switch(llop, unreach_cx.llbb, 3u);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_eq), eq_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_lt), lt_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_le), le_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_eq), eq_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_lt), lt_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_le), le_cx.llbb);
auto last_result =
last_cx.build.Phi(T_i1(), vec(eq_result, lt_result, le_result),
@@ -2398,17 +2406,17 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
bool signed, ValueRef llop) -> result {
auto lt_cmp; auto le_cmp;
if (signed) {
- lt_cmp = lib.llvm.LLVMIntSLT;
- le_cmp = lib.llvm.LLVMIntSLE;
+ lt_cmp = lib::llvm::LLVMIntSLT;
+ le_cmp = lib::llvm::LLVMIntSLE;
} else {
- lt_cmp = lib.llvm.LLVMIntULT;
- le_cmp = lib.llvm.LLVMIntULE;
+ lt_cmp = lib::llvm::LLVMIntULT;
+ le_cmp = lib::llvm::LLVMIntULE;
}
auto last_cx = new_sub_block_ctxt(cx, "last");
auto eq_cx = new_sub_block_ctxt(cx, "eq");
- auto eq_result = eq_cx.build.ICmp(lib.llvm.LLVMIntEQ, lhs, rhs);
+ auto eq_result = eq_cx.build.ICmp(lib::llvm::LLVMIntEQ, lhs, rhs);
eq_cx.build.Br(last_cx.llbb);
auto lt_cx = new_sub_block_ctxt(cx, "lt");
@@ -2423,9 +2431,9 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
unreach_cx.build.Unreachable();
auto llswitch = cx.build.Switch(llop, unreach_cx.llbb, 3u);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_eq), eq_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_lt), lt_cx.llbb);
- llvm.LLVMAddCase(llswitch, C_u8(abi.cmp_glue_op_le), le_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_eq), eq_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_lt), lt_cx.llbb);
+ llvm::LLVMAddCase(llswitch, C_u8(abi::cmp_glue_op_le), le_cx.llbb);
auto last_result =
last_cx.build.Phi(T_i1(), vec(eq_result, lt_result, le_result),
@@ -2435,9 +2443,9 @@ fn compare_integral_values(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
// A helper function to create integral comparison glue.
fn make_integral_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
- &ty.t intype, ValueRef llop) {
+ &ty::t intype, ValueRef llop) {
auto r = compare_integral_values(cx, lhs, rhs,
- ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype), llop);
+ ty::type_is_signed(cx.fcx.lcx.ccx.tcx, intype), llop);
r.bcx.build.Store(r.val, r.bcx.fcx.llretptr);
r.bcx.build.RetVoid();
}
@@ -2445,23 +2453,23 @@ fn make_integral_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
// Tag information
-type variant_info = rec(vec[ty.t] args, ty.t ctor_ty, ast.def_id id);
+type variant_info = rec(vec[ty::t] args, ty::t ctor_ty, ast::def_id id);
// Returns information about the variants in a tag.
-fn tag_variants(&@crate_ctxt cx, &ast.def_id id) -> vec[variant_info] {
+fn tag_variants(&@crate_ctxt cx, &ast::def_id id) -> vec[variant_info] {
if (cx.sess.get_targ_crate_num() != id._0) {
- ret creader.get_tag_variants(cx.sess, cx.tcx, id);
+ ret creader::get_tag_variants(cx.sess, cx.tcx, id);
}
assert (cx.items.contains_key(id));
alt (cx.items.get(id).node) {
- case (ast.item_tag(_, ?variants, _, _, _)) {
+ case (ast::item_tag(_, ?variants, _, _, _)) {
let vec[variant_info] result = vec();
- for (ast.variant variant in variants) {
+ for (ast::variant variant in variants) {
auto ctor_ty = node_ann_type(cx, variant.node.ann);
- let vec[ty.t] arg_tys = vec();
- if (Vec.len[ast.variant_arg](variant.node.args) > 0u) {
- for (ty.arg a in ty.ty_fn_args(cx.tcx, ctor_ty)) {
+ let vec[ty::t] arg_tys = vec();
+ if (_vec::len[ast::variant_arg](variant.node.args) > 0u) {
+ for (ty::arg a in ty::ty_fn_args(cx.tcx, ctor_ty)) {
arg_tys += vec(a.ty);
}
}
@@ -2474,16 +2482,16 @@ fn tag_variants(&@crate_ctxt cx, &ast.def_id id) -> vec[variant_info] {
fail; // not reached
}
-// Returns information about the tag variant with the given ID.
+// Returns information about the tag variant with the given ID:
fn tag_variant_with_id(&@crate_ctxt cx,
- &ast.def_id tag_id,
- &ast.def_id variant_id) -> variant_info {
+ &ast::def_id tag_id,
+ &ast::def_id variant_id) -> variant_info {
auto variants = tag_variants(cx, tag_id);
auto i = 0u;
- while (i < Vec.len[variant_info](variants)) {
+ while (i < _vec::len[variant_info](variants)) {
auto variant = variants.(i);
- if (common.def_eq(variant.id, variant_id)) {
+ if (common::def_eq(variant.id, variant_id)) {
ret variant;
}
i += 1u;
@@ -2496,22 +2504,22 @@ fn tag_variant_with_id(&@crate_ctxt cx,
type val_pair_fn = fn(&@block_ctxt cx, ValueRef dst, ValueRef src) -> result;
-type val_and_ty_fn = fn(&@block_ctxt cx, ValueRef v, ty.t t) -> result;
+type val_and_ty_fn = fn(&@block_ctxt cx, ValueRef v, ty::t t) -> result;
type val_pair_and_ty_fn =
- fn(&@block_ctxt cx, ValueRef av, ValueRef bv, ty.t t) -> result;
+ fn(&@block_ctxt cx, ValueRef av, ValueRef bv, ty::t t) -> result;
// Iterates through the elements of a structural type.
fn iter_structural_ty(&@block_ctxt cx,
ValueRef v,
- &ty.t t,
+ &ty::t t,
val_and_ty_fn f)
-> result {
fn adaptor_fn(val_and_ty_fn f,
&@block_ctxt cx,
ValueRef av,
ValueRef bv,
- ty.t t) -> result {
+ ty::t t) -> result {
ret f(cx, av, t);
}
be iter_structural_ty_full(cx, v, v, t,
@@ -2522,7 +2530,7 @@ fn iter_structural_ty(&@block_ctxt cx,
fn iter_structural_ty_full(&@block_ctxt cx,
ValueRef av,
ValueRef bv,
- &ty.t t,
+ &ty::t t,
&val_pair_and_ty_fn f)
-> result {
let result r = res(cx, C_nil());
@@ -2533,8 +2541,8 @@ fn iter_structural_ty_full(&@block_ctxt cx,
&val_pair_and_ty_fn f) -> result {
auto box_a_ptr = cx.build.Load(box_a_cell);
auto box_b_ptr = cx.build.Load(box_b_cell);
- auto tnil = ty.mk_nil(cx.fcx.lcx.ccx.tcx);
- auto tbox = ty.mk_imm_box(cx.fcx.lcx.ccx.tcx, tnil);
+ auto tnil = ty::mk_nil(cx.fcx.lcx.ccx.tcx);
+ auto tbox = ty::mk_imm_box(cx.fcx.lcx.ccx.tcx, tnil);
auto inner_cx = new_sub_block_ctxt(cx, "iter box");
auto next_cx = new_sub_block_ctxt(cx, "next");
@@ -2546,10 +2554,10 @@ fn iter_structural_ty_full(&@block_ctxt cx,
ret res(next_cx, C_nil());
}
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_tup(?args)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_tup(?args)) {
let int i = 0;
- for (ty.mt arg in args) {
+ for (ty::mt arg in args) {
r = GEP_tup_like(r.bcx, t, av, vec(0, i));
auto elt_a = r.val;
r = GEP_tup_like(r.bcx, t, bv, vec(0, i));
@@ -2561,9 +2569,9 @@ fn iter_structural_ty_full(&@block_ctxt cx,
i += 1;
}
}
- case (ty.ty_rec(?fields)) {
+ case (ty::ty_rec(?fields)) {
let int i = 0;
- for (ty.field fld in fields) {
+ for (ty::field fld in fields) {
r = GEP_tup_like(r.bcx, t, av, vec(0, i));
auto llfld_a = r.val;
r = GEP_tup_like(r.bcx, t, bv, vec(0, i));
@@ -2575,9 +2583,9 @@ fn iter_structural_ty_full(&@block_ctxt cx,
i += 1;
}
}
- case (ty.ty_tag(?tid, ?tps)) {
+ case (ty::ty_tag(?tid, ?tps)) {
auto variants = tag_variants(cx.fcx.lcx.ccx, tid);
- auto n_variants = Vec.len[variant_info](variants);
+ auto n_variants = _vec::len[variant_info](variants);
// Cast the tags to types we can GEP into.
auto lltagty = T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn);
@@ -2600,7 +2608,7 @@ fn iter_structural_ty_full(&@block_ctxt cx,
// comparison know not to proceed when the discriminants differ.
auto bcx = cx;
bcx = f(bcx, lldiscrim_a, lldiscrim_b,
- ty.mk_int(cx.fcx.lcx.ccx.tcx)).bcx;
+ ty::mk_int(cx.fcx.lcx.ccx.tcx)).bcx;
auto unr_cx = new_sub_block_ctxt(bcx, "tag-iter-unr");
unr_cx.build.Unreachable();
@@ -2614,16 +2622,16 @@ fn iter_structural_ty_full(&@block_ctxt cx,
for (variant_info variant in variants) {
auto variant_cx = new_sub_block_ctxt(bcx,
"tag-iter-variant-" +
- UInt.to_str(i, 10u));
- llvm.LLVMAddCase(llswitch, C_int(i as int), variant_cx.llbb);
+ _uint::to_str(i, 10u));
+ llvm::LLVMAddCase(llswitch, C_int(i as int), variant_cx.llbb);
- if (Vec.len[ty.t](variant.args) > 0u) {
+ if (_vec::len[ty::t](variant.args) > 0u) {
// N-ary variant.
auto fn_ty = variant.ctor_ty;
- alt (ty.struct(bcx.fcx.lcx.ccx.tcx, fn_ty)) {
- case (ty.ty_fn(_, ?args, _)) {
+ alt (ty::struct(bcx.fcx.lcx.ccx.tcx, fn_ty)) {
+ case (ty::ty_fn(_, ?args, _)) {
auto j = 0;
- for (ty.arg a in args) {
+ for (ty::arg a in args) {
auto v = vec(C_int(0), C_int(j as int));
auto rslt = GEP_tag(variant_cx, llunion_a_ptr,
@@ -2636,9 +2644,9 @@ fn iter_structural_ty_full(&@block_ctxt cx,
auto llfldp_b = rslt.val;
variant_cx = rslt.bcx;
- auto ty_subst = ty.bind_params_in_type(
+ auto ty_subst = ty::bind_params_in_type(
cx.fcx.lcx.ccx.tcx, a.ty);
- ty_subst = ty.substitute_type_params(
+ ty_subst = ty::substitute_type_params(
cx.fcx.lcx.ccx.tcx, tps, ty_subst);
auto llfld_a =
@@ -2671,26 +2679,26 @@ fn iter_structural_ty_full(&@block_ctxt cx,
ret res(next_cx, C_nil());
}
- case (ty.ty_fn(_,_,_)) {
+ case (ty::ty_fn(_,_,_)) {
auto box_cell_a =
cx.build.GEP(av,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
auto box_cell_b =
cx.build.GEP(bv,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
ret iter_boxpp(cx, box_cell_a, box_cell_b, f);
}
- case (ty.ty_obj(_)) {
+ case (ty::ty_obj(_)) {
auto box_cell_a =
cx.build.GEP(av,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
auto box_cell_b =
cx.build.GEP(bv,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
ret iter_boxpp(cx, box_cell_a, box_cell_b, f);
}
case (_) {
@@ -2725,7 +2733,7 @@ fn iter_sequence_raw(@block_ctxt cx,
let ValueRef src_curr = cond_cx.build.Phi(T_int(),
vec(src_int), vec(bcx.llbb));
- auto end_test = cond_cx.build.ICmp(lib.llvm.LLVMIntULT,
+ auto end_test = cond_cx.build.ICmp(lib::llvm::LLVMIntULT,
src_curr, src_lim_int);
cond_cx.build.CondBr(end_test, body_cx.llbb, next_cx.llbb);
@@ -2752,15 +2760,15 @@ fn iter_sequence_raw(@block_ctxt cx,
fn iter_sequence_inner(&@block_ctxt cx,
ValueRef src, // elt*
ValueRef src_lim, // elt*
- &ty.t elt_ty,
+ &ty::t elt_ty,
&val_and_ty_fn f) -> result {
fn adaptor_fn(val_and_ty_fn f,
- ty.t elt_ty,
+ ty::t elt_ty,
&@block_ctxt cx,
ValueRef dst,
ValueRef src) -> result {
auto llptrty;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
auto llty = type_of(cx.fcx.lcx.ccx, elt_ty);
llptrty = T_ptr(llty);
} else {
@@ -2780,22 +2788,22 @@ fn iter_sequence_inner(&@block_ctxt cx,
// Iterates through the elements of a vec or str.
fn iter_sequence(@block_ctxt cx,
ValueRef v,
- &ty.t t,
+ &ty::t t,
&val_and_ty_fn f) -> result {
fn iter_sequence_body(@block_ctxt cx,
ValueRef v,
- &ty.t elt_ty,
+ &ty::t elt_ty,
&val_and_ty_fn f,
bool trailing_null) -> result {
auto p0 = cx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_data)));
+ C_int(abi::vec_elt_data)));
auto lenptr = cx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_fill)));
+ C_int(abi::vec_elt_fill)));
auto llunit_ty;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
llunit_ty = T_i8();
} else {
llunit_ty = type_of(cx.fcx.lcx.ccx, elt_ty);
@@ -2816,17 +2824,17 @@ fn iter_sequence(@block_ctxt cx,
ret iter_sequence_inner(bcx, p0, p1, elt_ty, f);
}
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_vec(?elt)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_vec(?elt)) {
ret iter_sequence_body(cx, v, elt.ty, f, false);
}
- case (ty.ty_str) {
- auto et = ty.mk_mach(cx.fcx.lcx.ccx.tcx, common.ty_u8);
+ case (ty::ty_str) {
+ auto et = ty::mk_mach(cx.fcx.lcx.ccx.tcx, common::ty_u8);
ret iter_sequence_body(cx, v, et, f, true);
}
case (_) { fail; }
}
- cx.fcx.lcx.ccx.sess.bug("bad type in trans.iter_sequence");
+ cx.fcx.lcx.ccx.sess.bug("bad type in trans::iter_sequence");
fail;
}
@@ -2835,7 +2843,7 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v,
auto llrawptr = cx.build.BitCast(v, T_ptr(T_i8()));
auto lltydescs = cx.build.GEP(tydesc,
vec(C_int(0),
- C_int(abi.tydesc_field_first_param)));
+ C_int(abi::tydesc_field_first_param)));
lltydescs = cx.build.Load(lltydescs);
auto llfnptr = cx.build.GEP(tydesc, vec(C_int(0), C_int(field)));
auto llfn = cx.build.Load(llfnptr);
@@ -2848,7 +2856,7 @@ fn call_tydesc_glue_full(&@block_ctxt cx, ValueRef v,
}
fn call_tydesc_glue(&@block_ctxt cx, ValueRef v,
- &ty.t t, bool escapes, int field) -> result {
+ &ty::t t, bool escapes, int field) -> result {
auto td = get_tydesc(cx, t, escapes);
call_tydesc_glue_full(td.bcx,
spill_if_immediate(td.bcx, v, t),
@@ -2857,17 +2865,17 @@ fn call_tydesc_glue(&@block_ctxt cx, ValueRef v,
}
fn maybe_call_dtor(&@block_ctxt cx, ValueRef v) -> @block_ctxt {
- auto vtbl = cx.build.GEP(v, vec(C_int(0), C_int(abi.obj_field_vtbl)));
+ auto vtbl = cx.build.GEP(v, vec(C_int(0), C_int(abi::obj_field_vtbl)));
vtbl = cx.build.Load(vtbl);
auto dtor_ptr = cx.build.GEP(vtbl, vec(C_int(0), C_int(0)));
dtor_ptr = cx.build.Load(dtor_ptr);
- auto self_t = llvm.LLVMGetElementType(val_ty(v));
+ auto self_t = llvm::LLVMGetElementType(val_ty(v));
dtor_ptr = cx.build.BitCast(dtor_ptr,
T_ptr(T_dtor(cx.fcx.lcx.ccx, self_t)));
auto dtor_cx = new_sub_block_ctxt(cx, "dtor");
auto after_cx = new_sub_block_ctxt(cx, "after_dtor");
- auto test = cx.build.ICmp(lib.llvm.LLVMIntNE, dtor_ptr,
+ auto test = cx.build.ICmp(lib::llvm::LLVMIntNE, dtor_ptr,
C_null(val_ty(dtor_ptr)));
cx.build.CondBr(test, dtor_cx.llbb, after_cx.llbb);
@@ -2881,7 +2889,7 @@ fn maybe_call_dtor(&@block_ctxt cx, ValueRef v) -> @block_ctxt {
fn call_cmp_glue(&@block_ctxt cx,
ValueRef lhs,
ValueRef rhs,
- &ty.t t,
+ &ty::t t,
ValueRef llop) -> result {
// We can't use call_tydesc_glue_full() and friends here because compare
// glue has a special signature.
@@ -2895,11 +2903,11 @@ fn call_cmp_glue(&@block_ctxt cx,
auto r = get_tydesc(cx, t, false);
auto lltydescs =
r.bcx.build.GEP(r.val, vec(C_int(0),
- C_int(abi.tydesc_field_first_param)));
+ C_int(abi::tydesc_field_first_param)));
lltydescs = r.bcx.build.Load(lltydescs);
auto llfnptr =
r.bcx.build.GEP(r.val, vec(C_int(0),
- C_int(abi.tydesc_field_cmp_glue)));
+ C_int(abi::tydesc_field_cmp_glue)));
auto llfn = r.bcx.build.Load(llfnptr);
auto llcmpresultptr = r.bcx.build.Alloca(T_i1());
@@ -2917,31 +2925,31 @@ fn call_cmp_glue(&@block_ctxt cx,
ret res(r.bcx, r.bcx.build.Load(llcmpresultptr));
}
-fn take_ty(&@block_ctxt cx, ValueRef v, ty.t t) -> result {
- if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
- ret call_tydesc_glue(cx, v, t, false, abi.tydesc_field_take_glue);
+fn take_ty(&@block_ctxt cx, ValueRef v, ty::t t) -> result {
+ if (!ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
+ ret call_tydesc_glue(cx, v, t, false, abi::tydesc_field_take_glue);
}
ret res(cx, C_nil());
}
fn drop_slot(&@block_ctxt cx,
ValueRef slot,
- &ty.t t) -> result {
+ &ty::t t) -> result {
auto llptr = load_if_immediate(cx, slot, t);
auto re = drop_ty(cx, llptr, t);
auto llty = val_ty(slot);
- auto llelemty = lib.llvm.llvm.LLVMGetElementType(llty);
+ auto llelemty = lib::llvm::llvm::LLVMGetElementType(llty);
re.bcx.build.Store(C_null(llelemty), slot);
ret re;
}
fn drop_ty(&@block_ctxt cx,
ValueRef v,
- ty.t t) -> result {
+ ty::t t) -> result {
- if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
- ret call_tydesc_glue(cx, v, t, false, abi.tydesc_field_drop_glue);
+ if (!ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
+ ret call_tydesc_glue(cx, v, t, false, abi::tydesc_field_drop_glue);
}
ret res(cx, C_nil());
}
@@ -2959,7 +2967,7 @@ fn call_memmove(&@block_ctxt cx,
auto dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8()));
auto size = cx.build.IntCast(n_bytes, T_i32());
auto align =
- if (lib.llvm.llvm.LLVMIsConstant(align_bytes) == True)
+ if (lib::llvm::llvm::LLVMIsConstant(align_bytes) == True)
{ cx.build.IntCast(align_bytes, T_i32()) }
else
{ cx.build.IntCast(C_int(0), T_i32()) };
@@ -2982,7 +2990,7 @@ fn call_bzero(&@block_ctxt cx,
auto dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8()));
auto size = cx.build.IntCast(n_bytes, T_i32());
auto align =
- if (lib.llvm.llvm.LLVMIsConstant(align_bytes) == True)
+ if (lib::llvm::llvm::LLVMIsConstant(align_bytes) == True)
{ cx.build.IntCast(align_bytes, T_i32()) }
else
{ cx.build.IntCast(C_int(0), T_i32()) };
@@ -2996,8 +3004,8 @@ fn call_bzero(&@block_ctxt cx,
fn memmove_ty(&@block_ctxt cx,
ValueRef dst,
ValueRef src,
- &ty.t t) -> result {
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ &ty::t t) -> result {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
auto llsz = size_of(cx, t);
auto llalign = align_of(llsz.bcx, t);
ret call_memmove(llalign.bcx, dst, src, llsz.val, llalign.val);
@@ -3016,23 +3024,23 @@ fn copy_ty(&@block_ctxt cx,
copy_action action,
ValueRef dst,
ValueRef src,
- &ty.t t) -> result {
- if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
+ &ty::t t) -> result {
+ if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, cx.build.Store(src, dst));
- } else if (ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
ret res(cx, C_nil());
- } else if (ty.type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
auto r = take_ty(cx, src, t);
if (action == DROP_EXISTING) {
r = drop_ty(r.bcx, r.bcx.build.Load(dst), t);
}
ret res(r.bcx, r.bcx.build.Store(src, dst));
- } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t) ||
- ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t) ||
+ ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
auto r = take_ty(cx, src, t);
if (action == DROP_EXISTING) {
r = drop_ty(r.bcx, dst, t);
@@ -3040,75 +3048,75 @@ fn copy_ty(&@block_ctxt cx,
ret memmove_ty(r.bcx, dst, src, t);
}
- cx.fcx.lcx.ccx.sess.bug("unexpected type in trans.copy_ty: " +
- ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
+ cx.fcx.lcx.ccx.sess.bug("unexpected type in trans::copy_ty: " +
+ ty::ty_to_str(cx.fcx.lcx.ccx.tcx, t));
fail;
}
-fn trans_lit(&@crate_ctxt cx, &ast.lit lit, &ast.ann ann) -> ValueRef {
+fn trans_lit(&@crate_ctxt cx, &ast::lit lit, &ast::ann ann) -> ValueRef {
alt (lit.node) {
- case (ast.lit_int(?i)) {
+ case (ast::lit_int(?i)) {
ret C_int(i);
}
- case (ast.lit_uint(?u)) {
+ case (ast::lit_uint(?u)) {
ret C_int(u as int);
}
- case (ast.lit_mach_int(?tm, ?i)) {
+ case (ast::lit_mach_int(?tm, ?i)) {
// FIXME: the entire handling of mach types falls apart
// if target int width is larger than host, at the moment;
// re-do the mach-int types using 'big' when that works.
auto t = T_int();
auto s = True;
alt (tm) {
- case (common.ty_u8) { t = T_i8(); s = False; }
- case (common.ty_u16) { t = T_i16(); s = False; }
- case (common.ty_u32) { t = T_i32(); s = False; }
- case (common.ty_u64) { t = T_i64(); s = False; }
-
- case (common.ty_i8) { t = T_i8(); }
- case (common.ty_i16) { t = T_i16(); }
- case (common.ty_i32) { t = T_i32(); }
- case (common.ty_i64) { t = T_i64(); }
+ case (common::ty_u8) { t = T_i8(); s = False; }
+ case (common::ty_u16) { t = T_i16(); s = False; }
+ case (common::ty_u32) { t = T_i32(); s = False; }
+ case (common::ty_u64) { t = T_i64(); s = False; }
+
+ case (common::ty_i8) { t = T_i8(); }
+ case (common::ty_i16) { t = T_i16(); }
+ case (common::ty_i32) { t = T_i32(); }
+ case (common::ty_i64) { t = T_i64(); }
}
ret C_integral(t, i as uint, s);
}
- case(ast.lit_float(?fs)) {
+ case(ast::lit_float(?fs)) {
ret C_float(fs);
}
- case(ast.lit_mach_float(?tm, ?s)) {
+ case(ast::lit_mach_float(?tm, ?s)) {
auto t = T_float();
alt(tm) {
- case(common.ty_f32) { t = T_f32(); }
- case(common.ty_f64) { t = T_f64(); }
+ case(common::ty_f32) { t = T_f32(); }
+ case(common::ty_f64) { t = T_f64(); }
}
ret C_floating(s, t);
}
- case (ast.lit_char(?c)) {
+ case (ast::lit_char(?c)) {
ret C_integral(T_char(), c as uint, False);
}
- case (ast.lit_bool(?b)) {
+ case (ast::lit_bool(?b)) {
ret C_bool(b);
}
- case (ast.lit_nil) {
+ case (ast::lit_nil) {
ret C_nil();
}
- case (ast.lit_str(?s)) {
+ case (ast::lit_str(?s)) {
ret C_str(cx, s);
}
}
}
-fn target_type(&@crate_ctxt cx, &ty.t t) -> ty.t {
- alt (ty.struct(cx.tcx, t)) {
- case (ty.ty_int) {
- auto struct_ty = ty.mk_mach(cx.tcx,
+fn target_type(&@crate_ctxt cx, &ty::t t) -> ty::t {
+ alt (ty::struct(cx.tcx, t)) {
+ case (ty::ty_int) {
+ auto struct_ty = ty::mk_mach(cx.tcx,
cx.sess.get_targ_cfg().int_type);
- ret ty.copy_cname(cx.tcx, struct_ty, t);
+ ret ty::copy_cname(cx.tcx, struct_ty, t);
}
- case (ty.ty_uint) {
- auto struct_ty = ty.mk_mach(cx.tcx,
+ case (ty::ty_uint) {
+ auto struct_ty = ty::mk_mach(cx.tcx,
cx.sess.get_targ_cfg().uint_type);
- ret ty.copy_cname(cx.tcx, struct_ty, t);
+ ret ty::copy_cname(cx.tcx, struct_ty, t);
}
case (_) { /* fall through */ }
}
@@ -3117,61 +3125,61 @@ fn target_type(&@crate_ctxt cx, &ty.t t) -> ty.t {
// Converts an annotation to a type
-fn node_ann_type(&@crate_ctxt cx, &ast.ann a) -> ty.t {
- ret target_type(cx, ty.ann_to_monotype(cx.tcx, a));
+fn node_ann_type(&@crate_ctxt cx, &ast::ann a) -> ty::t {
+ ret target_type(cx, ty::ann_to_monotype(cx.tcx, a));
}
-fn node_ann_ty_params(&ast.ann a) -> vec[ty.t] {
+fn node_ann_ty_params(&ast::ann a) -> vec[ty::t] {
alt (a) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log_err "missing type annotation";
fail;
}
- case (ast.ann_type(_, _, ?tps_opt, _)) {
+ case (ast::ann_type(_, _, ?tps_opt, _)) {
alt (tps_opt) {
- case (none[vec[ty.t]]) {
+ case (none[vec[ty::t]]) {
log_err "type annotation has no ty params";
fail;
}
- case (some[vec[ty.t]](?tps)) { ret tps; }
+ case (some[vec[ty::t]](?tps)) { ret tps; }
}
}
}
}
-fn node_type(&@crate_ctxt cx, &ast.ann a) -> TypeRef {
+fn node_type(&@crate_ctxt cx, &ast::ann a) -> TypeRef {
ret type_of(cx, node_ann_type(cx, a));
}
-fn trans_unary(&@block_ctxt cx, ast.unop op,
- &@ast.expr e, &ast.ann a) -> result {
+fn trans_unary(&@block_ctxt cx, ast::unop op,
+ &@ast::expr e, &ast::ann a) -> result {
auto sub = trans_expr(cx, e);
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
alt (op) {
- case (ast.bitnot) {
+ case (ast::bitnot) {
sub = autoderef(sub.bcx, sub.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
ret res(sub.bcx, sub.bcx.build.Not(sub.val));
}
- case (ast.not) {
+ case (ast::not) {
sub = autoderef(sub.bcx, sub.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
ret res(sub.bcx, sub.bcx.build.Not(sub.val));
}
- case (ast.neg) {
+ case (ast::neg) {
sub = autoderef(sub.bcx, sub.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
- if(ty.struct(cx.fcx.lcx.ccx.tcx, e_ty) == ty.ty_float) {
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ if(ty::struct(cx.fcx.lcx.ccx.tcx, e_ty) == ty::ty_float) {
ret res(sub.bcx, sub.bcx.build.FNeg(sub.val));
}
else {
ret res(sub.bcx, sub.bcx.build.Neg(sub.val));
}
}
- case (ast.box(_)) {
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ case (ast::box(_)) {
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
auto e_val = sub.val;
auto box_ty = node_ann_type(sub.bcx.fcx.lcx.ccx, a);
sub = trans_malloc_boxed(sub.bcx, e_ty);
@@ -3181,16 +3189,16 @@ fn trans_unary(&@block_ctxt cx, ast.unop op,
auto box = sub.val;
auto rc = sub.bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto body = sub.bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
sub.bcx.build.Store(C_int(1), rc);
// Cast the body type to the type of the value. This is needed to
// make tags work, since tags have a different LLVM type depending
// on whether they're boxed or not.
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, e_ty)) {
auto llety = T_ptr(type_of(sub.bcx.fcx.lcx.ccx, e_ty));
body = sub.bcx.build.PointerCast(body, llety);
}
@@ -3198,7 +3206,7 @@ fn trans_unary(&@block_ctxt cx, ast.unop op,
sub = copy_ty(sub.bcx, INIT, body, e_val, e_ty);
ret res(sub.bcx, box);
}
- case (ast.deref) {
+ case (ast::deref) {
log_err "deref expressions should have been translated using " +
"trans_lval(), not trans_unary()";
fail;
@@ -3207,7 +3215,7 @@ fn trans_unary(&@block_ctxt cx, ast.unop op,
fail;
}
-fn trans_compare(&@block_ctxt cx0, ast.binop op, &ty.t t0,
+fn trans_compare(&@block_ctxt cx0, ast::binop op, &ty::t t0,
ValueRef lhs0, ValueRef rhs0) -> result {
// Autoderef both sides.
auto cx = cx0;
@@ -3226,12 +3234,12 @@ fn trans_compare(&@block_ctxt cx0, ast.binop op, &ty.t t0,
// FIXME: Use or-patterns when we have them.
auto llop;
alt (op) {
- case (ast.eq) { llop = C_u8(abi.cmp_glue_op_eq); }
- case (ast.lt) { llop = C_u8(abi.cmp_glue_op_lt); }
- case (ast.le) { llop = C_u8(abi.cmp_glue_op_le); }
- case (ast.ne) { llop = C_u8(abi.cmp_glue_op_eq); }
- case (ast.ge) { llop = C_u8(abi.cmp_glue_op_lt); }
- case (ast.gt) { llop = C_u8(abi.cmp_glue_op_le); }
+ case (ast::eq) { llop = C_u8(abi::cmp_glue_op_eq); }
+ case (ast::lt) { llop = C_u8(abi::cmp_glue_op_lt); }
+ case (ast::le) { llop = C_u8(abi::cmp_glue_op_le); }
+ case (ast::ne) { llop = C_u8(abi::cmp_glue_op_eq); }
+ case (ast::ge) { llop = C_u8(abi::cmp_glue_op_lt); }
+ case (ast::gt) { llop = C_u8(abi::cmp_glue_op_le); }
}
auto rslt = call_cmp_glue(cx, lhs, rhs, t, llop);
@@ -3239,23 +3247,23 @@ fn trans_compare(&@block_ctxt cx0, ast.binop op, &ty.t t0,
// Invert the result if necessary.
// FIXME: Use or-patterns when we have them.
alt (op) {
- case (ast.eq) { ret res(rslt.bcx, rslt.val); }
- case (ast.lt) { ret res(rslt.bcx, rslt.val); }
- case (ast.le) { ret res(rslt.bcx, rslt.val); }
- case (ast.ne) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
- case (ast.ge) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
- case (ast.gt) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
+ case (ast::eq) { ret res(rslt.bcx, rslt.val); }
+ case (ast::lt) { ret res(rslt.bcx, rslt.val); }
+ case (ast::le) { ret res(rslt.bcx, rslt.val); }
+ case (ast::ne) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
+ case (ast::ge) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
+ case (ast::gt) { ret res(rslt.bcx, rslt.bcx.build.Not(rslt.val)); }
}
}
-fn trans_vec_append(&@block_ctxt cx, &ty.t t,
+fn trans_vec_append(&@block_ctxt cx, &ty::t t,
ValueRef lhs, ValueRef rhs) -> result {
- auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
+ auto elt_ty = ty::sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
auto skip_null = C_bool(false);
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_str) { skip_null = C_bool(true); }
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_str) { skip_null = C_bool(true); }
case (_) { }
}
@@ -3277,7 +3285,7 @@ fn trans_vec_append(&@block_ctxt cx, &ty.t t,
dst, src, skip_null)));
}
-fn trans_vec_add(&@block_ctxt cx, &ty.t t,
+fn trans_vec_add(&@block_ctxt cx, &ty::t t,
ValueRef lhs, ValueRef rhs) -> result {
auto r = alloc_ty(cx, t);
auto tmp = r.val;
@@ -3290,12 +3298,12 @@ fn trans_vec_add(&@block_ctxt cx, &ty.t t,
}
-fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
+fn trans_eager_binop(&@block_ctxt cx, ast::binop op, &ty::t intype,
ValueRef lhs, ValueRef rhs) -> result {
auto is_float = false;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, intype)) {
- case (ty.ty_float) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, intype)) {
+ case (ty::ty_float) {
is_float = true;
}
case (_) {
@@ -3304,8 +3312,8 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
}
alt (op) {
- case (ast.add) {
- if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, intype)) {
+ case (ast::add) {
+ if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, intype)) {
ret trans_vec_add(cx, intype, lhs, rhs);
}
if (is_float) {
@@ -3315,7 +3323,7 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
ret res(cx, cx.build.Add(lhs, rhs));
}
}
- case (ast.sub) {
+ case (ast::sub) {
if (is_float) {
ret res(cx, cx.build.FSub(lhs, rhs));
}
@@ -3324,7 +3332,7 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
}
}
- case (ast.mul) {
+ case (ast::mul) {
if (is_float) {
ret res(cx, cx.build.FMul(lhs, rhs));
}
@@ -3333,33 +3341,33 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
}
}
- case (ast.div) {
+ case (ast::div) {
if (is_float) {
ret res(cx, cx.build.FDiv(lhs, rhs));
}
- if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
+ if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
ret res(cx, cx.build.SDiv(lhs, rhs));
} else {
ret res(cx, cx.build.UDiv(lhs, rhs));
}
}
- case (ast.rem) {
+ case (ast::rem) {
if (is_float) {
ret res(cx, cx.build.FRem(lhs, rhs));
}
- if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
+ if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
ret res(cx, cx.build.SRem(lhs, rhs));
} else {
ret res(cx, cx.build.URem(lhs, rhs));
}
}
- case (ast.bitor) { ret res(cx, cx.build.Or(lhs, rhs)); }
- case (ast.bitand) { ret res(cx, cx.build.And(lhs, rhs)); }
- case (ast.bitxor) { ret res(cx, cx.build.Xor(lhs, rhs)); }
- case (ast.lsl) { ret res(cx, cx.build.Shl(lhs, rhs)); }
- case (ast.lsr) { ret res(cx, cx.build.LShr(lhs, rhs)); }
- case (ast.asr) { ret res(cx, cx.build.AShr(lhs, rhs)); }
+ case (ast::bitor) { ret res(cx, cx.build.Or(lhs, rhs)); }
+ case (ast::bitand) { ret res(cx, cx.build.And(lhs, rhs)); }
+ case (ast::bitxor) { ret res(cx, cx.build.Xor(lhs, rhs)); }
+ case (ast::lsl) { ret res(cx, cx.build.Shl(lhs, rhs)); }
+ case (ast::lsr) { ret res(cx, cx.build.LShr(lhs, rhs)); }
+ case (ast::asr) { ret res(cx, cx.build.AShr(lhs, rhs)); }
case (_) {
ret trans_compare(cx, op, intype, lhs, rhs);
}
@@ -3367,23 +3375,23 @@ fn trans_eager_binop(&@block_ctxt cx, ast.binop op, &ty.t intype,
fail;
}
-fn autoderef(&@block_ctxt cx, ValueRef v, &ty.t t) -> result {
+fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
let ValueRef v1 = v;
- let ty.t t1 = t;
+ let ty::t t1 = t;
while (true) {
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t1)) {
- case (ty.ty_box(?mt)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t1)) {
+ case (ty::ty_box(?mt)) {
auto body = cx.build.GEP(v1,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
t1 = mt.ty;
// Since we're changing levels of box indirection, we may have
// to cast this pointer, since statically-sized tag types have
// different types depending on whether they're behind a box
// or not.
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, mt.ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, mt.ty)) {
auto llty = type_of(cx.fcx.lcx.ccx, mt.ty);
v1 = cx.build.PointerCast(body, T_ptr(llty));
} else {
@@ -3399,12 +3407,12 @@ fn autoderef(&@block_ctxt cx, ValueRef v, &ty.t t) -> result {
}
}
-fn autoderefed_ty(&@crate_ctxt ccx, &ty.t t) -> ty.t {
- let ty.t t1 = t;
+fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
+ let ty::t t1 = t;
while (true) {
- alt (ty.struct(ccx.tcx, t1)) {
- case (ty.ty_box(?mt)) {
+ alt (ty::struct(ccx.tcx, t1)) {
+ case (ty::ty_box(?mt)) {
t1 = mt.ty;
}
case (_) {
@@ -3414,22 +3422,22 @@ fn autoderefed_ty(&@crate_ctxt ccx, &ty.t t) -> ty.t {
}
}
-fn trans_binary(&@block_ctxt cx, ast.binop op,
- &@ast.expr a, &@ast.expr b) -> result {
+fn trans_binary(&@block_ctxt cx, ast::binop op,
+ &@ast::expr a, &@ast::expr b) -> result {
// First couple cases are lazy:
alt (op) {
- case (ast.and) {
+ case (ast::and) {
// Lazy-eval and
auto lhs_res = trans_expr(cx, a);
lhs_res = autoderef(lhs_res.bcx, lhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, a));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, a));
auto rhs_cx = new_scope_block_ctxt(cx, "rhs");
auto rhs_res = trans_expr(rhs_cx, b);
rhs_res = autoderef(rhs_res.bcx, rhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, b));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, b));
auto lhs_false_cx = new_scope_block_ctxt(cx, "lhs false");
auto lhs_false_res = res(lhs_false_cx, C_bool(false));
@@ -3442,16 +3450,16 @@ fn trans_binary(&@block_ctxt cx, ast.binop op,
vec(lhs_false_res, rhs_res));
}
- case (ast.or) {
+ case (ast::or) {
// Lazy-eval or
auto lhs_res = trans_expr(cx, a);
lhs_res = autoderef(lhs_res.bcx, lhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, a));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, a));
auto rhs_cx = new_scope_block_ctxt(cx, "rhs");
auto rhs_res = trans_expr(rhs_cx, b);
rhs_res = autoderef(rhs_res.bcx, rhs_res.val,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, b));
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, b));
auto lhs_true_cx = new_scope_block_ctxt(cx, "lhs true");
auto lhs_true_res = res(lhs_true_cx, C_bool(true));
@@ -3467,10 +3475,10 @@ fn trans_binary(&@block_ctxt cx, ast.binop op,
case (_) {
// Remaining cases are eager:
auto lhs = trans_expr(cx, a);
- auto lhty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, a);
+ auto lhty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, a);
lhs = autoderef(lhs.bcx, lhs.val, lhty);
auto rhs = trans_expr(lhs.bcx, b);
- auto rhty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, b);
+ auto rhty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, b);
rhs = autoderef(rhs.bcx, rhs.val, rhty);
ret trans_eager_binop(rhs.bcx, op,
autoderefed_ty(cx.fcx.lcx.ccx, lhty), lhs.val, rhs.val);
@@ -3496,12 +3504,12 @@ fn join_results(&@block_ctxt parent_cx,
}
}
- alt (Vec.len[result](live)) {
+ alt (_vec::len[result](live)) {
case (0u) {
// No incoming edges are live, so we're in dead-code-land.
// Arbitrarily pick the first dead edge, since the caller
// is just going to propagate it outward.
- assert (Vec.len[result](ins) >= 1u);
+ assert (_vec::len[result](ins) >= 1u);
ret ins.(0);
}
@@ -3517,8 +3525,8 @@ fn join_results(&@block_ctxt parent_cx,
ret res(join_cx, phi);
}
-fn trans_if(&@block_ctxt cx, &@ast.expr cond,
- &ast.block thn, &Option.t[@ast.expr] els) -> result {
+fn trans_if(&@block_ctxt cx, &@ast::expr cond,
+ &ast::block thn, &option::t[@ast::expr] els) -> result {
auto cond_res = trans_expr(cx, cond);
@@ -3530,12 +3538,12 @@ fn trans_if(&@block_ctxt cx, &@ast.expr cond,
auto else_res;
auto expr_llty;
alt (els) {
- case (some[@ast.expr](?elexpr)) {
+ case (some[@ast::expr](?elexpr)) {
alt (elexpr.node) {
- case (ast.expr_if(_, _, _, _)) {
+ case (ast::expr_if(_, _, _, _)) {
else_res = trans_expr(else_cx, elexpr);
}
- case (ast.expr_block(?blk, _)) {
+ case (ast::expr_block(?blk, _)) {
// Calling trans_block directly instead of trans_expr
// because trans_expr will create another scope block
// context for the block, but we've already got the
@@ -3547,12 +3555,12 @@ fn trans_if(&@block_ctxt cx, &@ast.expr cond,
// If we have an else expression, then the entire
// if expression can have a non-nil type.
// FIXME: This isn't quite right, particularly re: dynamic types
- auto expr_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, elexpr);
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ auto expr_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, elexpr);
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
} else {
expr_llty = type_of(else_res.bcx.fcx.lcx.ccx, expr_ty);
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_ptr(expr_llty);
}
}
@@ -3572,17 +3580,17 @@ fn trans_if(&@block_ctxt cx, &@ast.expr cond,
}
fn trans_for(&@block_ctxt cx,
- &@ast.decl decl,
- &@ast.expr seq,
- &ast.block body) -> result {
+ &@ast::decl decl,
+ &@ast::expr seq,
+ &ast::block body) -> result {
fn inner(&@block_ctxt cx,
- @ast.local local, ValueRef curr,
- ty.t t, ast.block body,
+ @ast::local local, ValueRef curr,
+ ty::t t, ast::block body,
@block_ctxt outer_next_cx) -> result {
auto next_cx = new_sub_block_ctxt(cx, "next");
auto scope_cx =
- new_loop_scope_block_ctxt(cx, Option.some[@block_ctxt](next_cx),
+ new_loop_scope_block_ctxt(cx, option::some[@block_ctxt](next_cx),
outer_next_cx, "for loop scope");
cx.build.Br(scope_cx.llbb);
@@ -3596,15 +3604,15 @@ fn trans_for(&@block_ctxt cx,
}
- let @ast.local local;
+ let @ast::local local;
alt (decl.node) {
- case (ast.decl_local(?loc)) {
+ case (ast::decl_local(?loc)) {
local = loc;
}
}
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto seq_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, seq);
+ auto seq_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, seq);
auto seq_res = trans_expr(cx, seq);
auto it = iter_sequence(seq_res.bcx, seq_res.val, seq_ty,
bind inner(_, local, _, _, body, next_cx));
@@ -3617,26 +3625,26 @@ fn trans_for(&@block_ctxt cx,
// Searches through a block for all references to locals or upvars in this
// frame and returns the list of definition IDs thus found.
-fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
- -> vec[ast.def_id] {
+fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
+ &ast::def_id initial_decl) -> vec[ast::def_id] {
type env = @rec(
- mutable vec[ast.def_id] refs,
- hashmap[ast.def_id,()] decls,
- resolve.def_map def_map
+ mutable vec[ast::def_id] refs,
+ hashmap[ast::def_id,()] decls,
+ resolve::def_map def_map
);
- fn walk_expr(env e, &@ast.expr expr) {
+ fn walk_expr(env e, &@ast::expr expr) {
alt (expr.node) {
- case (ast.expr_path(?path, ?ann)) {
- alt (e.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_arg(?did)) {
- Vec.push[ast.def_id](e.refs, did);
+ case (ast::expr_path(?path, ?ann)) {
+ alt (e.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_arg(?did)) {
+ _vec::push[ast::def_id](e.refs, did);
}
- case (ast.def_local(?did)) {
- Vec.push[ast.def_id](e.refs, did);
+ case (ast::def_local(?did)) {
+ _vec::push[ast::def_id](e.refs, did);
}
- case (ast.def_upvar(?did)) {
- Vec.push[ast.def_id](e.refs, did);
+ case (ast::def_upvar(?did)) {
+ _vec::push[ast::def_id](e.refs, did);
}
case (_) {}
}
@@ -3645,17 +3653,17 @@ fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
}
}
- fn walk_decl(env e, &@ast.decl decl) {
+ fn walk_decl(env e, &@ast::decl decl) {
alt (decl.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
e.decls.insert(local.id, ());
}
case (_) {}
}
}
- let vec[ast.def_id] refs = vec();
- let hashmap[ast.def_id,()] decls = new_def_hash[()]();
+ let vec[ast::def_id] refs = vec();
+ let hashmap[ast::def_id,()] decls = new_def_hash[()]();
decls.insert(initial_decl, ());
let env e = @rec(mutable refs=refs,
decls=decls,
@@ -3663,12 +3671,12 @@ fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
auto visitor = @rec(visit_decl_pre = bind walk_decl(e, _),
visit_expr_pre = bind walk_expr(e, _)
- with walk.default_visitor());
- walk.walk_block(*visitor, bloc);
+ with walk::default_visitor());
+ walk::walk_block(*visitor, bloc);
// Calculate (refs - decls). This is the set of captured upvars.
- let vec[ast.def_id] result = vec();
- for (ast.def_id ref_id in e.refs) {
+ let vec[ast::def_id] result = vec();
+ for (ast::def_id ref_id in e.refs) {
if (!decls.contains_key(ref_id)) {
result += vec(ref_id);
}
@@ -3678,9 +3686,9 @@ fn collect_upvars(&@block_ctxt cx, &ast.block bloc, &ast.def_id initial_decl)
}
fn trans_for_each(&@block_ctxt cx,
- &@ast.decl decl,
- &@ast.expr seq,
- &ast.block body) -> result {
+ &@ast::decl decl,
+ &@ast::expr seq,
+ &ast::block body) -> result {
/*
* The translation is a little .. complex here. Code like:
*
@@ -3709,24 +3717,24 @@ fn trans_for_each(&@block_ctxt cx,
auto lcx = cx.fcx.lcx;
// FIXME: possibly support alias-mode here?
- auto decl_ty = ty.mk_nil(lcx.ccx.tcx);
+ auto decl_ty = ty::mk_nil(lcx.ccx.tcx);
auto decl_id;
alt (decl.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
decl_ty = node_ann_type(lcx.ccx, local.ann);
decl_id = local.id;
}
}
auto upvars = collect_upvars(cx, body, decl_id);
- auto upvar_count = Vec.len[ast.def_id](upvars);
+ auto upvar_count = _vec::len[ast::def_id](upvars);
auto llbindingsptr;
if (upvar_count > 0u) {
// Gather up the upvars.
let vec[ValueRef] llbindings = vec();
let vec[TypeRef] llbindingtys = vec();
- for (ast.def_id did in upvars) {
+ for (ast::def_id did in upvars) {
auto llbinding;
alt (cx.fcx.lllocals.find(did)) {
case (none[ValueRef]) {
@@ -3758,14 +3766,14 @@ fn trans_for_each(&@block_ctxt cx,
}
// Create an environment and populate it with the bindings.
- auto tydesc_count = Vec.len[ValueRef](cx.fcx.lltydescs);
+ auto tydesc_count = _vec::len[ValueRef](cx.fcx.lltydescs);
auto llenvptrty = T_closure_ptr(lcx.ccx.tn, T_ptr(T_nil()),
val_ty(llbindingsptr), tydesc_count);
- auto llenvptr = alloca(cx, llvm.LLVMGetElementType(llenvptrty));
+ auto llenvptr = alloca(cx, llvm::LLVMGetElementType(llenvptrty));
auto llbindingsptrptr = cx.build.GEP(llenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
+ C_int(abi::box_rc_field_body),
C_int(2)));
cx.build.Store(llbindingsptr, llbindingsptrptr);
@@ -3773,8 +3781,8 @@ fn trans_for_each(&@block_ctxt cx,
// to them.
auto lltydescsptr = cx.build.GEP(llenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.closure_elt_ty_params)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::closure_elt_ty_params)));
auto i = 0u;
while (i < tydesc_count) {
auto lltydescptr = cx.build.GEP(lltydescsptr,
@@ -3794,10 +3802,10 @@ fn trans_for_each(&@block_ctxt cx,
// and pass it in as a first class fn-arg to the iterator.
auto iter_body_llty =
- type_of_fn_full(lcx.ccx, ast.proto_fn,
+ type_of_fn_full(lcx.ccx, ast::proto_fn,
none[TypeRef],
- vec(rec(mode=ty.mo_alias, ty=decl_ty)),
- ty.mk_nil(lcx.ccx.tcx), 0u);
+ vec(rec(mode=ty::mo_alias, ty=decl_ty)),
+ ty::mk_nil(lcx.ccx.tcx), 0u);
let ValueRef lliterbody = decl_internal_fastcall_fn(lcx.ccx.llmod,
s, iter_body_llty);
@@ -3812,8 +3820,8 @@ fn trans_for_each(&@block_ctxt cx,
auto llremotebindingsptrptr =
copy_args_bcx.build.GEP(llremoteenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.closure_elt_bindings)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::closure_elt_bindings)));
auto llremotebindingsptr =
copy_args_bcx.build.Load(llremotebindingsptrptr);
@@ -3833,8 +3841,8 @@ fn trans_for_each(&@block_ctxt cx,
auto llremotetydescsptr =
copy_args_bcx.build.GEP(llremoteenvptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.closure_elt_ty_params)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::closure_elt_ty_params)));
i = 0u;
while (i < tydesc_count) {
@@ -3847,7 +3855,7 @@ fn trans_for_each(&@block_ctxt cx,
}
// Add an upvar for the loop variable alias.
- fcx.llupvars.insert(decl_id, llvm.LLVMGetParam(fcx.llfn, 3u));
+ fcx.llupvars.insert(decl_id, llvm::LLVMGetParam(fcx.llfn, 3u));
auto bcx = new_top_block_ctxt(fcx);
auto lltop = bcx.llbb;
@@ -3862,17 +3870,17 @@ fn trans_for_each(&@block_ctxt cx,
alt (seq.node) {
- case (ast.expr_call(?f, ?args, ?ann)) {
+ case (ast::expr_call(?f, ?args, ?ann)) {
auto pair = alloca(cx, T_fn_pair(lcx.ccx.tn,
iter_body_llty));
auto code_cell = cx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
cx.build.Store(lliterbody, code_cell);
auto env_cell = cx.build.GEP(pair, vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
auto llenvblobptr = cx.build.PointerCast(llenvptr,
T_opaque_closure_ptr(lcx.ccx.tn));
cx.build.Store(llenvblobptr, env_cell);
@@ -3889,12 +3897,12 @@ fn trans_for_each(&@block_ctxt cx,
}
-fn trans_while(&@block_ctxt cx, &@ast.expr cond,
- &ast.block body) -> result {
+fn trans_while(&@block_ctxt cx, &@ast::expr cond,
+ &ast::block body) -> result {
auto cond_cx = new_scope_block_ctxt(cx, "while cond");
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto body_cx = new_loop_scope_block_ctxt(cx, Option.none[@block_ctxt],
+ auto body_cx = new_loop_scope_block_ctxt(cx, option::none[@block_ctxt],
next_cx, "while loop body");
auto body_res = trans_block(body_cx, body);
@@ -3909,11 +3917,11 @@ fn trans_while(&@block_ctxt cx, &@ast.expr cond,
ret res(next_cx, C_nil());
}
-fn trans_do_while(&@block_ctxt cx, &ast.block body,
- &@ast.expr cond) -> result {
+fn trans_do_while(&@block_ctxt cx, &ast::block body,
+ &@ast::expr cond) -> result {
auto next_cx = new_sub_block_ctxt(cx, "next");
- auto body_cx = new_loop_scope_block_ctxt(cx, Option.none[@block_ctxt],
+ auto body_cx = new_loop_scope_block_ctxt(cx, option::none[@block_ctxt],
next_cx, "do-while loop body");
auto body_res = trans_block(body_cx, body);
@@ -3928,23 +3936,23 @@ fn trans_do_while(&@block_ctxt cx, &ast.block body,
// Pattern matching translation
-fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
+fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
&@block_ctxt next_cx) -> result {
alt (pat.node) {
- case (ast.pat_wild(_)) { ret res(cx, llval); }
- case (ast.pat_bind(_, _, _)) { ret res(cx, llval); }
+ case (ast::pat_wild(_)) { ret res(cx, llval); }
+ case (ast::pat_bind(_, _, _)) { ret res(cx, llval); }
- case (ast.pat_lit(?lt, ?ann)) {
+ case (ast::pat_lit(?lt, ?ann)) {
auto lllit = trans_lit(cx.fcx.lcx.ccx, *lt, ann);
- auto lltype = ty.ann_to_type(ann);
- auto lleq = trans_compare(cx, ast.eq, lltype, llval, lllit);
+ auto lltype = ty::ann_to_type(ann);
+ auto lleq = trans_compare(cx, ast::eq, lltype, llval, lllit);
auto matched_cx = new_sub_block_ctxt(lleq.bcx, "matched_cx");
lleq.bcx.build.CondBr(lleq.val, matched_cx.llbb, next_cx.llbb);
ret res(matched_cx, llval);
}
- case (ast.pat_tag(?id, ?subpats, ?ann)) {
+ case (ast::pat_tag(?id, ?subpats, ?ann)) {
auto lltagptr = cx.build.PointerCast(llval,
T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn));
@@ -3952,8 +3960,8 @@ fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
vec(C_int(0), C_int(0)));
auto lldiscrim = cx.build.Load(lldiscrimptr);
- auto vdef = ast.variant_def_ids
- (cx.fcx.lcx.ccx.tcx.def_map.get(ast.ann_tag(ann)));
+ auto vdef = ast::variant_def_ids
+ (cx.fcx.lcx.ccx.tcx.def_map.get(ast::ann_tag(ann)));
auto variant_tag = 0;
auto variants = tag_variants(cx.fcx.lcx.ccx, vdef._0);
@@ -3969,17 +3977,17 @@ fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
auto matched_cx = new_sub_block_ctxt(cx, "matched_cx");
- auto lleq = cx.build.ICmp(lib.llvm.LLVMIntEQ, lldiscrim,
+ auto lleq = cx.build.ICmp(lib::llvm::LLVMIntEQ, lldiscrim,
C_int(variant_tag));
cx.build.CondBr(lleq, matched_cx.llbb, next_cx.llbb);
auto ty_params = node_ann_ty_params(ann);
- if (Vec.len[@ast.pat](subpats) > 0u) {
+ if (_vec::len[@ast::pat](subpats) > 0u) {
auto llblobptr = matched_cx.build.GEP(lltagptr,
vec(C_int(0), C_int(1)));
auto i = 0;
- for (@ast.pat subpat in subpats) {
+ for (@ast::pat subpat in subpats) {
auto rslt = GEP_tag(matched_cx, llblobptr, vdef._0,
vdef._1, ty_params, i);
auto llsubvalptr = rslt.val;
@@ -4002,13 +4010,13 @@ fn trans_pat_match(&@block_ctxt cx, &@ast.pat pat, ValueRef llval,
fail;
}
-fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
+fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
ValueRef llval, bool bind_alias)
-> result {
alt (pat.node) {
- case (ast.pat_wild(_)) { ret res(cx, llval); }
- case (ast.pat_lit(_, _)) { ret res(cx, llval); }
- case (ast.pat_bind(?id, ?def_id, ?ann)) {
+ case (ast::pat_wild(_)) { ret res(cx, llval); }
+ case (ast::pat_lit(_, _)) { ret res(cx, llval); }
+ case (ast::pat_bind(?id, ?def_id, ?ann)) {
if (bind_alias) {
cx.fcx.lllocals.insert(def_id, llval);
ret res(cx, llval);
@@ -4024,12 +4032,12 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
ret copy_ty(bcx, INIT, dst, llval, t);
}
}
- case (ast.pat_tag(_, ?subpats, ?ann)) {
- if (Vec.len[@ast.pat](subpats) == 0u) { ret res(cx, llval); }
+ case (ast::pat_tag(_, ?subpats, ?ann)) {
+ if (_vec::len[@ast::pat](subpats) == 0u) { ret res(cx, llval); }
// Get the appropriate variant for this tag.
- auto vdef = ast.variant_def_ids
- (cx.fcx.lcx.ccx.tcx.def_map.get(ast.ann_tag(ann)));
+ auto vdef = ast::variant_def_ids
+ (cx.fcx.lcx.ccx.tcx.def_map.get(ast::ann_tag(ann)));
auto lltagptr = cx.build.PointerCast(llval,
T_opaque_tag_ptr(cx.fcx.lcx.ccx.tn));
@@ -4039,7 +4047,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
auto this_cx = cx;
auto i = 0;
- for (@ast.pat subpat in subpats) {
+ for (@ast::pat subpat in subpats) {
auto rslt = GEP_tag(this_cx, llblobptr, vdef._0, vdef._1,
ty_param_substs, i);
this_cx = rslt.bcx;
@@ -4054,13 +4062,13 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast.pat pat,
}
}
-fn trans_alt(&@block_ctxt cx, &@ast.expr expr,
- &vec[ast.arm] arms, &ast.ann ann) -> result {
+fn trans_alt(&@block_ctxt cx, &@ast::expr expr,
+ &vec[ast::arm] arms, &ast::ann ann) -> result {
auto expr_res = trans_expr(cx, expr);
auto this_cx = expr_res.bcx;
let vec[result] arm_results = vec();
- for (ast.arm arm in arms) {
+ for (ast::arm arm in arms) {
auto next_cx = new_sub_block_ctxt(expr_res.bcx, "next");
auto match_res = trans_pat_match(this_cx, arm.pat, expr_res.val,
next_cx);
@@ -4078,17 +4086,17 @@ fn trans_alt(&@block_ctxt cx, &@ast.expr expr,
}
auto default_cx = this_cx;
- auto default_res = trans_fail(default_cx, some[common.span](expr.span),
+ auto default_res = trans_fail(default_cx, some[common::span](expr.span),
"non-exhaustive match failure");
// FIXME: This isn't quite right, particularly re: dynamic types
- auto expr_ty = ty.ann_to_type(ann);
+ auto expr_ty = ty::ann_to_type(ann);
auto expr_llty;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
} else {
expr_llty = type_of(cx.fcx.lcx.ccx, expr_ty);
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_ptr(expr_llty);
}
}
@@ -4096,21 +4104,21 @@ fn trans_alt(&@block_ctxt cx, &@ast.expr expr,
ret join_results(cx, expr_llty, arm_results);
}
-type generic_info = rec(ty.t item_type,
+type generic_info = rec(ty::t item_type,
vec[ValueRef] tydescs);
type lval_result = rec(result res,
bool is_mem,
- Option.t[generic_info] generic,
- Option.t[ValueRef] llobj,
- Option.t[ty.t] method_ty);
+ option::t[generic_info] generic,
+ option::t[ValueRef] llobj,
+ option::t[ty::t] method_ty);
fn lval_mem(&@block_ctxt cx, ValueRef val) -> lval_result {
ret rec(res=res(cx, val),
is_mem=true,
generic=none[generic_info],
llobj=none[ValueRef],
- method_ty=none[ty.t]);
+ method_ty=none[ty::t]);
}
fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
@@ -4118,22 +4126,22 @@ fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
is_mem=false,
generic=none[generic_info],
llobj=none[ValueRef],
- method_ty=none[ty.t]);
+ method_ty=none[ty::t]);
}
-fn trans_external_path(&@block_ctxt cx, &ast.def_id did,
- &ty.ty_param_count_and_ty tpt) -> lval_result {
+fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
+ &ty::ty_param_count_and_ty tpt) -> lval_result {
auto lcx = cx.fcx.lcx;
- auto name = creader.get_symbol(lcx.ccx.sess, did);
+ auto name = creader::get_symbol(lcx.ccx.sess, did);
auto v = get_extern_const(lcx.ccx.externs, lcx.ccx.llmod,
name, type_of_ty_param_count_and_ty(lcx, tpt));
ret lval_val(cx, v);
}
fn lval_generic_fn(&@block_ctxt cx,
- &ty.ty_param_count_and_ty tpt,
- &ast.def_id fn_id,
- &ast.ann ann)
+ &ty::ty_param_count_and_ty tpt,
+ &ast::def_id fn_id,
+ &ast::ann ann)
-> lval_result {
auto lv;
if (cx.fcx.lcx.ccx.sess.get_targ_crate_num() == fn_id._0) {
@@ -4146,26 +4154,26 @@ fn lval_generic_fn(&@block_ctxt cx,
}
auto monoty;
- let vec[ty.t] tys;
+ let vec[ty::t] tys;
alt (ann) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
cx.fcx.lcx.ccx.sess.bug("no type annotation for path!");
fail;
}
- case (ast.ann_type(_, ?monoty_, ?tps, _)) {
+ case (ast::ann_type(_, ?monoty_, ?tps, _)) {
monoty = monoty_;
- tys = Option.get[vec[ty.t]](tps);
+ tys = option::get[vec[ty::t]](tps);
}
}
- if (Vec.len[ty.t](tys) != 0u) {
+ if (_vec::len[ty::t](tys) != 0u) {
auto bcx = lv.res.bcx;
let vec[ValueRef] tydescs = vec();
- for (ty.t t in tys) {
+ for (ty::t t in tys) {
// TODO: Doesn't always escape.
auto td = get_tydesc(bcx, t, true);
bcx = td.bcx;
- Vec.push[ValueRef](tydescs, td.val);
+ _vec::push[ValueRef](tydescs, td.val);
}
auto gen = rec( item_type = tpt._1,
tydescs = tydescs );
@@ -4176,18 +4184,18 @@ fn lval_generic_fn(&@block_ctxt cx,
ret lv;
}
-fn lookup_discriminant(&@local_ctxt lcx, &ast.def_id tid, &ast.def_id vid)
+fn lookup_discriminant(&@local_ctxt lcx, &ast::def_id tid, &ast::def_id vid)
-> ValueRef {
alt (lcx.ccx.discrims.find(vid)) {
case (none[ValueRef]) {
// It's an external discriminant that we haven't seen yet.
assert (lcx.ccx.sess.get_targ_crate_num() != vid._0);
- auto sym = creader.get_symbol(lcx.ccx.sess, vid);
- auto gvar = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(),
- Str.buf(sym));
- llvm.LLVMSetLinkage(gvar,
- lib.llvm.LLVMExternalLinkage as llvm.Linkage);
- llvm.LLVMSetGlobalConstant(gvar, True);
+ auto sym = creader::get_symbol(lcx.ccx.sess, vid);
+ auto gvar = llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(),
+ _str::buf(sym));
+ llvm::LLVMSetLinkage(gvar, lib::llvm::LLVMExternalLinkage
+ as llvm::Linkage);
+ llvm::LLVMSetGlobalConstant(gvar, True);
lcx.ccx.discrims.insert(vid, gvar);
ret gvar;
}
@@ -4195,9 +4203,9 @@ fn lookup_discriminant(&@local_ctxt lcx, &ast.def_id tid, &ast.def_id vid)
}
}
-fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
- alt (cx.fcx.lcx.ccx.tcx.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_arg(?did)) {
+fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
+ alt (cx.fcx.lcx.ccx.tcx.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_arg(?did)) {
alt (cx.fcx.llargs.find(did)) {
case (none[ValueRef]) {
assert (cx.fcx.llupvars.contains_key(did));
@@ -4208,7 +4216,7 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
}
- case (ast.def_local(?did)) {
+ case (ast::def_local(?did)) {
alt (cx.fcx.lllocals.find(did)) {
case (none[ValueRef]) {
assert (cx.fcx.llupvars.contains_key(did));
@@ -4219,32 +4227,32 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
}
- case (ast.def_binding(?did)) {
+ case (ast::def_binding(?did)) {
assert (cx.fcx.lllocals.contains_key(did));
ret lval_mem(cx, cx.fcx.lllocals.get(did));
}
- case (ast.def_obj_field(?did)) {
+ case (ast::def_obj_field(?did)) {
assert (cx.fcx.llobjfields.contains_key(did));
ret lval_mem(cx, cx.fcx.llobjfields.get(did));
}
- case (ast.def_fn(?did)) {
- auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_fn(?did)) {
+ auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann);
}
- case (ast.def_obj(?did)) {
- auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_obj(?did)) {
+ auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann);
}
- case (ast.def_variant(?tid, ?vid)) {
- auto v_tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_variant(?tid, ?vid)) {
+ auto v_tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, vid);
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, v_tyt._1)) {
- case (ty.ty_fn(_, _, _)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, v_tyt._1)) {
+ case (ty::ty_fn(_, _, _)) {
// N-ary variant.
ret lval_generic_fn(cx, v_tyt, vid, ann);
}
@@ -4259,7 +4267,7 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
auto lltagblob = alloc_result.val;
auto lltagty;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx,
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx,
tag_ty)) {
lltagty = T_opaque_tag(cx.fcx.lcx.ccx.tn);
} else {
@@ -4277,13 +4285,13 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
}
- case (ast.def_const(?did)) {
+ case (ast::def_const(?did)) {
// TODO: externals
assert (cx.fcx.lcx.ccx.consts.contains_key(did));
ret lval_mem(cx, cx.fcx.lcx.ccx.consts.get(did));
}
- case (ast.def_native_fn(?did)) {
- auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
+ case (ast::def_native_fn(?did)) {
+ auto tyt = ty::lookup_item_type(cx.fcx.lcx.ccx.sess,
cx.fcx.lcx.ccx.tcx,
cx.fcx.lcx.ccx.type_cache, did);
ret lval_generic_fn(cx, tyt, did, ann);
@@ -4294,40 +4302,40 @@ fn trans_path(&@block_ctxt cx, &ast.path p, &ast.ann ann) -> lval_result {
}
}
-fn trans_field(&@block_ctxt cx, &ast.span sp, ValueRef v, &ty.t t0,
- &ast.ident field, &ast.ann ann) -> lval_result {
+fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
+ &ast::ident field, &ast::ann ann) -> lval_result {
auto r = autoderef(cx, v, t0);
auto t = autoderefed_ty(cx.fcx.lcx.ccx, t0);
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_tup(_)) {
- let uint ix = ty.field_num(cx.fcx.lcx.ccx.sess, sp, field);
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_tup(_)) {
+ let uint ix = ty::field_num(cx.fcx.lcx.ccx.sess, sp, field);
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
ret lval_mem(v.bcx, v.val);
}
- case (ty.ty_rec(?fields)) {
- let uint ix = ty.field_idx(cx.fcx.lcx.ccx.sess, sp, field,
+ case (ty::ty_rec(?fields)) {
+ let uint ix = ty::field_idx(cx.fcx.lcx.ccx.sess, sp, field,
fields);
auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
ret lval_mem(v.bcx, v.val);
}
- case (ty.ty_obj(?methods)) {
- let uint ix = ty.method_idx(cx.fcx.lcx.ccx.sess, sp, field,
+ case (ty::ty_obj(?methods)) {
+ let uint ix = ty::method_idx(cx.fcx.lcx.ccx.sess, sp, field,
methods);
auto vtbl = r.bcx.build.GEP(r.val,
vec(C_int(0),
- C_int(abi.obj_field_vtbl)));
+ C_int(abi::obj_field_vtbl)));
vtbl = r.bcx.build.Load(vtbl);
// +1 because slot #0 contains the destructor
auto v = r.bcx.build.GEP(vtbl, vec(C_int(0),
C_int((ix + 1u) as int)));
auto lvo = lval_mem(r.bcx, v);
- let ty.t fn_ty = ty.method_ty_to_fn_ty(cx.fcx.lcx.ccx.tcx,
+ let ty::t fn_ty = ty::method_ty_to_fn_ty(cx.fcx.lcx.ccx.tcx,
methods.(ix));
ret rec(llobj = some[ValueRef](r.val),
- method_ty = some[ty.t](fn_ty)
+ method_ty = some[ty::t](fn_ty)
with lvo);
}
case (_) {cx.fcx.lcx.ccx.sess.unimpl("field variant in trans_field");}
@@ -4335,11 +4343,11 @@ fn trans_field(&@block_ctxt cx, &ast.span sp, ValueRef v, &ty.t t0,
fail;
}
-fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
- &@ast.expr idx, &ast.ann ann) -> lval_result {
+fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base,
+ &@ast::expr idx, &ast::ann ann) -> lval_result {
auto lv = trans_expr(cx, base);
- lv = autoderef(lv.bcx, lv.val, ty.expr_ty(cx.fcx.lcx.ccx.tcx, base));
+ lv = autoderef(lv.bcx, lv.val, ty::expr_ty(cx.fcx.lcx.ccx.tcx, base));
auto ix = trans_expr(lv.bcx, idx);
auto v = lv.val;
auto bcx = ix.bcx;
@@ -4364,10 +4372,10 @@ fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
auto scaled_ix = bcx.build.Mul(ix_val, unit_sz.val);
maybe_name_value(cx.fcx.lcx.ccx, scaled_ix, "scaled_ix");
- auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_fill)));
+ auto lim = bcx.build.GEP(v, vec(C_int(0), C_int(abi::vec_elt_fill)));
lim = bcx.build.Load(lim);
- auto bounds_check = bcx.build.ICmp(lib.llvm.LLVMIntULT,
+ auto bounds_check = bcx.build.ICmp(lib::llvm::LLVMIntULT,
scaled_ix, lim);
auto fail_cx = new_sub_block_ctxt(bcx, "fail");
@@ -4375,12 +4383,12 @@ fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
bcx.build.CondBr(bounds_check, next_cx.llbb, fail_cx.llbb);
// fail: bad bounds check.
- auto fail_res = trans_fail(fail_cx, some[common.span](sp),
+ auto fail_res = trans_fail(fail_cx, some[common::span](sp),
"bounds check");
- auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_data)));
+ auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi::vec_elt_data)));
auto elt;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
body = next_cx.build.PointerCast(body, T_ptr(T_array(T_i8(), 1u)));
elt = next_cx.build.GEP(body, vec(C_int(0), scaled_ix));
} else {
@@ -4398,29 +4406,29 @@ fn trans_index(&@block_ctxt cx, &ast.span sp, &@ast.expr base,
// represented as an alloca or heap, hence needs a 'load' to be used as an
// immediate).
-fn trans_lval(&@block_ctxt cx, &@ast.expr e) -> lval_result {
+fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
alt (e.node) {
- case (ast.expr_path(?p, ?ann)) {
+ case (ast::expr_path(?p, ?ann)) {
ret trans_path(cx, p, ann);
}
- case (ast.expr_field(?base, ?ident, ?ann)) {
+ case (ast::expr_field(?base, ?ident, ?ann)) {
auto r = trans_expr(cx, base);
- auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, base);
+ auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, base);
ret trans_field(r.bcx, e.span, r.val, t, ident, ann);
}
- case (ast.expr_index(?base, ?idx, ?ann)) {
+ case (ast::expr_index(?base, ?idx, ?ann)) {
ret trans_index(cx, e.span, base, idx, ann);
}
- case (ast.expr_unary(?unop, ?base, ?ann)) {
- assert (unop == ast.deref);
+ case (ast::expr_unary(?unop, ?base, ?ann)) {
+ assert (unop == ast::deref);
auto sub = trans_expr(cx, base);
auto val = sub.bcx.build.GEP(sub.val,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
ret lval_mem(sub.bcx, val);
}
- case (ast.expr_self_method(?ident, ?ann)) {
+ case (ast::expr_self_method(?ident, ?ann)) {
alt (cx.fcx.llself) {
case (some[self_vt](?s_vt)) {
auto r = s_vt.v;
@@ -4444,8 +4452,8 @@ fn trans_lval(&@block_ctxt cx, &@ast.expr e) -> lval_result {
fn int_cast(&@block_ctxt bcx, TypeRef lldsttype, TypeRef llsrctype,
ValueRef llsrc, bool signed) -> ValueRef {
- if (llvm.LLVMGetIntTypeWidth(lldsttype) >
- llvm.LLVMGetIntTypeWidth(llsrctype)) {
+ if (llvm::LLVMGetIntTypeWidth(lldsttype) >
+ llvm::LLVMGetIntTypeWidth(llsrctype)) {
if (signed) {
// Widening signed cast.
ret bcx.build.SExtOrBitCast(llsrc, lldsttype);
@@ -4458,21 +4466,21 @@ fn int_cast(&@block_ctxt bcx, TypeRef lldsttype, TypeRef llsrctype,
ret bcx.build.TruncOrBitCast(llsrc, lldsttype);
}
-fn trans_cast(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
+fn trans_cast(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
auto e_res = trans_expr(cx, e);
auto llsrctype = val_ty(e_res.val);
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto lldsttype = type_of(cx.fcx.lcx.ccx, t);
- if (!ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
+ if (!ty::type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
// TODO: native-to-native casts
- if (ty.type_is_native(cx.fcx.lcx.ccx.tcx,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
+ if (ty::type_is_native(cx.fcx.lcx.ccx.tcx,
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
- } else if (ty.type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
+ } else if (ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
e_res.val = e_res.bcx.build.IntToPtr(e_res.val, lldsttype);
} else {
e_res.val = int_cast(e_res.bcx, lldsttype, llsrctype, e_res.val,
- ty.type_is_signed(cx.fcx.lcx.ccx.tcx, t));
+ ty::type_is_signed(cx.fcx.lcx.ccx.tcx, t));
}
} else {
cx.fcx.lcx.ccx.sess.unimpl("fp cast");
@@ -4481,14 +4489,14 @@ fn trans_cast(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
}
fn trans_bind_thunk(&@local_ctxt cx,
- &ty.t incoming_fty,
- &ty.t outgoing_fty,
- &vec[Option.t[@ast.expr]] args,
- &ty.t closure_ty,
- &vec[ty.t] bound_tys,
+ &ty::t incoming_fty,
+ &ty::t outgoing_fty,
+ &vec[option::t[@ast::expr]] args,
+ &ty::t closure_ty,
+ &vec[ty::t] bound_tys,
uint ty_param_count) -> ValueRef {
// Construct a thunk-call with signature incoming_fty, and that copies
- // args forward into a call to outgoing_fty.
+ // args forward into a call to outgoing_fty:
let str s = mangle_name_by_seq(cx.ccx, cx.path, "thunk");
let TypeRef llthunk_ty = get_pair_fn_ty(type_of(cx.ccx, incoming_fty));
@@ -4500,24 +4508,24 @@ fn trans_bind_thunk(&@local_ctxt cx,
auto lltop = bcx.llbb;
auto llclosure_ptr_ty =
- type_of(cx.ccx, ty.mk_imm_box(cx.ccx.tcx, closure_ty));
+ type_of(cx.ccx, ty::mk_imm_box(cx.ccx.tcx, closure_ty));
auto llclosure = bcx.build.PointerCast(fcx.llenv, llclosure_ptr_ty);
auto lltarget = GEP_tup_like(bcx, closure_ty, llclosure,
vec(0,
- abi.box_rc_field_body,
- abi.closure_elt_target));
+ abi::box_rc_field_body,
+ abi::closure_elt_target));
bcx = lltarget.bcx;
auto lltargetclosure = bcx.build.GEP(lltarget.val,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
lltargetclosure = bcx.build.Load(lltargetclosure);
- auto outgoing_ret_ty = ty.ty_fn_ret(cx.ccx.tcx, outgoing_fty);
- auto outgoing_args = ty.ty_fn_args(cx.ccx.tcx, outgoing_fty);
+ auto outgoing_ret_ty = ty::ty_fn_ret(cx.ccx.tcx, outgoing_fty);
+ auto outgoing_args = ty::ty_fn_args(cx.ccx.tcx, outgoing_fty);
auto llretptr = fcx.llretptr;
- if (ty.type_has_dynamic_size(cx.ccx.tcx, outgoing_ret_ty)) {
+ if (ty::type_has_dynamic_size(cx.ccx.tcx, outgoing_ret_ty)) {
llretptr = bcx.build.PointerCast(llretptr, T_typaram_ptr(cx.ccx.tn));
}
@@ -4531,8 +4539,8 @@ fn trans_bind_thunk(&@local_ctxt cx,
auto lltyparam_ptr =
GEP_tup_like(bcx, closure_ty, llclosure,
vec(0,
- abi.box_rc_field_body,
- abi.closure_elt_ty_params,
+ abi::box_rc_field_body,
+ abi::closure_elt_ty_params,
(i as int)));
bcx = lltyparam_ptr.bcx;
auto td = bcx.build.Load(lltyparam_ptr.val);
@@ -4547,7 +4555,7 @@ fn trans_bind_thunk(&@local_ctxt cx,
let vec[TypeRef] llout_arg_tys =
type_of_explicit_args(cx.ccx, outgoing_args);
- for (Option.t[@ast.expr] arg in args) {
+ for (option::t[@ast::expr] arg in args) {
auto out_arg = outgoing_args.(outgoing_arg_index);
auto llout_arg_ty = llout_arg_tys.(outgoing_arg_index);
@@ -4555,19 +4563,19 @@ fn trans_bind_thunk(&@local_ctxt cx,
alt (arg) {
// Arg provided at binding time; thunk copies it from closure.
- case (some[@ast.expr](?e)) {
- auto e_ty = ty.expr_ty(cx.ccx.tcx, e);
+ case (some[@ast::expr](?e)) {
+ auto e_ty = ty::expr_ty(cx.ccx.tcx, e);
auto bound_arg =
GEP_tup_like(bcx, closure_ty, llclosure,
vec(0,
- abi.box_rc_field_body,
- abi.closure_elt_bindings,
+ abi::box_rc_field_body,
+ abi::closure_elt_bindings,
b));
bcx = bound_arg.bcx;
auto val = bound_arg.val;
- if (out_arg.mode == ty.mo_val) {
+ if (out_arg.mode == ty::mo_val) {
if (type_is_immediate(cx.ccx, e_ty)) {
val = bcx.build.Load(val);
bcx = take_ty(bcx, val, e_ty).bcx;
@@ -4575,9 +4583,9 @@ fn trans_bind_thunk(&@local_ctxt cx,
bcx = take_ty(bcx, val, e_ty).bcx;
val = bcx.build.Load(val);
}
- } else if (ty.type_contains_params(cx.ccx.tcx,
+ } else if (ty::type_contains_params(cx.ccx.tcx,
out_arg.ty)) {
- assert (out_arg.mode == ty.mo_alias);
+ assert (out_arg.mode == ty::mo_alias);
val = bcx.build.PointerCast(val, llout_arg_ty);
}
@@ -4586,11 +4594,11 @@ fn trans_bind_thunk(&@local_ctxt cx,
}
// Arg will be provided when the thunk is invoked.
- case (none[@ast.expr]) {
- let ValueRef passed_arg = llvm.LLVMGetParam(llthunk, a);
+ case (none[@ast::expr]) {
+ let ValueRef passed_arg = llvm::LLVMGetParam(llthunk, a);
- if (ty.type_contains_params(cx.ccx.tcx, out_arg.ty)) {
- assert (out_arg.mode == ty.mo_alias);
+ if (ty::type_contains_params(cx.ccx.tcx, out_arg.ty)) {
+ assert (out_arg.mode == ty::mo_alias);
passed_arg = bcx.build.PointerCast(passed_arg,
llout_arg_ty);
}
@@ -4606,12 +4614,12 @@ fn trans_bind_thunk(&@local_ctxt cx,
// FIXME: turn this call + ret into a tail call.
auto lltargetfn = bcx.build.GEP(lltarget.val,
vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
// Cast the outgoing function to the appropriate type (see the comments in
// trans_bind below for why this is necessary).
auto lltargetty = type_of_fn(bcx.fcx.lcx.ccx,
- ty.ty_fn_proto(bcx.fcx.lcx.ccx.tcx,
+ ty::ty_fn_proto(bcx.fcx.lcx.ccx.tcx,
outgoing_fty),
outgoing_args,
outgoing_ret_ty,
@@ -4628,31 +4636,31 @@ fn trans_bind_thunk(&@local_ctxt cx,
ret llthunk;
}
-fn trans_bind(&@block_ctxt cx, &@ast.expr f,
- &vec[Option.t[@ast.expr]] args,
- &ast.ann ann) -> result {
+fn trans_bind(&@block_ctxt cx, &@ast::expr f,
+ &vec[option::t[@ast::expr]] args,
+ &ast::ann ann) -> result {
auto f_res = trans_lval(cx, f);
if (f_res.is_mem) {
cx.fcx.lcx.ccx.sess.unimpl("re-binding existing function");
} else {
- let vec[@ast.expr] bound = vec();
+ let vec[@ast::expr] bound = vec();
- for (Option.t[@ast.expr] argopt in args) {
+ for (option::t[@ast::expr] argopt in args) {
alt (argopt) {
- case (none[@ast.expr]) {
+ case (none[@ast::expr]) {
}
- case (some[@ast.expr](?e)) {
- Vec.push[@ast.expr](bound, e);
+ case (some[@ast::expr](?e)) {
+ _vec::push[@ast::expr](bound, e);
}
}
}
// Figure out which tydescs we need to pass, if any.
- let ty.t outgoing_fty;
+ let ty::t outgoing_fty;
let vec[ValueRef] lltydescs;
alt (f_res.generic) {
case (none[generic_info]) {
- outgoing_fty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, f);
+ outgoing_fty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, f);
lltydescs = vec();
}
case (some[generic_info](?ginfo)) {
@@ -4660,9 +4668,9 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
lltydescs = ginfo.tydescs;
}
}
- auto ty_param_count = Vec.len[ValueRef](lltydescs);
+ auto ty_param_count = _vec::len[ValueRef](lltydescs);
- if (Vec.len[@ast.expr](bound) == 0u && ty_param_count == 0u) {
+ if (_vec::len[@ast::expr](bound) == 0u && ty_param_count == 0u) {
// Trivial 'binding': just return the static pair-ptr.
ret f_res.res;
} else {
@@ -4671,39 +4679,39 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto pair_v = alloca(bcx, pair_t);
// Translate the bound expressions.
- let vec[ty.t] bound_tys = vec();
+ let vec[ty::t] bound_tys = vec();
let vec[ValueRef] bound_vals = vec();
auto i = 0u;
- for (@ast.expr e in bound) {
+ for (@ast::expr e in bound) {
auto arg = trans_expr(bcx, e);
bcx = arg.bcx;
- Vec.push[ValueRef](bound_vals, arg.val);
- Vec.push[ty.t](bound_tys,
- ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+ _vec::push[ValueRef](bound_vals, arg.val);
+ _vec::push[ty::t](bound_tys,
+ ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
i += 1u;
}
// Synthesize a closure type.
- let ty.t bindings_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ let ty::t bindings_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
bound_tys);
// NB: keep this in sync with T_closure_ptr; we're making
- // a ty.t structure that has the same "shape" as the LLVM type
+ // a ty::t structure that has the same "shape" as the LLVM type
// it constructs.
- let ty.t tydesc_ty = ty.mk_type(cx.fcx.lcx.ccx.tcx);
+ let ty::t tydesc_ty = ty::mk_type(cx.fcx.lcx.ccx.tcx);
- let vec[ty.t] captured_tys =
- Vec.init_elt[ty.t](tydesc_ty, ty_param_count);
+ let vec[ty::t] captured_tys =
+ _vec::init_elt[ty::t](tydesc_ty, ty_param_count);
- let vec[ty.t] closure_tys =
+ let vec[ty::t] closure_tys =
vec(tydesc_ty,
outgoing_fty,
bindings_ty,
- ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys));
+ ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys));
- let ty.t closure_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ let ty::t closure_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
closure_tys);
auto r = trans_malloc_boxed(bcx, closure_ty);
@@ -4711,18 +4719,18 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
bcx = r.bcx;
auto rc = bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_refcnt)));
+ C_int(abi::box_rc_field_refcnt)));
auto closure =
bcx.build.GEP(box,
vec(C_int(0),
- C_int(abi.box_rc_field_body)));
+ C_int(abi::box_rc_field_body)));
bcx.build.Store(C_int(1), rc);
// Store bindings tydesc.
auto bound_tydesc =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_tydesc)));
+ C_int(abi::closure_elt_tydesc)));
auto bindings_tydesc = get_tydesc(bcx, bindings_ty, true);
bcx = bindings_tydesc.bcx;
bcx.build.Store(bindings_tydesc.val, bound_tydesc);
@@ -4734,9 +4742,9 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
// function has, which type_of() doesn't, as only we know which
// item the function refers to.
auto llfnty = type_of_fn(bcx.fcx.lcx.ccx,
- ty.ty_fn_proto(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
- ty.ty_fn_args(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
- ty.ty_fn_ret(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+ ty::ty_fn_proto(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+ ty::ty_fn_args(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+ ty::ty_fn_ret(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
ty_param_count);
auto llclosurety = T_ptr(T_fn_pair(bcx.fcx.lcx.ccx.tn, llfnty));
@@ -4744,7 +4752,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto bound_target =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_target)));
+ C_int(abi::closure_elt_target)));
auto src = bcx.build.Load(f_res.res.val);
bound_target = bcx.build.PointerCast(bound_target, llclosurety);
bcx.build.Store(src, bound_target);
@@ -4754,7 +4762,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto bindings =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_bindings)));
+ C_int(abi::closure_elt_bindings)));
for (ValueRef v in bound_vals) {
auto bound = bcx.build.GEP(bindings,
vec(C_int(0), C_int(i as int)));
@@ -4770,7 +4778,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
auto ty_params_slot =
bcx.build.GEP(closure,
vec(C_int(0),
- C_int(abi.closure_elt_ty_params)));
+ C_int(abi::closure_elt_ty_params)));
auto i = 0;
for (ValueRef td in ginfo.tydescs) {
auto ty_param_slot = bcx.build.GEP(ty_params_slot,
@@ -4787,9 +4795,9 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
// Make thunk and store thunk-ptr in outer pair's code slot.
auto pair_code = bcx.build.GEP(pair_v,
vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
- let ty.t pair_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
+ let ty::t pair_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
let ValueRef llthunk =
trans_bind_thunk(cx.fcx.lcx, pair_ty, outgoing_fty,
@@ -4801,7 +4809,7 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
// Store box ptr in outer pair's box slot.
auto pair_box = bcx.build.GEP(pair_v,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
bcx.build.Store
(bcx.build.PointerCast
(box,
@@ -4817,21 +4825,21 @@ fn trans_bind(&@block_ctxt cx, &@ast.expr f,
}
fn trans_arg_expr(&@block_ctxt cx,
- &ty.arg arg,
+ &ty::arg arg,
TypeRef lldestty0,
- &@ast.expr e) -> result {
+ &@ast::expr e) -> result {
auto val;
auto bcx = cx;
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
auto re = trans_expr(bcx, e);
val = re.val;
bcx = re.bcx;
- } else if (arg.mode == ty.mo_alias) {
+ } else if (arg.mode == ty::mo_alias) {
let lval_result lv;
- if (ty.is_lval(e)) {
+ if (ty::is_lval(e)) {
lv = trans_lval(bcx, e);
} else {
auto r = trans_expr(bcx, e);
@@ -4856,24 +4864,24 @@ fn trans_arg_expr(&@block_ctxt cx,
bcx = re.bcx;
}
- if (arg.mode != ty.mo_alias) {
+ if (arg.mode != ty::mo_alias) {
bcx = take_ty(bcx, val, e_ty).bcx;
}
- if (ty.type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) {
+ if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) {
auto lldestty = lldestty0;
- if (arg.mode == ty.mo_val) {
+ if (arg.mode == ty::mo_val) {
// FIXME: we'd prefer to use &&, but rustboot doesn't like it
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
lldestty = T_ptr(lldestty);
}
}
val = bcx.build.PointerCast(val, lldestty);
}
- if (arg.mode == ty.mo_val) {
+ if (arg.mode == ty::mo_val) {
// FIXME: we'd prefer to use &&, but rustboot doesn't like it
- if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
// Until here we've been treating structures by pointer;
// we are now passing it as an arg, so need to load it.
val = bcx.build.Load(val);
@@ -4891,21 +4899,21 @@ fn trans_arg_expr(&@block_ctxt cx,
fn trans_args(&@block_ctxt cx,
ValueRef llenv,
- &Option.t[ValueRef] llobj,
- &Option.t[generic_info] gen,
- &Option.t[ValueRef] lliterbody,
- &vec[@ast.expr] es,
- &ty.t fn_ty)
+ &option::t[ValueRef] llobj,
+ &option::t[generic_info] gen,
+ &option::t[ValueRef] lliterbody,
+ &vec[@ast::expr] es,
+ &ty::t fn_ty)
-> tup(@block_ctxt, vec[ValueRef], ValueRef) {
- let vec[ty.arg] args = ty.ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
+ let vec[ty::arg] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
let vec[ValueRef] llargs = vec();
let vec[ValueRef] lltydescs = vec();
let @block_ctxt bcx = cx;
// Arg 0: Output pointer.
- auto retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tcx, fn_ty);
+ auto retty = ty::ty_fn_ret(cx.fcx.lcx.ccx.tcx, fn_ty);
auto llretslot_res = alloc_ty(bcx, retty);
bcx = llretslot_res.bcx;
auto llretslot = llretslot_res.val;
@@ -4913,16 +4921,16 @@ fn trans_args(&@block_ctxt cx,
alt (gen) {
case (some[generic_info](?g)) {
lltydescs = g.tydescs;
- args = ty.ty_fn_args(cx.fcx.lcx.ccx.tcx, g.item_type);
- retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tcx, g.item_type);
+ args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, g.item_type);
+ retty = ty::ty_fn_ret(cx.fcx.lcx.ccx.tcx, g.item_type);
}
case (_) {
}
}
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, retty)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, retty)) {
llargs += vec(bcx.build.PointerCast
(llretslot, T_typaram_ptr(cx.fcx.lcx.ccx.tn)));
- } else if (ty.type_contains_params(cx.fcx.lcx.ccx.tcx, retty)) {
+ } else if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, retty)) {
// It's possible that the callee has some generic-ness somewhere in
// its return value -- say a method signature within an obj or a fn
// type deep in a structure -- which the caller has a concrete view
@@ -4936,7 +4944,7 @@ fn trans_args(&@block_ctxt cx,
}
- // Arg 1: Task pointer.
+ // Arg 1: task pointer.
llargs += vec(bcx.fcx.lltaskptr);
// Arg 2: Env (closure-bindings / self-obj)
@@ -4971,7 +4979,7 @@ fn trans_args(&@block_ctxt cx,
auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, args);
auto i = 0u;
- for (@ast.expr e in es) {
+ for (@ast::expr e in es) {
auto r = trans_arg_expr(bcx, args.(i), arg_tys.(i), e);
bcx = r.bcx;
llargs += vec(r.val);
@@ -4981,10 +4989,10 @@ fn trans_args(&@block_ctxt cx,
ret tup(bcx, llargs, llretslot);
}
-fn trans_call(&@block_ctxt cx, &@ast.expr f,
- &Option.t[ValueRef] lliterbody,
- &vec[@ast.expr] args,
- &ast.ann ann) -> result {
+fn trans_call(&@block_ctxt cx, &@ast::expr f,
+ &option::t[ValueRef] lliterbody,
+ &vec[@ast::expr] args,
+ &ast::ann ann) -> result {
// 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
@@ -5004,31 +5012,31 @@ fn trans_call(&@block_ctxt cx, &@ast.expr f,
auto bcx = f_res.res.bcx;
auto pair = faddr;
faddr = bcx.build.GEP(pair, vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
faddr = bcx.build.Load(faddr);
auto llclosure = bcx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
llenv = bcx.build.Load(llclosure);
}
}
- let ty.t fn_ty;
+ let ty::t fn_ty;
alt (f_res.method_ty) {
- case (some[ty.t](?meth)) {
+ case (some[ty::t](?meth)) {
// self-call
fn_ty = meth;
}
case (_) {
- fn_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, f);
+ fn_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, f);
}
}
- auto ret_ty = ty.ann_to_type(ann);
+ auto ret_ty = ty::ann_to_type(ann);
auto args_res = trans_args(f_res.res.bcx,
llenv, f_res.llobj,
f_res.generic,
@@ -5052,7 +5060,7 @@ fn trans_call(&@block_ctxt cx, &@ast.expr f,
alt (lliterbody) {
case (none[ValueRef]) {
- if (!ty.type_is_nil(cx.fcx.lcx.ccx.tcx, ret_ty)) {
+ if (!ty::type_is_nil(cx.fcx.lcx.ccx.tcx, ret_ty)) {
retval = load_if_immediate(bcx, llretslot, ret_ty);
// Retval doesn't correspond to anything really tangible in
// the frame, but it's a ref all the same, so we put a note
@@ -5070,8 +5078,8 @@ fn trans_call(&@block_ctxt cx, &@ast.expr f,
ret res(bcx, retval);
}
-fn trans_tup(&@block_ctxt cx, &vec[ast.elt] elts,
- &ast.ann ann) -> result {
+fn trans_tup(&@block_ctxt cx, &vec[ast::elt] elts,
+ &ast::ann ann) -> result {
auto bcx = cx;
auto t = node_ann_type(bcx.fcx.lcx.ccx, ann);
auto tup_res = alloc_ty(bcx, t);
@@ -5082,8 +5090,8 @@ fn trans_tup(&@block_ctxt cx, &vec[ast.elt] elts,
vec(clean(bind drop_ty(_, tup_val, t)));
let int i = 0;
- for (ast.elt e in elts) {
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e.expr);
+ for (ast::elt e in elts) {
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e.expr);
auto src_res = trans_expr(bcx, e.expr);
bcx = src_res.bcx;
auto dst_res = GEP_tup_like(bcx, t, tup_val, vec(0, i));
@@ -5094,12 +5102,12 @@ fn trans_tup(&@block_ctxt cx, &vec[ast.elt] elts,
ret res(bcx, tup_val);
}
-fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
- &ast.ann ann) -> result {
+fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args,
+ &ast::ann ann) -> result {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_ty = t;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_vec(?mt)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_vec(?mt)) {
unit_ty = mt.ty;
}
case (_) {
@@ -5110,7 +5118,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
auto bcx = cx;
auto unit_sz = size_of(bcx, unit_ty);
bcx = unit_sz.bcx;
- auto data_sz = bcx.build.Mul(C_int(Vec.len[@ast.expr](args) as int),
+ auto data_sz = bcx.build.Mul(C_int(_vec::len[@ast::expr](args) as int),
unit_sz.val);
// FIXME: pass tydesc properly.
@@ -5124,15 +5132,15 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
vec(clean(bind drop_ty(_, vec_val, t)));
auto body = bcx.build.GEP(vec_val, vec(C_int(0),
- C_int(abi.vec_elt_data)));
+ C_int(abi::vec_elt_data)));
auto pseudo_tup_ty =
- ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
- Vec.init_elt[ty.t](unit_ty,
- Vec.len[@ast.expr](args)));
+ ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+ _vec::init_elt[ty::t](unit_ty,
+ _vec::len[@ast::expr](args)));
let int i = 0;
- for (@ast.expr e in args) {
+ for (@ast::expr e in args) {
auto src_res = trans_expr(bcx, e);
bcx = src_res.bcx;
auto dst_res = GEP_tup_like(bcx, pseudo_tup_ty, body, vec(0, i));
@@ -5151,7 +5159,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
// (5) "src_res" is derived from "unit_ty", which is not behind a box.
auto dst_val;
- if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
+ if (!ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
auto llunit_ty = type_of(cx.fcx.lcx.ccx, unit_ty);
dst_val = bcx.build.PointerCast(dst_res.val, T_ptr(llunit_ty));
} else {
@@ -5162,14 +5170,14 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast.expr] args,
i += 1;
}
auto fill = bcx.build.GEP(vec_val,
- vec(C_int(0), C_int(abi.vec_elt_fill)));
+ vec(C_int(0), C_int(abi::vec_elt_fill)));
bcx.build.Store(data_sz, fill);
ret res(bcx, vec_val);
}
-fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
- &Option.t[@ast.expr] base, &ast.ann ann) -> result {
+fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields,
+ &option::t[@ast::expr] base, &ast::ann ann) -> result {
auto bcx = cx;
auto t = node_ann_type(bcx.fcx.lcx.ccx, ann);
@@ -5184,20 +5192,20 @@ fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
auto base_val = C_nil();
alt (base) {
- case (none[@ast.expr]) { }
- case (some[@ast.expr](?bexp)) {
+ case (none[@ast::expr]) { }
+ case (some[@ast::expr](?bexp)) {
auto base_res = trans_expr(bcx, bexp);
bcx = base_res.bcx;
base_val = base_res.val;
}
}
- let vec[ty.field] ty_fields = vec();
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_rec(?flds)) { ty_fields = flds; }
+ let vec[ty::field] ty_fields = vec();
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_rec(?flds)) { ty_fields = flds; }
}
- for (ty.field tf in ty_fields) {
+ for (ty::field tf in ty_fields) {
auto e_ty = tf.mt.ty;
auto dst_res = GEP_tup_like(bcx, t, rec_val, vec(0, i));
bcx = dst_res.bcx;
@@ -5205,8 +5213,8 @@ fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
auto expr_provided = false;
auto src_res = res(bcx, C_nil());
- for (ast.field f in fields) {
- if (Str.eq(f.ident, tf.ident)) {
+ for (ast::field f in fields) {
+ if (_str::eq(f.ident, tf.ident)) {
expr_provided = true;
src_res = trans_expr(bcx, f.expr);
}
@@ -5226,47 +5234,47 @@ fn trans_rec(&@block_ctxt cx, &vec[ast.field] fields,
-fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_expr(&@block_ctxt cx, &@ast::expr e) -> result {
alt (e.node) {
- case (ast.expr_lit(?lit, ?ann)) {
+ case (ast::expr_lit(?lit, ?ann)) {
ret res(cx, trans_lit(cx.fcx.lcx.ccx, *lit, ann));
}
- case (ast.expr_unary(?op, ?x, ?ann)) {
- if (op != ast.deref) {
+ case (ast::expr_unary(?op, ?x, ?ann)) {
+ if (op != ast::deref) {
ret trans_unary(cx, op, x, ann);
}
}
- case (ast.expr_binary(?op, ?x, ?y, _)) {
+ case (ast::expr_binary(?op, ?x, ?y, _)) {
ret trans_binary(cx, op, x, y);
}
- case (ast.expr_if(?cond, ?thn, ?els, _)) {
+ case (ast::expr_if(?cond, ?thn, ?els, _)) {
ret trans_if(cx, cond, thn, els);
}
- case (ast.expr_for(?decl, ?seq, ?body, _)) {
+ case (ast::expr_for(?decl, ?seq, ?body, _)) {
ret trans_for(cx, decl, seq, body);
}
- case (ast.expr_for_each(?decl, ?seq, ?body, _)) {
+ case (ast::expr_for_each(?decl, ?seq, ?body, _)) {
ret trans_for_each(cx, decl, seq, body);
}
- case (ast.expr_while(?cond, ?body, _)) {
+ case (ast::expr_while(?cond, ?body, _)) {
ret trans_while(cx, cond, body);
}
- case (ast.expr_do_while(?body, ?cond, _)) {
+ case (ast::expr_do_while(?body, ?cond, _)) {
ret trans_do_while(cx, body, cond);
}
- case (ast.expr_alt(?expr, ?arms, ?ann)) {
+ case (ast::expr_alt(?expr, ?arms, ?ann)) {
ret trans_alt(cx, expr, arms, ann);
}
- case (ast.expr_block(?blk, _)) {
+ case (ast::expr_block(?blk, _)) {
auto sub_cx = new_scope_block_ctxt(cx, "block-expr body");
auto next_cx = new_sub_block_ctxt(cx, "next");
auto sub = trans_block(sub_cx, blk);
@@ -5277,7 +5285,7 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
ret res(next_cx, sub.val);
}
- case (ast.expr_assign(?dst, ?src, ?ann)) {
+ case (ast::expr_assign(?dst, ?src, ?ann)) {
auto lhs_res = trans_lval(cx, dst);
assert (lhs_res.is_mem);
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
@@ -5287,14 +5295,14 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
lhs_res.res.val, rhs_res.val, t);
}
- case (ast.expr_assign_op(?op, ?dst, ?src, ?ann)) {
+ case (ast::expr_assign_op(?op, ?dst, ?src, ?ann)) {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto lhs_res = trans_lval(cx, dst);
assert (lhs_res.is_mem);
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
- if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
alt (op) {
- case (ast.add) {
+ case (ast::add) {
ret trans_vec_append(rhs_res.bcx, t,
lhs_res.res.val,
rhs_res.val);
@@ -5311,83 +5319,83 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
lhs_res.res.val, v.val, t);
}
- case (ast.expr_bind(?f, ?args, ?ann)) {
+ case (ast::expr_bind(?f, ?args, ?ann)) {
ret trans_bind(cx, f, args, ann);
}
- case (ast.expr_call(?f, ?args, ?ann)) {
+ case (ast::expr_call(?f, ?args, ?ann)) {
ret trans_call(cx, f, none[ValueRef], args, ann);
}
- case (ast.expr_cast(?e, _, ?ann)) {
+ case (ast::expr_cast(?e, _, ?ann)) {
ret trans_cast(cx, e, ann);
}
- case (ast.expr_vec(?args, _, ?ann)) {
+ case (ast::expr_vec(?args, _, ?ann)) {
ret trans_vec(cx, args, ann);
}
- case (ast.expr_tup(?args, ?ann)) {
+ case (ast::expr_tup(?args, ?ann)) {
ret trans_tup(cx, args, ann);
}
- case (ast.expr_rec(?args, ?base, ?ann)) {
+ case (ast::expr_rec(?args, ?base, ?ann)) {
ret trans_rec(cx, args, base, ann);
}
- case (ast.expr_ext(_, _, _, ?expanded, _)) {
+ case (ast::expr_ext(_, _, _, ?expanded, _)) {
ret trans_expr(cx, expanded);
}
- case (ast.expr_fail(_)) {
- ret trans_fail(cx, some[common.span](e.span), "explicit failure");
+ case (ast::expr_fail(_)) {
+ ret trans_fail(cx, some(e.span), "explicit failure");
}
- case (ast.expr_log(?lvl, ?a, _)) {
+ case (ast::expr_log(?lvl, ?a, _)) {
ret trans_log(lvl, cx, a);
}
- case (ast.expr_assert(?a, _)) {
+ case (ast::expr_assert(?a, _)) {
ret trans_check_expr(cx, a);
}
- case (ast.expr_check(?a, _)) {
+ case (ast::expr_check(?a, _)) {
ret trans_check_expr(cx, a);
}
- case (ast.expr_break(?a)) {
+ case (ast::expr_break(?a)) {
ret trans_break(cx);
}
- case (ast.expr_cont(?a)) {
+ case (ast::expr_cont(?a)) {
ret trans_cont(cx);
}
- case (ast.expr_ret(?e, _)) {
+ case (ast::expr_ret(?e, _)) {
ret trans_ret(cx, e);
}
- case (ast.expr_put(?e, _)) {
+ case (ast::expr_put(?e, _)) {
ret trans_put(cx, e);
}
- case (ast.expr_be(?e, _)) {
+ case (ast::expr_be(?e, _)) {
ret trans_be(cx, e);
}
- case (ast.expr_port(?ann)) {
+ case (ast::expr_port(?ann)) {
ret trans_port(cx, ann);
}
- case (ast.expr_chan(?e, ?ann)) {
+ case (ast::expr_chan(?e, ?ann)) {
ret trans_chan(cx, e, ann);
}
- case (ast.expr_send(?lhs, ?rhs, ?ann)) {
+ case (ast::expr_send(?lhs, ?rhs, ?ann)) {
ret trans_send(cx, lhs, rhs, ann);
}
- case (ast.expr_recv(?lhs, ?rhs, ?ann)) {
+ case (ast::expr_recv(?lhs, ?rhs, ?ann)) {
ret trans_recv(cx, lhs, rhs, ann);
}
@@ -5399,7 +5407,7 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
// lval cases fall through to trans_lval and then
// possibly load the result (if it's non-structural).
- auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
auto sub = trans_lval(cx, e);
ret res(sub.res.bcx, load_if_immediate(sub.res.bcx, sub.res.val, t));
}
@@ -5410,10 +5418,10 @@ fn trans_expr(&@block_ctxt cx, &@ast.expr e) -> result {
// pointer (or need one), perform load/store operations based on the
// immediate-ness of the type.
-fn type_is_immediate(&@crate_ctxt ccx, &ty.t t) -> bool {
- ret ty.type_is_scalar(ccx.tcx, t) ||
- ty.type_is_boxed(ccx.tcx, t) ||
- ty.type_is_native(ccx.tcx, t);
+fn type_is_immediate(&@crate_ctxt ccx, &ty::t t) -> bool {
+ ret ty::type_is_scalar(ccx.tcx, t) ||
+ ty::type_is_boxed(ccx.tcx, t) ||
+ ty::type_is_native(ccx.tcx, t);
}
fn do_spill(&@block_ctxt cx, ValueRef v) -> ValueRef {
@@ -5423,55 +5431,55 @@ fn do_spill(&@block_ctxt cx, ValueRef v) -> ValueRef {
ret llptr;
}
-fn spill_if_immediate(&@block_ctxt cx, ValueRef v, &ty.t t) -> ValueRef {
+fn spill_if_immediate(&@block_ctxt cx, ValueRef v, &ty::t t) -> ValueRef {
if (type_is_immediate(cx.fcx.lcx.ccx, t)) {
ret do_spill(cx, v);
}
ret v;
}
-fn load_if_immediate(&@block_ctxt cx, ValueRef v, &ty.t t) -> ValueRef {
+fn load_if_immediate(&@block_ctxt cx, ValueRef v, &ty::t t) -> ValueRef {
if (type_is_immediate(cx.fcx.lcx.ccx, t)) {
ret cx.build.Load(v);
}
ret v;
}
-fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_log(int lvl, &@block_ctxt cx, &@ast::expr e) -> result {
auto lcx = cx.fcx.lcx;
- auto modname = Str.connect(lcx.module_path, "::");
+ auto modname = _str::connect(lcx.module_path, "::");
auto global;
if (lcx.ccx.module_data.contains_key(modname)) {
global = lcx.ccx.module_data.get(modname);
} else {
- global = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(),
- Str.buf("_rust_mod_log_" + modname));
- llvm.LLVMSetGlobalConstant(global, False);
- llvm.LLVMSetInitializer(global, C_null(T_int()));
- llvm.LLVMSetLinkage(global, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ global = llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(),
+ _str::buf("_rust_mod_log_" + modname));
+ llvm::LLVMSetGlobalConstant(global, False);
+ llvm::LLVMSetInitializer(global, C_null(T_int()));
+ llvm::LLVMSetLinkage(global, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
lcx.ccx.module_data.insert(modname, global);
}
auto log_cx = new_scope_block_ctxt(cx, "log");
auto after_cx = new_sub_block_ctxt(cx, "after");
auto load = cx.build.Load(global);
- auto test = cx.build.ICmp(lib.llvm.LLVMIntSGE, load, C_int(lvl));
+ auto test = cx.build.ICmp(lib::llvm::LLVMIntSGE, load, C_int(lvl));
cx.build.CondBr(test, log_cx.llbb, after_cx.llbb);
auto sub = trans_expr(log_cx, e);
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
auto log_bcx = sub.bcx;
- if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ if (ty::type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
let TypeRef tr;
let bool is32bit = false;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
- case (ty.ty_machine(util.common.ty_f32)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ case (ty::ty_machine(util::common::ty_f32)) {
tr = T_f32();
is32bit = true;
}
- case (ty.ty_machine(util.common.ty_f64)) {
+ case (ty::ty_machine(util::common::ty_f64)) {
tr = T_f64();
}
case (_) {
@@ -5490,8 +5498,8 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
vec(log_bcx.fcx.lltaskptr, C_int(lvl), tmp));
}
} else {
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
- case (ty.ty_str) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
+ case (ty::ty_str) {
log_bcx.build.Call(log_bcx.fcx.lcx.ccx.upcalls.log_str,
vec(log_bcx.fcx.lltaskptr, C_int(lvl),
sub.val));
@@ -5513,12 +5521,12 @@ fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
ret res(after_cx, C_nil());
}
-fn trans_check_expr(&@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_check_expr(&@block_ctxt cx, &@ast::expr e) -> result {
auto cond_res = trans_expr(cx, e);
- auto expr_str = util.common.expr_to_str(e);
+ auto expr_str = util::common::expr_to_str(e);
auto fail_cx = new_sub_block_ctxt(cx, "fail");
- auto fail_res = trans_fail(fail_cx, some[common.span](e.span), expr_str);
+ auto fail_res = trans_fail(fail_cx, some[common::span](e.span), expr_str);
auto next_cx = new_sub_block_ctxt(cx, "next");
cond_res.bcx.build.CondBr(cond_res.val,
@@ -5527,18 +5535,18 @@ fn trans_check_expr(&@block_ctxt cx, &@ast.expr e) -> result {
ret res(next_cx, C_nil());
}
-fn trans_fail(&@block_ctxt cx, &Option.t[common.span] sp_opt, &str fail_str)
+fn trans_fail(&@block_ctxt cx, &option::t[common::span] sp_opt, &str fail_str)
-> result {
auto V_fail_str = C_cstr(cx.fcx.lcx.ccx, fail_str);
auto V_filename; auto V_line;
alt (sp_opt) {
- case (some[common.span](?sp)) {
+ case (some[common::span](?sp)) {
auto loc = cx.fcx.lcx.ccx.sess.lookup_pos(sp.lo);
V_filename = C_cstr(cx.fcx.lcx.ccx, loc.filename);
V_line = loc.line as int;
}
- case (none[common.span]) {
+ case (none[common::span]) {
V_filename = C_cstr(cx.fcx.lcx.ccx, "<runtime>");
V_line = 0;
}
@@ -5554,7 +5562,7 @@ fn trans_fail(&@block_ctxt cx, &Option.t[common.span] sp_opt, &str fail_str)
ret res(cx, C_nil());
}
-fn trans_put(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
+fn trans_put(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
auto llcallee = C_nil();
auto llenv = C_nil();
@@ -5564,11 +5572,11 @@ fn trans_put(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
cx.build.Store(lli, slot);
llcallee = cx.build.GEP(slot, vec(C_int(0),
- C_int(abi.fn_field_code)));
+ C_int(abi::fn_field_code)));
llcallee = cx.build.Load(llcallee);
llenv = cx.build.GEP(slot, vec(C_int(0),
- C_int(abi.fn_field_box)));
+ C_int(abi::fn_field_box)));
llenv = cx.build.Load(llenv);
}
}
@@ -5576,10 +5584,10 @@ fn trans_put(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
auto dummy_retslot = alloca(bcx, T_nil());
let vec[ValueRef] llargs = vec(dummy_retslot, cx.fcx.lltaskptr, llenv);
alt (e) {
- case (none[@ast.expr]) { }
- case (some[@ast.expr](?x)) {
- auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, x);
- auto arg = rec(mode=ty.mo_alias, ty=e_ty);
+ case (none[@ast::expr]) { }
+ case (some[@ast::expr](?x)) {
+ auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, x);
+ auto arg = rec(mode=ty::mo_alias, ty=e_ty);
auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, vec(arg));
auto r = trans_arg_expr(bcx, arg, arg_tys.(0), x);
bcx = r.bcx;
@@ -5602,7 +5610,7 @@ fn trans_break_cont(&@block_ctxt cx, bool to_end) -> result {
bcx.build.Br(_break.llbb);
} else {
alt (_cont) {
- case (Option.some[@block_ctxt](?_cont)) {
+ case (option::some[@block_ctxt](?_cont)) {
bcx.build.Br(_cont.llbb);
}
case (_) {
@@ -5632,26 +5640,26 @@ fn trans_cont(&@block_ctxt cx) -> result {
}
-fn trans_ret(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
+fn trans_ret(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
auto bcx = cx;
auto val = C_nil();
alt (e) {
- case (some[@ast.expr](?x)) {
- auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, x);
+ case (some[@ast::expr](?x)) {
+ auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, x);
auto r = trans_expr(cx, x);
bcx = r.bcx;
val = r.val;
bcx = copy_ty(bcx, INIT, cx.fcx.llretptr, val, t).bcx;
}
case (_) {
- auto t = llvm.LLVMGetElementType(val_ty(cx.fcx.llretptr));
- auto null = lib.llvm.llvm.LLVMConstNull(t);
+ auto t = llvm::LLVMGetElementType(val_ty(cx.fcx.llretptr));
+ auto null = lib::llvm::llvm::LLVMConstNull(t);
bcx.build.Store(null, cx.fcx.llretptr);
}
}
- // Run all cleanups and back out.
+ // run all cleanups and back out.
let bool more_cleanups = true;
auto cleanup_cx = cx;
while (more_cleanups) {
@@ -5670,20 +5678,20 @@ fn trans_ret(&@block_ctxt cx, &Option.t[@ast.expr] e) -> result {
ret res(new_sub_block_ctxt(bcx, "ret.unreachable"), C_nil());
}
-fn trans_be(&@block_ctxt cx, &@ast.expr e) -> result {
+fn trans_be(&@block_ctxt cx, &@ast::expr e) -> result {
// FIXME: This should be a typestate precondition
- assert (ast.is_call_expr(e));
+ assert (ast::is_call_expr(e));
// FIXME: Turn this into a real tail call once
// calling convention issues are settled
ret trans_ret(cx, some(e));
}
-fn trans_port(&@block_ctxt cx, &ast.ann ann) -> result {
+fn trans_port(&@block_ctxt cx, &ast::ann ann) -> result {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_ty;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
- case (ty.ty_port(?t)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
+ case (ty::ty_port(?t)) {
unit_ty = t;
}
case (_) {
@@ -5707,7 +5715,7 @@ fn trans_port(&@block_ctxt cx, &ast.ann ann) -> result {
ret res(bcx, port_val);
}
-fn trans_chan(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
+fn trans_chan(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
auto bcx = cx;
auto prt = trans_expr(bcx, e);
@@ -5726,8 +5734,8 @@ fn trans_chan(&@block_ctxt cx, &@ast.expr e, &ast.ann ann) -> result {
ret res(bcx, chan_val);
}
-fn trans_send(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
- &ast.ann ann) -> result {
+fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
+ &ast::ann ann) -> result {
auto bcx = cx;
auto chn = trans_expr(bcx, lhs);
@@ -5737,8 +5745,8 @@ fn trans_send(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
auto chan_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
auto unit_ty;
- alt (ty.struct(cx.fcx.lcx.ccx.tcx, chan_ty)) {
- case (ty.ty_chan(?t)) {
+ alt (ty::struct(cx.fcx.lcx.ccx.tcx, chan_ty)) {
+ case (ty::ty_chan(?t)) {
unit_ty = t;
}
case (_) {
@@ -5763,8 +5771,8 @@ fn trans_send(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
ret res(bcx, chn.val);
}
-fn trans_recv(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
- &ast.ann ann) -> result {
+fn trans_recv(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
+ &ast::ann ann) -> result {
auto bcx = cx;
auto data = trans_lval(bcx, lhs);
@@ -5776,8 +5784,8 @@ fn trans_recv(&@block_ctxt cx, &@ast.expr lhs, &@ast.expr rhs,
ret recv_val(bcx, data.res.val, rhs, unit_ty, DROP_EXISTING);
}
-fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast.expr rhs,
- &ty.t unit_ty, copy_action action) -> result {
+fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs,
+ &ty::t unit_ty, copy_action action) -> result {
auto bcx = cx;
auto prt = trans_expr(bcx, rhs);
@@ -5797,7 +5805,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast.expr rhs,
ret res(bcx, lhs);
}
-fn init_local(&@block_ctxt cx, &@ast.local local) -> result {
+fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
// Make a note to drop this slot on the way out.
assert (cx.fcx.lllocals.contains_key(local.id));
@@ -5809,13 +5817,13 @@ fn init_local(&@block_ctxt cx, &@ast.local local) -> result {
vec(clean(bind drop_slot(_, llptr, ty)));
alt (local.init) {
- case (some[ast.initializer](?init)) {
+ case (some[ast::initializer](?init)) {
alt (init.op) {
- case (ast.init_assign) {
+ case (ast::init_assign) {
auto sub = trans_expr(bcx, init.expr);
bcx = copy_ty(sub.bcx, INIT, llptr, sub.val, ty).bcx;
}
- case (ast.init_recv) {
+ case (ast::init_recv) {
bcx = recv_val(bcx, llptr, init.expr, ty, INIT).bcx;
}
}
@@ -5827,34 +5835,34 @@ fn init_local(&@block_ctxt cx, &@ast.local local) -> result {
ret res(bcx, llptr);
}
-fn zero_alloca(&@block_ctxt cx, ValueRef llptr, ty.t t) -> result {
+fn zero_alloca(&@block_ctxt cx, ValueRef llptr, ty::t t) -> result {
auto bcx = cx;
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
auto llsz = size_of(bcx, t);
auto llalign = align_of(llsz.bcx, t);
bcx = call_bzero(llalign.bcx, llptr,
llsz.val, llalign.val).bcx;
} else {
auto llty = type_of(bcx.fcx.lcx.ccx, t);
- auto null = lib.llvm.llvm.LLVMConstNull(llty);
+ auto null = lib::llvm::llvm::LLVMConstNull(llty);
bcx.build.Store(null, llptr);
}
ret res(bcx, llptr);
}
-fn trans_stmt(&@block_ctxt cx, &ast.stmt s) -> result {
+fn trans_stmt(&@block_ctxt cx, &ast::stmt s) -> result {
auto bcx = cx;
alt (s.node) {
- case (ast.stmt_expr(?e,_)) {
+ case (ast::stmt_expr(?e,_)) {
bcx = trans_expr(cx, e).bcx;
}
- case (ast.stmt_decl(?d,_)) {
+ case (ast::stmt_decl(?d,_)) {
alt (d.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
bcx = init_local(bcx, local).bcx;
}
- case (ast.decl_item(?i)) {
+ case (ast::decl_item(?i)) {
trans_item(cx.fcx.lcx, *i);
}
}
@@ -5867,8 +5875,8 @@ fn trans_stmt(&@block_ctxt cx, &ast.stmt s) -> result {
}
fn new_builder(BasicBlockRef llbb) -> builder {
- let BuilderRef llbuild = llvm.LLVMCreateBuilder();
- llvm.LLVMPositionBuilderAtEnd(llbuild, llbb);
+ let BuilderRef llbuild = llvm::LLVMCreateBuilder();
+ llvm::LLVMPositionBuilderAtEnd(llbuild, llbb);
ret builder(llbuild, @mutable false);
}
@@ -5878,11 +5886,11 @@ fn new_block_ctxt(&@fn_ctxt cx, &block_parent parent,
block_kind kind,
&str name) -> @block_ctxt {
let vec[cleanup] cleanups = vec();
- auto s = Str.buf("");
+ auto s = _str::buf("");
if (cx.lcx.ccx.sess.get_opts().save_temps) {
- s = Str.buf(cx.lcx.ccx.names.next(name));
+ s = _str::buf(cx.lcx.ccx.names.next(name));
}
- let BasicBlockRef llbb = llvm.LLVMAppendBasicBlock(cx.llfn, s);
+ let BasicBlockRef llbb = llvm::LLVMAppendBasicBlock(cx.llfn, s);
ret @rec(llbb=llbb,
build=new_builder(llbb),
parent=parent,
@@ -5902,7 +5910,7 @@ fn new_scope_block_ctxt(&@block_ctxt bcx, &str n) -> @block_ctxt {
ret new_block_ctxt(bcx.fcx, parent_some(bcx), SCOPE_BLOCK, n);
}
-fn new_loop_scope_block_ctxt(&@block_ctxt bcx, &Option.t[@block_ctxt] _cont,
+fn new_loop_scope_block_ctxt(&@block_ctxt bcx, &option::t[@block_ctxt] _cont,
&@block_ctxt _break, &str n) -> @block_ctxt {
ret new_block_ctxt(bcx.fcx, parent_some(bcx),
LOOP_SCOPE_BLOCK(_cont, _break), n);
@@ -5925,10 +5933,10 @@ fn trans_block_cleanups(&@block_ctxt cx,
auto bcx = cx;
if (cleanup_cx.kind == NON_SCOPE_BLOCK) {
- assert (Vec.len[cleanup](cleanup_cx.cleanups) == 0u);
+ assert (_vec::len[cleanup](cleanup_cx.cleanups) == 0u);
}
- auto i = Vec.len[cleanup](cleanup_cx.cleanups);
+ auto i = _vec::len[cleanup](cleanup_cx.cleanups);
while (i > 0u) {
i -= 1u;
auto c = cleanup_cx.cleanups.(i);
@@ -5941,14 +5949,14 @@ fn trans_block_cleanups(&@block_ctxt cx,
ret bcx;
}
-iter block_locals(&ast.block b) -> @ast.local {
+iter block_locals(&ast::block b) -> @ast::local {
// FIXME: putting from inside an iter block doesn't work, so we can't
// use the index here.
- for (@ast.stmt s in b.node.stmts) {
+ for (@ast::stmt s in b.node.stmts) {
alt (s.node) {
- case (ast.stmt_decl(?d,_)) {
+ case (ast::stmt_decl(?d,_)) {
alt (d.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
put local;
}
case (_) { /* fall through */ }
@@ -5969,9 +5977,9 @@ fn llallocas_block_ctxt(&@fn_ctxt fcx) -> @block_ctxt {
fcx=fcx);
}
-fn alloc_ty(&@block_ctxt cx, &ty.t t) -> result {
+fn alloc_ty(&@block_ctxt cx, &ty::t t) -> result {
auto val = C_int(0);
- if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
// NB: we have to run this particular 'size_of' in a
// block_ctxt built on the llallocas block for the fn,
@@ -5993,22 +6001,22 @@ fn alloc_ty(&@block_ctxt cx, &ty.t t) -> result {
ret res(cx, val);
}
-fn alloc_local(&@block_ctxt cx, &@ast.local local) -> result {
+fn alloc_local(&@block_ctxt cx, &@ast::local local) -> result {
auto t = node_ann_type(cx.fcx.lcx.ccx, local.ann);
auto r = alloc_ty(cx, t);
r.bcx.fcx.lllocals.insert(local.id, r.val);
ret r;
}
-fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
+fn trans_block(&@block_ctxt cx, &ast::block b) -> result {
auto bcx = cx;
- for each (@ast.local local in block_locals(b)) {
+ for each (@ast::local local in block_locals(b)) {
bcx = alloc_local(bcx, local).bcx;
}
auto r = res(bcx, C_nil());
- for (@ast.stmt s in b.node.stmts) {
+ for (@ast::stmt s in b.node.stmts) {
r = trans_stmt(bcx, *s);
bcx = r.bcx;
// If we hit a terminator, control won't go any further so
@@ -6019,15 +6027,15 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
}
alt (b.node.expr) {
- case (some[@ast.expr](?e)) {
+ case (some[@ast::expr](?e)) {
r = trans_expr(bcx, e);
bcx = r.bcx;
if (is_terminated(bcx)) {
ret r;
} else {
- auto r_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
- if (!ty.type_is_nil(cx.fcx.lcx.ccx.tcx, r_ty)) {
+ auto r_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
+ if (!ty::type_is_nil(cx.fcx.lcx.ccx.tcx, r_ty)) {
// The value resulting from the block gets copied into an
// alloca created in an outer scope and its refcount
// bumped so that it can escape this block. This means
@@ -6053,7 +6061,7 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
fn drop_hoisted_ty(&@block_ctxt cx,
ValueRef alloca_val,
- ty.t t) -> result {
+ ty::t t) -> result {
auto reg_val = load_if_immediate(cx,
alloca_val, t);
ret drop_ty(cx, reg_val, t);
@@ -6065,7 +6073,7 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
}
}
}
- case (none[@ast.expr]) {
+ case (none[@ast::expr]) {
r = res(bcx, C_nil());
}
}
@@ -6076,8 +6084,8 @@ fn trans_block(&@block_ctxt cx, &ast.block b) -> result {
fn new_local_ctxt(&@crate_ctxt ccx) -> @local_ctxt {
let vec[str] pth = vec();
- let vec[ast.ty_param] obj_typarams = vec();
- let vec[ast.obj_field] obj_fields = vec();
+ let vec[ast::ty_param] obj_typarams = vec();
+ let vec[ast::obj_field] obj_fields = vec();
ret @rec(path=pth,
module_path=vec(crate_name(ccx, "main")),
obj_typarams = obj_typarams,
@@ -6089,9 +6097,9 @@ fn new_local_ctxt(&@crate_ctxt ccx) -> @local_ctxt {
// tydescs.
fn mk_standard_basic_blocks(ValueRef llfn) ->
tup(BasicBlockRef, BasicBlockRef, BasicBlockRef) {
- ret tup(llvm.LLVMAppendBasicBlock(llfn, Str.buf("allocas")),
- llvm.LLVMAppendBasicBlock(llfn, Str.buf("copy_args")),
- llvm.LLVMAppendBasicBlock(llfn, Str.buf("derived_tydescs")));
+ ret tup(llvm::LLVMAppendBasicBlock(llfn, _str::buf("allocas")),
+ llvm::LLVMAppendBasicBlock(llfn, _str::buf("copy_args")),
+ llvm::LLVMAppendBasicBlock(llfn, _str::buf("derived_tydescs")));
}
// NB: must keep 4 fns in sync:
@@ -6104,17 +6112,17 @@ fn mk_standard_basic_blocks(ValueRef llfn) ->
fn new_fn_ctxt(@local_ctxt cx,
ValueRef llfndecl) -> @fn_ctxt {
- let ValueRef llretptr = llvm.LLVMGetParam(llfndecl, 0u);
- let ValueRef lltaskptr = llvm.LLVMGetParam(llfndecl, 1u);
- let ValueRef llenv = llvm.LLVMGetParam(llfndecl, 2u);
+ let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u);
+ let ValueRef lltaskptr = llvm::LLVMGetParam(llfndecl, 1u);
+ let ValueRef llenv = llvm::LLVMGetParam(llfndecl, 2u);
- let hashmap[ast.def_id, ValueRef] llargs = new_def_hash[ValueRef]();
- let hashmap[ast.def_id, ValueRef] llobjfields = new_def_hash[ValueRef]();
- let hashmap[ast.def_id, ValueRef] lllocals = new_def_hash[ValueRef]();
- let hashmap[ast.def_id, ValueRef] llupvars = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] llargs = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] llobjfields = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] lllocals = new_def_hash[ValueRef]();
+ let hashmap[ast::def_id, ValueRef] llupvars = new_def_hash[ValueRef]();
auto 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);
auto llbbs = mk_standard_basic_blocks(llfndecl);
@@ -6131,7 +6139,7 @@ fn new_fn_ctxt(@local_ctxt cx,
llobjfields=llobjfields,
lllocals=lllocals,
llupvars=llupvars,
- mutable lltydescs=Vec.empty[ValueRef](),
+ mutable lltydescs=_vec::empty[ValueRef](),
derived_tydescs=derived_tydescs,
lcx=cx);
}
@@ -6144,22 +6152,22 @@ fn new_fn_ctxt(@local_ctxt cx,
// - trans_args
fn create_llargs_for_fn_args(&@fn_ctxt cx,
- ast.proto proto,
- Option.t[tup(TypeRef, ty.t)] ty_self,
- ty.t ret_ty,
- &vec[ast.arg] args,
- &vec[ast.ty_param] ty_params) {
+ ast::proto proto,
+ option::t[tup(TypeRef, ty::t)] ty_self,
+ ty::t ret_ty,
+ &vec[ast::arg] args,
+ &vec[ast::ty_param] ty_params) {
auto arg_n = 3u;
alt (ty_self) {
- case (some[tup(TypeRef, ty.t)](?tt)) {
+ case (some[tup(TypeRef, ty::t)](?tt)) {
cx.llself = some[self_vt](rec(v = cx.llenv, t = tt._1));
}
- case (none[tup(TypeRef, ty.t)]) {
+ case (none[tup(TypeRef, ty::t)]) {
auto i = 0u;
- for (ast.ty_param tp in ty_params) {
- auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
+ for (ast::ty_param tp in ty_params) {
+ auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
cx.lltydescs += vec(llarg);
arg_n += 1u;
@@ -6168,15 +6176,15 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
}
}
- if (proto == ast.proto_iter) {
- auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
+ if (proto == ast::proto_iter) {
+ auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
cx.lliterbody = some[ValueRef](llarg);
arg_n += 1u;
}
- for (ast.arg arg in args) {
- auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
+ for (ast::arg arg in args) {
+ auto llarg = llvm::LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
cx.llargs.insert(arg.id, llarg);
arg_n += 1u;
@@ -6188,14 +6196,14 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
// were passed and whatnot. Apparently mem2reg will mop up.
fn copy_any_self_to_alloca(@fn_ctxt fcx,
- Option.t[tup(TypeRef, ty.t)] ty_self) {
+ option::t[tup(TypeRef, ty::t)] ty_self) {
auto bcx = llallocas_block_ctxt(fcx);
alt (fcx.llself) {
case (some[self_vt](?s_vt)) {
alt (ty_self) {
- case (some[tup(TypeRef, ty.t)](?tt)) {
+ case (some[tup(TypeRef, ty::t)](?tt)) {
auto a = alloca(bcx, tt._0);
bcx.build.Store(s_vt.v, a);
fcx.llself = some[self_vt](rec(v = a, t = s_vt.t));
@@ -6209,14 +6217,14 @@ fn copy_any_self_to_alloca(@fn_ctxt fcx,
fn copy_args_to_allocas(@fn_ctxt fcx,
- vec[ast.arg] args,
- vec[ty.arg] arg_tys) {
+ vec[ast::arg] args,
+ vec[ty::arg] arg_tys) {
auto bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
let uint arg_n = 0u;
- for (ast.arg aarg in args) {
- if (aarg.mode != ast.alias) {
+ for (ast::arg aarg in args) {
+ if (aarg.mode != ast::alias) {
auto arg_t = type_of_arg(bcx.fcx.lcx, arg_tys.(arg_n));
auto a = alloca(bcx, arg_t);
auto argval = bcx.fcx.llargs.get(aarg.id);
@@ -6230,11 +6238,11 @@ fn copy_args_to_allocas(@fn_ctxt fcx,
}
fn add_cleanups_for_args(&@block_ctxt bcx,
- vec[ast.arg] args,
- vec[ty.arg] arg_tys) {
+ vec[ast::arg] args,
+ vec[ty::arg] arg_tys) {
let uint arg_n = 0u;
- for (ast.arg aarg in args) {
- if (aarg.mode != ast.alias) {
+ for (ast::arg aarg in args) {
+ if (aarg.mode != ast::alias) {
auto argval = bcx.fcx.llargs.get(aarg.id);
find_scope_cx(bcx).cleanups +=
vec(clean(bind drop_slot(_, argval, arg_tys.(arg_n).ty)));
@@ -6245,22 +6253,22 @@ fn add_cleanups_for_args(&@block_ctxt bcx,
fn is_terminated(&@block_ctxt cx) -> bool {
- auto inst = llvm.LLVMGetLastInstruction(cx.llbb);
- ret llvm.LLVMIsATerminatorInst(inst) as int != 0;
+ auto inst = llvm::LLVMGetLastInstruction(cx.llbb);
+ ret llvm::LLVMIsATerminatorInst(inst) as int != 0;
}
-fn arg_tys_of_fn(&@crate_ctxt ccx, ast.ann ann) -> vec[ty.arg] {
- alt (ty.struct(ccx.tcx, ty.ann_to_type(ann))) {
- case (ty.ty_fn(_, ?arg_tys, _)) {
+fn arg_tys_of_fn(&@crate_ctxt ccx, ast::ann ann) -> vec[ty::arg] {
+ alt (ty::struct(ccx.tcx, ty::ann_to_type(ann))) {
+ case (ty::ty_fn(_, ?arg_tys, _)) {
ret arg_tys;
}
}
fail;
}
-fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty.t t) -> ty.t {
- alt (ty.struct(ccx.tcx, t)) {
- case (ty.ty_fn(_, _, ?ret_ty)) {
+fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
+ alt (ty::struct(ccx.tcx, t)) {
+ case (ty::ty_fn(_, _, ?ret_ty)) {
ret ret_ty;
}
}
@@ -6268,30 +6276,30 @@ fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty.t t) -> ty.t {
}
-fn ret_ty_of_fn(&@crate_ctxt ccx, ast.ann ann) -> ty.t {
- ret ret_ty_of_fn_ty(ccx, ty.ann_to_type(ann));
+fn ret_ty_of_fn(&@crate_ctxt ccx, ast::ann ann) -> ty::t {
+ ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ann));
}
fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
auto bcx = llallocas_block_ctxt(fcx);
- let vec[ty.t] field_tys = vec();
+ let vec[ty::t] field_tys = vec();
- for (ast.obj_field f in bcx.fcx.lcx.obj_fields) {
+ for (ast::obj_field f in bcx.fcx.lcx.obj_fields) {
field_tys += vec(node_ann_type(bcx.fcx.lcx.ccx, f.ann));
}
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
// its magic.
- auto fields_tup_ty = ty.mk_imm_tup(fcx.lcx.ccx.tcx, field_tys);
+ auto fields_tup_ty = ty::mk_imm_tup(fcx.lcx.ccx.tcx, field_tys);
- auto n_typarams = Vec.len[ast.ty_param](bcx.fcx.lcx.obj_typarams);
+ auto n_typarams = _vec::len[ast::ty_param](bcx.fcx.lcx.obj_typarams);
let TypeRef llobj_box_ty = T_obj_ptr(bcx.fcx.lcx.ccx.tn, n_typarams);
auto box_cell =
bcx.build.GEP(llself.v,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
auto box_ptr = bcx.build.Load(box_cell);
@@ -6299,18 +6307,18 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
auto obj_typarams = bcx.build.GEP(box_ptr,
vec(C_int(0),
- C_int(abi.box_rc_field_body),
- C_int(abi.obj_body_elt_typarams)));
+ C_int(abi::box_rc_field_body),
+ C_int(abi::obj_body_elt_typarams)));
// The object fields immediately follow the type parameters, so we skip
// over them to get the pointer.
auto obj_fields = bcx.build.Add(vp2i(bcx, obj_typarams),
- llsize_of(llvm.LLVMGetElementType(val_ty(obj_typarams))));
+ llsize_of(llvm::LLVMGetElementType(val_ty(obj_typarams))));
// If we can (i.e. the type is statically sized), then cast the resulting
// fields pointer to the appropriate LLVM type. If not, just leave it as
// i8 *.
- if (!ty.type_has_dynamic_size(fcx.lcx.ccx.tcx, fields_tup_ty)) {
+ if (!ty::type_has_dynamic_size(fcx.lcx.ccx.tcx, fields_tup_ty)) {
auto llfields_ty = type_of(fcx.lcx.ccx, fields_tup_ty);
obj_fields = vi2p(bcx, obj_fields, T_ptr(llfields_ty));
} else {
@@ -6320,7 +6328,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
let int i = 0;
- for (ast.ty_param p in fcx.lcx.obj_typarams) {
+ for (ast::ty_param p in fcx.lcx.obj_typarams) {
let ValueRef lltyparam = bcx.build.GEP(obj_typarams,
vec(C_int(0),
C_int(i)));
@@ -6330,7 +6338,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
}
i = 0;
- for (ast.obj_field f in fcx.lcx.obj_fields) {
+ for (ast::obj_field f in fcx.lcx.obj_fields) {
auto rslt = GEP_tup_like(bcx, fields_tup_ty, obj_fields, vec(0, i));
bcx = llallocas_block_ctxt(fcx);
auto llfield = rslt.val;
@@ -6348,9 +6356,9 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) {
new_builder(fcx.llderivedtydescs).Br(lltop);
}
-fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
- Option.t[tup(TypeRef, ty.t)] ty_self,
- &vec[ast.ty_param] ty_params, &ast.ann ann) {
+fn trans_fn(@local_ctxt cx, &ast::_fn f, ast::def_id fid,
+ option::t[tup(TypeRef, ty::t)] ty_self,
+ &vec[ast::ty_param] ty_params, &ast::ann ann) {
auto llfndecl = cx.ccx.item_ids.get(fid);
auto fcx = new_fn_ctxt(cx, llfndecl);
@@ -6388,35 +6396,35 @@ fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
fn trans_vtbl(@local_ctxt cx,
TypeRef llself_ty,
- ty.t self_ty,
- &ast._obj ob,
- &vec[ast.ty_param] ty_params) -> ValueRef {
+ ty::t self_ty,
+ &ast::_obj ob,
+ &vec[ast::ty_param] ty_params) -> ValueRef {
auto dtor = C_null(T_ptr(T_i8()));
alt (ob.dtor) {
- case (some[@ast.method](?d)) {
+ case (some[@ast::method](?d)) {
auto dtor_1 = trans_dtor(cx, llself_ty, self_ty, ty_params, d);
- dtor = llvm.LLVMConstBitCast(dtor_1, val_ty(dtor));
+ dtor = llvm::LLVMConstBitCast(dtor_1, val_ty(dtor));
}
- case (none[@ast.method]) {}
+ case (none[@ast::method]) {}
}
let vec[ValueRef] methods = vec(dtor);
- fn meth_lteq(&@ast.method a, &@ast.method b) -> bool {
- ret Str.lteq(a.node.ident, b.node.ident);
+ fn meth_lteq(&@ast::method a, &@ast::method b) -> bool {
+ ret _str::lteq(a.node.ident, b.node.ident);
}
- auto meths = std.Sort.merge_sort[@ast.method](bind meth_lteq(_,_),
+ auto meths = std::sort::merge_sort[@ast::method](bind meth_lteq(_,_),
ob.methods);
- for (@ast.method m in meths) {
+ for (@ast::method m in meths) {
auto llfnty = T_nil();
- alt (ty.struct(cx.ccx.tcx, node_ann_type(cx.ccx, m.node.ann))) {
- case (ty.ty_fn(?proto, ?inputs, ?output)) {
+ alt (ty::struct(cx.ccx.tcx, node_ann_type(cx.ccx, m.node.ann))) {
+ case (ty::ty_fn(?proto, ?inputs, ?output)) {
llfnty = type_of_fn_full(cx.ccx, proto,
some[TypeRef](llself_ty),
inputs, output,
- Vec.len[ast.ty_param](ty_params));
+ _vec::len[ast::ty_param](ty_params));
}
}
@@ -6428,26 +6436,26 @@ fn trans_vtbl(@local_ctxt cx,
cx.ccx.item_symbols.insert(m.node.id, s);
trans_fn(mcx, m.node.meth, m.node.id,
- some[tup(TypeRef, ty.t)](tup(llself_ty, self_ty)),
+ some[tup(TypeRef, ty::t)](tup(llself_ty, self_ty)),
ty_params, m.node.ann);
methods += vec(llfn);
}
auto vtbl = C_struct(methods);
auto vtbl_name = mangle_name_by_seq(cx.ccx, cx.path, "vtbl");
- auto gvar = llvm.LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl),
- Str.buf(vtbl_name));
- llvm.LLVMSetInitializer(gvar, vtbl);
- llvm.LLVMSetGlobalConstant(gvar, True);
- llvm.LLVMSetLinkage(gvar, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ auto gvar = llvm::LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl),
+ _str::buf(vtbl_name));
+ llvm::LLVMSetInitializer(gvar, vtbl);
+ llvm::LLVMSetGlobalConstant(gvar, True);
+ llvm::LLVMSetLinkage(gvar, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ret gvar;
}
fn trans_dtor(@local_ctxt cx,
TypeRef llself_ty,
- ty.t self_ty,
- &vec[ast.ty_param] ty_params,
- &@ast.method dtor) -> ValueRef {
+ ty::t self_ty,
+ &vec[ast::ty_param] ty_params,
+ &@ast::method dtor) -> ValueRef {
auto llfnty = T_dtor(cx.ccx, llself_ty);
let @local_ctxt dcx = extend_path(cx, "drop");
@@ -6457,30 +6465,30 @@ fn trans_dtor(@local_ctxt cx,
cx.ccx.item_symbols.insert(dtor.node.id, s);
trans_fn(dcx, dtor.node.meth, dtor.node.id,
- some[tup(TypeRef, ty.t)](tup(llself_ty, self_ty)),
+ some[tup(TypeRef, ty::t)](tup(llself_ty, self_ty)),
ty_params, dtor.node.ann);
ret llfn;
}
-fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
- &vec[ast.ty_param] ty_params, &ast.ann ann) {
+fn trans_obj(@local_ctxt cx, &ast::_obj ob, ast::def_id oid,
+ &vec[ast::ty_param] ty_params, &ast::ann ann) {
auto ccx = cx.ccx;
auto llctor_decl = ccx.item_ids.get(oid);
// Translate obj ctor args to function arguments.
- let vec[ast.arg] fn_args = vec();
- for (ast.obj_field f in ob.fields) {
- fn_args += vec(rec(mode=ast.alias, ty=f.ty, ident=f.ident, id=f.id));
+ let vec[ast::arg] fn_args = vec();
+ for (ast::obj_field f in ob.fields) {
+ fn_args += vec(rec(mode=ast::alias, ty=f.ty, ident=f.ident, id=f.id));
}
auto fcx = new_fn_ctxt(cx, llctor_decl);
- create_llargs_for_fn_args(fcx, ast.proto_fn,
- none[tup(TypeRef, ty.t)],
+ create_llargs_for_fn_args(fcx, ast::proto_fn,
+ none[tup(TypeRef, ty::t)],
ret_ty_of_fn(ccx, ann),
fn_args, ty_params);
- let vec[ty.arg] arg_tys = arg_tys_of_fn(ccx, ann);
+ let vec[ty::arg] arg_tys = arg_tys_of_fn(ccx, ann);
copy_args_to_allocas(fcx, fn_args, arg_tys);
auto bcx = new_top_block_ctxt(fcx);
@@ -6493,66 +6501,66 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
auto vtbl = trans_vtbl(cx, llself_ty, self_ty, ob, ty_params);
auto pair_vtbl = bcx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.obj_field_vtbl)));
+ C_int(abi::obj_field_vtbl)));
auto pair_box = bcx.build.GEP(pair,
vec(C_int(0),
- C_int(abi.obj_field_box)));
+ C_int(abi::obj_field_box)));
bcx.build.Store(vtbl, pair_vtbl);
let TypeRef llbox_ty = T_opaque_obj_ptr(ccx.tn);
// FIXME we should probably also allocate a box for empty objs that have a
// dtor, since otherwise they are never dropped, and the dtor never runs
- if (Vec.len[ast.ty_param](ty_params) == 0u &&
- Vec.len[ty.arg](arg_tys) == 0u) {
+ if (_vec::len[ast::ty_param](ty_params) == 0u &&
+ _vec::len[ty::arg](arg_tys) == 0u) {
// Store null into pair, if no args or typarams.
bcx.build.Store(C_null(llbox_ty), pair_box);
} else {
// Malloc a box for the body and copy args in.
- let vec[ty.t] obj_fields = vec();
- for (ty.arg a in arg_tys) {
- Vec.push[ty.t](obj_fields, a.ty);
+ let vec[ty::t] obj_fields = vec();
+ for (ty::arg a in arg_tys) {
+ _vec::push[ty::t](obj_fields, a.ty);
}
// Synthesize an obj body type.
- auto tydesc_ty = ty.mk_type(ccx.tcx);
- let vec[ty.t] tps = vec();
- for (ast.ty_param tp in ty_params) {
- Vec.push[ty.t](tps, tydesc_ty);
+ auto tydesc_ty = ty::mk_type(ccx.tcx);
+ let vec[ty::t] tps = vec();
+ for (ast::ty_param tp in ty_params) {
+ _vec::push[ty::t](tps, tydesc_ty);
}
- let ty.t typarams_ty = ty.mk_imm_tup(ccx.tcx, tps);
- let ty.t fields_ty = ty.mk_imm_tup(ccx.tcx, obj_fields);
- let ty.t body_ty = ty.mk_imm_tup(ccx.tcx,
+ let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
+ let ty::t fields_ty = ty::mk_imm_tup(ccx.tcx, obj_fields);
+ let ty::t body_ty = ty::mk_imm_tup(ccx.tcx,
vec(tydesc_ty,
typarams_ty,
fields_ty));
- let ty.t boxed_body_ty = ty.mk_imm_box(ccx.tcx, body_ty);
+ let ty::t boxed_body_ty = ty::mk_imm_box(ccx.tcx, body_ty);
// Malloc a box for the body.
auto box = trans_malloc_boxed(bcx, body_ty);
bcx = box.bcx;
auto rc = GEP_tup_like(bcx, boxed_body_ty, box.val,
- vec(0, abi.box_rc_field_refcnt));
+ vec(0, abi::box_rc_field_refcnt));
bcx = rc.bcx;
auto body = GEP_tup_like(bcx, boxed_body_ty, box.val,
- vec(0, abi.box_rc_field_body));
+ vec(0, abi::box_rc_field_body));
bcx = body.bcx;
bcx.build.Store(C_int(1), rc.val);
// Store body tydesc.
auto body_tydesc =
GEP_tup_like(bcx, body_ty, body.val,
- vec(0, abi.obj_body_elt_tydesc));
+ vec(0, abi::obj_body_elt_tydesc));
bcx = body_tydesc.bcx;
auto body_td = get_tydesc(bcx, body_ty, true);
auto dtor = C_null(T_ptr(T_glue_fn(ccx.tn)));
alt (ob.dtor) {
- case (some[@ast.method](?d)) {
+ case (some[@ast::method](?d)) {
dtor = trans_dtor(cx, llself_ty, self_ty, ty_params, d);
}
- case (none[@ast.method]) {}
+ case (none[@ast::method]) {}
}
bcx = body_td.bcx;
@@ -6561,10 +6569,10 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
// Copy typarams into captured typarams.
auto body_typarams =
GEP_tup_like(bcx, body_ty, body.val,
- vec(0, abi.obj_body_elt_typarams));
+ vec(0, abi::obj_body_elt_typarams));
bcx = body_typarams.bcx;
let int i = 0;
- for (ast.ty_param tp in ty_params) {
+ for (ast::ty_param tp in ty_params) {
auto typaram = bcx.fcx.lltydescs.(i);
auto capture = GEP_tup_like(bcx, typarams_ty, body_typarams.val,
vec(0, i));
@@ -6576,11 +6584,11 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
// Copy args into body fields.
auto body_fields =
GEP_tup_like(bcx, body_ty, body.val,
- vec(0, abi.obj_body_elt_fields));
+ vec(0, abi::obj_body_elt_fields));
bcx = body_fields.bcx;
i = 0;
- for (ast.obj_field f in ob.fields) {
+ for (ast::obj_field f in ob.fields) {
auto arg = bcx.fcx.llargs.get(f.id);
arg = load_if_immediate(bcx, arg, arg_tys.(i).ty);
auto field = GEP_tup_like(bcx, fields_ty, body_fields.val,
@@ -6598,20 +6606,20 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
finish_fn(fcx, lltop);
}
-fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
- &ast.variant variant, int index,
- &vec[ast.ty_param] ty_params) {
- if (Vec.len[ast.variant_arg](variant.node.args) == 0u) {
+fn trans_tag_variant(@local_ctxt cx, ast::def_id tag_id,
+ &ast::variant variant, int index,
+ &vec[ast::ty_param] ty_params) {
+ if (_vec::len[ast::variant_arg](variant.node.args) == 0u) {
ret; // nullary constructors are just constants
}
// Translate variant arguments to function arguments.
- let vec[ast.arg] fn_args = vec();
+ let vec[ast::arg] fn_args = vec();
auto i = 0u;
- for (ast.variant_arg varg in variant.node.args) {
- fn_args += vec(rec(mode=ast.alias,
+ for (ast::variant_arg varg in variant.node.args) {
+ fn_args += vec(rec(mode=ast::alias,
ty=varg.ty,
- ident="arg" + UInt.to_str(i, 10u),
+ ident="arg" + _uint::to_str(i, 10u),
id=varg.id));
}
@@ -6620,15 +6628,15 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
auto fcx = new_fn_ctxt(cx, llfndecl);
- create_llargs_for_fn_args(fcx, ast.proto_fn,
- none[tup(TypeRef, ty.t)],
+ create_llargs_for_fn_args(fcx, ast::proto_fn,
+ none[tup(TypeRef, ty::t)],
ret_ty_of_fn(cx.ccx, variant.node.ann),
fn_args, ty_params);
- let vec[ty.t] ty_param_substs = vec();
+ let vec[ty::t] ty_param_substs = vec();
i = 0u;
- for (ast.ty_param tp in ty_params) {
- ty_param_substs += vec(ty.mk_param(cx.ccx.tcx, i));
+ for (ast::ty_param tp in ty_params) {
+ ty_param_substs += vec(ty::mk_param(cx.ccx.tcx, i));
i += 1u;
}
@@ -6650,7 +6658,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
vec(C_int(0), C_int(1)));
i = 0u;
- for (ast.variant_arg va in variant.node.args) {
+ for (ast::variant_arg va in variant.node.args) {
auto rslt = GEP_tag(bcx, llblobptr, tag_id, variant.node.id,
ty_param_substs, i as int);
bcx = rslt.bcx;
@@ -6664,8 +6672,8 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
auto arg_ty = arg_tys.(i).ty;
auto llargval;
- if (ty.type_is_structural(cx.ccx.tcx, arg_ty) ||
- ty.type_has_dynamic_size(cx.ccx.tcx, arg_ty)) {
+ if (ty::type_is_structural(cx.ccx.tcx, arg_ty) ||
+ ty::type_has_dynamic_size(cx.ccx.tcx, arg_ty)) {
llargval = llargptr;
} else {
llargval = bcx.build.Load(llargptr);
@@ -6687,9 +6695,9 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
// duplicate constants. I think. Maybe LLVM has a magical mode
// that does so later on?
-fn trans_const_expr(&@crate_ctxt cx, @ast.expr e) -> ValueRef {
+fn trans_const_expr(&@crate_ctxt cx, @ast::expr e) -> ValueRef {
alt (e.node) {
- case (ast.expr_lit(?lit, ?ann)) {
+ case (ast::expr_lit(?lit, ?ann)) {
ret trans_lit(cx, *lit, ann);
}
case (_) {
@@ -6698,53 +6706,53 @@ fn trans_const_expr(&@crate_ctxt cx, @ast.expr e) -> ValueRef {
}
}
-fn trans_const(&@crate_ctxt cx, @ast.expr e,
- &ast.def_id cid, &ast.ann ann) {
+fn trans_const(&@crate_ctxt cx, @ast::expr e,
+ &ast::def_id cid, &ast::ann ann) {
auto t = node_ann_type(cx, ann);
auto v = trans_const_expr(cx, e);
// The scalars come back as 1st class LLVM vals
// which we have to stick into global constants.
auto g = cx.consts.get(cid);
- llvm.LLVMSetInitializer(g, v);
- llvm.LLVMSetGlobalConstant(g, True);
+ llvm::LLVMSetInitializer(g, v);
+ llvm::LLVMSetGlobalConstant(g, True);
}
-fn trans_item(@local_ctxt cx, &ast.item item) {
+fn trans_item(@local_ctxt cx, &ast::item item) {
alt (item.node) {
- case (ast.item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
+ case (ast::item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
auto sub_cx = extend_path(cx, name);
- trans_fn(sub_cx, f, fid, none[tup(TypeRef, ty.t)], tps, ann);
+ trans_fn(sub_cx, f, fid, none[tup(TypeRef, ty::t)], tps, ann);
}
- case (ast.item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
+ case (ast::item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
auto sub_cx = @rec(obj_typarams=tps,
obj_fields=ob.fields with
*extend_path(cx, name));
trans_obj(sub_cx, ob, oid.ctor, tps, ann);
}
- case (ast.item_mod(?name, ?m, _)) {
+ case (ast::item_mod(?name, ?m, _)) {
auto sub_cx = @rec(path = cx.path + vec(name),
module_path = cx.module_path + vec(name)
with *cx);
trans_mod(sub_cx, m);
}
- case (ast.item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
+ case (ast::item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
auto sub_cx = extend_path(cx, name);
auto i = 0;
- for (ast.variant variant in variants) {
+ for (ast::variant variant in variants) {
trans_tag_variant(sub_cx, tag_id, variant, i, tps);
i += 1;
}
}
- case (ast.item_const(?name, _, ?expr, ?cid, ?ann)) {
+ case (ast::item_const(?name, _, ?expr, ?cid, ?ann)) {
trans_const(cx.ccx, expr, cid, ann);
}
case (_) { /* fall through */ }
}
}
-fn trans_mod(@local_ctxt cx, &ast._mod m) {
- for (@ast.item item in m.items) {
+fn trans_mod(@local_ctxt cx, &ast::_mod m) {
+ for (@ast::item item in m.items) {
trans_item(cx, *item);
}
}
@@ -6752,24 +6760,24 @@ fn trans_mod(@local_ctxt cx, &ast._mod m) {
fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
// Bit of a kludge: pick the fn typeref out of the pair.
let vec[TypeRef] pair_tys = vec(T_nil(), T_nil());
- llvm.LLVMGetStructElementTypes(llpairty,
- Vec.buf[TypeRef](pair_tys));
- ret llvm.LLVMGetElementType(pair_tys.(0));
+ llvm::LLVMGetStructElementTypes(llpairty,
+ _vec::buf[TypeRef](pair_tys));
+ ret llvm::LLVMGetElementType(pair_tys.(0));
}
fn decl_fn_and_pair(&@crate_ctxt ccx,
vec[str] path,
str flav,
- vec[ast.ty_param] ty_params,
- &ast.ann ann,
- ast.def_id id) {
+ vec[ast::ty_param] ty_params,
+ &ast::ann ann,
+ ast::def_id id) {
auto llfty;
auto llpairty;
- alt (ty.struct(ccx.tcx, node_ann_type(ccx, ann))) {
- case (ty.ty_fn(?proto, ?inputs, ?output)) {
+ alt (ty::struct(ccx.tcx, node_ann_type(ccx, ann))) {
+ case (ty::ty_fn(?proto, ?inputs, ?output)) {
llfty = type_of_fn(ccx, proto, inputs, output,
- Vec.len[ast.ty_param](ty_params));
+ _vec::len[ast::ty_param](ty_params));
llpairty = T_fn_pair(ccx.tn, llfty);
}
case (_) {
@@ -6789,17 +6797,17 @@ fn decl_fn_and_pair(&@crate_ctxt ccx,
}
fn register_fn_pair(&@crate_ctxt cx, str ps, TypeRef llpairty, ValueRef llfn,
- ast.def_id id) {
- let ValueRef gvar = llvm.LLVMAddGlobal(cx.llmod, llpairty,
- Str.buf(ps));
+ ast::def_id id) {
+ let ValueRef gvar = llvm::LLVMAddGlobal(cx.llmod, llpairty,
+ _str::buf(ps));
auto pair = C_struct(vec(llfn,
C_null(T_opaque_closure_ptr(cx.tn))));
- llvm.LLVMSetInitializer(gvar, pair);
- llvm.LLVMSetGlobalConstant(gvar, True);
- llvm.LLVMSetVisibility(gvar,
- lib.llvm.LLVMProtectedVisibility
- as llvm.Visibility);
+ llvm::LLVMSetInitializer(gvar, pair);
+ llvm::LLVMSetGlobalConstant(gvar, True);
+ llvm::LLVMSetVisibility(gvar,
+ lib::llvm::LLVMProtectedVisibility
+ as llvm::Visibility);
cx.item_ids.insert(id, llfn);
cx.item_symbols.insert(id, ps);
@@ -6807,27 +6815,27 @@ fn register_fn_pair(&@crate_ctxt cx, str ps, TypeRef llpairty, ValueRef llfn,
}
// Returns the number of type parameters that the given native function has.
-fn native_fn_ty_param_count(&@crate_ctxt cx, &ast.def_id id) -> uint {
+fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint {
auto count;
auto native_item = cx.native_items.get(id);
alt (native_item.node) {
- case (ast.native_item_ty(_,_)) {
+ case (ast::native_item_ty(_,_)) {
cx.sess.bug("decl_native_fn_and_pair(): native fn isn't " +
"actually a fn?!");
fail;
}
- case (ast.native_item_fn(_, _, _, ?tps, _, _)) {
- count = Vec.len[ast.ty_param](tps);
+ case (ast::native_item_fn(_, _, _, ?tps, _, _)) {
+ count = _vec::len[ast::ty_param](tps);
}
}
ret count;
}
-fn native_fn_wrapper_type(&@crate_ctxt cx, uint ty_param_count, ty.t x)
+fn native_fn_wrapper_type(&@crate_ctxt cx, uint ty_param_count, ty::t x)
-> TypeRef {
- alt (ty.struct(cx.tcx, x)) {
- case (ty.ty_native_fn(?abi, ?args, ?out)) {
- ret type_of_fn(cx, ast.proto_fn, args, out, ty_param_count);
+ alt (ty::struct(cx.tcx, x)) {
+ case (ty::ty_native_fn(?abi, ?args, ?out)) {
+ ret type_of_fn(cx, ast::proto_fn, args, out, ty_param_count);
}
}
fail;
@@ -6836,8 +6844,8 @@ fn native_fn_wrapper_type(&@crate_ctxt cx, uint ty_param_count, ty.t x)
fn decl_native_fn_and_pair(&@crate_ctxt ccx,
vec[str] path,
str name,
- &ast.ann ann,
- ast.def_id id) {
+ &ast::ann ann,
+ ast::def_id id) {
auto num_ty_param = native_fn_ty_param_count(ccx, id);
// Declare the wrapper.
@@ -6862,32 +6870,33 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
auto item = ccx.native_items.get(id);
auto fn_type = node_ann_type(ccx, ann); // NB: has no type params
- auto abi = ty.ty_fn_abi(ccx.tcx, fn_type);
+ auto abi = ty::ty_fn_abi(ccx.tcx, fn_type);
auto llfnty = type_of_native_fn(ccx, abi,
- ty.ty_fn_args(ccx.tcx, fn_type),
- ty.ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
+ ty::ty_fn_args(ccx.tcx, fn_type),
+ ty::ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
// FIXME: If the returned type is not nil, then we assume it's 32 bits
// wide. This is obviously wildly unsafe. We should have a better FFI
// that allows types of different sizes to be returned.
- auto rty_is_nil = ty.type_is_nil(ccx.tcx, ty.ty_fn_ret(ccx.tcx, fn_type));
+ auto rty_is_nil = ty::type_is_nil(ccx.tcx, ty::ty_fn_ret(ccx.tcx,
+ fn_type));
auto pass_task;
auto cast_to_i32;
alt (abi) {
- case (ast.native_abi_rust) {
+ case (ast::native_abi_rust) {
pass_task = true;
cast_to_i32 = true;
}
- case (ast.native_abi_rust_intrinsic) {
+ case (ast::native_abi_rust_intrinsic) {
pass_task = true;
cast_to_i32 = false;
}
- case (ast.native_abi_cdecl) {
+ case (ast::native_abi_cdecl) {
pass_task = false;
cast_to_i32 = true;
}
- case (ast.native_abi_llvm) {
+ case (ast::native_abi_llvm) {
pass_task = false;
cast_to_i32 = false;
}
@@ -6904,8 +6913,8 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
if (pass_task) { call_args += vec(lltaskptr); }
auto arg_n = 3u;
- for each (uint i in UInt.range(0u, num_ty_param)) {
- auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
+ for each (uint i in _uint::range(0u, num_ty_param)) {
+ auto llarg = llvm::LLVMGetParam(fcx.llfn, arg_n);
fcx.lltydescs += vec(llarg);
assert (llarg as int != 0);
@@ -6920,19 +6929,19 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
fn convert_arg_to_i32(&@block_ctxt cx,
ValueRef v,
- ty.t t,
- ty.mode mode) -> ValueRef {
- if (mode == ty.mo_val) {
- if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
+ ty::t t,
+ ty::mode mode) -> ValueRef {
+ if (mode == ty::mo_val) {
+ if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
auto lldsttype = T_int();
auto llsrctype = type_of(cx.fcx.lcx.ccx, t);
- if (llvm.LLVMGetIntTypeWidth(lldsttype) >
- llvm.LLVMGetIntTypeWidth(llsrctype)) {
+ if (llvm::LLVMGetIntTypeWidth(lldsttype) >
+ llvm::LLVMGetIntTypeWidth(llsrctype)) {
ret cx.build.ZExtOrBitCast(v, T_int());
}
ret cx.build.TruncOrBitCast(v, T_int());
}
- if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
+ if (ty::type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
ret cx.build.FPToSI(v, T_int());
}
}
@@ -6943,7 +6952,7 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
fn trans_simple_native_abi(&@block_ctxt bcx,
str name,
&mutable vec[ValueRef] call_args,
- ty.t fn_type,
+ ty::t fn_type,
uint first_arg_n) -> tup(ValueRef, ValueRef) {
let vec[TypeRef] call_arg_tys = vec();
for (ValueRef arg in call_args) {
@@ -6953,12 +6962,12 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
auto llnativefnty =
T_fn(call_arg_tys,
type_of(bcx.fcx.lcx.ccx,
- ty.ty_fn_ret(bcx.fcx.lcx.ccx.tcx, fn_type)));
+ ty::ty_fn_ret(bcx.fcx.lcx.ccx.tcx, fn_type)));
auto llnativefn = get_extern_fn(bcx.fcx.lcx.ccx.externs,
bcx.fcx.lcx.ccx.llmod,
name,
- lib.llvm.LLVMCCallConv,
+ lib::llvm::LLVMCCallConv,
llnativefnty);
auto r = bcx.build.Call(llnativefn, call_args);
@@ -6966,13 +6975,13 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
ret tup(r, rptr);
}
- auto args = ty.ty_fn_args(ccx.tcx, fn_type);
+ auto args = ty::ty_fn_args(ccx.tcx, fn_type);
// Build up the list of arguments.
- let vec[tup(ValueRef, ty.t)] drop_args = vec();
+ let vec[tup(ValueRef, ty::t)] drop_args = vec();
auto i = arg_n;
- for (ty.arg arg in args) {
- auto llarg = llvm.LLVMGetParam(fcx.llfn, i);
+ for (ty::arg arg in args) {
+ auto llarg = llvm::LLVMGetParam(fcx.llfn, i);
assert (llarg as int != 0);
if (cast_to_i32) {
@@ -6982,7 +6991,7 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
call_args += vec(llarg);
}
- if (arg.mode == ty.mo_val) {
+ if (arg.mode == ty::mo_val) {
drop_args += vec(tup(llarg, arg.ty));
}
@@ -6992,12 +7001,12 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
auto r;
auto rptr;
alt (abi) {
- case (ast.native_abi_llvm) {
+ case (ast::native_abi_llvm) {
auto result = trans_simple_native_abi(bcx, name, call_args,
fn_type, arg_n);
r = result._0; rptr = result._1;
}
- case (ast.native_abi_rust_intrinsic) {
+ case (ast::native_abi_rust_intrinsic) {
auto external_name = "rust_intrinsic_" + name;
auto result = trans_simple_native_abi(bcx, external_name,
call_args, fn_type, arg_n);
@@ -7017,7 +7026,7 @@ fn decl_native_fn_and_pair(&@crate_ctxt ccx,
// the FIXME above.
if (!rty_is_nil) { bcx.build.Store(r, rptr); }
- for (tup(ValueRef, ty.t) d in drop_args) {
+ for (tup(ValueRef, ty::t) d in drop_args) {
bcx = drop_ty(bcx, d._0, d._1).bcx;
}
@@ -7032,94 +7041,94 @@ fn new_walk_ctxt() -> @walk_ctxt {
ret @rec(mutable path=path);
}
-fn enter_item(@walk_ctxt cx, &@ast.item item) {
+fn enter_item(@walk_ctxt cx, &@ast::item item) {
alt (item.node) {
- case (ast.item_fn(?name, _, _, _, _)) {
- Vec.push[str](cx.path, name);
+ case (ast::item_fn(?name, _, _, _, _)) {
+ _vec::push[str](cx.path, name);
}
- case (ast.item_obj(?name, _, _, _, _)) {
- Vec.push[str](cx.path, name);
+ case (ast::item_obj(?name, _, _, _, _)) {
+ _vec::push[str](cx.path, name);
}
- case (ast.item_mod(?name, _, _)) {
- Vec.push[str](cx.path, name);
+ case (ast::item_mod(?name, _, _)) {
+ _vec::push[str](cx.path, name);
}
case (_) { }
}
}
-fn leave_item(@walk_ctxt cx, &@ast.item item) {
+fn leave_item(@walk_ctxt cx, &@ast::item item) {
alt (item.node) {
- case (ast.item_fn(_, _, _, _, _)) {
- Vec.pop[str](cx.path);
+ case (ast::item_fn(_, _, _, _, _)) {
+ _vec::pop[str](cx.path);
}
- case (ast.item_obj(_, _, _, _, _)) {
- Vec.pop[str](cx.path);
+ case (ast::item_obj(_, _, _, _, _)) {
+ _vec::pop[str](cx.path);
}
- case (ast.item_mod(_, _, _)) {
- Vec.pop[str](cx.path);
+ case (ast::item_mod(_, _, _)) {
+ _vec::pop[str](cx.path);
}
case (_) { }
}
}
fn collect_native_item(&@crate_ctxt ccx, @walk_ctxt wcx,
- &@ast.native_item i) {
+ &@ast::native_item i) {
alt (i.node) {
- case (ast.native_item_fn(?name, _, _, _, ?fid, ?ann)) {
+ case (ast::native_item_fn(?name, _, _, _, ?fid, ?ann)) {
ccx.native_items.insert(fid, i);
if (!ccx.obj_methods.contains_key(fid)) {
decl_native_fn_and_pair(ccx, wcx.path, name, ann, fid);
}
}
- case (ast.native_item_ty(_, ?tid)) {
+ case (ast::native_item_ty(_, ?tid)) {
ccx.native_items.insert(tid, i);
}
}
}
-fn collect_item_1(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
+fn collect_item_1(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
enter_item(wcx, i);
alt (i.node) {
- case (ast.item_const(?name, _, _, ?cid, ?ann)) {
+ case (ast::item_const(?name, _, _, ?cid, ?ann)) {
auto typ = node_ann_type(ccx, ann);
- auto g = llvm.LLVMAddGlobal(ccx.llmod, type_of(ccx, typ),
- Str.buf(ccx.names.next(name)));
- llvm.LLVMSetLinkage(g, lib.llvm.LLVMInternalLinkage
- as llvm.Linkage);
+ auto g = llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, typ),
+ _str::buf(ccx.names.next(name)));
+ llvm::LLVMSetLinkage(g, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
ccx.items.insert(cid, i);
ccx.consts.insert(cid, g);
}
- case (ast.item_mod(?name, ?m, ?mid)) {
+ case (ast::item_mod(?name, ?m, ?mid)) {
ccx.items.insert(mid, i);
}
- case (ast.item_native_mod(_, _, ?mid)) {
+ case (ast::item_native_mod(_, _, ?mid)) {
ccx.items.insert(mid, i);
}
- case (ast.item_ty(_, _, _, ?did, _)) {
+ case (ast::item_ty(_, _, _, ?did, _)) {
ccx.items.insert(did, i);
}
- case (ast.item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
+ case (ast::item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
ccx.items.insert(tag_id, i);
}
case (_) {}
}
}
-fn collect_item_2(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
+fn collect_item_2(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
enter_item(wcx, i);
alt (i.node) {
- case (ast.item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
+ case (ast::item_fn(?name, ?f, ?tps, ?fid, ?ann)) {
ccx.items.insert(fid, i);
if (!ccx.obj_methods.contains_key(fid)) {
decl_fn_and_pair(ccx, wcx.path, "fn", tps, ann, fid);
}
}
- case (ast.item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
+ case (ast::item_obj(?name, ?ob, ?tps, ?oid, ?ann)) {
ccx.items.insert(oid.ctor, i);
decl_fn_and_pair(ccx, wcx.path, "obj_ctor", tps, ann, oid.ctor);
- for (@ast.method m in ob.methods) {
+ for (@ast::method m in ob.methods) {
ccx.obj_methods.insert(m.node.id, ());
}
}
@@ -7127,9 +7136,9 @@ fn collect_item_2(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
}
}
-fn collect_items(&@crate_ctxt ccx, @ast.crate crate) {
+fn collect_items(&@crate_ctxt ccx, @ast::crate crate) {
auto wcx = new_walk_ctxt();
- auto visitor0 = walk.default_visitor();
+ auto visitor0 = walk::default_visitor();
auto visitor1 = rec(visit_native_item_pre =
bind collect_native_item(ccx, wcx, _),
visit_item_pre = bind collect_item_1(ccx, wcx, _),
@@ -7138,17 +7147,17 @@ fn collect_items(&@crate_ctxt ccx, @ast.crate crate) {
auto visitor2 = rec(visit_item_pre = bind collect_item_2(ccx, wcx, _),
visit_item_post = bind leave_item(wcx, _)
with visitor0);
- walk.walk_crate(visitor1, *crate);
- walk.walk_crate(visitor2, *crate);
+ walk::walk_crate(visitor1, *crate);
+ walk::walk_crate(visitor2, *crate);
}
-fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
+fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item i) {
enter_item(wcx, i);
alt (i.node) {
- case (ast.item_tag(_, ?variants, ?tps, _, _)) {
- for (ast.variant variant in variants) {
- if (Vec.len[ast.variant_arg](variant.node.args) != 0u) {
+ case (ast::item_tag(_, ?variants, ?tps, _, _)) {
+ for (ast::variant variant in variants) {
+ if (_vec::len[ast::variant_arg](variant.node.args) != 0u) {
decl_fn_and_pair(ccx, wcx.path + vec(variant.node.name),
"tag", tps, variant.node.ann,
variant.node.id);
@@ -7160,23 +7169,23 @@ fn collect_tag_ctor(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item i) {
}
}
-fn collect_tag_ctors(&@crate_ctxt ccx, @ast.crate crate) {
+fn collect_tag_ctors(&@crate_ctxt ccx, @ast::crate crate) {
auto wcx = new_walk_ctxt();
auto visitor = rec(visit_item_pre = bind collect_tag_ctor(ccx, wcx, _),
visit_item_post = bind leave_item(wcx, _)
- with walk.default_visitor());
- walk.walk_crate(visitor, *crate);
+ with walk::default_visitor());
+ walk::walk_crate(visitor, *crate);
}
// The constant translation pass.
-fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
+fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast::item it) {
enter_item(wcx, it);
alt (it.node) {
- case (ast.item_tag(?ident, ?variants, _, ?tag_id, _)) {
+ case (ast::item_tag(?ident, ?variants, _, ?tag_id, _)) {
auto i = 0u;
- auto n_variants = Vec.len[ast.variant](variants);
+ auto n_variants = _vec::len[ast::variant](variants);
while (i < n_variants) {
auto variant = variants.(i);
@@ -7185,11 +7194,11 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
auto s = mangle_name_by_seq(ccx, wcx.path,
#fmt("_rust_tag_discrim_%s_%u",
ident, i));
- auto discrim_gvar = llvm.LLVMAddGlobal(ccx.llmod, T_int(),
- Str.buf(s));
+ auto discrim_gvar = llvm::LLVMAddGlobal(ccx.llmod, T_int(),
+ _str::buf(s));
- llvm.LLVMSetInitializer(discrim_gvar, discrim_val);
- llvm.LLVMSetGlobalConstant(discrim_gvar, True);
+ llvm::LLVMSetInitializer(discrim_gvar, discrim_val);
+ llvm::LLVMSetGlobalConstant(discrim_gvar, True);
ccx.discrims.insert(variant.node.id, discrim_gvar);
ccx.discrim_symbols.insert(variant.node.id, s);
@@ -7198,7 +7207,7 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
}
}
- case (ast.item_const(?name, _, ?expr, ?cid, ?ann)) {
+ case (ast::item_const(?name, _, ?expr, ?cid, ?ann)) {
// FIXME: The whole expr-translation system needs cloning to deal
// with consts.
auto v = C_int(1);
@@ -7212,12 +7221,12 @@ fn trans_constant(&@crate_ctxt ccx, @walk_ctxt wcx, &@ast.item it) {
}
}
-fn trans_constants(&@crate_ctxt ccx, @ast.crate crate) {
+fn trans_constants(&@crate_ctxt ccx, @ast::crate crate) {
auto wcx = new_walk_ctxt();
auto visitor = rec(visit_item_pre = bind trans_constant(ccx, wcx, _),
visit_item_post = bind leave_item(wcx, _)
- with walk.default_visitor());
- walk.walk_crate(visitor, *crate);
+ with walk::default_visitor());
+ walk::walk_crate(visitor, *crate);
}
@@ -7231,11 +7240,11 @@ fn vi2p(&@block_ctxt cx, ValueRef v, TypeRef t) -> ValueRef {
}
fn p2i(ValueRef v) -> ValueRef {
- ret llvm.LLVMConstPtrToInt(v, T_int());
+ ret llvm::LLVMConstPtrToInt(v, T_int());
}
fn i2p(ValueRef v, TypeRef t) -> ValueRef {
- ret llvm.LLVMConstIntToPtr(v, t);
+ ret llvm::LLVMConstIntToPtr(v, t);
}
fn trans_exit_task_glue(@glue_fns glues,
@@ -7246,14 +7255,14 @@ fn trans_exit_task_glue(@glue_fns glues,
auto llfn = glues.exit_task_glue;
- auto entrybb = llvm.LLVMAppendBasicBlock(llfn, Str.buf("entry"));
+ auto entrybb = llvm::LLVMAppendBasicBlock(llfn, _str::buf("entry"));
auto build = new_builder(entrybb);
- let ValueRef arg1 = llvm.LLVMGetParam(llfn, 0u);
- let ValueRef arg2 = llvm.LLVMGetParam(llfn, 1u);
- let ValueRef arg3 = llvm.LLVMGetParam(llfn, 2u);
- let ValueRef arg4 = llvm.LLVMGetParam(llfn, 3u);
- let ValueRef arg5 = llvm.LLVMGetParam(llfn, 4u);
+ let ValueRef arg1 = llvm::LLVMGetParam(llfn, 0u);
+ let ValueRef arg2 = llvm::LLVMGetParam(llfn, 1u);
+ let ValueRef arg3 = llvm::LLVMGetParam(llfn, 2u);
+ let ValueRef arg4 = llvm::LLVMGetParam(llfn, 3u);
+ let ValueRef arg5 = llvm::LLVMGetParam(llfn, 4u);
auto main_type = T_fn(vec(T_int(), T_int(), T_int(), T_int()), T_void());
@@ -7268,9 +7277,9 @@ fn trans_exit_task_glue(@glue_fns glues,
}
fn create_typedefs(&@crate_ctxt cx) {
- llvm.LLVMAddTypeName(cx.llmod, Str.buf("crate"), T_crate(cx.tn));
- llvm.LLVMAddTypeName(cx.llmod, Str.buf("task"), T_task(cx.tn));
- llvm.LLVMAddTypeName(cx.llmod, Str.buf("tydesc"), T_tydesc(cx.tn));
+ llvm::LLVMAddTypeName(cx.llmod, _str::buf("crate"), T_crate(cx.tn));
+ llvm::LLVMAddTypeName(cx.llmod, _str::buf("task"), T_task(cx.tn));
+ llvm::LLVMAddTypeName(cx.llmod, _str::buf("tydesc"), T_tydesc(cx.tn));
}
fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
@@ -7278,13 +7287,13 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
let ValueRef crate_addr = p2i(crate_ptr);
let ValueRef activate_glue_off =
- llvm.LLVMConstSub(p2i(glues.activate_glue), crate_addr);
+ llvm::LLVMConstSub(p2i(glues.activate_glue), crate_addr);
let ValueRef yield_glue_off =
- llvm.LLVMConstSub(p2i(glues.yield_glue), crate_addr);
+ llvm::LLVMConstSub(p2i(glues.yield_glue), crate_addr);
let ValueRef exit_task_glue_off =
- llvm.LLVMConstSub(p2i(glues.exit_task_glue), crate_addr);
+ llvm::LLVMConstSub(p2i(glues.exit_task_glue), crate_addr);
let ValueRef crate_val =
C_struct(vec(C_null(T_int()), // ptrdiff_t image_base_off
@@ -7301,18 +7310,18 @@ fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
C_null(T_int()), // int n_rust_syms
C_null(T_int()), // int n_c_syms
C_null(T_int()), // int n_libs
- C_int(abi.abi_x86_rustc_fastcall) // uintptr_t abi_tag
+ C_int(abi::abi_x86_rustc_fastcall) // uintptr_t abi_tag
));
- llvm.LLVMSetInitializer(crate_ptr, crate_val);
+ llvm::LLVMSetInitializer(crate_ptr, crate_val);
}
fn find_main_fn(&@crate_ctxt cx) -> ValueRef {
auto e = sep() + "main";
let ValueRef v = C_nil();
let uint n = 0u;
- for each (@tup(ast.def_id, str) i in cx.item_symbols.items()) {
- if (Str.ends_with(i._1, e)) {
+ for each (@tup(ast::def_id, str) i in cx.item_symbols.items()) {
+ if (_str::ends_with(i._1, e)) {
n += 1u;
v = cx.item_ids.get(i._0);
}
@@ -7336,7 +7345,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
auto T_rust_start_args = vec(T_int(), T_int(), T_int(), T_int(), T_int());
auto main_name;
- if (Str.eq(std.OS.target_os(), "win32")) {
+ if (_str::eq(std::os::target_os(), "win32")) {
main_name = "WinMain@16";
} else {
main_name = "main";
@@ -7348,8 +7357,8 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
auto llrust_start = decl_cdecl_fn(cx.ccx.llmod, "rust_start",
T_fn(T_rust_start_args, T_int()));
- auto llargc = llvm.LLVMGetParam(llmain, 0u);
- auto llargv = llvm.LLVMGetParam(llmain, 1u);
+ auto llargc = llvm::LLVMGetParam(llmain, 0u);
+ auto llargv = llvm::LLVMGetParam(llmain, 1u);
auto llrust_main = find_main_fn(cx.ccx);
//
@@ -7361,7 +7370,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
//
let BasicBlockRef llbb =
- llvm.LLVMAppendBasicBlock(llmain, Str.buf(""));
+ llvm::LLVMAppendBasicBlock(llmain, _str::buf(""));
auto b = new_builder(llbb);
auto start_args = vec(p2i(llrust_main), p2i(llcrate), llargc, llargv,
@@ -7428,12 +7437,12 @@ fn trap(&@block_ctxt bcx) {
fn decl_no_op_type_glue(ModuleRef llmod, type_names tn) -> ValueRef {
auto ty = T_fn(vec(T_taskptr(tn), T_ptr(T_i8())), T_void());
- ret decl_fastcall_fn(llmod, abi.no_op_type_glue_name(), ty);
+ ret decl_fastcall_fn(llmod, abi::no_op_type_glue_name(), ty);
}
fn make_no_op_type_glue(ValueRef fun) {
- auto bb_name = Str.buf("_rust_no_op_type_glue_bb");
- auto llbb = llvm.LLVMAppendBasicBlock(fun, bb_name);
+ auto bb_name = _str::buf("_rust_no_op_type_glue_bb");
+ auto llbb = llvm::LLVMAppendBasicBlock(fun, bb_name);
new_builder(llbb).RetVoid();
}
@@ -7465,34 +7474,34 @@ fn make_vec_append_glue(ModuleRef llmod, type_names tn) -> ValueRef {
T_opaque_vec_ptr(), T_bool()),
T_void());
- auto llfn = decl_fastcall_fn(llmod, abi.vec_append_glue_name(), ty);
+ auto llfn = decl_fastcall_fn(llmod, abi::vec_append_glue_name(), ty);
ret llfn;
}
fn vec_fill(&@block_ctxt bcx, ValueRef v) -> ValueRef {
ret bcx.build.Load(bcx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_fill))));
+ C_int(abi::vec_elt_fill))));
}
fn put_vec_fill(&@block_ctxt bcx, ValueRef v, ValueRef fill) -> ValueRef {
ret bcx.build.Store(fill,
bcx.build.GEP(v,
vec(C_int(0),
- C_int(abi.vec_elt_fill))));
+ C_int(abi::vec_elt_fill))));
}
fn vec_fill_adjusted(&@block_ctxt bcx, ValueRef v,
ValueRef skipnull) -> ValueRef {
auto f = bcx.build.Load(bcx.build.GEP(v,
vec(C_int(0),
- C_int(abi.vec_elt_fill))));
+ C_int(abi::vec_elt_fill))));
ret bcx.build.Select(skipnull, bcx.build.Sub(f, C_int(1)), f);
}
fn vec_p0(&@block_ctxt bcx, ValueRef v) -> ValueRef {
auto p = bcx.build.GEP(v, vec(C_int(0),
- C_int(abi.vec_elt_data)));
+ C_int(abi::vec_elt_data)));
ret bcx.build.PointerCast(p, T_ptr(T_i8()));
}
@@ -7512,14 +7521,14 @@ fn trans_vec_append_glue(@local_ctxt cx) {
auto llfn = cx.ccx.glues.vec_append_glue;
- let ValueRef lltaskptr = llvm.LLVMGetParam(llfn, 0u);
- let ValueRef llvec_tydesc = llvm.LLVMGetParam(llfn, 1u);
- let ValueRef llelt_tydesc = llvm.LLVMGetParam(llfn, 2u);
- let ValueRef lldst_vec_ptr = llvm.LLVMGetParam(llfn, 3u);
- let ValueRef llsrc_vec = llvm.LLVMGetParam(llfn, 4u);
- let ValueRef llskipnull = llvm.LLVMGetParam(llfn, 5u);
+ let ValueRef lltaskptr = llvm::LLVMGetParam(llfn, 0u);
+ let ValueRef llvec_tydesc = llvm::LLVMGetParam(llfn, 1u);
+ let ValueRef llelt_tydesc = llvm::LLVMGetParam(llfn, 2u);
+ let ValueRef lldst_vec_ptr = llvm::LLVMGetParam(llfn, 3u);
+ let ValueRef llsrc_vec = llvm::LLVMGetParam(llfn, 4u);
+ let ValueRef llskipnull = llvm::LLVMGetParam(llfn, 5u);
auto 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);
auto llbbs = mk_standard_basic_blocks(llfn);
@@ -7536,7 +7545,7 @@ fn trans_vec_append_glue(@local_ctxt cx) {
llobjfields=new_def_hash[ValueRef](),
lllocals=new_def_hash[ValueRef](),
llupvars=new_def_hash[ValueRef](),
- mutable lltydescs=Vec.empty[ValueRef](),
+ mutable lltydescs=_vec::empty[ValueRef](),
derived_tydescs=derived_tydescs,
lcx=cx);
@@ -7581,13 +7590,13 @@ fn trans_vec_append_glue(@local_ctxt cx) {
auto elt_llsz =
cx.build.Load(cx.build.GEP(elt_tydesc,
vec(C_int(0),
- C_int(abi.tydesc_field_size))));
+ C_int(abi::tydesc_field_size))));
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llsz");
auto elt_llalign =
cx.build.Load(cx.build.GEP(elt_tydesc,
vec(C_int(0),
- C_int(abi.tydesc_field_align))));
+ C_int(abi::tydesc_field_align))));
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llalign");
@@ -7596,7 +7605,7 @@ fn trans_vec_append_glue(@local_ctxt cx) {
ValueRef dst, ValueRef src) -> result {
call_tydesc_glue_full(cx, src,
elt_tydesc,
- abi.tydesc_field_take_glue);
+ abi::tydesc_field_take_glue);
ret res(cx, src);
}
@@ -7648,9 +7657,9 @@ fn trans_vec_append_glue(@local_ctxt cx) {
fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
- ret @rec(activate_glue = decl_glue(llmod, tn, abi.activate_glue_name()),
- yield_glue = decl_glue(llmod, tn, abi.yield_glue_name()),
- exit_task_glue = decl_cdecl_fn(llmod, abi.exit_task_glue_name(),
+ ret @rec(activate_glue = decl_glue(llmod, tn, abi::activate_glue_name()),
+ yield_glue = decl_glue(llmod, tn, abi::yield_glue_name()),
+ exit_task_glue = decl_cdecl_fn(llmod, abi::exit_task_glue_name(),
T_fn(vec(T_int(),
T_int(),
T_int(),
@@ -7659,65 +7668,66 @@ fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
T_void())),
native_glues_rust =
- Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
- abi.ngt_rust, _), abi.n_native_glues + 1 as uint),
+ _vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
+ abi::ngt_rust, _), abi::n_native_glues + 1 as uint),
native_glues_pure_rust =
- Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
- abi.ngt_pure_rust, _), abi.n_native_glues + 1 as uint),
+ _vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
+ abi::ngt_pure_rust, _), abi::n_native_glues + 1 as uint),
native_glues_cdecl =
- Vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
- abi.ngt_cdecl, _), abi.n_native_glues + 1 as uint),
+ _vec::init_fn[ValueRef](bind decl_native_glue(llmod, tn,
+ abi::ngt_cdecl, _), abi::n_native_glues + 1 as uint),
no_op_type_glue = decl_no_op_type_glue(llmod, tn),
vec_append_glue = make_vec_append_glue(llmod, tn));
}
-fn make_common_glue(&session.session sess, &str output) {
+fn make_common_glue(&session::session sess, &str output) {
// FIXME: part of this is repetitive and is probably a good idea
// to autogen it.
auto llmod =
- llvm.LLVMModuleCreateWithNameInContext(Str.buf("rust_out"),
- llvm.LLVMGetGlobalContext());
+ llvm::LLVMModuleCreateWithNameInContext(_str::buf("rust_out"),
+ llvm::LLVMGetGlobalContext());
- llvm.LLVMSetDataLayout(llmod, Str.buf(x86.get_data_layout()));
- llvm.LLVMSetTarget(llmod, Str.buf(x86.get_target_triple()));
- auto td = mk_target_data(x86.get_data_layout());
+ llvm::LLVMSetDataLayout(llmod, _str::buf(x86::get_data_layout()));
+ llvm::LLVMSetTarget(llmod, _str::buf(x86::get_target_triple()));
+ auto td = mk_target_data(x86::get_data_layout());
auto tn = mk_type_names();
let ValueRef crate_ptr =
- llvm.LLVMAddGlobal(llmod, T_crate(tn), Str.buf("rust_crate"));
+ llvm::LLVMAddGlobal(llmod, T_crate(tn), _str::buf("rust_crate"));
auto intrinsics = declare_intrinsics(llmod);
- llvm.LLVMSetModuleInlineAsm(llmod, Str.buf(x86.get_module_asm()));
+ llvm::LLVMSetModuleInlineAsm(llmod, _str::buf(x86::get_module_asm()));
auto glues = make_glues(llmod, tn);
create_crate_constant(crate_ptr, glues);
- trans.trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn,
+ trans::trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn,
llmod);
- Link.Write.run_passes(sess, llmod, output);
+ Link::Write::run_passes(sess, llmod, output);
}
fn create_module_map(&@crate_ctxt ccx) -> ValueRef {
auto elttype = T_struct(vec(T_int(), T_int()));
auto maptype = T_array(elttype, ccx.module_data.size() + 1u);
- auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype,
- Str.buf("_rust_mod_map"));
- llvm.LLVMSetLinkage(map, lib.llvm.LLVMInternalLinkage as llvm.Linkage);
+ auto map = llvm::LLVMAddGlobal(ccx.llmod, maptype,
+ _str::buf("_rust_mod_map"));
+ llvm::LLVMSetLinkage(map, lib::llvm::LLVMInternalLinkage
+ as llvm::Linkage);
let vec[ValueRef] elts = vec();
for each (@tup(str, ValueRef) item in ccx.module_data.items()) {
auto elt = C_struct(vec(p2i(C_cstr(ccx, item._0)), p2i(item._1)));
- Vec.push[ValueRef](elts, elt);
+ _vec::push[ValueRef](elts, elt);
}
auto term = C_struct(vec(C_int(0), C_int(0)));
- Vec.push[ValueRef](elts, term);
- llvm.LLVMSetInitializer(map, C_array(elttype, elts));
+ _vec::push[ValueRef](elts, term);
+ llvm::LLVMSetInitializer(map, C_array(elttype, elts));
ret map;
}
fn crate_name(&@crate_ctxt ccx, &str deflt) -> str {
- for (@ast.meta_item item in ccx.sess.get_metadata()) {
- if (Str.eq(item.node.name, "name")) {
+ for (@ast::meta_item item in ccx.sess.get_metadata()) {
+ if (_str::eq(item.node.name, "name")) {
ret item.node.value;
}
}
@@ -7730,47 +7740,48 @@ fn create_crate_map(&@crate_ctxt ccx) -> ValueRef {
auto i = 1;
while (ccx.sess.has_external_crate(i)) {
auto name = ccx.sess.get_external_crate(i).name;
- auto cr = llvm.LLVMAddGlobal(ccx.llmod, T_int(),
- Str.buf("_rust_crate_map_" + name));
- Vec.push[ValueRef](subcrates, p2i(cr));
+ auto cr = llvm::LLVMAddGlobal(ccx.llmod, T_int(),
+ _str::buf("_rust_crate_map_" + name));
+ _vec::push[ValueRef](subcrates, p2i(cr));
i += 1;
}
- Vec.push[ValueRef](subcrates, C_int(0));
+ _vec::push[ValueRef](subcrates, C_int(0));
auto sym_name = "_rust_crate_map_" + crate_name(ccx, "__none__");
- auto arrtype = T_array(T_int(), Vec.len[ValueRef](subcrates));
+ auto arrtype = T_array(T_int(), _vec::len[ValueRef](subcrates));
auto maptype = T_struct(vec(T_int(), arrtype));
- auto map = llvm.LLVMAddGlobal(ccx.llmod, maptype, Str.buf(sym_name));
- llvm.LLVMSetLinkage(map, lib.llvm.LLVMExternalLinkage as llvm.Linkage);
- llvm.LLVMSetInitializer(map, C_struct(vec(p2i(create_module_map(ccx)),
+ auto map = llvm::LLVMAddGlobal(ccx.llmod, maptype, _str::buf(sym_name));
+ llvm::LLVMSetLinkage(map, lib::llvm::LLVMExternalLinkage
+ as llvm::Linkage);
+ llvm::LLVMSetInitializer(map, C_struct(vec(p2i(create_module_map(ccx)),
C_array(T_int(), subcrates))));
ret map;
}
-fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
- &ty.type_cache type_cache, &str output)
+fn trans_crate(&session::session sess, &@ast::crate crate, &ty::ctxt tcx,
+ &ty::type_cache type_cache, &str output)
-> ModuleRef {
auto llmod =
- llvm.LLVMModuleCreateWithNameInContext(Str.buf("rust_out"),
- llvm.LLVMGetGlobalContext());
+ llvm::LLVMModuleCreateWithNameInContext(_str::buf("rust_out"),
+ llvm::LLVMGetGlobalContext());
- llvm.LLVMSetDataLayout(llmod, Str.buf(x86.get_data_layout()));
- llvm.LLVMSetTarget(llmod, Str.buf(x86.get_target_triple()));
- auto td = mk_target_data(x86.get_data_layout());
+ llvm::LLVMSetDataLayout(llmod, _str::buf(x86::get_data_layout()));
+ llvm::LLVMSetTarget(llmod, _str::buf(x86::get_target_triple()));
+ auto td = mk_target_data(x86::get_data_layout());
auto tn = mk_type_names();
let ValueRef crate_ptr =
- llvm.LLVMAddGlobal(llmod, T_crate(tn), Str.buf("rust_crate"));
+ llvm::LLVMAddGlobal(llmod, T_crate(tn), _str::buf("rust_crate"));
auto intrinsics = declare_intrinsics(llmod);
auto glues = make_glues(llmod, tn);
- auto hasher = ty.hash_ty;
- auto eqer = ty.eq_ty;
- auto tag_sizes = Map.mk_hashmap[ty.t,uint](hasher, eqer);
- auto tydescs = Map.mk_hashmap[ty.t,@tydesc_info](hasher, eqer);
- auto lltypes = Map.mk_hashmap[ty.t,TypeRef](hasher, eqer);
- auto sha1s = Map.mk_hashmap[ty.t,str](hasher, eqer);
- auto abbrevs = Map.mk_hashmap[ty.t,metadata.ty_abbrev](hasher, eqer);
- auto short_names = Map.mk_hashmap[ty.t,str](hasher, eqer);
+ auto hasher = ty::hash_ty;
+ auto eqer = ty::eq_ty;
+ auto tag_sizes = map::mk_hashmap[ty::t,uint](hasher, eqer);
+ auto tydescs = map::mk_hashmap[ty::t,@tydesc_info](hasher, eqer);
+ auto lltypes = map::mk_hashmap[ty::t,TypeRef](hasher, eqer);
+ auto sha1s = map::mk_hashmap[ty::t,str](hasher, eqer);
+ auto abbrevs = map::mk_hashmap[ty::t,metadata::ty_abbrev](hasher, eqer);
+ auto short_names = map::mk_hashmap[ty::t,str](hasher, eqer);
auto ccx = @rec(sess = sess,
llmod = llmod,
@@ -7780,8 +7791,8 @@ fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
externs = new_str_hash[ValueRef](),
intrinsics = intrinsics,
item_ids = new_def_hash[ValueRef](),
- items = new_def_hash[@ast.item](),
- native_items = new_def_hash[@ast.native_item](),
+ items = new_def_hash[@ast::item](),
+ native_items = new_def_hash[@ast::native_item](),
type_cache = type_cache,
item_symbols = new_def_hash[str](),
tag_sizes = tag_sizes,
@@ -7795,12 +7806,12 @@ fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
lltypes = lltypes,
glues = glues,
names = namegen(0),
- sha = std.SHA1.mk_sha1(),
+ sha = std::sha1::mk_sha1(),
type_sha1s = sha1s,
type_abbrevs = abbrevs,
type_short_names = short_names,
tcx = tcx,
- upcalls = upcall.declare_upcalls(tn, llmod));
+ upcalls = upcall::declare_upcalls(tn, llmod));
auto cx = new_local_ctxt(ccx);
create_typedefs(ccx);
@@ -7815,8 +7826,8 @@ fn trans_crate(&session.session sess, &@ast.crate crate, &ty.ctxt tcx,
trans_main_fn(cx, crate_ptr, crate_map);
}
- // Translate the metadata.
- middle.metadata.write_metadata(cx.ccx, crate);
+ // Translate the metadata:
+ middle::metadata::write_metadata(cx.ccx, crate);
ret llmod;
}
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 8c79c605..ad876b38 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -1,37 +1,37 @@
-import std.Str;
-import std.UInt;
-import std.Vec;
-import std.Box;
-import std.UFind;
-import std.Map;
-import std.Map.hashmap;
-import std.Option;
-import std.Option.none;
-import std.Option.some;
-
-import driver.session;
-import front.ast;
-import front.ast.mutability;
-import front.creader;
-import middle.metadata;
-import util.common;
-
-import util.common.ty_u8;
-import util.common.ty_u16;
-import util.common.ty_u32;
-import util.common.ty_u64;
-
-import util.common.ty_i8;
-import util.common.ty_i16;
-import util.common.ty_i32;
-import util.common.ty_i64;
-
-import util.common.ty_f32;
-import util.common.ty_f64;
-
-import util.common.new_def_hash;
-import util.common.span;
-import util.typestate_ann.ts_ann;
+import std::_str;
+import std::_uint;
+import std::_vec;
+import std::box;
+import std::ufind;
+import std::map;
+import std::map::hashmap;
+import std::option;
+import std::option::none;
+import std::option::some;
+
+import driver::session;
+import front::ast;
+import front::ast::mutability;
+import front::creader;
+import middle::metadata;
+import util::common;
+
+import util::common::ty_u8;
+import util::common::ty_u16;
+import util::common::ty_u32;
+import util::common::ty_u64;
+
+import util::common::ty_i8;
+import util::common::ty_i16;
+import util::common::ty_i32;
+import util::common::ty_i64;
+
+import util::common::ty_f32;
+import util::common::ty_f64;
+
+import util::common::new_def_hash;
+import util::common::span;
+import util::typestate_ann::ts_ann;
// Data types
@@ -42,23 +42,23 @@ tag mode {
}
type arg = rec(mode mode, t ty);
-type field = rec(ast.ident ident, mt mt);
-type method = rec(ast.proto proto,
- ast.ident ident,
+type field = rec(ast::ident ident, mt mt);
+type method = rec(ast::proto proto,
+ ast::ident ident,
vec[arg] inputs,
t output);
-type mt = rec(t ty, ast.mutability mut);
+type mt = rec(t ty, ast::mutability mut);
// Contains information needed to resolve types and (in the future) look up
// the types of AST nodes.
-type creader_cache = hashmap[tup(int,uint,uint),ty.t];
+type creader_cache = hashmap[tup(int,uint,uint),ty::t];
type ctxt = rec(@type_store ts,
- session.session sess,
- resolve.def_map def_map,
+ session::session sess,
+ resolve::def_map def_map,
creader_cache rcache,
hashmap[t,str] short_names_cache);
-type ty_ctxt = ctxt; // Needed for disambiguation from Unify.ctxt.
+type ty_ctxt = ctxt; // Needed for disambiguation from Unify::ctxt.
// Convert from method type to function type. Pretty easy; we just drop
// 'ident'.
@@ -71,7 +71,7 @@ fn method_ty_to_fn_ty(ctxt cx, method m) -> t {
// TODO: It'd be really nice to be able to hide this definition from the
// outside world, to enforce the above invariants.
type raw_t = rec(sty struct,
- Option.t[str] cname,
+ option::t[str] cname,
uint hash,
bool has_params,
bool has_bound_params,
@@ -81,17 +81,17 @@ type raw_t = rec(sty struct,
type t = uint;
// NB: If you change this, you'll probably want to change the corresponding
-// AST structure in front/ast.rs as well.
+// AST structure in front/ast::rs as well.
tag sty {
ty_nil;
ty_bool;
ty_int;
ty_float;
ty_uint;
- ty_machine(util.common.ty_mach);
+ ty_machine(util::common::ty_mach);
ty_char;
ty_str;
- ty_tag(ast.def_id, vec[t]);
+ ty_tag(ast::def_id, vec[t]);
ty_box(mt);
ty_vec(mt);
ty_port(t);
@@ -99,11 +99,11 @@ tag sty {
ty_task;
ty_tup(vec[mt]);
ty_rec(vec[field]);
- ty_fn(ast.proto, vec[arg], t);
- ty_native_fn(ast.native_abi, vec[arg], t);
+ ty_fn(ast::proto, vec[arg], t);
+ ty_native_fn(ast::native_abi, vec[arg], t);
ty_obj(vec[method]);
ty_var(int); // ephemeral type var
- ty_local(ast.def_id); // type of a local var
+ ty_local(ast::def_id); // type of a local var
ty_param(uint); // fn/tag type param
ty_bound_param(uint); // bound param, only paths
ty_type;
@@ -114,9 +114,9 @@ tag sty {
// Data structures used in type unification
type unify_handler = obj {
- fn resolve_local(ast.def_id id) -> Option.t[t];
- fn record_local(ast.def_id id, t ty); // TODO: -> Unify.result
- fn record_param(uint index, t binding) -> Unify.result;
+ fn resolve_local(ast::def_id id) -> option::t[t];
+ fn record_local(ast::def_id id, t ty); // TODO: -> Unify::result
+ fn record_param(uint index, t binding) -> Unify::result;
};
tag type_err {
@@ -127,15 +127,15 @@ tag type_err {
terr_tuple_mutability;
terr_record_size(uint, uint);
terr_record_mutability;
- terr_record_fields(ast.ident,ast.ident);
+ terr_record_fields(ast::ident,ast::ident);
terr_meth_count;
- terr_obj_meths(ast.ident,ast.ident);
+ terr_obj_meths(ast::ident,ast::ident);
terr_arg_count;
}
type ty_param_count_and_ty = tup(uint, t);
-type type_cache = hashmap[ast.def_id,ty_param_count_and_ty];
+type type_cache = hashmap[ast::def_id,ty_param_count_and_ty];
const uint idx_nil = 0u;
const uint idx_bool = 1u;
@@ -165,7 +165,7 @@ type type_store = rec(mutable vec[raw_t] others,
fn mk_type_store() -> @type_store {
let vec[raw_t] others = vec();
let hashmap[raw_t,uint] ost =
- Map.mk_hashmap[raw_t,uint](hash_raw_ty, eq_raw_ty);
+ map::mk_hashmap[raw_t,uint](hash_raw_ty, eq_raw_ty);
auto ts = @rec(mutable others=others, other_structural=ost);
@@ -190,7 +190,7 @@ fn mk_type_store() -> @type_store {
intern(ts, ty_native, none[str]);
intern(ts, ty_type, none[str]);
- assert Vec.len(ts.others) == idx_first_others;
+ assert _vec::len(ts.others) == idx_first_others;
ret ts;
}
@@ -207,22 +207,22 @@ fn mk_rcache() -> creader_cache {
}
auto h = hash_cache_entry;
auto e = eq_cache_entries;
- ret Map.mk_hashmap[tup(int,uint,uint),t](h, e);
+ ret map::mk_hashmap[tup(int,uint,uint),t](h, e);
}
-fn mk_ctxt(session.session s, resolve.def_map dm) -> ctxt {
+fn mk_ctxt(session::session s, resolve::def_map dm) -> ctxt {
ret rec(ts = mk_type_store(),
sess = s,
def_map = dm,
rcache = mk_rcache(),
short_names_cache =
- Map.mk_hashmap[ty.t,str](ty.hash_ty, ty.eq_ty));
+ map::mk_hashmap[ty::t,str](ty::hash_ty, ty::eq_ty));
}
// Type constructors
-fn mk_raw_ty(&@type_store ts, &sty st, &Option.t[str] cname) -> raw_t {
+fn mk_raw_ty(&@type_store ts, &sty st, &option::t[str] cname) -> raw_t {
auto h = hash_type_info(st, cname);
let bool has_params = false;
@@ -352,16 +352,16 @@ fn mk_raw_ty(&@type_store ts, &sty st, &Option.t[str] cname) -> raw_t {
}
fn intern_raw_ty(&@type_store ts, &raw_t rt) {
- auto type_num = Vec.len[raw_t](ts.others);
+ auto type_num = _vec::len[raw_t](ts.others);
ts.others += vec(rt);
ts.other_structural.insert(rt, type_num);
}
-fn intern(&@type_store ts, &sty st, &Option.t[str] cname) {
+fn intern(&@type_store ts, &sty st, &option::t[str] cname) {
intern_raw_ty(ts, mk_raw_ty(ts, st, cname));
}
-fn gen_ty_full(&ctxt cx, &sty st, &Option.t[str] cname) -> t {
+fn gen_ty_full(&ctxt cx, &sty st, &option::t[str] cname) -> t {
auto raw_type = mk_raw_ty(cx.ts, st, cname);
// Is it interned?
@@ -370,8 +370,8 @@ fn gen_ty_full(&ctxt cx, &sty st, &Option.t[str] cname) -> t {
ret typ;
}
case (none[t]) {
- // Nope. Insert it and return.
- auto type_num = Vec.len[raw_t](cx.ts.others);
+ // Nope: Insert it and return.
+ auto type_num = _vec::len[raw_t](cx.ts.others);
intern_raw_ty(cx.ts, raw_type);
// log_err "added: " + ty_to_str(tystore, raw_type);
ret type_num;
@@ -391,7 +391,7 @@ fn mk_int(&ctxt cx) -> t { ret idx_int; }
fn mk_float(&ctxt cx) -> t { ret idx_float; }
fn mk_uint(&ctxt cx) -> t { ret idx_uint; }
-fn mk_mach(&ctxt cx, &util.common.ty_mach tm) -> t {
+fn mk_mach(&ctxt cx, &util::common::ty_mach tm) -> t {
alt (tm) {
case (ty_u8) { ret idx_u8; }
case (ty_u16) { ret idx_u16; }
@@ -412,7 +412,7 @@ fn mk_mach(&ctxt cx, &util.common.ty_mach tm) -> t {
fn mk_char(&ctxt cx) -> t { ret idx_char; }
fn mk_str(&ctxt cx) -> t { ret idx_str; }
-fn mk_tag(&ctxt cx, &ast.def_id did, &vec[t] tys) -> t {
+fn mk_tag(&ctxt cx, &ast::def_id did, &vec[t] tys) -> t {
ret gen_ty(cx, ty_tag(did, tys));
}
@@ -421,7 +421,7 @@ fn mk_box(&ctxt cx, &mt tm) -> t {
}
fn mk_imm_box(&ctxt cx, &t ty) -> t {
- ret mk_box(cx, rec(ty=ty, mut=ast.imm));
+ ret mk_box(cx, rec(ty=ty, mut=ast::imm));
}
fn mk_vec(&ctxt cx, &mt tm) -> t { ret gen_ty(cx, ty_vec(tm)); }
@@ -433,20 +433,20 @@ fn mk_tup(&ctxt cx, &vec[mt] tms) -> t { ret gen_ty(cx, ty_tup(tms)); }
fn mk_imm_tup(&ctxt cx, &vec[t] tys) -> t {
// TODO: map
- let vec[ty.mt] mts = vec();
+ let vec[ty::mt] mts = vec();
for (t typ in tys) {
- mts += vec(rec(ty=typ, mut=ast.imm));
+ mts += vec(rec(ty=typ, mut=ast::imm));
}
ret mk_tup(cx, mts);
}
fn mk_rec(&ctxt cx, &vec[field] fs) -> t { ret gen_ty(cx, ty_rec(fs)); }
-fn mk_fn(&ctxt cx, &ast.proto proto, &vec[arg] args, &t ty) -> t {
+fn mk_fn(&ctxt cx, &ast::proto proto, &vec[arg] args, &t ty) -> t {
ret gen_ty(cx, ty_fn(proto, args, ty));
}
-fn mk_native_fn(&ctxt cx, &ast.native_abi abi, &vec[arg] args, &t ty) -> t {
+fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &vec[arg] args, &t ty) -> t {
ret gen_ty(cx, ty_native_fn(abi, args, ty));
}
@@ -458,7 +458,7 @@ fn mk_var(&ctxt cx, int v) -> t {
ret gen_ty(cx, ty_var(v));
}
-fn mk_local(&ctxt cx, ast.def_id did) -> t {
+fn mk_local(&ctxt cx, ast::def_id did) -> t {
ret gen_ty(cx, ty_local(did));
}
@@ -478,17 +478,17 @@ fn mk_native(&ctxt cx) -> t { ret idx_native; }
fn struct(&ctxt cx, &t typ) -> sty { ret cx.ts.others.(typ).struct; }
// Returns the canonical name of the given type.
-fn cname(&ctxt cx, &t typ) -> Option.t[str] { ret cx.ts.others.(typ).cname; }
+fn cname(&ctxt cx, &t typ) -> option::t[str] { ret cx.ts.others.(typ).cname; }
// Stringification
-fn path_to_str(&ast.path pth) -> str {
- auto result = Str.connect(pth.node.idents, "::");
- if (Vec.len[@ast.ty](pth.node.types) > 0u) {
- auto f = pretty.pprust.ty_to_str;
+fn path_to_str(&ast::path pth) -> str {
+ auto result = _str::connect(pth.node.idents, "::");
+ if (_vec::len[@ast::ty](pth.node.types) > 0u) {
+ auto f = pretty::pprust::ty_to_str;
result += "[";
- result += Str.connect(Vec.map[@ast.ty,str](f, pth.node.types), ",");
+ result += _str::connect(_vec::map(f, pth.node.types), ",");
result += "]";
}
ret result;
@@ -508,23 +508,23 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
}
fn fn_to_str(ctxt cx,
- ast.proto proto,
- Option.t[ast.ident] ident,
+ ast::proto proto,
+ option::t[ast::ident] ident,
vec[arg] inputs, t output) -> str {
auto f = bind fn_input_to_str(cx, _);
auto s;
alt (proto) {
- case (ast.proto_iter) {
+ case (ast::proto_iter) {
s = "iter";
}
- case (ast.proto_fn) {
+ case (ast::proto_fn) {
s = "fn";
}
}
alt (ident) {
- case (some[ast.ident](?i)) {
+ case (some[ast::ident](?i)) {
s += " ";
s += i;
}
@@ -532,7 +532,7 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
}
s += "(";
- s += Str.connect(Vec.map[arg,str](f, inputs), ", ");
+ s += _str::connect(_vec::map[arg,str](f, inputs), ", ");
s += ")";
if (struct(cx, output) != ty_nil) {
@@ -542,7 +542,7 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
}
fn method_to_str(ctxt cx, &method m) -> str {
- ret fn_to_str(cx, m.proto, some[ast.ident](m.ident),
+ ret fn_to_str(cx, m.proto, some[ast::ident](m.ident),
m.inputs, m.output) + ";";
}
@@ -553,9 +553,9 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
fn mt_to_str(ctxt cx, &mt m) -> str {
auto mstr;
alt (m.mut) {
- case (ast.mut) { mstr = "mutable "; }
- case (ast.imm) { mstr = ""; }
- case (ast.maybe_mut) { mstr = "mutable? "; }
+ case (ast::mut) { mstr = "mutable "; }
+ case (ast::imm) { mstr = ""; }
+ case (ast::maybe_mut) { mstr = "mutable? "; }
}
ret mstr + ty_to_str(cx, m.ty);
@@ -577,7 +577,7 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
case (ty_int) { s += "int"; }
case (ty_float) { s += "float"; }
case (ty_uint) { s += "uint"; }
- case (ty_machine(?tm)) { s += common.ty_mach_to_str(tm); }
+ case (ty_machine(?tm)) { s += common::ty_mach_to_str(tm); }
case (ty_char) { s += "char"; }
case (ty_str) { s += "str"; }
case (ty_box(?tm)) { s += "@" + mt_to_str(cx, tm); }
@@ -588,56 +588,58 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
case (ty_tup(?elems)) {
auto f = bind mt_to_str(cx, _);
- auto strs = Vec.map[mt,str](f, elems);
- s += "tup(" + Str.connect(strs, ",") + ")";
+ auto strs = _vec::map[mt,str](f, elems);
+ s += "tup(" + _str::connect(strs, ",") + ")";
}
case (ty_rec(?elems)) {
auto f = bind field_to_str(cx, _);
- auto strs = Vec.map[field,str](f, elems);
- s += "rec(" + Str.connect(strs, ",") + ")";
+ auto strs = _vec::map[field,str](f, elems);
+ s += "rec(" + _str::connect(strs, ",") + ")";
}
case (ty_tag(?id, ?tps)) {
// The user should never see this if the cname is set properly!
- s += "<tag#" + util.common.istr(id._0) + ":" +
- util.common.istr(id._1) + ">";
- if (Vec.len[t](tps) > 0u) {
+ s += "<tag#" + util::common::istr(id._0) + ":" +
+ util::common::istr(id._1) + ">";
+ if (_vec::len[t](tps) > 0u) {
auto f = bind ty_to_str(cx, _);
- auto strs = Vec.map[t,str](f, tps);
- s += "[" + Str.connect(strs, ",") + "]";
+ auto strs = _vec::map[t,str](f, tps);
+ s += "[" + _str::connect(strs, ",") + "]";
}
}
case (ty_fn(?proto, ?inputs, ?output)) {
- s += fn_to_str(cx, proto, none[ast.ident], inputs, output);
+ s += fn_to_str(cx, proto, none[ast::ident], inputs, output);
}
case (ty_native_fn(_, ?inputs, ?output)) {
- s += fn_to_str(cx, ast.proto_fn, none[ast.ident], inputs, output);
+ s += fn_to_str(cx, ast::proto_fn, none[ast::ident],
+ inputs, output);
}
case (ty_obj(?meths)) {
auto f = bind method_to_str(cx, _);
- auto m = Vec.map[method,str](f, meths);
- s += "obj {\n\t" + Str.connect(m, "\n\t") + "\n}";
+ auto m = _vec::map[method,str](f, meths);
+ s += "obj {\n\t" + _str::connect(m, "\n\t") + "\n}";
}
case (ty_var(?v)) {
- s += "<T" + util.common.istr(v) + ">";
+ s += "<T" + util::common::istr(v) + ">";
}
case (ty_local(?id)) {
- s += "<L" + util.common.istr(id._0) + ":" +
- util.common.istr(id._1) + ">";
+ s += "<L" + util::common::istr(id._0) + ":" +
+ util::common::istr(id._1) + ">";
}
case (ty_param(?id)) {
- s += "'" + Str.unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
+ s += "'" + _str::unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
}
case (ty_bound_param(?id)) {
- s += "''" + Str.unsafe_from_bytes(vec(('a' as u8) + (id as u8)));
+ s += "''" + _str::unsafe_from_bytes(vec(('a' as u8) +
+ (id as u8)));
}
}
@@ -646,9 +648,9 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
fn ty_to_short_str(ctxt cx, t typ) -> str {
auto f = def_to_str;
- auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata.ac_no_abbrevs);
- auto s = metadata.Encode.ty_str(ecx, typ);
- if (Str.byte_len(s) >= 32u) { s = Str.substr(s, 0u, 32u); }
+ auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::ac_no_abbrevs);
+ auto s = metadata::Encode::ty_str(ecx, typ);
+ if (_str::byte_len(s) >= 32u) { s = _str::substr(s, 0u, 32u); }
ret s;
}
@@ -862,7 +864,7 @@ fn type_is_sequence(&ctxt cx, &t ty) -> bool {
fn sequence_element_type(&ctxt cx, &t ty) -> t {
alt (struct(cx, ty)) {
- case (ty_str) { ret mk_mach(cx, common.ty_u8); }
+ case (ty_str) { ret mk_mach(cx, common::ty_u8); }
case (ty_vec(?mt)) { ret mt.ty; }
}
fail;
@@ -943,14 +945,14 @@ fn type_has_dynamic_size(&ctxt cx, &t ty) -> bool {
alt (struct(cx, ty)) {
case (ty_tup(?mts)) {
auto i = 0u;
- while (i < Vec.len[mt](mts)) {
+ while (i < _vec::len[mt](mts)) {
if (type_has_dynamic_size(cx, mts.(i).ty)) { ret true; }
i += 1u;
}
}
case (ty_rec(?fields)) {
auto i = 0u;
- while (i < Vec.len[field](fields)) {
+ while (i < _vec::len[field](fields)) {
if (type_has_dynamic_size(cx, fields.(i).mt.ty)) {
ret true;
}
@@ -959,7 +961,7 @@ fn type_has_dynamic_size(&ctxt cx, &t ty) -> bool {
}
case (ty_tag(_, ?subtys)) {
auto i = 0u;
- while (i < Vec.len[t](subtys)) {
+ while (i < _vec::len[t](subtys)) {
if (type_has_dynamic_size(cx, subtys.(i))) { ret true; }
i += 1u;
}
@@ -976,15 +978,15 @@ fn type_is_integral(&ctxt cx, &t ty) -> bool {
case (ty_uint) { ret true; }
case (ty_machine(?m)) {
alt (m) {
- case (common.ty_i8) { ret true; }
- case (common.ty_i16) { ret true; }
- case (common.ty_i32) { ret true; }
- case (common.ty_i64) { ret true; }
-
- case (common.ty_u8) { ret true; }
- case (common.ty_u16) { ret true; }
- case (common.ty_u32) { ret true; }
- case (common.ty_u64) { ret true; }
+ case (common::ty_i8) { ret true; }
+ case (common::ty_i16) { ret true; }
+ case (common::ty_i32) { ret true; }
+ case (common::ty_i64) { ret true; }
+
+ case (common::ty_u8) { ret true; }
+ case (common::ty_u16) { ret true; }
+ case (common::ty_u32) { ret true; }
+ case (common::ty_u64) { ret true; }
case (_) { ret false; }
}
}
@@ -998,8 +1000,8 @@ fn type_is_fp(&ctxt cx, &t ty) -> bool {
alt (struct(cx, ty)) {
case (ty_machine(?tm)) {
alt (tm) {
- case (common.ty_f32) { ret true; }
- case (common.ty_f64) { ret true; }
+ case (common::ty_f32) { ret true; }
+ case (common::ty_f64) { ret true; }
case (_) { ret false; }
}
}
@@ -1016,10 +1018,10 @@ fn type_is_signed(&ctxt cx, &t ty) -> bool {
case (ty_int) { ret true; }
case (ty_machine(?tm)) {
alt (tm) {
- case (common.ty_i8) { ret true; }
- case (common.ty_i16) { ret true; }
- case (common.ty_i32) { ret true; }
- case (common.ty_i64) { ret true; }
+ case (common::ty_i8) { ret true; }
+ case (common::ty_i16) { ret true; }
+ case (common::ty_i32) { ret true; }
+ case (common::ty_i64) { ret true; }
case (_) { ret false; }
}
}
@@ -1028,7 +1030,7 @@ fn type_is_signed(&ctxt cx, &t ty) -> bool {
fail;
}
-fn type_param(&ctxt cx, &t ty) -> Option.t[uint] {
+fn type_param(&ctxt cx, &t ty) -> option::t[uint] {
alt (struct(cx, ty)) {
case (ty_param(?id)) { ret some[uint](id); }
case (_) { /* fall through */ }
@@ -1036,7 +1038,7 @@ fn type_param(&ctxt cx, &t ty) -> Option.t[uint] {
ret none[uint];
}
-fn def_to_str(&ast.def_id did) -> str {
+fn def_to_str(&ast::def_id did) -> str {
ret #fmt("%d:%d", did._0, did._1);
}
@@ -1050,7 +1052,7 @@ fn hash_type_structure(&sty st) -> uint {
ret h;
}
- fn hash_def(uint id, ast.def_id did) -> uint {
+ fn hash_def(uint id, ast::def_id did) -> uint {
auto h = id;
h += h << 5u + (did._0 as uint);
h += h << 5u + (did._1 as uint);
@@ -1080,18 +1082,18 @@ fn hash_type_structure(&sty st) -> uint {
case (ty_uint) { ret 4u; }
case (ty_machine(?tm)) {
alt (tm) {
- case (common.ty_i8) { ret 5u; }
- case (common.ty_i16) { ret 6u; }
- case (common.ty_i32) { ret 7u; }
- case (common.ty_i64) { ret 8u; }
+ case (common::ty_i8) { ret 5u; }
+ case (common::ty_i16) { ret 6u; }
+ case (common::ty_i32) { ret 7u; }
+ case (common::ty_i64) { ret 8u; }
- case (common.ty_u8) { ret 9u; }
- case (common.ty_u16) { ret 10u; }
- case (common.ty_u32) { ret 11u; }
- case (common.ty_u64) { ret 12u; }
+ case (common::ty_u8) { ret 9u; }
+ case (common::ty_u16) { ret 10u; }
+ case (common::ty_u32) { ret 11u; }
+ case (common::ty_u64) { ret 12u; }
- case (common.ty_f32) { ret 13u; }
- case (common.ty_f64) { ret 14u; }
+ case (common::ty_f32) { ret 13u; }
+ case (common::ty_f64) { ret 14u; }
}
}
case (ty_char) { ret 15u; }
@@ -1127,7 +1129,7 @@ fn hash_type_structure(&sty st) -> uint {
case (ty_obj(?methods)) {
auto h = 27u;
for (method m in methods) {
- h += h << 5u + Str.hash(m.ident);
+ h += h << 5u + _str::hash(m.ident);
}
ret h;
}
@@ -1140,11 +1142,11 @@ fn hash_type_structure(&sty st) -> uint {
}
}
-fn hash_type_info(&sty st, &Option.t[str] cname_opt) -> uint {
+fn hash_type_info(&sty st, &option::t[str] cname_opt) -> uint {
auto h = hash_type_structure(st);
alt (cname_opt) {
case (none[str]) { /* no-op */ }
- case (some[str](?s)) { h += h << 5u + Str.hash(s); }
+ case (some[str](?s)) { h += h << 5u + _str::hash(s); }
}
ret h;
}
@@ -1165,8 +1167,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
&vec[arg] args_b, &t rty_b) -> bool {
if (!eq_ty(rty_a, rty_b)) { ret false; }
- auto len = Vec.len[arg](args_a);
- if (len != Vec.len[arg](args_b)) { ret false; }
+ auto len = _vec::len[arg](args_a);
+ if (len != _vec::len[arg](args_b)) { ret false; }
auto i = 0u;
while (i < len) {
@@ -1178,7 +1180,7 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
ret true;
}
- fn equal_def(&ast.def_id did_a, &ast.def_id did_b) -> bool {
+ fn equal_def(&ast::def_id did_a, &ast::def_id did_b) -> bool {
ret did_a._0 == did_b._0 && did_a._1 == did_b._1;
}
@@ -1238,8 +1240,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_tag(?id_b, ?tys_b)) {
if (!equal_def(id_a, id_b)) { ret false; }
- auto len = Vec.len[t](tys_a);
- if (len != Vec.len[t](tys_b)) { ret false; }
+ auto len = _vec::len[t](tys_a);
+ if (len != _vec::len[t](tys_b)) { ret false; }
auto i = 0u;
while (i < len) {
if (!eq_ty(tys_a.(i), tys_b.(i))) { ret false; }
@@ -1283,8 +1285,8 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_tup(?mts_a)) {
alt (b) {
case (ty_tup(?mts_b)) {
- auto len = Vec.len[mt](mts_a);
- if (len != Vec.len[mt](mts_b)) { ret false; }
+ auto len = _vec::len[mt](mts_a);
+ if (len != _vec::len[mt](mts_b)) { ret false; }
auto i = 0u;
while (i < len) {
if (!equal_mt(mts_a.(i), mts_b.(i))) { ret false; }
@@ -1298,12 +1300,12 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_rec(?flds_a)) {
alt (b) {
case (ty_rec(?flds_b)) {
- auto len = Vec.len[field](flds_a);
- if (len != Vec.len[field](flds_b)) { ret false; }
+ auto len = _vec::len[field](flds_a);
+ if (len != _vec::len[field](flds_b)) { ret false; }
auto i = 0u;
while (i < len) {
auto fld_a = flds_a.(i); auto fld_b = flds_b.(i);
- if (!Str.eq(fld_a.ident, fld_b.ident) ||
+ if (!_str::eq(fld_a.ident, fld_b.ident) ||
!equal_mt(fld_a.mt, fld_b.mt)) {
ret false;
}
@@ -1335,13 +1337,13 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
case (ty_obj(?methods_a)) {
alt (b) {
case (ty_obj(?methods_b)) {
- auto len = Vec.len[method](methods_a);
- if (len != Vec.len[method](methods_b)) { ret false; }
+ auto len = _vec::len[method](methods_a);
+ if (len != _vec::len[method](methods_b)) { ret false; }
auto i = 0u;
while (i < len) {
auto m_a = methods_a.(i); auto m_b = methods_b.(i);
if (m_a.proto != m_b.proto ||
- !Str.eq(m_a.ident, m_b.ident) ||
+ !_str::eq(m_a.ident, m_b.ident) ||
!equal_fn(m_a.inputs, m_a.output,
m_b.inputs, m_b.output)) {
ret false;
@@ -1413,7 +1415,7 @@ fn eq_raw_ty(&raw_t a, &raw_t b) -> bool {
case (some[str](?s_a)) {
alt (b.cname) {
case (some[str](?s_b)) {
- if (!Str.eq(s_a, s_b)) { ret false; }
+ if (!_str::eq(s_a, s_b)) { ret false; }
}
case (_) { ret false; }
}
@@ -1429,25 +1431,25 @@ fn eq_raw_ty(&raw_t a, &raw_t b) -> bool {
fn eq_ty(&t a, &t b) -> bool { ret a == b; }
-fn ann_to_type(&ast.ann ann) -> t {
+fn ann_to_type(&ast::ann ann) -> t {
alt (ann) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log_err "ann_to_type() called on node with no type";
fail;
}
- case (ast.ann_type(_, ?ty, _, _)) {
+ case (ast::ann_type(_, ?ty, _, _)) {
ret ty;
}
}
}
-fn ann_to_type_params(&ast.ann ann) -> vec[t] {
+fn ann_to_type_params(&ast::ann ann) -> vec[t] {
alt (ann) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log_err "ann_to_type_params() called on node with no type params";
fail;
}
- case (ast.ann_type(_, _, ?tps, _)) {
+ case (ast::ann_type(_, _, ?tps, _)) {
alt (tps) {
case (none[vec[t]]) {
let vec[t] result = vec();
@@ -1461,15 +1463,15 @@ fn ann_to_type_params(&ast.ann ann) -> vec[t] {
// Returns the type of an annotation, with type parameter substitutions
// performed if applicable.
-fn ann_to_monotype(ctxt cx, ast.ann a) -> t {
+fn ann_to_monotype(ctxt cx, ast::ann a) -> t {
// TODO: Refactor to use recursive pattern matching when we're more
// confident that it works.
alt (a) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log_err "ann_to_monotype() called on expression with no type!";
fail;
}
- case (ast.ann_type(_, ?typ, ?tps_opt, _)) {
+ case (ast::ann_type(_, ?typ, ?tps_opt, _)) {
alt (tps_opt) {
case (none[vec[t]]) { ret typ; }
case (some[vec[t]](?tps)) {
@@ -1481,8 +1483,8 @@ fn ann_to_monotype(ctxt cx, ast.ann a) -> t {
}
// Turns a type into an ann_type, using defaults for other fields.
-fn triv_ann(&ast.ann old, t typ) -> ast.ann {
- ret ast.ann_type(ast.ann_tag(old), typ, none[vec[t]], none[@ts_ann]);
+fn triv_ann(&ast::ann old, t typ) -> ast::ann {
+ ret ast::ann_type(ast::ann_tag(old), typ, none[vec[t]], none[@ts_ann]);
}
// Returns the number of distinct type parameters in the given type.
@@ -1508,7 +1510,7 @@ fn count_ty_params(ctxt cx, t ty) -> uint {
let @mutable vec[uint] param_indices = @mutable v;
auto f = bind counter(cx, param_indices, _);
walk_ty(cx, f, ty);
- ret Vec.len[uint](*param_indices);
+ ret _vec::len[uint](*param_indices);
}
fn type_contains_vars(&ctxt cx, &t typ) -> bool {
@@ -1531,38 +1533,38 @@ fn type_contains_bound_params(&ctxt cx, &t typ) -> bool {
fn ty_fn_args(&ctxt cx, &t fty) -> vec[arg] {
alt (struct(cx, fty)) {
- case (ty.ty_fn(_, ?a, _)) { ret a; }
- case (ty.ty_native_fn(_, ?a, _)) { ret a; }
+ case (ty::ty_fn(_, ?a, _)) { ret a; }
+ case (ty::ty_native_fn(_, ?a, _)) { ret a; }
}
fail;
}
-fn ty_fn_proto(&ctxt cx, &t fty) -> ast.proto {
+fn ty_fn_proto(&ctxt cx, &t fty) -> ast::proto {
alt (struct(cx, fty)) {
- case (ty.ty_fn(?p, _, _)) { ret p; }
+ case (ty::ty_fn(?p, _, _)) { ret p; }
}
fail;
}
-fn ty_fn_abi(&ctxt cx, &t fty) -> ast.native_abi {
+fn ty_fn_abi(&ctxt cx, &t fty) -> ast::native_abi {
alt (struct(cx, fty)) {
- case (ty.ty_native_fn(?a, _, _)) { ret a; }
+ case (ty::ty_native_fn(?a, _, _)) { ret a; }
}
fail;
}
fn ty_fn_ret(&ctxt cx, &t fty) -> t {
alt (struct(cx, fty)) {
- case (ty.ty_fn(_, _, ?r)) { ret r; }
- case (ty.ty_native_fn(_, _, ?r)) { ret r; }
+ case (ty::ty_fn(_, _, ?r)) { ret r; }
+ case (ty::ty_native_fn(_, _, ?r)) { ret r; }
}
fail;
}
fn is_fn_ty(&ctxt cx, &t fty) -> bool {
alt (struct(cx, fty)) {
- case (ty.ty_fn(_, _, _)) { ret true; }
- case (ty.ty_native_fn(_, _, _)) { ret true; }
+ case (ty::ty_fn(_, _, _)) { ret true; }
+ case (ty::ty_native_fn(_, _, _)) { ret true; }
case (_) { ret false; }
}
ret false;
@@ -1573,43 +1575,43 @@ fn is_fn_ty(&ctxt cx, &t fty) -> bool {
// Given an item, returns the associated type as well as the number of type
// parameters it has.
-fn native_item_ty(&@ast.native_item it) -> ty_param_count_and_ty {
+fn native_item_ty(&@ast::native_item it) -> ty_param_count_and_ty {
auto ty_param_count;
auto result_ty;
alt (it.node) {
- case (ast.native_item_fn(_, _, _, ?tps, _, ?ann)) {
- ty_param_count = Vec.len[ast.ty_param](tps);
+ case (ast::native_item_fn(_, _, _, ?tps, _, ?ann)) {
+ ty_param_count = _vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ann);
}
}
ret tup(ty_param_count, result_ty);
}
-fn item_ty(&@ast.item it) -> ty_param_count_and_ty {
+fn item_ty(&@ast::item it) -> ty_param_count_and_ty {
auto ty_param_count;
auto result_ty;
alt (it.node) {
- case (ast.item_const(_, _, _, _, ?ann)) {
+ case (ast::item_const(_, _, _, _, ?ann)) {
ty_param_count = 0u;
result_ty = ann_to_type(ann);
}
- case (ast.item_fn(_, _, ?tps, _, ?ann)) {
- ty_param_count = Vec.len[ast.ty_param](tps);
+ case (ast::item_fn(_, _, ?tps, _, ?ann)) {
+ ty_param_count = _vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ann);
}
- case (ast.item_mod(_, _, _)) {
+ case (ast::item_mod(_, _, _)) {
fail; // modules are typeless
}
- case (ast.item_ty(_, _, ?tps, _, ?ann)) {
- ty_param_count = Vec.len[ast.ty_param](tps);
+ case (ast::item_ty(_, _, ?tps, _, ?ann)) {
+ ty_param_count = _vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ann);
}
- case (ast.item_tag(_, _, ?tps, ?did, ?ann)) {
- ty_param_count = Vec.len[ast.ty_param](tps);
+ case (ast::item_tag(_, _, ?tps, ?did, ?ann)) {
+ ty_param_count = _vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ann);
}
- case (ast.item_obj(_, _, ?tps, _, ?ann)) {
- ty_param_count = Vec.len[ast.ty_param](tps);
+ case (ast::item_obj(_, _, ?tps, _, ?ann)) {
+ ty_param_count = _vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ann);
}
}
@@ -1617,9 +1619,9 @@ fn item_ty(&@ast.item it) -> ty_param_count_and_ty {
ret tup(ty_param_count, result_ty);
}
-fn stmt_ty(&ctxt cx, &@ast.stmt s) -> t {
+fn stmt_ty(&ctxt cx, &@ast::stmt s) -> t {
alt (s.node) {
- case (ast.stmt_expr(?e,_)) {
+ case (ast::stmt_expr(?e,_)) {
ret expr_ty(cx, e);
}
case (_) {
@@ -1628,133 +1630,133 @@ fn stmt_ty(&ctxt cx, &@ast.stmt s) -> t {
}
}
-fn block_ty(&ctxt cx, &ast.block b) -> t {
+fn block_ty(&ctxt cx, &ast::block b) -> t {
alt (b.node.expr) {
- case (some[@ast.expr](?e)) { ret expr_ty(cx, e); }
- case (none[@ast.expr]) { ret mk_nil(cx); }
+ case (some[@ast::expr](?e)) { ret expr_ty(cx, e); }
+ case (none[@ast::expr]) { ret mk_nil(cx); }
}
}
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
// doesn't provide type parameter substitutions.
-fn pat_ty(&ctxt cx, &@ast.pat pat) -> t {
+fn pat_ty(&ctxt cx, &@ast::pat pat) -> t {
alt (pat.node) {
- case (ast.pat_wild(?ann)) { ret ann_to_monotype(cx, ann); }
- case (ast.pat_lit(_, ?ann)) { ret ann_to_monotype(cx, ann); }
- case (ast.pat_bind(_, _, ?ann)) { ret ann_to_monotype(cx, ann); }
- case (ast.pat_tag(_, _, ?ann)) { ret ann_to_monotype(cx, ann); }
+ case (ast::pat_wild(?ann)) { ret ann_to_monotype(cx, ann); }
+ case (ast::pat_lit(_, ?ann)) { ret ann_to_monotype(cx, ann); }
+ case (ast::pat_bind(_, _, ?ann)) { ret ann_to_monotype(cx, ann); }
+ case (ast::pat_tag(_, _, ?ann)) { ret ann_to_monotype(cx, ann); }
}
fail; // not reached
}
-fn expr_ann(&@ast.expr e) -> ast.ann {
+fn expr_ann(&@ast::expr e) -> ast::ann {
alt(e.node) {
- case (ast.expr_vec(_,_,?a)) {
+ case (ast::expr_vec(_,_,?a)) {
ret a;
}
- case (ast.expr_tup(_,?a)) {
+ case (ast::expr_tup(_,?a)) {
ret a;
}
- case (ast.expr_rec(_,_,?a)) {
+ case (ast::expr_rec(_,_,?a)) {
ret a;
}
- case (ast.expr_call(_,_,?a)) {
+ case (ast::expr_call(_,_,?a)) {
ret a;
}
- case (ast.expr_bind(_,_,?a)) {
+ case (ast::expr_bind(_,_,?a)) {
ret a;
}
- case (ast.expr_binary(_,_,_,?a)) {
+ case (ast::expr_binary(_,_,_,?a)) {
ret a;
}
- case (ast.expr_unary(_,_,?a)) {
+ case (ast::expr_unary(_,_,?a)) {
ret a;
}
- case (ast.expr_lit(_,?a)) {
+ case (ast::expr_lit(_,?a)) {
ret a;
}
- case (ast.expr_cast(_,_,?a)) {
+ case (ast::expr_cast(_,_,?a)) {
ret a;
}
- case (ast.expr_if(_,_,_,?a)) {
+ case (ast::expr_if(_,_,_,?a)) {
ret a;
}
- case (ast.expr_while(_,_,?a)) {
+ case (ast::expr_while(_,_,?a)) {
ret a;
}
- case (ast.expr_for(_,_,_,?a)) {
+ case (ast::expr_for(_,_,_,?a)) {
ret a;
}
- case (ast.expr_for_each(_,_,_,?a)) {
+ case (ast::expr_for_each(_,_,_,?a)) {
ret a;
}
- case (ast.expr_do_while(_,_,?a)) {
+ case (ast::expr_do_while(_,_,?a)) {
ret a;
}
- case (ast.expr_alt(_,_,?a)) {
+ case (ast::expr_alt(_,_,?a)) {
ret a;
}
- case (ast.expr_block(_,?a)) {
+ case (ast::expr_block(_,?a)) {
ret a;
}
- case (ast.expr_assign(_,_,?a)) {
+ case (ast::expr_assign(_,_,?a)) {
ret a;
}
- case (ast.expr_assign_op(_,_,_,?a)) {
+ case (ast::expr_assign_op(_,_,_,?a)) {
ret a;
}
- case (ast.expr_send(_,_,?a)) {
+ case (ast::expr_send(_,_,?a)) {
ret a;
}
- case (ast.expr_recv(_,_,?a)) {
+ case (ast::expr_recv(_,_,?a)) {
ret a;
}
- case (ast.expr_field(_,_,?a)) {
+ case (ast::expr_field(_,_,?a)) {
ret a;
}
- case (ast.expr_index(_,_,?a)) {
+ case (ast::expr_index(_,_,?a)) {
ret a;
}
- case (ast.expr_path(_,?a)) {
+ case (ast::expr_path(_,?a)) {
ret a;
}
- case (ast.expr_ext(_,_,_,_,?a)) {
+ case (ast::expr_ext(_,_,_,_,?a)) {
ret a;
}
- case (ast.expr_fail(?a)) {
+ case (ast::expr_fail(?a)) {
ret a;
}
- case (ast.expr_ret(_,?a)) {
+ case (ast::expr_ret(_,?a)) {
ret a;
}
- case (ast.expr_put(_,?a)) {
+ case (ast::expr_put(_,?a)) {
ret a;
}
- case (ast.expr_be(_,?a)) {
+ case (ast::expr_be(_,?a)) {
ret a;
}
- case (ast.expr_log(_,_,?a)) {
+ case (ast::expr_log(_,_,?a)) {
ret a;
}
- case (ast.expr_assert(_,?a)) {
+ case (ast::expr_assert(_,?a)) {
ret a;
}
- case (ast.expr_check(_,?a)) {
+ case (ast::expr_check(_,?a)) {
ret a;
}
- case (ast.expr_port(?a)) {
+ case (ast::expr_port(?a)) {
ret a;
}
- case (ast.expr_chan(_,?a)) {
+ case (ast::expr_chan(_,?a)) {
ret a;
}
- case (ast.expr_break(?a)) {
+ case (ast::expr_break(?a)) {
ret a;
}
- case (ast.expr_cont(?a)) {
+ case (ast::expr_cont(?a)) {
ret a;
}
- case (ast.expr_self_method(_, ?a)) {
+ case (ast::expr_self_method(_, ?a)) {
ret a;
}
}
@@ -1766,29 +1768,29 @@ fn expr_ann(&@ast.expr e) -> ast.ann {
// ask for the type of "id" in "id(3)", it will return "fn(&int) -> int"
// instead of "fn(&T) -> T with T = int". If this isn't what you want, see
// expr_ty_params_and_ty() below.
-fn expr_ty(&ctxt cx, &@ast.expr expr) -> t {
+fn expr_ty(&ctxt cx, &@ast::expr expr) -> t {
ret ann_to_monotype(cx, expr_ann(expr));
}
-fn expr_ty_params_and_ty(&ctxt cx, &@ast.expr expr) -> tup(vec[t], t) {
+fn expr_ty_params_and_ty(&ctxt cx, &@ast::expr expr) -> tup(vec[t], t) {
auto a = expr_ann(expr);
ret tup(ann_to_type_params(a), ann_to_type(a));
}
-fn expr_has_ty_params(&@ast.expr expr) -> bool {
+fn expr_has_ty_params(&@ast::expr expr) -> bool {
// FIXME: Rewrite using complex patterns when they're trustworthy.
alt (expr_ann(expr)) {
- case (ast.ann_none(_)) { fail; }
- case (ast.ann_type(_, _, ?tps_opt, _)) {
- ret !Option.is_none[vec[t]](tps_opt);
+ case (ast::ann_none(_)) { fail; }
+ case (ast::ann_type(_, _, ?tps_opt, _)) {
+ ret !option::is_none[vec[t]](tps_opt);
}
}
}
// FIXME: At the moment this works only for call, bind, and path expressions.
-fn replace_expr_type(&@ast.expr expr,
- &tup(vec[t], t) new_tyt) -> @ast.expr {
+fn replace_expr_type(&@ast::expr expr,
+ &tup(vec[t], t) new_tyt) -> @ast::expr {
auto new_tps;
if (expr_has_ty_params(expr)) {
new_tps = some[vec[t]](new_tyt._0);
@@ -1796,35 +1798,35 @@ fn replace_expr_type(&@ast.expr expr,
new_tps = none[vec[t]];
}
- fn mkann_fn(t tyt, Option.t[vec[t]] tps, &ast.ann old_ann) -> ast.ann {
- ret ast.ann_type(ast.ann_tag(old_ann), tyt, tps, none[@ts_ann]);
+ fn mkann_fn(t tyt, option::t[vec[t]] tps, &ast::ann old_ann) -> ast::ann {
+ ret ast::ann_type(ast::ann_tag(old_ann), tyt, tps, none[@ts_ann]);
}
auto mkann = bind mkann_fn(new_tyt._1, new_tps, _);
alt (expr.node) {
- case (ast.expr_call(?callee, ?args, ?a)) {
- ret @fold.respan(expr.span,
- ast.expr_call(callee, args, mkann(a)));
+ case (ast::expr_call(?callee, ?args, ?a)) {
+ ret @fold::respan(expr.span,
+ ast::expr_call(callee, args, mkann(a)));
}
- case (ast.expr_self_method(?ident, ?a)) {
- ret @fold.respan(expr.span,
- ast.expr_self_method(ident, mkann(a)));
+ case (ast::expr_self_method(?ident, ?a)) {
+ ret @fold::respan(expr.span,
+ ast::expr_self_method(ident, mkann(a)));
}
- case (ast.expr_bind(?callee, ?args, ?a)) {
- ret @fold.respan(expr.span,
- ast.expr_bind(callee, args, mkann(a)));
+ case (ast::expr_bind(?callee, ?args, ?a)) {
+ ret @fold::respan(expr.span,
+ ast::expr_bind(callee, args, mkann(a)));
}
- case (ast.expr_field(?e, ?i, ?a)) {
- ret @fold.respan(expr.span,
- ast.expr_field(e, i, mkann(a)));
+ case (ast::expr_field(?e, ?i, ?a)) {
+ ret @fold::respan(expr.span,
+ ast::expr_field(e, i, mkann(a)));
}
- case (ast.expr_path(?p, ?a)) {
- ret @fold.respan(expr.span,
- ast.expr_path(p, mkann(a)));
+ case (ast::expr_path(?p, ?a)) {
+ ret @fold::respan(expr.span,
+ ast::expr_path(p, mkann(a)));
}
case (_) {
log_err "unhandled expr type in replace_expr_type(): " +
- util.common.expr_to_str(expr);
+ util::common::expr_to_str(expr);
fail;
}
}
@@ -1832,8 +1834,8 @@ fn replace_expr_type(&@ast.expr expr,
// Expression utilities
-fn field_num(&session.session sess, &span sp,
- &ast.ident id) -> uint {
+fn field_num(&session::session sess, &span sp,
+ &ast::ident id) -> uint {
let uint accum = 0u;
let uint i = 0u;
for (u8 c in id) {
@@ -1849,7 +1851,7 @@ fn field_num(&session.session sess, &span sp,
accum += (c as uint) - ('0' as uint);
} else {
auto s = "";
- s += Str.unsafe_from_byte(c);
+ s += _str::unsafe_from_byte(c);
sess.span_err(sp,
"bad numeric field on tuple: "
+ " non-digit character: "
@@ -1861,11 +1863,11 @@ fn field_num(&session.session sess, &span sp,
ret accum;
}
-fn field_idx(&session.session sess, &span sp,
- &ast.ident id, &vec[field] fields) -> uint {
+fn field_idx(&session::session sess, &span sp,
+ &ast::ident id, &vec[field] fields) -> uint {
let uint i = 0u;
for (field f in fields) {
- if (Str.eq(f.ident, id)) {
+ if (_str::eq(f.ident, id)) {
ret i;
}
i += 1u;
@@ -1874,11 +1876,11 @@ fn field_idx(&session.session sess, &span sp,
fail;
}
-fn method_idx(&session.session sess, &span sp,
- &ast.ident id, &vec[method] meths) -> uint {
+fn method_idx(&session::session sess, &span sp,
+ &ast::ident id, &vec[method] meths) -> uint {
let uint i = 0u;
for (method m in meths) {
- if (Str.eq(m.ident, id)) {
+ if (_str::eq(m.ident, id)) {
ret i;
}
i += 1u;
@@ -1889,18 +1891,18 @@ fn method_idx(&session.session sess, &span sp,
fn sort_methods(&vec[method] meths) -> vec[method] {
fn method_lteq(&method a, &method b) -> bool {
- ret Str.lteq(a.ident, b.ident);
+ ret _str::lteq(a.ident, b.ident);
}
- ret std.Sort.merge_sort[method](bind method_lteq(_,_), meths);
+ ret std::sort::merge_sort[method](bind method_lteq(_,_), meths);
}
-fn is_lval(&@ast.expr expr) -> bool {
+fn is_lval(&@ast::expr expr) -> bool {
alt (expr.node) {
- case (ast.expr_field(_,_,_)) { ret true; }
- case (ast.expr_index(_,_,_)) { ret true; }
- case (ast.expr_path(_,_)) { ret true; }
- case (ast.expr_unary(ast.deref,_,_)) { ret true; }
+ case (ast::expr_field(_,_,_)) { ret true; }
+ case (ast::expr_index(_,_,_)) { ret true; }
+ case (ast::expr_path(_,_)) { ret true; }
+ case (ast::expr_unary(ast::deref,_,_)) { ret true; }
case (_) { ret false; }
}
}
@@ -1916,7 +1918,7 @@ mod Unify {
ures_err(type_err, t, t);
}
- type ctxt = rec(UFind.ufind sets,
+ type ctxt = rec(ufind::ufind sets,
hashmap[int,uint] var_ids,
mutable vec[mutable vec[t]] types,
unify_handler handler,
@@ -1939,18 +1941,18 @@ mod Unify {
}
// Unifies two mutability flags.
- fn unify_mut(ast.mutability expected, ast.mutability actual)
- -> Option.t[ast.mutability] {
+ fn unify_mut(ast::mutability expected, ast::mutability actual)
+ -> option::t[ast::mutability] {
if (expected == actual) {
- ret some[ast.mutability](expected);
+ ret some[ast::mutability](expected);
}
- if (expected == ast.maybe_mut) {
- ret some[ast.mutability](actual);
+ if (expected == ast::maybe_mut) {
+ ret some[ast::mutability](actual);
}
- if (actual == ast.maybe_mut) {
- ret some[ast.mutability](expected);
+ if (actual == ast::maybe_mut) {
+ ret some[ast::mutability](expected);
}
- ret none[ast.mutability];
+ ret none[ast::mutability];
}
tag fn_common_res {
@@ -1964,8 +1966,8 @@ mod Unify {
&vec[arg] expected_inputs, &t expected_output,
&vec[arg] actual_inputs, &t actual_output)
-> fn_common_res {
- auto expected_len = Vec.len[arg](expected_inputs);
- auto actual_len = Vec.len[arg](actual_inputs);
+ auto expected_len = _vec::len[arg](expected_inputs);
+ auto actual_len = _vec::len[arg](actual_inputs);
if (expected_len != actual_len) {
ret fn_common_res_err(ures_err(terr_arg_count,
expected, actual));
@@ -2020,8 +2022,8 @@ mod Unify {
}
fn unify_fn(&@ctxt cx,
- &ast.proto e_proto,
- &ast.proto a_proto,
+ &ast::proto e_proto,
+ &ast::proto a_proto,
&t expected,
&t actual,
&vec[arg] expected_inputs, &t expected_output,
@@ -2046,8 +2048,8 @@ mod Unify {
}
fn unify_native_fn(&@ctxt cx,
- &ast.native_abi e_abi,
- &ast.native_abi a_abi,
+ &ast::native_abi e_abi,
+ &ast::native_abi a_abi,
&t expected,
&t actual,
&vec[arg] expected_inputs, &t expected_output,
@@ -2079,8 +2081,8 @@ mod Unify {
&vec[method] actual_meths) -> result {
let vec[method] result_meths = vec();
let uint i = 0u;
- let uint expected_len = Vec.len[method](expected_meths);
- let uint actual_len = Vec.len[method](actual_meths);
+ let uint expected_len = _vec::len[method](expected_meths);
+ let uint actual_len = _vec::len[method](actual_meths);
if (expected_len != actual_len) {
ret ures_err(terr_meth_count, expected, actual);
@@ -2089,7 +2091,7 @@ mod Unify {
while (i < expected_len) {
auto e_meth = expected_meths.(i);
auto a_meth = actual_meths.(i);
- if (! Str.eq(e_meth.ident, a_meth.ident)) {
+ if (! _str::eq(e_meth.ident, a_meth.ident)) {
ret ures_err(terr_obj_meths(e_meth.ident, a_meth.ident),
expected, actual);
}
@@ -2122,7 +2124,7 @@ mod Unify {
auto set_num;
alt (cx.var_ids.find(id)) {
case (none[uint]) {
- set_num = UFind.make_set(cx.sets);
+ set_num = ufind::make_set(cx.sets);
cx.var_ids.insert(id, set_num);
}
case (some[uint](?n)) { set_num = n; }
@@ -2143,17 +2145,17 @@ mod Unify {
alt (struct(cx.tcx, actual)) {
// If the RHS is a variable type, then just do the appropriate
// binding.
- case (ty.ty_var(?actual_id)) {
+ case (ty::ty_var(?actual_id)) {
auto actual_n = get_or_create_set(cx, actual_id);
alt (struct(cx.tcx, expected)) {
- case (ty.ty_var(?expected_id)) {
+ case (ty::ty_var(?expected_id)) {
auto expected_n = get_or_create_set(cx, expected_id);
- UFind.union(cx.sets, expected_n, actual_n);
+ ufind::union(cx.sets, expected_n, actual_n);
}
case (_) {
// Just bind the type variable to the expected type.
- auto vlen = Vec.len[vec[t]](cx.types);
+ auto vlen = _vec::len[vec[t]](cx.types);
if (actual_n < vlen) {
cx.types.(actual_n) += vec(expected);
} else {
@@ -2164,7 +2166,7 @@ mod Unify {
}
ret ures_ok(actual);
}
- case (ty.ty_local(?actual_id)) {
+ case (ty::ty_local(?actual_id)) {
auto result_ty;
alt (cx.handler.resolve_local(actual_id)) {
case (none[t]) { result_ty = expected; }
@@ -2180,9 +2182,9 @@ mod Unify {
cx.handler.record_local(actual_id, result_ty);
ret ures_ok(result_ty);
}
- case (ty.ty_bound_param(?actual_id)) {
+ case (ty::ty_bound_param(?actual_id)) {
alt (struct(cx.tcx, expected)) {
- case (ty.ty_local(_)) {
+ case (ty::ty_local(_)) {
log_err "TODO: bound param unifying with local";
fail;
}
@@ -2196,31 +2198,31 @@ mod Unify {
}
alt (struct(cx.tcx, expected)) {
- case (ty.ty_nil) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_bool) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_int) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_uint) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_machine(_)) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_float) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_char) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_str) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_type) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_native) { ret struct_cmp(cx, expected, actual); }
- case (ty.ty_param(_)) { ret struct_cmp(cx, expected, actual); }
-
- case (ty.ty_tag(?expected_id, ?expected_tps)) {
+ case (ty::ty_nil) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_bool) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_int) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_uint) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_machine(_)) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_float) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_char) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_str) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_type) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_native) { ret struct_cmp(cx, expected, actual); }
+ case (ty::ty_param(_)) { ret struct_cmp(cx, expected, actual); }
+
+ case (ty::ty_tag(?expected_id, ?expected_tps)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_tag(?actual_id, ?actual_tps)) {
+ case (ty::ty_tag(?actual_id, ?actual_tps)) {
if (expected_id._0 != actual_id._0 ||
expected_id._1 != actual_id._1) {
ret ures_err(terr_mismatch, expected, actual);
}
// TODO: factor this cruft out, see the TODO in the
- // ty.ty_tup case
+ // ty::ty_tup case
let vec[t] result_tps = vec();
auto i = 0u;
- auto expected_len = Vec.len[t](expected_tps);
+ auto expected_len = _vec::len[t](expected_tps);
while (i < expected_len) {
auto expected_tp = expected_tps.(i);
auto actual_tp = actual_tps.(i);
@@ -2231,7 +2233,7 @@ mod Unify {
alt (result) {
case (ures_ok(?rty)) {
- Vec.push[t](result_tps, rty);
+ _vec::push[t](result_tps, rty);
}
case (_) {
ret result;
@@ -2249,16 +2251,16 @@ mod Unify {
ret ures_err(terr_mismatch, expected, actual);
}
- case (ty.ty_box(?expected_mt)) {
+ case (ty::ty_box(?expected_mt)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_box(?actual_mt)) {
+ case (ty::ty_box(?actual_mt)) {
auto mut;
alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
- case (none[ast.mutability]) {
+ case (none[ast::mutability]) {
ret ures_err(terr_box_mutability, expected,
actual);
}
- case (some[ast.mutability](?m)) { mut = m; }
+ case (some[ast::mutability](?m)) { mut = m; }
}
auto result = unify_step(cx,
@@ -2281,16 +2283,16 @@ mod Unify {
}
}
- case (ty.ty_vec(?expected_mt)) {
+ case (ty::ty_vec(?expected_mt)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_vec(?actual_mt)) {
+ case (ty::ty_vec(?actual_mt)) {
auto mut;
alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
- case (none[ast.mutability]) {
+ case (none[ast::mutability]) {
ret ures_err(terr_vec_mutability, expected,
actual);
}
- case (some[ast.mutability](?m)) { mut = m; }
+ case (some[ast::mutability](?m)) { mut = m; }
}
auto result = unify_step(cx,
@@ -2313,9 +2315,9 @@ mod Unify {
}
}
- case (ty.ty_port(?expected_sub)) {
+ case (ty::ty_port(?expected_sub)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_port(?actual_sub)) {
+ case (ty::ty_port(?actual_sub)) {
auto result = unify_step(cx,
expected_sub,
actual_sub);
@@ -2335,9 +2337,9 @@ mod Unify {
}
}
- case (ty.ty_chan(?expected_sub)) {
+ case (ty::ty_chan(?expected_sub)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_chan(?actual_sub)) {
+ case (ty::ty_chan(?actual_sub)) {
auto result = unify_step(cx,
expected_sub,
actual_sub);
@@ -2357,11 +2359,11 @@ mod Unify {
}
}
- case (ty.ty_tup(?expected_elems)) {
+ case (ty::ty_tup(?expected_elems)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_tup(?actual_elems)) {
- auto expected_len = Vec.len[ty.mt](expected_elems);
- auto actual_len = Vec.len[ty.mt](actual_elems);
+ case (ty::ty_tup(?actual_elems)) {
+ auto expected_len = _vec::len[ty::mt](expected_elems);
+ auto actual_len = _vec::len[ty::mt](actual_elems);
if (expected_len != actual_len) {
auto err = terr_tuple_size(expected_len,
actual_len);
@@ -2370,7 +2372,7 @@ mod Unify {
// TODO: implement an iterator that can iterate over
// two arrays simultaneously.
- let vec[ty.mt] result_elems = vec();
+ let vec[ty::mt] result_elems = vec();
auto i = 0u;
while (i < expected_len) {
auto expected_elem = expected_elems.(i);
@@ -2379,11 +2381,11 @@ mod Unify {
auto mut;
alt (unify_mut(expected_elem.mut,
actual_elem.mut)) {
- case (none[ast.mutability]) {
+ case (none[ast::mutability]) {
auto err = terr_tuple_mutability;
ret ures_err(err, expected, actual);
}
- case (some[ast.mutability](?m)) { mut = m; }
+ case (some[ast::mutability](?m)) { mut = m; }
}
auto result = unify_step(cx,
@@ -2411,11 +2413,11 @@ mod Unify {
}
}
- case (ty.ty_rec(?expected_fields)) {
+ case (ty::ty_rec(?expected_fields)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_rec(?actual_fields)) {
- auto expected_len = Vec.len[field](expected_fields);
- auto actual_len = Vec.len[field](actual_fields);
+ case (ty::ty_rec(?actual_fields)) {
+ auto expected_len = _vec::len[field](expected_fields);
+ auto actual_len = _vec::len[field](actual_fields);
if (expected_len != actual_len) {
auto err = terr_record_size(expected_len,
actual_len);
@@ -2433,14 +2435,14 @@ mod Unify {
auto mut;
alt (unify_mut(expected_field.mt.mut,
actual_field.mt.mut)) {
- case (none[ast.mutability]) {
+ case (none[ast::mutability]) {
ret ures_err(terr_record_mutability,
expected, actual);
}
- case (some[ast.mutability](?m)) { mut = m; }
+ case (some[ast::mutability](?m)) { mut = m; }
}
- if (!Str.eq(expected_field.ident,
+ if (!_str::eq(expected_field.ident,
actual_field.ident)) {
auto err =
terr_record_fields(expected_field.ident,
@@ -2454,7 +2456,7 @@ mod Unify {
alt (result) {
case (ures_ok(?rty)) {
auto mt = rec(ty=rty, mut=mut);
- Vec.push[field]
+ _vec::push[field]
(result_fields,
rec(mt=mt with expected_field));
}
@@ -2475,9 +2477,9 @@ mod Unify {
}
}
- case (ty.ty_fn(?ep, ?expected_inputs, ?expected_output)) {
+ case (ty::ty_fn(?ep, ?expected_inputs, ?expected_output)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_fn(?ap, ?actual_inputs, ?actual_output)) {
+ case (ty::ty_fn(?ap, ?actual_inputs, ?actual_output)) {
ret unify_fn(cx, ep, ap,
expected, actual,
expected_inputs, expected_output,
@@ -2490,10 +2492,10 @@ mod Unify {
}
}
- case (ty.ty_native_fn(?e_abi, ?expected_inputs,
+ case (ty::ty_native_fn(?e_abi, ?expected_inputs,
?expected_output)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_native_fn(?a_abi, ?actual_inputs,
+ case (ty::ty_native_fn(?a_abi, ?actual_inputs,
?actual_output)) {
ret unify_native_fn(cx, e_abi, a_abi,
expected, actual,
@@ -2506,9 +2508,9 @@ mod Unify {
}
}
- case (ty.ty_obj(?expected_meths)) {
+ case (ty::ty_obj(?expected_meths)) {
alt (struct(cx.tcx, actual)) {
- case (ty.ty_obj(?actual_meths)) {
+ case (ty::ty_obj(?actual_meths)) {
ret unify_obj(cx, expected, actual,
expected_meths, actual_meths);
}
@@ -2518,10 +2520,10 @@ mod Unify {
}
}
- case (ty.ty_var(?expected_id)) {
+ case (ty::ty_var(?expected_id)) {
// Add a binding.
auto expected_n = get_or_create_set(cx, expected_id);
- auto vlen = Vec.len[vec[t]](cx.types);
+ auto vlen = _vec::len[vec[t]](cx.types);
if (expected_n < vlen) {
cx.types.(expected_n) += vec(actual);
} else {
@@ -2531,7 +2533,7 @@ mod Unify {
ret ures_ok(expected);
}
- case (ty.ty_local(?expected_id)) {
+ case (ty::ty_local(?expected_id)) {
auto result_ty;
alt (cx.handler.resolve_local(expected_id)) {
case (none[t]) { result_ty = actual; }
@@ -2548,7 +2550,7 @@ mod Unify {
ret ures_ok(result_ty);
}
- case (ty.ty_bound_param(?expected_id)) {
+ case (ty::ty_bound_param(?expected_id)) {
ret cx.handler.record_param(expected_id, actual);
}
}
@@ -2568,7 +2570,7 @@ mod Unify {
case (ty_var(?id)) {
alt (cx.var_ids.find(id)) {
case (some[uint](?n)) {
- auto root = UFind.find(cx.sets, n);
+ auto root = ufind::find(cx.sets, n);
ret types.(root);
}
case (none[uint]) { ret typ; }
@@ -2585,23 +2587,23 @@ mod Unify {
fn unify_sets(&@ctxt cx) -> vec[t] {
let vec[t] throwaway = vec();
let vec[mutable vec[t]] set_types = vec(mutable throwaway);
- Vec.pop[vec[t]](set_types); // FIXME: botch
+ _vec::pop[vec[t]](set_types); // FIXME: botch
- for (UFind.node node in cx.sets.nodes) {
+ for (ufind::node node in cx.sets.nodes) {
let vec[t] v = vec();
set_types += vec(mutable v);
}
auto i = 0u;
- while (i < Vec.len[vec[t]](set_types)) {
- auto root = UFind.find(cx.sets, i);
+ while (i < _vec::len[vec[t]](set_types)) {
+ auto root = ufind::find(cx.sets, i);
set_types.(root) += cx.types.(i);
i += 1u;
}
let vec[t] result = vec();
for (vec[t] types in set_types) {
- if (Vec.len[t](types) > 1u) {
+ if (_vec::len[t](types) > 1u) {
log_err "unification of > 1 types in a type set is " +
"unimplemented";
fail;
@@ -2618,10 +2620,10 @@ mod Unify {
&ty_ctxt tcx) -> result {
let vec[t] throwaway = vec();
let vec[mutable vec[t]] types = vec(mutable throwaway);
- Vec.pop[vec[t]](types); // FIXME: botch
+ _vec::pop[vec[t]](types); // FIXME: botch
- auto cx = @rec(sets=UFind.make(),
- var_ids=common.new_int_hash[uint](),
+ auto cx = @rec(sets=ufind::make(),
+ var_ids=common::new_int_hash[uint](),
mutable types=types,
handler=handler,
tcx=tcx);
@@ -2631,7 +2633,7 @@ mod Unify {
case (ures_ok(?typ)) {
// Fast path: if there are no local variables, don't perform
// substitutions.
- if (Vec.len(cx.sets.nodes) == 0u) {
+ if (_vec::len(cx.sets.nodes) == 0u) {
ret ures_ok(typ);
}
@@ -2645,7 +2647,7 @@ mod Unify {
}
}
-fn type_err_to_str(&ty.type_err err) -> str {
+fn type_err_to_str(&ty::type_err err) -> str {
alt (err) {
case (terr_mismatch) {
ret "types differ";
@@ -2657,16 +2659,16 @@ fn type_err_to_str(&ty.type_err err) -> str {
ret "vectors differ in mutability";
}
case (terr_tuple_size(?e_sz, ?a_sz)) {
- ret "expected a tuple with " + UInt.to_str(e_sz, 10u) +
- " elements but found one with " + UInt.to_str(a_sz, 10u) +
+ ret "expected a tuple with " + _uint::to_str(e_sz, 10u) +
+ " elements but found one with " + _uint::to_str(a_sz, 10u) +
" elements";
}
case (terr_tuple_mutability) {
ret "tuple elements differ in mutability";
}
case (terr_record_size(?e_sz, ?a_sz)) {
- ret "expected a record with " + UInt.to_str(e_sz, 10u) +
- " fields but found one with " + UInt.to_str(a_sz, 10u) +
+ ret "expected a record with " + _uint::to_str(e_sz, 10u) +
+ " fields but found one with " + _uint::to_str(a_sz, 10u) +
" fields";
}
case (terr_record_mutability) {
@@ -2732,31 +2734,31 @@ fn bind_params_in_type(&ctxt cx, &t typ) -> t {
}
-fn def_has_ty_params(&ast.def def) -> bool {
+fn def_has_ty_params(&ast::def def) -> bool {
alt (def) {
- case (ast.def_fn(_)) { ret true; }
- case (ast.def_obj(_)) { ret true; }
- case (ast.def_obj_field(_)) { ret false; }
- case (ast.def_mod(_)) { ret false; }
- case (ast.def_const(_)) { ret false; }
- case (ast.def_arg(_)) { ret false; }
- case (ast.def_local(_)) { ret false; }
- case (ast.def_variant(_, _)) { ret true; }
- case (ast.def_ty(_)) { ret false; }
- case (ast.def_ty_arg(_)) { ret false; }
- case (ast.def_binding(_)) { ret false; }
- case (ast.def_use(_)) { ret false; }
- case (ast.def_native_ty(_)) { ret false; }
- case (ast.def_native_fn(_)) { ret true; }
+ case (ast::def_fn(_)) { ret true; }
+ case (ast::def_obj(_)) { ret true; }
+ case (ast::def_obj_field(_)) { ret false; }
+ case (ast::def_mod(_)) { ret false; }
+ case (ast::def_const(_)) { ret false; }
+ case (ast::def_arg(_)) { ret false; }
+ case (ast::def_local(_)) { ret false; }
+ case (ast::def_variant(_, _)) { ret true; }
+ case (ast::def_ty(_)) { ret false; }
+ case (ast::def_ty_arg(_)) { ret false; }
+ case (ast::def_binding(_)) { ret false; }
+ case (ast::def_use(_)) { ret false; }
+ case (ast::def_native_ty(_)) { ret false; }
+ case (ast::def_native_fn(_)) { ret true; }
}
}
// If the given item is in an external crate, looks up its type and adds it to
// the type cache. Returns the type parameters and type.
-fn lookup_item_type(session.session sess,
+fn lookup_item_type(session::session sess,
ctxt cx,
&type_cache cache,
- ast.def_id did) -> ty_param_count_and_ty {
+ ast::def_id did) -> ty_param_count_and_ty {
if (did._0 == sess.get_targ_crate_num()) {
// The item is in this crate. The caller should have added it to the
// type cache already; we simply return it.
@@ -2766,7 +2768,7 @@ fn lookup_item_type(session.session sess,
alt (cache.find(did)) {
case (some[ty_param_count_and_ty](?tpt)) { ret tpt; }
case (none[ty_param_count_and_ty]) {
- auto tyt = creader.get_type(sess, cx, did);
+ auto tyt = creader::get_type(sess, cx, did);
cache.insert(did, tyt);
ret tyt;
}
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index a8114cd1..fb7634a2 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -1,168 +1,168 @@
-import front.ast;
-import front.ast.ann;
-import front.ast.ann_none;
-import front.ast.mutability;
-import front.creader;
-import middle.fold;
-import driver.session;
-import util.common;
-import util.common.span;
-import util.common.plain_ann;
-import util.common.new_def_hash;
-import util.common.log_expr_err;
-
-import middle.ty;
-import middle.ty.ann_to_type;
-import middle.ty.arg;
-import middle.ty.bind_params_in_type;
-import middle.ty.block_ty;
-import middle.ty.expr_ty;
-import middle.ty.field;
-import middle.ty.method;
-import middle.ty.mo_val;
-import middle.ty.mo_alias;
-import middle.ty.mo_either;
-import middle.ty.pat_ty;
-import middle.ty.path_to_str;
-import middle.ty.struct;
-import middle.ty.triv_ann;
-import middle.ty.ty_to_str;
-import middle.ty.type_is_integral;
-import middle.ty.type_is_scalar;
-import middle.ty.ty_param_count_and_ty;
-import middle.ty.ty_nil;
-import middle.ty.Unify.ures_ok;
-import middle.ty.Unify.ures_err;
-
-import std.Str;
-import std.UInt;
-import std.Vec;
-import std.Map;
-import std.Map.hashmap;
-import std.Option;
-import std.Option.none;
-import std.Option.some;
-import std.Option.from_maybe;
-
-import util.typestate_ann.ts_ann;
-
-type ty_table = hashmap[ast.def_id, ty.t];
+import front::ast;
+import front::ast::ann;
+import front::ast::ann_none;
+import front::ast::mutability;
+import front::creader;
+import middle::fold;
+import driver::session;
+import util::common;
+import util::common::span;
+import util::common::plain_ann;
+import util::common::new_def_hash;
+import util::common::log_expr_err;
+
+import middle::ty;
+import middle::ty::ann_to_type;
+import middle::ty::arg;
+import middle::ty::bind_params_in_type;
+import middle::ty::block_ty;
+import middle::ty::expr_ty;
+import middle::ty::field;
+import middle::ty::method;
+import middle::ty::mo_val;
+import middle::ty::mo_alias;
+import middle::ty::mo_either;
+import middle::ty::pat_ty;
+import middle::ty::path_to_str;
+import middle::ty::struct;
+import middle::ty::triv_ann;
+import middle::ty::ty_to_str;
+import middle::ty::type_is_integral;
+import middle::ty::type_is_scalar;
+import middle::ty::ty_param_count_and_ty;
+import middle::ty::ty_nil;
+import middle::ty::Unify::ures_ok;
+import middle::ty::Unify::ures_err;
+
+import std::_str;
+import std::_uint;
+import std::_vec;
+import std::map;
+import std::map::hashmap;
+import std::option;
+import std::option::none;
+import std::option::some;
+import std::option::from_maybe;
+
+import util::typestate_ann::ts_ann;
+
+type ty_table = hashmap[ast::def_id, ty::t];
tag any_item {
- any_item_rust(@ast.item);
- any_item_native(@ast.native_item, ast.native_abi);
+ any_item_rust(@ast::item);
+ any_item_native(@ast::native_item, ast::native_abi);
}
-type ty_item_table = hashmap[ast.def_id,any_item];
-type fn_purity_table = hashmap[ast.def_id, ast.purity];
+type ty_item_table = hashmap[ast::def_id,any_item];
+type fn_purity_table = hashmap[ast::def_id, ast::purity];
-type unify_cache_entry = tup(ty.t,ty.t,vec[mutable ty.t]);
-type unify_cache = hashmap[unify_cache_entry,ty.Unify.result];
+type unify_cache_entry = tup(ty::t,ty::t,vec[mutable ty::t]);
+type unify_cache = hashmap[unify_cache_entry,ty::Unify::result];
-type crate_ctxt = rec(session.session sess,
- ty.type_cache type_cache,
+type crate_ctxt = rec(session::session sess,
+ ty::type_cache type_cache,
@ty_item_table item_items,
- vec[ast.obj_field] obj_fields,
- Option.t[ast.def_id] this_obj,
+ vec[ast::obj_field] obj_fields,
+ option::t[ast::def_id] this_obj,
@fn_purity_table fn_purity_table,
mutable int next_var_id,
unify_cache unify_cache,
mutable uint cache_hits,
mutable uint cache_misses,
- ty.ctxt tcx);
+ ty::ctxt tcx);
-type fn_ctxt = rec(ty.t ret_ty,
- ast.purity purity,
+type fn_ctxt = rec(ty::t ret_ty,
+ ast::purity purity,
@ty_table locals,
@crate_ctxt ccx);
// Used for ast_ty_to_ty() below.
-type ty_getter = fn(&ast.def_id) -> ty.ty_param_count_and_ty;
+type ty_getter = fn(&ast::def_id) -> ty::ty_param_count_and_ty;
// Substitutes the user's explicit types for the parameters in a path
// expression.
fn substitute_ty_params(&@crate_ctxt ccx,
- &ty.t typ,
+ &ty::t typ,
uint ty_param_count,
- &vec[ty.t] supplied,
- &span sp) -> ty.t {
- fn substituter(@crate_ctxt ccx, vec[ty.t] supplied, ty.t typ) -> ty.t {
+ &vec[ty::t] supplied,
+ &span sp) -> ty::t {
+ fn substituter(@crate_ctxt ccx, vec[ty::t] supplied, ty::t typ) -> ty::t {
alt (struct(ccx.tcx, typ)) {
- case (ty.ty_bound_param(?pid)) { ret supplied.(pid); }
+ case (ty::ty_bound_param(?pid)) { ret supplied.(pid); }
case (_) { ret typ; }
}
}
- auto supplied_len = Vec.len[ty.t](supplied);
+ auto supplied_len = _vec::len[ty::t](supplied);
if (ty_param_count != supplied_len) {
ccx.sess.span_err(sp, "expected " +
- UInt.to_str(ty_param_count, 10u) +
+ _uint::to_str(ty_param_count, 10u) +
" type parameter(s) but found " +
- UInt.to_str(supplied_len, 10u) + " parameter(s)");
+ _uint::to_str(supplied_len, 10u) + " parameter(s)");
fail;
}
- if (!ty.type_contains_bound_params(ccx.tcx, typ)) {
+ if (!ty::type_contains_bound_params(ccx.tcx, typ)) {
ret typ;
}
auto f = bind substituter(ccx, supplied, _);
- ret ty.fold_ty(ccx.tcx, f, typ);
+ ret ty::fold_ty(ccx.tcx, f, typ);
}
// Returns the type parameter count and the type for the given definition.
-fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &ast.span sp, &ast.def defn)
+fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &ast::span sp, &ast::def defn)
-> ty_param_count_and_ty {
alt (defn) {
- case (ast.def_arg(?id)) {
+ case (ast::def_arg(?id)) {
// assert (fcx.locals.contains_key(id));
ret tup(0u, fcx.locals.get(id));
}
- case (ast.def_local(?id)) {
+ case (ast::def_local(?id)) {
auto t;
alt (fcx.locals.find(id)) {
- case (some[ty.t](?t1)) { t = t1; }
- case (none[ty.t]) { t = ty.mk_local(fcx.ccx.tcx, id); }
+ case (some[ty::t](?t1)) { t = t1; }
+ case (none[ty::t]) { t = ty::mk_local(fcx.ccx.tcx, id); }
}
ret tup(0u, t);
}
- case (ast.def_obj_field(?id)) {
+ case (ast::def_obj_field(?id)) {
// assert (fcx.locals.contains_key(id));
ret tup(0u, fcx.locals.get(id));
}
- case (ast.def_fn(?id)) {
- ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ case (ast::def_fn(?id)) {
+ ret ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, id);
}
- case (ast.def_native_fn(?id)) {
- ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ case (ast::def_native_fn(?id)) {
+ ret ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, id);
}
- case (ast.def_const(?id)) {
- ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ case (ast::def_const(?id)) {
+ ret ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, id);
}
- case (ast.def_variant(_, ?vid)) {
- ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ case (ast::def_variant(_, ?vid)) {
+ ret ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, vid);
}
- case (ast.def_binding(?id)) {
+ case (ast::def_binding(?id)) {
// assert (fcx.locals.contains_key(id));
ret tup(0u, fcx.locals.get(id));
}
- case (ast.def_obj(?id)) {
- ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ case (ast::def_obj(?id)) {
+ ret ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, id);
}
- case (ast.def_mod(_)) {
+ case (ast::def_mod(_)) {
// Hopefully part of a path.
// TODO: return a type that's more poisonous, perhaps?
- ret tup(0u, ty.mk_nil(fcx.ccx.tcx));
+ ret tup(0u, ty::mk_nil(fcx.ccx.tcx));
}
- case (ast.def_ty(_)) {
+ case (ast::def_ty(_)) {
fcx.ccx.sess.span_err(sp, "expected value but found type");
fail;
}
@@ -177,21 +177,21 @@ fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &ast.span sp, &ast.def defn)
// Instantiates the given path, which must refer to an item with the given
// number of type parameters and type.
-fn instantiate_path(&@fn_ctxt fcx, &ast.path pth, &ty_param_count_and_ty tpt,
- &span sp, uint ann_tag) -> ast.ann {
+fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
+ &span sp, uint ann_tag) -> ast::ann {
auto ty_param_count = tpt._0;
auto t = bind_params_in_type(fcx.ccx.tcx, tpt._1);
auto ty_substs_opt;
- auto ty_substs_len = Vec.len[@ast.ty](pth.node.types);
+ auto ty_substs_len = _vec::len[@ast::ty](pth.node.types);
if (ty_substs_len > 0u) {
- let vec[ty.t] ty_substs = vec();
+ let vec[ty::t] ty_substs = vec();
auto i = 0u;
while (i < ty_substs_len) {
ty_substs += vec(ast_ty_to_ty_crate(fcx.ccx, pth.node.types.(i)));
i += 1u;
}
- ty_substs_opt = some[vec[ty.t]](ty_substs);
+ ty_substs_opt = some[vec[ty::t]](ty_substs);
if (ty_param_count == 0u) {
fcx.ccx.sess.span_err(sp, "this item does not take type " +
@@ -200,49 +200,49 @@ fn instantiate_path(&@fn_ctxt fcx, &ast.path pth, &ty_param_count_and_ty tpt,
}
} else {
// We will acquire the type parameters through unification.
- let vec[ty.t] ty_substs = vec();
+ let vec[ty::t] ty_substs = vec();
auto i = 0u;
while (i < ty_param_count) {
ty_substs += vec(next_ty_var(fcx.ccx));
i += 1u;
}
- ty_substs_opt = some[vec[ty.t]](ty_substs);
+ ty_substs_opt = some[vec[ty::t]](ty_substs);
}
- ret ast.ann_type(ann_tag, t, ty_substs_opt, none[@ts_ann]);
+ ret ast::ann_type(ann_tag, t, ty_substs_opt, none[@ts_ann]);
}
-fn ast_mode_to_mode(ast.mode mode) -> ty.mode {
+fn ast_mode_to_mode(ast::mode mode) -> ty::mode {
auto ty_mode;
alt (mode) {
- case (ast.val) { ty_mode = mo_val; }
- case (ast.alias) { ty_mode = mo_alias; }
+ case (ast::val) { ty_mode = mo_val; }
+ case (ast::alias) { ty_mode = mo_alias; }
}
ret ty_mode;
}
// Parses the programmer's textual representation of a type into our internal
// notion of a type. `getter` is a function that returns the type
-// corresponding to a definition ID.
-fn ast_ty_to_ty(&ty.ctxt tcx, &ty_getter getter, &@ast.ty ast_ty) -> ty.t {
- fn ast_arg_to_arg(&ty.ctxt tcx,
+// corresponding to a definition ID:
+fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
+ fn ast_arg_to_arg(&ty::ctxt tcx,
&ty_getter getter,
- &rec(ast.mode mode, @ast.ty ty) arg)
- -> rec(ty.mode mode, ty.t ty) {
+ &rec(ast::mode mode, @ast::ty ty) arg)
+ -> rec(ty::mode mode, ty::t ty) {
auto ty_mode = ast_mode_to_mode(arg.mode);
ret rec(mode=ty_mode, ty=ast_ty_to_ty(tcx, getter, arg.ty));
}
- fn ast_mt_to_mt(&ty.ctxt tcx,
+ fn ast_mt_to_mt(&ty::ctxt tcx,
&ty_getter getter,
- &ast.mt mt) -> ty.mt {
+ &ast::mt mt) -> ty::mt {
ret rec(ty=ast_ty_to_ty(tcx, getter, mt.ty), mut=mt.mut);
}
- fn instantiate(&ty.ctxt tcx,
+ fn instantiate(&ty::ctxt tcx,
&ty_getter getter,
- &ast.def_id id,
- &vec[@ast.ty] args) -> ty.t {
+ &ast::def_id id,
+ &vec[@ast::ty] args) -> ty::t {
// TODO: maybe record cname chains so we can do
// "foo = int" like OCaml?
auto params_opt_and_ty = getter(id);
@@ -256,73 +256,73 @@ fn ast_ty_to_ty(&ty.ctxt tcx, &ty_getter getter, &@ast.ty ast_ty) -> ty.t {
// TODO: Make sure the number of supplied bindings matches the number
// of type parameters in the typedef. Emit a friendly error otherwise.
auto bound_ty = bind_params_in_type(tcx, params_opt_and_ty._1);
- let vec[ty.t] param_bindings = vec();
- for (@ast.ty ast_ty in args) {
+ let vec[ty::t] param_bindings = vec();
+ for (@ast::ty ast_ty in args) {
param_bindings += vec(ast_ty_to_ty(tcx, getter, ast_ty));
}
- ret ty.substitute_type_params(tcx, param_bindings, bound_ty);
+ ret ty::substitute_type_params(tcx, param_bindings, bound_ty);
}
- auto mut = ast.imm;
+ auto mut = ast::imm;
auto typ;
auto cname = none[str];
alt (ast_ty.node) {
- case (ast.ty_nil) { typ = ty.mk_nil(tcx); }
- case (ast.ty_bool) { typ = ty.mk_bool(tcx); }
- case (ast.ty_int) { typ = ty.mk_int(tcx); }
- case (ast.ty_uint) { typ = ty.mk_uint(tcx); }
- case (ast.ty_float) { typ = ty.mk_float(tcx); }
- case (ast.ty_machine(?tm)) { typ = ty.mk_mach(tcx, tm); }
- case (ast.ty_char) { typ = ty.mk_char(tcx); }
- case (ast.ty_str) { typ = ty.mk_str(tcx); }
- case (ast.ty_box(?mt)) {
- typ = ty.mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
+ case (ast::ty_nil) { typ = ty::mk_nil(tcx); }
+ case (ast::ty_bool) { typ = ty::mk_bool(tcx); }
+ case (ast::ty_int) { typ = ty::mk_int(tcx); }
+ case (ast::ty_uint) { typ = ty::mk_uint(tcx); }
+ case (ast::ty_float) { typ = ty::mk_float(tcx); }
+ case (ast::ty_machine(?tm)) { typ = ty::mk_mach(tcx, tm); }
+ case (ast::ty_char) { typ = ty::mk_char(tcx); }
+ case (ast::ty_str) { typ = ty::mk_str(tcx); }
+ case (ast::ty_box(?mt)) {
+ typ = ty::mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
}
- case (ast.ty_vec(?mt)) {
- typ = ty.mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
+ case (ast::ty_vec(?mt)) {
+ typ = ty::mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
}
- case (ast.ty_port(?t)) {
- typ = ty.mk_port(tcx, ast_ty_to_ty(tcx, getter, t));
+ case (ast::ty_port(?t)) {
+ typ = ty::mk_port(tcx, ast_ty_to_ty(tcx, getter, t));
}
- case (ast.ty_chan(?t)) {
- typ = ty.mk_chan(tcx, ast_ty_to_ty(tcx, getter, t));
+ case (ast::ty_chan(?t)) {
+ typ = ty::mk_chan(tcx, ast_ty_to_ty(tcx, getter, t));
}
- case (ast.ty_tup(?fields)) {
- let vec[ty.mt] flds = vec();
- for (ast.mt field in fields) {
- Vec.push[ty.mt](flds, ast_mt_to_mt(tcx, getter, field));
+ case (ast::ty_tup(?fields)) {
+ let vec[ty::mt] flds = vec();
+ for (ast::mt field in fields) {
+ _vec::push[ty::mt](flds, ast_mt_to_mt(tcx, getter, field));
}
- typ = ty.mk_tup(tcx, flds);
+ typ = ty::mk_tup(tcx, flds);
}
- case (ast.ty_rec(?fields)) {
+ case (ast::ty_rec(?fields)) {
let vec[field] flds = vec();
- for (ast.ty_field f in fields) {
+ for (ast::ty_field f in fields) {
auto tm = ast_mt_to_mt(tcx, getter, f.mt);
- Vec.push[field](flds, rec(ident=f.ident, mt=tm));
+ _vec::push[field](flds, rec(ident=f.ident, mt=tm));
}
- typ = ty.mk_rec(tcx, flds);
+ typ = ty::mk_rec(tcx, flds);
}
- case (ast.ty_fn(?proto, ?inputs, ?output)) {
+ case (ast::ty_fn(?proto, ?inputs, ?output)) {
auto f = bind ast_arg_to_arg(tcx, getter, _);
- auto i = Vec.map[ast.ty_arg, arg](f, inputs);
+ auto i = _vec::map[ast::ty_arg, arg](f, inputs);
auto out_ty = ast_ty_to_ty(tcx, getter, output);
- typ = ty.mk_fn(tcx, proto, i, out_ty);
+ typ = ty::mk_fn(tcx, proto, i, out_ty);
}
- case (ast.ty_path(?path, ?ann)) {
- alt (tcx.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_ty(?id)) {
+ case (ast::ty_path(?path, ?ann)) {
+ alt (tcx.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_ty(?id)) {
typ = instantiate(tcx, getter, id, path.node.types);
}
- case (ast.def_native_ty(?id)) { typ = getter(id)._1; }
- case (ast.def_obj(?id)) {
+ case (ast::def_native_ty(?id)) { typ = getter(id)._1; }
+ case (ast::def_obj(?id)) {
typ = instantiate(tcx, getter, id, path.node.types);
}
- case (ast.def_ty_arg(?id)) { typ = ty.mk_param(tcx, id); }
+ case (ast::def_ty_arg(?id)) { typ = ty::mk_param(tcx, id); }
case (_) {
tcx.sess.span_err(ast_ty.span,
"found type name used as a variable");
@@ -332,27 +332,27 @@ fn ast_ty_to_ty(&ty.ctxt tcx, &ty_getter getter, &@ast.ty ast_ty) -> ty.t {
cname = some(path_to_str(path));
}
- case (ast.ty_obj(?meths)) {
- let vec[ty.method] tmeths = vec();
+ case (ast::ty_obj(?meths)) {
+ let vec[ty::method] tmeths = vec();
auto f = bind ast_arg_to_arg(tcx, getter, _);
- for (ast.ty_method m in meths) {
- auto ins = Vec.map[ast.ty_arg, arg](f, m.inputs);
+ for (ast::ty_method m in meths) {
+ auto ins = _vec::map[ast::ty_arg, arg](f, m.inputs);
auto out = ast_ty_to_ty(tcx, getter, m.output);
- Vec.push[ty.method](tmeths,
+ _vec::push[ty::method](tmeths,
rec(proto=m.proto,
ident=m.ident,
inputs=ins,
output=out));
}
- typ = ty.mk_obj(tcx, ty.sort_methods(tmeths));
+ typ = ty::mk_obj(tcx, ty::sort_methods(tmeths));
}
}
alt (cname) {
case (none[str]) { /* no-op */ }
case (some[str](?cname_str)) {
- typ = ty.rename(tcx, typ, cname_str);
+ typ = ty::rename(tcx, typ, cname_str);
}
}
ret typ;
@@ -360,9 +360,9 @@ fn ast_ty_to_ty(&ty.ctxt tcx, &ty_getter getter, &@ast.ty ast_ty) -> ty.t {
// A convenience function to use a crate_ctxt to resolve names for
// ast_ty_to_ty.
-fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast.ty ast_ty) -> ty.t {
- fn getter(@crate_ctxt ccx, &ast.def_id id) -> ty.ty_param_count_and_ty {
- ret ty.lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, id);
+fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast::ty ast_ty) -> ty::t {
+ fn getter(@crate_ctxt ccx, &ast::def_id id) -> ty::ty_param_count_and_ty {
+ ret ty::lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, id);
}
auto f = bind getter(ccx, _);
ret ast_ty_to_ty(ccx.tcx, f, ast_ty);
@@ -381,49 +381,49 @@ fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast.ty ast_ty) -> ty.t {
// AST, along with a table mapping item IDs to their types.
mod Collect {
- type ctxt = rec(session.session sess,
+ type ctxt = rec(session::session sess,
@ty_item_table id_to_ty_item,
- ty.type_cache type_cache,
- ty.ctxt tcx);
- type env = rec(@ctxt cx, ast.native_abi abi);
+ ty::type_cache type_cache,
+ ty::ctxt tcx);
+ type env = rec(@ctxt cx, ast::native_abi abi);
fn ty_of_fn_decl(&@ctxt cx,
- &fn(&@ast.ty ast_ty) -> ty.t convert,
- &fn(&ast.arg a) -> arg ty_of_arg,
- &ast.fn_decl decl,
- ast.proto proto,
- &vec[ast.ty_param] ty_params,
- &ast.def_id def_id) -> ty.ty_param_count_and_ty {
- auto input_tys = Vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
+ &fn(&@ast::ty ast_ty) -> ty::t convert,
+ &fn(&ast::arg a) -> arg ty_of_arg,
+ &ast::fn_decl decl,
+ ast::proto proto,
+ &vec[ast::ty_param] ty_params,
+ &ast::def_id def_id) -> ty::ty_param_count_and_ty {
+ auto input_tys = _vec::map[ast::arg,arg](ty_of_arg, decl.inputs);
auto output_ty = convert(decl.output);
- auto t_fn = ty.mk_fn(cx.tcx, proto, input_tys, output_ty);
- auto ty_param_count = Vec.len[ast.ty_param](ty_params);
+ auto t_fn = ty::mk_fn(cx.tcx, proto, input_tys, output_ty);
+ auto ty_param_count = _vec::len[ast::ty_param](ty_params);
auto tpt = tup(ty_param_count, t_fn);
cx.type_cache.insert(def_id, tpt);
ret tpt;
}
fn ty_of_native_fn_decl(&@ctxt cx,
- &fn(&@ast.ty ast_ty) -> ty.t convert,
- &fn(&ast.arg a) -> arg ty_of_arg,
- &ast.fn_decl decl,
- ast.native_abi abi,
- &vec[ast.ty_param] ty_params,
- &ast.def_id def_id) -> ty.ty_param_count_and_ty {
- auto input_tys = Vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
+ &fn(&@ast::ty ast_ty) -> ty::t convert,
+ &fn(&ast::arg a) -> arg ty_of_arg,
+ &ast::fn_decl decl,
+ ast::native_abi abi,
+ &vec[ast::ty_param] ty_params,
+ &ast::def_id def_id) -> ty::ty_param_count_and_ty{
+ auto input_tys = _vec::map[ast::arg,arg](ty_of_arg, decl.inputs);
auto output_ty = convert(decl.output);
- auto t_fn = ty.mk_native_fn(cx.tcx, abi, input_tys, output_ty);
- auto ty_param_count = Vec.len[ast.ty_param](ty_params);
+ auto t_fn = ty::mk_native_fn(cx.tcx, abi, input_tys, output_ty);
+ auto ty_param_count = _vec::len[ast::ty_param](ty_params);
auto tpt = tup(ty_param_count, t_fn);
cx.type_cache.insert(def_id, tpt);
ret tpt;
}
- fn getter(@ctxt cx, &ast.def_id id) -> ty.ty_param_count_and_ty {
+ fn getter(@ctxt cx, &ast::def_id id) -> ty::ty_param_count_and_ty {
if (id._0 != cx.sess.get_targ_crate_num()) {
// This is a type we need to load in from the crate reader.
- ret creader.get_type(cx.sess, cx.tcx, id);
+ ret creader::get_type(cx.sess, cx.tcx, id);
}
// assert (cx.id_to_ty_item.contains_key(id));
@@ -440,126 +440,126 @@ mod Collect {
ret tpt;
}
- fn ty_of_arg(@ctxt cx, &ast.arg a) -> arg {
+ fn ty_of_arg(@ctxt cx, &ast::arg a) -> arg {
auto ty_mode = ast_mode_to_mode(a.mode);
auto f = bind getter(cx, _);
ret rec(mode=ty_mode, ty=ast_ty_to_ty(cx.tcx, f, a.ty));
}
- fn ty_of_method(@ctxt cx, &@ast.method m) -> method {
+ fn ty_of_method(@ctxt cx, &@ast::method m) -> method {
auto get = bind getter(cx, _);
auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
auto f = bind ty_of_arg(cx, _);
- auto inputs = Vec.map[ast.arg,arg](f, m.node.meth.decl.inputs);
+ auto inputs = _vec::map[ast::arg,arg](f, m.node.meth.decl.inputs);
auto output = convert(m.node.meth.decl.output);
ret rec(proto=m.node.meth.proto, ident=m.node.ident,
inputs=inputs, output=output);
}
fn ty_of_obj(@ctxt cx,
- &ast.ident id,
- &ast._obj obj_info,
- &vec[ast.ty_param] ty_params) -> ty.ty_param_count_and_ty {
+ &ast::ident id,
+ &ast::_obj obj_info,
+ &vec[ast::ty_param] ty_params) -> ty::ty_param_count_and_ty {
auto f = bind ty_of_method(cx, _);
- auto methods = Vec.map[@ast.method,method](f, obj_info.methods);
+ auto methods = _vec::map[@ast::method,method](f, obj_info.methods);
- auto t_obj = ty.mk_obj(cx.tcx, ty.sort_methods(methods));
- t_obj = ty.rename(cx.tcx, t_obj, id);
- auto ty_param_count = Vec.len[ast.ty_param](ty_params);
+ auto t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods));
+ t_obj = ty::rename(cx.tcx, t_obj, id);
+ auto ty_param_count = _vec::len[ast::ty_param](ty_params);
ret tup(ty_param_count, t_obj);
}
fn ty_of_obj_ctor(@ctxt cx,
- &ast.ident id,
- &ast._obj obj_info,
- &ast.def_id obj_ty_id,
- &vec[ast.ty_param] ty_params)
- -> ty.ty_param_count_and_ty {
+ &ast::ident id,
+ &ast::_obj obj_info,
+ &ast::def_id obj_ty_id,
+ &vec[ast::ty_param] ty_params)
+ -> ty::ty_param_count_and_ty {
auto t_obj = ty_of_obj(cx, id, obj_info, ty_params);
let vec[arg] t_inputs = vec();
- for (ast.obj_field f in obj_info.fields) {
+ for (ast::obj_field f in obj_info.fields) {
auto g = bind getter(cx, _);
auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
- Vec.push[arg](t_inputs, rec(mode=ty.mo_alias, ty=t_field));
+ _vec::push[arg](t_inputs, rec(mode=ty::mo_alias, ty=t_field));
}
cx.type_cache.insert(obj_ty_id, t_obj);
- auto t_fn = ty.mk_fn(cx.tcx, ast.proto_fn, t_inputs, t_obj._1);
+ auto t_fn = ty::mk_fn(cx.tcx, ast::proto_fn, t_inputs, t_obj._1);
ret tup(t_obj._0, t_fn);
}
- fn ty_of_item(&@ctxt cx, &@ast.item it) -> ty.ty_param_count_and_ty {
+ fn ty_of_item(&@ctxt cx, &@ast::item it) -> ty::ty_param_count_and_ty {
auto get = bind getter(cx, _);
auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
alt (it.node) {
- case (ast.item_const(?ident, ?t, _, ?def_id, _)) {
+ case (ast::item_const(?ident, ?t, _, ?def_id, _)) {
auto typ = convert(t);
auto tpt = tup(0u, typ);
cx.type_cache.insert(def_id, tpt);
ret tpt;
}
- case (ast.item_fn(?ident, ?fn_info, ?tps, ?def_id, _)) {
+ case (ast::item_fn(?ident, ?fn_info, ?tps, ?def_id, _)) {
auto f = bind ty_of_arg(cx, _);
ret ty_of_fn_decl(cx, convert, f, fn_info.decl, fn_info.proto,
tps, def_id);
}
- case (ast.item_obj(?ident, ?obj_info, ?tps, ?odid, _)) {
+ case (ast::item_obj(?ident, ?obj_info, ?tps, ?odid, _)) {
auto t_ctor = ty_of_obj_ctor(cx, ident, obj_info, odid.ty,
tps);
cx.type_cache.insert(odid.ctor, t_ctor);
ret cx.type_cache.get(odid.ty);
}
- case (ast.item_ty(?ident, ?t, ?tps, ?def_id, _)) {
+ case (ast::item_ty(?ident, ?t, ?tps, ?def_id, _)) {
alt (cx.type_cache.find(def_id)) {
- case (some[ty.ty_param_count_and_ty](?tpt)) {
+ case (some[ty::ty_param_count_and_ty](?tpt)) {
ret tpt;
}
- case (none[ty.ty_param_count_and_ty]) {}
+ case (none[ty::ty_param_count_and_ty]) {}
}
// Tell ast_ty_to_ty() that we want to perform a recursive
// call to resolve any named types.
auto typ = convert(t);
- auto ty_param_count = Vec.len[ast.ty_param](tps);
+ auto ty_param_count = _vec::len[ast::ty_param](tps);
auto tpt = tup(ty_param_count, typ);
cx.type_cache.insert(def_id, tpt);
ret tpt;
}
- case (ast.item_tag(_, _, ?tps, ?def_id, _)) {
+ case (ast::item_tag(_, _, ?tps, ?def_id, _)) {
// Create a new generic polytype.
- let vec[ty.t] subtys = vec();
+ let vec[ty::t] subtys = vec();
auto i = 0u;
- for (ast.ty_param tp in tps) {
- subtys += vec(ty.mk_param(cx.tcx, i));
+ for (ast::ty_param tp in tps) {
+ subtys += vec(ty::mk_param(cx.tcx, i));
i += 1u;
}
- auto t = ty.mk_tag(cx.tcx, def_id, subtys);
+ auto t = ty::mk_tag(cx.tcx, def_id, subtys);
- auto ty_param_count = Vec.len[ast.ty_param](tps);
+ auto ty_param_count = _vec::len[ast::ty_param](tps);
auto tpt = tup(ty_param_count, t);
cx.type_cache.insert(def_id, tpt);
ret tpt;
}
- case (ast.item_mod(_, _, _)) { fail; }
- case (ast.item_native_mod(_, _, _)) { fail; }
+ case (ast::item_mod(_, _, _)) { fail; }
+ case (ast::item_native_mod(_, _, _)) { fail; }
}
}
- fn ty_of_native_item(&@ctxt cx, &@ast.native_item it, ast.native_abi abi)
- -> ty.ty_param_count_and_ty {
+ fn ty_of_native_item(&@ctxt cx, &@ast::native_item it,
+ ast::native_abi abi) -> ty::ty_param_count_and_ty {
alt (it.node) {
- case (ast.native_item_fn(?ident, ?lname, ?fn_decl,
+ case (ast::native_item_fn(?ident, ?lname, ?fn_decl,
?params, ?def_id, _)) {
auto get = bind getter(cx, _);
auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
@@ -567,15 +567,15 @@ mod Collect {
ret ty_of_native_fn_decl(cx, convert, f, fn_decl, abi, params,
def_id);
}
- case (ast.native_item_ty(_, ?def_id)) {
+ case (ast::native_item_ty(_, ?def_id)) {
alt (cx.type_cache.find(def_id)) {
- case (some[ty.ty_param_count_and_ty](?tpt)) {
+ case (some[ty::ty_param_count_and_ty](?tpt)) {
ret tpt;
}
- case (none[ty.ty_param_count_and_ty]) {}
+ case (none[ty::ty_param_count_and_ty]) {}
}
- auto t = ty.mk_native(cx.tcx);
+ auto t = ty::mk_native(cx.tcx);
auto tpt = tup(0u, t);
cx.type_cache.insert(def_id, tpt);
ret tpt;
@@ -583,40 +583,40 @@ mod Collect {
}
}
- fn get_tag_variant_types(&@ctxt cx, &ast.def_id tag_id,
- &vec[ast.variant] variants,
- &vec[ast.ty_param] ty_params)
- -> vec[ast.variant] {
- let vec[ast.variant] result = vec();
+ fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
+ &vec[ast::variant] variants,
+ &vec[ast::ty_param] ty_params)
+ -> vec[ast::variant] {
+ let vec[ast::variant] result = vec();
// Create a set of parameter types shared among all the variants.
- let vec[ty.t] ty_param_tys = vec();
+ let vec[ty::t] ty_param_tys = vec();
auto i = 0u;
- for (ast.ty_param tp in ty_params) {
- ty_param_tys += vec(ty.mk_param(cx.tcx, i));
+ for (ast::ty_param tp in ty_params) {
+ ty_param_tys += vec(ty::mk_param(cx.tcx, i));
i += 1u;
}
- auto ty_param_count = Vec.len[ast.ty_param](ty_params);
+ auto ty_param_count = _vec::len[ast::ty_param](ty_params);
- for (ast.variant variant in variants) {
+ for (ast::variant variant in variants) {
// Nullary tag constructors get turned into constants; n-ary tag
// constructors get turned into functions.
auto result_ty;
- if (Vec.len[ast.variant_arg](variant.node.args) == 0u) {
- result_ty = ty.mk_tag(cx.tcx, tag_id, ty_param_tys);
+ if (_vec::len[ast::variant_arg](variant.node.args) == 0u) {
+ result_ty = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
} else {
// As above, tell ast_ty_to_ty() that trans_ty_item_to_ty()
// should be called to resolve named types.
auto f = bind getter(cx, _);
let vec[arg] args = vec();
- for (ast.variant_arg va in variant.node.args) {
+ for (ast::variant_arg va in variant.node.args) {
auto arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
- args += vec(rec(mode=ty.mo_alias, ty=arg_ty));
+ args += vec(rec(mode=ty::mo_alias, ty=arg_ty));
}
- auto tag_t = ty.mk_tag(cx.tcx, tag_id, ty_param_tys);
- result_ty = ty.mk_fn(cx.tcx, ast.proto_fn, args, tag_t);
+ auto tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
+ result_ty = ty::mk_fn(cx.tcx, ast::proto_fn, args, tag_t);
}
auto tpt = tup(ty_param_count, result_ty);
@@ -624,22 +624,22 @@ mod Collect {
auto variant_t = rec(ann=triv_ann(variant.node.ann, result_ty)
with variant.node
);
- result += vec(fold.respan[ast.variant_](variant.span, variant_t));
+ result += vec(fold::respan(variant.span, variant_t));
}
ret result;
}
- fn collect(&@ty_item_table id_to_ty_item, &@ast.item i)
+ fn collect(&@ty_item_table id_to_ty_item, &@ast::item i)
-> @ty_item_table {
alt (i.node) {
- case (ast.item_ty(_, _, _, ?def_id, _)) {
+ case (ast::item_ty(_, _, _, ?def_id, _)) {
id_to_ty_item.insert(def_id, any_item_rust(i));
}
- case (ast.item_tag(_, _, _, ?def_id, _)) {
+ case (ast::item_tag(_, _, _, ?def_id, _)) {
id_to_ty_item.insert(def_id, any_item_rust(i));
}
- case (ast.item_obj(_, _, _, ?odid, _)) {
+ case (ast::item_obj(_, _, _, ?odid, _)) {
id_to_ty_item.insert(odid.ty, any_item_rust(i));
}
case (_) { /* empty */ }
@@ -647,14 +647,14 @@ mod Collect {
ret id_to_ty_item;
}
- fn collect_native(&@ty_item_table id_to_ty_item, &@ast.native_item i)
+ fn collect_native(&@ty_item_table id_to_ty_item, &@ast::native_item i)
-> @ty_item_table {
alt (i.node) {
- case (ast.native_item_ty(_, ?def_id)) {
+ case (ast::native_item_ty(_, ?def_id)) {
// The abi of types is not used.
id_to_ty_item.insert(def_id,
any_item_native(i,
- ast.native_abi_cdecl));
+ ast::native_abi_cdecl));
}
case (_) {
}
@@ -662,13 +662,13 @@ mod Collect {
ret id_to_ty_item;
}
- fn convert(&@env e, &@ast.item i) -> @env {
+ fn convert(&@env e, &@ast::item i) -> @env {
auto abi = e.abi;
alt (i.node) {
- case (ast.item_mod(_, _, _)) {
+ case (ast::item_mod(_, _, _)) {
// ignore item_mod, it has no type.
}
- case (ast.item_native_mod(_, ?native_mod, _)) {
+ case (ast::item_native_mod(_, ?native_mod, _)) {
// ignore item_native_mod, it has no type.
abi = native_mod.abi;
}
@@ -681,44 +681,45 @@ mod Collect {
ret @rec(abi=abi with *e);
}
- fn convert_native(&@env e, &@ast.native_item i) -> @env {
+ fn convert_native(&@env e, &@ast::native_item i) -> @env {
ty_of_native_item(e.cx, i, e.abi);
ret e;
}
- fn fold_item_const(&@env e, &span sp, &ast.ident i,
- &@ast.ty t, &@ast.expr ex,
- &ast.def_id id, &ast.ann a) -> @ast.item {
+ fn fold_item_const(&@env e, &span sp, &ast::ident i,
+ &@ast::ty t, &@ast::expr ex,
+ &ast::def_id id, &ast::ann a) -> @ast::item {
// assert (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
- auto item = ast.item_const(i, t, ex, id, triv_ann(a, typ));
- ret @fold.respan[ast.item_](sp, item);
+ auto item = ast::item_const(i, t, ex, id, triv_ann(a, typ));
+ ret @fold::respan[ast::item_](sp, item);
}
- fn fold_item_fn(&@env e, &span sp, &ast.ident i,
- &ast._fn f, &vec[ast.ty_param] ty_params,
- &ast.def_id id, &ast.ann a) -> @ast.item {
+ fn fold_item_fn(&@env e, &span sp, &ast::ident i,
+ &ast::_fn f, &vec[ast::ty_param] ty_params,
+ &ast::def_id id, &ast::ann a) -> @ast::item {
// assert (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
- auto item = ast.item_fn(i, f, ty_params, id, triv_ann(a, typ));
- ret @fold.respan[ast.item_](sp, item);
+ auto item = ast::item_fn(i, f, ty_params, id, triv_ann(a, typ));
+ ret @fold::respan[ast::item_](sp, item);
}
- fn fold_native_item_fn(&@env e, &span sp, &ast.ident i, &Option.t[str] ln,
- &ast.fn_decl d, &vec[ast.ty_param] ty_params,
- &ast.def_id id, &ast.ann a) -> @ast.native_item {
+ fn fold_native_item_fn(&@env e, &span sp, &ast::ident i,
+ &option::t[str] ln,
+ &ast::fn_decl d, &vec[ast::ty_param] ty_params,
+ &ast::def_id id, &ast::ann a) -> @ast::native_item{
// assert (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
- auto item = ast.native_item_fn(i, ln, d, ty_params, id,
+ auto item = ast::native_item_fn(i, ln, d, ty_params, id,
triv_ann(a, typ));
- ret @fold.respan[ast.native_item_](sp, item);
+ ret @fold::respan[ast::native_item_](sp, item);
}
- fn get_ctor_obj_methods(&@env e, &ty.t t) -> vec[method] {
+ fn get_ctor_obj_methods(&@env e, &ty::t t) -> vec[method] {
alt (struct(e.cx.tcx, t)) {
- case (ty.ty_fn(_,_,?tobj)) {
+ case (ty::ty_fn(_,_,?tobj)) {
alt (struct(e.cx.tcx, tobj)) {
- case (ty.ty_obj(?tm)) {
+ case (ty::ty_obj(?tm)) {
ret tm;
}
case (_) {
@@ -735,23 +736,23 @@ mod Collect {
}
- fn fold_item_obj(&@env e, &span sp, &ast.ident i,
- &ast._obj ob, &vec[ast.ty_param] ty_params,
- &ast.obj_def_ids odid, &ast.ann a) -> @ast.item {
+ fn fold_item_obj(&@env e, &span sp, &ast::ident i,
+ &ast::_obj ob, &vec[ast::ty_param] ty_params,
+ &ast::obj_def_ids odid, &ast::ann a) -> @ast::item {
// assert (e.cx.type_cache.contains_key(odid.ctor));
auto t = e.cx.type_cache.get(odid.ctor)._1;
let vec[method] meth_tys = get_ctor_obj_methods(e, t);
- let vec[@ast.method] methods = vec();
- let vec[ast.obj_field] fields = vec();
+ let vec[@ast::method] methods = vec();
+ let vec[ast::obj_field] fields = vec();
- for (@ast.method meth in ob.methods) {
- let uint ix = ty.method_idx(e.cx.sess,
+ for (@ast::method meth in ob.methods) {
+ let uint ix = ty::method_idx(e.cx.sess,
sp, meth.node.ident,
meth_tys);
let method meth_ty = meth_tys.(ix);
- let ast.method_ m_;
- let @ast.method m;
- auto meth_tfn = ty.mk_fn(e.cx.tcx,
+ let ast::method_ m_;
+ let @ast::method m;
+ auto meth_tfn = ty::mk_fn(e.cx.tcx,
meth_ty.proto,
meth_ty.inputs,
meth_ty.output);
@@ -759,85 +760,85 @@ mod Collect {
with meth.node
);
m = @rec(node=m_ with *meth);
- Vec.push[@ast.method](methods, m);
+ _vec::push[@ast::method](methods, m);
}
auto g = bind getter(e.cx, _);
- for (ast.obj_field fld in ob.fields) {
- let ty.t fty = ast_ty_to_ty(e.cx.tcx, g, fld.ty);
- let ast.obj_field f = rec(ann=triv_ann(fld.ann, fty)
+ for (ast::obj_field fld in ob.fields) {
+ let ty::t fty = ast_ty_to_ty(e.cx.tcx, g, fld.ty);
+ let ast::obj_field f = rec(ann=triv_ann(fld.ann, fty)
with fld
);
- Vec.push[ast.obj_field](fields, f);
+ _vec::push[ast::obj_field](fields, f);
}
- auto dtor = none[@ast.method];
+ auto dtor = none[@ast::method];
alt (ob.dtor) {
- case (some[@ast.method](?d)) {
+ case (some[@ast::method](?d)) {
let vec[arg] inputs = vec();
- let ty.t output = ty.mk_nil(e.cx.tcx);
- auto dtor_tfn = ty.mk_fn(e.cx.tcx, ast.proto_fn, inputs,
+ let ty::t output = ty::mk_nil(e.cx.tcx);
+ auto dtor_tfn = ty::mk_fn(e.cx.tcx, ast::proto_fn, inputs,
output);
auto d_ = rec(ann=triv_ann(d.node.ann, dtor_tfn) with d.node);
- dtor = some[@ast.method](@rec(node=d_ with *d));
+ dtor = some[@ast::method](@rec(node=d_ with *d));
}
- case (none[@ast.method]) { }
+ case (none[@ast::method]) { }
}
auto ob_ = rec(methods = methods,
fields = fields,
dtor = dtor
with ob);
- auto item = ast.item_obj(i, ob_, ty_params, odid, triv_ann(a, t));
- ret @fold.respan[ast.item_](sp, item);
+ auto item = ast::item_obj(i, ob_, ty_params, odid, triv_ann(a, t));
+ ret @fold::respan[ast::item_](sp, item);
}
- fn fold_item_ty(&@env e, &span sp, &ast.ident i,
- &@ast.ty t, &vec[ast.ty_param] ty_params,
- &ast.def_id id, &ast.ann a) -> @ast.item {
+ fn fold_item_ty(&@env e, &span sp, &ast::ident i,
+ &@ast::ty t, &vec[ast::ty_param] ty_params,
+ &ast::def_id id, &ast::ann a) -> @ast::item {
// assert (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
- auto item = ast.item_ty(i, t, ty_params, id, triv_ann(a, typ));
- ret @fold.respan[ast.item_](sp, item);
+ auto item = ast::item_ty(i, t, ty_params, id, triv_ann(a, typ));
+ ret @fold::respan[ast::item_](sp, item);
}
- fn fold_item_tag(&@env e, &span sp, &ast.ident i,
- &vec[ast.variant] variants,
- &vec[ast.ty_param] ty_params,
- &ast.def_id id, &ast.ann a) -> @ast.item {
+ fn fold_item_tag(&@env e, &span sp, &ast::ident i,
+ &vec[ast::variant] variants,
+ &vec[ast::ty_param] ty_params,
+ &ast::def_id id, &ast::ann a) -> @ast::item {
auto variants_t = get_tag_variant_types(e.cx, id, variants,
ty_params);
auto typ = e.cx.type_cache.get(id)._1;
- auto item = ast.item_tag(i, variants_t, ty_params, id,
- ast.ann_type(ast.ann_tag(a), typ,
- none[vec[ty.t]],
+ auto item = ast::item_tag(i, variants_t, ty_params, id,
+ ast::ann_type(ast::ann_tag(a), typ,
+ none[vec[ty::t]],
none[@ts_ann]));
- ret @fold.respan[ast.item_](sp, item);
+ ret @fold::respan[ast::item_](sp, item);
}
- fn collect_item_types(&session.session sess, &ty.ctxt tcx,
- &@ast.crate crate)
- -> tup(@ast.crate, ty.type_cache, @ty_item_table) {
- // First pass: collect all type item IDs.
+ fn collect_item_types(&session::session sess, &ty::ctxt tcx,
+ &@ast::crate crate)
+ -> tup(@ast::crate, ty::type_cache, @ty_item_table) {
+ // First pass: collect all type item IDs:
auto module = crate.node.module;
- auto id_to_ty_item = @common.new_def_hash[any_item]();
+ auto id_to_ty_item = @common::new_def_hash[any_item]();
- auto fld_1 = fold.new_identity_fold[@ty_item_table]();
+ auto fld_1 = fold::new_identity_fold[@ty_item_table]();
fld_1 = @rec(update_env_for_item = bind collect(_, _),
update_env_for_native_item = bind collect_native(_, _)
with *fld_1);
- fold.fold_crate[@ty_item_table](id_to_ty_item, fld_1, crate);
+ fold::fold_crate[@ty_item_table](id_to_ty_item, fld_1, crate);
// Second pass: translate the types of all items.
- auto type_cache = common.new_def_hash[ty.ty_param_count_and_ty]();
+ auto type_cache = common::new_def_hash[ty::ty_param_count_and_ty]();
auto cx = @rec(sess=sess,
id_to_ty_item=id_to_ty_item,
type_cache=type_cache,
tcx=tcx);
- let @env e = @rec(cx=cx, abi=ast.native_abi_cdecl);
+ let @env e = @rec(cx=cx, abi=ast::native_abi_cdecl);
- auto fld_2 = fold.new_identity_fold[@env]();
+ auto fld_2 = fold::new_identity_fold[@env]();
fld_2 =
@rec(update_env_for_item = bind convert(_,_),
update_env_for_native_item = bind convert_native(_,_),
@@ -849,7 +850,7 @@ mod Collect {
fold_item_ty = bind fold_item_ty(_,_,_,_,_,_,_),
fold_item_tag = bind fold_item_tag(_,_,_,_,_,_,_)
with *fld_2);
- auto crate_ = fold.fold_crate[@env](e, fld_2, crate);
+ auto crate_ = fold::fold_crate[@env](e, fld_2, crate);
ret tup(crate_, type_cache, id_to_ty_item);
}
}
@@ -858,48 +859,48 @@ mod Collect {
// Type unification
mod Unify {
- fn simple(&@fn_ctxt fcx, &ty.t expected,
- &ty.t actual) -> ty.Unify.result {
+ fn simple(&@fn_ctxt fcx, &ty::t expected,
+ &ty::t actual) -> ty::Unify::result {
// FIXME: horrid botch
- let vec[mutable ty.t] param_substs =
- vec(mutable ty.mk_nil(fcx.ccx.tcx));
- Vec.pop(param_substs);
+ let vec[mutable ty::t] param_substs =
+ vec(mutable ty::mk_nil(fcx.ccx.tcx));
+ _vec::pop(param_substs);
ret with_params(fcx, expected, actual, param_substs);
}
- fn with_params(&@fn_ctxt fcx, &ty.t expected, &ty.t actual,
- &vec[mutable ty.t] param_substs) -> ty.Unify.result {
+ fn with_params(&@fn_ctxt fcx, &ty::t expected, &ty::t actual,
+ &vec[mutable ty::t] param_substs) -> ty::Unify::result {
auto cache_key = tup(expected, actual, param_substs);
alt (fcx.ccx.unify_cache.find(cache_key)) {
- case (some[ty.Unify.result](?r)) {
+ case (some[ty::Unify::result](?r)) {
fcx.ccx.cache_hits += 1u;
ret r;
}
- case (none[ty.Unify.result]) {
+ case (none[ty::Unify::result]) {
fcx.ccx.cache_misses += 1u;
}
}
- obj unify_handler(@fn_ctxt fcx, vec[mutable ty.t] param_substs) {
- fn resolve_local(ast.def_id id) -> Option.t[ty.t] {
+ obj unify_handler(@fn_ctxt fcx, vec[mutable ty::t] param_substs) {
+ fn resolve_local(ast::def_id id) -> option::t[ty::t] {
alt (fcx.locals.find(id)) {
- case (none[ty.t]) { ret none[ty.t]; }
- case (some[ty.t](?existing_type)) {
- if (ty.type_contains_vars(fcx.ccx.tcx,
+ case (none[ty::t]) { ret none[ty::t]; }
+ case (some[ty::t](?existing_type)) {
+ if (ty::type_contains_vars(fcx.ccx.tcx,
existing_type)) {
// Not fully resolved yet. The writeback phase
// will mop up.
- ret none[ty.t];
+ ret none[ty::t];
}
- ret some[ty.t](existing_type);
+ ret some[ty::t](existing_type);
}
}
}
- fn record_local(ast.def_id id, ty.t new_type) {
+ fn record_local(ast::def_id id, ty::t new_type) {
auto unified_type;
alt (fcx.locals.find(id)) {
- case (none[ty.t]) { unified_type = new_type; }
- case (some[ty.t](?old_type)) {
+ case (none[ty::t]) { unified_type = new_type; }
+ case (some[ty::t](?old_type)) {
alt (with_params(fcx, old_type, new_type,
param_substs)) {
case (ures_ok(?ut)) { unified_type = ut; }
@@ -909,19 +910,19 @@ mod Unify {
}
// TODO: "freeze"
- let vec[ty.t] param_substs_1 = vec();
- for (ty.t subst in param_substs) {
+ let vec[ty::t] param_substs_1 = vec();
+ for (ty::t subst in param_substs) {
param_substs_1 += vec(subst);
}
unified_type =
- ty.substitute_type_params(fcx.ccx.tcx, param_substs_1,
+ ty::substitute_type_params(fcx.ccx.tcx, param_substs_1,
unified_type);
fcx.locals.insert(id, unified_type);
}
- fn record_param(uint index, ty.t binding) -> ty.Unify.result {
+ fn record_param(uint index, ty::t binding) -> ty::Unify::result {
// Unify with the appropriate type in the parameter
- // substitution List.
+ // substitution list:
auto old_subst = param_substs.(index);
auto result = with_params(fcx, old_subst, binding,
@@ -929,7 +930,7 @@ mod Unify {
alt (result) {
case (ures_ok(?new_subst)) {
param_substs.(index) = new_subst;
- ret ures_ok(ty.mk_bound_param(fcx.ccx.tcx, index));
+ ret ures_ok(ty::mk_bound_param(fcx.ccx.tcx, index));
}
case (_) { ret result; }
}
@@ -938,7 +939,8 @@ mod Unify {
auto handler = unify_handler(fcx, param_substs);
- auto result = ty.Unify.unify(expected, actual, handler, fcx.ccx.tcx);
+ auto result = ty::Unify::unify(expected, actual, handler,
+ fcx.ccx.tcx);
fcx.ccx.unify_cache.insert(cache_key, result);
ret result;
}
@@ -950,33 +952,33 @@ tag autoderef_kind {
NO_AUTODEREF;
}
-fn strip_boxes(&ty.ctxt tcx, &ty.t t) -> ty.t {
+fn strip_boxes(&ty::ctxt tcx, &ty::t t) -> ty::t {
auto t1 = t;
while (true) {
alt (struct(tcx, t1)) {
- case (ty.ty_box(?inner)) { t1 = inner.ty; }
+ case (ty::ty_box(?inner)) { t1 = inner.ty; }
case (_) { ret t1; }
}
}
fail;
}
-fn add_boxes(&@crate_ctxt ccx, uint n, &ty.t t) -> ty.t {
+fn add_boxes(&@crate_ctxt ccx, uint n, &ty::t t) -> ty::t {
auto t1 = t;
while (n != 0u) {
- t1 = ty.mk_imm_box(ccx.tcx, t1);
+ t1 = ty::mk_imm_box(ccx.tcx, t1);
n -= 1u;
}
ret t1;
}
-fn count_boxes(&ty.ctxt tcx, &ty.t t) -> uint {
+fn count_boxes(&ty::ctxt tcx, &ty::t t) -> uint {
auto n = 0u;
auto t1 = t;
while (true) {
alt (struct(tcx, t1)) {
- case (ty.ty_box(?inner)) { n += 1u; t1 = inner.ty; }
+ case (ty::ty_box(?inner)) { n += 1u; t1 = inner.ty; }
case (_) { ret n; }
}
}
@@ -987,25 +989,26 @@ fn count_boxes(&ty.ctxt tcx, &ty.t t) -> uint {
// Demands - procedures that require that two types unify and emit an error
// message if they don't.
-type ty_param_substs_and_ty = tup(vec[ty.t], ty.t);
+type ty_param_substs_and_ty = tup(vec[ty::t], ty::t);
mod Demand {
- fn simple(&@fn_ctxt fcx, &span sp, &ty.t expected, &ty.t actual) -> ty.t {
- let vec[ty.t] tps = vec();
+ fn simple(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual)
+ -> ty::t {
+ let vec[ty::t] tps = vec();
ret full(fcx, sp, expected, actual, tps, NO_AUTODEREF)._1;
}
- fn autoderef(&@fn_ctxt fcx, &span sp, &ty.t expected, &ty.t actual,
- autoderef_kind adk) -> ty.t {
- let vec[ty.t] tps = vec();
+ fn autoderef(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual,
+ autoderef_kind adk) -> ty::t {
+ let vec[ty::t] tps = vec();
ret full(fcx, sp, expected, actual, tps, adk)._1;
}
// Requires that the two types unify, and prints an error message if they
// don't. Returns the unified type and the type parameter substitutions.
- fn full(&@fn_ctxt fcx, &span sp, &ty.t expected, &ty.t actual,
- &vec[ty.t] ty_param_substs_0, autoderef_kind adk)
+ fn full(&@fn_ctxt fcx, &span sp, &ty::t expected, &ty::t actual,
+ &vec[ty::t] ty_param_substs_0, autoderef_kind adk)
-> ty_param_substs_and_ty {
auto expected_1 = expected;
@@ -1018,18 +1021,18 @@ mod Demand {
implicit_boxes = count_boxes(fcx.ccx.tcx, actual);
}
- let vec[mutable ty.t] ty_param_substs =
- vec(mutable ty.mk_nil(fcx.ccx.tcx));
- Vec.pop(ty_param_substs); // FIXME: horrid botch
- for (ty.t ty_param_subst in ty_param_substs_0) {
+ let vec[mutable ty::t] ty_param_substs =
+ vec(mutable ty::mk_nil(fcx.ccx.tcx));
+ _vec::pop(ty_param_substs); // FIXME: horrid botch
+ for (ty::t ty_param_subst in ty_param_substs_0) {
ty_param_substs += vec(mutable ty_param_subst);
}
- alt (Unify.with_params(fcx, expected_1, actual_1, ty_param_substs)) {
+ alt (Unify::with_params(fcx, expected_1, actual_1, ty_param_substs)) {
case (ures_ok(?t)) {
// TODO: Use "freeze", when we have it.
- let vec[ty.t] result_ty_param_substs = vec();
- for (ty.t ty_param_subst in ty_param_substs) {
+ let vec[ty::t] result_ty_param_substs = vec();
+ for (ty::t ty_param_subst in ty_param_substs) {
result_ty_param_substs += vec(ty_param_subst);
}
@@ -1041,7 +1044,7 @@ mod Demand {
fcx.ccx.sess.span_err(sp, "mismatched types: expected "
+ ty_to_str(fcx.ccx.tcx, expected) + " but found "
+ ty_to_str(fcx.ccx.tcx, actual) + " ("
- + ty.type_err_to_str(err) + ")");
+ + ty::type_err_to_str(err) + ")");
// TODO: In the future, try returning "expected", reporting
// the error, and continue.
@@ -1053,25 +1056,25 @@ mod Demand {
// Returns true if the two types unify and false if they don't.
-fn are_compatible(&@fn_ctxt fcx, &ty.t expected, &ty.t actual) -> bool {
- alt (Unify.simple(fcx, expected, actual)) {
+fn are_compatible(&@fn_ctxt fcx, &ty::t expected, &ty::t actual) -> bool {
+ alt (Unify::simple(fcx, expected, actual)) {
case (ures_ok(_)) { ret true; }
case (ures_err(_, _, _)) { ret false; }
}
}
// Returns the types of the arguments to a tag variant.
-fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast.def_id vid,
- &vec[ty.t] tag_ty_params) -> vec[ty.t] {
- auto ty_param_count = Vec.len[ty.t](tag_ty_params);
+fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
+ &vec[ty::t] tag_ty_params) -> vec[ty::t] {
+ auto ty_param_count = _vec::len[ty::t](tag_ty_params);
- let vec[ty.t] result = vec();
+ let vec[ty::t] result = vec();
- auto tpt = ty.lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, vid);
+ auto tpt = ty::lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, vid);
alt (struct(ccx.tcx, tpt._1)) {
- case (ty.ty_fn(_, ?ins, _)) {
+ case (ty::ty_fn(_, ?ins, _)) {
// N-ary variant.
- for (ty.arg arg in ins) {
+ for (ty::arg arg in ins) {
auto arg_ty = bind_params_in_type(ccx.tcx, arg.ty);
arg_ty = substitute_ty_params(ccx, arg_ty, ty_param_count,
tag_ty_params, sp);
@@ -1109,39 +1112,40 @@ mod Pushdown {
//
// TODO: enforce this via a predicate.
- fn pushdown_pat(&@fn_ctxt fcx, &ty.t expected,
- &@ast.pat pat) -> @ast.pat {
+ fn pushdown_pat(&@fn_ctxt fcx, &ty::t expected,
+ &@ast::pat pat) -> @ast::pat {
auto p_1;
alt (pat.node) {
- case (ast.pat_wild(?ann)) {
- auto t = Demand.simple(fcx, pat.span, expected,
+ case (ast::pat_wild(?ann)) {
+ auto t = Demand::simple(fcx, pat.span, expected,
ann_to_type(ann));
- p_1 = ast.pat_wild(ast.ann_type(ast.ann_tag(ann), t,
- none[vec[ty.t]],
+ p_1 = ast::pat_wild(ast::ann_type(ast::ann_tag(ann), t,
+ none[vec[ty::t]],
none[@ts_ann]));
}
- case (ast.pat_lit(?lit, ?ann)) {
- auto t = Demand.simple(fcx, pat.span, expected,
+ case (ast::pat_lit(?lit, ?ann)) {
+ auto t = Demand::simple(fcx, pat.span, expected,
ann_to_type(ann));
- p_1 = ast.pat_lit(lit, ast.ann_type(ast.ann_tag(ann), t,
- none[vec[ty.t]],
+ p_1 = ast::pat_lit(lit, ast::ann_type(ast::ann_tag(ann), t,
+ none[vec[ty::t]],
none[@ts_ann]));
}
- case (ast.pat_bind(?id, ?did, ?ann)) {
- auto t = Demand.simple(fcx, pat.span, expected,
+ case (ast::pat_bind(?id, ?did, ?ann)) {
+ auto t = Demand::simple(fcx, pat.span, expected,
ann_to_type(ann));
fcx.locals.insert(did, t);
- p_1 = ast.pat_bind(id, did, ast.ann_type(ast.ann_tag(ann), t,
- none[vec[ty.t]],
- none[@ts_ann]));
+ p_1 = ast::pat_bind(id, did, ast::ann_type(ast::ann_tag(ann),
+ t,
+ none[vec[ty::t]],
+ none[@ts_ann]));
}
- case (ast.pat_tag(?id, ?subpats, ?ann)) {
+ case (ast::pat_tag(?id, ?subpats, ?ann)) {
// Take the variant's type parameters out of the expected
// type.
auto tag_tps;
alt (struct(fcx.ccx.tcx, expected)) {
- case (ty.ty_tag(_, ?tps)) { tag_tps = tps; }
+ case (ty::ty_tag(_, ?tps)) { tag_tps = tps; }
case (_) {
log_err "tag pattern type not actually a tag?!";
fail;
@@ -1150,26 +1154,26 @@ mod Pushdown {
// Get the types of the arguments of the variant.
auto arg_tys;
- alt (fcx.ccx.tcx.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_variant(_, ?vdefid)) {
+ alt (fcx.ccx.tcx.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_variant(_, ?vdefid)) {
arg_tys = variant_arg_types(fcx.ccx, pat.span, vdefid,
tag_tps);
}
}
- let vec[@ast.pat] subpats_1 = vec();
+ let vec[@ast::pat] subpats_1 = vec();
auto i = 0u;
- for (@ast.pat subpat in subpats) {
+ for (@ast::pat subpat in subpats) {
subpats_1 += vec(pushdown_pat(fcx, arg_tys.(i), subpat));
i += 1u;
}
// TODO: push down type from "expected".
- p_1 = ast.pat_tag(id, subpats_1, ann);
+ p_1 = ast::pat_tag(id, subpats_1, ann);
}
}
- ret @fold.respan[ast.pat_](pat.span, p_1);
+ ret @fold::respan[ast::pat_](pat.span, p_1);
}
// Push-down over typed expressions. Note that the expression that you
@@ -1178,25 +1182,25 @@ mod Pushdown {
// TODO: enforce this via a predicate.
// TODO: This function is incomplete.
- fn pushdown_expr(&@fn_ctxt fcx, &ty.t expected, &@ast.expr e)
- -> @ast.expr {
+ fn pushdown_expr(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e)
+ -> @ast::expr {
be pushdown_expr_full(fcx, expected, e, NO_AUTODEREF);
}
- fn pushdown_expr_full(&@fn_ctxt fcx, &ty.t expected, &@ast.expr e,
- autoderef_kind adk) -> @ast.expr {
+ fn pushdown_expr_full(&@fn_ctxt fcx, &ty::t expected, &@ast::expr e,
+ autoderef_kind adk) -> @ast::expr {
auto e_1;
alt (e.node) {
- case (ast.expr_vec(?es_0, ?mut, ?ann)) {
+ case (ast::expr_vec(?es_0, ?mut, ?ann)) {
// TODO: enforce mutability
- auto t = Demand.simple(fcx, e.span, expected,
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- let vec[@ast.expr] es_1 = vec();
+ let vec[@ast::expr] es_1 = vec();
alt (struct(fcx.ccx.tcx, t)) {
- case (ty.ty_vec(?mt)) {
- for (@ast.expr e_0 in es_0) {
+ case (ty::ty_vec(?mt)) {
+ for (@ast::expr e_0 in es_0) {
es_1 += vec(pushdown_expr(fcx, mt.ty, e_0));
}
}
@@ -1205,16 +1209,16 @@ mod Pushdown {
fail;
}
}
- e_1 = ast.expr_vec(es_1, mut, triv_ann(ann, t));
+ e_1 = ast::expr_vec(es_1, mut, triv_ann(ann, t));
}
- case (ast.expr_tup(?es_0, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_tup(?es_0, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- let vec[ast.elt] elts_1 = vec();
+ let vec[ast::elt] elts_1 = vec();
alt (struct(fcx.ccx.tcx, t)) {
- case (ty.ty_tup(?mts)) {
+ case (ty::ty_tup(?mts)) {
auto i = 0u;
- for (ast.elt elt_0 in es_0) {
+ for (ast::elt elt_0 in es_0) {
auto e_1 = pushdown_expr(fcx, mts.(i).ty,
elt_0.expr);
elts_1 += vec(rec(mut=elt_0.mut, expr=e_1));
@@ -1226,22 +1230,22 @@ mod Pushdown {
fail;
}
}
- e_1 = ast.expr_tup(elts_1, triv_ann(ann, t));
+ e_1 = ast::expr_tup(elts_1, triv_ann(ann, t));
}
- case (ast.expr_rec(?fields_0, ?base_0, ?ann)) {
+ case (ast::expr_rec(?fields_0, ?base_0, ?ann)) {
auto base_1 = base_0;
- auto t = Demand.simple(fcx, e.span, expected,
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- let vec[ast.field] fields_1 = vec();
+ let vec[ast::field] fields_1 = vec();
alt (struct(fcx.ccx.tcx, t)) {
- case (ty.ty_rec(?field_mts)) {
+ case (ty::ty_rec(?field_mts)) {
alt (base_0) {
- case (none[@ast.expr]) {
+ case (none[@ast::expr]) {
auto i = 0u;
- for (ast.field field_0 in fields_0) {
- assert (Str.eq(field_0.ident,
+ for (ast::field field_0 in fields_0) {
+ assert (_str::eq(field_0.ident,
field_mts.(i).ident));
auto e_1 =
pushdown_expr(fcx,
@@ -1253,17 +1257,17 @@ mod Pushdown {
i += 1u;
}
}
- case (some[@ast.expr](?bx)) {
+ case (some[@ast::expr](?bx)) {
- base_1 = some[@ast.expr](pushdown_expr(fcx, t,
- bx));
+ base_1 = some[@ast::expr]
+ (pushdown_expr(fcx, t, bx));
let vec[field] base_fields = vec();
- for (ast.field field_0 in fields_0) {
+ for (ast::field field_0 in fields_0) {
- for (ty.field ft in field_mts) {
- if (Str.eq(field_0.ident,
+ for (ty::field ft in field_mts) {
+ if (_str::eq(field_0.ident,
ft.ident)) {
auto e_1 =
pushdown_expr(fcx, ft.mt.ty,
@@ -1283,118 +1287,118 @@ mod Pushdown {
fail;
}
}
- e_1 = ast.expr_rec(fields_1, base_1, triv_ann(ann, t));
+ e_1 = ast::expr_rec(fields_1, base_1, triv_ann(ann, t));
}
- case (ast.expr_bind(?sube, ?es, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_bind(?sube, ?es, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_bind(sube, es, triv_ann(ann, t));
+ e_1 = ast::expr_bind(sube, es, triv_ann(ann, t));
}
- case (ast.expr_call(?sube, ?es, ?ann)) {
- // NB: we call 'Demand.autoderef' and pass in adk only in
+ case (ast::expr_call(?sube, ?es, ?ann)) {
+ // NB: we call 'Demand::autoderef' and pass in adk only in
// cases where e is an expression that could *possibly*
// produce a box; things like expr_binary or expr_bind can't,
// so there's no need.
- auto t = Demand.autoderef(fcx, e.span, expected,
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
- e_1 = ast.expr_call(sube, es, triv_ann(ann, t));
+ e_1 = ast::expr_call(sube, es, triv_ann(ann, t));
}
- case (ast.expr_self_method(?id, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_self_method(?id, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_self_method(id, triv_ann(ann, t));
+ e_1 = ast::expr_self_method(id, triv_ann(ann, t));
}
- case (ast.expr_binary(?bop, ?lhs, ?rhs, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_binary(?bop, ?lhs, ?rhs, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_binary(bop, lhs, rhs, triv_ann(ann, t));
+ e_1 = ast::expr_binary(bop, lhs, rhs, triv_ann(ann, t));
}
- case (ast.expr_unary(?uop, ?sube, ?ann)) {
+ case (ast::expr_unary(?uop, ?sube, ?ann)) {
// See note in expr_unary for why we're calling
- // Demand.autoderef.
- auto t = Demand.autoderef(fcx, e.span, expected,
+ // Demand::autoderef.
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
- e_1 = ast.expr_unary(uop, sube, triv_ann(ann, t));
+ e_1 = ast::expr_unary(uop, sube, triv_ann(ann, t));
}
- case (ast.expr_lit(?lit, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_lit(?lit, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_lit(lit, triv_ann(ann, t));
+ e_1 = ast::expr_lit(lit, triv_ann(ann, t));
}
- case (ast.expr_cast(?sube, ?ast_ty, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_cast(?sube, ?ast_ty, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_cast(sube, ast_ty, triv_ann(ann, t));
+ e_1 = ast::expr_cast(sube, ast_ty, triv_ann(ann, t));
}
- case (ast.expr_if(?cond, ?then_0, ?else_0, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_if(?cond, ?then_0, ?else_0, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
auto then_1 = pushdown_block(fcx, expected, then_0);
auto else_1;
alt (else_0) {
- case (none[@ast.expr]) { else_1 = none[@ast.expr]; }
- case (some[@ast.expr](?e_0)) {
+ case (none[@ast::expr]) { else_1 = none[@ast::expr]; }
+ case (some[@ast::expr](?e_0)) {
auto e_1 = pushdown_expr(fcx, expected, e_0);
- else_1 = some[@ast.expr](e_1);
+ else_1 = some[@ast::expr](e_1);
}
}
- e_1 = ast.expr_if(cond, then_1, else_1, triv_ann(ann, t));
+ e_1 = ast::expr_if(cond, then_1, else_1, triv_ann(ann, t));
}
- case (ast.expr_for(?decl, ?seq, ?bloc, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_for(?decl, ?seq, ?bloc, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_for(decl, seq, bloc, triv_ann(ann, t));
+ e_1 = ast::expr_for(decl, seq, bloc, triv_ann(ann, t));
}
- case (ast.expr_for_each(?decl, ?seq, ?bloc, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_for_each(?decl, ?seq, ?bloc, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_for_each(decl, seq, bloc, triv_ann(ann, t));
+ e_1 = ast::expr_for_each(decl, seq, bloc, triv_ann(ann, t));
}
- case (ast.expr_while(?cond, ?bloc, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_while(?cond, ?bloc, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_while(cond, bloc, triv_ann(ann, t));
+ e_1 = ast::expr_while(cond, bloc, triv_ann(ann, t));
}
- case (ast.expr_do_while(?bloc, ?cond, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_do_while(?bloc, ?cond, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_do_while(bloc, cond, triv_ann(ann, t));
+ e_1 = ast::expr_do_while(bloc, cond, triv_ann(ann, t));
}
- case (ast.expr_block(?bloc, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_block(?bloc, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
- e_1 = ast.expr_block(bloc, triv_ann(ann, t));
+ e_1 = ast::expr_block(bloc, triv_ann(ann, t));
}
- case (ast.expr_assign(?lhs_0, ?rhs_0, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_assign(?lhs_0, ?rhs_0, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
auto lhs_1 = pushdown_expr(fcx, expected, lhs_0);
auto rhs_1 = pushdown_expr(fcx, expected, rhs_0);
- e_1 = ast.expr_assign(lhs_1, rhs_1, triv_ann(ann, t));
+ e_1 = ast::expr_assign(lhs_1, rhs_1, triv_ann(ann, t));
}
- case (ast.expr_assign_op(?op, ?lhs_0, ?rhs_0, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_assign_op(?op, ?lhs_0, ?rhs_0, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
auto lhs_1 = pushdown_expr(fcx, expected, lhs_0);
auto rhs_1 = pushdown_expr(fcx, expected, rhs_0);
- e_1 = ast.expr_assign_op(op, lhs_1, rhs_1, triv_ann(ann, t));
+ e_1 = ast::expr_assign_op(op, lhs_1, rhs_1, triv_ann(ann, t));
}
- case (ast.expr_field(?lhs, ?rhs, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_field(?lhs, ?rhs, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
- e_1 = ast.expr_field(lhs, rhs, triv_ann(ann, t));
+ e_1 = ast::expr_field(lhs, rhs, triv_ann(ann, t));
}
- case (ast.expr_index(?base, ?index, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_index(?base, ?index, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
- e_1 = ast.expr_index(base, index, triv_ann(ann, t));
+ e_1 = ast::expr_index(base, index, triv_ann(ann, t));
}
- case (ast.expr_path(?pth, ?ann)) {
- auto tp_substs_0 = ty.ann_to_type_params(ann);
+ case (ast::expr_path(?pth, ?ann)) {
+ auto tp_substs_0 = ty::ann_to_type_params(ann);
auto t_0 = ann_to_type(ann);
- auto result_0 = Demand.full(fcx, e.span, expected, t_0,
+ auto result_0 = Demand::full(fcx, e.span, expected, t_0,
tp_substs_0, adk);
auto t = result_0._1;
@@ -1402,57 +1406,58 @@ mod Pushdown {
// provided by the programmer.
auto ty_params_opt;
alt (ann) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log_err "pushdown_expr(): no type annotation for " +
"path expr; did you pass it to check_expr()?";
fail;
}
- case (ast.ann_type(_, _, ?tps_opt, _)) {
+ case (ast::ann_type(_, _, ?tps_opt, _)) {
alt (tps_opt) {
- case (none[vec[ty.t]]) {
- ty_params_opt = none[vec[ty.t]];
+ case (none[vec[ty::t]]) {
+ ty_params_opt = none[vec[ty::t]];
}
- case (some[vec[ty.t]](?tps)) {
- ty_params_opt = some[vec[ty.t]](tps);
+ case (some[vec[ty::t]](?tps)) {
+ ty_params_opt = some[vec[ty::t]](tps);
}
}
}
}
- e_1 = ast.expr_path(pth,
- ast.ann_type(ast.ann_tag(ann), t,
+ e_1 = ast::expr_path(pth,
+ ast::ann_type(ast::ann_tag(ann), t,
ty_params_opt,
none[@ts_ann]));
}
- case (ast.expr_ext(?p, ?args, ?body, ?expanded, ?ann)) {
- auto t = Demand.autoderef(fcx, e.span, expected,
+ case (ast::expr_ext(?p, ?args, ?body, ?expanded, ?ann)) {
+ auto t = Demand::autoderef(fcx, e.span, expected,
ann_to_type(ann), adk);
- e_1 = ast.expr_ext(p, args, body, expanded, triv_ann(ann, t));
+ e_1 = ast::expr_ext(p, args, body, expanded,
+ triv_ann(ann, t));
}
/* FIXME: should this check the type annotations? */
- case (ast.expr_fail(_)) { e_1 = e.node; }
- case (ast.expr_log(_,_,_)) { e_1 = e.node; }
- case (ast.expr_break(_)) { e_1 = e.node; }
- case (ast.expr_cont(_)) { e_1 = e.node; }
- case (ast.expr_ret(_,_)) { e_1 = e.node; }
- case (ast.expr_put(_,_)) { e_1 = e.node; }
- case (ast.expr_be(_,_)) { e_1 = e.node; }
- case (ast.expr_check(_,_)) { e_1 = e.node; }
- case (ast.expr_assert(_,_)) { e_1 = e.node; }
-
- case (ast.expr_port(?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_fail(_)) { e_1 = e.node; }
+ case (ast::expr_log(_,_,_)) { e_1 = e.node; }
+ case (ast::expr_break(_)) { e_1 = e.node; }
+ case (ast::expr_cont(_)) { e_1 = e.node; }
+ case (ast::expr_ret(_,_)) { e_1 = e.node; }
+ case (ast::expr_put(_,_)) { e_1 = e.node; }
+ case (ast::expr_be(_,_)) { e_1 = e.node; }
+ case (ast::expr_check(_,_)) { e_1 = e.node; }
+ case (ast::expr_assert(_,_)) { e_1 = e.node; }
+
+ case (ast::expr_port(?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- e_1 = ast.expr_port(triv_ann(ann, t));
+ e_1 = ast::expr_port(triv_ann(ann, t));
}
- case (ast.expr_chan(?es, ?ann)) {
- auto t = Demand.simple(fcx, e.span, expected,
+ case (ast::expr_chan(?es, ?ann)) {
+ auto t = Demand::simple(fcx, e.span, expected,
ann_to_type(ann));
- let @ast.expr es_1;
+ let @ast::expr es_1;
alt (struct(fcx.ccx.tcx, t)) {
- case (ty.ty_chan(?subty)) {
- auto pt = ty.mk_port(fcx.ccx.tcx, subty);
+ case (ty::ty_chan(?subty)) {
+ auto pt = ty::mk_port(fcx.ccx.tcx, subty);
es_1 = pushdown_expr(fcx, pt, es);
}
case (_) {
@@ -1460,66 +1465,66 @@ mod Pushdown {
fail;
}
}
- e_1 = ast.expr_chan(es_1, triv_ann(ann, t));
+ e_1 = ast::expr_chan(es_1, triv_ann(ann, t));
}
- case (ast.expr_alt(?discrim, ?arms_0, ?ann)) {
+ case (ast::expr_alt(?discrim, ?arms_0, ?ann)) {
auto t = expected;
- let vec[ast.arm] arms_1 = vec();
- for (ast.arm arm_0 in arms_0) {
+ let vec[ast::arm] arms_1 = vec();
+ for (ast::arm arm_0 in arms_0) {
auto block_1 = pushdown_block(fcx, expected, arm_0.block);
- t = Demand.simple(fcx, e.span, t,
+ t = Demand::simple(fcx, e.span, t,
block_ty(fcx.ccx.tcx, block_1));
auto arm_1 = rec(pat=arm_0.pat, block=block_1);
arms_1 += vec(arm_1);
}
- e_1 = ast.expr_alt(discrim, arms_1, triv_ann(ann, t));
+ e_1 = ast::expr_alt(discrim, arms_1, triv_ann(ann, t));
}
- case (ast.expr_recv(?lval_0, ?expr_0, ?ann)) {
+ case (ast::expr_recv(?lval_0, ?expr_0, ?ann)) {
auto lval_1 = pushdown_expr(fcx, next_ty_var(fcx.ccx),
lval_0);
auto t = expr_ty(fcx.ccx.tcx, lval_1);
- auto expr_1 = pushdown_expr(fcx, ty.mk_port(fcx.ccx.tcx, t),
+ auto expr_1 = pushdown_expr(fcx, ty::mk_port(fcx.ccx.tcx, t),
expr_0);
- e_1 = ast.expr_recv(lval_1, expr_1, ann);
+ e_1 = ast::expr_recv(lval_1, expr_1, ann);
}
- case (ast.expr_send(?lval_0, ?expr_0, ?ann)) {
+ case (ast::expr_send(?lval_0, ?expr_0, ?ann)) {
auto expr_1 = pushdown_expr(fcx, next_ty_var(fcx.ccx),
expr_0);
auto t = expr_ty(fcx.ccx.tcx, expr_1);
- auto lval_1 = pushdown_expr(fcx, ty.mk_chan(fcx.ccx.tcx, t),
+ auto lval_1 = pushdown_expr(fcx, ty::mk_chan(fcx.ccx.tcx, t),
lval_0);
- e_1 = ast.expr_send(lval_1, expr_1, ann);
+ e_1 = ast::expr_send(lval_1, expr_1, ann);
}
case (_) {
fcx.ccx.sess.span_unimpl(e.span,
#fmt("type unification for expression variant: %s",
- util.common.expr_to_str(e)));
+ util::common::expr_to_str(e)));
fail;
}
}
- ret @fold.respan[ast.expr_](e.span, e_1);
+ ret @fold::respan[ast::expr_](e.span, e_1);
}
// Push-down over typed blocks.
- fn pushdown_block(&@fn_ctxt fcx, &ty.t expected, &ast.block bloc)
- -> ast.block {
+ fn pushdown_block(&@fn_ctxt fcx, &ty::t expected, &ast::block bloc)
+ -> ast::block {
alt (bloc.node.expr) {
- case (some[@ast.expr](?e_0)) {
+ case (some[@ast::expr](?e_0)) {
auto e_1 = pushdown_expr(fcx, expected, e_0);
auto block_ = rec(stmts=bloc.node.stmts,
- expr=some[@ast.expr](e_1),
+ expr=some[@ast::expr](e_1),
a=plain_ann(bloc.node.a, fcx.ccx.tcx));
- ret fold.respan[ast.block_](bloc.span, block_);
+ ret fold::respan[ast::block_](bloc.span, block_);
}
- case (none[@ast.expr]) {
- Demand.simple(fcx, bloc.span, expected,
- ty.mk_nil(fcx.ccx.tcx));
- ret fold.respan(bloc.span,
+ case (none[@ast::expr]) {
+ Demand::simple(fcx, bloc.span, expected,
+ ty::mk_nil(fcx.ccx.tcx));
+ ret fold::respan(bloc.span,
rec(a = plain_ann(bloc.node.a, fcx.ccx.tcx)
with bloc.node));
@@ -1532,18 +1537,18 @@ mod Pushdown {
// Local variable resolution: the phase that finds all the types in the AST
// and replaces opaque "ty_local" types with the resolved local types.
-fn writeback_local(&Option.t[@fn_ctxt] env, &span sp, &@ast.local local)
- -> @ast.decl {
- auto fcx = Option.get[@fn_ctxt](env);
+fn writeback_local(&option::t[@fn_ctxt] env, &span sp, &@ast::local local)
+ -> @ast::decl {
+ auto fcx = option::get[@fn_ctxt](env);
auto local_ty;
alt (fcx.locals.find(local.id)) {
- case (none[ty.t]) {
+ case (none[ty::t]) {
fcx.ccx.sess.span_err(sp, "unable to determine type of local: "
+ local.ident);
fail;
}
- case (some[ty.t](?lt)) {
+ case (some[ty::t](?lt)) {
local_ty = lt;
}
}
@@ -1551,48 +1556,48 @@ fn writeback_local(&Option.t[@fn_ctxt] env, &span sp, &@ast.local local)
auto local_wb = @rec(ann=triv_ann(local.ann, local_ty)
with *local
);
- ret @fold.respan[ast.decl_](sp, ast.decl_local(local_wb));
+ ret @fold::respan[ast::decl_](sp, ast::decl_local(local_wb));
}
-fn resolve_local_types_in_annotation(&Option.t[@fn_ctxt] env, &ast.ann ann)
- -> ast.ann {
- fn resolver(@fn_ctxt fcx, ty.t typ) -> ty.t {
+fn resolve_local_types_in_annotation(&option::t[@fn_ctxt] env, &ast::ann ann)
+ -> ast::ann {
+ fn resolver(@fn_ctxt fcx, ty::t typ) -> ty::t {
alt (struct(fcx.ccx.tcx, typ)) {
- case (ty.ty_local(?lid)) { ret fcx.locals.get(lid); }
+ case (ty::ty_local(?lid)) { ret fcx.locals.get(lid); }
case (_) { ret typ; }
}
}
- auto fcx = Option.get[@fn_ctxt](env);
+ auto fcx = option::get[@fn_ctxt](env);
alt (ann) {
- case (ast.ann_none(_)) {
+ case (ast::ann_none(_)) {
log "warning: no type for expression";
ret ann;
}
- case (ast.ann_type(?tg, ?typ, ?tps, ?ts_info)) {
+ case (ast::ann_type(?tg, ?typ, ?tps, ?ts_info)) {
auto tt = ann_to_type(ann);
- if (!ty.type_contains_locals(fcx.ccx.tcx, tt)) {
+ if (!ty::type_contains_locals(fcx.ccx.tcx, tt)) {
ret ann;
}
auto f = bind resolver(fcx, _);
- auto new_type = ty.fold_ty(fcx.ccx.tcx, f, ann_to_type(ann));
- ret ast.ann_type(tg, new_type, tps, ts_info);
+ auto new_type = ty::fold_ty(fcx.ccx.tcx, f, ann_to_type(ann));
+ ret ast::ann_type(tg, new_type, tps, ts_info);
}
}
}
-fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block)
- -> ast.block {
- fn update_env_for_item(&Option.t[@fn_ctxt] env, &@ast.item i)
- -> Option.t[@fn_ctxt] {
+fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast::block block)
+ -> ast::block {
+ fn update_env_for_item(&option::t[@fn_ctxt] env, &@ast::item i)
+ -> option::t[@fn_ctxt] {
ret none[@fn_ctxt];
}
- fn keep_going(&Option.t[@fn_ctxt] env) -> bool {
- ret !Option.is_none[@fn_ctxt](env);
+ fn keep_going(&option::t[@fn_ctxt] env) -> bool {
+ ret !option::is_none[@fn_ctxt](env);
}
// FIXME: rustboot bug prevents us from using these functions directly
- auto fld = fold.new_identity_fold[Option.t[@fn_ctxt]]();
+ auto fld = fold::new_identity_fold[option::t[@fn_ctxt]]();
auto wbl = writeback_local;
auto rltia = bind resolve_local_types_in_annotation(_,_);
auto uefi = update_env_for_item;
@@ -1602,137 +1607,137 @@ fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block)
update_env_for_item = uefi,
keep_going = kg
with *fld);
- ret fold.fold_block[Option.t[@fn_ctxt]](some[@fn_ctxt](fcx), fld, block);
+ ret fold::fold_block[option::t[@fn_ctxt]](some(fcx), fld, block);
}
// AST fragment checking
-fn check_lit(@crate_ctxt ccx, &@ast.lit lit) -> ty.t {
+fn check_lit(@crate_ctxt ccx, &@ast::lit lit) -> ty::t {
alt (lit.node) {
- case (ast.lit_str(_)) { ret ty.mk_str(ccx.tcx); }
- case (ast.lit_char(_)) { ret ty.mk_char(ccx.tcx); }
- case (ast.lit_int(_)) { ret ty.mk_int(ccx.tcx); }
- case (ast.lit_float(_)) { ret ty.mk_float(ccx.tcx); }
- case (ast.lit_mach_float(?tm, _))
- { ret ty.mk_mach(ccx.tcx, tm); }
- case (ast.lit_uint(_)) { ret ty.mk_uint(ccx.tcx); }
- case (ast.lit_mach_int(?tm, _)) { ret ty.mk_mach(ccx.tcx, tm); }
- case (ast.lit_nil) { ret ty.mk_nil(ccx.tcx); }
- case (ast.lit_bool(_)) { ret ty.mk_bool(ccx.tcx); }
+ case (ast::lit_str(_)) { ret ty::mk_str(ccx.tcx); }
+ case (ast::lit_char(_)) { ret ty::mk_char(ccx.tcx); }
+ case (ast::lit_int(_)) { ret ty::mk_int(ccx.tcx); }
+ case (ast::lit_float(_)) { ret ty::mk_float(ccx.tcx); }
+ case (ast::lit_mach_float(?tm, _))
+ { ret ty::mk_mach(ccx.tcx, tm); }
+ case (ast::lit_uint(_)) { ret ty::mk_uint(ccx.tcx); }
+ case (ast::lit_mach_int(?tm, _)) { ret ty::mk_mach(ccx.tcx, tm); }
+ case (ast::lit_nil) { ret ty::mk_nil(ccx.tcx); }
+ case (ast::lit_bool(_)) { ret ty::mk_bool(ccx.tcx); }
}
fail; // not reached
}
-fn check_pat(&@fn_ctxt fcx, &@ast.pat pat) -> @ast.pat {
+fn check_pat(&@fn_ctxt fcx, &@ast::pat pat) -> @ast::pat {
auto new_pat;
alt (pat.node) {
- case (ast.pat_wild(?ann)) {
- new_pat = ast.pat_wild(triv_ann(ann, next_ty_var(fcx.ccx)));
+ case (ast::pat_wild(?ann)) {
+ new_pat = ast::pat_wild(triv_ann(ann, next_ty_var(fcx.ccx)));
}
- case (ast.pat_lit(?lt, ?ann)) {
- new_pat = ast.pat_lit(lt, triv_ann(ann, check_lit(fcx.ccx, lt)));
+ case (ast::pat_lit(?lt, ?ann)) {
+ new_pat = ast::pat_lit(lt, triv_ann(ann, check_lit(fcx.ccx, lt)));
}
- case (ast.pat_bind(?id, ?def_id, ?a)) {
+ case (ast::pat_bind(?id, ?def_id, ?a)) {
auto ann = triv_ann(a, next_ty_var(fcx.ccx));
- new_pat = ast.pat_bind(id, def_id, ann);
+ new_pat = ast::pat_bind(id, def_id, ann);
}
- case (ast.pat_tag(?p, ?subpats, ?old_ann)) {
- auto vdef = ast.variant_def_ids
- (fcx.ccx.tcx.def_map.get(ast.ann_tag(old_ann)));
- auto t = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ case (ast::pat_tag(?p, ?subpats, ?old_ann)) {
+ auto vdef = ast::variant_def_ids
+ (fcx.ccx.tcx.def_map.get(ast::ann_tag(old_ann)));
+ auto t = ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, vdef._1)._1;
- auto len = Vec.len[ast.ident](p.node.idents);
+ auto len = _vec::len[ast::ident](p.node.idents);
auto last_id = p.node.idents.(len - 1u);
- auto tpt = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
+ auto tpt = ty::lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
fcx.ccx.type_cache, vdef._0);
auto ann = instantiate_path(fcx, p, tpt, pat.span,
- ast.ann_tag(old_ann));
+ ast::ann_tag(old_ann));
alt (struct(fcx.ccx.tcx, t)) {
// N-ary variants have function types.
- case (ty.ty_fn(_, ?args, ?tag_ty)) {
- auto arg_len = Vec.len[arg](args);
- auto subpats_len = Vec.len[@ast.pat](subpats);
+ case (ty::ty_fn(_, ?args, ?tag_ty)) {
+ auto arg_len = _vec::len[arg](args);
+ auto subpats_len = _vec::len[@ast::pat](subpats);
if (arg_len != subpats_len) {
// TODO: pluralize properly
auto err_msg = "tag type " + last_id + " has " +
- UInt.to_str(subpats_len, 10u) +
+ _uint::to_str(subpats_len, 10u) +
" field(s), but this pattern has " +
- UInt.to_str(arg_len, 10u) +
+ _uint::to_str(arg_len, 10u) +
" field(s)";
fcx.ccx.sess.span_err(pat.span, err_msg);
fail; // TODO: recover
}
- let vec[@ast.pat] new_subpats = vec();
- for (@ast.pat subpat in subpats) {
+ let vec[@ast::pat] new_subpats = vec();
+ for (@ast::pat subpat in subpats) {
new_subpats += vec(check_pat(fcx, subpat));
}
- new_pat = ast.pat_tag(p, new_subpats, ann);
+ new_pat = ast::pat_tag(p, new_subpats, ann);
}
// Nullary variants have tag types.
- case (ty.ty_tag(?tid, _)) {
- auto subpats_len = Vec.len[@ast.pat](subpats);
+ case (ty::ty_tag(?tid, _)) {
+ auto subpats_len = _vec::len[@ast::pat](subpats);
if (subpats_len > 0u) {
// TODO: pluralize properly
auto err_msg = "tag type " + last_id +
" has no field(s)," +
" but this pattern has " +
- UInt.to_str(subpats_len, 10u) +
+ _uint::to_str(subpats_len, 10u) +
" field(s)";
fcx.ccx.sess.span_err(pat.span, err_msg);
fail; // TODO: recover
}
- new_pat = ast.pat_tag(p, subpats, ann);
+ new_pat = ast::pat_tag(p, subpats, ann);
}
}
}
}
- ret @fold.respan[ast.pat_](pat.span, new_pat);
+ ret @fold::respan[ast::pat_](pat.span, new_pat);
}
-fn require_impure(&session.session sess,
- &ast.purity f_purity, &span sp) -> () {
+fn require_impure(&session::session sess,
+ &ast::purity f_purity, &span sp) -> () {
alt (f_purity) {
- case (ast.impure_fn) {
+ case (ast::impure_fn) {
ret;
}
- case (ast.pure_fn) {
+ case (ast::pure_fn) {
sess.span_err(sp,
"Found impure expression in pure function decl");
}
}
}
-fn get_function_purity(@crate_ctxt ccx, &ast.def_id d_id) -> ast.purity {
- let Option.t[ast.purity] o = ccx.fn_purity_table.find(d_id);
- ret from_maybe[ast.purity](ast.impure_fn, o);
+fn get_function_purity(@crate_ctxt ccx, &ast::def_id d_id) -> ast::purity {
+ let option::t[ast::purity] o = ccx.fn_purity_table.find(d_id);
+ ret from_maybe[ast::purity](ast::impure_fn, o);
}
fn require_pure_call(@crate_ctxt ccx,
- &ast.purity caller_purity,
- &@ast.expr callee, &span sp) -> () {
+ &ast::purity caller_purity,
+ &@ast::expr callee, &span sp) -> () {
alt (caller_purity) {
- case (ast.impure_fn) {
+ case (ast::impure_fn) {
ret;
}
- case (ast.pure_fn) {
+ case (ast::pure_fn) {
alt (callee.node) {
- case (ast.expr_path(_, ?ann)) {
+ case (ast::expr_path(_, ?ann)) {
auto d_id;
- alt (ccx.tcx.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_fn(?_d_id)) { d_id = _d_id; }
+ alt (ccx.tcx.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_fn(?_d_id)) { d_id = _d_id; }
}
alt (get_function_purity(ccx, d_id)) {
- case (ast.pure_fn) {
+ case (ast::pure_fn) {
ret;
}
case (_) {
@@ -1751,46 +1756,46 @@ fn require_pure_call(@crate_ctxt ccx,
}
}
-fn require_pure_function(@crate_ctxt ccx, &ast.def_id d_id, &span sp) -> () {
+fn require_pure_function(@crate_ctxt ccx, &ast::def_id d_id, &span sp) -> () {
alt (get_function_purity(ccx, d_id)) {
- case (ast.impure_fn) {
+ case (ast::impure_fn) {
ccx.sess.span_err(sp, "Found non-predicate in check expression");
}
case (_) { ret; }
}
}
-fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
+fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
//fcx.ccx.sess.span_warn(expr.span, "typechecking expr " +
- // util.common.expr_to_str(expr));
+ // util::common::expr_to_str(expr));
// A generic function to factor out common logic from call and bind
// expressions.
- fn check_call_or_bind(&@fn_ctxt fcx, &@ast.expr f,
- &vec[Option.t[@ast.expr]] args)
- -> tup(@ast.expr, vec[Option.t[@ast.expr]]) {
+ fn check_call_or_bind(&@fn_ctxt fcx, &@ast::expr f,
+ &vec[option::t[@ast::expr]] args)
+ -> tup(@ast::expr, vec[option::t[@ast::expr]]) {
// Check the function.
auto f_0 = check_expr(fcx, f);
// Check the arguments and generate the argument signature.
- let vec[Option.t[@ast.expr]] args_0 = vec();
+ let vec[option::t[@ast::expr]] args_0 = vec();
let vec[arg] arg_tys_0 = vec();
- for (Option.t[@ast.expr] a_opt in args) {
+ for (option::t[@ast::expr] a_opt in args) {
alt (a_opt) {
- case (some[@ast.expr](?a)) {
+ case (some[@ast::expr](?a)) {
auto a_0 = check_expr(fcx, a);
- args_0 += vec(some[@ast.expr](a_0));
+ args_0 += vec(some[@ast::expr](a_0));
auto arg_ty = rec(mode=mo_either,
ty=expr_ty(fcx.ccx.tcx, a_0));
- Vec.push[arg](arg_tys_0, arg_ty);
+ _vec::push[arg](arg_tys_0, arg_ty);
}
- case (none[@ast.expr]) {
- args_0 += vec(none[@ast.expr]);
+ case (none[@ast::expr]) {
+ args_0 += vec(none[@ast::expr]);
auto typ = next_ty_var(fcx.ccx);
- Vec.push[arg](arg_tys_0, rec(mode=mo_either, ty=typ));
+ _vec::push[arg](arg_tys_0, rec(mode=mo_either, ty=typ));
}
}
}
@@ -1798,11 +1803,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
auto rt_0 = next_ty_var(fcx.ccx);
auto t_0;
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, f_0))) {
- case (ty.ty_fn(?proto, _, _)) {
- t_0 = ty.mk_fn(fcx.ccx.tcx, proto, arg_tys_0, rt_0);
+ case (ty::ty_fn(?proto, _, _)) {
+ t_0 = ty::mk_fn(fcx.ccx.tcx, proto, arg_tys_0, rt_0);
}
- case (ty.ty_native_fn(?abi, _, _)) {
- t_0 = ty.mk_native_fn(fcx.ccx.tcx, abi, arg_tys_0, rt_0);
+ case (ty::ty_native_fn(?abi, _, _)) {
+ t_0 = ty::mk_native_fn(fcx.ccx.tcx, abi, arg_tys_0, rt_0);
}
case (_) {
log_err "check_call_or_bind(): fn expr doesn't have fn type";
@@ -1811,25 +1816,25 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
// Unify the callee and arguments.
- auto tpt_0 = ty.expr_ty_params_and_ty(fcx.ccx.tcx, f_0);
- auto tpt_1 = Demand.full(fcx, f.span, tpt_0._1, t_0, tpt_0._0,
+ auto tpt_0 = ty::expr_ty_params_and_ty(fcx.ccx.tcx, f_0);
+ auto tpt_1 = Demand::full(fcx, f.span, tpt_0._1, t_0, tpt_0._0,
NO_AUTODEREF);
- auto f_1 = ty.replace_expr_type(f_0, tpt_1);
+ auto f_1 = ty::replace_expr_type(f_0, tpt_1);
ret tup(f_1, args_0);
}
// A generic function for checking assignment expressions
- fn check_assignment(&@fn_ctxt fcx, &@ast.expr lhs, &@ast.expr rhs,
- &ast.ann a)
- -> tup(@ast.expr, @ast.expr, ast.ann) {
+ fn check_assignment(&@fn_ctxt fcx, &@ast::expr lhs, &@ast::expr rhs,
+ &ast::ann a)
+ -> tup(@ast::expr, @ast::expr, ast::ann) {
auto lhs_0 = check_expr(fcx, lhs);
auto rhs_0 = check_expr(fcx, rhs);
auto lhs_t0 = expr_ty(fcx.ccx.tcx, lhs_0);
auto rhs_t0 = expr_ty(fcx.ccx.tcx, rhs_0);
- auto lhs_1 = Pushdown.pushdown_expr(fcx, rhs_t0, lhs_0);
- auto rhs_1 = Pushdown.pushdown_expr(fcx, expr_ty(fcx.ccx.tcx, lhs_1),
+ auto lhs_1 = Pushdown::pushdown_expr(fcx, rhs_t0, lhs_0);
+ auto rhs_1 = Pushdown::pushdown_expr(fcx, expr_ty(fcx.ccx.tcx, lhs_1),
rhs_0);
auto ann = triv_ann(a, expr_ty(fcx.ccx.tcx, rhs_1));
@@ -1837,77 +1842,77 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
// A generic function for checking call expressions
- fn check_call(&@fn_ctxt fcx, &@ast.expr f, &vec[@ast.expr] args)
- -> tup(@ast.expr, vec[@ast.expr]) {
+ fn check_call(&@fn_ctxt fcx, &@ast::expr f, &vec[@ast::expr] args)
+ -> tup(@ast::expr, vec[@ast::expr]) {
- let vec[Option.t[@ast.expr]] args_opt_0 = vec();
- for (@ast.expr arg in args) {
- args_opt_0 += vec(some[@ast.expr](arg));
+ let vec[option::t[@ast::expr]] args_opt_0 = vec();
+ for (@ast::expr arg in args) {
+ args_opt_0 += vec(some[@ast::expr](arg));
}
// Call the generic checker.
auto result = check_call_or_bind(fcx, f, args_opt_0);
// Pull out the arguments.
- let vec[@ast.expr] args_1 = vec();
- for (Option.t[@ast.expr] arg in result._1) {
- args_1 += vec(Option.get[@ast.expr](arg));
+ let vec[@ast::expr] args_1 = vec();
+ for (option::t[@ast::expr] arg in result._1) {
+ args_1 += vec(option::get[@ast::expr](arg));
}
ret tup(result._0, args_1);
}
alt (expr.node) {
- case (ast.expr_lit(?lit, ?a)) {
+ case (ast::expr_lit(?lit, ?a)) {
auto typ = check_lit(fcx.ccx, lit);
auto ann = triv_ann(a, typ);
- ret @fold.respan[ast.expr_](expr.span, ast.expr_lit(lit, ann));
+ ret @fold::respan[ast::expr_](expr.span, ast::expr_lit(lit, ann));
}
- case (ast.expr_binary(?binop, ?lhs, ?rhs, ?a)) {
+ case (ast::expr_binary(?binop, ?lhs, ?rhs, ?a)) {
auto lhs_0 = check_expr(fcx, lhs);
auto rhs_0 = check_expr(fcx, rhs);
auto lhs_t0 = expr_ty(fcx.ccx.tcx, lhs_0);
auto rhs_t0 = expr_ty(fcx.ccx.tcx, rhs_0);
// FIXME: Binops have a bit more subtlety than this.
- auto lhs_1 = Pushdown.pushdown_expr_full(fcx, rhs_t0, lhs_0,
+ auto lhs_1 = Pushdown::pushdown_expr_full(fcx, rhs_t0, lhs_0,
AUTODEREF_OK);
auto rhs_1 =
- Pushdown.pushdown_expr_full(fcx,
+ Pushdown::pushdown_expr_full(fcx,
expr_ty(fcx.ccx.tcx, lhs_1),
rhs_0, AUTODEREF_OK);
auto t = strip_boxes(fcx.ccx.tcx, lhs_t0);
alt (binop) {
- case (ast.eq) { t = ty.mk_bool(fcx.ccx.tcx); }
- case (ast.lt) { t = ty.mk_bool(fcx.ccx.tcx); }
- case (ast.le) { t = ty.mk_bool(fcx.ccx.tcx); }
- case (ast.ne) { t = ty.mk_bool(fcx.ccx.tcx); }
- case (ast.ge) { t = ty.mk_bool(fcx.ccx.tcx); }
- case (ast.gt) { t = ty.mk_bool(fcx.ccx.tcx); }
+ case (ast::eq) { t = ty::mk_bool(fcx.ccx.tcx); }
+ case (ast::lt) { t = ty::mk_bool(fcx.ccx.tcx); }
+ case (ast::le) { t = ty::mk_bool(fcx.ccx.tcx); }
+ case (ast::ne) { t = ty::mk_bool(fcx.ccx.tcx); }
+ case (ast::ge) { t = ty::mk_bool(fcx.ccx.tcx); }
+ case (ast::gt) { t = ty::mk_bool(fcx.ccx.tcx); }
case (_) { /* fall through */ }
}
auto ann = triv_ann(a, t);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_binary(binop, lhs_1, rhs_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_binary(binop, lhs_1, rhs_1,
ann));
}
- case (ast.expr_unary(?unop, ?oper, ?a)) {
+ case (ast::expr_unary(?unop, ?oper, ?a)) {
auto oper_1 = check_expr(fcx, oper);
auto oper_t = expr_ty(fcx.ccx.tcx, oper_1);
alt (unop) {
- case (ast.box(?mut)) {
- oper_t = ty.mk_box(fcx.ccx.tcx,
+ case (ast::box(?mut)) {
+ oper_t = ty::mk_box(fcx.ccx.tcx,
rec(ty=oper_t, mut=mut));
}
- case (ast.deref) {
+ case (ast::deref) {
alt (struct(fcx.ccx.tcx, oper_t)) {
- case (ty.ty_box(?inner)) {
+ case (ty::ty_box(?inner)) {
oper_t = inner.ty;
}
case (_) {
@@ -1922,144 +1927,144 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
auto ann = triv_ann(a, oper_t);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_unary(unop, oper_1, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_unary(unop, oper_1, ann));
}
- case (ast.expr_path(?pth, ?old_ann)) {
- auto t = ty.mk_nil(fcx.ccx.tcx);
- auto defn = fcx.ccx.tcx.def_map.get(ast.ann_tag(old_ann));
+ case (ast::expr_path(?pth, ?old_ann)) {
+ auto t = ty::mk_nil(fcx.ccx.tcx);
+ auto defn = fcx.ccx.tcx.def_map.get(ast::ann_tag(old_ann));
auto tpt = ty_param_count_and_ty_for_def(fcx, expr.span, defn);
- if (ty.def_has_ty_params(defn)) {
+ if (ty::def_has_ty_params(defn)) {
auto ann = instantiate_path(fcx, pth, tpt, expr.span,
- ast.ann_tag(old_ann));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_path(pth, ann));
+ ast::ann_tag(old_ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_path(pth, ann));
}
// The definition doesn't take type parameters. If the programmer
// supplied some, that's an error.
- if (Vec.len[@ast.ty](pth.node.types) > 0u) {
+ if (_vec::len[@ast::ty](pth.node.types) > 0u) {
fcx.ccx.sess.span_err(expr.span, "this kind of value does " +
"not take type parameters");
fail;
}
- auto e = ast.expr_path(pth, triv_ann(old_ann, tpt._1));
- ret @fold.respan[ast.expr_](expr.span, e);
+ auto e = ast::expr_path(pth, triv_ann(old_ann, tpt._1));
+ ret @fold::respan[ast::expr_](expr.span, e);
}
- case (ast.expr_ext(?p, ?args, ?body, ?expanded, ?a)) {
+ case (ast::expr_ext(?p, ?args, ?body, ?expanded, ?a)) {
auto exp_ = check_expr(fcx, expanded);
auto t = expr_ty(fcx.ccx.tcx, exp_);
auto ann = triv_ann(a, t);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_ext(p, args, body, exp_,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_ext(p, args, body, exp_,
ann));
}
- case (ast.expr_fail(?a)) {
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_fail(plain_ann(a, fcx.ccx.tcx)));
+ case (ast::expr_fail(?a)) {
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_fail(plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.expr_break(?a)) {
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_break(plain_ann(a, fcx.ccx.tcx)));
+ case (ast::expr_break(?a)) {
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_break(plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.expr_cont(?a)) {
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_cont(plain_ann(a, fcx.ccx.tcx)));
+ case (ast::expr_cont(?a)) {
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_cont(plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.expr_ret(?expr_opt, ?a)) {
+ case (ast::expr_ret(?expr_opt, ?a)) {
alt (expr_opt) {
- case (none[@ast.expr]) {
- auto nil = ty.mk_nil(fcx.ccx.tcx);
+ case (none[@ast::expr]) {
+ auto nil = ty::mk_nil(fcx.ccx.tcx);
if (!are_compatible(fcx, fcx.ret_ty, nil)) {
fcx.ccx.sess.err("ret; in function "
+ "returning non-nil");
}
- ret @fold.respan[ast.expr_]
+ ret @fold::respan[ast::expr_]
(expr.span,
- ast.expr_ret(none[@ast.expr],
+ ast::expr_ret(none[@ast::expr],
plain_ann(a, fcx.ccx.tcx)));
}
- case (some[@ast.expr](?e)) {
+ case (some[@ast::expr](?e)) {
auto expr_0 = check_expr(fcx, e);
- auto expr_1 = Pushdown.pushdown_expr(fcx, fcx.ret_ty,
+ auto expr_1 = Pushdown::pushdown_expr(fcx, fcx.ret_ty,
expr_0);
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_ret(some(expr_1),
+ ret @fold::respan[ast::expr_]
+ (expr.span, ast::expr_ret(some(expr_1),
plain_ann(a, fcx.ccx.tcx)));
}
}
}
- case (ast.expr_put(?expr_opt, ?a)) {
+ case (ast::expr_put(?expr_opt, ?a)) {
require_impure(fcx.ccx.sess, fcx.purity, expr.span);
alt (expr_opt) {
- case (none[@ast.expr]) {
- auto nil = ty.mk_nil(fcx.ccx.tcx);
+ case (none[@ast::expr]) {
+ auto nil = ty::mk_nil(fcx.ccx.tcx);
if (!are_compatible(fcx, fcx.ret_ty, nil)) {
fcx.ccx.sess.err("put; in function "
+ "putting non-nil");
}
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_put(none[@ast.expr],
+ ret @fold::respan[ast::expr_]
+ (expr.span, ast::expr_put(none[@ast::expr],
plain_ann(a, fcx.ccx.tcx)));
}
- case (some[@ast.expr](?e)) {
+ case (some[@ast::expr](?e)) {
auto expr_0 = check_expr(fcx, e);
- auto expr_1 = Pushdown.pushdown_expr(fcx, fcx.ret_ty,
+ auto expr_1 = Pushdown::pushdown_expr(fcx, fcx.ret_ty,
expr_0);
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_put(some(expr_1),
+ ret @fold::respan[ast::expr_]
+ (expr.span, ast::expr_put(some(expr_1),
plain_ann(a, fcx.ccx.tcx)));
}
}
}
- case (ast.expr_be(?e, ?a)) {
+ case (ast::expr_be(?e, ?a)) {
/* FIXME: prove instead of check */
- assert (ast.is_call_expr(e));
+ assert (ast::is_call_expr(e));
auto expr_0 = check_expr(fcx, e);
- auto expr_1 = Pushdown.pushdown_expr(fcx, fcx.ret_ty, expr_0);
- ret @fold.respan(expr.span,
- ast.expr_be(expr_1, plain_ann(a, fcx.ccx.tcx)));
+ auto expr_1 = Pushdown::pushdown_expr(fcx, fcx.ret_ty, expr_0);
+ ret @fold::respan(expr.span,
+ ast::expr_be(expr_1, plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.expr_log(?l, ?e, ?a)) {
+ case (ast::expr_log(?l, ?e, ?a)) {
auto expr_t = check_expr(fcx, e);
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_log(l, expr_t,
+ ret @fold::respan[ast::expr_]
+ (expr.span, ast::expr_log(l, expr_t,
plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.expr_check(?e, ?a)) {
+ case (ast::expr_check(?e, ?a)) {
auto expr_t = check_expr(fcx, e);
- Demand.simple(fcx, expr.span, ty.mk_bool(fcx.ccx.tcx),
+ Demand::simple(fcx, expr.span, ty::mk_bool(fcx.ccx.tcx),
expr_ty(fcx.ccx.tcx, expr_t));
/* e must be a call expr where all arguments are either
literals or slots */
alt (e.node) {
- case (ast.expr_call(?operator, ?operands, _)) {
+ case (ast::expr_call(?operator, ?operands, _)) {
alt (operator.node) {
- case (ast.expr_path(?oper_name, ?ann)) {
+ case (ast::expr_path(?oper_name, ?ann)) {
auto d_id;
- alt (fcx.ccx.tcx.def_map.get(ast.ann_tag(ann))) {
- case (ast.def_fn(?_d_id)) { d_id = _d_id; }
+ alt (fcx.ccx.tcx.def_map.get(ast::ann_tag(ann))) {
+ case (ast::def_fn(?_d_id)) { d_id = _d_id; }
}
- for (@ast.expr operand in operands) {
- if (! ast.is_constraint_arg(operand)) {
+ for (@ast::expr operand in operands) {
+ if (! ast::is_constraint_arg(operand)) {
fcx.ccx.sess.span_err(expr.span,
"Constraint args must be "
+ "slot variables or literals");
@@ -2068,8 +2073,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
require_pure_function(fcx.ccx, d_id, expr.span);
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_check(expr_t,
+ ret @fold::respan[ast::expr_]
+ (expr.span, ast::expr_check(expr_t,
plain_ann(a, fcx.ccx.tcx)));
}
case (_) {
@@ -2086,90 +2091,91 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
}
- case (ast.expr_assert(?e, ?a)) {
+ case (ast::expr_assert(?e, ?a)) {
auto expr_t = check_expr(fcx, e);
- Demand.simple(fcx, expr.span, ty.mk_bool(fcx.ccx.tcx),
+ Demand::simple(fcx, expr.span, ty::mk_bool(fcx.ccx.tcx),
expr_ty(fcx.ccx.tcx, expr_t));
- ret @fold.respan[ast.expr_]
- (expr.span, ast.expr_assert(expr_t,
+ ret @fold::respan[ast::expr_]
+ (expr.span, ast::expr_assert(expr_t,
plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.expr_assign(?lhs, ?rhs, ?a)) {
+ case (ast::expr_assign(?lhs, ?rhs, ?a)) {
require_impure(fcx.ccx.sess, fcx.purity, expr.span);
auto checked = check_assignment(fcx, lhs, rhs, a);
- auto newexpr = ast.expr_assign(checked._0,
+ auto newexpr = ast::expr_assign(checked._0,
checked._1,
checked._2);
- ret @fold.respan[ast.expr_](expr.span, newexpr);
+ ret @fold::respan[ast::expr_](expr.span, newexpr);
}
- case (ast.expr_assign_op(?op, ?lhs, ?rhs, ?a)) {
+ case (ast::expr_assign_op(?op, ?lhs, ?rhs, ?a)) {
require_impure(fcx.ccx.sess, fcx.purity, expr.span);
auto checked = check_assignment(fcx, lhs, rhs, a);
- auto newexpr = ast.expr_assign_op(op,
+ auto newexpr = ast::expr_assign_op(op,
checked._0,
checked._1,
checked._2);
- ret @fold.respan[ast.expr_](expr.span, newexpr);
+ ret @fold::respan[ast::expr_](expr.span, newexpr);
}
- case (ast.expr_send(?lhs, ?rhs, ?a)) {
+ case (ast::expr_send(?lhs, ?rhs, ?a)) {
require_impure(fcx.ccx.sess, fcx.purity, expr.span);
auto lhs_0 = check_expr(fcx, lhs);
auto rhs_0 = check_expr(fcx, rhs);
auto rhs_t = expr_ty(fcx.ccx.tcx, rhs_0);
- auto chan_t = ty.mk_chan(fcx.ccx.tcx, rhs_t);
- auto lhs_1 = Pushdown.pushdown_expr(fcx, chan_t, lhs_0);
+ auto chan_t = ty::mk_chan(fcx.ccx.tcx, rhs_t);
+ auto lhs_1 = Pushdown::pushdown_expr(fcx, chan_t, lhs_0);
auto item_t;
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, lhs_1))) {
- case (ty.ty_chan(?it)) {
+ case (ty::ty_chan(?it)) {
item_t = it;
}
case (_) {
fail;
}
}
- auto rhs_1 = Pushdown.pushdown_expr(fcx, item_t, rhs_0);
+ auto rhs_1 = Pushdown::pushdown_expr(fcx, item_t, rhs_0);
auto ann = triv_ann(a, chan_t);
- auto newexpr = ast.expr_send(lhs_1, rhs_1, ann);
- ret @fold.respan[ast.expr_](expr.span, newexpr);
+ auto newexpr = ast::expr_send(lhs_1, rhs_1, ann);
+ ret @fold::respan[ast::expr_](expr.span, newexpr);
}
- case (ast.expr_recv(?lhs, ?rhs, ?a)) {
+ case (ast::expr_recv(?lhs, ?rhs, ?a)) {
require_impure(fcx.ccx.sess, fcx.purity, expr.span);
auto lhs_0 = check_expr(fcx, lhs);
auto rhs_0 = check_expr(fcx, rhs);
auto lhs_t1 = expr_ty(fcx.ccx.tcx, lhs_0);
- auto port_t = ty.mk_port(fcx.ccx.tcx, lhs_t1);
- auto rhs_1 = Pushdown.pushdown_expr(fcx, port_t, rhs_0);
+ auto port_t = ty::mk_port(fcx.ccx.tcx, lhs_t1);
+ auto rhs_1 = Pushdown::pushdown_expr(fcx, port_t, rhs_0);
auto item_t;
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, rhs_0))) {
- case (ty.ty_port(?it)) {
+ case (ty::ty_port(?it)) {
item_t = it;
}
case (_) {
fail;
}
}
- auto lhs_1 = Pushdown.pushdown_expr(fcx, item_t, lhs_0);
+ auto lhs_1 = Pushdown::pushdown_expr(fcx, item_t, lhs_0);
auto ann = triv_ann(a, item_t);
- auto newexpr = ast.expr_recv(lhs_1, rhs_1, ann);
- ret @fold.respan[ast.expr_](expr.span, newexpr);
+ auto newexpr = ast::expr_recv(lhs_1, rhs_1, ann);
+ ret @fold::respan[ast::expr_](expr.span, newexpr);
}
- case (ast.expr_if(?cond, ?thn, ?elsopt, ?a)) {
+ case (ast::expr_if(?cond, ?thn, ?elsopt, ?a)) {
auto cond_0 = check_expr(fcx, cond);
- auto cond_1 = Pushdown.pushdown_expr(fcx, ty.mk_bool(fcx.ccx.tcx),
- cond_0);
+ auto cond_1 = Pushdown::pushdown_expr(fcx,
+ ty::mk_bool(fcx.ccx.tcx),
+ cond_0);
auto thn_0 = check_block(fcx, thn);
auto thn_t = block_ty(fcx.ccx.tcx, thn_0);
@@ -2177,27 +2183,27 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
auto elsopt_1;
auto elsopt_t;
alt (elsopt) {
- case (some[@ast.expr](?els)) {
+ case (some[@ast::expr](?els)) {
auto els_0 = check_expr(fcx, els);
- auto els_1 = Pushdown.pushdown_expr(fcx, thn_t, els_0);
- elsopt_1 = some[@ast.expr](els_1);
+ auto els_1 = Pushdown::pushdown_expr(fcx, thn_t, els_0);
+ elsopt_1 = some[@ast::expr](els_1);
elsopt_t = expr_ty(fcx.ccx.tcx, els_1);
}
- case (none[@ast.expr]) {
- elsopt_1 = none[@ast.expr];
- elsopt_t = ty.mk_nil(fcx.ccx.tcx);
+ case (none[@ast::expr]) {
+ elsopt_1 = none[@ast::expr];
+ elsopt_t = ty::mk_nil(fcx.ccx.tcx);
}
}
- auto thn_1 = Pushdown.pushdown_block(fcx, elsopt_t, thn_0);
+ auto thn_1 = Pushdown::pushdown_block(fcx, elsopt_t, thn_0);
auto ann = triv_ann(a, elsopt_t);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_if(cond_1, thn_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_if(cond_1, thn_1,
elsopt_1, ann));
}
- case (ast.expr_for(?decl, ?seq, ?body, ?a)) {
+ case (ast::expr_for(?decl, ?seq, ?body, ?a)) {
auto decl_1 = check_decl_local(fcx, decl);
auto seq_1 = check_expr(fcx, seq);
auto body_1 = check_block(fcx, body);
@@ -2205,81 +2211,83 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
// FIXME: enforce that the type of the decl is the element type
// of the seq.
- auto ann = triv_ann(a, ty.mk_nil(fcx.ccx.tcx));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_for(decl_1, seq_1,
+ auto ann = triv_ann(a, ty::mk_nil(fcx.ccx.tcx));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_for(decl_1, seq_1,
body_1, ann));
}
- case (ast.expr_for_each(?decl, ?seq, ?body, ?a)) {
+ case (ast::expr_for_each(?decl, ?seq, ?body, ?a)) {
auto decl_1 = check_decl_local(fcx, decl);
auto seq_1 = check_expr(fcx, seq);
auto body_1 = check_block(fcx, body);
- auto ann = triv_ann(a, ty.mk_nil(fcx.ccx.tcx));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_for_each(decl_1, seq_1,
+ auto ann = triv_ann(a, ty::mk_nil(fcx.ccx.tcx));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_for_each(decl_1, seq_1,
body_1, ann));
}
- case (ast.expr_while(?cond, ?body, ?a)) {
+ case (ast::expr_while(?cond, ?body, ?a)) {
auto cond_0 = check_expr(fcx, cond);
- auto cond_1 = Pushdown.pushdown_expr(fcx, ty.mk_bool(fcx.ccx.tcx),
- cond_0);
+ auto cond_1 = Pushdown::pushdown_expr(fcx,
+ ty::mk_bool(fcx.ccx.tcx),
+ cond_0);
auto body_1 = check_block(fcx, body);
- auto ann = triv_ann(a, ty.mk_nil(fcx.ccx.tcx));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_while(cond_1, body_1, ann));
+ auto ann = triv_ann(a, ty::mk_nil(fcx.ccx.tcx));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_while(cond_1, body_1, ann));
}
- case (ast.expr_do_while(?body, ?cond, ?a)) {
+ case (ast::expr_do_while(?body, ?cond, ?a)) {
auto cond_0 = check_expr(fcx, cond);
- auto cond_1 = Pushdown.pushdown_expr(fcx, ty.mk_bool(fcx.ccx.tcx),
- cond_0);
+ auto cond_1 = Pushdown::pushdown_expr(fcx,
+ ty::mk_bool(fcx.ccx.tcx),
+ cond_0);
auto body_1 = check_block(fcx, body);
auto ann = triv_ann(a, block_ty(fcx.ccx.tcx, body_1));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_do_while(body_1, cond_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_do_while(body_1, cond_1,
ann));
}
- case (ast.expr_alt(?expr, ?arms, ?a)) {
+ case (ast::expr_alt(?expr, ?arms, ?a)) {
auto expr_0 = check_expr(fcx, expr);
// Typecheck the patterns first, so that we get types for all the
// bindings.
auto pattern_ty = expr_ty(fcx.ccx.tcx, expr_0);
- let vec[@ast.pat] pats_0 = vec();
- for (ast.arm arm in arms) {
+ let vec[@ast::pat] pats_0 = vec();
+ for (ast::arm arm in arms) {
auto pat_0 = check_pat(fcx, arm.pat);
- pattern_ty = Demand.simple(fcx, pat_0.span, pattern_ty,
+ pattern_ty = Demand::simple(fcx, pat_0.span, pattern_ty,
pat_ty(fcx.ccx.tcx, pat_0));
pats_0 += vec(pat_0);
}
- let vec[@ast.pat] pats_1 = vec();
- for (@ast.pat pat_0 in pats_0) {
- pats_1 += vec(Pushdown.pushdown_pat(fcx, pattern_ty, pat_0));
+ let vec[@ast::pat] pats_1 = vec();
+ for (@ast::pat pat_0 in pats_0) {
+ pats_1 += vec(Pushdown::pushdown_pat(fcx, pattern_ty, pat_0));
}
// Now typecheck the blocks.
auto result_ty = next_ty_var(fcx.ccx);
- let vec[ast.block] blocks_0 = vec();
- for (ast.arm arm in arms) {
+ let vec[ast::block] blocks_0 = vec();
+ for (ast::arm arm in arms) {
auto block_0 = check_block(fcx, arm.block);
- result_ty = Demand.simple(fcx, block_0.span, result_ty,
+ result_ty = Demand::simple(fcx, block_0.span, result_ty,
block_ty(fcx.ccx.tcx, block_0));
blocks_0 += vec(block_0);
}
- let vec[ast.arm] arms_1 = vec();
+ let vec[ast::arm] arms_1 = vec();
auto i = 0u;
- for (ast.block block_0 in blocks_0) {
- auto block_1 = Pushdown.pushdown_block(fcx, result_ty,
+ for (ast::block block_0 in blocks_0) {
+ auto block_1 = Pushdown::pushdown_block(fcx, result_ty,
block_0);
auto pat_1 = pats_1.(i);
auto arm = arms.(i);
@@ -2288,47 +2296,47 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
i += 1u;
}
- auto expr_1 = Pushdown.pushdown_expr(fcx, pattern_ty, expr_0);
+ auto expr_1 = Pushdown::pushdown_expr(fcx, pattern_ty, expr_0);
auto ann = triv_ann(a, result_ty);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_alt(expr_1, arms_1, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_alt(expr_1, arms_1, ann));
}
- case (ast.expr_block(?b, ?a)) {
+ case (ast::expr_block(?b, ?a)) {
auto b_0 = check_block(fcx, b);
auto ann;
alt (b_0.node.expr) {
- case (some[@ast.expr](?expr)) {
+ case (some[@ast::expr](?expr)) {
ann = triv_ann(a, expr_ty(fcx.ccx.tcx, expr));
}
- case (none[@ast.expr]) {
- ann = triv_ann(a, ty.mk_nil(fcx.ccx.tcx));
+ case (none[@ast::expr]) {
+ ann = triv_ann(a, ty::mk_nil(fcx.ccx.tcx));
}
}
- ret @fold.respan[ast.expr_](expr.span, ast.expr_block(b_0, ann));
+ ret @fold::respan(expr.span, ast::expr_block(b_0, ann));
}
- case (ast.expr_bind(?f, ?args, ?a)) {
+ case (ast::expr_bind(?f, ?args, ?a)) {
// Call the generic checker.
auto result = check_call_or_bind(fcx, f, args);
// Pull the argument and return types out.
auto proto_1;
- let vec[ty.arg] arg_tys_1 = vec();
+ let vec[ty::arg] arg_tys_1 = vec();
auto rt_1;
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, result._0))) {
- case (ty.ty_fn(?proto, ?arg_tys, ?rt)) {
+ case (ty::ty_fn(?proto, ?arg_tys, ?rt)) {
proto_1 = proto;
rt_1 = rt;
// For each blank argument, add the type of that argument
// to the resulting function type.
auto i = 0u;
- while (i < Vec.len[Option.t[@ast.expr]](args)) {
+ while (i < _vec::len[option::t[@ast::expr]](args)) {
alt (args.(i)) {
- case (some[@ast.expr](_)) { /* no-op */ }
- case (none[@ast.expr]) {
+ case (some[@ast::expr](_)) { /* no-op */ }
+ case (none[@ast::expr]) {
arg_tys_1 += vec(arg_tys.(i));
}
}
@@ -2341,14 +2349,14 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
}
- auto t_1 = ty.mk_fn(fcx.ccx.tcx, proto_1, arg_tys_1, rt_1);
+ auto t_1 = ty::mk_fn(fcx.ccx.tcx, proto_1, arg_tys_1, rt_1);
auto ann = triv_ann(a, t_1);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_bind(result._0, result._1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_bind(result._0, result._1,
ann));
}
- case (ast.expr_call(?f, ?args, ?a)) {
+ case (ast::expr_call(?f, ?args, ?a)) {
/* here we're kind of hosed, as f can be any expr
need to restrict it to being an explicit expr_path if we're
inside a pure function, and need an environment mapping from
@@ -2360,10 +2368,10 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
auto args_1 = result._1;
// Pull the return type out of the type of the function.
- auto rt_1 = ty.mk_nil(fcx.ccx.tcx); // FIXME: typestate botch
+ auto rt_1 = ty::mk_nil(fcx.ccx.tcx); // FIXME: typestate botch
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, f_1))) {
- case (ty.ty_fn(_,_,?rt)) { rt_1 = rt; }
- case (ty.ty_native_fn(_, _, ?rt)) { rt_1 = rt; }
+ case (ty::ty_fn(_,_,?rt)) { rt_1 = rt; }
+ case (ty::ty_native_fn(_, _, ?rt)) { rt_1 = rt; }
case (_) {
log_err "LHS of call expr didn't have a function type?!";
fail;
@@ -2371,19 +2379,19 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
auto ann = triv_ann(a, rt_1);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_call(f_1, args_1, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_call(f_1, args_1, ann));
}
- case (ast.expr_self_method(?id, ?a)) {
- auto t = ty.mk_nil(fcx.ccx.tcx);
- let ty.t this_obj_ty;
+ case (ast::expr_self_method(?id, ?a)) {
+ auto t = ty::mk_nil(fcx.ccx.tcx);
+ let ty::t this_obj_ty;
// Grab the type of the current object
auto this_obj_id = fcx.ccx.this_obj;
alt (this_obj_id) {
- case (some[ast.def_id](?def_id)) {
- this_obj_ty = ty.lookup_item_type(fcx.ccx.sess,
+ case (some[ast::def_id](?def_id)) {
+ this_obj_ty = ty::lookup_item_type(fcx.ccx.sess,
fcx.ccx.tcx, fcx.ccx.type_cache, def_id)._1;
}
case (_) { fail; }
@@ -2392,12 +2400,12 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
// Grab this method's type out of the current object type
- // this_obj_ty is an ty.t
+ // this_obj_ty is an ty::t
alt (struct(fcx.ccx.tcx, this_obj_ty)) {
- case (ty.ty_obj(?methods)) {
- for (ty.method method in methods) {
+ case (ty::ty_obj(?methods)) {
+ for (ty::method method in methods) {
if (method.ident == id) {
- t = ty.method_ty_to_fn_ty(fcx.ccx.tcx,
+ t = ty::method_ty_to_fn_ty(fcx.ccx.tcx,
method);
}
}
@@ -2409,20 +2417,20 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
require_impure(fcx.ccx.sess, fcx.purity, expr.span);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_self_method(id, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_self_method(id, ann));
}
- case (ast.expr_spawn(?dom, ?name, ?f, ?args, ?a)) {
+ case (ast::expr_spawn(?dom, ?name, ?f, ?args, ?a)) {
auto result = check_call(fcx, f, args);
auto f_1 = result._0;
auto args_1 = result._1;
// Check the return type
alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, f_1))) {
- case (ty.ty_fn(_,_,?rt)) {
+ case (ty::ty_fn(_,_,?rt)) {
alt (struct(fcx.ccx.tcx, rt)) {
- case (ty.ty_nil) {
+ case (ty::ty_nil) {
// This is acceptable
}
case (_) {
@@ -2437,13 +2445,13 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
// FIXME: Other typechecks needed
- auto ann = triv_ann(a, ty.mk_task(fcx.ccx.tcx));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_spawn(dom, name,
+ auto ann = triv_ann(a, ty::mk_task(fcx.ccx.tcx));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_spawn(dom, name,
f_1, args_1, ann));
}
- case (ast.expr_cast(?e, ?t, ?a)) {
+ case (ast::expr_cast(?e, ?t, ?a)) {
auto e_1 = check_expr(fcx, e);
auto t_1 = ast_ty_to_ty_crate(fcx.ccx, t);
// FIXME: there are more forms of cast to support, eventually.
@@ -2456,87 +2464,87 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
auto ann = triv_ann(a, t_1);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_cast(e_1, t, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_cast(e_1, t, ann));
}
- case (ast.expr_vec(?args, ?mut, ?a)) {
- let vec[@ast.expr] args_1 = vec();
+ case (ast::expr_vec(?args, ?mut, ?a)) {
+ let vec[@ast::expr] args_1 = vec();
- let ty.t t;
- if (Vec.len[@ast.expr](args) == 0u) {
+ let ty::t t;
+ if (_vec::len[@ast::expr](args) == 0u) {
t = next_ty_var(fcx.ccx);
} else {
auto expr_1 = check_expr(fcx, args.(0));
t = expr_ty(fcx.ccx.tcx, expr_1);
}
- for (@ast.expr e in args) {
+ for (@ast::expr e in args) {
auto expr_1 = check_expr(fcx, e);
auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
- Demand.simple(fcx, expr.span, t, expr_t);
- Vec.push[@ast.expr](args_1,expr_1);
+ Demand::simple(fcx, expr.span, t, expr_t);
+ _vec::push[@ast::expr](args_1,expr_1);
}
- auto ann = triv_ann(a, ty.mk_vec(fcx.ccx.tcx,
+ auto ann = triv_ann(a, ty::mk_vec(fcx.ccx.tcx,
rec(ty=t, mut=mut)));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_vec(args_1, mut, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_vec(args_1, mut, ann));
}
- case (ast.expr_tup(?elts, ?a)) {
- let vec[ast.elt] elts_1 = vec();
- let vec[ty.mt] elts_mt = vec();
+ case (ast::expr_tup(?elts, ?a)) {
+ let vec[ast::elt] elts_1 = vec();
+ let vec[ty::mt] elts_mt = vec();
- for (ast.elt e in elts) {
+ for (ast::elt e in elts) {
auto expr_1 = check_expr(fcx, e.expr);
auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
- Vec.push[ast.elt](elts_1, rec(expr=expr_1 with e));
+ _vec::push[ast::elt](elts_1, rec(expr=expr_1 with e));
elts_mt += vec(rec(ty=expr_t, mut=e.mut));
}
- auto ann = triv_ann(a, ty.mk_tup(fcx.ccx.tcx, elts_mt));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_tup(elts_1, ann));
+ auto ann = triv_ann(a, ty::mk_tup(fcx.ccx.tcx, elts_mt));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_tup(elts_1, ann));
}
- case (ast.expr_rec(?fields, ?base, ?a)) {
+ case (ast::expr_rec(?fields, ?base, ?a)) {
auto base_1;
alt (base) {
- case (none[@ast.expr]) { base_1 = none[@ast.expr]; }
- case (some[@ast.expr](?b_0)) {
- base_1 = some[@ast.expr](check_expr(fcx, b_0));
+ case (none[@ast::expr]) { base_1 = none[@ast::expr]; }
+ case (some[@ast::expr](?b_0)) {
+ base_1 = some[@ast::expr](check_expr(fcx, b_0));
}
}
- let vec[ast.field] fields_1 = vec();
+ let vec[ast::field] fields_1 = vec();
let vec[field] fields_t = vec();
- for (ast.field f in fields) {
+ for (ast::field f in fields) {
auto expr_1 = check_expr(fcx, f.expr);
auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
- Vec.push[ast.field](fields_1, rec(expr=expr_1 with f));
+ _vec::push[ast::field](fields_1, rec(expr=expr_1 with f));
auto expr_mt = rec(ty=expr_t, mut=f.mut);
- Vec.push[field](fields_t, rec(ident=f.ident, mt=expr_mt));
+ _vec::push[field](fields_t, rec(ident=f.ident, mt=expr_mt));
}
auto ann;
alt (base) {
- case (none[@ast.expr]) {
- ann = triv_ann(a, ty.mk_rec(fcx.ccx.tcx, fields_t));
+ case (none[@ast::expr]) {
+ ann = triv_ann(a, ty::mk_rec(fcx.ccx.tcx, fields_t));
}
- case (some[@ast.expr](?bexpr)) {
+ case (some[@ast::expr](?bexpr)) {
auto bexpr_1 = check_expr(fcx, bexpr);
auto bexpr_t = expr_ty(fcx.ccx.tcx, bexpr_1);
let vec[field] base_fields = vec();
alt (struct(fcx.ccx.tcx, bexpr_t)) {
- case (ty.ty_rec(?flds)) {
+ case (ty::ty_rec(?flds)) {
base_fields = flds;
}
case (_) {
@@ -2548,11 +2556,11 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
ann = triv_ann(a, bexpr_t);
- for (ty.field f in fields_t) {
+ for (ty::field f in fields_t) {
auto found = false;
- for (ty.field bf in base_fields) {
- if (Str.eq(f.ident, bf.ident)) {
- Demand.simple(fcx, expr.span, f.mt.ty,
+ for (ty::field bf in base_fields) {
+ if (_str::eq(f.ident, bf.ident)) {
+ Demand::simple(fcx, expr.span, f.mt.ty,
bf.mt.ty);
found = true;
}
@@ -2567,69 +2575,69 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
}
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_rec(fields_1, base_1, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_rec(fields_1, base_1, ann));
}
- case (ast.expr_field(?base, ?field, ?a)) {
+ case (ast::expr_field(?base, ?field, ?a)) {
auto base_1 = check_expr(fcx, base);
auto base_t = strip_boxes(fcx.ccx.tcx,
expr_ty(fcx.ccx.tcx, base_1));
alt (struct(fcx.ccx.tcx, base_t)) {
- case (ty.ty_tup(?args)) {
- let uint ix = ty.field_num(fcx.ccx.sess,
+ case (ty::ty_tup(?args)) {
+ let uint ix = ty::field_num(fcx.ccx.sess,
expr.span, field);
- if (ix >= Vec.len[ty.mt](args)) {
+ if (ix >= _vec::len[ty::mt](args)) {
fcx.ccx.sess.span_err(expr.span,
"bad index on tuple");
}
auto ann = triv_ann(a, args.(ix).ty);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_field(base_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_field(base_1,
field,
ann));
}
- case (ty.ty_rec(?fields)) {
- let uint ix = ty.field_idx(fcx.ccx.sess,
+ case (ty::ty_rec(?fields)) {
+ let uint ix = ty::field_idx(fcx.ccx.sess,
expr.span, field, fields);
- if (ix >= Vec.len[typeck.field](fields)) {
+ if (ix >= _vec::len[typeck::field](fields)) {
fcx.ccx.sess.span_err(expr.span,
"bad index on record");
}
auto ann = triv_ann(a, fields.(ix).mt.ty);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_field(base_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_field(base_1,
field,
ann));
}
- case (ty.ty_obj(?methods)) {
- let uint ix = ty.method_idx(fcx.ccx.sess,
+ case (ty::ty_obj(?methods)) {
+ let uint ix = ty::method_idx(fcx.ccx.sess,
expr.span, field, methods);
- if (ix >= Vec.len[typeck.method](methods)) {
+ if (ix >= _vec::len[typeck::method](methods)) {
fcx.ccx.sess.span_err(expr.span,
"bad index on obj");
}
auto meth = methods.(ix);
- auto t = ty.mk_fn(fcx.ccx.tcx, meth.proto,
+ auto t = ty::mk_fn(fcx.ccx.tcx, meth.proto,
meth.inputs, meth.output);
auto ann = triv_ann(a, t);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_field(base_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_field(base_1,
field,
ann));
}
case (_) {
fcx.ccx.sess.span_unimpl(expr.span,
- "base type for expr_field in typeck.check_expr: " +
+ "base type for expr_field in typeck::check_expr: " +
ty_to_str(fcx.ccx.tcx, base_t));
}
}
}
- case (ast.expr_index(?base, ?idx, ?a)) {
+ case (ast::expr_index(?base, ?idx, ?a)) {
auto base_1 = check_expr(fcx, base);
auto base_t = strip_boxes(fcx.ccx.tcx,
expr_ty(fcx.ccx.tcx, base_1));
@@ -2637,7 +2645,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
auto idx_1 = check_expr(fcx, idx);
auto idx_t = expr_ty(fcx.ccx.tcx, idx_1);
alt (struct(fcx.ccx.tcx, base_t)) {
- case (ty.ty_vec(?mt)) {
+ case (ty::ty_vec(?mt)) {
if (! type_is_integral(fcx.ccx.tcx, idx_t)) {
fcx.ccx.sess.span_err
(idx.span,
@@ -2645,22 +2653,22 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
+ ty_to_str(fcx.ccx.tcx, idx_t));
}
auto ann = triv_ann(a, mt.ty);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_index(base_1,
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_index(base_1,
idx_1,
ann));
}
- case (ty.ty_str) {
+ case (ty::ty_str) {
if (! type_is_integral(fcx.ccx.tcx, idx_t)) {
fcx.ccx.sess.span_err
(idx.span,
"non-integral type of str index: "
+ ty_to_str(fcx.ccx.tcx, idx_t));
}
- auto ann = triv_ann(a, ty.mk_mach(fcx.ccx.tcx,
- common.ty_u8));
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_index(base_1,
+ auto ann = triv_ann(a, ty::mk_mach(fcx.ccx.tcx,
+ common::ty_u8));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_index(base_1,
idx_1,
ann));
}
@@ -2673,22 +2681,22 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
}
- case (ast.expr_port(?a)) {
+ case (ast::expr_port(?a)) {
auto t = next_ty_var(fcx.ccx);
- auto pt = ty.mk_port(fcx.ccx.tcx, t);
+ auto pt = ty::mk_port(fcx.ccx.tcx, t);
auto ann = triv_ann(a, pt);
- ret @fold.respan[ast.expr_](expr.span, ast.expr_port(ann));
+ ret @fold::respan[ast::expr_](expr.span, ast::expr_port(ann));
}
- case (ast.expr_chan(?x, ?a)) {
+ case (ast::expr_chan(?x, ?a)) {
auto expr_1 = check_expr(fcx, x);
auto port_t = expr_ty(fcx.ccx.tcx, expr_1);
alt (struct(fcx.ccx.tcx, port_t)) {
- case (ty.ty_port(?subtype)) {
- auto ct = ty.mk_chan(fcx.ccx.tcx, subtype);
+ case (ty::ty_port(?subtype)) {
+ auto ct = ty::mk_chan(fcx.ccx.tcx, subtype);
auto ann = triv_ann(a, ct);
- ret @fold.respan[ast.expr_](expr.span,
- ast.expr_chan(expr_1, ann));
+ ret @fold::respan[ast::expr_](expr.span,
+ ast::expr_chan(expr_1, ann));
}
case (_) {
fcx.ccx.sess.span_err(expr.span,
@@ -2698,33 +2706,33 @@ fn check_expr(&@fn_ctxt fcx, &@ast.expr expr) -> @ast.expr {
}
case (_) {
- fcx.ccx.sess.unimpl("expr type in typeck.check_expr");
+ fcx.ccx.sess.unimpl("expr type in typeck::check_expr");
// TODO
ret expr;
}
}
}
-fn next_ty_var(&@crate_ctxt ccx) -> ty.t {
- auto t = ty.mk_var(ccx.tcx, ccx.next_var_id);
+fn next_ty_var(&@crate_ctxt ccx) -> ty::t {
+ auto t = ty::mk_var(ccx.tcx, ccx.next_var_id);
ccx.next_var_id += 1;
ret t;
}
-fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
+fn check_decl_local(&@fn_ctxt fcx, &@ast::decl decl) -> @ast::decl {
alt (decl.node) {
- case (ast.decl_local(?local)) {
+ case (ast::decl_local(?local)) {
auto t;
- t = ty.mk_nil(fcx.ccx.tcx);
+ t = ty::mk_nil(fcx.ccx.tcx);
alt (local.ty) {
- case (none[@ast.ty]) {
+ case (none[@ast::ty]) {
// Auto slot. Do nothing for now.
}
- case (some[@ast.ty](?ast_ty)) {
+ case (some[@ast::ty](?ast_ty)) {
auto local_ty = ast_ty_to_ty_crate(fcx.ccx, ast_ty);
fcx.locals.insert(local.id, local_ty);
t = local_ty;
@@ -2741,48 +2749,49 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
auto initopt = local.init;
alt (local.init) {
- case (some[ast.initializer](?init)) {
+ case (some[ast::initializer](?init)) {
auto expr_0 = check_expr(fcx, init.expr);
- auto lty = ty.mk_local(fcx.ccx.tcx, local.id);
+ auto lty = ty::mk_local(fcx.ccx.tcx, local.id);
auto expr_1;
alt (init.op) {
- case (ast.init_assign) {
- expr_1 = Pushdown.pushdown_expr(fcx, lty, expr_0);
+ case (ast::init_assign) {
+ expr_1 = Pushdown::pushdown_expr(fcx, lty,
+ expr_0);
}
- case (ast.init_recv) {
- auto port_ty = ty.mk_port(fcx.ccx.tcx, lty);
- expr_1 = Pushdown.pushdown_expr(fcx, port_ty,
+ case (ast::init_recv) {
+ auto port_ty = ty::mk_port(fcx.ccx.tcx, lty);
+ expr_1 = Pushdown::pushdown_expr(fcx, port_ty,
expr_0);
}
}
auto init_0 = rec(expr = expr_1 with init);
- initopt = some[ast.initializer](init_0);
+ initopt = some[ast::initializer](init_0);
}
case (_) { /* fall through */ }
}
auto local_1 = @rec(init = initopt, ann = a_res with *local);
- ret @rec(node=ast.decl_local(local_1)
+ ret @rec(node=ast::decl_local(local_1)
with *decl);
}
}
}
-fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
+fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
alt (stmt.node) {
- case (ast.stmt_decl(?decl,?a)) {
+ case (ast::stmt_decl(?decl,?a)) {
alt (decl.node) {
- case (ast.decl_local(_)) {
+ case (ast::decl_local(_)) {
auto decl_1 = check_decl_local(fcx, decl);
- ret @fold.respan[ast.stmt_](stmt.span,
- ast.stmt_decl(decl_1,
+ ret @fold::respan[ast::stmt_](stmt.span,
+ ast::stmt_decl(decl_1,
plain_ann(a, fcx.ccx.tcx)));
}
- case (ast.decl_item(_)) {
+ case (ast::decl_item(_)) {
// Ignore for now. We'll return later.
- ret @fold.respan[ast.stmt_](stmt.span,
- ast.stmt_decl(decl,
+ ret @fold::respan[ast::stmt_](stmt.span,
+ ast::stmt_decl(decl,
plain_ann(a, fcx.ccx.tcx)));
}
}
@@ -2790,73 +2799,75 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
// ret stmt;
}
- case (ast.stmt_expr(?expr,?a)) {
+ case (ast::stmt_expr(?expr,?a)) {
auto expr_t = check_expr(fcx, expr);
- expr_t = Pushdown.pushdown_expr(fcx, expr_ty(fcx.ccx.tcx, expr_t),
- expr_t);
- ret @fold.respan(stmt.span,
- ast.stmt_expr(expr_t, plain_ann(a, fcx.ccx.tcx)));
+ expr_t = Pushdown::pushdown_expr(fcx,
+ expr_ty(fcx.ccx.tcx, expr_t),
+ expr_t);
+ ret @fold::respan(stmt.span,
+ ast::stmt_expr(expr_t,
+ plain_ann(a, fcx.ccx.tcx)));
}
}
fail;
}
-fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
- let vec[@ast.stmt] stmts = vec();
- for (@ast.stmt s in block.node.stmts) {
- Vec.push[@ast.stmt](stmts, check_stmt(fcx, s));
+fn check_block(&@fn_ctxt fcx, &ast::block block) -> ast::block {
+ let vec[@ast::stmt] stmts = vec();
+ for (@ast::stmt s in block.node.stmts) {
+ _vec::push[@ast::stmt](stmts, check_stmt(fcx, s));
}
- auto expr = none[@ast.expr];
+ auto expr = none[@ast::expr];
alt (block.node.expr) {
- case (none[@ast.expr]) { /* empty */ }
- case (some[@ast.expr](?e)) {
+ case (none[@ast::expr]) { /* empty */ }
+ case (some[@ast::expr](?e)) {
auto expr_t = check_expr(fcx, e);
- expr_t = Pushdown.pushdown_expr(fcx,
+ expr_t = Pushdown::pushdown_expr(fcx,
expr_ty(fcx.ccx.tcx, expr_t),
expr_t);
- expr = some[@ast.expr](expr_t);
+ expr = some[@ast::expr](expr_t);
}
}
- ret fold.respan(block.span,
+ ret fold::respan(block.span,
rec(stmts=stmts, expr=expr,
a=plain_ann(block.node.a, fcx.ccx.tcx)));
}
-fn check_const(&@crate_ctxt ccx, &span sp, &ast.ident ident, &@ast.ty t,
- &@ast.expr e, &ast.def_id id, &ast.ann ann) -> @ast.item {
+fn check_const(&@crate_ctxt ccx, &span sp, &ast::ident ident, &@ast::ty t,
+ &@ast::expr e, &ast::def_id id, &ast::ann ann) -> @ast::item {
// FIXME: this is kinda a kludge; we manufacture a fake "function context"
// for checking the initializer expression.
auto rty = ann_to_type(ann);
let @fn_ctxt fcx = @rec(ret_ty = rty,
- purity = ast.pure_fn,
- locals = @common.new_def_hash[ty.t](),
+ purity = ast::pure_fn,
+ locals = @common::new_def_hash[ty::t](),
ccx = ccx);
auto e_ = check_expr(fcx, e);
// FIXME: necessary? Correct sequence?
- Pushdown.pushdown_expr(fcx, rty, e_);
- auto item = ast.item_const(ident, t, e_, id, ann);
- ret @fold.respan[ast.item_](sp, item);
+ Pushdown::pushdown_expr(fcx, rty, e_);
+ auto item = ast::item_const(ident, t, e_, id, ann);
+ ret @fold::respan[ast::item_](sp, item);
}
-fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, ast.proto proto,
- &ast.block body) -> ast._fn {
- auto local_ty_table = @common.new_def_hash[ty.t]();
+fn check_fn(&@crate_ctxt ccx, &ast::fn_decl decl, ast::proto proto,
+ &ast::block body) -> ast::_fn {
+ auto local_ty_table = @common::new_def_hash[ty::t]();
// FIXME: duplicate work: the item annotation already has the arg types
- // and return type translated to typeck.ty values. We don't need do to it
+ // and return type translated to typeck::ty values. We don't need do to it
// again here, we can extract them.
- for (ast.obj_field f in ccx.obj_fields) {
- auto field_ty = ty.ann_to_type(f.ann);
+ for (ast::obj_field f in ccx.obj_fields) {
+ auto field_ty = ty::ann_to_type(f.ann);
local_ty_table.insert(f.id, field_ty);
}
// Store the type of each argument in the table.
- for (ast.arg arg in decl.inputs) {
+ for (ast::arg arg in decl.inputs) {
auto input_ty = ast_ty_to_ty_crate(ccx, arg.ty);
local_ty_table.insert(arg.id, input_ty);
}
@@ -2869,10 +2880,10 @@ fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, ast.proto proto,
// TODO: Make sure the type of the block agrees with the function type.
auto block_t = check_block(fcx, body);
alt (decl.purity) {
- case (ast.pure_fn) {
+ case (ast::pure_fn) {
// per the previous comment, this just checks that the declared
// type is bool, and trusts that that's the actual return type.
- if (!ty.type_is_bool(ccx.tcx, fcx.ret_ty)) {
+ if (!ty::type_is_bool(ccx.tcx, fcx.ret_ty)) {
ccx.sess.span_err(body.span, "Non-boolean return type in pred");
}
}
@@ -2887,34 +2898,34 @@ fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, ast.proto proto,
ret fn_t;
}
-fn check_item_fn(&@crate_ctxt ccx, &span sp, &ast.ident ident, &ast._fn f,
- &vec[ast.ty_param] ty_params, &ast.def_id id,
- &ast.ann ann) -> @ast.item {
+fn check_item_fn(&@crate_ctxt ccx, &span sp, &ast::ident ident, &ast::_fn f,
+ &vec[ast::ty_param] ty_params, &ast::def_id id,
+ &ast::ann ann) -> @ast::item {
// FIXME: duplicate work: the item annotation already has the arg types
- // and return type translated to typeck.ty values. We don't need do to it
+ // and return type translated to typeck::ty values. We don't need do to it
// again here, we can extract them.
let vec[arg] inputs = vec();
- for (ast.arg arg in f.decl.inputs) {
+ for (ast::arg arg in f.decl.inputs) {
auto input_ty = ast_ty_to_ty_crate(ccx, arg.ty);
inputs += vec(rec(mode=ast_mode_to_mode(arg.mode), ty=input_ty));
}
auto output_ty = ast_ty_to_ty_crate(ccx, f.decl.output);
- auto fn_ann = triv_ann(ann, ty.mk_fn(ccx.tcx, f.proto, inputs,
+ auto fn_ann = triv_ann(ann, ty::mk_fn(ccx.tcx, f.proto, inputs,
output_ty));
- auto item = ast.item_fn(ident, f, ty_params, id, fn_ann);
- ret @fold.respan[ast.item_](sp, item);
+ auto item = ast::item_fn(ident, f, ty_params, id, fn_ann);
+ ret @fold::respan[ast::item_](sp, item);
}
-fn update_obj_fields(&@crate_ctxt ccx, &@ast.item i) -> @crate_ctxt {
+fn update_obj_fields(&@crate_ctxt ccx, &@ast::item i) -> @crate_ctxt {
alt (i.node) {
- case (ast.item_obj(_, ?ob, _, ?obj_def_ids, _)) {
- let ast.def_id di = obj_def_ids.ty;
+ case (ast::item_obj(_, ?ob, _, ?obj_def_ids, _)) {
+ let ast::def_id di = obj_def_ids.ty;
ret @rec(obj_fields = ob.fields,
- this_obj = some[ast.def_id](di) with *ccx);
+ this_obj = some[ast::def_id](di) with *ccx);
}
case (_) {
}
@@ -2926,13 +2937,13 @@ fn update_obj_fields(&@crate_ctxt ccx, &@ast.item i) -> @crate_ctxt {
// Utilities for the unification cache
fn hash_unify_cache_entry(&unify_cache_entry uce) -> uint {
- auto h = ty.hash_ty(uce._0);
- h += h << 5u + ty.hash_ty(uce._1);
+ auto h = ty::hash_ty(uce._0);
+ h += h << 5u + ty::hash_ty(uce._1);
auto i = 0u;
- auto tys_len = Vec.len(uce._2);
+ auto tys_len = _vec::len(uce._2);
while (i < tys_len) {
- h += h << 5u + ty.hash_ty(uce._2.(i));
+ h += h << 5u + ty::hash_ty(uce._2.(i));
i += 1u;
}
@@ -2940,26 +2951,26 @@ fn hash_unify_cache_entry(&unify_cache_entry uce) -> uint {
}
fn eq_unify_cache_entry(&unify_cache_entry a, &unify_cache_entry b) -> bool {
- if (!ty.eq_ty(a._0, b._0) || !ty.eq_ty(a._1, b._1)) { ret false; }
+ if (!ty::eq_ty(a._0, b._0) || !ty::eq_ty(a._1, b._1)) { ret false; }
auto i = 0u;
- auto tys_len = Vec.len(a._2);
- if (Vec.len(b._2) != tys_len) { ret false; }
+ auto tys_len = _vec::len(a._2);
+ if (_vec::len(b._2) != tys_len) { ret false; }
while (i < tys_len) {
- if (!ty.eq_ty(a._2.(i), b._2.(i))) { ret false; }
+ if (!ty::eq_ty(a._2.(i), b._2.(i))) { ret false; }
i += 1u;
}
ret true;
}
-fn mk_fn_purity_table(&@ast.crate crate) -> @fn_purity_table {
- auto res = @new_def_hash[ast.purity]();
+fn mk_fn_purity_table(&@ast::crate crate) -> @fn_purity_table {
+ auto res = @new_def_hash[ast::purity]();
- fn do_one(@fn_purity_table t, &@ast.item i) -> () {
+ fn do_one(@fn_purity_table t, &@ast::item i) -> () {
alt (i.node) {
- case (ast.item_fn(_, ?f, _, ?d_id, _)) {
+ case (ast::item_fn(_, ?f, _, ?d_id, _)) {
t.insert(d_id, f.decl.purity);
}
case (_) {}
@@ -2967,26 +2978,26 @@ fn mk_fn_purity_table(&@ast.crate crate) -> @fn_purity_table {
}
auto do_one_fn = bind do_one(res,_);
- auto v = walk.default_visitor();
+ auto v = walk::default_visitor();
auto add_fn_entry_visitor = rec(visit_item_post=do_one_fn with v);
- walk.walk_crate(add_fn_entry_visitor, *crate);
+ walk::walk_crate(add_fn_entry_visitor, *crate);
ret res;
}
-type typecheck_result = tup(@ast.crate, ty.type_cache);
+type typecheck_result = tup(@ast::crate, ty::type_cache);
-fn check_crate(&ty.ctxt tcx, &@ast.crate crate) -> typecheck_result {
+fn check_crate(&ty::ctxt tcx, &@ast::crate crate) -> typecheck_result {
auto sess = tcx.sess;
- auto result = Collect.collect_item_types(sess, tcx, crate);
+ auto result = Collect::collect_item_types(sess, tcx, crate);
- let vec[ast.obj_field] fields = vec();
+ let vec[ast::obj_field] fields = vec();
auto hasher = hash_unify_cache_entry;
auto eqer = eq_unify_cache_entry;
auto unify_cache =
- Map.mk_hashmap[unify_cache_entry,ty.Unify.result](hasher, eqer);
+ map::mk_hashmap[unify_cache_entry,ty::Unify::result](hasher, eqer);
auto fpt =
mk_fn_purity_table(crate); // use a variation on Collect
@@ -2994,7 +3005,7 @@ fn check_crate(&ty.ctxt tcx, &@ast.crate crate) -> typecheck_result {
type_cache=result._1,
item_items=result._2,
obj_fields=fields,
- this_obj=none[ast.def_id],
+ this_obj=none[ast::def_id],
fn_purity_table = fpt,
mutable next_var_id=0,
unify_cache=unify_cache,
@@ -3002,14 +3013,14 @@ fn check_crate(&ty.ctxt tcx, &@ast.crate crate) -> typecheck_result {
mutable cache_misses=0u,
tcx=tcx);
- auto fld = fold.new_identity_fold[@crate_ctxt]();
+ auto fld = fold::new_identity_fold[@crate_ctxt]();
fld = @rec(update_env_for_item = bind update_obj_fields(_, _),
fold_fn = bind check_fn(_,_,_,_),
fold_item_fn = bind check_item_fn(_,_,_,_,_,_,_)
with *fld);
- auto crate_1 = fold.fold_crate[@crate_ctxt](ccx, fld, result._0);
+ auto crate_1 = fold::fold_crate[@crate_ctxt](ccx, fld, result._0);
log #fmt("cache hit rate: %u/%u", ccx.cache_hits,
ccx.cache_hits + ccx.cache_misses);
diff --git a/src/comp/middle/typestate_check.rs b/src/comp/middle/typestate_check.rs
index b1336418..2d46309a 100644
--- a/src/comp/middle/typestate_check.rs
+++ b/src/comp/middle/typestate_check.rs
@@ -1,214 +1,214 @@
-import front.ast;
-import front.ast.ann;
-import front.ast.method;
-import front.ast.ty;
-import front.ast.mutability;
-import front.ast.item;
-import front.ast.block;
-import front.ast.block_;
-import front.ast.obj_field;
-import front.ast.decl;
-import front.ast.arm;
-import front.ast.stmt;
-import front.ast.stmt_;
-import front.ast.stmt_decl;
-import front.ast.stmt_expr;
-import front.ast.stmt_crate_directive;
-import front.ast.decl_local;
-import front.ast.decl_item;
-import front.ast.ident;
-import front.ast.def_id;
-import front.ast.ann;
-import front.ast.field;
-import front.ast.expr;
-import front.ast.expr_call;
-import front.ast.expr_vec;
-import front.ast.expr_tup;
-import front.ast.expr_path;
-import front.ast.expr_field;
-import front.ast.expr_index;
-import front.ast.expr_log;
-import front.ast.expr_block;
-import front.ast.expr_rec;
-import front.ast.expr_if;
-import front.ast.expr_binary;
-import front.ast.expr_unary;
-import front.ast.expr_assign;
-import front.ast.expr_assign_op;
-import front.ast.expr_while;
-import front.ast.expr_do_while;
-import front.ast.expr_alt;
-import front.ast.expr_lit;
-import front.ast.expr_ret;
-import front.ast.expr_self_method;
-import front.ast.expr_bind;
-import front.ast.expr_spawn;
-import front.ast.expr_ext;
-import front.ast.expr_fail;
-import front.ast.expr_break;
-import front.ast.expr_cont;
-import front.ast.expr_send;
-import front.ast.expr_recv;
-import front.ast.expr_put;
-import front.ast.expr_port;
-import front.ast.expr_chan;
-import front.ast.expr_be;
-import front.ast.expr_check;
-import front.ast.expr_assert;
-import front.ast.expr_cast;
-import front.ast.expr_for;
-import front.ast.expr_for_each;
-import front.ast.path;
-import front.ast.elt;
-import front.ast.crate_directive;
-import front.ast.fn_decl;
-import front.ast._obj;
-import front.ast.native_mod;
-import front.ast.variant;
-import front.ast.ty_param;
-import front.ast.ty;
-import front.ast.proto;
-import front.ast.pat;
-import front.ast.binop;
-import front.ast.unop;
-import front.ast.def;
-import front.ast.lit;
-import front.ast.init_op;
-import front.ast.initializer;
-import front.ast.local;
-import front.ast._fn;
-import front.ast.ann_none;
-import front.ast.ann_type;
-import front.ast._obj;
-import front.ast._mod;
-import front.ast.crate;
-import front.ast.item_fn;
-import front.ast.item_obj;
-import front.ast.def_local;
-
-import middle.fold;
-import middle.fold.respan;
-import driver.session;
-import util.common;
-import util.common.span;
-import util.common.spanned;
-import util.common.new_str_hash;
-import util.common.new_def_hash;
-import util.common.uistr;
-import util.common.elt_exprs;
-import util.common.field_exprs;
-import util.common.log_expr;
-import util.common.log_expr_err;
-import util.common.log_stmt;
-import util.common.log_block;
-import util.common.log_stmt_err;
-import util.common.log_fn_err;
-import util.common.log_fn;
-import util.common.log_block_err;
-import util.common.has_nonlocal_exits;
-import util.common.decl_lhs;
-import util.typestate_ann;
-import util.typestate_ann.ts_ann;
-import util.typestate_ann.empty_pre_post;
-import util.typestate_ann.empty_poststate;
-import util.typestate_ann.true_precond;
-import util.typestate_ann.true_postcond;
-import util.typestate_ann.false_postcond;
-import util.typestate_ann.postcond;
-import util.typestate_ann.precond;
-import util.typestate_ann.poststate;
-import util.typestate_ann.prestate;
-import util.typestate_ann.pre_and_post;
-import util.typestate_ann.get_pre;
-import util.typestate_ann.get_post;
-import util.typestate_ann.ann_precond;
-import util.typestate_ann.ann_prestate;
-import util.typestate_ann.set_precondition;
-import util.typestate_ann.set_postcondition;
-import util.typestate_ann.set_prestate;
-import util.typestate_ann.set_poststate;
-import util.typestate_ann.set_in_postcond;
-import util.typestate_ann.set_in_poststate;
-import util.typestate_ann.implies;
-import util.typestate_ann.pre_and_post_state;
-import util.typestate_ann.empty_states;
-import util.typestate_ann.empty_prestate;
-import util.typestate_ann.empty_ann;
-import util.typestate_ann.extend_prestate;
-import util.typestate_ann.extend_poststate;
-import util.typestate_ann.relax_prestate;
-import util.typestate_ann.intersect;
-import util.typestate_ann.pp_clone;
-import util.typestate_ann.clone;
-
-import middle.ty;
-import middle.ty.ann_to_type;
-import middle.ty.arg;
-import middle.ty.expr_ann;
-import middle.ty.ty_to_str;
-
-import pretty.pprust.print_block;
-import pretty.pprust.print_expr;
-import pretty.pprust.print_decl;
-import pretty.pp.mkstate;
-import std.IO.stdout;
-import std.IO.str_writer;
-import std.IO.string_writer;
-import std.Vec.map;
-import std.Vec;
-import std.Vec.len;
-import std.Vec.pop;
-import std.Vec.push;
-import std.Vec.slice;
-import std.Vec.unzip;
-import std.Vec.plus_option;
-import std.Vec.cat_options;
-import std.Option;
-import std.Option.t;
-import std.Option.some;
-import std.Option.none;
-import std.Option.from_maybe;
-import std.Option.maybe;
-import std.Option.is_none;
-import std.Option.get;
-import std.Map.hashmap;
-import std.List;
-import std.List.list;
-import std.List.cons;
-import std.List.nil;
-import std.List.foldl;
-import std.List.find;
-import std.UInt;
-import std.BitV;
-import std.Util.fst;
-import std.Util.snd;
-
-import util.typestate_ann;
-import util.typestate_ann.difference;
-import util.typestate_ann.union;
-import util.typestate_ann.pps_len;
-import util.typestate_ann.require_and_preserve;
-
-import resolve.def_map;
+import front::ast;
+import front::ast::ann;
+import front::ast::method;
+import front::ast::ty;
+import front::ast::mutability;
+import front::ast::item;
+import front::ast::block;
+import front::ast::block_;
+import front::ast::obj_field;
+import front::ast::decl;
+import front::ast::arm;
+import front::ast::stmt;
+import front::ast::stmt_;
+import front::ast::stmt_decl;
+import front::ast::stmt_expr;
+import front::ast::stmt_crate_directive;
+import front::ast::decl_local;
+import front::ast::decl_item;
+import front::ast::ident;
+import front::ast::def_id;
+import front::ast::ann;
+import front::ast::field;
+import front::ast::expr;
+import front::ast::expr_call;
+import front::ast::expr_vec;
+import front::ast::expr_tup;
+import front::ast::expr_path;
+import front::ast::expr_field;
+import front::ast::expr_index;
+import front::ast::expr_log;
+import front::ast::expr_block;
+import front::ast::expr_rec;
+import front::ast::expr_if;
+import front::ast::expr_binary;
+import front::ast::expr_unary;
+import front::ast::expr_assign;
+import front::ast::expr_assign_op;
+import front::ast::expr_while;
+import front::ast::expr_do_while;
+import front::ast::expr_alt;
+import front::ast::expr_lit;
+import front::ast::expr_ret;
+import front::ast::expr_self_method;
+import front::ast::expr_bind;
+import front::ast::expr_spawn;
+import front::ast::expr_ext;
+import front::ast::expr_fail;
+import front::ast::expr_break;
+import front::ast::expr_cont;
+import front::ast::expr_send;
+import front::ast::expr_recv;
+import front::ast::expr_put;
+import front::ast::expr_port;
+import front::ast::expr_chan;
+import front::ast::expr_be;
+import front::ast::expr_check;
+import front::ast::expr_assert;
+import front::ast::expr_cast;
+import front::ast::expr_for;
+import front::ast::expr_for_each;
+import front::ast::path;
+import front::ast::elt;
+import front::ast::crate_directive;
+import front::ast::fn_decl;
+import front::ast::_obj;
+import front::ast::native_mod;
+import front::ast::variant;
+import front::ast::ty_param;
+import front::ast::ty;
+import front::ast::proto;
+import front::ast::pat;
+import front::ast::binop;
+import front::ast::unop;
+import front::ast::def;
+import front::ast::lit;
+import front::ast::init_op;
+import front::ast::initializer;
+import front::ast::local;
+import front::ast::_fn;
+import front::ast::ann_none;
+import front::ast::ann_type;
+import front::ast::_obj;
+import front::ast::_mod;
+import front::ast::crate;
+import front::ast::item_fn;
+import front::ast::item_obj;
+import front::ast::def_local;
+
+import middle::fold;
+import middle::fold::respan;
+import driver::session;
+import util::common;
+import util::common::span;
+import util::common::spanned;
+import util::common::new_str_hash;
+import util::common::new_def_hash;
+import util::common::uistr;
+import util::common::elt_exprs;
+import util::common::field_exprs;
+import util::common::log_expr;
+import util::common::log_expr_err;
+import util::common::log_stmt;
+import util::common::log_block;
+import util::common::log_stmt_err;
+import util::common::log_fn_err;
+import util::common::log_fn;
+import util::common::log_block_err;
+import util::common::has_nonlocal_exits;
+import util::common::decl_lhs;
+import util::typestate_ann;
+import util::typestate_ann::ts_ann;
+import util::typestate_ann::empty_pre_post;
+import util::typestate_ann::empty_poststate;
+import util::typestate_ann::true_precond;
+import util::typestate_ann::true_postcond;
+import util::typestate_ann::false_postcond;
+import util::typestate_ann::postcond;
+import util::typestate_ann::precond;
+import util::typestate_ann::poststate;
+import util::typestate_ann::prestate;
+import util::typestate_ann::pre_and_post;
+import util::typestate_ann::get_pre;
+import util::typestate_ann::get_post;
+import util::typestate_ann::ann_precond;
+import util::typestate_ann::ann_prestate;
+import util::typestate_ann::set_precondition;
+import util::typestate_ann::set_postcondition;
+import util::typestate_ann::set_prestate;
+import util::typestate_ann::set_poststate;
+import util::typestate_ann::set_in_postcond;
+import util::typestate_ann::set_in_poststate;
+import util::typestate_ann::implies;
+import util::typestate_ann::pre_and_post_state;
+import util::typestate_ann::empty_states;
+import util::typestate_ann::empty_prestate;
+import util::typestate_ann::empty_ann;
+import util::typestate_ann::extend_prestate;
+import util::typestate_ann::extend_poststate;
+import util::typestate_ann::relax_prestate;
+import util::typestate_ann::intersect;
+import util::typestate_ann::pp_clone;
+import util::typestate_ann::clone;
+
+import middle::ty;
+import middle::ty::ann_to_type;
+import middle::ty::arg;
+import middle::ty::expr_ann;
+import middle::ty::ty_to_str;
+
+import pretty::pprust::print_block;
+import pretty::pprust::print_expr;
+import pretty::pprust::print_decl;
+import pretty::pp::mkstate;
+import std::io::stdout;
+import std::io::str_writer;
+import std::io::string_writer;
+import std::_vec::map;
+import std::_vec;
+import std::_vec::len;
+import std::_vec::pop;
+import std::_vec::push;
+import std::_vec::slice;
+import std::_vec::unzip;
+import std::_vec::plus_option;
+import std::_vec::cat_options;
+import std::option;
+import std::option::t;
+import std::option::some;
+import std::option::none;
+import std::option::from_maybe;
+import std::option::maybe;
+import std::option::is_none;
+import std::option::get;
+import std::map::hashmap;
+import std::list;
+import std::list::list;
+import std::list::cons;
+import std::list::nil;
+import std::list::foldl;
+import std::list::find;
+import std::_uint;
+import std::bitv;
+import std::util::fst;
+import std::util::snd;
+
+import util::typestate_ann;
+import util::typestate_ann::difference;
+import util::typestate_ann::union;
+import util::typestate_ann::pps_len;
+import util::typestate_ann::require_and_preserve;
+
+import resolve::def_map;
/**** debugging junk ****/
-fn bitv_to_str(fn_info enclosing, BitV.t v) -> str {
+fn bitv_to_str(fn_info enclosing, bitv::t v) -> str {
auto s = "";
for each (@tup(def_id, tup(uint, ident)) p in enclosing.items()) {
- if (BitV.get(v, p._1._0)) {
+ if (bitv::get(v, p._1._0)) {
s += " " + p._1._1 + " ";
}
}
ret s;
}
-fn log_bitv(fn_info enclosing, BitV.t v) {
+fn log_bitv(fn_info enclosing, bitv::t v) {
log(bitv_to_str(enclosing, v));
}
-fn log_bitv_err(fn_info enclosing, BitV.t v) {
+fn log_bitv_err(fn_info enclosing, bitv::t v) {
log_err(bitv_to_str(enclosing, v));
}
@@ -233,8 +233,8 @@ fn log_cond_err(vec[uint] v) -> () {
}
fn log_pp(&pre_and_post pp) -> () {
- auto p1 = BitV.to_vec(pp.precondition);
- auto p2 = BitV.to_vec(pp.postcondition);
+ auto p1 = bitv::to_vec(pp.precondition);
+ auto p2 = bitv::to_vec(pp.postcondition);
log("pre:");
log_cond(p1);
log("post:");
@@ -242,8 +242,8 @@ fn log_pp(&pre_and_post pp) -> () {
}
fn log_pp_err(&pre_and_post pp) -> () {
- auto p1 = BitV.to_vec(pp.precondition);
- auto p2 = BitV.to_vec(pp.postcondition);
+ auto p1 = bitv::to_vec(pp.precondition);
+ auto p2 = bitv::to_vec(pp.postcondition);
log_err("pre:");
log_cond_err(p1);
log_err("post:");
@@ -251,8 +251,8 @@ fn log_pp_err(&pre_and_post pp) -> () {
}
fn log_states(&pre_and_post_state pp) -> () {
- auto p1 = BitV.to_vec(pp.prestate);
- auto p2 = BitV.to_vec(pp.poststate);
+ auto p1 = bitv::to_vec(pp.prestate);
+ auto p2 = bitv::to_vec(pp.poststate);
log("prestate:");
log_cond(p1);
log("poststate:");
@@ -260,8 +260,8 @@ fn log_states(&pre_and_post_state pp) -> () {
}
fn log_states_err(&pre_and_post_state pp) -> () {
- auto p1 = BitV.to_vec(pp.prestate);
- auto p2 = BitV.to_vec(pp.poststate);
+ auto p1 = bitv::to_vec(pp.prestate);
+ auto p2 = bitv::to_vec(pp.poststate);
log_err("prestate:");
log_cond_err(p1);
log_err("poststate:");
@@ -286,9 +286,9 @@ fn print_idents(vec[ident] idents) -> () {
variable in a given function) to bit number
(also remembers the ident for error-logging purposes) */
type var_info = tup(uint, ident);
-type fn_info = std.Map.hashmap[def_id, var_info];
+type fn_info = std::map::hashmap[def_id, var_info];
/* mapping from function name to fn_info map */
-type fn_info_map = std.Map.hashmap[def_id, fn_info];
+type fn_info_map = std::map::hashmap[def_id, fn_info];
fn bit_num(def_id v, fn_info m) -> uint {
assert (m.contains_key(v));
@@ -307,25 +307,25 @@ fn num_locals(fn_info m) -> uint {
ret m.size();
}
-fn collect_local(&@vec[tup(ident, def_id)] vars, &span sp, &@ast.local loc)
+fn collect_local(&@vec[tup(ident, def_id)] vars, &span sp, &@ast::local loc)
-> @decl {
log("collect_local: pushing " + loc.ident);
- Vec.push[tup(ident, def_id)](*vars, tup(loc.ident, loc.id));
+ _vec::push[tup(ident, def_id)](*vars, tup(loc.ident, loc.id));
ret @respan(sp, decl_local(loc));
}
fn find_locals(_fn f) -> @vec[tup(ident,def_id)] {
- auto res = @Vec.alloc[tup(ident,def_id)](0u);
+ auto res = @_vec::alloc[tup(ident,def_id)](0u);
- auto fld = fold.new_identity_fold[@vec[tup(ident, def_id)]]();
+ auto fld = fold::new_identity_fold[@vec[tup(ident, def_id)]]();
fld = @rec(fold_decl_local = bind collect_local(_,_,_) with *fld);
- auto ignore = fold.fold_fn[@vec[tup(ident, def_id)]](res, fld, f);
+ auto ignore = fold::fold_fn[@vec[tup(ident, def_id)]](res, fld, f);
ret res;
}
fn add_var(def_id v, ident nm, uint next, fn_info tbl) -> uint {
- log(nm + " |-> " + util.common.uistr(next));
+ log(nm + " |-> " + util::common::uistr(next));
tbl.insert(v, tup(next,nm));
ret (next + 1u);
}
@@ -335,13 +335,13 @@ fn add_var(def_id v, ident nm, uint next, fn_info tbl) -> uint {
fn mk_fn_info(_fn f) -> fn_info {
auto res = new_def_hash[var_info]();
let uint next = 0u;
- let vec[ast.arg] f_args = f.decl.inputs;
+ let vec[ast::arg] f_args = f.decl.inputs;
/* ignore args, which we know are initialized;
just collect locally declared vars */
let @vec[tup(ident,def_id)] locals = find_locals(f);
- log(uistr(Vec.len[tup(ident, def_id)](*locals)) + " locals");
+ log(uistr(_vec::len[tup(ident, def_id)](*locals)) + " locals");
for (tup(ident,def_id) p in *locals) {
next = add_var(p._1, p._0, next, res);
}
@@ -351,8 +351,8 @@ fn mk_fn_info(_fn f) -> fn_info {
/* extends mk_fn_info to a function item, side-effecting the map fi from
function IDs to fn_info maps */
-fn mk_fn_info_item_fn(&fn_info_map fi, &span sp, &ident i, &ast._fn f,
- &vec[ast.ty_param] ty_params, &def_id id, &ann a) -> @item {
+fn mk_fn_info_item_fn(&fn_info_map fi, &span sp, &ident i, &ast::_fn f,
+ &vec[ast::ty_param] ty_params, &def_id id, &ann a) -> @item {
fi.insert(id, mk_fn_info(f));
log(i + " has " + uistr(num_locals(mk_fn_info(f))) + " local vars");
ret @respan(sp, item_fn(i, f, ty_params, id, a));
@@ -360,10 +360,10 @@ fn mk_fn_info_item_fn(&fn_info_map fi, &span sp, &ident i, &ast._fn f,
/* extends mk_fn_info to an obj item, side-effecting the map fi from
function IDs to fn_info maps */
-fn mk_fn_info_item_obj(&fn_info_map fi, &span sp, &ident i, &ast._obj o,
- &vec[ast.ty_param] ty_params,
- &ast.obj_def_ids odid, &ann a) -> @item {
- auto all_methods = Vec.clone[@method](o.methods);
+fn mk_fn_info_item_obj(&fn_info_map fi, &span sp, &ident i, &ast::_obj o,
+ &vec[ast::ty_param] ty_params,
+ &ast::obj_def_ids odid, &ann a) -> @item {
+ auto all_methods = _vec::clone[@method](o.methods);
plus_option[@method](all_methods, o.dtor);
for (@method m in all_methods) {
fi.insert(m.node.id, mk_fn_info(m.node.meth));
@@ -376,14 +376,14 @@ fn mk_fn_info_item_obj(&fn_info_map fi, &span sp, &ident i, &ast._obj o,
/* initializes the global fn_info_map (mapping each function ID, including
nested locally defined functions, onto a mapping from local variable name
to bit number) */
-fn mk_f_to_fn_info(@ast.crate c) -> fn_info_map {
+fn mk_f_to_fn_info(@ast::crate c) -> fn_info_map {
auto res = new_def_hash[fn_info]();
- auto fld = fold.new_identity_fold[fn_info_map]();
+ auto fld = fold::new_identity_fold[fn_info_map]();
fld = @rec(fold_item_fn = bind mk_fn_info_item_fn(_,_,_,_,_,_,_),
fold_item_obj = bind mk_fn_info_item_obj(_,_,_,_,_,_,_)
with *fld);
- fold.fold_crate[fn_info_map](res, fld, c);
+ fold::fold_crate[fn_info_map](res, fld, c);
ret res;
}
@@ -402,7 +402,7 @@ fn ann_to_ts_ann(ann a, uint nv) -> ts_ann {
}
}
-fn ann_to_ts_ann_fail(ann a) -> Option.t[@ts_ann] {
+fn ann_to_ts_ann_fail(ann a) -> option::t[@ts_ann] {
alt (a) {
case (ann_none(_)) {
log("ann_to_ts_ann_fail: didn't expect ann_none here");
@@ -431,7 +431,7 @@ fn ann_to_poststate(ann a) -> poststate {
ret (ann_to_ts_ann_fail_more(a)).states.poststate;
}
-fn stmt_to_ann(&stmt s) -> Option.t[@ts_ann] {
+fn stmt_to_ann(&stmt s) -> option::t[@ts_ann] {
alt (s.node) {
case (stmt_decl(_,?a)) {
ret ann_to_ts_ann_fail(a);
@@ -651,7 +651,7 @@ fn seq_preconds(fn_info enclosing, vec[pre_and_post] pps) -> precond {
/* works on either postconds or preconds
should probably rethink the whole type synonym situation */
fn union_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
- auto sz = Vec.len[postcond](rest);
+ auto sz = _vec::len[postcond](rest);
if (sz > 0u) {
auto other = rest.(0);
@@ -664,7 +664,7 @@ fn union_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
fn union_postconds(uint nv, &vec[postcond] pcs) -> postcond {
if (len[postcond](pcs) > 0u) {
- ret union_postconds_go(BitV.clone(pcs.(0)), pcs);
+ ret union_postconds_go(bitv::clone(pcs.(0)), pcs);
}
else {
ret empty_prestate(nv);
@@ -673,7 +673,7 @@ fn union_postconds(uint nv, &vec[postcond] pcs) -> postcond {
/* Gee, maybe we could use foldl or something */
fn intersect_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
- auto sz = Vec.len[postcond](rest);
+ auto sz = _vec::len[postcond](rest);
if (sz > 0u) {
auto other = rest.(0);
@@ -688,7 +688,7 @@ fn intersect_postconds_go(&postcond first, &vec[postcond] rest) -> postcond {
fn intersect_postconds(&vec[postcond] pcs) -> postcond {
assert (len[postcond](pcs) > 0u);
- ret intersect_postconds_go(BitV.clone(pcs.(0)), pcs);
+ ret intersect_postconds_go(bitv::clone(pcs.(0)), pcs);
}
/******* AST-traversing code ********/
@@ -719,8 +719,8 @@ fn find_pre_post_obj(&def_map dm, &fn_info_map fm, _obj o) -> () {
find_pre_post_fn(dm, fm, fm.get(m.node.id), m.node.meth);
}
auto f = bind do_a_method(dm, fm, _);
- Vec.map[@method, ()](f, o.methods);
- Option.map[@method, ()](f, o.dtor);
+ _vec::map[@method, ()](f, o.methods);
+ option::map[@method, ()](f, o.dtor);
}
fn find_pre_post_state_obj(&def_map dm, &fn_info_map fm, _obj o) -> bool {
@@ -729,8 +729,8 @@ fn find_pre_post_state_obj(&def_map dm, &fn_info_map fm, _obj o) -> bool {
ret find_pre_post_state_fn(dm, fm, fm.get(m.node.id), m.node.meth);
}
auto f = bind do_a_method(dm, fm, _);
- auto flags = Vec.map[@method, bool](f, o.methods);
- auto changed = Vec.or(flags);
+ auto flags = _vec::map[@method, bool](f, o.methods);
+ auto changed = _vec::or(flags);
changed = changed || maybe[@method, bool](false, f, o.dtor);
ret changed;
}
@@ -738,26 +738,26 @@ fn find_pre_post_state_obj(&def_map dm, &fn_info_map fm, _obj o) -> bool {
fn find_pre_post_item(&def_map dm, &fn_info_map fm, &fn_info enclosing,
&item i) -> () {
alt (i.node) {
- case (ast.item_const(?id, ?t, ?e, ?di, ?a)) {
+ case (ast::item_const(?id, ?t, ?e, ?di, ?a)) {
find_pre_post_expr(dm, fm, enclosing, e);
}
- case (ast.item_fn(?id, ?f, ?ps, ?di, ?a)) {
+ case (ast::item_fn(?id, ?f, ?ps, ?di, ?a)) {
assert (fm.contains_key(di));
find_pre_post_fn(dm, fm, fm.get(di), f);
}
- case (ast.item_mod(?id, ?m, ?di)) {
+ case (ast::item_mod(?id, ?m, ?di)) {
find_pre_post_mod(m);
}
- case (ast.item_native_mod(?id, ?nm, ?di)) {
+ case (ast::item_native_mod(?id, ?nm, ?di)) {
find_pre_post_native_mod(nm);
}
- case (ast.item_ty(_,_,_,_,_)) {
+ case (ast::item_ty(_,_,_,_,_)) {
ret;
}
- case (ast.item_tag(_,_,_,_,_)) {
+ case (ast::item_tag(_,_,_,_,_)) {
ret;
}
- case (ast.item_obj(?id, ?o, ?ps, ?di, ?a)) {
+ case (ast::item_obj(?id, ?o, ?ps, ?di, ?a)) {
find_pre_post_obj(dm, fm, o);
}
}
@@ -777,19 +777,19 @@ fn find_pre_post_exprs(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
auto f = bind do_one(dm, fm, enclosing, _);
- Vec.map[@expr, ()](f, args);
+ _vec::map[@expr, ()](f, args);
fn get_pp(&@expr e) -> pre_and_post {
ret expr_pp(e);
}
auto g = get_pp;
- auto pps = Vec.map[@expr, pre_and_post](g, args);
+ auto pps = _vec::map[@expr, pre_and_post](g, args);
auto h = get_post;
set_pre_and_post(a,
rec(precondition=seq_preconds(enclosing, pps),
postcondition=union_postconds
- (nv, (Vec.map[pre_and_post, postcond](h, pps)))));
+ (nv, (_vec::map[pre_and_post, postcond](h, pps)))));
}
fn find_pre_post_loop(&def_map dm, &fn_info_map fm, &fn_info enclosing,
@@ -816,13 +816,13 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
alt (e.node) {
case (expr_call(?operator, ?operands, ?a)) {
- auto args = Vec.clone[@expr](operands);
- Vec.push[@expr](args, operator);
+ auto args = _vec::clone[@expr](operands);
+ _vec::push[@expr](args, operator);
find_pre_post_exprs(dm, fm, enclosing, args, a);
}
case (expr_spawn(_, _, ?operator, ?operands, ?a)) {
- auto args = Vec.clone[@expr](operands);
- Vec.push[@expr](args, operator);
+ auto args = _vec::clone[@expr](operands);
+ _vec::push[@expr](args, operator);
find_pre_post_exprs(dm, fm, enclosing, args, a);
}
case (expr_vec(?args, _, ?a)) {
@@ -834,7 +834,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
case (expr_path(?p, ?a)) {
auto res = empty_pre_post(num_local_vars);
- alt (dm.get(ast.ann_tag(a))) {
+ alt (dm.get(ast::ann_tag(a))) {
case (def_local(?d_id)) {
auto i = bit_num(d_id, enclosing);
require_and_preserve(i, res);
@@ -875,13 +875,13 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
case (expr_rec(?fields,?maybe_base,?a)) {
auto es = field_exprs(fields);
- Vec.plus_option[@expr](es, maybe_base);
+ _vec::plus_option[@expr](es, maybe_base);
find_pre_post_exprs(dm, fm, enclosing, es, a);
}
case (expr_assign(?lhs, ?rhs, ?a)) {
alt (lhs.node) {
case (expr_path(?p, ?a_lhs)) {
- alt (dm.get(ast.ann_tag(a_lhs))) {
+ alt (dm.get(ast::ann_tag(a_lhs))) {
case (def_local(?d_id)) {
find_pre_post_expr(dm, fm, enclosing, rhs);
set_pre_and_post(a, expr_pp(rhs));
@@ -902,7 +902,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
case (expr_recv(?lhs, ?rhs, ?a)) {
alt (lhs.node) {
case (expr_path(?p, ?a_lhs)) {
- alt (dm.get(ast.ann_tag(a_lhs))) {
+ alt (dm.get(ast::ann_tag(a_lhs))) {
case (def_local(?d_id)) {
find_pre_post_expr(dm, fm, enclosing, rhs);
set_pre_and_post(a, expr_pp(rhs));
@@ -1048,7 +1048,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
ret block_pp(an_alt.block);
}
auto f = bind do_an_alt(dm, fm, enclosing, _);
- auto alt_pps = Vec.map[arm, pre_and_post](f, alts);
+ auto alt_pps = _vec::map[arm, pre_and_post](f, alts);
fn combine_pp(pre_and_post antec,
fn_info enclosing, &pre_and_post pp,
&pre_and_post next) -> pre_and_post {
@@ -1062,7 +1062,7 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
postcondition=false_postcond(num_local_vars));
auto g = bind combine_pp(antec_pp, enclosing, _, _);
- auto alts_overall_pp = Vec.foldl[pre_and_post, pre_and_post]
+ auto alts_overall_pp = _vec::foldl[pre_and_post, pre_and_post]
(g, e_pp, alt_pps);
set_pre_and_post(a, alts_overall_pp);
@@ -1088,8 +1088,8 @@ fn find_pre_post_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
set_pre_and_post(a, expr_pp(p));
}
case(expr_bind(?operator, ?maybe_args, ?a)) {
- auto args = Vec.cat_options[@expr](maybe_args);
- Vec.push[@expr](args, operator); /* ??? order of eval? */
+ auto args = _vec::cat_options[@expr](maybe_args);
+ _vec::push[@expr](args, operator); /* ??? order of eval? */
find_pre_post_exprs(dm, fm, enclosing, args, a);
}
case (expr_break(?a)) {
@@ -1131,17 +1131,17 @@ fn gen_poststate(&fn_info enclosing, &ann a, def_id id) -> bool {
}
fn find_pre_post_stmt(&def_map dm, fn_info_map fm, &fn_info enclosing,
- &ast.stmt s) -> () {
+ &ast::stmt s) -> () {
log("stmt =");
log_stmt(s);
auto num_local_vars = num_locals(enclosing);
alt(s.node) {
- case(ast.stmt_decl(?adecl, ?a)) {
+ case(ast::stmt_decl(?adecl, ?a)) {
alt(adecl.node) {
- case(ast.decl_local(?alocal)) {
+ case(ast::decl_local(?alocal)) {
alt(alocal.init) {
- case(some[ast.initializer](?an_init)) {
+ case(some[ast::initializer](?an_init)) {
find_pre_post_expr(dm, fm, enclosing, an_init.expr);
auto rhs_pp = expr_pp(an_init.expr);
set_pre_and_post(alocal.ann, rhs_pp);
@@ -1157,7 +1157,7 @@ fn find_pre_post_stmt(&def_map dm, fn_info_map fm, &fn_info enclosing,
log_err("pp = ");
log_pp(stmt_pp(s)); */
}
- case(none[ast.initializer]) {
+ case(none[ast::initializer]) {
auto pp = empty_pre_post(num_local_vars);
set_pre_and_post(alocal.ann, pp);
set_pre_and_post(a, pp);
@@ -1207,12 +1207,12 @@ fn find_pre_post_block(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
auto do_one = bind do_one_(dm, fm, enclosing, _);
- Vec.map[@stmt, ()](do_one, b.node.stmts);
+ _vec::map[@stmt, ()](do_one, b.node.stmts);
fn do_inner_(def_map dm, fn_info_map fm, fn_info i, &@expr e) -> () {
find_pre_post_expr(dm, fm, i, e);
}
auto do_inner = bind do_inner_(dm, fm, enclosing, _);
- Option.map[@expr, ()](do_inner, b.node.expr);
+ option::map[@expr, ()](do_inner, b.node.expr);
let vec[pre_and_post] pps = vec();
@@ -1220,20 +1220,20 @@ fn find_pre_post_block(&def_map dm, &fn_info_map fm, &fn_info enclosing,
ret stmt_pp(*s);
}
auto f = get_pp_stmt;
- pps += Vec.map[@stmt, pre_and_post](f, b.node.stmts);
+ pps += _vec::map[@stmt, pre_and_post](f, b.node.stmts);
fn get_pp_expr(&@expr e) -> pre_and_post {
ret expr_pp(e);
}
auto g = get_pp_expr;
plus_option[pre_and_post](pps,
- Option.map[@expr, pre_and_post](g, b.node.expr));
+ option::map[@expr, pre_and_post](g, b.node.expr));
auto block_precond = seq_preconds(enclosing, pps);
auto h = get_post;
- auto postconds = Vec.map[pre_and_post, postcond](h, pps);
+ auto postconds = _vec::map[pre_and_post, postcond](h, pps);
/* A block may be empty, so this next line ensures that the postconds
vector is non-empty. */
- Vec.push[postcond](postconds, block_precond);
+ _vec::push[postcond](postconds, block_precond);
auto block_postcond = empty_poststate(nv);
/* conservative approximation */
if (! has_nonlocal_exits(b)) {
@@ -1248,8 +1248,8 @@ fn find_pre_post_fn(&def_map dm, &fn_info_map fm, &fn_info fi, &_fn f) -> () {
find_pre_post_block(dm, fm, fi, f.body);
}
-fn check_item_fn(&def_map dm, &fn_info_map fm, &span sp, &ident i, &ast._fn f,
- &vec[ast.ty_param] ty_params,
+fn check_item_fn(&def_map dm, &fn_info_map fm, &span sp, &ident i,
+ &ast::_fn f, &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item {
log("check_item_fn:");
@@ -1258,33 +1258,33 @@ fn check_item_fn(&def_map dm, &fn_info_map fm, &span sp, &ident i, &ast._fn f,
assert (fm.contains_key(id));
find_pre_post_fn(dm, fm, fm.get(id), f);
- ret @respan(sp, ast.item_fn(i, f, ty_params, id, a));
+ ret @respan(sp, ast::item_fn(i, f, ty_params, id, a));
}
fn find_pre_post_state_item(&def_map dm, &fn_info_map fm, &fn_info enclosing,
@item i) -> bool {
alt (i.node) {
- case (ast.item_const(?id, ?t, ?e, ?di, ?a)) {
+ case (ast::item_const(?id, ?t, ?e, ?di, ?a)) {
ret find_pre_post_state_expr(dm, fm, enclosing,
empty_prestate(num_locals(enclosing)), e);
}
- case (ast.item_fn(?id, ?f, ?ps, ?di, ?a)) {
+ case (ast::item_fn(?id, ?f, ?ps, ?di, ?a)) {
assert (fm.contains_key(di));
ret find_pre_post_state_fn(dm, fm, fm.get(di), f);
}
- case (ast.item_mod(?id, ?m, ?di)) {
+ case (ast::item_mod(?id, ?m, ?di)) {
ret find_pre_post_state_mod(m);
}
- case (ast.item_native_mod(?id, ?nm, ?di)) {
+ case (ast::item_native_mod(?id, ?nm, ?di)) {
ret find_pre_post_state_native_mod(nm);
}
- case (ast.item_ty(_,_,_,_,_)) {
+ case (ast::item_ty(_,_,_,_,_)) {
ret false;
}
- case (ast.item_tag(_,_,_,_,_)) {
+ case (ast::item_tag(_,_,_,_,_)) {
ret false;
}
- case (ast.item_obj(?id, ?o, ?ps, ?di, ?a)) {
+ case (ast::item_obj(?id, ?o, ?ps, ?di, ?a)) {
ret find_pre_post_state_obj(dm, fm, o);
}
}
@@ -1518,7 +1518,7 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
alt (lhs.node) {
case (expr_path(_, ?a_lhs)) {
- alt (dm.get(ast.ann_tag(a_lhs))) {
+ alt (dm.get(ast::ann_tag(a_lhs))) {
case (def_local(?d_id)) {
// assignment to local var
changed = pure_exp(a_lhs, pres) || changed;
@@ -1546,7 +1546,7 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
alt (lhs.node) {
case (expr_path(?p, ?a_lhs)) {
- alt (dm.get(ast.ann_tag(a_lhs))) {
+ alt (dm.get(ast::ann_tag(a_lhs))) {
case (def_local(?d_id)) {
// receive to local var
changed = pure_exp(a_lhs, pres) || changed;
@@ -1708,7 +1708,7 @@ fn find_pre_post_state_expr(&def_map dm, &fn_info_map fm, &fn_info enclosing,
|| changed;
auto e_post = expr_poststate(e);
auto a_post;
- if (Vec.len[arm](alts) > 0u) {
+ if (_vec::len[arm](alts) > 0u) {
a_post = false_postcond(num_local_vars);
for (arm an_alt in alts) {
changed = find_pre_post_state_block(dm, fm, enclosing, e_post,
@@ -1788,18 +1788,18 @@ fn find_pre_post_state_stmt(&def_map dm, &fn_info_map fm, &fn_info enclosing,
log("*At beginning: stmt = ");
log_stmt(*s);
log("*prestate = ");
- log(BitV.to_str(stmt_ann.states.prestate));
+ log(bitv::to_str(stmt_ann.states.prestate));
log("*poststate =");
- log(BitV.to_str(stmt_ann.states.poststate));
+ log(bitv::to_str(stmt_ann.states.poststate));
log("*changed =");
log(changed);
alt (s.node) {
case (stmt_decl(?adecl, ?a)) {
alt (adecl.node) {
- case (ast.decl_local(?alocal)) {
+ case (ast::decl_local(?alocal)) {
alt (alocal.init) {
- case (some[ast.initializer](?an_init)) {
+ case (some[ast::initializer](?an_init)) {
changed = extend_prestate(stmt_ann.states.prestate, pres)
|| changed;
changed = find_pre_post_state_expr
@@ -1811,7 +1811,7 @@ fn find_pre_post_state_stmt(&def_map dm, &fn_info_map fm, &fn_info enclosing,
log("Summary: stmt = ");
log_stmt(*s);
log("prestate = ");
- log(BitV.to_str(stmt_ann.states.prestate));
+ log(bitv::to_str(stmt_ann.states.prestate));
log_bitv(enclosing, stmt_ann.states.prestate);
log("poststate =");
log_bitv(enclosing, stmt_ann.states.poststate);
@@ -1820,7 +1820,7 @@ fn find_pre_post_state_stmt(&def_map dm, &fn_info_map fm, &fn_info enclosing,
ret changed;
}
- case (none[ast.initializer]) {
+ case (none[ast::initializer]) {
changed = extend_prestate(stmt_ann.states.prestate, pres)
|| changed;
changed = extend_poststate(stmt_ann.states.poststate, pres)
@@ -1829,7 +1829,7 @@ fn find_pre_post_state_stmt(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
}
}
- case (ast.decl_item(?an_item)) {
+ case (ast::decl_item(?an_item)) {
changed = extend_prestate(stmt_ann.states.prestate, pres)
|| changed;
changed = extend_poststate(stmt_ann.states.poststate, pres)
@@ -1850,10 +1850,10 @@ fn find_pre_post_state_stmt(&def_map dm, &fn_info_map fm, &fn_info enclosing,
log("Summary: stmt = ");
log_stmt(*s);
log("prestate = ");
- log(BitV.to_str(stmt_ann.states.prestate));
+ log(bitv::to_str(stmt_ann.states.prestate));
log_bitv(enclosing, stmt_ann.states.prestate);
log("poststate =");
- log(BitV.to_str(stmt_ann.states.poststate));
+ log(bitv::to_str(stmt_ann.states.poststate));
log_bitv(enclosing, stmt_ann.states.poststate);
log("changed =");
log(changed);
@@ -1926,7 +1926,7 @@ fn find_pre_post_state_block(&def_map dm, &fn_info_map fm, &fn_info enclosing,
}
fn find_pre_post_state_fn(&def_map dm, &fn_info_map f_info, &fn_info fi,
- &ast._fn f) -> bool {
+ &ast::_fn f) -> bool {
/* FIXME: where do we set args as being initialized?
What about for methods? */
auto num_local_vars = num_locals(fi);
@@ -1981,23 +1981,23 @@ fn check_states_stmt(fn_info enclosing, &stmt s) -> () {
}
}
-fn check_states_against_conditions(fn_info enclosing, &ast._fn f) -> () {
+fn check_states_against_conditions(fn_info enclosing, &ast::_fn f) -> () {
fn do_one_(fn_info i, &@stmt s) -> () {
check_states_stmt(i, *s);
}
auto do_one = bind do_one_(enclosing, _);
- Vec.map[@stmt, ()](do_one, f.body.node.stmts);
+ _vec::map[@stmt, ()](do_one, f.body.node.stmts);
fn do_inner_(fn_info i, &@expr e) -> () {
check_states_expr(i, e);
}
auto do_inner = bind do_inner_(enclosing, _);
- Option.map[@expr, ()](do_inner, f.body.node.expr);
+ option::map[@expr, ()](do_inner, f.body.node.expr);
}
fn check_fn_states(&def_map dm, &fn_info_map f_info_map, &fn_info f_info,
- &ast._fn f) -> () {
+ &ast::_fn f) -> () {
/* Compute the pre- and post-states for this function */
// (Fixpoint iteration)
while (find_pre_post_state_fn(dm, f_info_map, f_info, f)) {}
@@ -2008,7 +2008,7 @@ fn check_fn_states(&def_map dm, &fn_info_map f_info_map, &fn_info f_info,
}
fn check_item_fn_state(def_map dm, &fn_info_map f_info_map, &span sp,
- &ident i, &ast._fn f, &vec[ast.ty_param] ty_params,
+ &ident i, &ast::_fn f, &vec[ast::ty_param] ty_params,
&def_id id, &ann a) -> @item {
/* Look up the var-to-bit-num map for this function */
@@ -2018,7 +2018,7 @@ fn check_item_fn_state(def_map dm, &fn_info_map f_info_map, &span sp,
check_fn_states(dm, f_info_map, f_info, f);
/* Rebuild the same function */
- ret @respan(sp, ast.item_fn(i, f, ty_params, id, a));
+ ret @respan(sp, ast::item_fn(i, f, ty_params, id, a));
}
fn check_method_states(&def_map dm, &fn_info_map f_info_map, @method m) {
@@ -2029,13 +2029,13 @@ fn check_method_states(&def_map dm, &fn_info_map f_info_map, @method m) {
fn check_obj_state(def_map dm, &fn_info_map f_info_map,
&vec[obj_field] fields, &vec[@method] methods,
- &Option.t[@method] dtor) -> ast._obj {
+ &option::t[@method] dtor) -> ast::_obj {
fn one(def_map dm, fn_info_map fm, &@method m) -> () {
ret check_method_states(dm, fm, m);
}
auto f = bind one(dm, f_info_map,_);
- Vec.map[@method, ()](f, methods);
- Option.map[@method, ()](f, dtor);
+ _vec::map[@method, ()](f, methods);
+ option::map[@method, ()](f, dtor);
ret rec(fields=fields, methods=methods, dtor=dtor);
}
@@ -2079,34 +2079,34 @@ fn init_block(&fn_info fi, &span sp, &block_ b) -> block {
fail;
}
case (ann_type(_, ?t,?ps,_)) {
- auto fld0 = fold.new_identity_fold[fn_info]();
+ auto fld0 = fold::new_identity_fold[fn_info]();
fld0 = @rec(fold_ann = bind init_ann(_,_) with *fld0);
- ret fold.fold_block[fn_info](fi, fld0, respan(sp, b));
+ ret fold::fold_block[fn_info](fi, fld0, respan(sp, b));
}
}
}
-fn item_fn_anns(&fn_info_map fm, &span sp, ident i, &ast._fn f,
- vec[ast.ty_param] ty_params, def_id id, ann a) -> @item {
+fn item_fn_anns(&fn_info_map fm, &span sp, ident i, &ast::_fn f,
+ vec[ast::ty_param] ty_params, def_id id, ann a) -> @item {
assert (fm.contains_key(id));
auto f_info = fm.get(id);
log(i + " has " + uistr(num_locals(f_info)) + " local vars");
- auto fld0 = fold.new_identity_fold[fn_info]();
+ auto fld0 = fold::new_identity_fold[fn_info]();
fld0 = @rec(fold_ann = bind init_ann(_,_)
with *fld0);
- ret fold.fold_item[fn_info]
+ ret fold::fold_item[fn_info]
(f_info, fld0, @respan(sp, item_fn(i, f, ty_params, id, a)));
}
/* This is painstakingly written as an explicit recursion b/c the
- standard ast.fold doesn't traverse in the correct order:
+ standard ast::fold doesn't traverse in the correct order:
consider
fn foo() {
fn bar() {
@@ -2125,7 +2125,7 @@ fn annotate_exprs(&fn_info_map fm, &vec[@expr] es) -> vec[@expr] {
ret annotate_expr(fm, e);
}
auto f = bind one(fm,_);
- ret Vec.map[@expr, @expr](f, es);
+ ret _vec::map[@expr, @expr](f, es);
}
fn annotate_elts(&fn_info_map fm, &vec[elt] es) -> vec[elt] {
fn one(fn_info_map fm, &elt e) -> elt {
@@ -2133,7 +2133,7 @@ fn annotate_elts(&fn_info_map fm, &vec[elt] es) -> vec[elt] {
expr=annotate_expr(fm, e.expr));
}
auto f = bind one(fm,_);
- ret Vec.map[elt, elt](f, es);
+ ret _vec::map[elt, elt](f, es);
}
fn annotate_fields(&fn_info_map fm, &vec[field] fs) -> vec[field] {
fn one(fn_info_map fm, &field f) -> field {
@@ -2142,23 +2142,23 @@ fn annotate_fields(&fn_info_map fm, &vec[field] fs) -> vec[field] {
expr=annotate_expr(fm, f.expr));
}
auto f = bind one(fm,_);
- ret Vec.map[field, field](f, fs);
+ ret _vec::map[field, field](f, fs);
}
-fn annotate_option_exp(&fn_info_map fm, &Option.t[@expr] o)
- -> Option.t[@expr] {
+fn annotate_option_exp(&fn_info_map fm, &option::t[@expr] o)
+ -> option::t[@expr] {
fn one(fn_info_map fm, &@expr e) -> @expr {
ret annotate_expr(fm, e);
}
auto f = bind one(fm,_);
- ret Option.map[@expr, @expr](f, o);
+ ret option::map[@expr, @expr](f, o);
}
-fn annotate_option_exprs(&fn_info_map fm, &vec[Option.t[@expr]] es)
- -> vec[Option.t[@expr]] {
- fn one(fn_info_map fm, &Option.t[@expr] o) -> Option.t[@expr] {
+fn annotate_option_exprs(&fn_info_map fm, &vec[option::t[@expr]] es)
+ -> vec[option::t[@expr]] {
+ fn one(fn_info_map fm, &option::t[@expr] o) -> option::t[@expr] {
ret annotate_option_exp(fm, o);
}
auto f = bind one(fm,_);
- ret Vec.map[Option.t[@expr], Option.t[@expr]](f, es);
+ ret _vec::map[option::t[@expr], option::t[@expr]](f, es);
}
fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl {
auto d1 = d.node;
@@ -2166,7 +2166,7 @@ fn annotate_decl(&fn_info_map fm, &@decl d) -> @decl {
case (decl_local(?l)) {
alt(l.init) {
case (some[initializer](?init)) {
- let Option.t[initializer] an_i =
+ let option::t[initializer] an_i =
some[initializer]
(rec(expr=annotate_expr(fm, init.expr)
with init));
@@ -2188,7 +2188,7 @@ fn annotate_alts(&fn_info_map fm, &vec[arm] alts) -> vec[arm] {
block=annotate_block(fm, a.block));
}
auto f = bind one(fm,_);
- ret Vec.map[arm, arm](f, alts);
+ ret _vec::map[arm, arm](f, alts);
}
fn annotate_expr(&fn_info_map fm, &@expr e) -> @expr {
@@ -2339,153 +2339,154 @@ fn annotate_block(&fn_info_map fm, &block b) -> block {
for (@stmt s in b.node.stmts) {
auto new_s = annotate_stmt(fm, s);
- Vec.push[@stmt](new_stmts, new_s);
+ _vec::push[@stmt](new_stmts, new_s);
}
fn ann_e(fn_info_map fm, &@expr e) -> @expr {
ret annotate_expr(fm, e);
}
auto f = bind ann_e(fm,_);
- auto new_e = Option.map[@expr, @expr](f, b.node.expr);
+ auto new_e = option::map[@expr, @expr](f, b.node.expr);
ret respan(b.span,
rec(stmts=new_stmts, expr=new_e with b.node));
}
-fn annotate_fn(&fn_info_map fm, &ast._fn f) -> ast._fn {
+fn annotate_fn(&fn_info_map fm, &ast::_fn f) -> ast::_fn {
// subexps have *already* been annotated based on
// f's number-of-locals
ret rec(body=annotate_block(fm, f.body) with f);
}
-fn annotate_mod(&fn_info_map fm, &ast._mod m) -> ast._mod {
+fn annotate_mod(&fn_info_map fm, &ast::_mod m) -> ast::_mod {
let vec[@item] new_items = vec();
for (@item i in m.items) {
auto new_i = annotate_item(fm, i);
- Vec.push[@item](new_items, new_i);
+ _vec::push[@item](new_items, new_i);
}
ret rec(items=new_items with m);
}
fn annotate_method(&fn_info_map fm, &@method m) -> @method {
auto f_info = get_fn_info(fm, m.node.id);
- auto fld0 = fold.new_identity_fold[fn_info]();
+ auto fld0 = fold::new_identity_fold[fn_info]();
fld0 = @rec(fold_ann = bind init_ann(_,_)
with *fld0);
- auto outer = fold.fold_method[fn_info](f_info, fld0, m);
+ auto outer = fold::fold_method[fn_info](f_info, fld0, m);
auto new_fn = annotate_fn(fm, outer.node.meth);
ret @respan(m.span,
rec(meth=new_fn with m.node));
}
-fn annotate_obj(&fn_info_map fm, &ast._obj o) -> ast._obj {
+fn annotate_obj(&fn_info_map fm, &ast::_obj o) -> ast::_obj {
fn one(fn_info_map fm, &@method m) -> @method {
ret annotate_method(fm, m);
}
auto f = bind one(fm,_);
- auto new_methods = Vec.map[@method, @method](f, o.methods);
- auto new_dtor = Option.map[@method, @method](f, o.dtor);
+ auto new_methods = _vec::map[@method, @method](f, o.methods);
+ auto new_dtor = option::map[@method, @method](f, o.dtor);
ret rec(methods=new_methods, dtor=new_dtor with o);
}
// Only annotates the components of the item recursively.
-fn annotate_item_inner(&fn_info_map fm, &@ast.item item) -> @ast.item {
+fn annotate_item_inner(&fn_info_map fm, &@ast::item item) -> @ast::item {
alt (item.node) {
/* FIXME can't skip this case -- exprs contain blocks contain stmts,
which contain decls */
- case (ast.item_const(_,_,_,_,_)) {
+ case (ast::item_const(_,_,_,_,_)) {
// this has already been annotated by annotate_item
ret item;
}
- case (ast.item_fn(?ident, ?ff, ?tps, ?id, ?ann)) {
+ case (ast::item_fn(?ident, ?ff, ?tps, ?id, ?ann)) {
ret @respan(item.span,
- ast.item_fn(ident, annotate_fn(fm, ff), tps, id, ann));
+ ast::item_fn(ident, annotate_fn(fm, ff),
+ tps, id, ann));
}
- case (ast.item_mod(?ident, ?mm, ?id)) {
+ case (ast::item_mod(?ident, ?mm, ?id)) {
ret @respan(item.span,
- ast.item_mod(ident, annotate_mod(fm, mm), id));
+ ast::item_mod(ident, annotate_mod(fm, mm), id));
}
- case (ast.item_native_mod(?ident, ?mm, ?id)) {
+ case (ast::item_native_mod(?ident, ?mm, ?id)) {
ret item;
}
- case (ast.item_ty(_,_,_,_,_)) {
+ case (ast::item_ty(_,_,_,_,_)) {
ret item;
}
- case (ast.item_tag(_,_,_,_,_)) {
+ case (ast::item_tag(_,_,_,_,_)) {
ret item;
}
- case (ast.item_obj(?ident, ?ob, ?tps, ?odid, ?ann)) {
+ case (ast::item_obj(?ident, ?ob, ?tps, ?odid, ?ann)) {
ret @respan(item.span,
- ast.item_obj(ident, annotate_obj(fm, ob), tps, odid, ann));
+ ast::item_obj(ident, annotate_obj(fm, ob), tps, odid, ann));
}
}
}
-fn annotate_item(&fn_info_map fm, &@ast.item item) -> @ast.item {
+fn annotate_item(&fn_info_map fm, &@ast::item item) -> @ast::item {
// Using a fold, recursively set all anns in this item
// to be blank.
// *Then*, call annotate_item recursively to do the right
// thing for any nested items inside this one.
alt (item.node) {
- case (ast.item_const(_,_,_,_,_)) {
- auto fld0 = fold.new_identity_fold[()]();
+ case (ast::item_const(_,_,_,_,_)) {
+ auto fld0 = fold::new_identity_fold[()]();
fld0 = @rec(fold_ann = bind init_blank_ann(_,_)
with *fld0);
- ret fold.fold_item[()]((), fld0, item);
+ ret fold::fold_item[()]((), fld0, item);
}
- case (ast.item_fn(?i,?ff,?tps,?id,?ann)) {
+ case (ast::item_fn(?i,?ff,?tps,?id,?ann)) {
auto f_info = get_fn_info(fm, id);
- auto fld0 = fold.new_identity_fold[fn_info]();
+ auto fld0 = fold::new_identity_fold[fn_info]();
fld0 = @rec(fold_ann = bind init_ann(_,_)
with *fld0);
- auto outer = fold.fold_item[fn_info](f_info, fld0, item);
+ auto outer = fold::fold_item[fn_info](f_info, fld0, item);
// now recurse into any nested items
ret annotate_item_inner(fm, outer);
}
- case (ast.item_mod(?i, ?mm, ?id)) {
- auto fld0 = fold.new_identity_fold[()]();
+ case (ast::item_mod(?i, ?mm, ?id)) {
+ auto fld0 = fold::new_identity_fold[()]();
fld0 = @rec(fold_ann = bind init_blank_ann(_,_)
with *fld0);
- auto outer = fold.fold_item[()]((), fld0, item);
+ auto outer = fold::fold_item[()]((), fld0, item);
ret annotate_item_inner(fm, outer);
}
- case (ast.item_native_mod(?i, ?nm, ?id)) {
+ case (ast::item_native_mod(?i, ?nm, ?id)) {
ret item;
}
- case (ast.item_ty(_,_,_,_,_)) {
+ case (ast::item_ty(_,_,_,_,_)) {
ret item;
}
- case (ast.item_tag(_,_,_,_,_)) {
+ case (ast::item_tag(_,_,_,_,_)) {
ret item;
}
- case (ast.item_obj(?i,?ob,?tps,?odid,?ann)) {
- auto fld0 = fold.new_identity_fold[()]();
+ case (ast::item_obj(?i,?ob,?tps,?odid,?ann)) {
+ auto fld0 = fold::new_identity_fold[()]();
fld0 = @rec(fold_ann = bind init_blank_ann(_,_)
with *fld0);
- auto outer = fold.fold_item[()]((), fld0, item);
+ auto outer = fold::fold_item[()]((), fld0, item);
ret annotate_item_inner(fm, outer);
}
}
}
-fn annotate_module(&fn_info_map fm, &ast._mod module) -> ast._mod {
+fn annotate_module(&fn_info_map fm, &ast::_mod module) -> ast::_mod {
let vec[@item] new_items = vec();
for (@item i in module.items) {
auto new_item = annotate_item(fm, i);
- Vec.push[@item](new_items, new_item);
+ _vec::push[@item](new_items, new_item);
}
ret rec(items = new_items with module);
}
-fn annotate_crate(&fn_info_map fm, &@ast.crate crate) -> @ast.crate {
+fn annotate_crate(&fn_info_map fm, &@ast::crate crate) -> @ast::crate {
ret @respan(crate.span,
rec(module = annotate_module(fm, crate.node.module)
with crate.node));
}
-fn check_crate(@ast.crate crate, def_map dm) -> @ast.crate {
+fn check_crate(@ast::crate crate, def_map dm) -> @ast::crate {
/* Build the global map from function id to var-to-bit-num-map */
auto fm = mk_f_to_fn_info(crate);
@@ -2493,18 +2494,18 @@ fn check_crate(@ast.crate crate, def_map dm) -> @ast.crate {
auto with_anns = annotate_crate(fm, crate);
/* Compute the pre and postcondition for every subexpression */
- auto fld = fold.new_identity_fold[fn_info_map]();
+ auto fld = fold::new_identity_fold[fn_info_map]();
fld = @rec(fold_item_fn = bind check_item_fn(dm,_,_,_,_,_,_,_) with *fld);
- auto with_pre_postconditions = fold.fold_crate[fn_info_map]
+ auto with_pre_postconditions = fold::fold_crate[fn_info_map]
(fm, fld, with_anns);
- auto fld1 = fold.new_identity_fold[fn_info_map]();
+ auto fld1 = fold::new_identity_fold[fn_info_map]();
fld1 = @rec(fold_item_fn = bind check_item_fn_state(dm,_,_,_,_,_,_,_),
fold_obj = bind check_obj_state(dm,_,_,_,_)
with *fld1);
- ret fold.fold_crate[fn_info_map](fm, fld1,
+ ret fold::fold_crate[fn_info_map](fm, fld1,
with_pre_postconditions);
}
diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs
index e684924a..848c4338 100644
--- a/src/comp/middle/walk.rs
+++ b/src/comp/middle/walk.rs
@@ -1,120 +1,120 @@
-import front.ast;
+import front::ast;
-import std.Option;
-import std.Option.some;
-import std.Option.none;
+import std::option;
+import std::option::some;
+import std::option::none;
type ast_visitor =
rec(fn () -> bool keep_going,
fn () -> bool want_crate_directives,
- fn (&ast.crate c) visit_crate_pre,
- fn (&ast.crate c) visit_crate_post,
- fn (&@ast.crate_directive cd) visit_crate_directive_pre,
- fn (&@ast.crate_directive cd) visit_crate_directive_post,
- fn (&@ast.view_item i) visit_view_item_pre,
- fn (&@ast.view_item i) visit_view_item_post,
- fn (&@ast.native_item i) visit_native_item_pre,
- fn (&@ast.native_item i) visit_native_item_post,
- fn (&@ast.item i) visit_item_pre,
- fn (&@ast.item i) visit_item_post,
- fn (&ast.block b) visit_block_pre,
- fn (&ast.block b) visit_block_post,
- fn (&@ast.stmt s) visit_stmt_pre,
- fn (&@ast.stmt s) visit_stmt_post,
- fn (&@ast.decl d) visit_decl_pre,
- fn (&@ast.decl d) visit_decl_post,
- fn (&@ast.expr e) visit_expr_pre,
- fn (&@ast.expr e) visit_expr_post,
- fn (&@ast.ty t) visit_ty_pre,
- fn (&@ast.ty t) visit_ty_post);
+ fn (&ast::crate c) visit_crate_pre,
+ fn (&ast::crate c) visit_crate_post,
+ fn (&@ast::crate_directive cd) visit_crate_directive_pre,
+ fn (&@ast::crate_directive cd) visit_crate_directive_post,
+ fn (&@ast::view_item i) visit_view_item_pre,
+ fn (&@ast::view_item i) visit_view_item_post,
+ fn (&@ast::native_item i) visit_native_item_pre,
+ fn (&@ast::native_item i) visit_native_item_post,
+ fn (&@ast::item i) visit_item_pre,
+ fn (&@ast::item i) visit_item_post,
+ fn (&ast::block b) visit_block_pre,
+ fn (&ast::block b) visit_block_post,
+ fn (&@ast::stmt s) visit_stmt_pre,
+ fn (&@ast::stmt s) visit_stmt_post,
+ fn (&@ast::decl d) visit_decl_pre,
+ fn (&@ast::decl d) visit_decl_post,
+ fn (&@ast::expr e) visit_expr_pre,
+ fn (&@ast::expr e) visit_expr_post,
+ fn (&@ast::ty t) visit_ty_pre,
+ fn (&@ast::ty t) visit_ty_post);
-fn walk_crate(&ast_visitor v, &ast.crate c) {
+fn walk_crate(&ast_visitor v, &ast::crate c) {
if (!v.keep_going()) { ret; }
v.visit_crate_pre(c);
walk_mod(v, c.node.module);
v.visit_crate_post(c);
}
-fn walk_crate_directive(&ast_visitor v, @ast.crate_directive cd) {
+fn walk_crate_directive(&ast_visitor v, @ast::crate_directive cd) {
if (!v.keep_going()) { ret; }
if (!v.want_crate_directives()) { ret; }
v.visit_crate_directive_pre(cd);
alt (cd.node) {
- case (ast.cdir_let(_, ?e, ?cdirs)) {
+ case (ast::cdir_let(_, ?e, ?cdirs)) {
walk_expr(v, e);
- for (@ast.crate_directive cdir in cdirs) {
+ for (@ast::crate_directive cdir in cdirs) {
walk_crate_directive(v, cdir);
}
}
- case (ast.cdir_src_mod(_, _)) {}
- case (ast.cdir_dir_mod(_, _, ?cdirs)) {
- for (@ast.crate_directive cdir in cdirs) {
+ case (ast::cdir_src_mod(_, _)) {}
+ case (ast::cdir_dir_mod(_, _, ?cdirs)) {
+ for (@ast::crate_directive cdir in cdirs) {
walk_crate_directive(v, cdir);
}
}
- case (ast.cdir_view_item(?vi)) {
+ case (ast::cdir_view_item(?vi)) {
walk_view_item(v, vi);
}
- case (ast.cdir_meta(_)) {}
- case (ast.cdir_syntax(_)) {}
- case (ast.cdir_auth(_, _)) {}
+ case (ast::cdir_meta(_)) {}
+ case (ast::cdir_syntax(_)) {}
+ case (ast::cdir_auth(_, _)) {}
}
v.visit_crate_directive_post(cd);
}
-fn walk_mod(&ast_visitor v, &ast._mod m) {
+fn walk_mod(&ast_visitor v, &ast::_mod m) {
if (!v.keep_going()) { ret; }
- for (@ast.view_item vi in m.view_items) {
+ for (@ast::view_item vi in m.view_items) {
walk_view_item(v, vi);
}
- for (@ast.item i in m.items) {
+ for (@ast::item i in m.items) {
walk_item(v, i);
}
}
-fn walk_view_item(&ast_visitor v, @ast.view_item vi) {
+fn walk_view_item(&ast_visitor v, @ast::view_item vi) {
if (!v.keep_going()) { ret; }
v.visit_view_item_pre(vi);
v.visit_view_item_post(vi);
}
-fn walk_item(&ast_visitor v, @ast.item i) {
+fn walk_item(&ast_visitor v, @ast::item i) {
if (!v.keep_going()) { ret; }
v.visit_item_pre(i);
alt (i.node) {
- case (ast.item_const(_, ?t, ?e, _, _)) {
+ case (ast::item_const(_, ?t, ?e, _, _)) {
walk_ty(v, t);
walk_expr(v, e);
}
- case (ast.item_fn(_, ?f, _, _, _)) {
+ case (ast::item_fn(_, ?f, _, _, _)) {
walk_fn(v, f);
}
- case (ast.item_mod(_, ?m, _)) {
+ case (ast::item_mod(_, ?m, _)) {
walk_mod(v, m);
}
- case (ast.item_native_mod(_, ?nm, _)) {
+ case (ast::item_native_mod(_, ?nm, _)) {
walk_native_mod(v, nm);
}
- case (ast.item_ty(_, ?t, _, _, _)) {
+ case (ast::item_ty(_, ?t, _, _, _)) {
walk_ty(v, t);
}
- case (ast.item_tag(_, ?variants, _, _, _)) {
- for (ast.variant vr in variants) {
- for (ast.variant_arg va in vr.node.args) {
+ case (ast::item_tag(_, ?variants, _, _, _)) {
+ for (ast::variant vr in variants) {
+ for (ast::variant_arg va in vr.node.args) {
walk_ty(v, va.ty);
}
}
}
- case (ast.item_obj(_, ?ob, _, _, _)) {
- for (ast.obj_field f in ob.fields) {
+ case (ast::item_obj(_, ?ob, _, _, _)) {
+ for (ast::obj_field f in ob.fields) {
walk_ty(v, f.ty);
}
- for (@ast.method m in ob.methods) {
+ for (@ast::method m in ob.methods) {
walk_fn(v, m.node.meth);
}
alt (ob.dtor) {
- case (none[@ast.method]) {}
- case (some[@ast.method](?m)) {
+ case (none[@ast::method]) {}
+ case (some[@ast::method](?m)) {
walk_fn(v, m.node.meth);
}
}
@@ -124,282 +124,282 @@ fn walk_item(&ast_visitor v, @ast.item i) {
v.visit_item_post(i);
}
-fn walk_ty(&ast_visitor v, @ast.ty t) {
+fn walk_ty(&ast_visitor v, @ast::ty t) {
if (!v.keep_going()) { ret; }
v.visit_ty_pre(t);
alt (t.node) {
- case (ast.ty_nil) {}
- case (ast.ty_bool) {}
- case (ast.ty_int) {}
- case (ast.ty_uint) {}
- case (ast.ty_float) {}
- case (ast.ty_machine(_)) {}
- case (ast.ty_char) {}
- case (ast.ty_str) {}
- case (ast.ty_box(?mt)) { walk_ty(v, mt.ty); }
- case (ast.ty_vec(?mt)) { walk_ty(v, mt.ty); }
- case (ast.ty_port(?t)) { walk_ty(v, t); }
- case (ast.ty_chan(?t)) { walk_ty(v, t); }
- case (ast.ty_tup(?mts)) {
- for (ast.mt mt in mts) {
+ case (ast::ty_nil) {}
+ case (ast::ty_bool) {}
+ case (ast::ty_int) {}
+ case (ast::ty_uint) {}
+ case (ast::ty_float) {}
+ case (ast::ty_machine(_)) {}
+ case (ast::ty_char) {}
+ case (ast::ty_str) {}
+ case (ast::ty_box(?mt)) { walk_ty(v, mt.ty); }
+ case (ast::ty_vec(?mt)) { walk_ty(v, mt.ty); }
+ case (ast::ty_port(?t)) { walk_ty(v, t); }
+ case (ast::ty_chan(?t)) { walk_ty(v, t); }
+ case (ast::ty_tup(?mts)) {
+ for (ast::mt mt in mts) {
walk_ty(v, mt.ty);
}
}
- case (ast.ty_rec(?flds)) {
- for (ast.ty_field f in flds) {
+ case (ast::ty_rec(?flds)) {
+ for (ast::ty_field f in flds) {
walk_ty(v, f.mt.ty);
}
}
- case (ast.ty_fn(_, ?args, ?out)) {
- for (ast.ty_arg a in args) {
+ case (ast::ty_fn(_, ?args, ?out)) {
+ for (ast::ty_arg a in args) {
walk_ty(v, a.ty);
}
walk_ty(v, out);
}
- case (ast.ty_obj(?tmeths)) {
- for (ast.ty_method m in tmeths) {
- for (ast.ty_arg a in m.inputs) {
+ case (ast::ty_obj(?tmeths)) {
+ for (ast::ty_method m in tmeths) {
+ for (ast::ty_arg a in m.inputs) {
walk_ty(v, a.ty);
}
walk_ty(v, m.output);
}
}
- case (ast.ty_path(_, _)) {}
- case (ast.ty_type) {}
- case (ast.ty_constr(?t, _)) { walk_ty(v, t); }
+ case (ast::ty_path(_, _)) {}
+ case (ast::ty_type) {}
+ case (ast::ty_constr(?t, _)) { walk_ty(v, t); }
}
v.visit_ty_post(t);
}
-fn walk_native_mod(&ast_visitor v, &ast.native_mod nm) {
+fn walk_native_mod(&ast_visitor v, &ast::native_mod nm) {
if (!v.keep_going()) { ret; }
- for (@ast.view_item vi in nm.view_items) {
+ for (@ast::view_item vi in nm.view_items) {
walk_view_item(v, vi);
}
- for (@ast.native_item ni in nm.items) {
+ for (@ast::native_item ni in nm.items) {
walk_native_item(v, ni);
}
}
-fn walk_native_item(&ast_visitor v, @ast.native_item ni) {
+fn walk_native_item(&ast_visitor v, @ast::native_item ni) {
if (!v.keep_going()) { ret; }
v.visit_native_item_pre(ni);
alt (ni.node) {
- case (ast.native_item_fn(_, _, ?fd, _, _, _)) {
+ case (ast::native_item_fn(_, _, ?fd, _, _, _)) {
walk_fn_decl(v, fd);
}
- case (ast.native_item_ty(_, _)) {
+ case (ast::native_item_ty(_, _)) {
}
}
v.visit_native_item_post(ni);
}
-fn walk_fn_decl(&ast_visitor v, &ast.fn_decl fd) {
- for (ast.arg a in fd.inputs) {
+fn walk_fn_decl(&ast_visitor v, &ast::fn_decl fd) {
+ for (ast::arg a in fd.inputs) {
walk_ty(v, a.ty);
}
walk_ty(v, fd.output);
}
-fn walk_fn(&ast_visitor v, &ast._fn f) {
+fn walk_fn(&ast_visitor v, &ast::_fn f) {
if (!v.keep_going()) { ret; }
walk_fn_decl(v, f.decl);
walk_block(v, f.body);
}
-fn walk_block(&ast_visitor v, &ast.block b) {
+fn walk_block(&ast_visitor v, &ast::block b) {
if (!v.keep_going()) { ret; }
v.visit_block_pre(b);
- for (@ast.stmt s in b.node.stmts) {
+ for (@ast::stmt s in b.node.stmts) {
walk_stmt(v, s);
}
walk_expr_opt(v, b.node.expr);
v.visit_block_post(b);
}
-fn walk_stmt(&ast_visitor v, @ast.stmt s) {
+fn walk_stmt(&ast_visitor v, @ast::stmt s) {
if (!v.keep_going()) { ret; }
v.visit_stmt_pre(s);
alt (s.node) {
- case (ast.stmt_decl(?d, _)) {
+ case (ast::stmt_decl(?d, _)) {
walk_decl(v, d);
}
- case (ast.stmt_expr(?e, _)) {
+ case (ast::stmt_expr(?e, _)) {
walk_expr(v, e);
}
- case (ast.stmt_crate_directive(?cdir)) {
+ case (ast::stmt_crate_directive(?cdir)) {
walk_crate_directive(v, cdir);
}
}
v.visit_stmt_post(s);
}
-fn walk_decl(&ast_visitor v, @ast.decl d) {
+fn walk_decl(&ast_visitor v, @ast::decl d) {
if (!v.keep_going()) { ret; }
v.visit_decl_pre(d);
alt (d.node) {
- case (ast.decl_local(?loc)) {
+ case (ast::decl_local(?loc)) {
alt (loc.ty) {
- case (none[@ast.ty]) {}
- case (some[@ast.ty](?t)) { walk_ty(v, t); }
+ case (none[@ast::ty]) {}
+ case (some[@ast::ty](?t)) { walk_ty(v, t); }
}
alt (loc.init) {
- case (none[ast.initializer]) {}
- case (some[ast.initializer](?i)) {
+ case (none[ast::initializer]) {}
+ case (some[ast::initializer](?i)) {
walk_expr(v, i.expr);
}
}
}
- case (ast.decl_item(?it)) {
+ case (ast::decl_item(?it)) {
walk_item(v, it);
}
}
v.visit_decl_post(d);
}
-fn walk_expr_opt(&ast_visitor v, Option.t[@ast.expr] eo) {
+fn walk_expr_opt(&ast_visitor v, option::t[@ast::expr] eo) {
alt (eo) {
- case (none[@ast.expr]) {}
- case (some[@ast.expr](?e)) {
+ case (none[@ast::expr]) {}
+ case (some[@ast::expr](?e)) {
walk_expr(v, e);
}
}
}
-fn walk_exprs(&ast_visitor v, vec[@ast.expr] exprs) {
- for (@ast.expr e in exprs) {
+fn walk_exprs(&ast_visitor v, vec[@ast::expr] exprs) {
+ for (@ast::expr e in exprs) {
walk_expr(v, e);
}
}
-fn walk_expr(&ast_visitor v, @ast.expr e) {
+fn walk_expr(&ast_visitor v, @ast::expr e) {
if (!v.keep_going()) { ret; }
v.visit_expr_pre(e);
alt (e.node) {
- case (ast.expr_vec(?es, _, _)) {
+ case (ast::expr_vec(?es, _, _)) {
walk_exprs(v, es);
}
- case (ast.expr_tup(?elts, _)) {
- for (ast.elt e in elts) {
+ case (ast::expr_tup(?elts, _)) {
+ for (ast::elt e in elts) {
walk_expr(v, e.expr);
}
}
- case (ast.expr_rec(?flds, ?base, _)) {
- for (ast.field f in flds) {
+ case (ast::expr_rec(?flds, ?base, _)) {
+ for (ast::field f in flds) {
walk_expr(v, f.expr);
}
walk_expr_opt(v, base);
}
- case (ast.expr_call(?callee, ?args, _)) {
+ case (ast::expr_call(?callee, ?args, _)) {
walk_expr(v, callee);
walk_exprs(v, args);
}
- case (ast.expr_self_method(_, _)) { }
- case (ast.expr_bind(?callee, ?args, _)) {
+ case (ast::expr_self_method(_, _)) { }
+ case (ast::expr_bind(?callee, ?args, _)) {
walk_expr(v, callee);
- for (Option.t[@ast.expr] eo in args) {
+ for (option::t[@ast::expr] eo in args) {
walk_expr_opt(v, eo);
}
}
- case (ast.expr_spawn(_, _, ?callee, ?args, _)) {
+ case (ast::expr_spawn(_, _, ?callee, ?args, _)) {
walk_expr(v, callee);
walk_exprs(v, args);
}
- case (ast.expr_binary(_, ?a, ?b, _)) {
+ case (ast::expr_binary(_, ?a, ?b, _)) {
walk_expr(v, a);
walk_expr(v, b);
}
- case (ast.expr_unary(_, ?a, _)) {
+ case (ast::expr_unary(_, ?a, _)) {
walk_expr(v, a);
}
- case (ast.expr_lit(_, _)) { }
- case (ast.expr_cast(?x, ?t, _)) {
+ case (ast::expr_lit(_, _)) { }
+ case (ast::expr_cast(?x, ?t, _)) {
walk_expr(v, x);
walk_ty(v, t);
}
- case (ast.expr_if(?x, ?b, ?eo, _)) {
+ case (ast::expr_if(?x, ?b, ?eo, _)) {
walk_expr(v, x);
walk_block(v, b);
walk_expr_opt(v, eo);
}
- case (ast.expr_while(?x, ?b, _)) {
+ case (ast::expr_while(?x, ?b, _)) {
walk_expr(v, x);
walk_block(v, b);
}
- case (ast.expr_for(?dcl, ?x, ?b, _)) {
+ case (ast::expr_for(?dcl, ?x, ?b, _)) {
walk_decl(v, dcl);
walk_expr(v, x);
walk_block(v, b);
}
- case (ast.expr_for_each(?dcl, ?x, ?b, _)) {
+ case (ast::expr_for_each(?dcl, ?x, ?b, _)) {
walk_decl(v, dcl);
walk_expr(v, x);
walk_block(v, b);
}
- case (ast.expr_do_while(?b, ?x, _)) {
+ case (ast::expr_do_while(?b, ?x, _)) {
walk_block(v, b);
walk_expr(v, x);
}
- case (ast.expr_alt(?x, ?arms, _)) {
+ case (ast::expr_alt(?x, ?arms, _)) {
walk_expr(v, x);
- for (ast.arm a in arms) {
+ for (ast::arm a in arms) {
walk_block(v, a.block);
}
}
- case (ast.expr_block(?b, _)) {
+ case (ast::expr_block(?b, _)) {
walk_block(v, b);
}
- case (ast.expr_assign(?a, ?b, _)) {
+ case (ast::expr_assign(?a, ?b, _)) {
walk_expr(v, a);
walk_expr(v, b);
}
- case (ast.expr_assign_op(_, ?a, ?b, _)) {
+ case (ast::expr_assign_op(_, ?a, ?b, _)) {
walk_expr(v, a);
walk_expr(v, b);
}
- case (ast.expr_send(?a, ?b, _)) {
+ case (ast::expr_send(?a, ?b, _)) {
walk_expr(v, a);
walk_expr(v, b);
}
- case (ast.expr_recv(?a, ?b, _)) {
+ case (ast::expr_recv(?a, ?b, _)) {
walk_expr(v, a);
walk_expr(v, b);
}
- case (ast.expr_field(?x, _, _)) {
+ case (ast::expr_field(?x, _, _)) {
walk_expr(v, x);
}
- case (ast.expr_index(?a, ?b, _)) {
+ case (ast::expr_index(?a, ?b, _)) {
walk_expr(v, a);
walk_expr(v, b);
}
- case (ast.expr_path(_, _)) { }
- case (ast.expr_ext(_, ?args, ?body, ?expansion, _)) {
+ case (ast::expr_path(_, _)) { }
+ case (ast::expr_ext(_, ?args, ?body, ?expansion, _)) {
// Only walk expansion, not args/body.
walk_expr(v, expansion);
}
- case (ast.expr_fail(_)) { }
- case (ast.expr_break(_)) { }
- case (ast.expr_cont(_)) { }
- case (ast.expr_ret(?eo, _)) {
+ case (ast::expr_fail(_)) { }
+ case (ast::expr_break(_)) { }
+ case (ast::expr_cont(_)) { }
+ case (ast::expr_ret(?eo, _)) {
walk_expr_opt(v, eo);
}
- case (ast.expr_put(?eo, _)) {
+ case (ast::expr_put(?eo, _)) {
walk_expr_opt(v, eo);
}
- case (ast.expr_be(?x, _)) {
+ case (ast::expr_be(?x, _)) {
walk_expr(v, x);
}
- case (ast.expr_log(_,?x, _)) {
+ case (ast::expr_log(_,?x, _)) {
walk_expr(v, x);
}
- case (ast.expr_check(?x, _)) {
+ case (ast::expr_check(?x, _)) {
walk_expr(v, x);
}
- case (ast.expr_assert(?x, _)) {
+ case (ast::expr_assert(?x, _)) {
walk_expr(v, x);
}
- case (ast.expr_port(_)) { }
- case (ast.expr_chan(?x, _)) {
+ case (ast::expr_port(_)) { }
+ case (ast::expr_chan(?x, _)) {
walk_expr(v, x);
}
}
@@ -408,16 +408,16 @@ fn walk_expr(&ast_visitor v, @ast.expr e) {
fn def_keep_going() -> bool { ret true; }
fn def_want_crate_directives() -> bool { ret false; }
-fn def_visit_crate(&ast.crate c) { }
-fn def_visit_crate_directive(&@ast.crate_directive c) { }
-fn def_visit_view_item(&@ast.view_item vi) { }
-fn def_visit_native_item(&@ast.native_item ni) { }
-fn def_visit_item(&@ast.item i) { }
-fn def_visit_block(&ast.block b) { }
-fn def_visit_stmt(&@ast.stmt s) { }
-fn def_visit_decl(&@ast.decl d) { }
-fn def_visit_expr(&@ast.expr e) { }
-fn def_visit_ty(&@ast.ty t) { }
+fn def_visit_crate(&ast::crate c) { }
+fn def_visit_crate_directive(&@ast::crate_directive c) { }
+fn def_visit_view_item(&@ast::view_item vi) { }
+fn def_visit_native_item(&@ast::native_item ni) { }
+fn def_visit_item(&@ast::item i) { }
+fn def_visit_block(&ast::block b) { }
+fn def_visit_stmt(&@ast::stmt s) { }
+fn def_visit_decl(&@ast::decl d) { }
+fn def_visit_expr(&@ast::expr e) { }
+fn def_visit_ty(&@ast::ty t) { }
fn default_visitor() -> ast_visitor {