diff options
| author | Michael Woerister <michaelwoerister@posteo.net> | 2015-12-08 15:53:19 -0500 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2015-12-10 16:59:31 -0500 |
| commit | 5addc31adb558da1613c8f9748ee05688f6eaf91 (patch) | |
| tree | 63ff7e3fe6c4599d03cd82708098a9041297cb51 /src/librustc/mir | |
| parent | 8eee116cb8532d5879cbef6af4a59d563d4fb644 (diff) | |
| download | rust-5addc31adb558da1613c8f9748ee05688f6eaf91.tar.gz rust-5addc31adb558da1613c8f9748ee05688f6eaf91.zip | |
Make MIR encodable and store it in crate metadata.
Diffstat (limited to 'src/librustc/mir')
| -rw-r--r-- | src/librustc/mir/repr.rs | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/librustc/mir/repr.rs b/src/librustc/mir/repr.rs index bbc2464c117..049063f73a5 100644 --- a/src/librustc/mir/repr.rs +++ b/src/librustc/mir/repr.rs @@ -21,6 +21,7 @@ use std::fmt::{Debug, Formatter, Error}; use std::u32; /// Lowered representation of a single function. +#[derive(RustcEncodable, RustcDecodable)] pub struct Mir<'tcx> { /// List of basic blocks. References to basic block use a newtyped index type `BasicBlock` /// that indexes into this vector. @@ -71,13 +72,13 @@ impl<'tcx> Mir<'tcx> { /////////////////////////////////////////////////////////////////////////// // Mutability and borrow kinds -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum Mutability { Mut, Not, } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum BorrowKind { /// Data must be immutable and is aliasable. Shared, @@ -128,6 +129,7 @@ pub enum BorrowKind { // A "variable" is a binding declared by the user as part of the fn // decl, a let, etc. +#[derive(RustcEncodable, RustcDecodable)] pub struct VarDecl<'tcx> { pub mutability: Mutability, pub name: Name, @@ -136,6 +138,7 @@ pub struct VarDecl<'tcx> { // A "temp" is a temporary that we place on the stack. They are // anonymous, always mutable, and have only a type. +#[derive(RustcEncodable, RustcDecodable)] pub struct TempDecl<'tcx> { pub ty: Ty<'tcx>, } @@ -151,6 +154,7 @@ pub struct TempDecl<'tcx> { // // there is only one argument, of type `(i32, u32)`, but two bindings // (`x` and `y`). +#[derive(RustcEncodable, RustcDecodable)] pub struct ArgDecl<'tcx> { pub ty: Ty<'tcx>, } @@ -162,7 +166,7 @@ pub struct ArgDecl<'tcx> { /// list of the `Mir`. /// /// (We use a `u32` internally just to save memory.) -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub struct BasicBlock(u32); impl BasicBlock { @@ -186,12 +190,13 @@ impl Debug for BasicBlock { /////////////////////////////////////////////////////////////////////////// // BasicBlock and Terminator -#[derive(Debug)] +#[derive(Debug, RustcEncodable, RustcDecodable)] pub struct BasicBlockData<'tcx> { pub statements: Vec<Statement<'tcx>>, pub terminator: Terminator<'tcx>, } +#[derive(RustcEncodable, RustcDecodable)] pub enum Terminator<'tcx> { /// block should have one successor in the graph; we jump there Goto { @@ -289,7 +294,7 @@ impl<'tcx> Terminator<'tcx> { } } -#[derive(Debug)] +#[derive(Debug, RustcEncodable, RustcDecodable)] pub struct CallData<'tcx> { /// where the return value is written to pub destination: Lvalue<'tcx>, @@ -346,18 +351,19 @@ impl<'tcx> Debug for Terminator<'tcx> { /////////////////////////////////////////////////////////////////////////// // Statements +#[derive(RustcEncodable, RustcDecodable)] pub struct Statement<'tcx> { pub span: Span, pub kind: StatementKind<'tcx>, } -#[derive(Debug)] +#[derive(Debug, RustcEncodable, RustcDecodable)] pub enum StatementKind<'tcx> { Assign(Lvalue<'tcx>, Rvalue<'tcx>), Drop(DropKind, Lvalue<'tcx>), } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum DropKind { Free, // free a partially constructed box, should go away eventually Deep @@ -378,7 +384,7 @@ impl<'tcx> Debug for Statement<'tcx> { /// A path to a value; something that can be evaluated without /// changing or disturbing program state. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable)] pub enum Lvalue<'tcx> { /// local variable declared by the user Var(u32), @@ -404,13 +410,13 @@ pub enum Lvalue<'tcx> { /// or `*B` or `B[index]`. Note that it is parameterized because it is /// shared between `Constant` and `Lvalue`. See the aliases /// `LvalueProjection` etc below. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] pub struct Projection<'tcx, B, V> { pub base: B, pub elem: ProjectionElem<'tcx, V>, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] pub enum ProjectionElem<'tcx, V> { Deref, Field(Field), @@ -448,7 +454,7 @@ pub type LvalueElem<'tcx> = ProjectionElem<'tcx,Operand<'tcx>>; /// Index into the list of fields found in a `VariantDef` -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] pub struct Field(u32); impl Field { @@ -524,7 +530,7 @@ impl<'tcx> Debug for Lvalue<'tcx> { // lvalue). They are intentionally limited to prevent rvalues from // being nested in one another. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable)] pub enum Operand<'tcx> { Consume(Lvalue<'tcx>), Constant(Constant<'tcx>), @@ -543,7 +549,7 @@ impl<'tcx> Debug for Operand<'tcx> { /////////////////////////////////////////////////////////////////////////// // Rvalues -#[derive(Clone)] +#[derive(Clone, RustcEncodable, RustcDecodable)] pub enum Rvalue<'tcx> { // x (either a move or copy, depending on type of x) Use(Operand<'tcx>), @@ -587,7 +593,7 @@ pub enum Rvalue<'tcx> { InlineAsm(InlineAsm), } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum CastKind { Misc, @@ -605,7 +611,7 @@ pub enum CastKind { Unsize, } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum AggregateKind<'tcx> { Vec, Tuple, @@ -613,7 +619,7 @@ pub enum AggregateKind<'tcx> { Closure(DefId, &'tcx ClosureSubsts<'tcx>), } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum BinOp { /// The `+` operator (addition) Add, @@ -649,7 +655,7 @@ pub enum BinOp { Gt, } -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum UnOp { /// The `!` operator for logical inversion Not, @@ -685,14 +691,14 @@ impl<'tcx> Debug for Rvalue<'tcx> { // this does not necessarily mean that they are "==" in Rust -- in // particular one must be wary of `NaN`! -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] pub struct Constant<'tcx> { pub span: Span, pub ty: Ty<'tcx>, pub literal: Literal<'tcx>, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] pub enum Literal<'tcx> { Item { def_id: DefId, |
