4
Copyright (c) 2021 МГТУ им. Н.Э. Баумана, кафедра ИУ-6, Михаил Фетисов,
6
https://bmstu.codes/lsx/simodo/loom
9
#include "simodo/ast/generator/FormationWrapper.h"
15
FormationWrapper::FormationWrapper(size_t streams_quantity)
16
: _ast_streams(streams_quantity)
18
assert(streams_quantity >= DEFAULT_STREAMS_QUANTITY);
21
void FormationWrapper::setStreamNo(uint16_t no)
23
assert(no < _ast_streams.size());
24
_current_stream_no = no;
27
const FormationFlow & FormationWrapper::getStream(uint16_t no) const
29
assert(no < _ast_streams.size());
30
return _ast_streams[no];
33
void FormationWrapper::removeStream(uint16_t no)
35
assert(no < _ast_streams.size());
36
_ast_streams[no] = {};
39
void FormationWrapper::addNode(const std::u16string & host,
41
const inout::Token & op_symbol,
42
const inout::Token & bound)
44
FormationFlow & stream = getStream_mutable(_current_stream_no);
46
stream.addNode(host, op, op_symbol, bound);
49
void FormationWrapper::addNode_StepInto(const std::u16string & host,
51
const inout::Token & op_symbol,
52
const inout::Token & bound)
54
FormationFlow & stream = getStream_mutable(_current_stream_no);
56
stream.addNode_StepInto(host, op, op_symbol, bound);
59
bool FormationWrapper::goParent()
61
FormationFlow & stream = getStream_mutable(_current_stream_no);
63
return stream.goParent();
66
void FormationWrapper::addFile(const std::string & file_path)
68
FormationFlow & stream = getStream_mutable(_current_stream_no);
70
stream.addFile(file_path);
73
const ast::Tree & FormationWrapper::tree() const
78
void FormationWrapper::finalize()
82
for(const FormationFlow & ff : _ast_streams) {
83
const std::vector<Node> & fb = ff.branches();
85
wb.insert(wb.end(), fb.begin(), fb.end());
88
_tree._root._branches.swap(wb);
91
FormationFlow &FormationWrapper::getStream_mutable(uint16_t stream_no)
93
assert(stream_no < _ast_streams.size());
94
return _ast_streams[stream_no];