* Get the true type behind a series of typedefs.
*/
static t_type* get_true_type(t_type* type) {
- while (type->is_typedef()) {
- type = ((t_typedef*)type)->get_type();
- }
- return type;
+ return type->get_true_type();
}
protected:
#include "t_type.h"
+#include "t_typedef.h"
#include "md5.h"
md5_append(&ctx, (md5_byte_t*)(material.data()), (int)material.size());
md5_finish(&ctx, (md5_byte_t*)fingerprint_);
}
+
+t_type* t_type::get_true_type() {
+ t_type* type = this;
+ while (type->is_typedef()) {
+ type = ((t_typedef*)type)->get_type();
+ }
+ return type;
+}
throw "No enum value or constant found named \"" + const_val->get_identifier() + "\"!";
}
- if (constant->get_type()->is_base_type()) {
- switch (((t_base_type*)constant->get_type())->get_base()) {
+ // Resolve typedefs to the underlying type
+ t_type* const_type = constant->get_type()->get_true_type();
+
+ if (const_type->is_base_type()) {
+ switch (((t_base_type*)const_type)->get_base()) {
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
case t_base_type::TYPE_I64:
case t_base_type::TYPE_VOID:
throw "Constants cannot be of type VOID";
}
- } else if (constant->get_type()->is_map()) {
+ } else if (const_type->is_map()) {
const std::map<t_const_value*, t_const_value*>& map = constant->get_value()->get_map();
std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
const_val->add_map(v_iter->first, v_iter->second);
}
- } else if (constant->get_type()->is_list()) {
+ } else if (const_type->is_list()) {
const std::vector<t_const_value*>& val = constant->get_value()->get_list();
std::vector<t_const_value*>::const_iterator v_iter;