mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
refactor children -> __children
This commit is contained in:
24
src/eval.js
24
src/eval.js
@@ -216,7 +216,11 @@ const codegen = (node, cxt, parent) => {
|
||||
+ do_codegen(node.property)
|
||||
+ ']'
|
||||
} else if(node.type == 'unary') {
|
||||
return '(' + node.operator + ' ' + do_codegen(node.expr) + ')'
|
||||
if(node.operator == 'await') {
|
||||
return `(await __with_restore_children(${do_codegen(node.expr)}))`
|
||||
} else {
|
||||
return '(' + node.operator + ' ' + do_codegen(node.expr) + ')'
|
||||
}
|
||||
} else if(node.type == 'binary'){
|
||||
return ''
|
||||
+ do_codegen(node.args[0])
|
||||
@@ -267,7 +271,7 @@ export const eval_modules = (
|
||||
calltree_changed_token,
|
||||
location
|
||||
) => {
|
||||
// TODO gensym __modules, __exports
|
||||
// TODO gensym __modules, __exports, children
|
||||
|
||||
// TODO bug if module imported twice, once as external and as regular
|
||||
|
||||
@@ -365,6 +369,22 @@ export const eval_modules = (
|
||||
}
|
||||
}
|
||||
|
||||
const __with_restore_children = async value => {
|
||||
// children is an array of child calls for current function call. But it
|
||||
// can be null to save one empty array allocation in case it has no child
|
||||
// calls. Allocate array now, so we can have a reference to this array
|
||||
// which will be used after await
|
||||
if(children == null) {
|
||||
children = []
|
||||
}
|
||||
const children_copy = children
|
||||
try {
|
||||
return await value
|
||||
} finally {
|
||||
children = children_copy
|
||||
}
|
||||
}
|
||||
|
||||
const trace = (fn, name, argscount, __location, get_closure) => {
|
||||
const result = (...args) => {
|
||||
if(result.__closure == null) {
|
||||
|
||||
Reference in New Issue
Block a user