Skip to content

Commit

Permalink
Reuse previous location when we don't have a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
SupernaviX committed Sep 18, 2024
1 parent ec40e83 commit e8892e6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions gastronomy/src/execution_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,19 @@ pub fn parse_raw_frames<'a>(
let mut prev_mem = 0;
for (state, budget) in states {
let (label, context, env, term, location, ret_value) = match state {
MachineState::Compute(context, env, term) => (
"Compute",
context,
env,
term,
term.index().and_then(|i| source_map.get(&i)),
None,
),
MachineState::Compute(context, env, term) => {
let prev_location = frames.last().and_then(|f: &RawFrame<'_>| f.location);
(
"Compute",
context,
env,
term,
term.index()
.and_then(|i| source_map.get(&i))
.or(prev_location),
None,
)
}
MachineState::Done(term) => {
let prev_frame: &RawFrame =
frames.last().expect("Invalid program starts with return");
Expand All @@ -100,7 +105,9 @@ pub fn parse_raw_frames<'a>(
prev_frame.context,
prev_frame.env,
term,
term.index().and_then(|i| source_map.get(&i)),
term.index()
.and_then(|i| source_map.get(&i))
.or(prev_frame.location),
None,
)
}
Expand Down

0 comments on commit e8892e6

Please sign in to comment.