]>
git.proxmox.com Git - rustc.git/blob - src/librustc_trans/trans/mir/statement.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use rustc
::mir
::repr
as mir
;
12 use trans
::common
::BlockAndBuilder
;
14 use super::MirContext
;
17 impl<'bcx
, 'tcx
> MirContext
<'bcx
, 'tcx
> {
18 pub fn trans_statement(&mut self,
19 bcx
: BlockAndBuilder
<'bcx
, 'tcx
>,
20 statement
: &mir
::Statement
<'tcx
>)
21 -> BlockAndBuilder
<'bcx
, 'tcx
> {
22 debug
!("trans_statement(statement={:?})", statement
);
24 match statement
.kind
{
25 mir
::StatementKind
::Assign(ref lvalue
, ref rvalue
) => {
27 mir
::Lvalue
::Temp(index
) => {
28 let index
= index
as usize;
29 match self.temps
[index
as usize] {
30 TempRef
::Lvalue(tr_dest
) => {
31 self.trans_rvalue(bcx
, tr_dest
, rvalue
)
33 TempRef
::Operand(None
) => {
34 let (bcx
, operand
) = self.trans_rvalue_operand(bcx
, rvalue
);
35 self.temps
[index
] = TempRef
::Operand(Some(operand
));
38 TempRef
::Operand(Some(_
)) => {
39 bcx
.tcx().sess
.span_bug(
41 &format
!("operand {:?} already assigned", rvalue
));
46 let tr_dest
= self.trans_lvalue(&bcx
, lvalue
);
47 self.trans_rvalue(bcx
, tr_dest
, rvalue
)