Add a transpileTree function to Target.hpp
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
3c130529a4
commit
56e1db5fcc
|
@ -74,6 +74,17 @@ protected:
|
||||||
typedef pair<const char*, const char*> print_functions_pair;
|
typedef pair<const char*, const char*> print_functions_pair;
|
||||||
virtual unordered_task_map getTaskMap() = 0;
|
virtual unordered_task_map getTaskMap() = 0;
|
||||||
virtual print_functions_pair printFunctions() = 0;
|
virtual print_functions_pair printFunctions() = 0;
|
||||||
|
void transpileTree(const derived_from<ParseTree> auto& parseTree) {
|
||||||
|
if (parseTree.size() > 0) {
|
||||||
|
unsigned int subIndex = 0;
|
||||||
|
for (auto pointer_iterator = parseTree.cbegin(); pointer_iterator < parseTree.cend(); ++pointer_iterator) {
|
||||||
|
getTaskMapInstance().at(pointer_iterator->get()->getId())(parseTree, subIndex); ++subIndex;
|
||||||
|
if ((pointer_iterator + 1) != parseTree.cend() && parseTree.getId() == typeid(StandardComponents::Call)) {
|
||||||
|
output << ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
typedef optional<const char*> optional_string;
|
typedef optional<const char*> optional_string;
|
||||||
virtual optional_string uniqueLineSeparator() { return ";"; };
|
virtual optional_string uniqueLineSeparator() { return ";"; };
|
||||||
const bool newLines;
|
const bool newLines;
|
||||||
|
@ -83,22 +94,14 @@ public:
|
||||||
static unordered_task_map staticMap = getTaskMap();
|
static unordered_task_map staticMap = getTaskMap();
|
||||||
// Default / Shared tasks:
|
// Default / Shared tasks:
|
||||||
staticMap.merge(unordered_task_map({
|
staticMap.merge(unordered_task_map({
|
||||||
make_task(ParseTree,
|
make_task(ParseTree, transpileTree(parseComponent);),
|
||||||
unsigned int subIndex = 0;
|
|
||||||
for (auto pointer_iterator = parseComponent.cbegin(); pointer_iterator < parseComponent.cend(); ++pointer_iterator) {
|
|
||||||
staticMap[pointer_iterator->get()->getId()](parseComponent, subIndex); ++subIndex;
|
|
||||||
if ((pointer_iterator + 1) != parseComponent.cend() && parseComponent.getId() == typeid(StandardComponents::Call)) {
|
|
||||||
output << ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
make_task(StandardComponents::Reference,
|
make_task(StandardComponents::Reference,
|
||||||
const auto print_functions = printFunctions();
|
const auto print_functions = printFunctions();
|
||||||
output << ((parseComponent.name == "print") ? print_functions.first : (parseComponent.name == "print_line") ? print_functions.second : parseComponent.name);
|
output << ((parseComponent.name == "print") ? print_functions.first : (parseComponent.name == "print_line") ? print_functions.second : parseComponent.name);
|
||||||
),
|
),
|
||||||
make_task_noR(StandardComponents::Call,
|
make_task(StandardComponents::Call,
|
||||||
output << '(';
|
output << '(';
|
||||||
staticMap[typeid(ParseTree)](parsedTree, index);
|
transpileTree(parseComponent);
|
||||||
output << ')';
|
output << ')';
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue