Remove what's left of resolve1

This commit is contained in:
Tim Chevalier 2012-07-17 15:23:59 -07:00
parent 1615afe704
commit beb2cd1658
15 changed files with 37 additions and 105 deletions

View file

@ -4,7 +4,7 @@ import session::{session, session_};
import syntax::parse; import syntax::parse;
import syntax::{ast, codemap}; import syntax::{ast, codemap};
import syntax::attr; import syntax::attr;
import middle::{trans, resolve, freevars, kind, ty, typeck, lint}; import middle::{trans, freevars, kind, ty, typeck, lint};
import syntax::print::{pp, pprust}; import syntax::print::{pp, pprust};
import util::ppaux; import util::ppaux;
import back::link; import back::link;

View file

@ -54,7 +54,7 @@ type maps = {
mutbl_map: middle::borrowck::mutbl_map, mutbl_map: middle::borrowck::mutbl_map,
root_map: middle::borrowck::root_map, root_map: middle::borrowck::root_map,
last_use_map: middle::liveness::last_use_map, last_use_map: middle::liveness::last_use_map,
impl_map: middle::resolve::impl_map, impl_map: middle::resolve3::ImplMap,
method_map: middle::typeck::method_map, method_map: middle::typeck::method_map,
vtable_map: middle::typeck::vtable_map, vtable_map: middle::typeck::vtable_map,
}; };

View file

@ -5,7 +5,7 @@ import std::map::hashmap;
import dvec::{dvec, extensions}; import dvec::{dvec, extensions};
fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map, fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map,
def_map: resolve::def_map, def_map: resolve3::DefMap,
method_map: typeck::method_map, tcx: ty::ctxt) { method_map: typeck::method_map, tcx: ty::ctxt) {
visit::visit_crate(*crate, false, visit::mk_vt(@{ visit::visit_crate(*crate, false, visit::mk_vt(@{
visit_item: |a,b,c| check_item(sess, ast_map, def_map, a, b, c), visit_item: |a,b,c| check_item(sess, ast_map, def_map, a, b, c),
@ -17,7 +17,8 @@ fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map,
sess.abort_if_errors(); sess.abort_if_errors();
} }
fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve::def_map, fn check_item(sess: session, ast_map: ast_map::map,
def_map: resolve3::DefMap,
it: @item, &&_is_const: bool, v: visit::vt<bool>) { it: @item, &&_is_const: bool, v: visit::vt<bool>) {
alt it.node { alt it.node {
item_const(_, ex) { item_const(_, ex) {
@ -54,7 +55,7 @@ fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
} }
} }
fn check_expr(sess: session, def_map: resolve::def_map, fn check_expr(sess: session, def_map: resolve3::DefMap,
method_map: typeck::method_map, tcx: ty::ctxt, method_map: typeck::method_map, tcx: ty::ctxt,
e: @expr, &&is_const: bool, v: visit::vt<bool>) { e: @expr, &&is_const: bool, v: visit::vt<bool>) {
if is_const { if is_const {
@ -130,13 +131,13 @@ fn check_expr(sess: session, def_map: resolve::def_map,
// Make sure a const item doesn't recursively refer to itself // Make sure a const item doesn't recursively refer to itself
// FIXME: Should use the dependency graph when it's available (#1356) // FIXME: Should use the dependency graph when it's available (#1356)
fn check_item_recursion(sess: session, ast_map: ast_map::map, fn check_item_recursion(sess: session, ast_map: ast_map::map,
def_map: resolve::def_map, it: @item) { def_map: resolve3::DefMap, it: @item) {
type env = { type env = {
root_it: @item, root_it: @item,
sess: session, sess: session,
ast_map: ast_map::map, ast_map: ast_map::map,
def_map: resolve::def_map, def_map: resolve3::DefMap,
idstack: @dvec<node_id>, idstack: @dvec<node_id>,
}; };

View file

@ -6,7 +6,6 @@ import std::map::*;
import option::*; import option::*;
import syntax::{ast, ast_util, visit}; import syntax::{ast, ast_util, visit};
import syntax::ast::{serialize_span, deserialize_span}; import syntax::ast::{serialize_span, deserialize_span};
import middle::resolve;
import syntax::codemap::span; import syntax::codemap::span;
export annotate_freevars; export annotate_freevars;
@ -31,7 +30,7 @@ type freevar_map = hashmap<ast::node_id, freevar_info>;
// Since we want to be able to collect upvars in some arbitrary piece // Since we want to be able to collect upvars in some arbitrary piece
// of the AST, we take a walker function that we invoke with a visitor // of the AST, we take a walker function that we invoke with a visitor
// in order to start the search. // in order to start the search.
fn collect_freevars(def_map: resolve::def_map, blk: ast::blk) fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk)
-> freevar_info { -> freevar_info {
let seen = int_hash(); let seen = int_hash();
let refs = @mut ~[]; let refs = @mut ~[];
@ -86,7 +85,7 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk)
// efficient as it fully recomputes the free variables at every // efficient as it fully recomputes the free variables at every
// node of interest rather than building up the free variables in // node of interest rather than building up the free variables in
// one pass. This could be improved upon if it turns out to matter. // one pass. This could be improved upon if it turns out to matter.
fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) -> fn annotate_freevars(def_map: resolve3::DefMap, crate: @ast::crate) ->
freevar_map { freevar_map {
let freevars = int_hash(); let freevars = int_hash();

View file

@ -13,7 +13,7 @@ type pat_id_map = std::map::hashmap<ident, node_id>;
// This is used because same-named variables in alternative patterns need to // This is used because same-named variables in alternative patterns need to
// use the node_id of their namesake in the first pattern. // use the node_id of their namesake in the first pattern.
fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map { fn pat_id_map(dm: resolve3::DefMap, pat: @pat) -> pat_id_map {
let map = std::map::box_str_hash(); let map = std::map::box_str_hash();
do pat_bindings(dm, pat) |p_id, _s, n| { do pat_bindings(dm, pat) |p_id, _s, n| {
map.insert(path_to_ident(n), p_id); map.insert(path_to_ident(n), p_id);
@ -21,7 +21,7 @@ fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map {
ret map; ret map;
} }
fn pat_is_variant(dm: resolve::def_map, pat: @pat) -> bool { fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool {
alt pat.node { alt pat.node {
pat_enum(_, _) { true } pat_enum(_, _) { true }
pat_ident(_, none) { pat_ident(_, none) {
@ -34,7 +34,7 @@ fn pat_is_variant(dm: resolve::def_map, pat: @pat) -> bool {
} }
} }
fn pat_bindings(dm: resolve::def_map, pat: @pat, fn pat_bindings(dm: resolve3::DefMap, pat: @pat,
it: fn(node_id, span, @path)) { it: fn(node_id, span, @path)) {
do walk_pat(pat) |p| { do walk_pat(pat) |p| {
alt p.node { alt p.node {
@ -46,7 +46,7 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat,
} }
} }
fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> ~[node_id] { fn pat_binding_ids(dm: resolve3::DefMap, pat: @pat) -> ~[node_id] {
let mut found = ~[]; let mut found = ~[];
pat_bindings(dm, pat, |b_id, _sp, _pt| vec::push(found, b_id) ); pat_bindings(dm, pat, |b_id, _sp, _pt| vec::push(found, b_id) );
ret found; ret found;

View file

@ -161,7 +161,7 @@ type region_map = hashmap<ast::node_id, ast::node_id>;
type ctxt = { type ctxt = {
sess: session, sess: session,
def_map: resolve::def_map, def_map: resolve3::DefMap,
region_map: region_map, region_map: region_map,
// The parent scope is the innermost block, call, or alt // The parent scope is the innermost block, call, or alt
@ -384,8 +384,8 @@ fn resolve_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
visit::visit_fn(fk, decl, body, sp, id, fn_cx, visitor); visit::visit_fn(fk, decl, body, sp, id, fn_cx, visitor);
} }
fn resolve_crate(sess: session, def_map: resolve::def_map, crate: @ast::crate) fn resolve_crate(sess: session, def_map: resolve3::DefMap,
-> region_map { crate: @ast::crate) -> region_map {
let cx: ctxt = {sess: sess, let cx: ctxt = {sess: sess,
def_map: def_map, def_map: def_map,
region_map: int_hash(), region_map: int_hash(),
@ -429,7 +429,7 @@ type dep_map = hashmap<ast::node_id, @dvec<ast::node_id>>;
type determine_rp_ctxt_ = { type determine_rp_ctxt_ = {
sess: session, sess: session,
ast_map: ast_map::map, ast_map: ast_map::map,
def_map: resolve::def_map, def_map: resolve3::DefMap,
region_paramd_items: region_paramd_items, region_paramd_items: region_paramd_items,
dep_map: dep_map, dep_map: dep_map,
worklist: dvec<ast::node_id>, worklist: dvec<ast::node_id>,
@ -610,7 +610,7 @@ fn determine_rp_in_ty(ty: @ast::ty,
fn determine_rp_in_crate(sess: session, fn determine_rp_in_crate(sess: session,
ast_map: ast_map::map, ast_map: ast_map::map,
def_map: resolve::def_map, def_map: resolve3::DefMap,
crate: @ast::crate) -> region_paramd_items { crate: @ast::crate) -> region_paramd_items {
let cx = determine_rp_ctxt_(@{sess: sess, let cx = determine_rp_ctxt_(@{sess: sess,
ast_map: ast_map, ast_map: ast_map,

View file

@ -1,67 +0,0 @@
import syntax::{ast, ast_util, codemap, ast_map};
import syntax::ast::*;
import ast::{ident, fn_ident, def, def_id, node_id};
import ast::{required, provided};
import syntax::ast_util::{local_def, def_id_of_def, new_def_hash,
class_item_ident, path_to_ident};
import pat_util::*;
import syntax::attr;
import metadata::{csearch, cstore};
import driver::session::session;
import util::common::is_main_name;
import std::map::{int_hash, str_hash, box_str_hash, hashmap};
import vec::each;
import syntax::codemap::span;
import syntax::visit;
import visit::vt;
import std::{list};
import std::list::{list, nil, cons};
import option::{is_none, is_some};
import syntax::print::pprust::*;
import dvec::{dvec, extensions};
export resolve_crate;
export def_map, ext_map, exp_map, impl_map;
export _impl, iscopes, method_info;
// 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,
// and then uses this information to resolve the imports. The second pass
// locates all names (in expressions, types, and alt patterns) and resolves
// them, storing the resulting def in the AST nodes.
/* foreign modules can't contain enums, and we don't store their ASTs because
we only need to look at them to determine exports, which they can't
control.*/
type def_map = hashmap<node_id, def>;
type ext_map = hashmap<def_id, ~[ident]>;
type impl_map = hashmap<node_id, iscopes>;
type impl_cache = hashmap<def_id, option<@~[@_impl]>>;
// Impl resolution
type method_info = {did: def_id, n_tps: uint, ident: ast::ident};
/* An _impl represents an implementation that's currently in scope.
Its fields:
* did: the def id of the class or impl item
* ident: the name of the impl, unless it has no name (as in
"impl of X") in which case the ident
is the ident of the trait that's being implemented
* methods: the item's methods
*/
type _impl = {did: def_id, ident: ast::ident, methods: ~[@method_info]};
type iscopes = @list<@~[@_impl]>;
type exp = {reexp: bool, id: def_id};
type exp_map = hashmap<node_id, ~[exp]>;
// Local Variables:
// mode: rust
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End:

View file

@ -10,7 +10,7 @@ import syntax::ast_util::{dummy_sp, path_to_ident};
import syntax::ast::def_id; import syntax::ast::def_id;
import syntax::codemap::span; import syntax::codemap::span;
import syntax::print::pprust::pat_to_str; import syntax::print::pprust::pat_to_str;
import middle::resolve::def_map; import middle::resolve3::DefMap;
import back::abi; import back::abi;
import std::map::hashmap; import std::map::hashmap;
import dvec::{dvec, extensions}; import dvec::{dvec, extensions};
@ -130,7 +130,7 @@ fn expand_nested_bindings(m: match, col: uint, val: ValueRef) -> match {
type enter_pat = fn(@ast::pat) -> option<~[@ast::pat]>; type enter_pat = fn(@ast::pat) -> option<~[@ast::pat]>;
fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef, fn enter_match(dm: DefMap, m: match, col: uint, val: ValueRef,
e: enter_pat) -> match { e: enter_pat) -> match {
let mut result = ~[]; let mut result = ~[];
for vec::each(m) |br| { for vec::each(m) |br| {
@ -157,7 +157,7 @@ fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef,
ret result; ret result;
} }
fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match { fn enter_default(dm: DefMap, m: match, col: uint, val: ValueRef) -> match {
do enter_match(dm, m, col, val) |p| { do enter_match(dm, m, col, val) |p| {
alt p.node { alt p.node {
ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some(~[]) } ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some(~[]) }
@ -195,7 +195,7 @@ fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint,
} }
} }
fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident], fn enter_rec(dm: DefMap, m: match, col: uint, fields: ~[ast::ident],
val: ValueRef) -> match { val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(dm, m, col, val) |p| { do enter_match(dm, m, col, val) |p| {
@ -216,7 +216,7 @@ fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident],
} }
} }
fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef, fn enter_tup(dm: DefMap, m: match, col: uint, val: ValueRef,
n_elts: uint) -> match { n_elts: uint) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(dm, m, col, val) |p| { do enter_match(dm, m, col, val) |p| {
@ -227,7 +227,7 @@ fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef,
} }
} }
fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match { fn enter_box(dm: DefMap, m: match, col: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(dm, m, col, val) |p| { do enter_match(dm, m, col, val) |p| {
alt p.node { alt p.node {
@ -237,7 +237,7 @@ fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
} }
} }
fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match { fn enter_uniq(dm: DefMap, m: match, col: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
do enter_match(dm, m, col, val) |p| { do enter_match(dm, m, col, val) |p| {
alt p.node { alt p.node {

View file

@ -5450,7 +5450,7 @@ fn write_abi_version(ccx: @crate_ctxt) {
} }
fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
output: ~str, emap: resolve::exp_map, output: ~str, emap: resolve3::ExportMap,
maps: astencode::maps) maps: astencode::maps)
-> (ModuleRef, link_meta) { -> (ModuleRef, link_meta) {
let sha = std::sha1::sha1(); let sha = std::sha1::sha1();

View file

@ -9,7 +9,7 @@ import std::map::{hashmap,set};
import syntax::{ast, ast_map}; import syntax::{ast, ast_map};
import driver::session; import driver::session;
import session::session; import session::session;
import middle::{resolve, ty}; import middle::ty;
import back::{link, abi, upcall}; import back::{link, abi, upcall};
import syntax::codemap::span; import syntax::codemap::span;
import lib::llvm::{llvm, target_data, type_names, associate_type, import lib::llvm::{llvm, target_data, type_names, associate_type,
@ -87,7 +87,7 @@ type crate_ctxt = {
externs: hashmap<~str, ValueRef>, externs: hashmap<~str, ValueRef>,
intrinsics: hashmap<~str, ValueRef>, intrinsics: hashmap<~str, ValueRef>,
item_vals: hashmap<ast::node_id, ValueRef>, item_vals: hashmap<ast::node_id, ValueRef>,
exp_map: resolve::exp_map, exp_map: resolve3::ExportMap,
reachable: reachable::map, reachable: reachable::map,
item_symbols: hashmap<ast::node_id, ~str>, item_symbols: hashmap<ast::node_id, ~str>,
mut main_fn: option<ValueRef>, mut main_fn: option<ValueRef>,

View file

@ -17,12 +17,12 @@ export map, find_reachable;
type map = std::map::hashmap<node_id, ()>; type map = std::map::hashmap<node_id, ()>;
type ctx = {exp_map: resolve::exp_map, type ctx = {exp_map: resolve3::ExportMap,
tcx: ty::ctxt, tcx: ty::ctxt,
method_map: typeck::method_map, method_map: typeck::method_map,
rmap: map}; rmap: map};
fn find_reachable(crate_mod: _mod, exp_map: resolve::exp_map, fn find_reachable(crate_mod: _mod, exp_map: resolve3::ExportMap,
tcx: ty::ctxt, method_map: typeck::method_map) -> map { tcx: ty::ctxt, method_map: typeck::method_map) -> map {
let rmap = std::map::int_hash(); let rmap = std::map::int_hash();
let cx = {exp_map: exp_map, tcx: tcx, method_map: method_map, rmap: rmap}; let cx = {exp_map: exp_map, tcx: tcx, method_map: method_map, rmap: rmap};

View file

@ -224,7 +224,7 @@ type ctxt =
vecs_implicitly_copyable: bool, vecs_implicitly_copyable: bool,
cstore: metadata::cstore::cstore, cstore: metadata::cstore::cstore,
sess: session::session, sess: session::session,
def_map: resolve::def_map, def_map: resolve3::DefMap,
region_map: middle::region::region_map, region_map: middle::region::region_map,
region_paramd_items: middle::region::region_paramd_items, region_paramd_items: middle::region::region_paramd_items,
@ -502,7 +502,7 @@ fn new_ty_hash<V: copy>() -> map::hashmap<t, V> {
} }
fn mk_ctxt(s: session::session, fn mk_ctxt(s: session::session,
dm: resolve::def_map, dm: resolve3::DefMap,
amap: ast_map::map, amap: ast_map::map,
freevars: freevars::freevar_map, freevars: freevars::freevar_map,
region_map: middle::region::region_map, region_map: middle::region::region_map,

View file

@ -154,7 +154,7 @@ type ty_param_substs_and_ty = {substs: ty::substs, ty: ty::t};
type ty_table = hashmap<ast::def_id, ty::t>; type ty_table = hashmap<ast::def_id, ty::t>;
type crate_ctxt_ = {impl_map: resolve::impl_map, type crate_ctxt_ = {impl_map: resolve3::ImplMap,
trait_map: resolve3::TraitMap, trait_map: resolve3::TraitMap,
method_map: method_map, method_map: method_map,
vtable_map: vtable_map, vtable_map: vtable_map,
@ -291,7 +291,7 @@ fn check_for_main_fn(ccx: @crate_ctxt) {
} }
fn check_crate(tcx: ty::ctxt, fn check_crate(tcx: ty::ctxt,
impl_map: resolve::impl_map, impl_map: resolve3::ImplMap,
trait_map: resolve3::TraitMap, trait_map: resolve3::TraitMap,
crate: @ast::crate) crate: @ast::crate)
-> (method_map, vtable_map) { -> (method_map, vtable_map) {

View file

@ -10,7 +10,7 @@ fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
}) })
} }
fn lookup_vtables(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, fn lookup_vtables(fcx: @fn_ctxt, isc: resolve3::ImplScopes, sp: span,
bounds: @~[ty::param_bounds], substs: ty::substs, bounds: @~[ty::param_bounds], substs: ty::substs,
allow_unsafe: bool) -> vtable_res { allow_unsafe: bool) -> vtable_res {
let tcx = fcx.ccx.tcx; let tcx = fcx.ccx.tcx;
@ -53,7 +53,7 @@ as if it has type <trait_ty>
XXX: This doesn't use the coherence tables yet. XXX: This doesn't use the coherence tables yet.
*/ */
fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, fn lookup_vtable(fcx: @fn_ctxt, isc: resolve3::ImplScopes, sp: span,
ty: ty::t, trait_ty: ty::t, allow_unsafe: bool) ty: ty::t, trait_ty: ty::t, allow_unsafe: bool)
-> vtable_origin { -> vtable_origin {

View file

@ -51,7 +51,6 @@ mod middle {
mod reachable; mod reachable;
} }
mod ty; mod ty;
mod resolve;
mod resolve3; mod resolve3;
mod typeck { mod typeck {
mod check { mod check {