Make ast::ExprKind
smaller.
This commit is contained in:
parent
6e9bf12c6f
commit
b60bcba9e4
@ -1208,36 +1208,30 @@ impl<'a> LoweringContext<'a> {
|
||||
ExprKind::Break(opt_ident) => hir::ExprBreak(self.lower_opt_sp_ident(opt_ident)),
|
||||
ExprKind::Continue(opt_ident) => hir::ExprAgain(self.lower_opt_sp_ident(opt_ident)),
|
||||
ExprKind::Ret(ref e) => hir::ExprRet(e.as_ref().map(|x| self.lower_expr(x))),
|
||||
ExprKind::InlineAsm(InlineAsm {
|
||||
ref inputs,
|
||||
ref outputs,
|
||||
ref asm,
|
||||
asm_str_style,
|
||||
ref clobbers,
|
||||
volatile,
|
||||
alignstack,
|
||||
dialect,
|
||||
expn_id,
|
||||
}) => hir::ExprInlineAsm(P(hir::InlineAsm {
|
||||
inputs: inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
|
||||
outputs: outputs.iter()
|
||||
.map(|out| {
|
||||
ExprKind::InlineAsm(ref asm) => {
|
||||
let hir_asm = hir::InlineAsm {
|
||||
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
|
||||
outputs: asm.outputs.iter().map(|out| {
|
||||
hir::InlineAsmOutput {
|
||||
constraint: out.constraint.clone(),
|
||||
is_rw: out.is_rw,
|
||||
is_indirect: out.is_indirect,
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
asm: asm.clone(),
|
||||
asm_str_style: asm_str_style,
|
||||
clobbers: clobbers.clone().into(),
|
||||
volatile: volatile,
|
||||
alignstack: alignstack,
|
||||
dialect: dialect,
|
||||
expn_id: expn_id,
|
||||
}), outputs.iter().map(|out| self.lower_expr(&out.expr)).collect(),
|
||||
inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect()),
|
||||
}).collect(),
|
||||
asm: asm.asm.clone(),
|
||||
asm_str_style: asm.asm_str_style,
|
||||
clobbers: asm.clobbers.clone().into(),
|
||||
volatile: asm.volatile,
|
||||
alignstack: asm.alignstack,
|
||||
dialect: asm.dialect,
|
||||
expn_id: asm.expn_id,
|
||||
};
|
||||
let outputs =
|
||||
asm.outputs.iter().map(|out| self.lower_expr(&out.expr)).collect();
|
||||
let inputs =
|
||||
asm.inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect();
|
||||
hir::ExprInlineAsm(P(hir_asm), outputs, inputs)
|
||||
}
|
||||
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => {
|
||||
hir::ExprStruct(self.lower_path(path),
|
||||
fields.iter().map(|x| self.lower_field(x)).collect(),
|
||||
|
@ -1050,7 +1050,7 @@ pub enum ExprKind {
|
||||
Ret(Option<P<Expr>>),
|
||||
|
||||
/// Output of the `asm!()` macro
|
||||
InlineAsm(InlineAsm),
|
||||
InlineAsm(P<InlineAsm>),
|
||||
|
||||
/// A macro invocation; pre-expansion
|
||||
Mac(Mac),
|
||||
|
@ -1249,21 +1249,12 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
|
||||
folder.fold_ident(label.node)))
|
||||
),
|
||||
ExprKind::Ret(e) => ExprKind::Ret(e.map(|x| folder.fold_expr(x))),
|
||||
ExprKind::InlineAsm(InlineAsm {
|
||||
inputs,
|
||||
outputs,
|
||||
asm,
|
||||
asm_str_style,
|
||||
clobbers,
|
||||
volatile,
|
||||
alignstack,
|
||||
dialect,
|
||||
expn_id,
|
||||
}) => ExprKind::InlineAsm(InlineAsm {
|
||||
inputs: inputs.move_map(|(c, input)| {
|
||||
ExprKind::InlineAsm(asm) => ExprKind::InlineAsm(asm.map(|asm| {
|
||||
InlineAsm {
|
||||
inputs: asm.inputs.move_map(|(c, input)| {
|
||||
(c, folder.fold_expr(input))
|
||||
}),
|
||||
outputs: outputs.move_map(|out| {
|
||||
outputs: asm.outputs.move_map(|out| {
|
||||
InlineAsmOutput {
|
||||
constraint: out.constraint,
|
||||
expr: folder.fold_expr(out.expr),
|
||||
@ -1271,14 +1262,9 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
|
||||
is_indirect: out.is_indirect,
|
||||
}
|
||||
}),
|
||||
asm: asm,
|
||||
asm_str_style: asm_str_style,
|
||||
clobbers: clobbers,
|
||||
volatile: volatile,
|
||||
alignstack: alignstack,
|
||||
dialect: dialect,
|
||||
expn_id: expn_id,
|
||||
}),
|
||||
..asm
|
||||
}
|
||||
})),
|
||||
ExprKind::Mac(mac) => ExprKind::Mac(folder.fold_mac(mac)),
|
||||
ExprKind::Struct(path, fields, maybe_expr) => {
|
||||
ExprKind::Struct(folder.fold_path(path),
|
||||
|
@ -250,7 +250,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
|
||||
|
||||
MacEager::expr(P(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::ExprKind::InlineAsm(ast::InlineAsm {
|
||||
node: ast::ExprKind::InlineAsm(P(ast::InlineAsm {
|
||||
asm: token::intern_and_get_ident(&asm),
|
||||
asm_str_style: asm_str_style.unwrap(),
|
||||
outputs: outputs,
|
||||
@ -260,7 +260,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
|
||||
alignstack: alignstack,
|
||||
dialect: dialect,
|
||||
expn_id: expn_id,
|
||||
}),
|
||||
})),
|
||||
span: sp,
|
||||
attrs: ast::ThinVec::new(),
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user