UNPKG

@nat-lang/nat

Version:
59 lines (58 loc) 1.79 kB
import { NatModule } from "../lib/nat"; export type Compilation = { success: boolean; tex: string; }; export type CoreFile = { path: string; content: string; type: "tree" | "blob"; }; export type RespType = "string" | "tex" | "flag"; export type CodeblockResp = { success: boolean; type: "codeblock"; out: { text: string; }; }; export type InterpretResp = { success: boolean; type: RespType; out: string; } | CodeblockResp; type OutputHandler = (stdout: string) => void; type OutputHandlerMap = { [key: string]: OutputHandler; }; export declare const GEN_START = "__start_generation__"; export declare const CORE_DIR = "core", SRC_DIR = "src"; export declare const abs: (path: string) => string; export declare enum InterpretationStatus { OK = 0, COMPILATION_ERROR = 1, RUNTIME_ERROR = 2 } declare class Runtime { wasmModule?: NatModule; stdOutHandlers: OutputHandlerMap; stdErrHandlers: OutputHandlerMap; errors: string[]; constructor(); handleStdOut: (stdout: string) => void; handleStdErr: (stderr: string) => void; storeErr: (err: string) => number; onStdout: (handler: OutputHandler) => () => void; onStderr: (handler: OutputHandler) => () => void; loadWasmModule: () => Promise<NatModule>; readStrMem: (ptr: number) => Promise<string>; interpret: (path: string) => Promise<InterpretResp>; generate(path: string): AsyncGenerator<InterpretResp>; free: () => Promise<void>; getCoreFiles: (dir?: string) => Promise<CoreFile[]>; mkDir: (path: string) => Promise<void>; getFile: (path: string) => Promise<CoreFile>; setFile: (path: string, content: string) => Promise<void>; rmFile: (path: string) => Promise<void>; } export default Runtime;