Store item paths in ast_map, get rid of trans::local_ctxt
The direct motivation for this was that the monomorphizer needs to be able to generate sane symbols for random items. The typechecker can probably also use this in the future to provide more useful error messages.
This commit is contained in:
parent
c1b075d042
commit
43ce38375d
18 changed files with 383 additions and 400 deletions
|
@ -49,7 +49,7 @@ fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option<str> {
|
|||
ast_map::node_item(@{
|
||||
ident: ident,
|
||||
node: ast::item_fn(decl, _, blk), _
|
||||
}) {
|
||||
}, _) {
|
||||
some(pprust::fun_to_str(decl, ident, []))
|
||||
}
|
||||
_ {
|
||||
|
@ -86,7 +86,7 @@ fn get_ret_ty(srv: astsrv::srv, fn_id: doc::ast_id) -> option<str> {
|
|||
alt ctxt.ast_map.get(fn_id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_fn(decl, _, _), _
|
||||
}) {
|
||||
}, _) {
|
||||
ret_ty_to_str(decl)
|
||||
}
|
||||
_ { fail "get_ret_ty: undocumented invariant"; }
|
||||
|
@ -136,10 +136,10 @@ fn get_arg_tys(srv: astsrv::srv, fn_id: doc::ast_id) -> [(str, str)] {
|
|||
alt ctxt.ast_map.get(fn_id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_fn(decl, _, _), _
|
||||
}) |
|
||||
}, _) |
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_res(decl, _, _, _, _), _
|
||||
}) {
|
||||
}, _) {
|
||||
decl_arg_tys(decl)
|
||||
}
|
||||
_ {
|
||||
|
@ -174,7 +174,7 @@ fn fold_const(
|
|||
alt ctxt.ast_map.get(doc.id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_const(ty, _), _
|
||||
}) {
|
||||
}, _) {
|
||||
pprust::ty_to_str(ty)
|
||||
}
|
||||
_ {
|
||||
|
@ -204,7 +204,7 @@ fn fold_enum(
|
|||
alt ctxt.ast_map.get(doc.id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_enum(ast_variants, _), _
|
||||
}) {
|
||||
}, _) {
|
||||
let ast_variant = option::get(
|
||||
vec::find(ast_variants) {|v|
|
||||
v.node.name == variant.name
|
||||
|
@ -243,7 +243,7 @@ fn fold_res(
|
|||
alt ctxt.ast_map.get(doc.id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_res(decl, _, _, _, _), _
|
||||
}) {
|
||||
}, _) {
|
||||
pprust::res_to_str(decl, doc.name, [])
|
||||
}
|
||||
_ { fail "fold_res: undocumented invariant"; }
|
||||
|
@ -324,7 +324,7 @@ fn get_method_ret_ty(
|
|||
alt ctxt.ast_map.get(item_id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_iface(_, methods), _
|
||||
}) {
|
||||
}, _) {
|
||||
alt vec::find(methods) {|method|
|
||||
method.ident == method_name
|
||||
} {
|
||||
|
@ -336,7 +336,7 @@ fn get_method_ret_ty(
|
|||
}
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_impl(_, _, _, methods), _
|
||||
}) {
|
||||
}, _) {
|
||||
alt vec::find(methods) {|method|
|
||||
method.ident == method_name
|
||||
} {
|
||||
|
@ -360,7 +360,7 @@ fn get_method_sig(
|
|||
alt ctxt.ast_map.get(item_id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_iface(_, methods), _
|
||||
}) {
|
||||
}, _) {
|
||||
alt vec::find(methods) {|method|
|
||||
method.ident == method_name
|
||||
} {
|
||||
|
@ -372,7 +372,7 @@ fn get_method_sig(
|
|||
}
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_impl(_, _, _, methods), _
|
||||
}) {
|
||||
}, _) {
|
||||
alt vec::find(methods) {|method|
|
||||
method.ident == method_name
|
||||
} {
|
||||
|
@ -412,7 +412,7 @@ fn get_method_arg_tys(
|
|||
alt ctxt.ast_map.get(item_id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_iface(_, methods), _
|
||||
}) {
|
||||
}, _) {
|
||||
alt vec::find(methods) {|method|
|
||||
method.ident == method_name
|
||||
} {
|
||||
|
@ -424,7 +424,7 @@ fn get_method_arg_tys(
|
|||
}
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_impl(_, _, _, methods), _
|
||||
}) {
|
||||
}, _) {
|
||||
alt vec::find(methods) {|method|
|
||||
method.ident == method_name
|
||||
} {
|
||||
|
@ -476,7 +476,7 @@ fn fold_impl(
|
|||
alt ctxt.ast_map.get(doc.id) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_impl(_, iface_ty, self_ty, _), _
|
||||
}) {
|
||||
}, _) {
|
||||
let iface_ty = option::map(iface_ty) {|iface_ty|
|
||||
pprust::ty_to_str(iface_ty)
|
||||
};
|
||||
|
@ -551,7 +551,7 @@ fn fold_type(
|
|||
ast_map::node_item(@{
|
||||
ident: ident,
|
||||
node: ast::item_ty(ty, params), _
|
||||
}) {
|
||||
}, _) {
|
||||
some(#fmt(
|
||||
"type %s%s = %s",
|
||||
ident,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue