dwarf-assembly/src/NativeSwitchCompiler.cpp

30 lines
776 B
C++
Raw Normal View History

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++;
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--;
}