mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
refactor
This commit is contained in:
@@ -691,10 +691,7 @@ export const find_call = (state, index) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loc = {index: node.index, module: state.current_module}
|
const loc = {index: node.index, module: state.current_module}
|
||||||
const {calltree, call} = state.calltree_actions.find_call(
|
const {calltree, call} = state.calltree_actions.find_call(loc)
|
||||||
root_calltree_module(state),
|
|
||||||
loc
|
|
||||||
)
|
|
||||||
if(call == null) {
|
if(call == null) {
|
||||||
return add_calltree_node_by_loc(
|
return add_calltree_node_by_loc(
|
||||||
// Remove active_calltree_node
|
// Remove active_calltree_node
|
||||||
|
|||||||
20
src/eval.js
20
src/eval.js
@@ -310,9 +310,9 @@ export const eval_modules = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const find_call = (entrypoint, location) => {
|
const find_call = (location) => {
|
||||||
searched_location = location
|
searched_location = location
|
||||||
const calltree = run(entrypoint)
|
const calltree = run()
|
||||||
searched_location = null
|
searched_location = null
|
||||||
const call = found_call
|
const call = found_call
|
||||||
found_call = null
|
found_call = null
|
||||||
@@ -479,7 +479,7 @@ export const eval_modules = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = entrypoint => {
|
const run = () => {
|
||||||
|
|
||||||
is_recording_async_calls = false
|
is_recording_async_calls = false
|
||||||
|
|
||||||
@@ -540,10 +540,14 @@ export const eval_modules = (
|
|||||||
`
|
`
|
||||||
|
|
||||||
const actions = make_function(
|
const actions = make_function(
|
||||||
|
'entrypoint',
|
||||||
'external_imports',
|
'external_imports',
|
||||||
'on_async_call',
|
'on_async_call',
|
||||||
codestring
|
codestring
|
||||||
)(
|
)(
|
||||||
|
/* entrypoint */
|
||||||
|
sorted[sorted.length - 1],
|
||||||
|
|
||||||
/* external_imports */
|
/* external_imports */
|
||||||
external_imports == null
|
external_imports == null
|
||||||
? null
|
? null
|
||||||
@@ -561,8 +565,8 @@ export const eval_modules = (
|
|||||||
const expanded = actions.expand_calltree_node(node)
|
const expanded = actions.expand_calltree_node(node)
|
||||||
return assign_code(modules, expanded)
|
return assign_code(modules, expanded)
|
||||||
},
|
},
|
||||||
find_call: (entrypoint, loc) => {
|
find_call: (loc) => {
|
||||||
const {calltree, call} = actions.find_call(entrypoint, loc)
|
const {calltree, call} = actions.find_call(loc)
|
||||||
return {
|
return {
|
||||||
calltree: assign_code_calltree(modules, calltree),
|
calltree: assign_code_calltree(modules, calltree),
|
||||||
// TODO: `call` does not have `code` property here. Currently it is
|
// 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
|
let calltree, call
|
||||||
|
|
||||||
if(location == null) {
|
if(location == null) {
|
||||||
calltree = actions.run(entrypoint)
|
calltree = actions.run()
|
||||||
} else {
|
} else {
|
||||||
const result = calltree_actions.find_call(entrypoint, location)
|
const result = calltree_actions.find_call(location)
|
||||||
calltree = result.calltree
|
calltree = result.calltree
|
||||||
call = result.call
|
call = result.call
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user