From 91eeb33d9e1db48891274d36160e2be0d202f78c Mon Sep 17 00:00:00 2001 From: binekrasik Date: Thu, 26 Mar 2026 23:58:09 +0100 Subject: [PATCH] feat: simple loadprg implementation --- src/program/Loadprg.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/program/Loadprg.ts b/src/program/Loadprg.ts index 2d7423e..b4b9022 100644 --- a/src/program/Loadprg.ts +++ b/src/program/Loadprg.ts @@ -3,21 +3,30 @@ import type { SimpleStream } from '../utils/SimpleStream' import { Program } from './Program' export class Loadprg extends Program { - // private wush: Wush + private wush: Wush - constructor(_: Wush) { + constructor(wush: Wush) { super() - // this.wush = wush + this.wush = wush } async Exec(_: SimpleStream, stdout: SimpleStream, args: string[]): Promise { - stdout.emit('Not implemented yet.\n') - return 0 + // stdout.emit('Not implemented yet.\n') + // return 0 - const javascript = args.slice(1).join(' ') + const javascript = args.slice(2).join(' ') try { - eval(javascript) + const exec: Function = eval(javascript) + + const program = class extends Program { + async Exec(stdin: SimpleStream, stdout: SimpleStream, args: string[]): Promise { + exec(stdin, stdout, args) + return 0 + } + } + + this.wush.LoadProgram(new program(), args[1]) } catch (e) { stdout.emit(`${String(e)}\n`) stdout.emit(`${String((e as Error).stack)}\n`)