debug!("expr_as_rvalue(block={:?}, expr={:?})", block, expr);
let this = self;
+ let scope_id = this.innermost_scope_id();
let expr_span = expr.span;
match expr.kind {
ExprKind::Scope { extent, value } => {
- this.in_scope(extent, block, |this| this.as_rvalue(block, value))
+ this.in_scope(extent, block, |this, _| this.as_rvalue(block, value))
}
- ExprKind::InlineAsm { asm } => {
- block.and(Rvalue::InlineAsm(asm.clone()))
+ ExprKind::InlineAsm { asm, outputs, inputs } => {
+ let outputs = outputs.into_iter().map(|output| {
+ unpack!(block = this.as_lvalue(block, output))
+ }).collect();
+
+ let inputs = inputs.into_iter().map(|input| {
+ unpack!(block = this.as_operand(block, input))
+ }).collect();
+
+ block.and(Rvalue::InlineAsm {
+ asm: asm.clone(),
+ outputs: outputs,
+ inputs: inputs
+ })
}
ExprKind::Repeat { value, count } => {
let value_operand = unpack!(block = this.as_operand(block, value));
let value = this.hir.mirror(value);
let result = this.temp(expr.ty);
// to start, malloc some memory of suitable type (thus far, uninitialized):
- this.cfg.push_assign(block, expr_span, &result, Rvalue::Box(value.ty));
- this.in_scope(value_extents, block, |this| {
+ this.cfg.push_assign(block, scope_id, expr_span, &result, Rvalue::Box(value.ty));
+ this.in_scope(value_extents, block, |this, _| {
// schedule a shallow free of that memory, lest we unwind:
this.schedule_box_free(expr_span, value_extents, &result, value.ty);
// initialize the box contents:
})
}
ExprKind::Cast { source } => {
- let source = unpack!(block = this.as_operand(block, source));
- block.and(Rvalue::Cast(CastKind::Misc, source, expr.ty))
+ let source = this.hir.mirror(source);
+ if source.ty == expr.ty {
+ this.expr_as_rvalue(block, source)
+ } else {
+ let source = unpack!(block = this.as_operand(block, source));
+ block.and(Rvalue::Cast(CastKind::Misc, source, expr.ty))
+ }
}
ExprKind::ReifyFnPointer { source } => {
let source = unpack!(block = this.as_operand(block, source));