feat: simple loadprg implementation
This commit is contained in:
@@ -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<string>, stdout: SimpleStream<string>, args: string[]): Promise<number> {
|
||||
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<string>, stdout: SimpleStream<string>, args: string[]): Promise<number> {
|
||||
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`)
|
||||
|
||||
Reference in New Issue
Block a user