@@ -55,18 +55,18 @@ Before the evaluation, a virtual memory location (in this case essentially a
55
55
` vec![u8; 4] ` or ` vec![u8; 8] ` ) is created for storing the evaluation result.
56
56
57
57
At the start of the evaluation, ` _0 ` and ` _1 ` are
58
- ` Value::ByVal(PrimVal ::Undef)` . When the initialization of ` _1 ` is invoked, the
58
+ ` ConstValue::Scalar(Scalar ::Undef)` . When the initialization of ` _1 ` is invoked, the
59
59
value of the ` FOO ` constant is required, and triggers another call to
60
60
` tcx.const_eval ` , which will not be shown here. If the evaluation of FOO is
61
61
successful, 42 will be subtracted by its value ` 4096 ` and the result stored in
62
- ` _1 ` as ` Value::ByValPair(PrimVal ::Bytes(4054), PrimVal ::Bytes(0))` . The first
62
+ ` _1 ` as ` ConstValue::ScalarPair(Scalar ::Bytes(4054), Scalar ::Bytes(0))` . The first
63
63
part of the pair is the computed value, the second part is a bool that's true if
64
64
an overflow happened.
65
65
66
66
The next statement asserts that said boolean is ` 0 ` . In case the assertion
67
67
fails, its error message is used for reporting a compile-time error.
68
68
69
- Since it does not fail, ` Value::ByVal(PrimVal ::Bytes(4054))` is stored in the
69
+ Since it does not fail, ` ConstValue::Scalar(Scalar ::Bytes(4054))` is stored in the
70
70
virtual memory was allocated before the evaluation. ` _0 ` always refers to that
71
71
location directly.
72
72
@@ -75,23 +75,23 @@ After the evaluation is done, the virtual memory allocation is interned into the
75
75
miri, but just extract the value from the interned allocation.
76
76
77
77
The ` tcx.const_eval ` function has one additional feature: it will not return a
78
- ` ByRef(interned_allocation_id) ` , but a ` ByVal (computed_value)` if possible. This
78
+ ` ByRef(interned_allocation_id) ` , but a ` Scalar (computed_value)` if possible. This
79
79
makes using the result much more convenient, as no further queries need to be
80
80
executed in order to get at something as simple as a ` usize ` .
81
81
82
82
## Datastructures
83
83
84
84
Miri's core datastructures can be found in
85
85
[ librustc/mir/interpret] ( https://github.com/rust-lang/rust/blob/master/src/librustc/mir/interpret ) .
86
- This is mainly the error enum and the ` Value ` and ` PrimVal ` types. A ` Value ` can
87
- be either ` ByVal ` (a single ` PrimVal ` ), ` ByValPair ` (two ` PrimVal ` s, usually fat
86
+ This is mainly the error enum and the ` ConstValue ` and ` Scalar ` types. A ` ConstValue ` can
87
+ be either ` Scalar ` (a single ` Scalar ` ), ` ScalarPair ` (two ` Scalar ` s, usually fat
88
88
pointers or two element tuples) or ` ByRef ` , which is used for anything else and
89
89
refers to a virtual allocation. These allocations can be accessed via the
90
90
methods on ` tcx.interpret_interner ` .
91
91
92
92
If you are expecting a numeric result, you can use ` unwrap_u64 ` (panics on
93
93
anything that can't be representad as a ` u64 ` ) or ` to_raw_bits ` which results
94
- in an ` Option<u128> ` yielding the ` ByVal ` if possible.
94
+ in an ` Option<u128> ` yielding the ` Scalar ` if possible.
95
95
96
96
## Allocations
97
97
@@ -113,7 +113,7 @@ to a pointer to `b`.
113
113
Although the main entry point to constant evaluation is the ` tcx.const_eval `
114
114
query, there are additional functions in
115
115
[ librustc_mir/const_eval.rs] ( https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/index.html )
116
- that allow accessing the fields of a ` Value ` (` ByRef ` or otherwise). You should
116
+ that allow accessing the fields of a ` ConstValue ` (` ByRef ` or otherwise). You should
117
117
never have to access an ` Allocation ` directly except for translating it to the
118
118
compilation target (at the moment just LLVM).
119
119
0 commit comments