Add an intital HIR and lowering step
This commit is contained in:
parent
cfd76b364c
commit
facdf2ebb1
160 changed files with 13917 additions and 4451 deletions
|
|
@ -25,7 +25,7 @@ use metadata::loader::METADATA_FILENAME;
|
|||
use metadata::{encoder, cstore, filesearch, csearch, creader};
|
||||
use middle::dependency_format::Linkage;
|
||||
use middle::ty::{self, Ty};
|
||||
use rustc::ast_map::{PathElem, PathElems, PathName};
|
||||
use rustc::front::map::{PathElem, PathElems, PathName};
|
||||
use trans::{CrateContext, CrateTranslation, gensym_name};
|
||||
use util::common::time;
|
||||
use util::sha2::{Digest, Sha256};
|
||||
|
|
@ -43,9 +43,12 @@ use std::str;
|
|||
use flate;
|
||||
use serialize::hex::ToHex;
|
||||
use syntax::ast;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use rustc_front::attr::AttrMetaMethods as FrontAttrMetaMethods;
|
||||
|
||||
use rustc_front::hir;
|
||||
|
||||
// RLIB LLVM-BYTECODE OBJECT LAYOUT
|
||||
// Version 1
|
||||
|
|
@ -178,7 +181,7 @@ pub fn find_crate_name(sess: Option<&Session>,
|
|||
"rust_out".to_string()
|
||||
}
|
||||
|
||||
pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
|
||||
pub fn build_link_meta(sess: &Session, krate: &hir::Crate,
|
||||
name: String) -> LinkMeta {
|
||||
let r = LinkMeta {
|
||||
crate_name: name,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ extern crate graphviz;
|
|||
extern crate libc;
|
||||
extern crate rustc;
|
||||
extern crate rustc_back;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_llvm as llvm;
|
||||
extern crate rustc_platform_intrinsics as intrinsics;
|
||||
extern crate serialize;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ use syntax::visit::{self, Visitor};
|
|||
use syntax::print::pprust::{path_to_string, ty_to_string};
|
||||
use syntax::ptr::P;
|
||||
|
||||
use rustc_front::lowering::lower_expr;
|
||||
|
||||
use super::span_utils::SpanUtils;
|
||||
use super::recorder::{Recorder, FmtStrs};
|
||||
|
||||
|
|
@ -1074,8 +1076,9 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
visit::walk_expr(self, ex);
|
||||
}
|
||||
ast::ExprStruct(ref path, ref fields, ref base) => {
|
||||
let adt = self.tcx.expr_ty(ex).ty_adt_def().unwrap();
|
||||
let def = self.tcx.resolve_expr(ex);
|
||||
let hir_expr = lower_expr(ex);
|
||||
let adt = self.tcx.expr_ty(&hir_expr).ty_adt_def().unwrap();
|
||||
let def = self.tcx.resolve_expr(&hir_expr);
|
||||
self.process_struct_lit(ex,
|
||||
path,
|
||||
fields,
|
||||
|
|
@ -1106,7 +1109,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
|
||||
self.visit_expr(&**sub_ex);
|
||||
|
||||
let ty = &self.tcx.expr_ty_adjusted(&**sub_ex).sty;
|
||||
let hir_node = self.tcx.map.expect_expr(sub_ex.id);
|
||||
let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty;
|
||||
match *ty {
|
||||
ty::TyStruct(def, _) => {
|
||||
let sub_span = self.span.sub_span_after_token(ex.span, token::Dot);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ use std::env;
|
|||
use std::fs::{self, File};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rustc::ast_map::NodeItem;
|
||||
use rustc_front;
|
||||
use rustc::front::map::NodeItem;
|
||||
use rustc_front::hir;
|
||||
|
||||
use syntax::{attr};
|
||||
use syntax::attr;
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::*;
|
||||
|
|
@ -356,9 +358,9 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
Some(impl_id) => match self.tcx.map.get(impl_id.node) {
|
||||
NodeItem(item) => {
|
||||
match item.node {
|
||||
ast::ItemImpl(_, _, _, _, ref ty, _) => {
|
||||
hir::ItemImpl(_, _, _, _, ref ty, _) => {
|
||||
let mut result = String::from("<");
|
||||
result.push_str(&ty_to_string(&**ty));
|
||||
result.push_str(&rustc_front::print::pprust::ty_to_string(&**ty));
|
||||
|
||||
match self.tcx.trait_of_item(DefId::local(id)) {
|
||||
Some(def_id) => {
|
||||
|
|
@ -446,7 +448,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
|
||||
match expr.node {
|
||||
ast::ExprField(ref sub_ex, ident) => {
|
||||
let ty = &self.tcx.expr_ty_adjusted(&sub_ex).sty;
|
||||
let hir_node = self.tcx.map.expect_expr(sub_ex.id);
|
||||
let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty;
|
||||
match *ty {
|
||||
ty::TyStruct(def, _) => {
|
||||
let f = def.struct_variant().field_named(ident.node.name);
|
||||
|
|
@ -465,7 +468,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
ast::ExprStruct(ref path, _, _) => {
|
||||
let ty = &self.tcx.expr_ty_adjusted(expr).sty;
|
||||
let hir_node = self.tcx.map.expect_expr(expr.id);
|
||||
let ty = &self.tcx.expr_ty_adjusted(hir_node).sty;
|
||||
match *ty {
|
||||
ty::TyStruct(def, _) => {
|
||||
let sub_span = self.span_utils.span_for_last_ident(path.span);
|
||||
|
|
@ -605,7 +609,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
|
||||
let trait_item = self.tcx.map.expect_trait_item(def_id.node);
|
||||
if let ast::TraitItem_::MethodTraitItem(_, Some(_)) = trait_item.node {
|
||||
if let hir::TraitItem_::MethodTraitItem(_, Some(_)) = trait_item.node {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
|
@ -705,9 +709,9 @@ impl<'v> Visitor<'v> for PathCollector {
|
|||
}
|
||||
|
||||
pub fn process_crate(tcx: &ty::ctxt,
|
||||
krate: &ast::Crate,
|
||||
analysis: &ty::CrateAnalysis,
|
||||
odir: Option<&Path>) {
|
||||
let krate = tcx.map.krate();
|
||||
if generated_code(krate.span) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,14 +224,14 @@ use std;
|
|||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{DUMMY_NODE_ID, NodeId};
|
||||
use rustc_front::hir;
|
||||
use syntax::ast::{self, DUMMY_NODE_ID, NodeId};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::fold::Folder;
|
||||
use rustc_front::fold::Folder;
|
||||
use syntax::ptr::P;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct ConstantExpr<'a>(&'a ast::Expr);
|
||||
struct ConstantExpr<'a>(&'a hir::Expr);
|
||||
|
||||
impl<'a> ConstantExpr<'a> {
|
||||
fn eq(self, other: ConstantExpr<'a>, tcx: &ty::ctxt) -> bool {
|
||||
|
|
@ -379,7 +379,7 @@ type BindingsMap<'tcx> = FnvHashMap<ast::Ident, BindingInfo<'tcx>>;
|
|||
|
||||
struct ArmData<'p, 'blk, 'tcx: 'blk> {
|
||||
bodycx: Block<'blk, 'tcx>,
|
||||
arm: &'p ast::Arm,
|
||||
arm: &'p hir::Arm,
|
||||
bindings_map: BindingsMap<'tcx>
|
||||
}
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ struct ArmData<'p, 'blk, 'tcx: 'blk> {
|
|||
/// As we proceed `bound_ptrs` are filled with pointers to values to be bound,
|
||||
/// these pointers are stored in llmatch variables just before executing `data` arm.
|
||||
struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
|
||||
pats: Vec<&'p ast::Pat>,
|
||||
pats: Vec<&'p hir::Pat>,
|
||||
data: &'a ArmData<'p, 'blk, 'tcx>,
|
||||
bound_ptrs: Vec<(ast::Ident, ValueRef)>,
|
||||
// Thread along renamings done by the check_match::StaticInliner, so we can
|
||||
|
|
@ -410,7 +410,7 @@ impl<'a, 'p, 'blk, 'tcx> fmt::Debug for Match<'a, 'p, 'blk, 'tcx> {
|
|||
fn has_nested_bindings(m: &[Match], col: usize) -> bool {
|
||||
for br in m {
|
||||
match br.pats[col].node {
|
||||
ast::PatIdent(_, _, Some(_)) => return true,
|
||||
hir::PatIdent(_, _, Some(_)) => return true,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let mut pat = br.pats[col];
|
||||
loop {
|
||||
pat = match pat.node {
|
||||
ast::PatIdent(_, ref path, Some(ref inner)) => {
|
||||
hir::PatIdent(_, ref path, Some(ref inner)) => {
|
||||
bound_ptrs.push((path.node, val.val));
|
||||
&**inner
|
||||
},
|
||||
|
|
@ -489,7 +489,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
val: MatchInput,
|
||||
mut e: F)
|
||||
-> Vec<Match<'a, 'p, 'blk, 'tcx>> where
|
||||
F: FnMut(&[&'p ast::Pat]) -> Option<Vec<&'p ast::Pat>>,
|
||||
F: FnMut(&[&'p hir::Pat]) -> Option<Vec<&'p hir::Pat>>,
|
||||
{
|
||||
debug!("enter_match(bcx={}, m={:?}, col={}, val={})",
|
||||
bcx.to_str(),
|
||||
|
|
@ -503,13 +503,13 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
let this = br.pats[col];
|
||||
let mut bound_ptrs = br.bound_ptrs.clone();
|
||||
match this.node {
|
||||
ast::PatIdent(_, ref path, None) => {
|
||||
hir::PatIdent(_, ref path, None) => {
|
||||
if pat_is_binding(dm, &*this) {
|
||||
bound_ptrs.push((path.node, val.val));
|
||||
}
|
||||
}
|
||||
ast::PatVec(ref before, Some(ref slice), ref after) => {
|
||||
if let ast::PatIdent(_, ref path, None) = slice.node {
|
||||
hir::PatVec(ref before, Some(ref slice), ref after) => {
|
||||
if let hir::PatIdent(_, ref path, None) = slice.node {
|
||||
let subslice_val = bind_subslice_pat(
|
||||
bcx, this.id, val,
|
||||
before.len(), after.len());
|
||||
|
|
@ -648,10 +648,10 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
};
|
||||
|
||||
let opt = match cur.node {
|
||||
ast::PatLit(ref l) => {
|
||||
hir::PatLit(ref l) => {
|
||||
ConstantValue(ConstantExpr(&**l), debug_loc)
|
||||
}
|
||||
ast::PatIdent(..) | ast::PatEnum(..) | ast::PatStruct(..) => {
|
||||
hir::PatIdent(..) | hir::PatEnum(..) | hir::PatStruct(..) => {
|
||||
// This is either an enum variant or a variable binding.
|
||||
let opt_def = tcx.def_map.borrow().get(&cur.id).map(|d| d.full_def());
|
||||
match opt_def {
|
||||
|
|
@ -665,13 +665,13 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
_ => continue
|
||||
}
|
||||
}
|
||||
ast::PatRange(ref l1, ref l2) => {
|
||||
hir::PatRange(ref l1, ref l2) => {
|
||||
ConstantRange(ConstantExpr(&**l1), ConstantExpr(&**l2), debug_loc)
|
||||
}
|
||||
ast::PatVec(ref before, None, ref after) => {
|
||||
hir::PatVec(ref before, None, ref after) => {
|
||||
SliceLengthEqual(before.len() + after.len(), debug_loc)
|
||||
}
|
||||
ast::PatVec(ref before, Some(_), ref after) => {
|
||||
hir::PatVec(ref before, Some(_), ref after) => {
|
||||
SliceLengthGreaterOrEqual(before.len(), after.len(), debug_loc)
|
||||
}
|
||||
_ => continue
|
||||
|
|
@ -770,25 +770,25 @@ macro_rules! any_pat {
|
|||
}
|
||||
|
||||
fn any_uniq_pat(m: &[Match], col: usize) -> bool {
|
||||
any_pat!(m, col, ast::PatBox(_))
|
||||
any_pat!(m, col, hir::PatBox(_))
|
||||
}
|
||||
|
||||
fn any_region_pat(m: &[Match], col: usize) -> bool {
|
||||
any_pat!(m, col, ast::PatRegion(..))
|
||||
any_pat!(m, col, hir::PatRegion(..))
|
||||
}
|
||||
|
||||
fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: usize) -> bool {
|
||||
m.iter().any(|br| {
|
||||
let pat = br.pats[col];
|
||||
match pat.node {
|
||||
ast::PatTup(_) => true,
|
||||
ast::PatStruct(..) => {
|
||||
hir::PatTup(_) => true,
|
||||
hir::PatStruct(..) => {
|
||||
match tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def()) {
|
||||
Some(def::DefVariant(..)) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
ast::PatEnum(..) | ast::PatIdent(_, _, None) => {
|
||||
hir::PatEnum(..) | hir::PatIdent(_, _, None) => {
|
||||
match tcx.def_map.borrow().get(&pat.id).map(|d| d.full_def()) {
|
||||
Some(def::DefStruct(..)) => true,
|
||||
_ => false
|
||||
|
|
@ -831,9 +831,9 @@ impl FailureHandler {
|
|||
}
|
||||
|
||||
fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<usize> {
|
||||
fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> usize {
|
||||
fn pat_score(def_map: &DefMap, pat: &hir::Pat) -> usize {
|
||||
match pat.node {
|
||||
ast::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &**inner),
|
||||
hir::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &**inner),
|
||||
_ if pat_is_refutable(def_map, pat) => 1,
|
||||
_ => 0
|
||||
}
|
||||
|
|
@ -855,7 +855,7 @@ fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<usize> {
|
|||
|
||||
let column_contains_any_nonwild_patterns = |&col: &usize| -> bool {
|
||||
m.iter().any(|row| match row.pats[col].node {
|
||||
ast::PatWild(_) => false,
|
||||
hir::PatWild(_) => false,
|
||||
_ => true
|
||||
})
|
||||
};
|
||||
|
|
@ -891,7 +891,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
|
||||
let _icx = push_ctxt("compare_values");
|
||||
if rhs_t.is_scalar() {
|
||||
let cmp = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq, debug_loc);
|
||||
let cmp = compare_scalar_types(cx, lhs, rhs, rhs_t, hir::BiEq, debug_loc);
|
||||
return Result::new(cx, cmp);
|
||||
}
|
||||
|
||||
|
|
@ -905,7 +905,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
|
||||
}
|
||||
ty::TyArray(ty, _) | ty::TySlice(ty) => match ty.sty {
|
||||
ty::TyUint(ast::TyU8) => {
|
||||
ty::TyUint(hir::TyU8) => {
|
||||
// NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
|
||||
// which calls memcmp().
|
||||
let pat_len = val_ty(rhs).element_type().array_length();
|
||||
|
|
@ -1027,7 +1027,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
guard_expr: &ast::Expr,
|
||||
guard_expr: &hir::Expr,
|
||||
data: &ArmData<'p, 'blk, 'tcx>,
|
||||
m: &[Match<'a, 'p, 'blk, 'tcx>],
|
||||
vals: &[MatchInput],
|
||||
|
|
@ -1324,14 +1324,14 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
RangeResult(Result { val: vbegin, .. },
|
||||
Result { bcx, val: vend }) => {
|
||||
let llge = compare_scalar_types(bcx, test_val, vbegin,
|
||||
t, ast::BiGe, debug_loc);
|
||||
t, hir::BiGe, debug_loc);
|
||||
let llle = compare_scalar_types(bcx, test_val, vend,
|
||||
t, ast::BiLe, debug_loc);
|
||||
t, hir::BiLe, debug_loc);
|
||||
Result::new(bcx, And(bcx, llge, llle, DebugLoc::None))
|
||||
}
|
||||
LowerBound(Result { bcx, val }) => {
|
||||
Result::new(bcx, compare_scalar_types(bcx, test_val,
|
||||
val, t, ast::BiGe,
|
||||
val, t, hir::BiGe,
|
||||
debug_loc))
|
||||
}
|
||||
}
|
||||
|
|
@ -1415,9 +1415,9 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
match_expr: &ast::Expr,
|
||||
discr_expr: &ast::Expr,
|
||||
arms: &[ast::Arm],
|
||||
match_expr: &hir::Expr,
|
||||
discr_expr: &hir::Expr,
|
||||
arms: &[hir::Arm],
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("match::trans_match");
|
||||
|
|
@ -1425,20 +1425,20 @@ pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
/// Checks whether the binding in `discr` is assigned to anywhere in the expression `body`
|
||||
fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool {
|
||||
fn is_discr_reassigned(bcx: Block, discr: &hir::Expr, body: &hir::Expr) -> bool {
|
||||
let (vid, field) = match discr.node {
|
||||
ast::ExprPath(..) => match bcx.def(discr.id) {
|
||||
hir::ExprPath(..) => match bcx.def(discr.id) {
|
||||
def::DefLocal(vid) | def::DefUpvar(vid, _) => (vid, None),
|
||||
_ => return false
|
||||
},
|
||||
ast::ExprField(ref base, field) => {
|
||||
hir::ExprField(ref base, field) => {
|
||||
let vid = match bcx.tcx().def_map.borrow().get(&base.id).map(|d| d.full_def()) {
|
||||
Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _)) => vid,
|
||||
_ => return false
|
||||
};
|
||||
(vid, Some(mc::NamedField(field.node.name)))
|
||||
},
|
||||
ast::ExprTupField(ref base, field) => {
|
||||
hir::ExprTupField(ref base, field) => {
|
||||
let vid = match bcx.tcx().def_map.borrow().get(&base.id).map(|d| d.full_def()) {
|
||||
Some(def::DefLocal(vid)) | Some(def::DefUpvar(vid, _)) => vid,
|
||||
_ => return false
|
||||
|
|
@ -1473,8 +1473,8 @@ struct ReassignmentChecker {
|
|||
// for cases where the matched value is moved.
|
||||
impl<'tcx> euv::Delegate<'tcx> for ReassignmentChecker {
|
||||
fn consume(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: euv::ConsumeMode) {}
|
||||
fn matched_pat(&mut self, _: &ast::Pat, _: mc::cmt, _: euv::MatchMode) {}
|
||||
fn consume_pat(&mut self, _: &ast::Pat, _: mc::cmt, _: euv::ConsumeMode) {}
|
||||
fn matched_pat(&mut self, _: &hir::Pat, _: mc::cmt, _: euv::MatchMode) {}
|
||||
fn consume_pat(&mut self, _: &hir::Pat, _: mc::cmt, _: euv::ConsumeMode) {}
|
||||
fn borrow(&mut self, _: ast::NodeId, _: Span, _: mc::cmt, _: ty::Region,
|
||||
_: ty::BorrowKind, _: euv::LoanCause) {}
|
||||
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
|
||||
|
|
@ -1498,8 +1498,8 @@ impl<'tcx> euv::Delegate<'tcx> for ReassignmentChecker {
|
|||
}
|
||||
}
|
||||
|
||||
fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
||||
discr: &ast::Expr, body: &ast::Expr)
|
||||
fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &hir::Pat,
|
||||
discr: &hir::Expr, body: &hir::Expr)
|
||||
-> BindingsMap<'tcx> {
|
||||
// Create the bindings map, which is a mapping from each binding name
|
||||
// to an alloca() that will be the value for that local variable.
|
||||
|
|
@ -1521,7 +1521,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||
let trmode;
|
||||
let moves_by_default = variable_ty.moves_by_default(¶m_env, span);
|
||||
match bm {
|
||||
ast::BindByValue(_) if !moves_by_default || reassigned =>
|
||||
hir::BindByValue(_) if !moves_by_default || reassigned =>
|
||||
{
|
||||
llmatch = alloca(bcx, llvariable_ty.ptr_to(), "__llmatch");
|
||||
let llcopy = alloca(bcx, llvariable_ty, &bcx.name(name));
|
||||
|
|
@ -1531,14 +1531,14 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||
TrByCopy(llcopy)
|
||||
};
|
||||
}
|
||||
ast::BindByValue(_) => {
|
||||
hir::BindByValue(_) => {
|
||||
// in this case, the final type of the variable will be T,
|
||||
// but during matching we need to store a *T as explained
|
||||
// above
|
||||
llmatch = alloca(bcx, llvariable_ty.ptr_to(), &bcx.name(name));
|
||||
trmode = TrByMoveRef;
|
||||
}
|
||||
ast::BindByRef(_) => {
|
||||
hir::BindByRef(_) => {
|
||||
llmatch = alloca(bcx, llvariable_ty, &bcx.name(name));
|
||||
trmode = TrByRef;
|
||||
}
|
||||
|
|
@ -1556,8 +1556,8 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||
|
||||
fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
||||
match_id: ast::NodeId,
|
||||
discr_expr: &ast::Expr,
|
||||
arms: &[ast::Arm],
|
||||
discr_expr: &hir::Expr,
|
||||
arms: &[hir::Arm],
|
||||
dest: Dest) -> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("match::trans_match_inner");
|
||||
let fcx = scope_cx.fcx;
|
||||
|
|
@ -1589,7 +1589,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
|||
None
|
||||
};
|
||||
|
||||
let arm_pats: Vec<Vec<P<ast::Pat>>> = {
|
||||
let arm_pats: Vec<Vec<P<hir::Pat>>> = {
|
||||
let mut static_inliner = StaticInliner::new(scope_cx.tcx(),
|
||||
pat_renaming_map.as_mut());
|
||||
arm_datas.iter().map(|arm_data| {
|
||||
|
|
@ -1615,7 +1615,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
|||
// to the default arm.
|
||||
let has_default = arms.last().map_or(false, |arm| {
|
||||
arm.pats.len() == 1
|
||||
&& arm.pats.last().unwrap().node == ast::PatWild(ast::PatWildSingle)
|
||||
&& arm.pats.last().unwrap().node == hir::PatWild(hir::PatWildSingle)
|
||||
});
|
||||
|
||||
compile_submatch(bcx, &matches[..], &[discr_datum.match_input()], &chk, has_default);
|
||||
|
|
@ -1639,7 +1639,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
|||
/// Generates code for a local variable declaration like `let <pat>;` or `let <pat> =
|
||||
/// <opt_init_expr>`.
|
||||
pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
local: &ast::Local)
|
||||
local: &hir::Local)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("match::store_local");
|
||||
let mut bcx = bcx;
|
||||
|
|
@ -1647,7 +1647,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let pat = &*local.pat;
|
||||
|
||||
fn create_dummy_locals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
pat: &ast::Pat)
|
||||
pat: &hir::Pat)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("create_dummy_locals");
|
||||
// create dummy memory for the variables if we have no
|
||||
|
|
@ -1764,7 +1764,7 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
|
|||
/// - pat: the irrefutable pattern being matched.
|
||||
/// - val: the value being matched -- must be an lvalue (by ref, with cleanup)
|
||||
pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
pat: &ast::Pat,
|
||||
pat: &hir::Pat,
|
||||
val: MatchInput,
|
||||
cleanup_scope: cleanup::ScopeId)
|
||||
-> Block<'blk, 'tcx> {
|
||||
|
|
@ -1784,7 +1784,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let tcx = bcx.tcx();
|
||||
let ccx = bcx.ccx();
|
||||
match pat.node {
|
||||
ast::PatIdent(pat_binding_mode, ref path1, ref inner) => {
|
||||
hir::PatIdent(pat_binding_mode, ref path1, ref inner) => {
|
||||
if pat_is_binding(&tcx.def_map, &*pat) {
|
||||
// Allocate the stack slot where the value of this
|
||||
// binding will live and place it into the appropriate
|
||||
|
|
@ -1794,14 +1794,14 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
"_match::bind_irrefutable_pat",
|
||||
|(), bcx, Datum { val: llval, ty, kind: _ }| {
|
||||
match pat_binding_mode {
|
||||
ast::BindByValue(_) => {
|
||||
hir::BindByValue(_) => {
|
||||
// By value binding: move the value that `val`
|
||||
// points at into the binding's stack slot.
|
||||
let d = val.to_datum(ty);
|
||||
d.store_to(bcx, llval)
|
||||
}
|
||||
|
||||
ast::BindByRef(_) => {
|
||||
hir::BindByRef(_) => {
|
||||
// By ref binding: the value of the variable
|
||||
// is the pointer `val` itself or fat pointer referenced by `val`
|
||||
if type_is_fat_ptr(bcx.tcx(), ty) {
|
||||
|
|
@ -1821,7 +1821,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
bcx = bind_irrefutable_pat(bcx, &**inner_pat, val, cleanup_scope);
|
||||
}
|
||||
}
|
||||
ast::PatEnum(_, ref sub_pats) => {
|
||||
hir::PatEnum(_, ref sub_pats) => {
|
||||
let opt_def = bcx.tcx().def_map.borrow().get(&pat.id).map(|d| d.full_def());
|
||||
match opt_def {
|
||||
Some(def::DefVariant(enum_id, var_id, _)) => {
|
||||
|
|
@ -1866,7 +1866,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::PatStruct(_, ref fields, _) => {
|
||||
hir::PatStruct(_, ref fields, _) => {
|
||||
let tcx = bcx.tcx();
|
||||
let pat_ty = node_id_type(bcx, pat.id);
|
||||
let pat_repr = adt::represent_type(bcx.ccx(), pat_ty);
|
||||
|
|
@ -1885,7 +1885,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
cleanup_scope);
|
||||
}
|
||||
}
|
||||
ast::PatTup(ref elems) => {
|
||||
hir::PatTup(ref elems) => {
|
||||
let repr = adt::represent_node(bcx, pat.id);
|
||||
for (i, elem) in elems.iter().enumerate() {
|
||||
let fldptr = adt::trans_field_ptr(bcx, &*repr, val.val, 0, i);
|
||||
|
|
@ -1896,12 +1896,12 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
cleanup_scope);
|
||||
}
|
||||
}
|
||||
ast::PatBox(ref inner) => {
|
||||
hir::PatBox(ref inner) => {
|
||||
let llbox = Load(bcx, val.val);
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx, &**inner, MatchInput::from_val(llbox), cleanup_scope);
|
||||
}
|
||||
ast::PatRegion(ref inner, _) => {
|
||||
hir::PatRegion(ref inner, _) => {
|
||||
let loaded_val = Load(bcx, val.val);
|
||||
bcx = bind_irrefutable_pat(
|
||||
bcx,
|
||||
|
|
@ -1909,7 +1909,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
MatchInput::from_val(loaded_val),
|
||||
cleanup_scope);
|
||||
}
|
||||
ast::PatVec(ref before, ref slice, ref after) => {
|
||||
hir::PatVec(ref before, ref slice, ref after) => {
|
||||
let pat_ty = node_id_type(bcx, pat.id);
|
||||
let mut extracted = extract_vec_elems(bcx, pat_ty, before.len(), after.len(), val);
|
||||
match slice {
|
||||
|
|
@ -1934,11 +1934,8 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
cleanup_scope)
|
||||
});
|
||||
}
|
||||
ast::PatMac(..) => {
|
||||
bcx.sess().span_bug(pat.span, "unexpanded macro");
|
||||
}
|
||||
ast::PatQPath(..) | ast::PatWild(_) | ast::PatLit(_) |
|
||||
ast::PatRange(_, _) => ()
|
||||
hir::PatQPath(..) | hir::PatWild(_) | hir::PatLit(_) |
|
||||
hir::PatRange(_, _) => ()
|
||||
}
|
||||
return bcx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,9 @@ use middle::subst;
|
|||
use middle::ty::{self, Ty};
|
||||
use middle::ty::Disr;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::attr::IntType;
|
||||
use rustc_front::attr;
|
||||
use rustc_front::attr::IntType;
|
||||
use rustc_front::hir;
|
||||
use trans::_match;
|
||||
use trans::build::*;
|
||||
use trans::cleanup;
|
||||
|
|
@ -386,11 +387,11 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let ity = if use_align {
|
||||
// Use the overall alignment
|
||||
match align {
|
||||
1 => attr::UnsignedInt(ast::TyU8),
|
||||
2 => attr::UnsignedInt(ast::TyU16),
|
||||
4 => attr::UnsignedInt(ast::TyU32),
|
||||
1 => attr::UnsignedInt(hir::TyU8),
|
||||
2 => attr::UnsignedInt(hir::TyU16),
|
||||
4 => attr::UnsignedInt(hir::TyU32),
|
||||
8 if machine::llalign_of_min(cx, Type::i64(cx)) == 8 =>
|
||||
attr::UnsignedInt(ast::TyU64),
|
||||
attr::UnsignedInt(hir::TyU64),
|
||||
_ => min_ity // use min_ity as a fallback
|
||||
}
|
||||
} else {
|
||||
|
|
@ -582,12 +583,12 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
|||
// Lists of sizes to try. u64 is always allowed as a fallback.
|
||||
#[allow(non_upper_case_globals)]
|
||||
const choose_shortest: &'static [IntType] = &[
|
||||
attr::UnsignedInt(ast::TyU8), attr::SignedInt(ast::TyI8),
|
||||
attr::UnsignedInt(ast::TyU16), attr::SignedInt(ast::TyI16),
|
||||
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
|
||||
attr::UnsignedInt(hir::TyU8), attr::SignedInt(hir::TyI8),
|
||||
attr::UnsignedInt(hir::TyU16), attr::SignedInt(hir::TyI16),
|
||||
attr::UnsignedInt(hir::TyU32), attr::SignedInt(hir::TyI32)];
|
||||
#[allow(non_upper_case_globals)]
|
||||
const at_least_32: &'static [IntType] = &[
|
||||
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
|
||||
attr::UnsignedInt(hir::TyU32), attr::SignedInt(hir::TyI32)];
|
||||
|
||||
let attempts;
|
||||
match hint {
|
||||
|
|
@ -621,7 +622,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
|
|||
return ity;
|
||||
}
|
||||
}
|
||||
return attr::UnsignedInt(ast::TyU64);
|
||||
return attr::UnsignedInt(hir::TyU64);
|
||||
}
|
||||
|
||||
pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use trans::expr;
|
|||
use trans::type_of;
|
||||
use trans::type_::Type;
|
||||
|
||||
use syntax::ast;
|
||||
use rustc_front::hir as ast;
|
||||
use std::ffi::CString;
|
||||
use libc::{c_uint, c_char};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use middle::ty;
|
|||
use middle::infer;
|
||||
use session::config::NoDebugInfo;
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
pub use syntax::attr::InlineAttr;
|
||||
use rustc_front::hir;
|
||||
pub use rustc_front::attr::InlineAttr;
|
||||
use trans::base;
|
||||
use trans::common;
|
||||
use trans::context::CrateContext;
|
||||
|
|
@ -91,8 +91,8 @@ pub fn set_optimize_for_size(val: ValueRef, optimize: bool) {
|
|||
|
||||
/// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
|
||||
/// attributes.
|
||||
pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRef) {
|
||||
use syntax::attr::*;
|
||||
pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[hir::Attribute], llfn: ValueRef) {
|
||||
use rustc_front::attr::*;
|
||||
inline(llfn, find_inline_attr(Some(ccx.sess().diagnostic()), attrs));
|
||||
|
||||
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
|
||||
|
|
@ -262,11 +262,11 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
|
|||
// on memory dependencies rather than pointer equality
|
||||
let interior_unsafe = mt.ty.type_contents(ccx.tcx()).interior_unsafe();
|
||||
|
||||
if mt.mutbl == ast::MutMutable || !interior_unsafe {
|
||||
if mt.mutbl == hir::MutMutable || !interior_unsafe {
|
||||
attrs.arg(idx, llvm::Attribute::NoAlias);
|
||||
}
|
||||
|
||||
if mt.mutbl == ast::MutImmutable && !interior_unsafe {
|
||||
if mt.mutbl == hir::MutImmutable && !interior_unsafe {
|
||||
attrs.arg(idx, llvm::Attribute::ReadOnly);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ use middle::weak_lang_items;
|
|||
use middle::pat_util::simple_identifier;
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::{self, Ty, HasTypeFlags};
|
||||
use rustc::ast_map;
|
||||
use rustc::front::map as hir_map;
|
||||
use session::config::{self, NoDebugInfo, FullDebugInfo};
|
||||
use session::Session;
|
||||
use trans::_match;
|
||||
|
|
@ -93,13 +93,15 @@ use std::mem;
|
|||
use std::str;
|
||||
use std::{i8, i16, i32, i64};
|
||||
use syntax::abi::{Rust, RustCall, RustIntrinsic, PlatformIntrinsic, Abi};
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::visit::Visitor;
|
||||
use syntax::visit;
|
||||
use syntax::{ast, ast_util};
|
||||
use rustc_front;
|
||||
use rustc_front::attr::AttrMetaMethods;
|
||||
use rustc_front::attr;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::hir;
|
||||
use syntax::ast;
|
||||
|
||||
thread_local! {
|
||||
static TASK_LOCAL_INSN_KEY: RefCell<Option<Vec<&'static str>>> = {
|
||||
|
|
@ -277,15 +279,15 @@ pub fn malloc_raw_dyn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
|
||||
pub fn bin_op_to_icmp_predicate(ccx: &CrateContext, op: ast::BinOp_, signed: bool)
|
||||
pub fn bin_op_to_icmp_predicate(ccx: &CrateContext, op: hir::BinOp_, signed: bool)
|
||||
-> llvm::IntPredicate {
|
||||
match op {
|
||||
ast::BiEq => llvm::IntEQ,
|
||||
ast::BiNe => llvm::IntNE,
|
||||
ast::BiLt => if signed { llvm::IntSLT } else { llvm::IntULT },
|
||||
ast::BiLe => if signed { llvm::IntSLE } else { llvm::IntULE },
|
||||
ast::BiGt => if signed { llvm::IntSGT } else { llvm::IntUGT },
|
||||
ast::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE },
|
||||
hir::BiEq => llvm::IntEQ,
|
||||
hir::BiNe => llvm::IntNE,
|
||||
hir::BiLt => if signed { llvm::IntSLT } else { llvm::IntULT },
|
||||
hir::BiLe => if signed { llvm::IntSLE } else { llvm::IntULE },
|
||||
hir::BiGt => if signed { llvm::IntSGT } else { llvm::IntUGT },
|
||||
hir::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE },
|
||||
op => {
|
||||
ccx.sess().bug(&format!("comparison_op_to_icmp_predicate: expected \
|
||||
comparison operator, found {:?}", op));
|
||||
|
|
@ -293,15 +295,15 @@ pub fn bin_op_to_icmp_predicate(ccx: &CrateContext, op: ast::BinOp_, signed: boo
|
|||
}
|
||||
}
|
||||
|
||||
pub fn bin_op_to_fcmp_predicate(ccx: &CrateContext, op: ast::BinOp_)
|
||||
pub fn bin_op_to_fcmp_predicate(ccx: &CrateContext, op: hir::BinOp_)
|
||||
-> llvm::RealPredicate {
|
||||
match op {
|
||||
ast::BiEq => llvm::RealOEQ,
|
||||
ast::BiNe => llvm::RealUNE,
|
||||
ast::BiLt => llvm::RealOLT,
|
||||
ast::BiLe => llvm::RealOLE,
|
||||
ast::BiGt => llvm::RealOGT,
|
||||
ast::BiGe => llvm::RealOGE,
|
||||
hir::BiEq => llvm::RealOEQ,
|
||||
hir::BiNe => llvm::RealUNE,
|
||||
hir::BiLt => llvm::RealOLT,
|
||||
hir::BiLe => llvm::RealOLE,
|
||||
hir::BiGt => llvm::RealOGT,
|
||||
hir::BiGe => llvm::RealOGE,
|
||||
op => {
|
||||
ccx.sess().bug(&format!("comparison_op_to_fcmp_predicate: expected \
|
||||
comparison operator, found {:?}", op));
|
||||
|
|
@ -313,7 +315,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
lhs: ValueRef,
|
||||
rhs: ValueRef,
|
||||
t: Ty<'tcx>,
|
||||
op: ast::BinOp_,
|
||||
op: hir::BinOp_,
|
||||
debug_loc: DebugLoc)
|
||||
-> ValueRef {
|
||||
match t.sty {
|
||||
|
|
@ -321,8 +323,8 @@ pub fn compare_scalar_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// We don't need to do actual comparisons for nil.
|
||||
// () == () holds but () < () does not.
|
||||
match op {
|
||||
ast::BiEq | ast::BiLe | ast::BiGe => return C_bool(bcx.ccx(), true),
|
||||
ast::BiNe | ast::BiLt | ast::BiGt => return C_bool(bcx.ccx(), false),
|
||||
hir::BiEq | hir::BiLe | hir::BiGe => return C_bool(bcx.ccx(), true),
|
||||
hir::BiNe | hir::BiLt | hir::BiGt => return C_bool(bcx.ccx(), false),
|
||||
// refinements would be nice
|
||||
_ => bcx.sess().bug("compare_scalar_types: must be a comparison operator")
|
||||
}
|
||||
|
|
@ -349,7 +351,7 @@ pub fn compare_simd_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
rhs: ValueRef,
|
||||
t: Ty<'tcx>,
|
||||
ret_ty: Type,
|
||||
op: ast::BinOp_,
|
||||
op: hir::BinOp_,
|
||||
debug_loc: DebugLoc)
|
||||
-> ValueRef {
|
||||
let signed = match t.sty {
|
||||
|
|
@ -526,7 +528,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn cast_shift_expr_rhs(cx: Block,
|
||||
op: ast::BinOp_,
|
||||
op: hir::BinOp_,
|
||||
lhs: ValueRef,
|
||||
rhs: ValueRef)
|
||||
-> ValueRef {
|
||||
|
|
@ -535,14 +537,14 @@ pub fn cast_shift_expr_rhs(cx: Block,
|
|||
|a,b| ZExt(cx, a, b))
|
||||
}
|
||||
|
||||
pub fn cast_shift_const_rhs(op: ast::BinOp_,
|
||||
pub fn cast_shift_const_rhs(op: hir::BinOp_,
|
||||
lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||
cast_shift_rhs(op, lhs, rhs,
|
||||
|a, b| unsafe { llvm::LLVMConstTrunc(a, b.to_ref()) },
|
||||
|a, b| unsafe { llvm::LLVMConstZExt(a, b.to_ref()) })
|
||||
}
|
||||
|
||||
fn cast_shift_rhs<F, G>(op: ast::BinOp_,
|
||||
fn cast_shift_rhs<F, G>(op: hir::BinOp_,
|
||||
lhs: ValueRef,
|
||||
rhs: ValueRef,
|
||||
trunc: F,
|
||||
|
|
@ -552,7 +554,7 @@ fn cast_shift_rhs<F, G>(op: ast::BinOp_,
|
|||
G: FnOnce(ValueRef, Type) -> ValueRef,
|
||||
{
|
||||
// Shifts may have any size int on the rhs
|
||||
if ast_util::is_shift_binop(op) {
|
||||
if rustc_front::util::is_shift_binop(op) {
|
||||
let mut rhs_llty = val_ty(rhs);
|
||||
let mut lhs_llty = val_ty(lhs);
|
||||
if rhs_llty.kind() == Vector { rhs_llty = rhs_llty.element_type() }
|
||||
|
|
@ -579,12 +581,12 @@ pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
ty::TyInt(t) => {
|
||||
let llty = Type::int_from_ty(cx.ccx(), t);
|
||||
let min = match t {
|
||||
ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
|
||||
ast::TyIs => i64::MIN as u64,
|
||||
ast::TyI8 => i8::MIN as u64,
|
||||
ast::TyI16 => i16::MIN as u64,
|
||||
ast::TyI32 => i32::MIN as u64,
|
||||
ast::TyI64 => i64::MIN as u64,
|
||||
hir::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
|
||||
hir::TyIs => i64::MIN as u64,
|
||||
hir::TyI8 => i8::MIN as u64,
|
||||
hir::TyI16 => i16::MIN as u64,
|
||||
hir::TyI32 => i32::MIN as u64,
|
||||
hir::TyI64 => i64::MIN as u64,
|
||||
};
|
||||
(llty, min)
|
||||
}
|
||||
|
|
@ -595,12 +597,12 @@ pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
|
||||
cx: Block<'blk, 'tcx>,
|
||||
call_info: NodeIdAndSpan,
|
||||
divrem: ast::BinOp,
|
||||
divrem: hir::BinOp,
|
||||
lhs: ValueRef,
|
||||
rhs: ValueRef,
|
||||
rhs_t: Ty<'tcx>)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let (zero_text, overflow_text) = if divrem.node == ast::BiDiv {
|
||||
let (zero_text, overflow_text) = if divrem.node == hir::BiDiv {
|
||||
("attempted to divide by zero",
|
||||
"attempted to divide with overflow")
|
||||
} else {
|
||||
|
|
@ -871,7 +873,7 @@ pub fn to_arg_ty_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef, ty: Ty<'
|
|||
}
|
||||
}
|
||||
|
||||
pub fn init_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, local: &ast::Local)
|
||||
pub fn init_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, local: &hir::Local)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("init_local(bcx={}, local.id={})", bcx.to_str(), local.id);
|
||||
let _indenter = indenter();
|
||||
|
|
@ -1086,9 +1088,9 @@ impl FindNestedReturn {
|
|||
}
|
||||
|
||||
impl<'v> Visitor<'v> for FindNestedReturn {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
fn visit_expr(&mut self, e: &hir::Expr) {
|
||||
match e.node {
|
||||
ast::ExprRet(..) => {
|
||||
hir::ExprRet(..) => {
|
||||
self.found = true;
|
||||
}
|
||||
_ => visit::walk_expr(self, e)
|
||||
|
|
@ -1098,40 +1100,40 @@ impl<'v> Visitor<'v> for FindNestedReturn {
|
|||
|
||||
fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
|
||||
let blk = match tcx.map.find(id) {
|
||||
Some(ast_map::NodeItem(i)) => {
|
||||
Some(hir_map::NodeItem(i)) => {
|
||||
match i.node {
|
||||
ast::ItemFn(_, _, _, _, _, ref blk) => {
|
||||
hir::ItemFn(_, _, _, _, _, ref blk) => {
|
||||
blk
|
||||
}
|
||||
_ => tcx.sess.bug("unexpected item variant in has_nested_returns")
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeTraitItem(trait_item)) => {
|
||||
Some(hir_map::NodeTraitItem(trait_item)) => {
|
||||
match trait_item.node {
|
||||
ast::MethodTraitItem(_, Some(ref body)) => body,
|
||||
hir::MethodTraitItem(_, Some(ref body)) => body,
|
||||
_ => {
|
||||
tcx.sess.bug("unexpected variant: trait item other than a \
|
||||
provided method in has_nested_returns")
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeImplItem(impl_item)) => {
|
||||
Some(hir_map::NodeImplItem(impl_item)) => {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(_, ref body) => body,
|
||||
hir::MethodImplItem(_, ref body) => body,
|
||||
_ => {
|
||||
tcx.sess.bug("unexpected variant: non-method impl item in \
|
||||
has_nested_returns")
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeExpr(e)) => {
|
||||
Some(hir_map::NodeExpr(e)) => {
|
||||
match e.node {
|
||||
ast::ExprClosure(_, _, ref blk) => blk,
|
||||
hir::ExprClosure(_, _, ref blk) => blk,
|
||||
_ => tcx.sess.bug("unexpected expr variant in has_nested_returns")
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeVariant(..)) |
|
||||
Some(ast_map::NodeStructCtor(..)) => return (ast::DUMMY_NODE_ID, None),
|
||||
Some(hir_map::NodeVariant(..)) |
|
||||
Some(hir_map::NodeStructCtor(..)) => return (ast::DUMMY_NODE_ID, None),
|
||||
|
||||
// glue, shims, etc
|
||||
None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None),
|
||||
|
|
@ -1157,8 +1159,8 @@ fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bo
|
|||
for index in cfg.graph.depth_traverse(cfg.entry) {
|
||||
let n = cfg.graph.node_data(index);
|
||||
match tcx.map.find(n.id()) {
|
||||
Some(ast_map::NodeExpr(ex)) => {
|
||||
if let ast::ExprRet(Some(ref ret_expr)) = ex.node {
|
||||
Some(hir_map::NodeExpr(ex)) => {
|
||||
if let hir::ExprRet(Some(ref ret_expr)) = ex.node {
|
||||
let mut visitor = FindNestedReturn::new();
|
||||
visit::walk_expr(&mut visitor, &**ret_expr);
|
||||
if visitor.found {
|
||||
|
|
@ -1166,7 +1168,7 @@ fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bo
|
|||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeBlock(blk)) if blk.id == blk_id => {
|
||||
Some(hir_map::NodeBlock(blk)) if blk.id == blk_id => {
|
||||
let mut visitor = FindNestedReturn::new();
|
||||
visit::walk_expr_opt(&mut visitor, &blk.expr);
|
||||
if visitor.found {
|
||||
|
|
@ -1354,7 +1356,7 @@ pub fn arg_kind<'a, 'tcx>(cx: &FunctionContext<'a, 'tcx>, t: Ty<'tcx>)
|
|||
// create_datums_for_fn_args: creates lvalue datums for each of the
|
||||
// incoming function arguments.
|
||||
pub fn create_datums_for_fn_args<'a, 'tcx>(mut bcx: Block<'a, 'tcx>,
|
||||
args: &[ast::Arg],
|
||||
args: &[hir::Arg],
|
||||
arg_tys: &[Ty<'tcx>],
|
||||
has_tupled_arg: bool,
|
||||
arg_scope: cleanup::CustomScopeIndex)
|
||||
|
|
@ -1559,12 +1561,12 @@ pub fn build_return_block<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
|
|||
///
|
||||
/// If the function closes over its environment a closure will be returned.
|
||||
pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
decl: &hir::FnDecl,
|
||||
body: &hir::Block,
|
||||
llfndecl: ValueRef,
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
fn_ast_id: ast::NodeId,
|
||||
_attributes: &[ast::Attribute],
|
||||
_attributes: &[hir::Attribute],
|
||||
output_type: ty::FnOutput<'tcx>,
|
||||
abi: Abi,
|
||||
closure_env: closure::ClosureEnv<'b>) {
|
||||
|
|
@ -1678,12 +1680,12 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
/// Creates an LLVM function corresponding to a source language function.
|
||||
pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
decl: &hir::FnDecl,
|
||||
body: &hir::Block,
|
||||
llfndecl: ValueRef,
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
id: ast::NodeId,
|
||||
attrs: &[ast::Attribute]) {
|
||||
attrs: &[hir::Attribute]) {
|
||||
let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string());
|
||||
debug!("trans_fn(param_substs={:?})", param_substs);
|
||||
let _icx = push_ctxt("trans_fn");
|
||||
|
|
@ -1860,7 +1862,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
|
|||
finish_fn(&fcx, bcx, result_ty, DebugLoc::None);
|
||||
}
|
||||
|
||||
fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, id: ast::NodeId) {
|
||||
fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &hir::EnumDef, sp: Span, id: ast::NodeId) {
|
||||
let mut sizes = Vec::new(); // does no allocation if no pushes, thankfully
|
||||
|
||||
let print_info = ccx.sess().print_enum_sizes();
|
||||
|
|
@ -1939,7 +1941,7 @@ pub struct TransItemVisitor<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for TransItemVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
trans_item(self.ccx, i);
|
||||
}
|
||||
}
|
||||
|
|
@ -2010,7 +2012,7 @@ pub fn update_linkage(ccx: &CrateContext,
|
|||
|
||||
if let Some(id) = id {
|
||||
let item = ccx.tcx().map.get(id);
|
||||
if let ast_map::NodeItem(i) = item {
|
||||
if let hir_map::NodeItem(i) = item {
|
||||
if let Some(name) = attr::first_attr_value_str_by_name(&i.attrs, "linkage") {
|
||||
if let Some(linkage) = llvm_linkage_by_name(&name) {
|
||||
llvm::SetLinkage(llval, linkage);
|
||||
|
|
@ -2037,7 +2039,7 @@ pub fn update_linkage(ccx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
fn set_global_section(ccx: &CrateContext, llval: ValueRef, i: &ast::Item) {
|
||||
fn set_global_section(ccx: &CrateContext, llval: ValueRef, i: &hir::Item) {
|
||||
match attr::first_attr_value_str_by_name(&i.attrs,
|
||||
"link_section") {
|
||||
Some(sect) => {
|
||||
|
|
@ -2054,13 +2056,13 @@ fn set_global_section(ccx: &CrateContext, llval: ValueRef, i: &ast::Item) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
||||
pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
|
||||
let _icx = push_ctxt("trans_item");
|
||||
|
||||
let from_external = ccx.external_srcs().borrow().contains_key(&item.id);
|
||||
|
||||
match item.node {
|
||||
ast::ItemFn(ref decl, _, _, abi, ref generics, ref body) => {
|
||||
hir::ItemFn(ref decl, _, _, abi, ref generics, ref body) => {
|
||||
if !generics.is_type_parameterized() {
|
||||
let trans_everywhere = attr::requests_inline(&item.attrs);
|
||||
// Ignore `trans_everywhere` for cross-crate inlined items
|
||||
|
|
@ -2098,29 +2100,29 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
|||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
v.visit_block(&**body);
|
||||
}
|
||||
ast::ItemImpl(_, _, ref generics, _, _, ref impl_items) => {
|
||||
hir::ItemImpl(_, _, ref generics, _, _, ref impl_items) => {
|
||||
meth::trans_impl(ccx,
|
||||
item.ident,
|
||||
&impl_items[..],
|
||||
generics,
|
||||
item.id);
|
||||
}
|
||||
ast::ItemMod(ref m) => {
|
||||
hir::ItemMod(ref m) => {
|
||||
trans_mod(&ccx.rotate(), m);
|
||||
}
|
||||
ast::ItemEnum(ref enum_definition, ref gens) => {
|
||||
hir::ItemEnum(ref enum_definition, ref gens) => {
|
||||
if gens.ty_params.is_empty() {
|
||||
// sizes only make sense for non-generic types
|
||||
|
||||
enum_variant_size_lint(ccx, enum_definition, item.span, item.id);
|
||||
}
|
||||
}
|
||||
ast::ItemConst(_, ref expr) => {
|
||||
hir::ItemConst(_, ref expr) => {
|
||||
// Recurse on the expression to catch items in blocks
|
||||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
v.visit_expr(&**expr);
|
||||
}
|
||||
ast::ItemStatic(_, m, ref expr) => {
|
||||
hir::ItemStatic(_, m, ref expr) => {
|
||||
// Recurse on the expression to catch items in blocks
|
||||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
v.visit_expr(&**expr);
|
||||
|
|
@ -2129,10 +2131,10 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
|||
set_global_section(ccx, g, item);
|
||||
update_linkage(ccx, g, Some(item.id), OriginalTranslation);
|
||||
},
|
||||
ast::ItemForeignMod(ref foreign_mod) => {
|
||||
hir::ItemForeignMod(ref foreign_mod) => {
|
||||
foreign::trans_foreign_mod(ccx, foreign_mod);
|
||||
}
|
||||
ast::ItemTrait(..) => {
|
||||
hir::ItemTrait(..) => {
|
||||
// Inside of this trait definition, we won't be actually translating any
|
||||
// functions, but the trait still needs to be walked. Otherwise default
|
||||
// methods with items will not get translated and will cause ICE's when
|
||||
|
|
@ -2149,7 +2151,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
|||
// separate modules in the compiled program. That's because modules exist
|
||||
// only as a convenience for humans working with the code, to organize names
|
||||
// and control visibility.
|
||||
pub fn trans_mod(ccx: &CrateContext, m: &ast::Mod) {
|
||||
pub fn trans_mod(ccx: &CrateContext, m: &hir::Mod) {
|
||||
let _icx = push_ctxt("trans_mod");
|
||||
for item in &m.items {
|
||||
trans_item(ccx, &**item);
|
||||
|
|
@ -2295,7 +2297,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
|
|||
}
|
||||
|
||||
fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, id: ast::NodeId,
|
||||
ty: Ty<'tcx>, attrs: &[ast::Attribute]) -> String {
|
||||
ty: Ty<'tcx>, attrs: &[hir::Attribute]) -> String {
|
||||
match ccx.external_srcs().borrow().get(&id) {
|
||||
Some(&did) => {
|
||||
let sym = csearch::get_symbol(&ccx.sess().cstore, did);
|
||||
|
|
@ -2340,12 +2342,12 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
let item = ccx.tcx().map.get(id);
|
||||
debug!("get_item_val: id={} item={:?}", id, item);
|
||||
let val = match item {
|
||||
ast_map::NodeItem(i) => {
|
||||
hir_map::NodeItem(i) => {
|
||||
let ty = ccx.tcx().node_id_to_type(i.id);
|
||||
let sym = || exported_name(ccx, id, ty, &i.attrs);
|
||||
|
||||
let v = match i.node {
|
||||
ast::ItemStatic(..) => {
|
||||
hir::ItemStatic(..) => {
|
||||
// If this static came from an external crate, then
|
||||
// we need to get the symbol from csearch instead of
|
||||
// using the current crate's name/version
|
||||
|
|
@ -2366,7 +2368,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
g
|
||||
}
|
||||
|
||||
ast::ItemFn(_, _, _, abi, _, _) => {
|
||||
hir::ItemFn(_, _, _, abi, _, _) => {
|
||||
let sym = sym();
|
||||
let llfn = if abi == Rust {
|
||||
register_fn(ccx, i.span, sym, i.id, ty)
|
||||
|
|
@ -2383,10 +2385,10 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
v
|
||||
}
|
||||
|
||||
ast_map::NodeTraitItem(trait_item) => {
|
||||
hir_map::NodeTraitItem(trait_item) => {
|
||||
debug!("get_item_val(): processing a NodeTraitItem");
|
||||
match trait_item.node {
|
||||
ast::MethodTraitItem(_, Some(_)) => {
|
||||
hir::MethodTraitItem(_, Some(_)) => {
|
||||
register_method(ccx, id, &trait_item.attrs, trait_item.span)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -2397,9 +2399,9 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
}
|
||||
}
|
||||
|
||||
ast_map::NodeImplItem(impl_item) => {
|
||||
hir_map::NodeImplItem(impl_item) => {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(..) => {
|
||||
hir::MethodImplItem(..) => {
|
||||
register_method(ccx, id, &impl_item.attrs, impl_item.span)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -2410,9 +2412,9 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
}
|
||||
}
|
||||
|
||||
ast_map::NodeForeignItem(ni) => {
|
||||
hir_map::NodeForeignItem(ni) => {
|
||||
match ni.node {
|
||||
ast::ForeignItemFn(..) => {
|
||||
hir::ForeignItemFn(..) => {
|
||||
let abi = ccx.tcx().map.get_foreign_abi(id);
|
||||
let ty = ccx.tcx().node_id_to_type(ni.id);
|
||||
let name = foreign::link_name(&*ni);
|
||||
|
|
@ -2420,17 +2422,17 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
attributes::from_fn_attrs(ccx, &ni.attrs, llfn);
|
||||
llfn
|
||||
}
|
||||
ast::ForeignItemStatic(..) => {
|
||||
hir::ForeignItemStatic(..) => {
|
||||
foreign::register_static(ccx, &*ni)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ast_map::NodeVariant(ref v) => {
|
||||
hir_map::NodeVariant(ref v) => {
|
||||
let llfn;
|
||||
let args = match v.node.kind {
|
||||
ast::TupleVariantKind(ref args) => args,
|
||||
ast::StructVariantKind(_) => {
|
||||
hir::TupleVariantKind(ref args) => args,
|
||||
hir::StructVariantKind(_) => {
|
||||
ccx.sess().bug("struct variant kind unexpected in get_item_val")
|
||||
}
|
||||
};
|
||||
|
|
@ -2444,7 +2446,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
&enm.attrs);
|
||||
|
||||
llfn = match enm.node {
|
||||
ast::ItemEnum(_, _) => {
|
||||
hir::ItemEnum(_, _) => {
|
||||
register_fn(ccx, (*v).span, sym, id, ty)
|
||||
}
|
||||
_ => ccx.sess().bug("NodeVariant, shouldn't happen")
|
||||
|
|
@ -2453,7 +2455,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
llfn
|
||||
}
|
||||
|
||||
ast_map::NodeStructCtor(struct_def) => {
|
||||
hir_map::NodeStructCtor(struct_def) => {
|
||||
// Only register the constructor if this is a tuple-like struct.
|
||||
let ctor_id = match struct_def.ctor_id {
|
||||
None => {
|
||||
|
|
@ -2495,7 +2497,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
|||
}
|
||||
|
||||
fn register_method(ccx: &CrateContext, id: ast::NodeId,
|
||||
attrs: &[ast::Attribute], span: Span) -> ValueRef {
|
||||
attrs: &[hir::Attribute], span: Span) -> ValueRef {
|
||||
let mty = ccx.tcx().node_id_to_type(id);
|
||||
|
||||
let sym = exported_name(ccx, id, mty, &attrs);
|
||||
|
|
@ -2529,7 +2531,7 @@ pub fn crate_ctxt_to_encode_parms<'a, 'tcx>(cx: &'a SharedCrateContext<'a, 'tcx>
|
|||
}
|
||||
}
|
||||
|
||||
pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate,
|
||||
pub fn write_metadata(cx: &SharedCrateContext, krate: &hir::Crate,
|
||||
reachable: &NodeSet) -> Vec<u8> {
|
||||
use flate;
|
||||
|
||||
|
|
@ -2679,7 +2681,7 @@ pub fn filter_reachable_ids(ccx: &SharedCrateContext) -> NodeSet {
|
|||
// As a result, if this id is an FFI item (foreign item) then we only
|
||||
// let it through if it's included statically.
|
||||
match ccx.tcx().map.get(id) {
|
||||
ast_map::NodeForeignItem(..) => {
|
||||
hir_map::NodeForeignItem(..) => {
|
||||
ccx.sess().cstore.is_statically_included_foreign_item(id)
|
||||
}
|
||||
_ => true,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use middle::def;
|
|||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::subst;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use rustc::front::map as hir_map;
|
||||
use trans::adt;
|
||||
use trans::base;
|
||||
use trans::base::*;
|
||||
|
|
@ -50,7 +51,7 @@ use trans::type_::Type;
|
|||
use trans::type_of;
|
||||
use middle::ty::{self, Ty, HasTypeFlags, RegionEscape};
|
||||
use middle::ty::MethodCall;
|
||||
use rustc::ast_map;
|
||||
use rustc_front::hir;
|
||||
|
||||
use syntax::abi as synabi;
|
||||
use syntax::ast;
|
||||
|
|
@ -83,14 +84,14 @@ pub struct Callee<'blk, 'tcx: 'blk> {
|
|||
pub ty: Ty<'tcx>
|
||||
}
|
||||
|
||||
fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
|
||||
fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &hir::Expr)
|
||||
-> Callee<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_callee");
|
||||
debug!("callee::trans(expr={:?})", expr);
|
||||
|
||||
// pick out special kinds of expressions that can be called:
|
||||
match expr.node {
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
return trans_def(bcx, bcx.def(expr.id), expr);
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -99,7 +100,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
|
|||
// any other expressions are closures:
|
||||
return datum_callee(bcx, expr);
|
||||
|
||||
fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
|
||||
fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &hir::Expr)
|
||||
-> Callee<'blk, 'tcx> {
|
||||
let DatumBlock { bcx, datum, .. } = expr::trans(bcx, expr);
|
||||
match datum.ty.sty {
|
||||
|
|
@ -130,7 +131,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
|
|||
|
||||
fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
def: def::Def,
|
||||
ref_expr: &ast::Expr)
|
||||
ref_expr: &hir::Expr)
|
||||
-> Callee<'blk, 'tcx> {
|
||||
debug!("trans_def(def={:?}, ref_expr={:?})", def, ref_expr);
|
||||
let expr_ty = common::node_id_type(bcx, ref_expr.id);
|
||||
|
|
@ -140,7 +141,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
|
|||
let maybe_ast_node = maybe_def_id.and_then(|def_id| bcx.tcx().map
|
||||
.find(def_id.node));
|
||||
match maybe_ast_node {
|
||||
Some(ast_map::NodeStructCtor(_)) => true,
|
||||
Some(hir_map::NodeStructCtor(_)) => true,
|
||||
_ => false
|
||||
}
|
||||
} => {
|
||||
|
|
@ -286,7 +287,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
let (opt_def_id, sig) =
|
||||
match bare_fn_ty.sty {
|
||||
ty::TyBareFn(opt_def_id,
|
||||
&ty::BareFnTy { unsafety: ast::Unsafety::Normal,
|
||||
&ty::BareFnTy { unsafety: hir::Unsafety::Normal,
|
||||
abi: synabi::Rust,
|
||||
ref sig }) => {
|
||||
(opt_def_id, sig)
|
||||
|
|
@ -301,7 +302,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
|
|||
let tuple_input_ty = tcx.mk_tup(sig.inputs.to_vec());
|
||||
let tuple_fn_ty = tcx.mk_fn(opt_def_id,
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Normal,
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: synabi::RustCall,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![bare_fn_ty_maybe_ref,
|
||||
|
|
@ -471,11 +472,11 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
|
|||
|| "local item should be in ast map".to_string());
|
||||
|
||||
match map_node {
|
||||
ast_map::NodeVariant(v) => match v.node.kind {
|
||||
ast::TupleVariantKind(ref args) => !args.is_empty(),
|
||||
hir_map::NodeVariant(v) => match v.node.kind {
|
||||
hir::TupleVariantKind(ref args) => !args.is_empty(),
|
||||
_ => false
|
||||
},
|
||||
ast_map::NodeStructCtor(_) => true,
|
||||
hir_map::NodeStructCtor(_) => true,
|
||||
_ => false
|
||||
}
|
||||
} else {
|
||||
|
|
@ -572,8 +573,8 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
|
|||
// Translating calls
|
||||
|
||||
pub fn trans_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
call_expr: &ast::Expr,
|
||||
f: &ast::Expr,
|
||||
call_expr: &hir::Expr,
|
||||
f: &hir::Expr,
|
||||
args: CallArgs<'a, 'tcx>,
|
||||
dest: expr::Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
|
|
@ -586,8 +587,8 @@ pub fn trans_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_method_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
call_expr: &ast::Expr,
|
||||
rcvr: &ast::Expr,
|
||||
call_expr: &hir::Expr,
|
||||
rcvr: &hir::Expr,
|
||||
args: CallArgs<'a, 'tcx>,
|
||||
dest: expr::Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
|
|
@ -853,7 +854,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
pub enum CallArgs<'a, 'tcx> {
|
||||
// Supply value of arguments as a list of expressions that must be
|
||||
// translated. This is used in the common case of `foo(bar, qux)`.
|
||||
ArgExprs(&'a [P<ast::Expr>]),
|
||||
ArgExprs(&'a [P<hir::Expr>]),
|
||||
|
||||
// Supply value of arguments as a list of LLVM value refs; frequently
|
||||
// used with lang items and so forth, when the argument is an internal
|
||||
|
|
@ -868,12 +869,12 @@ pub enum CallArgs<'a, 'tcx> {
|
|||
|
||||
// Supply value of arguments as a list of expressions that must be
|
||||
// translated, for overloaded call operators.
|
||||
ArgOverloadedCall(Vec<&'a ast::Expr>),
|
||||
ArgOverloadedCall(Vec<&'a hir::Expr>),
|
||||
}
|
||||
|
||||
fn trans_args_under_call_abi<'blk, 'tcx>(
|
||||
mut bcx: Block<'blk, 'tcx>,
|
||||
arg_exprs: &[P<ast::Expr>],
|
||||
arg_exprs: &[P<hir::Expr>],
|
||||
fn_ty: Ty<'tcx>,
|
||||
llargs: &mut Vec<ValueRef>,
|
||||
arg_cleanup_scope: cleanup::ScopeId,
|
||||
|
|
@ -934,7 +935,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
|
|||
|
||||
fn trans_overloaded_call_args<'blk, 'tcx>(
|
||||
mut bcx: Block<'blk, 'tcx>,
|
||||
arg_exprs: Vec<&ast::Expr>,
|
||||
arg_exprs: Vec<&hir::Expr>,
|
||||
fn_ty: Ty<'tcx>,
|
||||
llargs: &mut Vec<ValueRef>,
|
||||
arg_cleanup_scope: cleanup::ScopeId,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ use session::config::FullDebugInfo;
|
|||
use syntax::abi::RustCall;
|
||||
use syntax::ast;
|
||||
|
||||
use rustc_front::hir;
|
||||
|
||||
|
||||
fn load_closure_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
arg_scope_id: ScopeId,
|
||||
|
|
@ -171,8 +173,8 @@ pub enum Dest<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
decl: &hir::FnDecl,
|
||||
body: &hir::Block,
|
||||
id: ast::NodeId,
|
||||
closure_substs: &'tcx ty::ClosureSubsts<'tcx>)
|
||||
-> Option<Block<'a, 'tcx>>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ use middle::traits;
|
|||
use middle::ty::{self, HasTypeFlags, Ty};
|
||||
use middle::ty_fold;
|
||||
use middle::ty_fold::{TypeFolder, TypeFoldable};
|
||||
use rustc::ast_map::{PathElem, PathName};
|
||||
use rustc::front::map::{PathElem, PathName};
|
||||
use rustc_front::hir;
|
||||
use util::nodemap::{FnvHashMap, NodeMap};
|
||||
|
||||
use arena::TypedArena;
|
||||
|
|
@ -266,7 +267,7 @@ pub struct NodeIdAndSpan {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
pub fn expr_info(expr: &ast::Expr) -> NodeIdAndSpan {
|
||||
pub fn expr_info(expr: &hir::Expr) -> NodeIdAndSpan {
|
||||
NodeIdAndSpan { id: expr.id, span: expr.span }
|
||||
}
|
||||
|
||||
|
|
@ -1024,11 +1025,11 @@ pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty
|
|||
monomorphize_type(bcx, t)
|
||||
}
|
||||
|
||||
pub fn expr_ty<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
|
||||
pub fn expr_ty<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &hir::Expr) -> Ty<'tcx> {
|
||||
node_id_type(bcx, ex.id)
|
||||
}
|
||||
|
||||
pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
|
||||
pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &hir::Expr) -> Ty<'tcx> {
|
||||
monomorphize_type(bcx, bcx.tcx().expr_ty_adjusted(ex))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,28 +38,31 @@ use middle::subst::Substs;
|
|||
use middle::ty::{self, Ty};
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::attr;
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use libc::c_uint;
|
||||
use syntax::{ast, attr};
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
|
||||
pub type FnArgMap<'a> = Option<&'a NodeMap<ValueRef>>;
|
||||
|
||||
pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
|
||||
pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &hir::Lit)
|
||||
-> ValueRef {
|
||||
let _icx = push_ctxt("trans_lit");
|
||||
debug!("const_lit: {:?}", lit);
|
||||
match lit.node {
|
||||
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
|
||||
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
|
||||
ast::LitInt(i, ast::SignedIntLit(t, _)) => {
|
||||
hir::LitByte(b) => C_integral(Type::uint_from_ty(cx, hir::TyU8), b as u64, false),
|
||||
hir::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
|
||||
hir::LitInt(i, hir::SignedIntLit(t, _)) => {
|
||||
C_integral(Type::int_from_ty(cx, t), i, true)
|
||||
}
|
||||
ast::LitInt(u, ast::UnsignedIntLit(t)) => {
|
||||
hir::LitInt(u, hir::UnsignedIntLit(t)) => {
|
||||
C_integral(Type::uint_from_ty(cx, t), u, false)
|
||||
}
|
||||
ast::LitInt(i, ast::UnsuffixedIntLit(_)) => {
|
||||
hir::LitInt(i, hir::UnsuffixedIntLit(_)) => {
|
||||
let lit_int_ty = cx.tcx().node_id_to_type(e.id);
|
||||
match lit_int_ty.sty {
|
||||
ty::TyInt(t) => {
|
||||
|
|
@ -74,10 +77,10 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
|
|||
lit_int_ty))
|
||||
}
|
||||
}
|
||||
ast::LitFloat(ref fs, t) => {
|
||||
hir::LitFloat(ref fs, t) => {
|
||||
C_floating(&fs, Type::float_from_ty(cx, t))
|
||||
}
|
||||
ast::LitFloatUnsuffixed(ref fs) => {
|
||||
hir::LitFloatUnsuffixed(ref fs) => {
|
||||
let lit_float_ty = cx.tcx().node_id_to_type(e.id);
|
||||
match lit_float_ty.sty {
|
||||
ty::TyFloat(t) => {
|
||||
|
|
@ -89,9 +92,9 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::LitBool(b) => C_bool(cx, b),
|
||||
ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
|
||||
ast::LitBinary(ref data) => {
|
||||
hir::LitBool(b) => C_bool(cx, b),
|
||||
hir::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
|
||||
hir::LitBinary(ref data) => {
|
||||
addr_of(cx, C_bytes(cx, &data[..]), "binary")
|
||||
}
|
||||
}
|
||||
|
|
@ -194,8 +197,8 @@ fn const_fn_call<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
pub fn get_const_expr<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
def_id: DefId,
|
||||
ref_expr: &ast::Expr)
|
||||
-> &'tcx ast::Expr {
|
||||
ref_expr: &hir::Expr)
|
||||
-> &'tcx hir::Expr {
|
||||
let def_id = inline::maybe_instantiate_inline(ccx, def_id);
|
||||
|
||||
if def_id.krate != LOCAL_CRATE {
|
||||
|
|
@ -213,21 +216,21 @@ pub fn get_const_expr<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
fn get_const_val(ccx: &CrateContext,
|
||||
def_id: DefId,
|
||||
ref_expr: &ast::Expr) -> ValueRef {
|
||||
ref_expr: &hir::Expr) -> ValueRef {
|
||||
let expr = get_const_expr(ccx, def_id, ref_expr);
|
||||
let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());
|
||||
get_const_expr_as_global(ccx, expr, check_const::ConstQualif::empty(), empty_substs)
|
||||
}
|
||||
|
||||
pub fn get_const_expr_as_global<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
qualif: check_const::ConstQualif,
|
||||
param_substs: &'tcx Substs<'tcx>)
|
||||
-> ValueRef {
|
||||
debug!("get_const_expr_as_global: {:?}", expr.id);
|
||||
// Special-case constants to cache a common global for all uses.
|
||||
match expr.node {
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
let def = ccx.tcx().def_map.borrow().get(&expr.id).unwrap().full_def();
|
||||
match def {
|
||||
def::DefConst(def_id) | def::DefAssociatedConst(def_id) => {
|
||||
|
|
@ -274,7 +277,7 @@ pub fn get_const_expr_as_global<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
e: &ast::Expr,
|
||||
e: &hir::Expr,
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
fn_args: FnArgMap)
|
||||
-> (ValueRef, Ty<'tcx>) {
|
||||
|
|
@ -378,11 +381,11 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
(llconst, ety_adjusted)
|
||||
}
|
||||
|
||||
fn check_unary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
||||
fn check_unary_expr_validity(cx: &CrateContext, e: &hir::Expr, t: Ty,
|
||||
te: ValueRef) {
|
||||
// The only kind of unary expression that we check for validity
|
||||
// here is `-expr`, to check if it "overflows" (e.g. `-i32::MIN`).
|
||||
if let ast::ExprUnary(ast::UnNeg, ref inner_e) = e.node {
|
||||
if let hir::ExprUnary(hir::UnNeg, ref inner_e) = e.node {
|
||||
|
||||
// An unfortunate special case: we parse e.g. -128 as a
|
||||
// negation of the literal 128, which means if we're expecting
|
||||
|
|
@ -392,7 +395,7 @@ fn check_unary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
|||
//
|
||||
// Catch this up front by looking for ExprLit directly,
|
||||
// and just accepting it.
|
||||
if let ast::ExprLit(_) = inner_e.node { return; }
|
||||
if let hir::ExprLit(_) = inner_e.node { return; }
|
||||
|
||||
let result = match t.sty {
|
||||
ty::TyInt(int_type) => {
|
||||
|
|
@ -421,9 +424,9 @@ fn check_unary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
|||
}
|
||||
}
|
||||
|
||||
fn check_binary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
||||
fn check_binary_expr_validity(cx: &CrateContext, e: &hir::Expr, t: Ty,
|
||||
te1: ValueRef, te2: ValueRef) {
|
||||
let b = if let ast::ExprBinary(b, _, _) = e.node { b } else { return };
|
||||
let b = if let hir::ExprBinary(b, _, _) = e.node { b } else { return };
|
||||
|
||||
let result = match t.sty {
|
||||
ty::TyInt(int_type) => {
|
||||
|
|
@ -435,13 +438,13 @@ fn check_binary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
|||
|
||||
let opt_ety = Some(const_eval::IntTy::from(cx.tcx(), int_type));
|
||||
match b.node {
|
||||
ast::BiAdd => const_int_checked_add(lhs, rhs, e, opt_ety),
|
||||
ast::BiSub => const_int_checked_sub(lhs, rhs, e, opt_ety),
|
||||
ast::BiMul => const_int_checked_mul(lhs, rhs, e, opt_ety),
|
||||
ast::BiDiv => const_int_checked_div(lhs, rhs, e, opt_ety),
|
||||
ast::BiRem => const_int_checked_rem(lhs, rhs, e, opt_ety),
|
||||
ast::BiShl => const_int_checked_shl(lhs, rhs, e, opt_ety),
|
||||
ast::BiShr => const_int_checked_shr(lhs, rhs, e, opt_ety),
|
||||
hir::BiAdd => const_int_checked_add(lhs, rhs, e, opt_ety),
|
||||
hir::BiSub => const_int_checked_sub(lhs, rhs, e, opt_ety),
|
||||
hir::BiMul => const_int_checked_mul(lhs, rhs, e, opt_ety),
|
||||
hir::BiDiv => const_int_checked_div(lhs, rhs, e, opt_ety),
|
||||
hir::BiRem => const_int_checked_rem(lhs, rhs, e, opt_ety),
|
||||
hir::BiShl => const_int_checked_shl(lhs, rhs, e, opt_ety),
|
||||
hir::BiShr => const_int_checked_shr(lhs, rhs, e, opt_ety),
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
|
|
@ -454,13 +457,13 @@ fn check_binary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
|||
|
||||
let opt_ety = Some(const_eval::UintTy::from(cx.tcx(), uint_type));
|
||||
match b.node {
|
||||
ast::BiAdd => const_uint_checked_add(lhs, rhs, e, opt_ety),
|
||||
ast::BiSub => const_uint_checked_sub(lhs, rhs, e, opt_ety),
|
||||
ast::BiMul => const_uint_checked_mul(lhs, rhs, e, opt_ety),
|
||||
ast::BiDiv => const_uint_checked_div(lhs, rhs, e, opt_ety),
|
||||
ast::BiRem => const_uint_checked_rem(lhs, rhs, e, opt_ety),
|
||||
ast::BiShl => const_uint_checked_shl(lhs, rhs, e, opt_ety),
|
||||
ast::BiShr => const_uint_checked_shr(lhs, rhs, e, opt_ety),
|
||||
hir::BiAdd => const_uint_checked_add(lhs, rhs, e, opt_ety),
|
||||
hir::BiSub => const_uint_checked_sub(lhs, rhs, e, opt_ety),
|
||||
hir::BiMul => const_uint_checked_mul(lhs, rhs, e, opt_ety),
|
||||
hir::BiDiv => const_uint_checked_div(lhs, rhs, e, opt_ety),
|
||||
hir::BiRem => const_uint_checked_rem(lhs, rhs, e, opt_ety),
|
||||
hir::BiShl => const_uint_checked_shl(lhs, rhs, e, opt_ety),
|
||||
hir::BiShr => const_uint_checked_shr(lhs, rhs, e, opt_ety),
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
|
|
@ -473,7 +476,7 @@ fn check_binary_expr_validity(cx: &CrateContext, e: &ast::Expr, t: Ty,
|
|||
}
|
||||
|
||||
fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
e: &ast::Expr,
|
||||
e: &hir::Expr,
|
||||
ety: Ty<'tcx>,
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
fn_args: FnArgMap)
|
||||
|
|
@ -484,17 +487,17 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ety,
|
||||
param_substs);
|
||||
|
||||
let map_list = |exprs: &[P<ast::Expr>]| -> Vec<ValueRef> {
|
||||
let map_list = |exprs: &[P<hir::Expr>]| -> Vec<ValueRef> {
|
||||
exprs.iter()
|
||||
.map(|e| const_expr(cx, &**e, param_substs, fn_args).0)
|
||||
.collect()
|
||||
};
|
||||
let _icx = push_ctxt("const_expr");
|
||||
match e.node {
|
||||
ast::ExprLit(ref lit) => {
|
||||
hir::ExprLit(ref lit) => {
|
||||
const_lit(cx, e, &**lit)
|
||||
},
|
||||
ast::ExprBinary(b, ref e1, ref e2) => {
|
||||
hir::ExprBinary(b, ref e1, ref e2) => {
|
||||
/* Neither type is bottom, and we expect them to be unified
|
||||
* already, so the following is safe. */
|
||||
let (te1, ty) = const_expr(cx, &**e1, param_substs, fn_args);
|
||||
|
|
@ -510,38 +513,38 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
check_binary_expr_validity(cx, e, ty, te1, te2);
|
||||
|
||||
unsafe { match b.node {
|
||||
ast::BiAdd if is_float => llvm::LLVMConstFAdd(te1, te2),
|
||||
ast::BiAdd => llvm::LLVMConstAdd(te1, te2),
|
||||
hir::BiAdd if is_float => llvm::LLVMConstFAdd(te1, te2),
|
||||
hir::BiAdd => llvm::LLVMConstAdd(te1, te2),
|
||||
|
||||
ast::BiSub if is_float => llvm::LLVMConstFSub(te1, te2),
|
||||
ast::BiSub => llvm::LLVMConstSub(te1, te2),
|
||||
hir::BiSub if is_float => llvm::LLVMConstFSub(te1, te2),
|
||||
hir::BiSub => llvm::LLVMConstSub(te1, te2),
|
||||
|
||||
ast::BiMul if is_float => llvm::LLVMConstFMul(te1, te2),
|
||||
ast::BiMul => llvm::LLVMConstMul(te1, te2),
|
||||
hir::BiMul if is_float => llvm::LLVMConstFMul(te1, te2),
|
||||
hir::BiMul => llvm::LLVMConstMul(te1, te2),
|
||||
|
||||
ast::BiDiv if is_float => llvm::LLVMConstFDiv(te1, te2),
|
||||
ast::BiDiv if signed => llvm::LLVMConstSDiv(te1, te2),
|
||||
ast::BiDiv => llvm::LLVMConstUDiv(te1, te2),
|
||||
hir::BiDiv if is_float => llvm::LLVMConstFDiv(te1, te2),
|
||||
hir::BiDiv if signed => llvm::LLVMConstSDiv(te1, te2),
|
||||
hir::BiDiv => llvm::LLVMConstUDiv(te1, te2),
|
||||
|
||||
ast::BiRem if is_float => llvm::LLVMConstFRem(te1, te2),
|
||||
ast::BiRem if signed => llvm::LLVMConstSRem(te1, te2),
|
||||
ast::BiRem => llvm::LLVMConstURem(te1, te2),
|
||||
hir::BiRem if is_float => llvm::LLVMConstFRem(te1, te2),
|
||||
hir::BiRem if signed => llvm::LLVMConstSRem(te1, te2),
|
||||
hir::BiRem => llvm::LLVMConstURem(te1, te2),
|
||||
|
||||
ast::BiAnd => llvm::LLVMConstAnd(te1, te2),
|
||||
ast::BiOr => llvm::LLVMConstOr(te1, te2),
|
||||
ast::BiBitXor => llvm::LLVMConstXor(te1, te2),
|
||||
ast::BiBitAnd => llvm::LLVMConstAnd(te1, te2),
|
||||
ast::BiBitOr => llvm::LLVMConstOr(te1, te2),
|
||||
ast::BiShl => {
|
||||
hir::BiAnd => llvm::LLVMConstAnd(te1, te2),
|
||||
hir::BiOr => llvm::LLVMConstOr(te1, te2),
|
||||
hir::BiBitXor => llvm::LLVMConstXor(te1, te2),
|
||||
hir::BiBitAnd => llvm::LLVMConstAnd(te1, te2),
|
||||
hir::BiBitOr => llvm::LLVMConstOr(te1, te2),
|
||||
hir::BiShl => {
|
||||
let te2 = base::cast_shift_const_rhs(b.node, te1, te2);
|
||||
llvm::LLVMConstShl(te1, te2)
|
||||
},
|
||||
ast::BiShr => {
|
||||
hir::BiShr => {
|
||||
let te2 = base::cast_shift_const_rhs(b.node, te1, te2);
|
||||
if signed { llvm::LLVMConstAShr(te1, te2) }
|
||||
else { llvm::LLVMConstLShr(te1, te2) }
|
||||
},
|
||||
ast::BiEq | ast::BiNe | ast::BiLt | ast::BiLe | ast::BiGt | ast::BiGe => {
|
||||
hir::BiEq | hir::BiNe | hir::BiLt | hir::BiLe | hir::BiGt | hir::BiGe => {
|
||||
if is_float {
|
||||
let cmp = base::bin_op_to_fcmp_predicate(cx, b.node);
|
||||
ConstFCmp(cmp, te1, te2)
|
||||
|
|
@ -552,34 +555,34 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
},
|
||||
} } // unsafe { match b.node {
|
||||
},
|
||||
ast::ExprUnary(u, ref inner_e) => {
|
||||
hir::ExprUnary(u, ref inner_e) => {
|
||||
let (te, ty) = const_expr(cx, &**inner_e, param_substs, fn_args);
|
||||
|
||||
check_unary_expr_validity(cx, e, ty, te);
|
||||
|
||||
let is_float = ty.is_fp();
|
||||
unsafe { match u {
|
||||
ast::UnUniq | ast::UnDeref => const_deref(cx, te, ty).0,
|
||||
ast::UnNot => llvm::LLVMConstNot(te),
|
||||
ast::UnNeg if is_float => llvm::LLVMConstFNeg(te),
|
||||
ast::UnNeg => llvm::LLVMConstNeg(te),
|
||||
hir::UnUniq | hir::UnDeref => const_deref(cx, te, ty).0,
|
||||
hir::UnNot => llvm::LLVMConstNot(te),
|
||||
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
|
||||
hir::UnNeg => llvm::LLVMConstNeg(te),
|
||||
} }
|
||||
},
|
||||
ast::ExprField(ref base, field) => {
|
||||
hir::ExprField(ref base, field) => {
|
||||
let (bv, bt) = const_expr(cx, &**base, param_substs, fn_args);
|
||||
let brepr = adt::represent_type(cx, bt);
|
||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||
let ix = vinfo.field_index(field.node.name);
|
||||
adt::const_get_field(cx, &*brepr, bv, vinfo.discr, ix)
|
||||
},
|
||||
ast::ExprTupField(ref base, idx) => {
|
||||
hir::ExprTupField(ref base, idx) => {
|
||||
let (bv, bt) = const_expr(cx, &**base, param_substs, fn_args);
|
||||
let brepr = adt::represent_type(cx, bt);
|
||||
let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None);
|
||||
adt::const_get_field(cx, &*brepr, bv, vinfo.discr, idx.node)
|
||||
},
|
||||
|
||||
ast::ExprIndex(ref base, ref index) => {
|
||||
hir::ExprIndex(ref base, ref index) => {
|
||||
let (bv, bt) = const_expr(cx, &**base, param_substs, fn_args);
|
||||
let iv = match eval_const_expr_partial(cx.tcx(), &index, ExprTypeChecked) {
|
||||
Ok(ConstVal::Int(i)) => i as u64,
|
||||
|
|
@ -629,7 +632,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
const_get_elt(cx, arr, &[iv as c_uint])
|
||||
}
|
||||
},
|
||||
ast::ExprCast(ref base, _) => {
|
||||
hir::ExprCast(ref base, _) => {
|
||||
let t_cast = ety;
|
||||
let llty = type_of::type_of(cx, t_cast);
|
||||
let (v, t_expr) = const_expr(cx, &**base, param_substs, fn_args);
|
||||
|
|
@ -690,15 +693,15 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
},
|
||||
} } // unsafe { match ( ... ) {
|
||||
},
|
||||
ast::ExprAddrOf(ast::MutImmutable, ref sub) => {
|
||||
hir::ExprAddrOf(hir::MutImmutable, ref sub) => {
|
||||
// If this is the address of some static, then we need to return
|
||||
// the actual address of the static itself (short circuit the rest
|
||||
// of const eval).
|
||||
let mut cur = sub;
|
||||
loop {
|
||||
match cur.node {
|
||||
ast::ExprParen(ref sub) => cur = sub,
|
||||
ast::ExprBlock(ref blk) => {
|
||||
hir::ExprParen(ref sub) => cur = sub,
|
||||
hir::ExprBlock(ref blk) => {
|
||||
if let Some(ref sub) = blk.expr {
|
||||
cur = sub;
|
||||
} else {
|
||||
|
|
@ -718,16 +721,16 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
addr_of(cx, v, "ref")
|
||||
}
|
||||
},
|
||||
ast::ExprAddrOf(ast::MutMutable, ref sub) => {
|
||||
hir::ExprAddrOf(hir::MutMutable, ref sub) => {
|
||||
let (v, _) = const_expr(cx, &**sub, param_substs, fn_args);
|
||||
addr_of_mut(cx, v, "ref_mut_slice")
|
||||
},
|
||||
ast::ExprTup(ref es) => {
|
||||
hir::ExprTup(ref es) => {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
let vals = map_list(&es[..]);
|
||||
adt::trans_const(cx, &*repr, 0, &vals[..])
|
||||
},
|
||||
ast::ExprStruct(_, ref fs, ref base_opt) => {
|
||||
hir::ExprStruct(_, ref fs, ref base_opt) => {
|
||||
let repr = adt::represent_type(cx, ety);
|
||||
|
||||
let base_val = match *base_opt {
|
||||
|
|
@ -749,7 +752,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
adt::trans_const(cx, &*repr, discr, &cs[..])
|
||||
}
|
||||
},
|
||||
ast::ExprVec(ref es) => {
|
||||
hir::ExprVec(ref es) => {
|
||||
let unit_ty = ety.sequence_element_type(cx.tcx());
|
||||
let llunitty = type_of::type_of(cx, unit_ty);
|
||||
let vs = es.iter()
|
||||
|
|
@ -762,7 +765,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
C_array(llunitty, &vs[..])
|
||||
}
|
||||
},
|
||||
ast::ExprRepeat(ref elem, ref count) => {
|
||||
hir::ExprRepeat(ref elem, ref count) => {
|
||||
let unit_ty = ety.sequence_element_type(cx.tcx());
|
||||
let llunitty = type_of::type_of(cx, unit_ty);
|
||||
let n = cx.tcx().eval_repeat_count(count);
|
||||
|
|
@ -774,7 +777,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
C_array(llunitty, &vs[..])
|
||||
}
|
||||
},
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
let def = cx.tcx().def_map.borrow().get(&e.id).unwrap().full_def();
|
||||
match def {
|
||||
def::DefLocal(id) => {
|
||||
|
|
@ -820,12 +823,12 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
},
|
||||
ast::ExprCall(ref callee, ref args) => {
|
||||
hir::ExprCall(ref callee, ref args) => {
|
||||
let mut callee = &**callee;
|
||||
loop {
|
||||
callee = match callee.node {
|
||||
ast::ExprParen(ref inner) => &**inner,
|
||||
ast::ExprBlock(ref block) => match block.expr {
|
||||
hir::ExprParen(ref inner) => &**inner,
|
||||
hir::ExprBlock(ref block) => match block.expr {
|
||||
Some(ref tail) => &**tail,
|
||||
None => break,
|
||||
},
|
||||
|
|
@ -857,21 +860,21 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
_ => cx.sess().span_bug(e.span, "expected a struct, variant, or const fn def"),
|
||||
}
|
||||
},
|
||||
ast::ExprMethodCall(_, _, ref args) => {
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
let arg_vals = map_list(args);
|
||||
let method_call = ty::MethodCall::expr(e.id);
|
||||
let method_did = cx.tcx().tables.borrow().method_map[&method_call].def_id;
|
||||
const_fn_call(cx, MethodCallKey(method_call),
|
||||
method_did, &arg_vals, param_substs)
|
||||
},
|
||||
ast::ExprParen(ref e) => const_expr(cx, &**e, param_substs, fn_args).0,
|
||||
ast::ExprBlock(ref block) => {
|
||||
hir::ExprParen(ref e) => const_expr(cx, &**e, param_substs, fn_args).0,
|
||||
hir::ExprBlock(ref block) => {
|
||||
match block.expr {
|
||||
Some(ref expr) => const_expr(cx, &**expr, param_substs, fn_args).0,
|
||||
None => C_nil(cx),
|
||||
}
|
||||
},
|
||||
ast::ExprClosure(_, ref decl, ref body) => {
|
||||
hir::ExprClosure(_, ref decl, ref body) => {
|
||||
match ety.sty {
|
||||
ty::TyClosure(_, ref substs) => {
|
||||
closure::trans_closure_expr(closure::Dest::Ignore(cx), decl,
|
||||
|
|
@ -889,10 +892,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
pub fn trans_static(ccx: &CrateContext,
|
||||
m: ast::Mutability,
|
||||
expr: &ast::Expr,
|
||||
m: hir::Mutability,
|
||||
expr: &hir::Expr,
|
||||
id: ast::NodeId,
|
||||
attrs: &Vec<ast::Attribute>)
|
||||
attrs: &Vec<hir::Attribute>)
|
||||
-> ValueRef {
|
||||
unsafe {
|
||||
let _icx = push_ctxt("trans_static");
|
||||
|
|
@ -934,7 +937,7 @@ pub fn trans_static(ccx: &CrateContext,
|
|||
|
||||
// As an optimization, all shared statics which do not have interior
|
||||
// mutability are placed into read-only memory.
|
||||
if m != ast::MutMutable {
|
||||
if m != hir::MutMutable {
|
||||
let tcontents = ty.type_contents(ccx.tcx());
|
||||
if !tcontents.interior_unsafe() {
|
||||
llvm::LLVMSetGlobalConstant(g, llvm::True);
|
||||
|
|
|
|||
|
|
@ -25,13 +25,15 @@ use trans::expr;
|
|||
use trans;
|
||||
use middle::ty;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::util as ast_util;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::ast_util;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::parse::token;
|
||||
|
||||
pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
s: &ast::Stmt)
|
||||
s: &hir::Stmt)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_stmt");
|
||||
let fcx = cx.fcx;
|
||||
|
|
@ -53,20 +55,19 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
fcx.push_ast_cleanup_scope(cleanup_debug_loc);
|
||||
|
||||
match s.node {
|
||||
ast::StmtExpr(ref e, _) | ast::StmtSemi(ref e, _) => {
|
||||
hir::StmtExpr(ref e, _) | hir::StmtSemi(ref e, _) => {
|
||||
bcx = trans_stmt_semi(bcx, &**e);
|
||||
}
|
||||
ast::StmtDecl(ref d, _) => {
|
||||
hir::StmtDecl(ref d, _) => {
|
||||
match d.node {
|
||||
ast::DeclLocal(ref local) => {
|
||||
hir::DeclLocal(ref local) => {
|
||||
bcx = init_local(bcx, &**local);
|
||||
debuginfo::create_local_var_metadata(bcx, &**local);
|
||||
}
|
||||
// Inner items are visited by `trans_item`/`trans_meth`.
|
||||
ast::DeclItem(_) => {},
|
||||
hir::DeclItem(_) => {},
|
||||
}
|
||||
}
|
||||
ast::StmtMac(..) => cx.tcx().sess.bug("unexpanded macro")
|
||||
}
|
||||
|
||||
bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, ast_util::stmt_id(s));
|
||||
|
|
@ -74,7 +75,7 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
return bcx;
|
||||
}
|
||||
|
||||
pub fn trans_stmt_semi<'blk, 'tcx>(cx: Block<'blk, 'tcx>, e: &ast::Expr)
|
||||
pub fn trans_stmt_semi<'blk, 'tcx>(cx: Block<'blk, 'tcx>, e: &hir::Expr)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_stmt_semi");
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ pub fn trans_stmt_semi<'blk, 'tcx>(cx: Block<'blk, 'tcx>, e: &ast::Expr)
|
|||
}
|
||||
|
||||
pub fn trans_block<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
b: &ast::Block,
|
||||
b: &hir::Block,
|
||||
mut dest: expr::Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_block");
|
||||
|
|
@ -145,9 +146,9 @@ pub fn trans_block<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
if_id: ast::NodeId,
|
||||
cond: &ast::Expr,
|
||||
thn: &ast::Block,
|
||||
els: Option<&ast::Expr>,
|
||||
cond: &hir::Expr,
|
||||
thn: &hir::Block,
|
||||
els: Option<&hir::Expr>,
|
||||
dest: expr::Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("trans_if(bcx={}, if_id={}, cond={:?}, thn={}, dest={})",
|
||||
|
|
@ -211,9 +212,9 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_while<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
loop_expr: &ast::Expr,
|
||||
cond: &ast::Expr,
|
||||
body: &ast::Block)
|
||||
loop_expr: &hir::Expr,
|
||||
cond: &hir::Expr,
|
||||
body: &hir::Block)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_while");
|
||||
|
||||
|
|
@ -260,8 +261,8 @@ pub fn trans_while<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_loop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
loop_expr: &ast::Expr,
|
||||
body: &ast::Block)
|
||||
loop_expr: &hir::Expr,
|
||||
body: &hir::Block)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_loop");
|
||||
|
||||
|
|
@ -303,7 +304,7 @@ pub fn trans_loop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
opt_label: Option<ast::Ident>,
|
||||
exit: usize)
|
||||
-> Block<'blk, 'tcx> {
|
||||
|
|
@ -336,22 +337,22 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_break<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
label_opt: Option<ast::Ident>)
|
||||
-> Block<'blk, 'tcx> {
|
||||
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_BREAK);
|
||||
}
|
||||
|
||||
pub fn trans_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
label_opt: Option<ast::Ident>)
|
||||
-> Block<'blk, 'tcx> {
|
||||
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_LOOP);
|
||||
}
|
||||
|
||||
pub fn trans_ret<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
return_expr: &ast::Expr,
|
||||
retval_expr: Option<&ast::Expr>)
|
||||
return_expr: &hir::Expr,
|
||||
retval_expr: Option<&hir::Expr>)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_ret");
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@ use llvm;
|
|||
use llvm::debuginfo::{DIScope, DISubprogram};
|
||||
use trans::common::CrateContext;
|
||||
use middle::pat_util;
|
||||
use util::nodemap::NodeMap;
|
||||
use rustc::util::nodemap::NodeMap;
|
||||
|
||||
use libc::c_uint;
|
||||
use syntax::codemap::{Span, Pos};
|
||||
use syntax::{ast, codemap, ast_util};
|
||||
use syntax::{ast, codemap};
|
||||
|
||||
use rustc_front;
|
||||
use rustc_front::hir;
|
||||
|
||||
// This procedure builds the *scope map* for a given function, which maps any
|
||||
// given ast::NodeId in the function's AST to the correct DIScope metadata instance.
|
||||
|
|
@ -29,8 +32,8 @@ use syntax::{ast, codemap, ast_util};
|
|||
// introducing *artificial* lexical scope descriptors where necessary. These
|
||||
// artificial scopes allow GDB to correctly handle name shadowing.
|
||||
pub fn create_scope_map(cx: &CrateContext,
|
||||
args: &[ast::Arg],
|
||||
fn_entry_block: &ast::Block,
|
||||
args: &[hir::Arg],
|
||||
fn_entry_block: &hir::Block,
|
||||
fn_metadata: DISubprogram,
|
||||
fn_ast_id: ast::NodeId)
|
||||
-> NodeMap<DIScope> {
|
||||
|
|
@ -107,23 +110,22 @@ struct ScopeStackEntry {
|
|||
}
|
||||
|
||||
fn walk_block(cx: &CrateContext,
|
||||
block: &ast::Block,
|
||||
block: &hir::Block,
|
||||
scope_stack: &mut Vec<ScopeStackEntry> ,
|
||||
scope_map: &mut NodeMap<DIScope>) {
|
||||
scope_map.insert(block.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
// The interesting things here are statements and the concluding expression.
|
||||
for statement in &block.stmts {
|
||||
scope_map.insert(ast_util::stmt_id(&**statement),
|
||||
scope_map.insert(rustc_front::util::stmt_id(&**statement),
|
||||
scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
match statement.node {
|
||||
ast::StmtDecl(ref decl, _) =>
|
||||
hir::StmtDecl(ref decl, _) =>
|
||||
walk_decl(cx, &**decl, scope_stack, scope_map),
|
||||
ast::StmtExpr(ref exp, _) |
|
||||
ast::StmtSemi(ref exp, _) =>
|
||||
hir::StmtExpr(ref exp, _) |
|
||||
hir::StmtSemi(ref exp, _) =>
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map),
|
||||
ast::StmtMac(..) => () // Ignore macros (which should be expanded anyway).
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,11 +135,11 @@ fn walk_block(cx: &CrateContext,
|
|||
}
|
||||
|
||||
fn walk_decl(cx: &CrateContext,
|
||||
decl: &ast::Decl,
|
||||
decl: &hir::Decl,
|
||||
scope_stack: &mut Vec<ScopeStackEntry> ,
|
||||
scope_map: &mut NodeMap<DIScope>) {
|
||||
match *decl {
|
||||
codemap::Spanned { node: ast::DeclLocal(ref local), .. } => {
|
||||
codemap::Spanned { node: hir::DeclLocal(ref local), .. } => {
|
||||
scope_map.insert(local.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
walk_pattern(cx, &*local.pat, scope_stack, scope_map);
|
||||
|
|
@ -151,7 +153,7 @@ fn walk_decl(cx: &CrateContext,
|
|||
}
|
||||
|
||||
fn walk_pattern(cx: &CrateContext,
|
||||
pat: &ast::Pat,
|
||||
pat: &hir::Pat,
|
||||
scope_stack: &mut Vec<ScopeStackEntry> ,
|
||||
scope_map: &mut NodeMap<DIScope>) {
|
||||
|
||||
|
|
@ -161,7 +163,7 @@ fn walk_pattern(cx: &CrateContext,
|
|||
// ast_util::walk_pat() here because we have to visit *all* nodes in
|
||||
// order to put them into the scope map. The above functions don't do that.
|
||||
match pat.node {
|
||||
ast::PatIdent(_, ref path1, ref sub_pat_opt) => {
|
||||
hir::PatIdent(_, ref path1, ref sub_pat_opt) => {
|
||||
|
||||
// Check if this is a binding. If so we need to put it on the
|
||||
// scope stack and maybe introduce an artificial scope
|
||||
|
|
@ -233,11 +235,11 @@ fn walk_pattern(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::PatWild(_) => {
|
||||
hir::PatWild(_) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
}
|
||||
|
||||
ast::PatEnum(_, ref sub_pats_opt) => {
|
||||
hir::PatEnum(_, ref sub_pats_opt) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
if let Some(ref sub_pats) = *sub_pats_opt {
|
||||
|
|
@ -247,22 +249,22 @@ fn walk_pattern(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::PatQPath(..) => {
|
||||
hir::PatQPath(..) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
}
|
||||
|
||||
ast::PatStruct(_, ref field_pats, _) => {
|
||||
hir::PatStruct(_, ref field_pats, _) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
for &codemap::Spanned {
|
||||
node: ast::FieldPat { pat: ref sub_pat, .. },
|
||||
node: hir::FieldPat { pat: ref sub_pat, .. },
|
||||
..
|
||||
} in field_pats {
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
ast::PatTup(ref sub_pats) => {
|
||||
hir::PatTup(ref sub_pats) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
for sub_pat in sub_pats {
|
||||
|
|
@ -270,23 +272,23 @@ fn walk_pattern(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::PatBox(ref sub_pat) | ast::PatRegion(ref sub_pat, _) => {
|
||||
hir::PatBox(ref sub_pat) | hir::PatRegion(ref sub_pat, _) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::PatLit(ref exp) => {
|
||||
hir::PatLit(ref exp) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::PatRange(ref exp1, ref exp2) => {
|
||||
hir::PatRange(ref exp1, ref exp2) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
walk_expr(cx, &**exp1, scope_stack, scope_map);
|
||||
walk_expr(cx, &**exp2, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::PatVec(ref front_sub_pats, ref middle_sub_pats, ref back_sub_pats) => {
|
||||
hir::PatVec(ref front_sub_pats, ref middle_sub_pats, ref back_sub_pats) => {
|
||||
scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
for sub_pat in front_sub_pats {
|
||||
|
|
@ -301,75 +303,70 @@ fn walk_pattern(cx: &CrateContext,
|
|||
walk_pattern(cx, &**sub_pat, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
ast::PatMac(_) => {
|
||||
cx.sess().span_bug(pat.span, "debuginfo::create_scope_map() - \
|
||||
Found unexpanded macro.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn walk_expr(cx: &CrateContext,
|
||||
exp: &ast::Expr,
|
||||
exp: &hir::Expr,
|
||||
scope_stack: &mut Vec<ScopeStackEntry> ,
|
||||
scope_map: &mut NodeMap<DIScope>) {
|
||||
|
||||
scope_map.insert(exp.id, scope_stack.last().unwrap().scope_metadata);
|
||||
|
||||
match exp.node {
|
||||
ast::ExprLit(_) |
|
||||
ast::ExprBreak(_) |
|
||||
ast::ExprAgain(_) |
|
||||
ast::ExprPath(..) => {}
|
||||
hir::ExprLit(_) |
|
||||
hir::ExprBreak(_) |
|
||||
hir::ExprAgain(_) |
|
||||
hir::ExprPath(..) => {}
|
||||
|
||||
ast::ExprCast(ref sub_exp, _) |
|
||||
ast::ExprAddrOf(_, ref sub_exp) |
|
||||
ast::ExprField(ref sub_exp, _) |
|
||||
ast::ExprTupField(ref sub_exp, _) |
|
||||
ast::ExprParen(ref sub_exp) =>
|
||||
hir::ExprCast(ref sub_exp, _) |
|
||||
hir::ExprAddrOf(_, ref sub_exp) |
|
||||
hir::ExprField(ref sub_exp, _) |
|
||||
hir::ExprTupField(ref sub_exp, _) |
|
||||
hir::ExprParen(ref sub_exp) =>
|
||||
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
||||
|
||||
ast::ExprBox(ref place, ref sub_expr) => {
|
||||
hir::ExprBox(ref place, ref sub_expr) => {
|
||||
place.as_ref().map(
|
||||
|e| walk_expr(cx, &**e, scope_stack, scope_map));
|
||||
walk_expr(cx, &**sub_expr, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::ExprRet(ref exp_opt) => match *exp_opt {
|
||||
hir::ExprRet(ref exp_opt) => match *exp_opt {
|
||||
Some(ref sub_exp) => walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
||||
None => ()
|
||||
},
|
||||
|
||||
ast::ExprUnary(_, ref sub_exp) => {
|
||||
hir::ExprUnary(_, ref sub_exp) => {
|
||||
walk_expr(cx, &**sub_exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::ExprAssignOp(_, ref lhs, ref rhs) |
|
||||
ast::ExprIndex(ref lhs, ref rhs) |
|
||||
ast::ExprBinary(_, ref lhs, ref rhs) => {
|
||||
hir::ExprAssignOp(_, ref lhs, ref rhs) |
|
||||
hir::ExprIndex(ref lhs, ref rhs) |
|
||||
hir::ExprBinary(_, ref lhs, ref rhs) => {
|
||||
walk_expr(cx, &**lhs, scope_stack, scope_map);
|
||||
walk_expr(cx, &**rhs, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::ExprRange(ref start, ref end) => {
|
||||
hir::ExprRange(ref start, ref end) => {
|
||||
start.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map));
|
||||
end.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map));
|
||||
}
|
||||
|
||||
ast::ExprVec(ref init_expressions) |
|
||||
ast::ExprTup(ref init_expressions) => {
|
||||
hir::ExprVec(ref init_expressions) |
|
||||
hir::ExprTup(ref init_expressions) => {
|
||||
for ie in init_expressions {
|
||||
walk_expr(cx, &**ie, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
ast::ExprAssign(ref sub_exp1, ref sub_exp2) |
|
||||
ast::ExprRepeat(ref sub_exp1, ref sub_exp2) => {
|
||||
hir::ExprAssign(ref sub_exp1, ref sub_exp2) |
|
||||
hir::ExprRepeat(ref sub_exp1, ref sub_exp2) => {
|
||||
walk_expr(cx, &**sub_exp1, scope_stack, scope_map);
|
||||
walk_expr(cx, &**sub_exp2, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
ast::ExprIf(ref cond_exp, ref then_block, ref opt_else_exp) => {
|
||||
hir::ExprIf(ref cond_exp, ref then_block, ref opt_else_exp) => {
|
||||
walk_expr(cx, &**cond_exp, scope_stack, scope_map);
|
||||
|
||||
with_new_scope(cx,
|
||||
|
|
@ -387,12 +384,7 @@ fn walk_expr(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::ExprIfLet(..) => {
|
||||
cx.sess().span_bug(exp.span, "debuginfo::create_scope_map() - \
|
||||
Found unexpanded if-let.");
|
||||
}
|
||||
|
||||
ast::ExprWhile(ref cond_exp, ref loop_body, _) => {
|
||||
hir::ExprWhile(ref cond_exp, ref loop_body, _) => {
|
||||
walk_expr(cx, &**cond_exp, scope_stack, scope_map);
|
||||
|
||||
with_new_scope(cx,
|
||||
|
|
@ -404,23 +396,8 @@ fn walk_expr(cx: &CrateContext,
|
|||
})
|
||||
}
|
||||
|
||||
ast::ExprWhileLet(..) => {
|
||||
cx.sess().span_bug(exp.span, "debuginfo::create_scope_map() - \
|
||||
Found unexpanded while-let.");
|
||||
}
|
||||
|
||||
ast::ExprForLoop(..) => {
|
||||
cx.sess().span_bug(exp.span, "debuginfo::create_scope_map() - \
|
||||
Found unexpanded for loop.");
|
||||
}
|
||||
|
||||
ast::ExprMac(_) => {
|
||||
cx.sess().span_bug(exp.span, "debuginfo::create_scope_map() - \
|
||||
Found unexpanded macro.");
|
||||
}
|
||||
|
||||
ast::ExprLoop(ref block, _) |
|
||||
ast::ExprBlock(ref block) => {
|
||||
hir::ExprLoop(ref block, _) |
|
||||
hir::ExprBlock(ref block) => {
|
||||
with_new_scope(cx,
|
||||
block.span,
|
||||
scope_stack,
|
||||
|
|
@ -430,13 +407,13 @@ fn walk_expr(cx: &CrateContext,
|
|||
})
|
||||
}
|
||||
|
||||
ast::ExprClosure(_, ref decl, ref block) => {
|
||||
hir::ExprClosure(_, ref decl, ref block) => {
|
||||
with_new_scope(cx,
|
||||
block.span,
|
||||
scope_stack,
|
||||
scope_map,
|
||||
|cx, scope_stack, scope_map| {
|
||||
for &ast::Arg { pat: ref pattern, .. } in &decl.inputs {
|
||||
for &hir::Arg { pat: ref pattern, .. } in &decl.inputs {
|
||||
walk_pattern(cx, &**pattern, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
|
|
@ -444,7 +421,7 @@ fn walk_expr(cx: &CrateContext,
|
|||
})
|
||||
}
|
||||
|
||||
ast::ExprCall(ref fn_exp, ref args) => {
|
||||
hir::ExprCall(ref fn_exp, ref args) => {
|
||||
walk_expr(cx, &**fn_exp, scope_stack, scope_map);
|
||||
|
||||
for arg_exp in args {
|
||||
|
|
@ -452,13 +429,13 @@ fn walk_expr(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::ExprMethodCall(_, _, ref args) => {
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
for arg_exp in args {
|
||||
walk_expr(cx, &**arg_exp, scope_stack, scope_map);
|
||||
}
|
||||
}
|
||||
|
||||
ast::ExprMatch(ref discriminant_exp, ref arms, _) => {
|
||||
hir::ExprMatch(ref discriminant_exp, ref arms, _) => {
|
||||
walk_expr(cx, &**discriminant_exp, scope_stack, scope_map);
|
||||
|
||||
// For each arm we have to first walk the pattern as these might
|
||||
|
|
@ -487,8 +464,8 @@ fn walk_expr(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::ExprStruct(_, ref fields, ref base_exp) => {
|
||||
for &ast::Field { expr: ref exp, .. } in fields {
|
||||
hir::ExprStruct(_, ref fields, ref base_exp) => {
|
||||
for &hir::Field { expr: ref exp, .. } in fields {
|
||||
walk_expr(cx, &**exp, scope_stack, scope_map);
|
||||
}
|
||||
|
||||
|
|
@ -498,7 +475,7 @@ fn walk_expr(cx: &CrateContext,
|
|||
}
|
||||
}
|
||||
|
||||
ast::ExprInlineAsm(ast::InlineAsm { ref inputs,
|
||||
hir::ExprInlineAsm(hir::InlineAsm { ref inputs,
|
||||
ref outputs,
|
||||
.. }) => {
|
||||
// inputs, outputs: Vec<(String, P<Expr>)>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use session::config::NoDebugInfo;
|
|||
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use syntax::attr;
|
||||
use rustc_front::attr;
|
||||
|
||||
|
||||
/// Inserts a side-effect free instruction sequence that makes sure that the
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType};
|
|||
use middle::def_id::DefId;
|
||||
use middle::pat_util;
|
||||
use middle::subst::{self, Substs};
|
||||
use rustc::ast_map;
|
||||
use rustc::front::map as hir_map;
|
||||
use rustc_front;
|
||||
use rustc_front::hir;
|
||||
use trans::{type_of, adt, machine, monomorphize};
|
||||
use trans::common::{self, CrateContext, FunctionContext, Block};
|
||||
use trans::_match::{BindingInfo, TransBindingMode};
|
||||
|
|
@ -207,7 +209,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
},
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
|
||||
unique_type_id.push('*');
|
||||
if mutbl == ast::MutMutable {
|
||||
if mutbl == hir::MutMutable {
|
||||
unique_type_id.push_str("mut");
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +219,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
},
|
||||
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => {
|
||||
unique_type_id.push('&');
|
||||
if mutbl == ast::MutMutable {
|
||||
if mutbl == hir::MutMutable {
|
||||
unique_type_id.push_str("mut");
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +253,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
&mut unique_type_id);
|
||||
},
|
||||
ty::TyBareFn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
if unsafety == hir::Unsafety::Unsafe {
|
||||
unique_type_id.push_str("unsafe ");
|
||||
}
|
||||
|
||||
|
|
@ -525,7 +527,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
-> MetadataCreationResult {
|
||||
let data_ptr_type = cx.tcx().mk_ptr(ty::TypeAndMut {
|
||||
ty: element_type,
|
||||
mutbl: ast::MutImmutable
|
||||
mutbl: hir::MutImmutable
|
||||
});
|
||||
|
||||
let element_type_metadata = type_metadata(cx, data_ptr_type, span);
|
||||
|
|
@ -932,22 +934,22 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::TyBool => ("bool".to_string(), DW_ATE_boolean),
|
||||
ty::TyChar => ("char".to_string(), DW_ATE_unsigned_char),
|
||||
ty::TyInt(int_ty) => match int_ty {
|
||||
ast::TyIs => ("isize".to_string(), DW_ATE_signed),
|
||||
ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
|
||||
ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
|
||||
ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
|
||||
ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
|
||||
hir::TyIs => ("isize".to_string(), DW_ATE_signed),
|
||||
hir::TyI8 => ("i8".to_string(), DW_ATE_signed),
|
||||
hir::TyI16 => ("i16".to_string(), DW_ATE_signed),
|
||||
hir::TyI32 => ("i32".to_string(), DW_ATE_signed),
|
||||
hir::TyI64 => ("i64".to_string(), DW_ATE_signed)
|
||||
},
|
||||
ty::TyUint(uint_ty) => match uint_ty {
|
||||
ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
|
||||
ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
|
||||
ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
|
||||
ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
|
||||
ast::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
|
||||
hir::TyUs => ("usize".to_string(), DW_ATE_unsigned),
|
||||
hir::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
|
||||
hir::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
|
||||
hir::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
|
||||
hir::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
|
||||
},
|
||||
ty::TyFloat(float_ty) => match float_ty {
|
||||
ast::TyF32 => ("f32".to_string(), DW_ATE_float),
|
||||
ast::TyF64 => ("f64".to_string(), DW_ATE_float),
|
||||
hir::TyF32 => ("f32".to_string(), DW_ATE_float),
|
||||
hir::TyF64 => ("f64".to_string(), DW_ATE_float),
|
||||
},
|
||||
_ => cx.sess().bug("debuginfo::basic_type_metadata - t is invalid type")
|
||||
};
|
||||
|
|
@ -1606,7 +1608,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
})
|
||||
.collect();
|
||||
|
||||
let discriminant_type_metadata = |inttype| {
|
||||
let discriminant_type_metadata = |inttype: rustc_front::attr::IntType| {
|
||||
let disr_type_key = (enum_def_id, inttype);
|
||||
let cached_discriminant_type_metadata = debug_context(cx).created_enum_disr_types
|
||||
.borrow()
|
||||
|
|
@ -1854,10 +1856,10 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
|||
let var_item = cx.tcx().map.get(node_id);
|
||||
|
||||
let (name, span) = match var_item {
|
||||
ast_map::NodeItem(item) => {
|
||||
hir_map::NodeItem(item) => {
|
||||
match item.node {
|
||||
ast::ItemStatic(..) => (item.ident.name, item.span),
|
||||
ast::ItemConst(..) => (item.ident.name, item.span),
|
||||
hir::ItemStatic(..) => (item.ident.name, item.span),
|
||||
hir::ItemConst(..) => (item.ident.name, item.span),
|
||||
_ => {
|
||||
cx.sess()
|
||||
.span_bug(item.span,
|
||||
|
|
@ -1871,7 +1873,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
|||
},
|
||||
_ => cx.sess().bug(&format!("debuginfo::create_global_var_metadata() \
|
||||
- Captured var-id refers to unexpected \
|
||||
ast_map variant: {:?}",
|
||||
hir_map variant: {:?}",
|
||||
var_item))
|
||||
};
|
||||
|
||||
|
|
@ -1912,7 +1914,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
|||
/// This function assumes that there's a datum for each pattern component of the
|
||||
/// local in `bcx.fcx.lllocals`.
|
||||
/// Adds the created metadata nodes directly to the crate's IR.
|
||||
pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
|
||||
pub fn create_local_var_metadata(bcx: Block, local: &hir::Local) {
|
||||
if bcx.unreachable.get() ||
|
||||
fn_should_be_ignored(bcx.fcx) ||
|
||||
bcx.sess().opts.debuginfo != FullDebugInfo {
|
||||
|
|
@ -1973,9 +1975,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
None => {
|
||||
cx.sess().span_bug(span, "debuginfo::create_captured_var_metadata: node not found");
|
||||
}
|
||||
Some(ast_map::NodeLocal(pat)) | Some(ast_map::NodeArg(pat)) => {
|
||||
Some(hir_map::NodeLocal(pat)) | Some(hir_map::NodeArg(pat)) => {
|
||||
match pat.node {
|
||||
ast::PatIdent(_, ref path1, _) => {
|
||||
hir::PatIdent(_, ref path1, _) => {
|
||||
path1.node.name
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1984,7 +1986,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
&format!(
|
||||
"debuginfo::create_captured_var_metadata() - \
|
||||
Captured var-id refers to unexpected \
|
||||
ast_map variant: {:?}",
|
||||
hir_map variant: {:?}",
|
||||
ast_item));
|
||||
}
|
||||
}
|
||||
|
|
@ -1994,7 +1996,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
.span_bug(span,
|
||||
&format!("debuginfo::create_captured_var_metadata() - \
|
||||
Captured var-id refers to unexpected \
|
||||
ast_map variant: {:?}",
|
||||
hir_map variant: {:?}",
|
||||
ast_item));
|
||||
}
|
||||
};
|
||||
|
|
@ -2088,7 +2090,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
/// This function assumes that there's a datum for each pattern component of the
|
||||
/// argument in `bcx.fcx.lllocals`.
|
||||
/// Adds the created metadata nodes directly to the crate's IR.
|
||||
pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
|
||||
pub fn create_argument_metadata(bcx: Block, arg: &hir::Arg) {
|
||||
if bcx.unreachable.get() ||
|
||||
fn_should_be_ignored(bcx.fcx) ||
|
||||
bcx.sess().opts.debuginfo != FullDebugInfo {
|
||||
|
|
|
|||
|
|
@ -28,22 +28,26 @@ use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArr
|
|||
DIDescriptor, FlagPrototyped};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::{self, Substs};
|
||||
use rustc::ast_map;
|
||||
use rustc_front;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::attr::IntType;
|
||||
|
||||
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
|
||||
use trans;
|
||||
use trans::{monomorphize, type_of};
|
||||
use middle::ty::{self, Ty};
|
||||
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
|
||||
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
|
||||
use rustc::front::map as hir_map;
|
||||
|
||||
use libc::c_uint;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
||||
use syntax::codemap::{Span, Pos};
|
||||
use syntax::{abi, ast, codemap, ast_util};
|
||||
use syntax::attr::IntType;
|
||||
use syntax::{abi, ast, codemap};
|
||||
use syntax::parse::token::{self, special_idents};
|
||||
|
||||
pub mod gdb;
|
||||
|
|
@ -225,18 +229,18 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
let empty_generics = ast_util::empty_generics();
|
||||
let empty_generics = rustc_front::util::empty_generics();
|
||||
|
||||
let fnitem = cx.tcx().map.get(fn_ast_id);
|
||||
|
||||
let (name, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
|
||||
ast_map::NodeItem(ref item) => {
|
||||
hir_map::NodeItem(ref item) => {
|
||||
if contains_nodebug_attribute(&item.attrs) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
match item.node {
|
||||
ast::ItemFn(ref fn_decl, _, _, _, ref generics, ref top_level_block) => {
|
||||
hir::ItemFn(ref fn_decl, _, _, _, ref generics, ref top_level_block) => {
|
||||
(item.ident.name, fn_decl, generics, top_level_block, item.span, true)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -245,9 +249,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast_map::NodeImplItem(impl_item) => {
|
||||
hir_map::NodeImplItem(impl_item) => {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(ref sig, ref body) => {
|
||||
hir::MethodImplItem(ref sig, ref body) => {
|
||||
if contains_nodebug_attribute(&impl_item.attrs) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
|
@ -266,9 +270,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast_map::NodeExpr(ref expr) => {
|
||||
hir_map::NodeExpr(ref expr) => {
|
||||
match expr.node {
|
||||
ast::ExprClosure(_, ref fn_decl, ref top_level_block) => {
|
||||
hir::ExprClosure(_, ref fn_decl, ref top_level_block) => {
|
||||
let name = format!("fn{}", token::gensym("fn"));
|
||||
let name = token::intern(&name[..]);
|
||||
(name, fn_decl,
|
||||
|
|
@ -284,9 +288,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
"create_function_debug_context: expected an expr_fn_block here")
|
||||
}
|
||||
}
|
||||
ast_map::NodeTraitItem(trait_item) => {
|
||||
hir_map::NodeTraitItem(trait_item) => {
|
||||
match trait_item.node {
|
||||
ast::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
hir::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
if contains_nodebug_attribute(&trait_item.attrs) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
|
@ -306,9 +310,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast_map::NodeForeignItem(..) |
|
||||
ast_map::NodeVariant(..) |
|
||||
ast_map::NodeStructCtor(..) => {
|
||||
hir_map::NodeForeignItem(..) |
|
||||
hir_map::NodeVariant(..) |
|
||||
hir_map::NodeStructCtor(..) => {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
_ => cx.sess().bug(&format!("create_function_debug_context: \
|
||||
|
|
@ -341,9 +345,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
file_metadata,
|
||||
&mut function_name);
|
||||
|
||||
// There is no ast_map::Path for ast::ExprClosure-type functions. For now,
|
||||
// There is no hir_map::Path for hir::ExprClosure-type functions. For now,
|
||||
// just don't put them into a namespace. In the future this could be improved
|
||||
// somehow (storing a path in the ast_map, or construct a path using the
|
||||
// somehow (storing a path in the hir_map, or construct a path using the
|
||||
// enclosing function).
|
||||
let (linkage_name, containing_scope) = if has_path {
|
||||
let namespace_node = namespace_for_item(cx, DefId::local(fn_ast_id));
|
||||
|
|
@ -452,7 +456,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
|
||||
fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
generics: &ast::Generics,
|
||||
generics: &hir::Generics,
|
||||
param_substs: &Substs<'tcx>,
|
||||
file_metadata: DIFile,
|
||||
name_to_append_suffix_to: &mut String)
|
||||
|
|
@ -515,7 +519,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
|
||||
// Handle other generic parameters
|
||||
let actual_types = param_substs.types.get_slice(subst::FnSpace);
|
||||
for (index, &ast::TyParam{ ident, .. }) in generics.ty_params.iter().enumerate() {
|
||||
for (index, &hir::TyParam{ ident, .. }) in generics.ty_params.iter().enumerate() {
|
||||
let actual_type = actual_types[index];
|
||||
// Add actual type name to <...> clause of function name
|
||||
let actual_type_name = compute_debuginfo_type_name(cx,
|
||||
|
|
@ -646,7 +650,7 @@ pub trait ToDebugLoc {
|
|||
fn debug_loc(&self) -> DebugLoc;
|
||||
}
|
||||
|
||||
impl ToDebugLoc for ast::Expr {
|
||||
impl ToDebugLoc for hir::Expr {
|
||||
fn debug_loc(&self) -> DebugLoc {
|
||||
DebugLoc::At(self.id, self.span)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ use super::utils::{DIB, debug_context};
|
|||
|
||||
use llvm;
|
||||
use llvm::debuginfo::DIScope;
|
||||
use rustc::ast_map;
|
||||
use rustc::middle::def_id::DefId;
|
||||
use rustc::front::map as hir_map;
|
||||
use trans::common::CrateContext;
|
||||
|
||||
use std::ffi::CString;
|
||||
|
|
@ -60,7 +60,7 @@ pub fn namespace_for_item(cx: &CrateContext, def_id: DefId) -> Rc<NamespaceTreeN
|
|||
// prepend crate name if not already present
|
||||
let krate = if def_id.is_local() {
|
||||
let crate_namespace_name = token::intern(crate_root_namespace(cx));
|
||||
Some(ast_map::PathMod(crate_namespace_name))
|
||||
Some(hir_map::PathMod(crate_namespace_name))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use middle::def_id::DefId;
|
|||
use middle::subst::{self, Substs};
|
||||
use middle::ty::{self, Ty};
|
||||
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
|
||||
|
||||
// Compute the name of the type as it should be stored in debuginfo. Does not do
|
||||
|
|
@ -43,18 +43,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::TyBool => output.push_str("bool"),
|
||||
ty::TyChar => output.push_str("char"),
|
||||
ty::TyStr => output.push_str("str"),
|
||||
ty::TyInt(ast::TyIs) => output.push_str("isize"),
|
||||
ty::TyInt(ast::TyI8) => output.push_str("i8"),
|
||||
ty::TyInt(ast::TyI16) => output.push_str("i16"),
|
||||
ty::TyInt(ast::TyI32) => output.push_str("i32"),
|
||||
ty::TyInt(ast::TyI64) => output.push_str("i64"),
|
||||
ty::TyUint(ast::TyUs) => output.push_str("usize"),
|
||||
ty::TyUint(ast::TyU8) => output.push_str("u8"),
|
||||
ty::TyUint(ast::TyU16) => output.push_str("u16"),
|
||||
ty::TyUint(ast::TyU32) => output.push_str("u32"),
|
||||
ty::TyUint(ast::TyU64) => output.push_str("u64"),
|
||||
ty::TyFloat(ast::TyF32) => output.push_str("f32"),
|
||||
ty::TyFloat(ast::TyF64) => output.push_str("f64"),
|
||||
ty::TyInt(hir::TyIs) => output.push_str("isize"),
|
||||
ty::TyInt(hir::TyI8) => output.push_str("i8"),
|
||||
ty::TyInt(hir::TyI16) => output.push_str("i16"),
|
||||
ty::TyInt(hir::TyI32) => output.push_str("i32"),
|
||||
ty::TyInt(hir::TyI64) => output.push_str("i64"),
|
||||
ty::TyUint(hir::TyUs) => output.push_str("usize"),
|
||||
ty::TyUint(hir::TyU8) => output.push_str("u8"),
|
||||
ty::TyUint(hir::TyU16) => output.push_str("u16"),
|
||||
ty::TyUint(hir::TyU32) => output.push_str("u32"),
|
||||
ty::TyUint(hir::TyU64) => output.push_str("u64"),
|
||||
ty::TyFloat(hir::TyF32) => output.push_str("f32"),
|
||||
ty::TyFloat(hir::TyF64) => output.push_str("f64"),
|
||||
ty::TyStruct(def, substs) |
|
||||
ty::TyEnum(def, substs) => {
|
||||
push_item_name(cx, def.did, qualified, output);
|
||||
|
|
@ -80,15 +80,15 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
|
||||
output.push('*');
|
||||
match mutbl {
|
||||
ast::MutImmutable => output.push_str("const "),
|
||||
ast::MutMutable => output.push_str("mut "),
|
||||
hir::MutImmutable => output.push_str("const "),
|
||||
hir::MutMutable => output.push_str("mut "),
|
||||
}
|
||||
|
||||
push_debuginfo_type_name(cx, inner_type, true, output);
|
||||
},
|
||||
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => {
|
||||
output.push('&');
|
||||
if mutbl == ast::MutMutable {
|
||||
if mutbl == hir::MutMutable {
|
||||
output.push_str("mut ");
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
push_type_params(cx, principal.substs, output);
|
||||
},
|
||||
ty::TyBareFn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
|
||||
if unsafety == ast::Unsafety::Unsafe {
|
||||
if unsafety == hir::Unsafety::Unsafe {
|
||||
output.push_str("unsafe ");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ use trans::machine;
|
|||
use trans::common::{CrateContext, FunctionContext};
|
||||
use trans::type_::Type;
|
||||
|
||||
use rustc_front::hir;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::{ast, codemap};
|
||||
|
||||
|
|
@ -44,11 +46,11 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool {
|
||||
pub fn contains_nodebug_attribute(attributes: &[hir::Attribute]) -> bool {
|
||||
attributes.iter().any(|attr| {
|
||||
let meta_item: &ast::MetaItem = &*attr.node.value;
|
||||
let meta_item: &hir::MetaItem = &*attr.node.value;
|
||||
match meta_item.node {
|
||||
ast::MetaWord(ref value) => &value[..] == "no_debug",
|
||||
hir::MetaWord(ref value) => &value[..] == "no_debug",
|
||||
_ => false
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -79,7 +79,10 @@ use util::common::indenter;
|
|||
use trans::machine::{llsize_of, llsize_of_alloc};
|
||||
use trans::type_::Type;
|
||||
|
||||
use syntax::{ast, ast_util, codemap};
|
||||
use rustc_front;
|
||||
use rustc_front::hir;
|
||||
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::ptr::P;
|
||||
use syntax::parse::token;
|
||||
|
|
@ -108,7 +111,7 @@ impl Dest {
|
|||
/// This function is equivalent to `trans(bcx, expr).store_to_dest(dest)` but it may generate
|
||||
/// better optimized LLVM code.
|
||||
pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let mut bcx = bcx;
|
||||
|
|
@ -146,7 +149,7 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// it prefers in-place instantiation, likely because it contains
|
||||
// `[x; N]` somewhere within.
|
||||
match expr.node {
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
match bcx.def(expr.id) {
|
||||
def::DefConst(did) => {
|
||||
let const_expr = consts::get_const_expr(bcx.ccx(), did, expr);
|
||||
|
|
@ -205,7 +208,7 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
/// possible, it is preferred to use `trans_into`, as that may avoid creating a temporary on the
|
||||
/// stack.
|
||||
pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr)
|
||||
expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
debug!("trans(expr={:?})", expr);
|
||||
|
||||
|
|
@ -333,7 +336,7 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
|
|||
/// Helper for trans that apply adjustments from `expr` to `datum`, which should be the unadjusted
|
||||
/// translation of `expr`.
|
||||
fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
datum: Datum<'tcx, Expr>)
|
||||
-> DatumBlock<'blk, 'tcx, Expr>
|
||||
{
|
||||
|
|
@ -549,7 +552,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
///
|
||||
/// { tmp = x(); tmp.f }
|
||||
pub fn trans_to_lvalue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
name: &str)
|
||||
-> DatumBlock<'blk, 'tcx, Lvalue> {
|
||||
let mut bcx = bcx;
|
||||
|
|
@ -560,7 +563,7 @@ pub fn trans_to_lvalue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
/// A version of `trans` that ignores adjustments. You almost certainly do not want to call this
|
||||
/// directly.
|
||||
fn trans_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr)
|
||||
expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let mut bcx = bcx;
|
||||
|
||||
|
|
@ -619,29 +622,29 @@ fn trans_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr)
|
||||
expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let mut bcx = bcx;
|
||||
let fcx = bcx.fcx;
|
||||
let _icx = push_ctxt("trans_datum_unadjusted");
|
||||
|
||||
match expr.node {
|
||||
ast::ExprParen(ref e) => {
|
||||
hir::ExprParen(ref e) => {
|
||||
trans(bcx, &**e)
|
||||
}
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
trans_def(bcx, expr, bcx.def(expr.id))
|
||||
}
|
||||
ast::ExprField(ref base, ident) => {
|
||||
hir::ExprField(ref base, ident) => {
|
||||
trans_rec_field(bcx, &**base, ident.node.name)
|
||||
}
|
||||
ast::ExprTupField(ref base, idx) => {
|
||||
hir::ExprTupField(ref base, idx) => {
|
||||
trans_rec_tup_field(bcx, &**base, idx.node)
|
||||
}
|
||||
ast::ExprIndex(ref base, ref idx) => {
|
||||
hir::ExprIndex(ref base, ref idx) => {
|
||||
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
|
||||
}
|
||||
ast::ExprBox(_, ref contents) => {
|
||||
hir::ExprBox(_, ref contents) => {
|
||||
// Special case for `Box<T>`
|
||||
let box_ty = expr_ty(bcx, expr);
|
||||
let contents_ty = expr_ty(bcx, &**contents);
|
||||
|
|
@ -654,16 +657,16 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
}
|
||||
ast::ExprLit(ref lit) => trans_immediate_lit(bcx, expr, &**lit),
|
||||
ast::ExprBinary(op, ref lhs, ref rhs) => {
|
||||
hir::ExprLit(ref lit) => trans_immediate_lit(bcx, expr, &**lit),
|
||||
hir::ExprBinary(op, ref lhs, ref rhs) => {
|
||||
trans_binary(bcx, expr, op, &**lhs, &**rhs)
|
||||
}
|
||||
ast::ExprUnary(op, ref x) => {
|
||||
hir::ExprUnary(op, ref x) => {
|
||||
trans_unary(bcx, expr, op, &**x)
|
||||
}
|
||||
ast::ExprAddrOf(_, ref x) => {
|
||||
hir::ExprAddrOf(_, ref x) => {
|
||||
match x.node {
|
||||
ast::ExprRepeat(..) | ast::ExprVec(..) => {
|
||||
hir::ExprRepeat(..) | hir::ExprVec(..) => {
|
||||
// Special case for slices.
|
||||
let cleanup_debug_loc =
|
||||
debuginfo::get_cleanup_debug_loc_for_ast_node(bcx.ccx(),
|
||||
|
|
@ -681,7 +684,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::ExprCast(ref val, _) => {
|
||||
hir::ExprCast(ref val, _) => {
|
||||
// Datum output mode means this is a scalar cast:
|
||||
trans_imm_cast(bcx, &**val, expr.id)
|
||||
}
|
||||
|
|
@ -696,7 +699,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||
base: &ast::Expr,
|
||||
base: &hir::Expr,
|
||||
get_idx: F)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> where
|
||||
F: FnOnce(&'blk ty::ctxt<'tcx>, &VariantInfo<'tcx>) -> usize,
|
||||
|
|
@ -731,7 +734,7 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
/// Translates `base.field`.
|
||||
fn trans_rec_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
base: &ast::Expr,
|
||||
base: &hir::Expr,
|
||||
field: ast::Name)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
trans_field(bcx, base, |_, vinfo| vinfo.field_index(field))
|
||||
|
|
@ -739,16 +742,16 @@ fn trans_rec_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
/// Translates `base.<idx>`.
|
||||
fn trans_rec_tup_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
base: &ast::Expr,
|
||||
base: &hir::Expr,
|
||||
idx: usize)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
trans_field(bcx, base, |_, _| idx)
|
||||
}
|
||||
|
||||
fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
index_expr: &ast::Expr,
|
||||
base: &ast::Expr,
|
||||
idx: &ast::Expr,
|
||||
index_expr: &hir::Expr,
|
||||
base: &hir::Expr,
|
||||
idx: &hir::Expr,
|
||||
method_call: MethodCall)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
//! Translates `base[idx]`.
|
||||
|
|
@ -867,7 +870,7 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ref_expr: &ast::Expr,
|
||||
ref_expr: &hir::Expr,
|
||||
def: def::Def)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
//! Translates a reference to a path.
|
||||
|
|
@ -918,7 +921,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr)
|
||||
expr: &hir::Expr)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let mut bcx = bcx;
|
||||
let _icx = push_ctxt("trans_rvalue_stmt");
|
||||
|
|
@ -930,16 +933,16 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
|
||||
|
||||
match expr.node {
|
||||
ast::ExprParen(ref e) => {
|
||||
hir::ExprParen(ref e) => {
|
||||
trans_into(bcx, &**e, Ignore)
|
||||
}
|
||||
ast::ExprBreak(label_opt) => {
|
||||
hir::ExprBreak(label_opt) => {
|
||||
controlflow::trans_break(bcx, expr, label_opt)
|
||||
}
|
||||
ast::ExprAgain(label_opt) => {
|
||||
hir::ExprAgain(label_opt) => {
|
||||
controlflow::trans_cont(bcx, expr, label_opt)
|
||||
}
|
||||
ast::ExprRet(ref ex) => {
|
||||
hir::ExprRet(ref ex) => {
|
||||
// Check to see if the return expression itself is reachable.
|
||||
// This can occur when the inner expression contains a return
|
||||
let reachable = if let Some(ref cfg) = bcx.fcx.cfg {
|
||||
|
|
@ -964,13 +967,13 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
bcx
|
||||
}
|
||||
}
|
||||
ast::ExprWhile(ref cond, ref body, _) => {
|
||||
hir::ExprWhile(ref cond, ref body, _) => {
|
||||
controlflow::trans_while(bcx, expr, &**cond, &**body)
|
||||
}
|
||||
ast::ExprLoop(ref body, _) => {
|
||||
hir::ExprLoop(ref body, _) => {
|
||||
controlflow::trans_loop(bcx, expr, &**body)
|
||||
}
|
||||
ast::ExprAssign(ref dst, ref src) => {
|
||||
hir::ExprAssign(ref dst, ref src) => {
|
||||
let src_datum = unpack_datum!(bcx, trans(bcx, &**src));
|
||||
let dst_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &**dst, "assign"));
|
||||
|
||||
|
|
@ -1019,10 +1022,10 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
src_datum.store_to(bcx, dst_datum.val)
|
||||
}
|
||||
}
|
||||
ast::ExprAssignOp(op, ref dst, ref src) => {
|
||||
hir::ExprAssignOp(op, ref dst, ref src) => {
|
||||
trans_assign_op(bcx, expr, op, &**dst, &**src)
|
||||
}
|
||||
ast::ExprInlineAsm(ref a) => {
|
||||
hir::ExprInlineAsm(ref a) => {
|
||||
asm::trans_inline_asm(bcx, a)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1036,7 +1039,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_rvalue_dps_unadjusted");
|
||||
|
|
@ -1046,22 +1049,22 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
|
||||
|
||||
match expr.node {
|
||||
ast::ExprParen(ref e) => {
|
||||
hir::ExprParen(ref e) => {
|
||||
trans_into(bcx, &**e, dest)
|
||||
}
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
trans_def_dps_unadjusted(bcx, expr, bcx.def(expr.id), dest)
|
||||
}
|
||||
ast::ExprIf(ref cond, ref thn, ref els) => {
|
||||
hir::ExprIf(ref cond, ref thn, ref els) => {
|
||||
controlflow::trans_if(bcx, expr.id, &**cond, &**thn, els.as_ref().map(|e| &**e), dest)
|
||||
}
|
||||
ast::ExprMatch(ref discr, ref arms, _) => {
|
||||
hir::ExprMatch(ref discr, ref arms, _) => {
|
||||
_match::trans_match(bcx, expr, &**discr, &arms[..], dest)
|
||||
}
|
||||
ast::ExprBlock(ref blk) => {
|
||||
hir::ExprBlock(ref blk) => {
|
||||
controlflow::trans_block(bcx, &**blk, dest)
|
||||
}
|
||||
ast::ExprStruct(_, ref fields, ref base) => {
|
||||
hir::ExprStruct(_, ref fields, ref base) => {
|
||||
trans_struct(bcx,
|
||||
&fields[..],
|
||||
base.as_ref().map(|e| &**e),
|
||||
|
|
@ -1070,11 +1073,11 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
node_id_type(bcx, expr.id),
|
||||
dest)
|
||||
}
|
||||
ast::ExprRange(ref start, ref end) => {
|
||||
hir::ExprRange(ref start, ref end) => {
|
||||
// FIXME it is just not right that we are synthesising ast nodes in
|
||||
// trans. Shudder.
|
||||
fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
|
||||
ast::Field {
|
||||
fn make_field(field_name: &str, expr: P<hir::Expr>) -> hir::Field {
|
||||
hir::Field {
|
||||
ident: codemap::dummy_spanned(token::str_to_ident(field_name)),
|
||||
expr: expr,
|
||||
span: codemap::DUMMY_SP,
|
||||
|
|
@ -1123,8 +1126,8 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
"No lang item for ranges (how did we get this far?)")
|
||||
}
|
||||
}
|
||||
ast::ExprTup(ref args) => {
|
||||
let numbered_fields: Vec<(usize, &ast::Expr)> =
|
||||
hir::ExprTup(ref args) => {
|
||||
let numbered_fields: Vec<(usize, &hir::Expr)> =
|
||||
args.iter().enumerate().map(|(i, arg)| (i, &**arg)).collect();
|
||||
trans_adt(bcx,
|
||||
expr_ty(bcx, expr),
|
||||
|
|
@ -1134,9 +1137,9 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
dest,
|
||||
expr.debug_loc())
|
||||
}
|
||||
ast::ExprLit(ref lit) => {
|
||||
hir::ExprLit(ref lit) => {
|
||||
match lit.node {
|
||||
ast::LitStr(ref s, _) => {
|
||||
hir::LitStr(ref s, _) => {
|
||||
tvec::trans_lit_str(bcx, expr, (*s).clone(), dest)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1148,10 +1151,10 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::ExprVec(..) | ast::ExprRepeat(..) => {
|
||||
hir::ExprVec(..) | hir::ExprRepeat(..) => {
|
||||
tvec::trans_fixed_vstore(bcx, expr, dest)
|
||||
}
|
||||
ast::ExprClosure(_, ref decl, ref body) => {
|
||||
hir::ExprClosure(_, ref decl, ref body) => {
|
||||
let dest = match dest {
|
||||
SaveIn(lldest) => closure::Dest::SaveIn(bcx, lldest),
|
||||
Ignore => closure::Dest::Ignore(bcx.ccx())
|
||||
|
|
@ -1165,7 +1168,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
};
|
||||
closure::trans_closure_expr(dest, decl, body, expr.id, substs).unwrap_or(bcx)
|
||||
}
|
||||
ast::ExprCall(ref f, ref args) => {
|
||||
hir::ExprCall(ref f, ref args) => {
|
||||
if bcx.tcx().is_method_call(expr.id) {
|
||||
trans_overloaded_call(bcx,
|
||||
expr,
|
||||
|
|
@ -1180,39 +1183,39 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
dest)
|
||||
}
|
||||
}
|
||||
ast::ExprMethodCall(_, _, ref args) => {
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
callee::trans_method_call(bcx,
|
||||
expr,
|
||||
&*args[0],
|
||||
callee::ArgExprs(&args[..]),
|
||||
dest)
|
||||
}
|
||||
ast::ExprBinary(op, ref lhs, ref rhs) => {
|
||||
hir::ExprBinary(op, ref lhs, ref rhs) => {
|
||||
// if not overloaded, would be RvalueDatumExpr
|
||||
let lhs = unpack_datum!(bcx, trans(bcx, &**lhs));
|
||||
let rhs_datum = unpack_datum!(bcx, trans(bcx, &**rhs));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), lhs,
|
||||
Some((rhs_datum, rhs.id)), Some(dest),
|
||||
!ast_util::is_by_value_binop(op.node)).bcx
|
||||
!rustc_front::util::is_by_value_binop(op.node)).bcx
|
||||
}
|
||||
ast::ExprUnary(op, ref subexpr) => {
|
||||
hir::ExprUnary(op, ref subexpr) => {
|
||||
// if not overloaded, would be RvalueDatumExpr
|
||||
let arg = unpack_datum!(bcx, trans(bcx, &**subexpr));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id),
|
||||
arg, None, Some(dest), !ast_util::is_by_value_unop(op)).bcx
|
||||
arg, None, Some(dest), !rustc_front::util::is_by_value_unop(op)).bcx
|
||||
}
|
||||
ast::ExprIndex(ref base, ref idx) => {
|
||||
hir::ExprIndex(ref base, ref idx) => {
|
||||
// if not overloaded, would be RvalueDatumExpr
|
||||
let base = unpack_datum!(bcx, trans(bcx, &**base));
|
||||
let idx_datum = unpack_datum!(bcx, trans(bcx, &**idx));
|
||||
trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), base,
|
||||
Some((idx_datum, idx.id)), Some(dest), true).bcx
|
||||
}
|
||||
ast::ExprCast(..) => {
|
||||
hir::ExprCast(..) => {
|
||||
// Trait casts used to come this way, now they should be coercions.
|
||||
bcx.tcx().sess.span_bug(expr.span, "DPS expr_cast (residual trait cast?)")
|
||||
}
|
||||
ast::ExprAssignOp(op, ref dst, ref src) => {
|
||||
hir::ExprAssignOp(op, ref dst, ref src) => {
|
||||
trans_assign_op(bcx, expr, op, &**dst, &**src)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1226,7 +1229,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
ref_expr: &ast::Expr,
|
||||
ref_expr: &hir::Expr,
|
||||
def: def::Def,
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
|
|
@ -1275,7 +1278,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn trans_def_fn_unadjusted<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
ref_expr: &ast::Expr,
|
||||
ref_expr: &hir::Expr,
|
||||
def: def::Def,
|
||||
param_substs: &'tcx Substs<'tcx>)
|
||||
-> Datum<'tcx, Rvalue> {
|
||||
|
|
@ -1352,8 +1355,8 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
fields: &[ast::Field],
|
||||
base: Option<&ast::Expr>,
|
||||
fields: &[hir::Field],
|
||||
base: Option<&hir::Expr>,
|
||||
expr_span: codemap::Span,
|
||||
expr_id: ast::NodeId,
|
||||
ty: Ty<'tcx>,
|
||||
|
|
@ -1407,7 +1410,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
/// evaluated for side-effects.
|
||||
pub struct StructBaseInfo<'a, 'tcx> {
|
||||
/// The base expression; will be evaluated after all explicit fields.
|
||||
expr: &'a ast::Expr,
|
||||
expr: &'a hir::Expr,
|
||||
/// The indices of fields to copy paired with their types.
|
||||
fields: Vec<(usize, Ty<'tcx>)>
|
||||
}
|
||||
|
|
@ -1423,7 +1426,7 @@ pub struct StructBaseInfo<'a, 'tcx> {
|
|||
pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
discr: ty::Disr,
|
||||
fields: &[(usize, &ast::Expr)],
|
||||
fields: &[(usize, &hir::Expr)],
|
||||
optbase: Option<StructBaseInfo<'a, 'tcx>>,
|
||||
dest: Dest,
|
||||
debug_location: DebugLoc)
|
||||
|
|
@ -1544,8 +1547,8 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
|
||||
|
||||
fn trans_immediate_lit<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
lit: &ast::Lit)
|
||||
expr: &hir::Expr,
|
||||
lit: &hir::Lit)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
// must not be a string constant, that is a RvalueDpsExpr
|
||||
let _icx = push_ctxt("trans_immediate_lit");
|
||||
|
|
@ -1555,9 +1558,9 @@ fn trans_immediate_lit<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
op: ast::UnOp,
|
||||
sub_expr: &ast::Expr)
|
||||
expr: &hir::Expr,
|
||||
op: hir::UnOp,
|
||||
sub_expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let ccx = bcx.ccx();
|
||||
let mut bcx = bcx;
|
||||
|
|
@ -1568,19 +1571,19 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// The only overloaded operator that is translated to a datum
|
||||
// is an overloaded deref, since it is always yields a `&T`.
|
||||
// Otherwise, we should be in the RvalueDpsExpr path.
|
||||
assert!(op == ast::UnDeref || !ccx.tcx().is_method_call(expr.id));
|
||||
assert!(op == hir::UnDeref || !ccx.tcx().is_method_call(expr.id));
|
||||
|
||||
let un_ty = expr_ty(bcx, expr);
|
||||
|
||||
let debug_loc = expr.debug_loc();
|
||||
|
||||
match op {
|
||||
ast::UnNot => {
|
||||
hir::UnNot => {
|
||||
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
|
||||
let llresult = Not(bcx, datum.to_llscalarish(bcx), debug_loc);
|
||||
immediate_rvalue_bcx(bcx, llresult, un_ty).to_expr_datumblock()
|
||||
}
|
||||
ast::UnNeg => {
|
||||
hir::UnNeg => {
|
||||
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
|
||||
let val = datum.to_llscalarish(bcx);
|
||||
let (bcx, llneg) = {
|
||||
|
|
@ -1607,10 +1610,10 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
};
|
||||
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
|
||||
}
|
||||
ast::UnUniq => {
|
||||
hir::UnUniq => {
|
||||
trans_uniq_expr(bcx, expr, un_ty, sub_expr, expr_ty(bcx, sub_expr))
|
||||
}
|
||||
ast::UnDeref => {
|
||||
hir::UnDeref => {
|
||||
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
|
||||
deref_once(bcx, expr, datum, method_call)
|
||||
}
|
||||
|
|
@ -1618,9 +1621,9 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
box_expr: &ast::Expr,
|
||||
box_expr: &hir::Expr,
|
||||
box_ty: Ty<'tcx>,
|
||||
contents: &ast::Expr,
|
||||
contents: &hir::Expr,
|
||||
contents_ty: Ty<'tcx>)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let _icx = push_ctxt("trans_uniq_expr");
|
||||
|
|
@ -1663,8 +1666,8 @@ fn ref_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
subexpr: &ast::Expr)
|
||||
expr: &hir::Expr,
|
||||
subexpr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let _icx = push_ctxt("trans_addr_of");
|
||||
let mut bcx = bcx;
|
||||
|
|
@ -1682,9 +1685,9 @@ fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
// Important to get types for both lhs and rhs, because one might be _|_
|
||||
// and the other not.
|
||||
fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
binop_expr: &ast::Expr,
|
||||
binop_expr: &hir::Expr,
|
||||
binop_ty: Ty<'tcx>,
|
||||
op: ast::BinOp,
|
||||
op: hir::BinOp,
|
||||
lhs_t: Ty<'tcx>,
|
||||
lhs: ValueRef,
|
||||
rhs_t: Ty<'tcx>,
|
||||
|
|
@ -1702,7 +1705,7 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
let mut bcx = bcx;
|
||||
let val = match op.node {
|
||||
ast::BiAdd => {
|
||||
hir::BiAdd => {
|
||||
if is_float {
|
||||
FAdd(bcx, lhs, rhs, binop_debug_loc)
|
||||
} else {
|
||||
|
|
@ -1712,7 +1715,7 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
res
|
||||
}
|
||||
}
|
||||
ast::BiSub => {
|
||||
hir::BiSub => {
|
||||
if is_float {
|
||||
FSub(bcx, lhs, rhs, binop_debug_loc)
|
||||
} else {
|
||||
|
|
@ -1722,7 +1725,7 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
res
|
||||
}
|
||||
}
|
||||
ast::BiMul => {
|
||||
hir::BiMul => {
|
||||
if is_float {
|
||||
FMul(bcx, lhs, rhs, binop_debug_loc)
|
||||
} else {
|
||||
|
|
@ -1732,7 +1735,7 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
res
|
||||
}
|
||||
}
|
||||
ast::BiDiv => {
|
||||
hir::BiDiv => {
|
||||
if is_float {
|
||||
FDiv(bcx, lhs, rhs, binop_debug_loc)
|
||||
} else {
|
||||
|
|
@ -1750,7 +1753,7 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::BiRem => {
|
||||
hir::BiRem => {
|
||||
if is_float {
|
||||
// LLVM currently always lowers the `frem` instructions appropriate
|
||||
// library calls typically found in libm. Notably f64 gets wired up
|
||||
|
|
@ -1801,22 +1804,22 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::BiBitOr => Or(bcx, lhs, rhs, binop_debug_loc),
|
||||
ast::BiBitAnd => And(bcx, lhs, rhs, binop_debug_loc),
|
||||
ast::BiBitXor => Xor(bcx, lhs, rhs, binop_debug_loc),
|
||||
ast::BiShl => {
|
||||
hir::BiBitOr => Or(bcx, lhs, rhs, binop_debug_loc),
|
||||
hir::BiBitAnd => And(bcx, lhs, rhs, binop_debug_loc),
|
||||
hir::BiBitXor => Xor(bcx, lhs, rhs, binop_debug_loc),
|
||||
hir::BiShl => {
|
||||
let (newbcx, res) = with_overflow_check(
|
||||
bcx, OverflowOp::Shl, info, lhs_t, lhs, rhs, binop_debug_loc);
|
||||
bcx = newbcx;
|
||||
res
|
||||
}
|
||||
ast::BiShr => {
|
||||
hir::BiShr => {
|
||||
let (newbcx, res) = with_overflow_check(
|
||||
bcx, OverflowOp::Shr, info, lhs_t, lhs, rhs, binop_debug_loc);
|
||||
bcx = newbcx;
|
||||
res
|
||||
}
|
||||
ast::BiEq | ast::BiNe | ast::BiLt | ast::BiGe | ast::BiLe | ast::BiGt => {
|
||||
hir::BiEq | hir::BiNe | hir::BiLt | hir::BiGe | hir::BiLe | hir::BiGt => {
|
||||
base::compare_scalar_types(bcx, lhs, rhs, lhs_t, op.node, binop_debug_loc)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1834,10 +1837,10 @@ enum lazy_binop_ty {
|
|||
}
|
||||
|
||||
fn trans_lazy_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
binop_expr: &ast::Expr,
|
||||
binop_expr: &hir::Expr,
|
||||
op: lazy_binop_ty,
|
||||
a: &ast::Expr,
|
||||
b: &ast::Expr)
|
||||
a: &hir::Expr,
|
||||
b: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let _icx = push_ctxt("trans_lazy_binop");
|
||||
let binop_ty = expr_ty(bcx, binop_expr);
|
||||
|
|
@ -1873,10 +1876,10 @@ fn trans_lazy_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_binary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
op: ast::BinOp,
|
||||
lhs: &ast::Expr,
|
||||
rhs: &ast::Expr)
|
||||
expr: &hir::Expr,
|
||||
op: hir::BinOp,
|
||||
lhs: &hir::Expr,
|
||||
rhs: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let _icx = push_ctxt("trans_binary");
|
||||
let ccx = bcx.ccx();
|
||||
|
|
@ -1885,10 +1888,10 @@ fn trans_binary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
assert!(!ccx.tcx().is_method_call(expr.id));
|
||||
|
||||
match op.node {
|
||||
ast::BiAnd => {
|
||||
hir::BiAnd => {
|
||||
trans_lazy_binop(bcx, expr, lazy_and, lhs, rhs)
|
||||
}
|
||||
ast::BiOr => {
|
||||
hir::BiOr => {
|
||||
trans_lazy_binop(bcx, expr, lazy_or, lhs, rhs)
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -1915,7 +1918,7 @@ fn trans_binary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
method_call: MethodCall,
|
||||
lhs: Datum<'tcx, Expr>,
|
||||
rhs: Option<(Datum<'tcx, Expr>, ast::NodeId)>,
|
||||
|
|
@ -1935,9 +1938,9 @@ fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_overloaded_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
callee: &'a ast::Expr,
|
||||
args: &'a [P<ast::Expr>],
|
||||
expr: &hir::Expr,
|
||||
callee: &'a hir::Expr,
|
||||
args: &'a [P<hir::Expr>],
|
||||
dest: Option<Dest>)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("trans_overloaded_call {}", expr.id);
|
||||
|
|
@ -1960,7 +1963,7 @@ fn trans_overloaded_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
pub fn cast_is_noop<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
t_in: Ty<'tcx>,
|
||||
t_out: Ty<'tcx>)
|
||||
-> bool {
|
||||
|
|
@ -1982,7 +1985,7 @@ pub fn cast_is_noop<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
}
|
||||
|
||||
fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
id: ast::NodeId)
|
||||
-> DatumBlock<'blk, 'tcx, Expr>
|
||||
{
|
||||
|
|
@ -2105,10 +2108,10 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
op: ast::BinOp,
|
||||
dst: &ast::Expr,
|
||||
src: &ast::Expr)
|
||||
expr: &hir::Expr,
|
||||
op: hir::BinOp,
|
||||
dst: &hir::Expr,
|
||||
src: &hir::Expr)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("trans_assign_op");
|
||||
let mut bcx = bcx;
|
||||
|
|
@ -2138,7 +2141,7 @@ fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
datum: Datum<'tcx, Expr>,
|
||||
expr: &ast::Expr)
|
||||
expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let mut bcx = bcx;
|
||||
|
||||
|
|
@ -2163,7 +2166,7 @@ fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn deref_multiple<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
datum: Datum<'tcx, Expr>,
|
||||
times: usize)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
|
|
@ -2177,7 +2180,7 @@ fn deref_multiple<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
|
||||
fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
datum: Datum<'tcx, Expr>,
|
||||
method_call: MethodCall)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
|
|
@ -2323,8 +2326,8 @@ impl OverflowOpViaIntrinsic {
|
|||
bcx.ccx().get_intrinsic(&name)
|
||||
}
|
||||
fn to_intrinsic_name(&self, tcx: &ty::ctxt, ty: Ty) -> &'static str {
|
||||
use syntax::ast::IntTy::*;
|
||||
use syntax::ast::UintTy::*;
|
||||
use rustc_front::hir::IntTy::*;
|
||||
use rustc_front::hir::UintTy::*;
|
||||
use middle::ty::{TyInt, TyUint};
|
||||
|
||||
let new_sty = match ty.sty {
|
||||
|
|
@ -2504,7 +2507,7 @@ fn build_unchecked_lshift<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
lhs: ValueRef,
|
||||
rhs: ValueRef,
|
||||
binop_debug_loc: DebugLoc) -> ValueRef {
|
||||
let rhs = base::cast_shift_expr_rhs(bcx, ast::BinOp_::BiShl, lhs, rhs);
|
||||
let rhs = base::cast_shift_expr_rhs(bcx, hir::BinOp_::BiShl, lhs, rhs);
|
||||
// #1877, #10183: Ensure that input is always valid
|
||||
let rhs = shift_mask_rhs(bcx, rhs, binop_debug_loc);
|
||||
Shl(bcx, lhs, rhs, binop_debug_loc)
|
||||
|
|
@ -2515,7 +2518,7 @@ fn build_unchecked_rshift<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
lhs: ValueRef,
|
||||
rhs: ValueRef,
|
||||
binop_debug_loc: DebugLoc) -> ValueRef {
|
||||
let rhs = base::cast_shift_expr_rhs(bcx, ast::BinOp_::BiShr, lhs, rhs);
|
||||
let rhs = base::cast_shift_expr_rhs(bcx, hir::BinOp_::BiShr, lhs, rhs);
|
||||
// #1877, #10183: Ensure that input is always valid
|
||||
let rhs = shift_mask_rhs(bcx, rhs, binop_debug_loc);
|
||||
let is_signed = lhs_t.is_signed();
|
||||
|
|
@ -2575,19 +2578,19 @@ enum ExprKind {
|
|||
RvalueStmt
|
||||
}
|
||||
|
||||
fn expr_kind(tcx: &ty::ctxt, expr: &ast::Expr) -> ExprKind {
|
||||
fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {
|
||||
if tcx.is_method_call(expr.id) {
|
||||
// Overloaded operations are generally calls, and hence they are
|
||||
// generated via DPS, but there are a few exceptions:
|
||||
return match expr.node {
|
||||
// `a += b` has a unit result.
|
||||
ast::ExprAssignOp(..) => ExprKind::RvalueStmt,
|
||||
hir::ExprAssignOp(..) => ExprKind::RvalueStmt,
|
||||
|
||||
// the deref method invoked for `*a` always yields an `&T`
|
||||
ast::ExprUnary(ast::UnDeref, _) => ExprKind::Lvalue,
|
||||
hir::ExprUnary(hir::UnDeref, _) => ExprKind::Lvalue,
|
||||
|
||||
// the index method invoked for `a[i]` always yields an `&T`
|
||||
ast::ExprIndex(..) => ExprKind::Lvalue,
|
||||
hir::ExprIndex(..) => ExprKind::Lvalue,
|
||||
|
||||
// in the general case, result could be any type, use DPS
|
||||
_ => ExprKind::RvalueDps
|
||||
|
|
@ -2595,7 +2598,7 @@ fn expr_kind(tcx: &ty::ctxt, expr: &ast::Expr) -> ExprKind {
|
|||
}
|
||||
|
||||
match expr.node {
|
||||
ast::ExprPath(..) => {
|
||||
hir::ExprPath(..) => {
|
||||
match tcx.resolve_expr(expr) {
|
||||
def::DefStruct(_) | def::DefVariant(..) => {
|
||||
if let ty::TyBareFn(..) = tcx.node_id_to_type(expr.id).sty {
|
||||
|
|
@ -2635,63 +2638,52 @@ fn expr_kind(tcx: &ty::ctxt, expr: &ast::Expr) -> ExprKind {
|
|||
}
|
||||
}
|
||||
|
||||
ast::ExprUnary(ast::UnDeref, _) |
|
||||
ast::ExprField(..) |
|
||||
ast::ExprTupField(..) |
|
||||
ast::ExprIndex(..) => {
|
||||
hir::ExprUnary(hir::UnDeref, _) |
|
||||
hir::ExprField(..) |
|
||||
hir::ExprTupField(..) |
|
||||
hir::ExprIndex(..) => {
|
||||
ExprKind::Lvalue
|
||||
}
|
||||
|
||||
ast::ExprCall(..) |
|
||||
ast::ExprMethodCall(..) |
|
||||
ast::ExprStruct(..) |
|
||||
ast::ExprRange(..) |
|
||||
ast::ExprTup(..) |
|
||||
ast::ExprIf(..) |
|
||||
ast::ExprMatch(..) |
|
||||
ast::ExprClosure(..) |
|
||||
ast::ExprBlock(..) |
|
||||
ast::ExprRepeat(..) |
|
||||
ast::ExprVec(..) => {
|
||||
hir::ExprCall(..) |
|
||||
hir::ExprMethodCall(..) |
|
||||
hir::ExprStruct(..) |
|
||||
hir::ExprRange(..) |
|
||||
hir::ExprTup(..) |
|
||||
hir::ExprIf(..) |
|
||||
hir::ExprMatch(..) |
|
||||
hir::ExprClosure(..) |
|
||||
hir::ExprBlock(..) |
|
||||
hir::ExprRepeat(..) |
|
||||
hir::ExprVec(..) => {
|
||||
ExprKind::RvalueDps
|
||||
}
|
||||
|
||||
ast::ExprIfLet(..) => {
|
||||
tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
|
||||
}
|
||||
ast::ExprWhileLet(..) => {
|
||||
tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
|
||||
}
|
||||
|
||||
ast::ExprForLoop(..) => {
|
||||
tcx.sess.span_bug(expr.span, "non-desugared ExprForLoop");
|
||||
}
|
||||
|
||||
ast::ExprLit(ref lit) if ast_util::lit_is_str(&**lit) => {
|
||||
hir::ExprLit(ref lit) if rustc_front::util::lit_is_str(&**lit) => {
|
||||
ExprKind::RvalueDps
|
||||
}
|
||||
|
||||
ast::ExprBreak(..) |
|
||||
ast::ExprAgain(..) |
|
||||
ast::ExprRet(..) |
|
||||
ast::ExprWhile(..) |
|
||||
ast::ExprLoop(..) |
|
||||
ast::ExprAssign(..) |
|
||||
ast::ExprInlineAsm(..) |
|
||||
ast::ExprAssignOp(..) => {
|
||||
hir::ExprBreak(..) |
|
||||
hir::ExprAgain(..) |
|
||||
hir::ExprRet(..) |
|
||||
hir::ExprWhile(..) |
|
||||
hir::ExprLoop(..) |
|
||||
hir::ExprAssign(..) |
|
||||
hir::ExprInlineAsm(..) |
|
||||
hir::ExprAssignOp(..) => {
|
||||
ExprKind::RvalueStmt
|
||||
}
|
||||
|
||||
ast::ExprLit(_) | // Note: LitStr is carved out above
|
||||
ast::ExprUnary(..) |
|
||||
ast::ExprBox(None, _) |
|
||||
ast::ExprAddrOf(..) |
|
||||
ast::ExprBinary(..) |
|
||||
ast::ExprCast(..) => {
|
||||
hir::ExprLit(_) | // Note: LitStr is carved out above
|
||||
hir::ExprUnary(..) |
|
||||
hir::ExprBox(None, _) |
|
||||
hir::ExprAddrOf(..) |
|
||||
hir::ExprBinary(..) |
|
||||
hir::ExprCast(..) => {
|
||||
ExprKind::RvalueDatum
|
||||
}
|
||||
|
||||
ast::ExprBox(Some(ref place), _) => {
|
||||
hir::ExprBox(Some(ref place), _) => {
|
||||
// Special case `Box<T>` for now:
|
||||
let def_id = match tcx.def_map.borrow().get(&place.id) {
|
||||
Some(def) => def.def_id(),
|
||||
|
|
@ -2704,12 +2696,6 @@ fn expr_kind(tcx: &ty::ctxt, expr: &ast::Expr) -> ExprKind {
|
|||
}
|
||||
}
|
||||
|
||||
ast::ExprParen(ref e) => expr_kind(tcx, &**e),
|
||||
|
||||
ast::ExprMac(..) => {
|
||||
tcx.sess.span_bug(
|
||||
expr.span,
|
||||
"macro expression remains after expansion");
|
||||
}
|
||||
hir::ExprParen(ref e) => expr_kind(tcx, &**e),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use back::{abi, link};
|
|||
use llvm::{ValueRef, CallConv, get_param};
|
||||
use llvm;
|
||||
use middle::weak_lang_items;
|
||||
use rustc::ast_map;
|
||||
use trans::attributes;
|
||||
use trans::base::{llvm_linkage_by_name, push_ctxt};
|
||||
use trans::base;
|
||||
|
|
@ -30,6 +29,7 @@ use trans::type_of::*;
|
|||
use trans::type_of;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::subst::Substs;
|
||||
use rustc::front::map as hir_map;
|
||||
|
||||
use std::cmp;
|
||||
use libc::c_uint;
|
||||
|
|
@ -38,8 +38,10 @@ use syntax::abi::{PlatformIntrinsic, RustIntrinsic, Rust, RustCall, Stdcall, Fas
|
|||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::{InternedString, special_idents};
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::print::pprust;
|
||||
|
||||
use rustc_front::print::pprust;
|
||||
use rustc_front::attr;
|
||||
use rustc_front::hir;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Type definitions
|
||||
|
|
@ -111,7 +113,7 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
|
|||
}
|
||||
|
||||
pub fn register_static(ccx: &CrateContext,
|
||||
foreign_item: &ast::ForeignItem) -> ValueRef {
|
||||
foreign_item: &hir::ForeignItem) -> ValueRef {
|
||||
let ty = ccx.tcx().node_id_to_type(foreign_item.id);
|
||||
let llty = type_of::type_of(ccx, ty);
|
||||
|
||||
|
|
@ -449,9 +451,9 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
// feature gate SIMD types in FFI, since I (huonw) am not sure the
|
||||
// ABIs are handled at all correctly.
|
||||
fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
|
||||
fn gate_simd_ffi(tcx: &ty::ctxt, decl: &hir::FnDecl, ty: &ty::BareFnTy) {
|
||||
if !tcx.sess.features.borrow().simd_ffi {
|
||||
let check = |ast_ty: &ast::Ty, ty: ty::Ty| {
|
||||
let check = |ast_ty: &hir::Ty, ty: ty::Ty| {
|
||||
if ty.is_simd() {
|
||||
tcx.sess.span_err(ast_ty.span,
|
||||
&format!("use of SIMD type `{}` in FFI is highly experimental and \
|
||||
|
|
@ -465,18 +467,18 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
|
|||
for (input, ty) in decl.inputs.iter().zip(&sig.inputs) {
|
||||
check(&*input.ty, *ty)
|
||||
}
|
||||
if let ast::Return(ref ty) = decl.output {
|
||||
if let hir::Return(ref ty) = decl.output {
|
||||
check(&**ty, sig.output.unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
|
||||
pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) {
|
||||
let _icx = push_ctxt("foreign::trans_foreign_mod");
|
||||
for foreign_item in &foreign_mod.items {
|
||||
let lname = link_name(&**foreign_item);
|
||||
|
||||
if let ast::ForeignItemFn(ref decl, _) = foreign_item.node {
|
||||
if let hir::ForeignItemFn(ref decl, _) = foreign_item.node {
|
||||
match foreign_mod.abi {
|
||||
Rust | RustIntrinsic | PlatformIntrinsic => {}
|
||||
abi => {
|
||||
|
|
@ -571,9 +573,9 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
|
|||
}
|
||||
|
||||
pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
attrs: &[ast::Attribute],
|
||||
decl: &hir::FnDecl,
|
||||
body: &hir::Block,
|
||||
attrs: &[hir::Attribute],
|
||||
llwrapfn: ValueRef,
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
id: ast::NodeId,
|
||||
|
|
@ -593,10 +595,10 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
|
||||
fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
decl: &hir::FnDecl,
|
||||
body: &hir::Block,
|
||||
param_substs: &'tcx Substs<'tcx>,
|
||||
attrs: &[ast::Attribute],
|
||||
attrs: &[hir::Attribute],
|
||||
id: ast::NodeId,
|
||||
hash: Option<&str>)
|
||||
-> ValueRef
|
||||
|
|
@ -607,7 +609,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
let t = monomorphize::apply_param_substs(tcx, param_substs, &t);
|
||||
|
||||
let ps = ccx.tcx().map.with_path(id, |path| {
|
||||
let abi = Some(ast_map::PathName(special_idents::clownshoe_abi.name));
|
||||
let abi = Some(hir_map::PathName(special_idents::clownshoe_abi.name));
|
||||
link::mangle(path.chain(abi), hash)
|
||||
});
|
||||
|
||||
|
|
@ -899,7 +901,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
// This code is kind of a confused mess and needs to be reworked given
|
||||
// the massive simplifications that have occurred.
|
||||
|
||||
pub fn link_name(i: &ast::ForeignItem) -> InternedString {
|
||||
pub fn link_name(i: &hir::ForeignItem) -> InternedString {
|
||||
match attr::first_attr_value_str_by_name(&i.attrs, "link_name") {
|
||||
Some(ln) => ln.clone(),
|
||||
None => match weak_lang_items::link_name(&i.attrs) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ use middle::subst::Substs;
|
|||
use trans::base::{push_ctxt, trans_item, get_item_val, trans_fn};
|
||||
use trans::common::*;
|
||||
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
|
||||
|
||||
fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
||||
-> Option<DefId> {
|
||||
|
|
@ -57,7 +58,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
|||
trans_item(ccx, item);
|
||||
|
||||
let linkage = match item.node {
|
||||
ast::ItemFn(_, _, _, _, ref generics, _) => {
|
||||
hir::ItemFn(_, _, _, _, ref generics, _) => {
|
||||
if generics.is_type_parameterized() {
|
||||
// Generics have no symbol, so they can't be given any
|
||||
// linkage.
|
||||
|
|
@ -78,7 +79,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::ItemConst(..) => None,
|
||||
hir::ItemConst(..) => None,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
|
@ -103,7 +104,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
|||
|
||||
let mut my_id = 0;
|
||||
match item.node {
|
||||
ast::ItemEnum(ref ast_def, _) => {
|
||||
hir::ItemEnum(ref ast_def, _) => {
|
||||
let ast_vs = &ast_def.variants;
|
||||
let ty_vs = &ccx.tcx().lookup_adt_def(parent_id).variants;
|
||||
assert_eq!(ast_vs.len(), ty_vs.len());
|
||||
|
|
@ -112,7 +113,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
|||
ccx.external().borrow_mut().insert(ty_v.did, Some(ast_v.node.id));
|
||||
}
|
||||
}
|
||||
ast::ItemStruct(ref struct_def, _) => {
|
||||
hir::ItemStruct(ref struct_def, _) => {
|
||||
match struct_def.ctor_id {
|
||||
None => ccx.sess().bug("instantiate_inline: called on a \
|
||||
non-tuple struct"),
|
||||
|
|
@ -158,7 +159,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
|||
ccx.stats().n_inlines.set(ccx.stats().n_inlines.get() + 1);
|
||||
|
||||
// Translate monomorphic impl methods immediately.
|
||||
if let ast::MethodImplItem(ref sig, ref body) = impl_item.node {
|
||||
if let hir::MethodImplItem(ref sig, ref body) = impl_item.node {
|
||||
let impl_tpt = ccx.tcx().lookup_item_type(impl_did);
|
||||
if impl_tpt.generics.types.is_empty() &&
|
||||
sig.generics.ty_params.is_empty() {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use trans::machine::llsize_of;
|
|||
use trans::type_::Type;
|
||||
use middle::ty::{self, Ty, HasTypeFlags};
|
||||
use middle::subst::Substs;
|
||||
use rustc_front::hir;
|
||||
use syntax::abi::{self, RustIntrinsic};
|
||||
use syntax::ast;
|
||||
use syntax::ptr::P;
|
||||
|
|
@ -45,7 +46,7 @@ use syntax::parse::token;
|
|||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Option<ValueRef> {
|
||||
pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Option<ValueRef> {
|
||||
let name = match &*item.ident.name.as_str() {
|
||||
"sqrtf32" => "llvm.sqrt.f32",
|
||||
"sqrtf64" => "llvm.sqrt.f64",
|
||||
|
|
@ -1373,7 +1374,7 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
|
|||
let tcx = ccx.tcx();
|
||||
let i8p = tcx.mk_mut_ptr(tcx.types.i8);
|
||||
let fn_ty = tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
unsafety: hir::Unsafety::Unsafe,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![i8p],
|
||||
|
|
@ -1384,7 +1385,7 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
|
|||
let fn_ty = tcx.mk_fn(None, fn_ty);
|
||||
let output = ty::FnOutput::FnConverging(i8p);
|
||||
let try_fn_ty = tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: ast::Unsafety::Unsafe,
|
||||
unsafety: hir::Unsafety::Unsafe,
|
||||
abi: abi::Rust,
|
||||
sig: ty::Binder(ty::FnSig {
|
||||
inputs: vec![fn_ty, i8p],
|
||||
|
|
@ -1402,7 +1403,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
|
|||
name: &str,
|
||||
substs: subst::Substs<'tcx>,
|
||||
callee_ty: Ty<'tcx>,
|
||||
args: Option<&[P<ast::Expr>]>,
|
||||
args: Option<&[P<hir::Expr>]>,
|
||||
llargs: &[ValueRef],
|
||||
ret_ty: Ty<'tcx>,
|
||||
llret_ty: Type,
|
||||
|
|
@ -1452,12 +1453,12 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
|
|||
let in_len = arg_tys[0].simd_size(tcx);
|
||||
|
||||
let comparison = match name {
|
||||
"simd_eq" => Some(ast::BiEq),
|
||||
"simd_ne" => Some(ast::BiNe),
|
||||
"simd_lt" => Some(ast::BiLt),
|
||||
"simd_le" => Some(ast::BiLe),
|
||||
"simd_gt" => Some(ast::BiGt),
|
||||
"simd_ge" => Some(ast::BiGe),
|
||||
"simd_eq" => Some(hir::BiEq),
|
||||
"simd_ne" => Some(hir::BiNe),
|
||||
"simd_lt" => Some(hir::BiLt),
|
||||
"simd_le" => Some(hir::BiLe),
|
||||
"simd_gt" => Some(hir::BiGt),
|
||||
"simd_ge" => Some(hir::BiGe),
|
||||
_ => None
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,14 @@ use trans::type_of::*;
|
|||
use middle::ty::{self, Ty, HasTypeFlags};
|
||||
use middle::ty::MethodCall;
|
||||
|
||||
use syntax::{ast, attr, visit};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::ptr::P;
|
||||
|
||||
use rustc_front::attr;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::hir;
|
||||
|
||||
// drop_glue pointer, size, align.
|
||||
const VTABLE_OFFSET: usize = 3;
|
||||
|
||||
|
|
@ -50,8 +54,8 @@ const VTABLE_OFFSET: usize = 3;
|
|||
/// see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
|
||||
pub fn trans_impl(ccx: &CrateContext,
|
||||
name: ast::Ident,
|
||||
impl_items: &[P<ast::ImplItem>],
|
||||
generics: &ast::Generics,
|
||||
impl_items: &[P<hir::ImplItem>],
|
||||
generics: &hir::Generics,
|
||||
id: ast::NodeId) {
|
||||
let _icx = push_ctxt("meth::trans_impl");
|
||||
let tcx = ccx.tcx();
|
||||
|
|
@ -65,7 +69,7 @@ pub fn trans_impl(ccx: &CrateContext,
|
|||
if !generics.ty_params.is_empty() {
|
||||
for impl_item in impl_items {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(..) => {
|
||||
hir::MethodImplItem(..) => {
|
||||
visit::walk_impl_item(&mut v, impl_item);
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -75,7 +79,7 @@ pub fn trans_impl(ccx: &CrateContext,
|
|||
}
|
||||
for impl_item in impl_items {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(ref sig, ref body) => {
|
||||
hir::MethodImplItem(ref sig, ref body) => {
|
||||
if sig.generics.ty_params.is_empty() {
|
||||
let trans_everywhere = attr::requests_inline(&impl_item.attrs);
|
||||
for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) {
|
||||
|
|
@ -98,7 +102,7 @@ pub fn trans_impl(ccx: &CrateContext,
|
|||
|
||||
pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
method_call: MethodCall,
|
||||
self_expr: Option<&ast::Expr>,
|
||||
self_expr: Option<&hir::Expr>,
|
||||
arg_cleanup_scope: cleanup::ScopeId)
|
||||
-> Callee<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("meth::trans_method_callee");
|
||||
|
|
@ -289,7 +293,7 @@ fn method_with_name(ccx: &CrateContext, impl_id: DefId, name: ast::Name)
|
|||
|
||||
fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
method_call: MethodCall,
|
||||
self_expr: Option<&ast::Expr>,
|
||||
self_expr: Option<&hir::Expr>,
|
||||
trait_id: DefId,
|
||||
method_id: DefId,
|
||||
method_ty: Ty<'tcx>,
|
||||
|
|
@ -416,7 +420,7 @@ fn combine_impl_and_methods_tps<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
fn trans_trait_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
opaque_fn_ty: Ty<'tcx>,
|
||||
vtable_index: usize,
|
||||
self_expr: &ast::Expr,
|
||||
self_expr: &hir::Expr,
|
||||
arg_cleanup_scope: cleanup::ScopeId)
|
||||
-> Callee<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("meth::trans_trait_callee");
|
||||
|
|
@ -769,7 +773,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
fn opaque_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>)
|
||||
-> &'tcx ty::BareFnTy<'tcx> {
|
||||
let mut inputs = method_ty.sig.0.inputs.clone();
|
||||
inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(ast::TyI8));
|
||||
inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(hir::TyI8));
|
||||
|
||||
tcx.mk_bare_fn(ty::BareFnTy {
|
||||
unsafety: method_ty.unsafety,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use middle::subst;
|
|||
use middle::subst::{Subst, Substs};
|
||||
use middle::traits;
|
||||
use middle::ty_fold::{TypeFolder, TypeFoldable};
|
||||
use rustc::ast_map;
|
||||
use trans::attributes;
|
||||
use trans::base::{trans_enum_variant, push_ctxt, get_item_val};
|
||||
use trans::base::trans_fn;
|
||||
|
|
@ -27,10 +26,13 @@ use trans::common::*;
|
|||
use trans::declare;
|
||||
use trans::foreign;
|
||||
use middle::ty::{self, HasTypeFlags, Ty};
|
||||
use rustc::front::map as hir_map;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::attr;
|
||||
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use std::hash::{Hasher, Hash, SipHasher};
|
||||
|
||||
|
|
@ -90,7 +92,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
fn_id)
|
||||
});
|
||||
|
||||
if let ast_map::NodeForeignItem(_) = map_node {
|
||||
if let hir_map::NodeForeignItem(_) = map_node {
|
||||
let abi = ccx.tcx().map.get_foreign_abi(fn_id.node);
|
||||
if abi != abi::RustIntrinsic && abi != abi::PlatformIntrinsic {
|
||||
// Foreign externs don't have to be monomorphized.
|
||||
|
|
@ -146,7 +148,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
|
||||
lldecl
|
||||
};
|
||||
let setup_lldecl = |lldecl, attrs: &[ast::Attribute]| {
|
||||
let setup_lldecl = |lldecl, attrs: &[hir::Attribute]| {
|
||||
base::update_linkage(ccx, lldecl, None, base::OriginalTranslation);
|
||||
attributes::from_fn_attrs(ccx, attrs, lldecl);
|
||||
|
||||
|
|
@ -167,10 +169,10 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
};
|
||||
|
||||
let lldecl = match map_node {
|
||||
ast_map::NodeItem(i) => {
|
||||
hir_map::NodeItem(i) => {
|
||||
match *i {
|
||||
ast::Item {
|
||||
node: ast::ItemFn(ref decl, _, _, abi, _, ref body),
|
||||
hir::Item {
|
||||
node: hir::ItemFn(ref decl, _, _, abi, _, ref body),
|
||||
..
|
||||
} => {
|
||||
let d = mk_lldecl(abi);
|
||||
|
|
@ -192,7 +194,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast_map::NodeVariant(v) => {
|
||||
hir_map::NodeVariant(v) => {
|
||||
let variant = inlined_variant_def(ccx, fn_id.node);
|
||||
assert_eq!(v.node.name.name, variant.name);
|
||||
let d = mk_lldecl(abi::Rust);
|
||||
|
|
@ -200,9 +202,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
trans_enum_variant(ccx, fn_id.node, variant.disr_val, psubsts, d);
|
||||
d
|
||||
}
|
||||
ast_map::NodeImplItem(impl_item) => {
|
||||
hir_map::NodeImplItem(impl_item) => {
|
||||
match impl_item.node {
|
||||
ast::MethodImplItem(ref sig, ref body) => {
|
||||
hir::MethodImplItem(ref sig, ref body) => {
|
||||
let d = mk_lldecl(abi::Rust);
|
||||
let needs_body = setup_lldecl(d, &impl_item.attrs);
|
||||
if needs_body {
|
||||
|
|
@ -222,9 +224,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast_map::NodeTraitItem(trait_item) => {
|
||||
hir_map::NodeTraitItem(trait_item) => {
|
||||
match trait_item.node {
|
||||
ast::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
hir::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
let d = mk_lldecl(abi::Rust);
|
||||
let needs_body = setup_lldecl(d, &trait_item.attrs);
|
||||
if needs_body {
|
||||
|
|
@ -239,7 +241,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast_map::NodeStructCtor(struct_def) => {
|
||||
hir_map::NodeStructCtor(struct_def) => {
|
||||
let d = mk_lldecl(abi::Rust);
|
||||
attributes::inline(d, attributes::InlineAttr::Hint);
|
||||
base::trans_tuple_struct(ccx,
|
||||
|
|
@ -251,15 +253,15 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
|
||||
// Ugh -- but this ensures any new variants won't be forgotten
|
||||
ast_map::NodeForeignItem(..) |
|
||||
ast_map::NodeLifetime(..) |
|
||||
ast_map::NodeTyParam(..) |
|
||||
ast_map::NodeExpr(..) |
|
||||
ast_map::NodeStmt(..) |
|
||||
ast_map::NodeArg(..) |
|
||||
ast_map::NodeBlock(..) |
|
||||
ast_map::NodePat(..) |
|
||||
ast_map::NodeLocal(..) => {
|
||||
hir_map::NodeForeignItem(..) |
|
||||
hir_map::NodeLifetime(..) |
|
||||
hir_map::NodeTyParam(..) |
|
||||
hir_map::NodeExpr(..) |
|
||||
hir_map::NodeStmt(..) |
|
||||
hir_map::NodeArg(..) |
|
||||
hir_map::NodeBlock(..) |
|
||||
hir_map::NodePat(..) |
|
||||
hir_map::NodeLocal(..) => {
|
||||
ccx.sess().bug(&format!("can't monomorphize a {:?}",
|
||||
map_node))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ use trans::type_::Type;
|
|||
use trans::type_of;
|
||||
use middle::ty::{self, Ty};
|
||||
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
|
||||
use syntax::parse::token::InternedString;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
@ -46,7 +47,7 @@ impl<'tcx> VecTypes<'tcx> {
|
|||
}
|
||||
|
||||
pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &ast::Expr,
|
||||
expr: &hir::Expr,
|
||||
dest: expr::Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
//!
|
||||
|
|
@ -76,8 +77,8 @@ pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
/// caller must make the reference). "..." is similar except that the memory can be statically
|
||||
/// allocated and we return a reference (strings are always by-ref).
|
||||
pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
slice_expr: &ast::Expr,
|
||||
content_expr: &ast::Expr)
|
||||
slice_expr: &hir::Expr,
|
||||
content_expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let fcx = bcx.fcx;
|
||||
let ccx = fcx.ccx;
|
||||
|
|
@ -89,8 +90,8 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let vec_ty = node_id_type(bcx, slice_expr.id);
|
||||
|
||||
// Handle the "..." case (returns a slice since strings are always unsized):
|
||||
if let ast::ExprLit(ref lit) = content_expr.node {
|
||||
if let ast::LitStr(ref s, _) = lit.node {
|
||||
if let hir::ExprLit(ref lit) = content_expr.node {
|
||||
if let hir::LitStr(ref s, _) = lit.node {
|
||||
let scratch = rvalue_scratch_datum(bcx, vec_ty, "");
|
||||
bcx = trans_lit_str(bcx,
|
||||
content_expr,
|
||||
|
|
@ -131,7 +132,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
/// Literal strings translate to slices into static memory. This is different from
|
||||
/// trans_slice_vstore() above because it doesn't need to copy the content anywhere.
|
||||
pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
lit_expr: &ast::Expr,
|
||||
lit_expr: &hir::Expr,
|
||||
str_lit: InternedString,
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
|
|
@ -155,8 +156,8 @@ pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
|
||||
fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
vt: &VecTypes<'tcx>,
|
||||
vstore_expr: &ast::Expr,
|
||||
content_expr: &ast::Expr,
|
||||
vstore_expr: &hir::Expr,
|
||||
content_expr: &hir::Expr,
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let _icx = push_ctxt("tvec::write_content");
|
||||
|
|
@ -169,9 +170,9 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
vstore_expr);
|
||||
|
||||
match content_expr.node {
|
||||
ast::ExprLit(ref lit) => {
|
||||
hir::ExprLit(ref lit) => {
|
||||
match lit.node {
|
||||
ast::LitStr(ref s, _) => {
|
||||
hir::LitStr(ref s, _) => {
|
||||
match dest {
|
||||
Ignore => return bcx,
|
||||
SaveIn(lldest) => {
|
||||
|
|
@ -193,7 +194,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::ExprVec(ref elements) => {
|
||||
hir::ExprVec(ref elements) => {
|
||||
match dest {
|
||||
Ignore => {
|
||||
for element in elements {
|
||||
|
|
@ -218,7 +219,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
return bcx;
|
||||
}
|
||||
ast::ExprRepeat(ref element, ref count_expr) => {
|
||||
hir::ExprRepeat(ref element, ref count_expr) => {
|
||||
match dest {
|
||||
Ignore => {
|
||||
return expr::trans_into(bcx, &**element, Ignore);
|
||||
|
|
@ -247,7 +248,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
fn vec_types_from_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, vec_expr: &ast::Expr)
|
||||
fn vec_types_from_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, vec_expr: &hir::Expr)
|
||||
-> VecTypes<'tcx> {
|
||||
let vec_ty = node_id_type(bcx, vec_expr.id);
|
||||
vec_types(bcx, vec_ty.sequence_element_type(bcx.tcx()))
|
||||
|
|
@ -261,21 +262,21 @@ fn vec_types<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, unit_ty: Ty<'tcx>)
|
|||
}
|
||||
}
|
||||
|
||||
fn elements_required(bcx: Block, content_expr: &ast::Expr) -> usize {
|
||||
fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
|
||||
//! Figure out the number of elements we need to store this content
|
||||
|
||||
match content_expr.node {
|
||||
ast::ExprLit(ref lit) => {
|
||||
hir::ExprLit(ref lit) => {
|
||||
match lit.node {
|
||||
ast::LitStr(ref s, _) => s.len(),
|
||||
hir::LitStr(ref s, _) => s.len(),
|
||||
_ => {
|
||||
bcx.tcx().sess.span_bug(content_expr.span,
|
||||
"unexpected evec content")
|
||||
}
|
||||
}
|
||||
},
|
||||
ast::ExprVec(ref es) => es.len(),
|
||||
ast::ExprRepeat(_, ref count_expr) => {
|
||||
hir::ExprVec(ref es) => es.len(),
|
||||
hir::ExprRepeat(_, ref count_expr) => {
|
||||
bcx.tcx().eval_repeat_count(&**count_expr)
|
||||
}
|
||||
_ => bcx.tcx().sess.span_bug(content_expr.span,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128};
|
|||
use trans::context::CrateContext;
|
||||
use util::nodemap::FnvHashMap;
|
||||
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::mem;
|
||||
|
|
@ -125,30 +125,30 @@ impl Type {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
|
||||
pub fn int_from_ty(ccx: &CrateContext, t: hir::IntTy) -> Type {
|
||||
match t {
|
||||
ast::TyIs => ccx.int_type(),
|
||||
ast::TyI8 => Type::i8(ccx),
|
||||
ast::TyI16 => Type::i16(ccx),
|
||||
ast::TyI32 => Type::i32(ccx),
|
||||
ast::TyI64 => Type::i64(ccx)
|
||||
hir::TyIs => ccx.int_type(),
|
||||
hir::TyI8 => Type::i8(ccx),
|
||||
hir::TyI16 => Type::i16(ccx),
|
||||
hir::TyI32 => Type::i32(ccx),
|
||||
hir::TyI64 => Type::i64(ccx)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
|
||||
pub fn uint_from_ty(ccx: &CrateContext, t: hir::UintTy) -> Type {
|
||||
match t {
|
||||
ast::TyUs => ccx.int_type(),
|
||||
ast::TyU8 => Type::i8(ccx),
|
||||
ast::TyU16 => Type::i16(ccx),
|
||||
ast::TyU32 => Type::i32(ccx),
|
||||
ast::TyU64 => Type::i64(ccx)
|
||||
hir::TyUs => ccx.int_type(),
|
||||
hir::TyU8 => Type::i8(ccx),
|
||||
hir::TyU16 => Type::i16(ccx),
|
||||
hir::TyU32 => Type::i32(ccx),
|
||||
hir::TyU64 => Type::i64(ccx)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn float_from_ty(ccx: &CrateContext, t: ast::FloatTy) -> Type {
|
||||
pub fn float_from_ty(ccx: &CrateContext, t: hir::FloatTy) -> Type {
|
||||
match t {
|
||||
ast::TyF32 => Type::f32(ccx),
|
||||
ast::TyF64 => Type::f64(ccx),
|
||||
hir::TyF32 => Type::f32(ccx),
|
||||
hir::TyF64 => Type::f64(ccx),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use middle::ty::{self, RegionEscape, Ty};
|
|||
use trans::type_::Type;
|
||||
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
|
||||
// LLVM doesn't like objects that are too big. Issue #17913
|
||||
fn ensure_array_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
|
@ -379,7 +379,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||
let unsized_part = cx.tcx().struct_tail(ty);
|
||||
let info_ty = match unsized_part.sty {
|
||||
ty::TyStr | ty::TyArray(..) | ty::TySlice(_) => {
|
||||
Type::uint_from_ty(cx, ast::TyUs)
|
||||
Type::uint_from_ty(cx, hir::TyUs)
|
||||
}
|
||||
ty::TyTrait(_) => Type::vtable_ptr(cx),
|
||||
_ => panic!("Unexpected type returned from \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue