diff options
Diffstat (limited to '')
| -rw-r--r-- | src/eval.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/eval.ts b/src/eval.ts index 445cb8f..aba31df 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -31,6 +31,11 @@ export interface EvalActions { }): Promise<void> addChildren(id: string, children: Expr[]): Promise<void> removeElement(id: string | undefined): Promise<void> + callMethod( + id: string | undefined, + method: string, + args: EvalValue[], + ): Promise<void> // calculate ?? } @@ -154,6 +159,14 @@ const getFunctions = (name: string, args: Expr[], actions: EvalActions) => { actions.removeElement( (args[0] && (await evalExpr(args[0], actions))) ?? undefined, ), + call: async () => { + const [id, method, ...methodArgs] = await Promise.all( + args.map(a => evalExpr(a, actions)), + ) + if (id && method) { + actions.callMethod(id, method, methodArgs) + } + }, _: () => Promise.reject(new Error('not supposed to be here')), }) |
