-// Accessors
-
-impl block_ {
- pub fn ccx(&self) -> @mut CrateContext { self.fcx.ccx }
- pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx }
- pub fn sess(&self) -> Session { self.fcx.ccx.sess }
-
- pub fn ident(&self, ident: ident) -> @str {
- token::ident_to_str(&ident)
- }
-
- pub fn node_id_to_str(&self, id: ast::node_id) -> ~str {
- ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
- }
-
- pub fn expr_to_str(&self, e: @ast::expr) -> ~str {
- e.repr(self.tcx())
- }
-
- pub fn expr_is_lval(&self, e: &ast::expr) -> bool {
- ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e)
- }
-
- pub fn expr_kind(&self, e: &ast::expr) -> ty::ExprKind {
- ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e)
- }
-
- pub fn def(&self, nid: ast::node_id) -> ast::def {
- match self.tcx().def_map.find(&nid) {
- Some(&v) => v,
- None => {
- self.tcx().sess.bug(fmt!(
- "No def associated with node id %?", nid));
- }
- }
- }
-
- pub fn val_to_str(&self, val: ValueRef) -> ~str {
- self.ccx().tn.val_to_str(val)
- }
-
- pub fn llty_str(&self, ty: Type) -> ~str {
- self.ccx().tn.type_to_str(ty)
- }
-
- pub fn ty_to_str(&self, t: ty::t) -> ~str {
- t.repr(self.tcx())
- }
-
- pub fn to_str(&self) -> ~str {
- unsafe {
- match self.node_info {
- Some(node_info) => fmt!("[block %d]", node_info.id),
- None => fmt!("[block %x]", transmute(&*self)),
- }
- }
- }
-}