This commit is contained in:
Dmitry Vasilev
2022-12-02 08:49:50 +08:00
parent 9d551ce4f6
commit e235704455

View File

@@ -170,8 +170,11 @@ const do_external_imports_loaded = (
const node = find_call_node(state, index) const node = find_call_node(state, index)
let active_calltree_node, next
if( if(
// edit module that is not imported (maybe recursively by state.entrypoint) // edit module that is not imported (maybe recursively by state.entrypoint)
// TODO if module not imported, then do not run code on edit at all
node == null node == null
|| ||
node.type == 'do' /* toplevel AST node */ node.type == 'do' /* toplevel AST node */
@@ -182,45 +185,10 @@ const do_external_imports_loaded = (
state.on_deferred_call, state.on_deferred_call,
state.calltree_changed_token, state.calltree_changed_token,
) )
const next = apply_eval_result(state, result) next = apply_eval_result(state, result)
if(node == state.parse_result.modules[root_calltree_module(next)]) { if(node == state.parse_result.modules[root_calltree_module(next)]) {
const toplevel = root_calltree_node(next) active_calltree_node = root_calltree_node(next)
return add_frame(
default_expand_path(
next,
toplevel
),
toplevel,
)
} else {
const {node, state: next2} = initial_calltree_node(next)
return set_active_calltree_node(next2, null, node)
}
}
const result = eval_modules(
state.parse_result,
external_imports,
state.on_deferred_call,
state.calltree_changed_token,
{index: node.index, module: state.current_module},
)
if(result.call == null) {
// Unreachable call
const {node, state: next} = initial_calltree_node(
apply_eval_result(state, result)
)
return set_active_calltree_node(next, null, node)
}
const next = apply_eval_result(state, result)
// We cannot use `call` because `code` was not assigned to it
const active_calltree_node = find_node(root_calltree_node(next),
n => n.id == result.call.id
)
return add_frame( return add_frame(
default_expand_path( default_expand_path(
expand_path( expand_path(
@@ -230,6 +198,45 @@ const do_external_imports_loaded = (
), ),
active_calltree_node, active_calltree_node,
) )
} else {
active_calltree_node = null
}
} else {
const result = eval_modules(
state.parse_result,
external_imports,
state.on_deferred_call,
state.calltree_changed_token,
{index: node.index, module: state.current_module},
)
next = apply_eval_result(state, result)
if(result.call == null) {
// Unreachable call
active_calltree_node = null
} else {
// We cannot use `call` because `code` was not assigned to it
active_calltree_node = find_node(root_calltree_node(next),
n => n.id == result.call.id
)
}
}
if(active_calltree_node == null) {
const {node, state: next2} = initial_calltree_node(next)
return set_active_calltree_node(next2, null, node)
} else {
return add_frame(
default_expand_path(
expand_path(
next,
active_calltree_node
)
),
active_calltree_node,
)
}
} }
const external_imports_loaded = ( const external_imports_loaded = (