async calls find_call and test async call nav

This commit is contained in:
Dmitry Vasilev
2022-11-24 04:41:34 +08:00
parent 7fa3e78db3
commit 9a8e86a390
3 changed files with 186 additions and 56 deletions

View File

@@ -606,7 +606,7 @@ export const find_call = (state, index) => {
if(ct_node_id != null) {
const ct_node = find_node(
root_calltree_node(state),
state.calltree,
n => n.id == ct_node_id
)
if(ct_node == null) {
@@ -630,7 +630,12 @@ export const find_call = (state, index) => {
}
const loc = {index: node.index, module: state.current_module}
const {calltree, call} = state.calltree_actions.find_call(
const {
calltree,
call,
is_found_async_call,
async_call_index
} = state.calltree_actions.find_call(
loc,
get_async_calls(state)
)
@@ -645,20 +650,41 @@ export const find_call = (state, index) => {
)
}
const merged = make_calltree(
merge_calltrees(root_calltree_node(state), calltree),
get_async_calls(state),
)
let next_calltree, active_calltree_node
const active_calltree_node = find_same_node(
root_calltree_node({calltree: merged}),
calltree,
call.id
)
if(is_found_async_call) {
const async_calls = get_async_calls(state)
const prev_call = async_calls[async_call_index]
const merged = merge_calltrees(prev_call, calltree)
const next_async_calls = async_calls.map((c, i) =>
i == async_call_index
? merged
: c
)
next_calltree = make_calltree(
root_calltree_node(state),
next_async_calls,
)
active_calltree_node = find_same_node(
merged,
calltree,
call.id
)
} else {
next_calltree = make_calltree(
merge_calltrees(root_calltree_node(state), calltree),
get_async_calls(state),
)
active_calltree_node = find_same_node(
root_calltree_node({calltree: next_calltree}),
calltree,
call.id
)
}
return add_frame(
expand_path(
{...state, calltree: merged},
{...state, calltree: next_calltree},
active_calltree_node
),
active_calltree_node,

View File

@@ -312,19 +312,40 @@ export const eval_modules = (
const find_call = (location, async_calls) => {
searched_location = location
const {modules, calltree} = run()
let is_found_async_call = false
let i
let {calltree} = run()
is_recording_async_calls = false
if(found_call == null && async_calls != null) {
for(let c of async_calls) {
c.fn.apply(c.context, c.args)
for(i = 0; i < async_calls.length; i++) {
const c = async_calls[i]
try {
c.fn.apply(c.context, c.args)
} catch(e) {
// do nothing. Exception was caught and recorded inside 'trace'
}
if(found_call != null) {
is_found_async_call = true
calltree = children[0]
children = null
break
}
}
}
is_recording_async_calls = true
searched_location = null
const call = found_call
found_call = null
return {modules, calltree, call}
return {
is_found_async_call,
async_call_index: i,
calltree,
call
}
}
const trace = (fn, name, argscount, __location, get_closure) => {
@@ -563,8 +584,15 @@ export const eval_modules = (
return assign_code(parse_result.modules, expanded)
},
find_call: (loc, async_calls) => {
const {modules, calltree, call} = actions.find_call(loc, async_calls)
const {
is_found_async_call,
async_call_index,
calltree,
call
} = actions.find_call(loc, async_calls)
return {
is_found_async_call,
async_call_index,
calltree: assign_code(parse_result.modules, calltree),
// TODO: `call` does not have `code` property here. Currently it is
// worked around by callers. Refactor