Skip to content

Commit 0192e54

Browse files
committed
---
yaml --- r: 149103 b: refs/heads/try2 c: f7e5d84 h: refs/heads/master i: 149101: 6928890 149099: 81a315e 149095: d2dbeea 149087: 6602083 v: v3
1 parent f7be960 commit 0192e54

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0e005ab84892aa201f720cc60d2aef002bfd7a4a
8+
refs/heads/try2: f7e5d8418c0e6dcd17efc61f7f5eb641dce8653d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/ty.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use syntax::attr;
4545
use syntax::attr::AttrMetaMethods;
4646
use syntax::codemap::Span;
4747
use syntax::parse::token;
48+
use syntax::parse::token::InternedString;
4849
use syntax::{ast, ast_map};
4950
use syntax::opt_vec::OptVec;
5051
use syntax::opt_vec;
@@ -2668,8 +2669,13 @@ pub fn node_id_to_trait_ref(cx: ctxt, id: ast::NodeId) -> @ty::TraitRef {
26682669
}
26692670
}
26702671

2672+
pub fn try_node_id_to_type(cx: ctxt, id: ast::NodeId) -> Option<t> {
2673+
let node_types = cx.node_types.borrow();
2674+
node_types.get().find_copy(&(id as uint))
2675+
}
2676+
26712677
pub fn node_id_to_type(cx: ctxt, id: ast::NodeId) -> t {
2672-
match node_id_to_type_opt(cx, id) {
2678+
match try_node_id_to_type(cx, id) {
26732679
Some(t) => t,
26742680
None => cx.sess.bug(
26752681
format!("node_id_to_type: no type for node `{}`",
@@ -2883,6 +2889,45 @@ pub fn expr_ty_adjusted(cx: ctxt, expr: &ast::Expr) -> t {
28832889
adjust_ty(cx, expr.span, unadjusted_ty, adjustment)
28842890
}
28852891

2892+
pub fn expr_span(cx: ctxt, id: NodeId) -> Span {
2893+
match cx.items.find(id) {
2894+
Some(ast_map::NodeExpr(e)) => {
2895+
e.span
2896+
}
2897+
Some(f) => {
2898+
cx.sess.bug(format!("Node id {} is not an expr: {:?}",
2899+
id, f));
2900+
}
2901+
None => {
2902+
cx.sess.bug(format!("Node id {} is not present \
2903+
in the node map", id));
2904+
}
2905+
}
2906+
}
2907+
2908+
pub fn local_var_name_str(cx: ctxt, id: NodeId) -> InternedString {
2909+
match cx.items.find(id) {
2910+
Some(ast_map::NodeLocal(pat)) => {
2911+
match pat.node {
2912+
ast::PatIdent(_, ref path, _) => {
2913+
let ident = ast_util::path_to_ident(path);
2914+
token::get_ident(ident.name)
2915+
}
2916+
_ => {
2917+
cx.sess.bug(
2918+
format!("Variable id {} maps to {:?}, not local",
2919+
id, pat));
2920+
}
2921+
}
2922+
}
2923+
r => {
2924+
cx.sess.bug(
2925+
format!("Variable id {} maps to {:?}, not local",
2926+
id, r));
2927+
}
2928+
}
2929+
}
2930+
28862931
pub fn adjust_ty(cx: ctxt,
28872932
span: Span,
28882933
unadjusted_ty: ty::t,

0 commit comments

Comments
 (0)