4
Copyright (c) 2024 МГТУ им. Н.Э. Баумана, кафедра ИУ-6, Михаил Фетисов,
6
https://bmstu.codes/lsx/simodo/loom
9
#include "simodo/engine/Executor.h"
10
#include "simodo/engine/FrameBody.h"
11
#include "simodo/engine/debug/RegularFormatter.h"
12
#include "simodo/interpret/Interpret.h"
14
namespace simodo::engine
16
extern simodo::interpret::SemanticDataCollector_null null_semantic_data_collector;
18
Executor::Executor(inout::Reporter_abstract & m,
19
inout::InputStreamSupplier_interface & stream_supplier,
20
const std::string & loom_dir,
21
const std::string & initial_contracts_file,
22
const std::string & source_file,
23
interpret::Logistics_interface & logistics,
25
OutputFormatter_interface & output)
27
, _interpret_factory(interpret::InterpretType::Preview, m, _loom, logistics)
28
, _module_management(m, stream_supplier, loom_dir, _interpret_factory, null_semantic_data_collector)
29
, _show_call_stack(show_call_stack)
30
, _engine(new FrameBody(m, _module_management, PRELOAD_ANALYZE_MODULES, initial_contracts_file, source_file))
32
if (&null_output_formatter == &output) {
33
_regular_formatter = std::make_unique<RegularFormatter>(*this);
34
_output_formatter = _regular_formatter.get();
37
_output_formatter = &output;
45
loom::FiberStatus Executor::run(interpret::NextStepBehaviour mode)
47
loom::FiberStatus status = _engine->run(mode);
49
if (status == loom::FiberStatus::Paused && _output_formatter) {
50
const loom::Fiber_interface * p_causer = causer();
53
const interpret::Interpret_interface *
54
interpret = dynamic_cast<const interpret::Interpret_interface *>(p_causer);
57
// Гонка невозможна, т.к. causer всегда остановлен
58
const ast::Node * op = interpret->lookupOperationNode();
62
ok = _output_formatter->source(op->token().location());
64
_output_formatter->error("The operator cannot be defined");
66
if (ok && _show_call_stack)
67
ok = _output_formatter->calls(interpret);
70
_output_formatter->fibers();