diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-08-24 13:20:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-24 13:20:48 -0700 |
commit | 2235dd795d3cc6c24ff1bdd1bbdcd110b4b0bdfc (patch) | |
tree | a5811adc062cbb1c66f05c863c9be245cf4fd2d2 /js/repl.ts | |
parent | bdc0a13261deaa3748f51d9948b4e7b92864c324 (diff) |
Revert json ops (#2814)
* Revert "port more ops to JSON (#2809)"
This reverts commit 137f33733d365026903d40e7cde6e34ac6c36dcf.
* Revert "port ops to JSON: compiler, errors, fetch, files (#2804)"
This reverts commit 79f82cf10ed1dbf91346994250d7311a4d74377a.
* Revert "Port rest of os ops to JSON (#2802)"
This reverts commit 5b2baa5c990fbeae747e952c5dcd7a5369e950b1.
Diffstat (limited to 'js/repl.ts')
-rw-r--r-- | js/repl.ts | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/js/repl.ts b/js/repl.ts index ac6700657..c971e4420 100644 --- a/js/repl.ts +++ b/js/repl.ts @@ -1,12 +1,12 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +import { assert } from "./util"; import { close } from "./files"; +import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers"; import { exit } from "./os"; import { window } from "./window"; import { core } from "./core"; import { formatError } from "./format_error"; import { stringifyArgs } from "./console"; -import * as dispatch from "./dispatch"; -import { sendSync, sendAsync } from "./dispatch_json"; /** * REPL logging. @@ -43,12 +43,34 @@ const replCommands = { }; function startRepl(historyFile: string): number { - return sendSync(dispatch.OP_REPL_START, { historyFile }); + const builder = flatbuffers.createBuilder(); + const historyFile_ = builder.createString(historyFile); + const inner = msg.ReplStart.createReplStart(builder, historyFile_); + + const baseRes = sendSync(builder, msg.Any.ReplStart, inner); + assert(baseRes != null); + assert(msg.Any.ReplStartRes === baseRes!.innerType()); + const innerRes = new msg.ReplStartRes(); + assert(baseRes!.inner(innerRes) != null); + const rid = innerRes.rid(); + return rid; } // @internal export async function readline(rid: number, prompt: string): Promise<string> { - return sendAsync(dispatch.OP_REPL_READLINE, { rid, prompt }); + const builder = flatbuffers.createBuilder(); + const prompt_ = builder.createString(prompt); + const inner = msg.ReplReadline.createReplReadline(builder, rid, prompt_); + + const baseRes = await sendAsync(builder, msg.Any.ReplReadline, inner); + + assert(baseRes != null); + assert(msg.Any.ReplReadlineRes === baseRes!.innerType()); + const innerRes = new msg.ReplReadlineRes(); + assert(baseRes!.inner(innerRes) != null); + const line = innerRes.line(); + assert(line !== null); + return line || ""; } // Error messages that allow users to continue input |