From b6942d846b3d51ebb28e96be72cb457efc581d8a Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Tue, 15 Nov 2022 15:03:19 +0800 Subject: [PATCH] refactor --- src/calltree.js | 5 +---- src/eval.js | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/calltree.js b/src/calltree.js index 1e6337a..fd915b6 100644 --- a/src/calltree.js +++ b/src/calltree.js @@ -691,10 +691,7 @@ export const find_call = (state, index) => { } const loc = {index: node.index, module: state.current_module} - const {calltree, call} = state.calltree_actions.find_call( - root_calltree_module(state), - loc - ) + const {calltree, call} = state.calltree_actions.find_call(loc) if(call == null) { return add_calltree_node_by_loc( // Remove active_calltree_node diff --git a/src/eval.js b/src/eval.js index e0a5031..cb812bd 100644 --- a/src/eval.js +++ b/src/eval.js @@ -310,9 +310,9 @@ export const eval_modules = ( } } - const find_call = (entrypoint, location) => { + const find_call = (location) => { searched_location = location - const calltree = run(entrypoint) + const calltree = run() searched_location = null const call = found_call found_call = null @@ -479,7 +479,7 @@ export const eval_modules = ( } } - const run = entrypoint => { + const run = () => { is_recording_async_calls = false @@ -540,10 +540,14 @@ export const eval_modules = ( ` const actions = make_function( + 'entrypoint', 'external_imports', 'on_async_call', codestring )( + /* entrypoint */ + sorted[sorted.length - 1], + /* external_imports */ external_imports == null ? null @@ -561,8 +565,8 @@ export const eval_modules = ( const expanded = actions.expand_calltree_node(node) return assign_code(modules, expanded) }, - find_call: (entrypoint, loc) => { - const {calltree, call} = actions.find_call(entrypoint, loc) + find_call: (loc) => { + const {calltree, call} = actions.find_call(loc) return { calltree: assign_code_calltree(modules, calltree), // TODO: `call` does not have `code` property here. Currently it is @@ -572,14 +576,12 @@ export const eval_modules = ( } } - const entrypoint = sorted[sorted.length - 1] - let calltree, call if(location == null) { - calltree = actions.run(entrypoint) + calltree = actions.run() } else { - const result = calltree_actions.find_call(entrypoint, location) + const result = calltree_actions.find_call(location) calltree = result.calltree call = result.call }