mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
record io
This commit is contained in:
41
src/eval.js
41
src/eval.js
@@ -287,6 +287,7 @@ export const eval_modules = (
|
||||
external_imports,
|
||||
on_deferred_call,
|
||||
calltree_changed_token,
|
||||
io_cache,
|
||||
location
|
||||
) => {
|
||||
// TODO gensym __cxt, __trace, __trace_call
|
||||
@@ -295,6 +296,23 @@ export const eval_modules = (
|
||||
|
||||
const is_async = has_toplevel_await(parse_result.modules)
|
||||
|
||||
const Function = is_async
|
||||
? globalThis.run_window.eval('(async function(){})').constructor
|
||||
: globalThis.run_window.Function
|
||||
|
||||
const module_fns = parse_result.sorted.map(module => (
|
||||
{
|
||||
module,
|
||||
fn: new Function(
|
||||
'__cxt',
|
||||
'__trace',
|
||||
'__trace_call',
|
||||
'__do_await',
|
||||
codegen(parse_result.modules[module], {module})
|
||||
)
|
||||
}
|
||||
))
|
||||
|
||||
const cxt = {
|
||||
modules: external_imports == null
|
||||
? {}
|
||||
@@ -325,24 +343,7 @@ export const eval_modules = (
|
||||
Promise: globalThis.run_window.Promise,
|
||||
}
|
||||
|
||||
const Function = is_async
|
||||
? globalThis.run_window.eval('(async function(){})').constructor
|
||||
: globalThis.run_window.Function
|
||||
|
||||
const module_fns = parse_result.sorted.map(module => (
|
||||
{
|
||||
module,
|
||||
fn: new Function(
|
||||
'__cxt',
|
||||
'__trace',
|
||||
'__trace_call',
|
||||
'__do_await',
|
||||
codegen(parse_result.modules[module], {module})
|
||||
)
|
||||
}
|
||||
))
|
||||
|
||||
const result = run(module_fns, cxt)
|
||||
const result = run(module_fns, cxt, io_cache)
|
||||
|
||||
const make_result = result => ({
|
||||
modules: result.modules,
|
||||
@@ -350,14 +351,14 @@ export const eval_modules = (
|
||||
eval_cxt: result.eval_cxt,
|
||||
calltree: assign_code(parse_result.modules, result.calltree),
|
||||
call: result.call && assign_code(parse_result.modules, result.call),
|
||||
io_cache: result.eval_cxt.io_cache,
|
||||
})
|
||||
|
||||
if(result.then != null) {
|
||||
if(is_async) {
|
||||
return result.then(make_result)
|
||||
} else {
|
||||
return make_result(result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const eval_find_call = (cxt, parse_result, calltree, location) => {
|
||||
|
||||
Reference in New Issue
Block a user