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:
@@ -1,6 +1,7 @@
|
||||
import std::map;
|
||||
import std::map::hashmap;
|
||||
import syntax::ast::*;
|
||||
import syntax::print::pprust;
|
||||
import syntax::ast_util;
|
||||
import syntax::ast_util::inlined_item_methods;
|
||||
import syntax::{visit, codemap};
|
||||
@@ -20,6 +21,14 @@ fn path_to_str_with_sep(p: path, sep: str) -> str {
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
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:
|
||||
// mode: rust
|
||||
// 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 {
|
||||
alt smallintmap::find(*cx.node_types, id as uint) {
|
||||
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