| 423 | } |
| 424 | |
| 425 | void repl::run(const string &code) |
| 426 | { |
| 427 | if (code.empty()) |
| 428 | return; |
| 429 | std::deque<char> buff; |
| 430 | for (auto &ch : code) |
| 431 | buff.push_back(ch); |
| 432 | try { |
| 433 | std::deque<std::deque<token_base *>> ast; |
| 434 | context->compiler->clear_metadata(); |
| 435 | context->compiler->build_line(buff, ast, 1, encoding); |
| 436 | for (auto &line : ast) |
| 437 | interpret(code, line); |
| 438 | } |
| 439 | catch (const lang_error &le) { |
| 440 | reset_status(); |
| 441 | throw fatal_error(std::string("Uncaught exception: ") + le.what()); |
| 442 | } |
| 443 | catch (const cs::exception &e) { |
| 444 | reset_status(); |
| 445 | throw e; |
| 446 | } |
| 447 | catch (const std::exception &e) { |
| 448 | reset_status(); |
| 449 | throw exception(line_num, context->file_path, code, e.what()); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | void repl::exec(const string &code) |
| 454 | { |
no test coverage detected