2018-05-21 18:53:53 -04:00
|
|
|
import { ModuleInfo } from "./types";
|
2018-05-23 11:31:53 -04:00
|
|
|
import { sendMsg } from "./dispatch";
|
2018-05-25 15:24:24 -04:00
|
|
|
import { main as pb } from "./msg.pb";
|
|
|
|
import { assert } from "./util";
|
2018-05-14 17:27:34 -04:00
|
|
|
|
2018-05-25 15:36:13 -04:00
|
|
|
export function exit(exitCode = 0): void {
|
|
|
|
sendMsg("os", {
|
|
|
|
command: pb.Msg.Command.EXIT,
|
|
|
|
exitCode
|
|
|
|
});
|
2018-05-14 17:27:34 -04:00
|
|
|
}
|
|
|
|
|
2018-05-17 09:47:09 -04:00
|
|
|
export function sourceCodeFetch(
|
2018-05-19 04:47:40 -04:00
|
|
|
moduleSpecifier: string,
|
|
|
|
containingFile: string
|
|
|
|
): ModuleInfo {
|
2018-05-23 11:31:53 -04:00
|
|
|
const res = sendMsg("os", {
|
2018-05-25 15:36:13 -04:00
|
|
|
command: pb.Msg.Command.SOURCE_CODE_FETCH,
|
|
|
|
sourceCodeFetchModuleSpecifier: moduleSpecifier,
|
|
|
|
sourceCodeFetchContainingFile: containingFile
|
2018-05-17 09:47:09 -04:00
|
|
|
});
|
2018-05-25 15:24:24 -04:00
|
|
|
assert(res.command === pb.Msg.Command.SOURCE_CODE_FETCH_RES);
|
|
|
|
return {
|
|
|
|
moduleName: res.sourceCodeFetchResModuleName,
|
|
|
|
filename: res.sourceCodeFetchResFilename,
|
|
|
|
sourceCode: res.sourceCodeFetchResSourceCode,
|
|
|
|
outputCode: res.sourceCodeFetchResOutputCode
|
|
|
|
};
|
2018-05-17 09:47:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function sourceCodeCache(
|
|
|
|
filename: string,
|
|
|
|
sourceCode: string,
|
|
|
|
outputCode: string
|
|
|
|
): void {
|
2018-05-23 11:31:53 -04:00
|
|
|
sendMsg("os", {
|
2018-05-25 15:36:13 -04:00
|
|
|
command: pb.Msg.Command.SOURCE_CODE_CACHE,
|
|
|
|
sourceCodeCacheFilename: filename,
|
|
|
|
sourceCodeCacheSourceCode: sourceCode,
|
|
|
|
sourceCodeCacheOutputCode: outputCode
|
2018-05-15 04:39:03 -04:00
|
|
|
});
|
2018-05-17 09:47:09 -04:00
|
|
|
}
|