refactor to store the types during inference in tables in the fcx
this is a step towards separating out the repr. of types during inference from the repr. in later stages.
This commit is contained in:
@@ -130,7 +130,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
|
|||||||
}
|
}
|
||||||
item_impl(tps, ifce, ty, methods) {
|
item_impl(tps, ifce, ty, methods) {
|
||||||
v.visit_ty_params(tps, e, v);
|
v.visit_ty_params(tps, e, v);
|
||||||
alt ifce { some(ty) { v.visit_ty(ty, e, v); } _ {} }
|
alt ifce { some(ty) { v.visit_ty(ty, e, v); } none {} }
|
||||||
v.visit_ty(ty, e, v);
|
v.visit_ty(ty, e, v);
|
||||||
for m in methods {
|
for m in methods {
|
||||||
visit_method_helper(m, e, v)
|
visit_method_helper(m, e, v)
|
||||||
@@ -193,7 +193,11 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
|
|||||||
v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v);
|
v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ {}
|
ty_nil |
|
||||||
|
ty_bot |
|
||||||
|
ty_mac(_) |
|
||||||
|
ty_infer {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +247,7 @@ fn visit_ty_params<E>(tps: [ty_param], e: E, v: vt<E>) {
|
|||||||
for bound in *tp.bounds {
|
for bound in *tp.bounds {
|
||||||
alt bound {
|
alt bound {
|
||||||
bound_iface(t) { v.visit_ty(t, e, v); }
|
bound_iface(t) { v.visit_ty(t, e, v); }
|
||||||
_ {}
|
bound_copy | bound_send { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import std::map;
|
import std::map;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import syntax::ast::*;
|
import syntax::ast::*;
|
||||||
|
import syntax::print::pprust;
|
||||||
import syntax::ast_util;
|
import syntax::ast_util;
|
||||||
import syntax::ast_util::inlined_item_methods;
|
import syntax::ast_util::inlined_item_methods;
|
||||||
import syntax::{visit, codemap};
|
import syntax::{visit, codemap};
|
||||||
@@ -20,6 +21,14 @@ fn path_to_str_with_sep(p: path, sep: str) -> str {
|
|||||||
str::connect(strs, sep)
|
str::connect(strs, sep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn path_ident_to_str(p: path, i: ident) -> str {
|
||||||
|
if vec::is_empty(p) {
|
||||||
|
i
|
||||||
|
} else {
|
||||||
|
#fmt["%s::%s", path_to_str(p), i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn path_to_str(p: path) -> str {
|
fn path_to_str(p: path) -> str {
|
||||||
path_to_str_with_sep(p, "::")
|
path_to_str_with_sep(p, "::")
|
||||||
}
|
}
|
||||||
@@ -224,6 +233,49 @@ fn map_expr(ex: @expr, cx: ctx, v: vt) {
|
|||||||
visit::visit_expr(ex, cx, v);
|
visit::visit_expr(ex, cx, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn node_id_to_str(map: map, id: node_id) -> str {
|
||||||
|
alt map.find(id) {
|
||||||
|
none {
|
||||||
|
#fmt["unknown node (id=%d)", id]
|
||||||
|
}
|
||||||
|
some(node_item(item, path)) {
|
||||||
|
#fmt["item %s (id=%?)", path_ident_to_str(*path, item.ident), id]
|
||||||
|
}
|
||||||
|
some(node_native_item(item, abi, path)) {
|
||||||
|
#fmt["native item %s with abi %? (id=%?)",
|
||||||
|
path_ident_to_str(*path, item.ident), abi, id]
|
||||||
|
}
|
||||||
|
some(node_method(m, impl_did, path)) {
|
||||||
|
#fmt["method %s in %s (id=%?)",
|
||||||
|
m.ident, path_to_str(*path), id]
|
||||||
|
}
|
||||||
|
some(node_variant(variant, def_id, path)) {
|
||||||
|
#fmt["variant %s in %s (id=%?)",
|
||||||
|
variant.node.name, path_to_str(*path), id]
|
||||||
|
}
|
||||||
|
some(node_expr(expr)) {
|
||||||
|
#fmt["expr %s (id=%?)",
|
||||||
|
pprust::expr_to_str(expr), id]
|
||||||
|
}
|
||||||
|
some(node_export(_, path)) {
|
||||||
|
#fmt["export %s (id=%?)", // FIXME: add more info here
|
||||||
|
path_to_str(*path), id]
|
||||||
|
}
|
||||||
|
some(node_arg(_, _)) { // FIXME: add more info here
|
||||||
|
#fmt["arg (id=%?)", id]
|
||||||
|
}
|
||||||
|
some(node_local(_)) { // FIXME: add more info here
|
||||||
|
#fmt["local (id=%?)", id]
|
||||||
|
}
|
||||||
|
some(node_ctor(_, _)) { // FIXME: add more info here
|
||||||
|
#fmt["node_ctor (id=%?)", id]
|
||||||
|
}
|
||||||
|
some(node_block(_)) {
|
||||||
|
#fmt["block"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: rust
|
// mode: rust
|
||||||
// fill-column: 78;
|
// fill-column: 78;
|
||||||
|
|||||||
@@ -1561,7 +1561,8 @@ fn constrs_eq(cs: [@constr], ds: [@constr]) -> bool {
|
|||||||
fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
||||||
alt smallintmap::find(*cx.node_types, id as uint) {
|
alt smallintmap::find(*cx.node_types, id as uint) {
|
||||||
some(t) { t }
|
some(t) { t }
|
||||||
none { cx.sess.bug(#fmt("node_id_to_type: unbound node ID %?", id)); }
|
none { cx.sess.bug(#fmt("node_id_to_type: unbound node ID %s",
|
||||||
|
ast_map::node_id_to_str(cx.items, id))); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user