mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
WIP
This commit is contained in:
18
src/eval.js
18
src/eval.js
@@ -73,7 +73,7 @@ const codegen_function_expr = (node, cxt) => {
|
||||
|
||||
const args = node.function_args.children.map(do_codegen).join(',')
|
||||
|
||||
const call = `(${args}) => ` + (
|
||||
const call = (node.is_async ? 'async ' : '') + `(${args}) => ` + (
|
||||
(node.body.type == 'do')
|
||||
? '{' + do_codegen(node.body) + '}'
|
||||
: '(' + do_codegen(node.body) + ')'
|
||||
@@ -384,7 +384,17 @@ export const eval_modules = (
|
||||
try {
|
||||
value = fn(...args)
|
||||
ok = true
|
||||
return value
|
||||
return value instanceof Promise.Original
|
||||
? value
|
||||
.then(v => {
|
||||
value.status = {ok: true, value: v}
|
||||
return v
|
||||
})
|
||||
.catch(e => {
|
||||
value.status = {ok: false, error: e}
|
||||
throw e
|
||||
})
|
||||
: value
|
||||
} catch(_error) {
|
||||
ok = false
|
||||
error = _error
|
||||
@@ -917,6 +927,10 @@ const do_eval_frame_expr = (node, scope, callsleft) => {
|
||||
value = typeof(expr.result.value)
|
||||
} else if(node.operator == '-') {
|
||||
value = - expr.result.value
|
||||
} else if(node.operator == 'await') {
|
||||
log('expr', expr.result.value.status)
|
||||
value = expr.result.value
|
||||
//throw new Error('not implemented')
|
||||
} else {
|
||||
throw new Error('unknown op')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user