2018-06-25 11:33:36 +02:00
|
|
|
#include "NativeSwitchCompiler.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
NativeSwitchCompiler::NativeSwitchCompiler(
|
2018-06-25 11:54:45 +02:00
|
|
|
int indent):
|
|
|
|
AbstractSwitchCompiler(indent)
|
2018-06-25 11:33:36 +02:00
|
|
|
{}
|
|
|
|
|
2018-06-25 11:54:45 +02:00
|
|
|
void NativeSwitchCompiler::to_stream(ostream& os, const SwitchStatement& sw) {
|
2018-06-25 11:33:36 +02:00
|
|
|
os << indent() << "switch(" << sw.switch_var << ") {\n";
|
|
|
|
indent_count++;
|
|
|
|
|
|
|
|
for(const auto& cur_case: sw.cases) {
|
|
|
|
os << indent() << "case 0x"
|
|
|
|
<< hex << cur_case.low_bound << " ... 0x" << cur_case.high_bound
|
|
|
|
<< dec << ":\n";
|
|
|
|
indent_count++;
|
2018-06-25 16:32:52 +02:00
|
|
|
os << indent_str(cur_case.content.code);
|
2018-06-25 11:33:36 +02:00
|
|
|
indent_count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
os << indent() << "default:\n";
|
|
|
|
indent_count++;
|
|
|
|
os << indent_str(sw.default_case);
|
|
|
|
indent_count--;
|
|
|
|
os << indent() << "}\n";
|
|
|
|
indent_count--;
|
|
|
|
}
|