| 1203 | } |
| 1204 | |
| 1205 | void ScriptEngine::ProcessREPL() |
| 1206 | { |
| 1207 | while (!_evalQueue.empty()) |
| 1208 | { |
| 1209 | auto item = std::move(_evalQueue.front()); |
| 1210 | _evalQueue.pop(); |
| 1211 | auto promise = std::move(std::get<0>(item)); |
| 1212 | auto command = std::move(std::get<1>(item)); |
| 1213 | |
| 1214 | JSValue res = JS_Eval(_replContext, command.c_str(), command.length(), "<repl>", JS_EVAL_TYPE_GLOBAL); |
| 1215 | if (JS_IsException(res)) |
| 1216 | { |
| 1217 | JSValue exceptionVal = JS_GetException(_replContext); |
| 1218 | _console.WriteLineError(Stringify(_replContext, exceptionVal)); |
| 1219 | JS_FreeValue(_replContext, exceptionVal); |
| 1220 | } |
| 1221 | else if (!JS_IsUndefined(res)) |
| 1222 | { |
| 1223 | _console.WriteLine(Stringify(_replContext, res)); |
| 1224 | } |
| 1225 | JS_FreeValue(_replContext, res); |
| 1226 | |
| 1227 | // Signal the promise so caller can continue |
| 1228 | promise.set_value(); |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 | std::future<void> ScriptEngine::Eval(const std::string& s) |
| 1233 | { |
nothing calls this directly
no test coverage detected