Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149103
b: refs/heads/try2
c: f7e5d84
h: refs/heads/master
i:
  149101: 6928890
  149099: 81a315e
  149095: d2dbeea
  149087: 6602083
v: v3
  • Loading branch information
nikomatsakis committed Feb 11, 2014
1 parent f7be960 commit 0192e54
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
refs/heads/try2: 0e005ab84892aa201f720cc60d2aef002bfd7a4a
refs/heads/try2: f7e5d8418c0e6dcd17efc61f7f5eb641dce8653d
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Expand Down
47 changes: 46 additions & 1 deletion branches/try2/src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::parse::token::InternedString;
use syntax::{ast, ast_map};
use syntax::opt_vec::OptVec;
use syntax::opt_vec;
Expand Down Expand Up @@ -2668,8 +2669,13 @@ pub fn node_id_to_trait_ref(cx: ctxt, id: ast::NodeId) -> @ty::TraitRef {
}
}

pub fn try_node_id_to_type(cx: ctxt, id: ast::NodeId) -> Option<t> {
let node_types = cx.node_types.borrow();
node_types.get().find_copy(&(id as uint))
}

pub fn node_id_to_type(cx: ctxt, id: ast::NodeId) -> t {
match node_id_to_type_opt(cx, id) {
match try_node_id_to_type(cx, id) {
Some(t) => t,
None => cx.sess.bug(
format!("node_id_to_type: no type for node `{}`",
Expand Down Expand Up @@ -2883,6 +2889,45 @@ pub fn expr_ty_adjusted(cx: ctxt, expr: &ast::Expr) -> t {
adjust_ty(cx, expr.span, unadjusted_ty, adjustment)
}

pub fn expr_span(cx: ctxt, id: NodeId) -> Span {
match cx.items.find(id) {
Some(ast_map::NodeExpr(e)) => {
e.span
}
Some(f) => {
cx.sess.bug(format!("Node id {} is not an expr: {:?}",
id, f));
}
None => {
cx.sess.bug(format!("Node id {} is not present \
in the node map", id));
}
}
}

pub fn local_var_name_str(cx: ctxt, id: NodeId) -> InternedString {
match cx.items.find(id) {
Some(ast_map::NodeLocal(pat)) => {
match pat.node {
ast::PatIdent(_, ref path, _) => {
let ident = ast_util::path_to_ident(path);
token::get_ident(ident.name)
}
_ => {
cx.sess.bug(
format!("Variable id {} maps to {:?}, not local",
id, pat));
}
}
}
r => {
cx.sess.bug(
format!("Variable id {} maps to {:?}, not local",
id, r));
}
}
}

pub fn adjust_ty(cx: ctxt,
span: Span,
unadjusted_ty: ty::t,
Expand Down

0 comments on commit 0192e54

Please sign in to comment.