Summary: Show return value when stepping out of a function When stepping out of a function, or when stepping through an leaving it (paused at the closing brace) we should show the return value somewhere in the UI. Often it is the result of a computation and it would be useful for the user to see + interact with it.
<rdar://problem/28579565>
Created attachment 291853 [details] [WIP] Return Value when leaving function This didn't handle stepping out of Constructors, where the op_debug is not immediately before an op_return.
Created attachment 291854 [details] [WIP] Last Returned Value This adds in Last Return Value whenever you step over / step out of a function call.
After playing with these I believe they are a little too simplistic. They depend on op_ret which doesn't happen for Native/Host functions, so it ends up missing return values of host functions (e.g. the `undefined` from `console.log(1)`). I think a better approach would be: - When compiling with DebugHooks, replace op_call* with op_debug_call* - Which would be equivalent to: op_debug BeforeCall op_call ... op_debug AfterCall - Currently we have BeforeCall but not AfterCall. - BeforeCall is used as a pause opportunity. - AfterCall is can be used to save the return value for the next pause opportunity. - AfterCall may eventually be useful as a pause opportunity for stepping out. So that is why I put up two patches. I think we still end up taking the original patch for "Return Value when leaving function" because this is right before we are leaving the function. it just needs to address the Constructor edge case and get tests. However to get "Last Returned Value" working everywhere I think we need a better approach like the one above.