@@ -42,7 +42,7 @@ pub struct EvalContext<'a, 'tcx: 'a> {
42
42
/// The virtual memory system.
43
43
memory : Memory < ' tcx > ,
44
44
45
- /// Precomputed statics, constants and promoteds
45
+ /// Precomputed statics, constants and promoteds.
46
46
statics : HashMap < ConstantId < ' tcx > , Pointer > ,
47
47
48
48
/// The virtual call stack.
@@ -51,20 +51,25 @@ pub struct EvalContext<'a, 'tcx: 'a> {
51
51
52
52
/// A stack frame.
53
53
pub struct Frame < ' a , ' tcx : ' a > {
54
- /// The def_id of the current function
55
- pub def_id : DefId ,
54
+ ////////////////////////////////////////////////////////////////////////////////
55
+ // Function and callsite information
56
+ ////////////////////////////////////////////////////////////////////////////////
56
57
57
- /// The span of the call site
58
- pub span : codemap:: Span ,
58
+ /// The MIR for the function called on this frame.
59
+ pub mir : CachedMir < ' a , ' tcx > ,
60
+
61
+ /// The def_id of the current function.
62
+ pub def_id : DefId ,
59
63
60
- /// type substitutions for the current function invocation
64
+ /// type substitutions for the current function invocation.
61
65
pub substs : & ' tcx Substs < ' tcx > ,
62
66
63
- /// The MIR for the function called on this frame .
64
- pub mir : CachedMir < ' a , ' tcx > ,
67
+ /// The span of the call site .
68
+ pub span : codemap :: Span ,
65
69
66
- /// The block that is currently executed (or will be executed after the above call stacks return)
67
- pub next_block : mir:: BasicBlock ,
70
+ ////////////////////////////////////////////////////////////////////////////////
71
+ // Return pointer and local allocations
72
+ ////////////////////////////////////////////////////////////////////////////////
68
73
69
74
/// A pointer for writing the return value of the current call if it's not a diverging call.
70
75
pub return_ptr : Option < Pointer > ,
@@ -80,7 +85,15 @@ pub struct Frame<'a, 'tcx: 'a> {
80
85
/// The offset of the first temporary in `self.locals`.
81
86
pub temp_offset : usize ,
82
87
83
- /// The index of the currently evaluated statment
88
+ ////////////////////////////////////////////////////////////////////////////////
89
+ // Current position within the function
90
+ ////////////////////////////////////////////////////////////////////////////////
91
+
92
+ /// The block that is currently executed (or will be executed after the above call stacks
93
+ /// return).
94
+ pub block : mir:: BasicBlock ,
95
+
96
+ /// The index of the currently evaluated statment.
84
97
pub stmt : usize ,
85
98
}
86
99
@@ -353,7 +366,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
353
366
354
367
self . stack . push ( Frame {
355
368
mir : mir. clone ( ) ,
356
- next_block : mir:: START_BLOCK ,
369
+ block : mir:: START_BLOCK ,
357
370
return_ptr : return_ptr,
358
371
locals : locals,
359
372
var_offset : num_args,
@@ -378,13 +391,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
378
391
Return => self . pop_stack_frame ( ) ,
379
392
380
393
Goto { target } => {
381
- self . frame_mut ( ) . next_block = target;
394
+ self . frame_mut ( ) . block = target;
382
395
} ,
383
396
384
397
If { ref cond, targets : ( then_target, else_target) } => {
385
398
let cond_ptr = self . eval_operand ( cond) ?;
386
399
let cond_val = self . memory . read_bool ( cond_ptr) ?;
387
- self . frame_mut ( ) . next_block = if cond_val { then_target } else { else_target } ;
400
+ self . frame_mut ( ) . block = if cond_val { then_target } else { else_target } ;
388
401
}
389
402
390
403
SwitchInt { ref discr, ref values, ref targets, .. } => {
@@ -407,7 +420,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
407
420
}
408
421
}
409
422
410
- self . frame_mut ( ) . next_block = target_block;
423
+ self . frame_mut ( ) . block = target_block;
411
424
}
412
425
413
426
Switch { ref discr, ref targets, adt_def } => {
@@ -419,7 +432,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
419
432
420
433
match matching {
421
434
Some ( i) => {
422
- self . frame_mut ( ) . next_block = targets[ i] ;
435
+ self . frame_mut ( ) . block = targets[ i] ;
423
436
} ,
424
437
None => return Err ( EvalError :: InvalidDiscriminant ) ,
425
438
}
@@ -428,7 +441,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
428
441
Call { ref func, ref args, ref destination, .. } => {
429
442
let mut return_ptr = None ;
430
443
if let Some ( ( ref lv, target) ) = * destination {
431
- self . frame_mut ( ) . next_block = target;
444
+ self . frame_mut ( ) . block = target;
432
445
return_ptr = Some ( self . eval_lvalue ( lv) ?. to_ptr ( ) ) ;
433
446
}
434
447
@@ -458,14 +471,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
458
471
let ptr = self . eval_lvalue ( location) ?. to_ptr ( ) ;
459
472
let ty = self . lvalue_ty ( location) ;
460
473
self . drop ( ptr, ty) ?;
461
- self . frame_mut ( ) . next_block = target;
474
+ self . frame_mut ( ) . block = target;
462
475
}
463
476
464
477
Assert { ref cond, expected, ref msg, target, cleanup } => {
465
478
let actual_ptr = self . eval_operand ( cond) ?;
466
479
let actual = self . memory . read_bool ( actual_ptr) ?;
467
480
if actual == expected {
468
- self . frame_mut ( ) . next_block = target;
481
+ self . frame_mut ( ) . block = target;
469
482
} else {
470
483
panic ! ( "unimplemented: jump to {:?} and print {:?}" , cleanup, msg) ;
471
484
}
0 commit comments