#include <jit/jit-plus.h>
jit_jump_table::jit_jump_table(int size)
{
try
{
labels = new jit_label_t[size];
}
catch(...)
{
throw jit_build_exception(JIT_RESULT_OUT_OF_MEMORY);
}
for (int i = 0; i < size; i++)
{
labels[i] = jit_label_undefined;
}
num_labels = size;
}
jit_jump_table::~jit_jump_table()
{
delete [] labels;
}
jit_label
jit_jump_table::get(int index)
{
if (index < 0 || index >= num_labels)
{
throw jit_build_exception(JIT_RESULT_COMPILE_ERROR);
}
return jit_label(labels[index]);
}
void
jit_jump_table::set(int index, jit_label label)
{
if (index < 0 || index >= num_labels)
{
throw jit_build_exception(JIT_RESULT_COMPILE_ERROR);
}
labels[index] = label.raw();
}