summaryrefslogtreecommitdiffhomepage
path: root/ir/tr
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-12-07 04:39:53 +0100
committerMatthias Braun <matze@braunis.de>2015-12-07 04:42:10 +0100
commita207bef2a952d94201c7378323f12e13c36c881a (patch)
treef9bcf939c6dbb756c2db302c6f114f3b89b0d18b /ir/tr
parentf119db2422d572ef8da668cd063fb5ac960fb758 (diff)
Remove the whole type op concept
The simple tp_opcode enum is enough, no need to have dispatch tables and information structs behind each type kind.
Diffstat (limited to 'ir/tr')
-rw-r--r--ir/tr/entity.c14
-rw-r--r--ir/tr/tpop.c74
-rw-r--r--ir/tr/tpop_t.h91
-rw-r--r--ir/tr/trverify.c7
-rw-r--r--ir/tr/type.c97
-rw-r--r--ir/tr/type_t.h74
-rw-r--r--ir/tr/typewalk.c40
7 files changed, 92 insertions, 305 deletions
diff --git a/ir/tr/entity.c b/ir/tr/entity.c
index 3b28089..1d91f73 100644
--- a/ir/tr/entity.c
+++ b/ir/tr/entity.c
@@ -761,18 +761,16 @@ int is_unknown_entity(const ir_entity *entity)
int is_atomic_entity(const ir_entity *ent)
{
- ir_type *t = get_entity_type(ent);
- const tp_op *op = get_type_tpop(t);
- return op == type_primitive || op == type_pointer
- || op == type_method;
+ ir_type const *const type = get_entity_type(ent);
+ tp_opcode const opcode = get_type_opcode(type);
+ return opcode == tpo_primitive || opcode == tpo_pointer
+ || opcode == tpo_method;
}
int is_compound_entity(const ir_entity *ent)
{
- ir_type *t = get_entity_type(ent);
- const tp_op *op = get_type_tpop(t);
- return (op == type_class || op == type_struct ||
- op == type_array || op == type_union);
+ ir_type const *const type = get_entity_type(ent);
+ return is_compound_type(type);
}
int is_method_entity(const ir_entity *ent)
diff --git a/ir/tr/tpop.c b/ir/tr/tpop.c
deleted file mode 100644
index cd303c8..0000000
--- a/ir/tr/tpop.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @brief Opcode of types.
- * @author Goetz Lindenmaier, Michael Beck
- */
-#include "ident_t.h"
-#include "xmalloc.h"
-#include "tpop_t.h"
-#include "type_t.h"
-
-const tp_op *type_class; const tp_op *get_tpop_class (void) { return type_class; }
-const tp_op *type_struct; const tp_op *get_tpop_struct (void) { return type_struct; }
-const tp_op *type_method; const tp_op *get_tpop_method (void) { return type_method; }
-const tp_op *type_union; const tp_op *get_tpop_union (void) { return type_union; }
-const tp_op *type_array; const tp_op *get_tpop_array (void) { return type_array; }
-const tp_op *type_pointer; const tp_op *get_tpop_pointer (void) { return type_pointer; }
-const tp_op *type_primitive; const tp_op *get_tpop_primitive(void) { return type_primitive; }
-const tp_op *tpop_code; const tp_op *get_tpop_code_type(void) { return tpop_code; }
-const tp_op *tpop_unknown; const tp_op *get_tpop_unknown (void) { return tpop_unknown; }
-
-const tp_op *new_tpop(tp_opcode code, ident *name, size_t attr_size)
-{
- tp_op *res = XMALLOC(tp_op);
- res->code = code;
- res->name = name;
- res->attr_size = attr_size;
- return res;
-}
-
-void free_tpop(const tp_op *tpop)
-{
- free((void*)tpop);
-}
-
-void init_tpop(void)
-{
- type_class = new_tpop(tpo_class, NEW_IDENT("class"), sizeof(cls_attr) );
- type_struct = new_tpop(tpo_struct, NEW_IDENT("struct"), sizeof(compound_attr));
- type_method = new_tpop(tpo_method, NEW_IDENT("method"), sizeof(mtd_attr) );
- type_union = new_tpop(tpo_union, NEW_IDENT("union"), sizeof(compound_attr));
- type_array = new_tpop(tpo_array, NEW_IDENT("array"), sizeof(arr_attr) );
- type_pointer = new_tpop(tpo_pointer, NEW_IDENT("pointer"), sizeof(ptr_attr) );
- type_primitive = new_tpop(tpo_primitive, NEW_IDENT("primitive"), 0 );
- tpop_code = new_tpop(tpo_code, NEW_IDENT("code"), 0 );
- tpop_unknown = new_tpop(tpo_unknown, NEW_IDENT("Unknown"), 0 );
-}
-
-void finish_tpop(void)
-{
- free_tpop(type_class ); type_class = NULL;
- free_tpop(type_struct ); type_struct = NULL;
- free_tpop(type_method ); type_method = NULL;
- free_tpop(type_union ); type_union = NULL;
- free_tpop(type_array ); type_array = NULL;
- free_tpop(type_pointer ); type_pointer = NULL;
- free_tpop(type_primitive); type_primitive = NULL;
- free_tpop(tpop_code ); tpop_code = NULL;
- free_tpop(tpop_unknown ); tpop_unknown = NULL;
-}
-
-const char *get_tpop_name(const tp_op *op)
-{
- return get_id_str(op->name);
-}
-
-tp_opcode (get_tpop_code)(const tp_op *op)
-{
- return _get_tpop_code(op);
-}
diff --git a/ir/tr/tpop_t.h b/ir/tr/tpop_t.h
deleted file mode 100644
index 146c870..0000000
--- a/ir/tr/tpop_t.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @brief Opcode of types -- private header.
- * @author Goetz Lindenmaier, Michael Beck
- */
-#ifndef FIRM_TR_TPOP_T_H
-#define FIRM_TR_TPOP_T_H
-
-#include <stdlib.h>
-
-#include "firm_types.h"
-#include "typerep.h"
-
-#define get_tpop_code(op) _get_tpop_code(op)
-#define get_tpop_ident(op) _get_tpop_ident(op)
-
-/** The type opcode. */
-struct tp_op {
- tp_opcode code; /**< The tpop code. */
- ident *name; /**< The name of the type opcode. */
- size_t attr_size; /**< The attribute size for a type of this opcode. */
-};
-
-/**
- * Returns a new type opcode.
- *
- * Allocates a new tp_op struct and initializes its fields with
- * the passed values. This function is only to be used during
- * initialization of the library.
- *
- * @param code the enum for this type opcode.
- * @param name an ident for the name of the type opcode.
- * @param attr_size the size of the attributes necessary for a type with
- * this opcode
- * @return A new type opcode.
- */
-tp_op const *new_tpop(tp_opcode code, ident *name, size_t attr_size);
-
-/**
- * Free a tpop data structure.
- */
-void free_tpop(tp_op const *tpop);
-
-/**
- * Initialize the tpop module.
- *
- * Must be called during the initialization of the library. Allocates
- * opcodes and sets the globals that are external visible as specified
- * in tpop.h.
- * Allocates opcodes for classes, struct, method, union, array,
- * pointer and primitive and sets the according values.
- */
-void init_tpop(void);
-
-/**
- * Finalize the tpop module.
- *
- * Frees all type opcodes.
- */
-void finish_tpop(void);
-
-/**
- * Returns the size of the attribute to this kind
- * of type.
- *
- * Internal feature.
- *
- * @param op The type opcode to get the size for.
- * @return The size of the attribute of types with this opcode.
- */
-static inline size_t get_tpop_attr_size(tp_op const *op)
-{
- return op->attr_size;
-}
-
-static inline tp_opcode _get_tpop_code(tp_op const *op)
-{
- return op->code;
-}
-
-static inline ident *_get_tpop_ident(tp_op const *op)
-{
- return op->name;
-}
-
-#endif
diff --git a/ir/tr/trverify.c b/ir/tr/trverify.c
index cf6ce19..161cd8a 100644
--- a/ir/tr/trverify.c
+++ b/ir/tr/trverify.c
@@ -81,7 +81,7 @@ static bool check_pointer_type(const ir_type *tp)
int check_type(const ir_type *tp)
{
- switch (get_type_tpop_code(tp)) {
+ switch (get_type_opcode(tp)) {
case tpo_union:
case tpo_struct:
case tpo_class: return check_compound_type(tp);
@@ -92,9 +92,10 @@ int check_type(const ir_type *tp)
case tpo_uninitialized:
case tpo_unknown:
case tpo_code:
- break;
+ return true;
}
- return true;
+ report_error("Invalid type opcode");
+ return false;
}
static bool check_visited_flag(ir_graph *irg, ir_node *n)
diff --git a/ir/tr/type.c b/ir/tr/type.c
index f5390cd..4f8a730 100644
--- a/ir/tr/type.c
+++ b/ir/tr/type.c
@@ -38,7 +38,6 @@
#include "xmalloc.h"
#include "irprog_t.h"
#include "ircons.h"
-#include "tpop_t.h"
#include "tv_t.h"
#include "irhooks.h"
#include "util.h"
@@ -50,9 +49,26 @@
#include "array.h"
-static ir_type *new_type(tp_op const *type_op, ir_mode *mode);
+static ir_type *new_type(tp_opcode opcode, size_t attr_size, ir_mode *mode);
static void free_compound_entities(ir_type *type);
+const char *get_type_opcode_name(tp_opcode const opcode)
+{
+ switch (opcode) {
+ case tpo_array: return "array";
+ case tpo_class: return "class";
+ case tpo_code: return "code";
+ case tpo_method: return "method";
+ case tpo_pointer: return "pointer";
+ case tpo_primitive: return "primitive";
+ case tpo_struct: return "struct";
+ case tpo_uninitialized: return "uninitialized";
+ case tpo_union: return "union";
+ case tpo_unknown: return "unknown";
+ }
+ panic("Invalid type opcode");
+}
+
ir_type *get_code_type(void)
{
return irp->code_type;
@@ -65,10 +81,10 @@ ir_type *get_unknown_type(void)
void ir_init_type(ir_prog *irp)
{
- irp->code_type = new_type(tpop_code, mode_ANY);
+ irp->code_type = new_type(tpo_code, 0, mode_ANY);
set_type_state(irp->code_type, layout_fixed);
- irp->unknown_type = new_type(tpop_unknown, mode_ANY);
+ irp->unknown_type = new_type(tpo_unknown, 0, mode_ANY);
set_type_state (irp->unknown_type, layout_fixed);
irp->dummy_owner = new_type_struct(new_id_from_str("$dummy_owner$"));
@@ -100,21 +116,18 @@ void inc_master_type_visited(void)
/**
* Creates a new type representation:
- *
- * @param type_op the kind of this type. May not be type_id.
- * @param mode the mode to be used for this type, may be NULL
- *
* @return A new type of the given type. The remaining private attributes are
* not initialized. The type is in state layout_undefined.
*/
-static ir_type *new_type(tp_op const *type_op, ir_mode *mode)
+static ir_type *new_type(tp_opcode const opcode, size_t attr_size,
+ ir_mode *const mode)
{
- size_t const node_size = offsetof(ir_type, attr) + type_op->attr_size;
+ size_t const node_size = offsetof(ir_type, attr) + attr_size;
ir_type *const res = (ir_type*)xmalloc(node_size);
memset(res, 0, node_size);
res->kind = k_type;
- res->type_op = type_op;
+ res->opcode = opcode;
res->mode = mode;
res->visibility = ir_visibility_external;
res->flags = tf_none;
@@ -137,7 +150,7 @@ void free_type_entities(ir_type *const type)
static void free_type_attrs(ir_type *const type)
{
- switch (type->type_op->code) {
+ switch (get_type_opcode(type)) {
case tpo_class:
free_class_attrs(type);
return;
@@ -183,30 +196,14 @@ void (set_type_link)(ir_type *tp, void *l)
set_type_link_(tp, l);
}
-const tp_op *(get_type_tpop)(const ir_type *tp)
-{
- return get_type_tpop_(tp);
-}
-
-ident *(get_type_tpop_nameid)(const ir_type *tp)
-{
- return get_type_tpop_nameid_(tp);
-}
-
static inline bool is_type(const void *thing)
{
return get_kind(thing) == k_type;
}
-const char* get_type_tpop_name(const ir_type *tp)
-{
- assert(is_type(tp));
- return get_id_str(tp->type_op->name);
-}
-
-tp_opcode (get_type_tpop_code)(const ir_type *tp)
+tp_opcode (get_type_opcode)(ir_type const *const type)
{
- return get_type_tpop_code_(tp);
+ return get_type_opcode_(type);
}
ir_mode *(get_type_mode)(const ir_type *tp)
@@ -274,8 +271,9 @@ void set_type_state(ir_type *tp, ir_type_state state)
{
assert(is_type(tp));
- if (tp->type_op == type_pointer || tp->type_op == type_primitive
- || tp->type_op == type_method)
+ tp_opcode opcode = get_type_opcode(tp);
+ if (opcode == tpo_pointer || opcode == tpo_primitive
+ || opcode == tpo_method)
return;
#ifndef NDEBUG
@@ -347,7 +345,7 @@ static void free_compound_entities(ir_type *type)
ir_type *new_type_class(ident *name)
{
- ir_type *res = new_type(type_class, NULL);
+ ir_type *res = new_type(tpo_class, sizeof(cls_attr), NULL);
compound_init(res, name);
res->attr.cla.subtypes = NEW_ARR_F(ir_type*, 0);
res->attr.cla.supertypes = NEW_ARR_F(ir_type*, 0);
@@ -454,7 +452,7 @@ void remove_class_subtype(ir_type *clss, ir_type *subtype)
void add_class_supertype(ir_type *clss, ir_type *supertype)
{
assert(is_Class_type(clss));
- assert(supertype->type_op == type_class);
+ assert(is_Class_type(supertype));
ARR_APP1(ir_type *, clss->attr.cla.supertypes, supertype);
for (size_t i = 0, n = get_class_n_subtypes(supertype); i < n; ++i) {
if (get_class_subtype(supertype, i) == clss)
@@ -516,7 +514,7 @@ int (is_Class_type)(const ir_type *clss)
ir_type *new_type_struct(ident *name)
{
- ir_type *res = new_type(type_struct, NULL);
+ ir_type *res = new_type(tpo_struct, sizeof(compound_attr), NULL);
compound_init(res, name);
hook_new_type(res);
return res;
@@ -561,7 +559,7 @@ int (is_Struct_type)(const ir_type *strct)
ir_type *new_type_method(size_t n_param, size_t n_res)
{
- ir_type *res = new_type(type_method, mode_P);
+ ir_type *res = new_type(tpo_method, sizeof(mtd_attr), mode_P);
res->flags |= tf_layout_fixed;
res->size = get_mode_size_bytes(mode_P);
res->attr.ma.n_params = n_param;
@@ -582,7 +580,7 @@ ir_type *clone_type_method(ir_type *tp)
size_t n_params = tp->attr.ma.n_params;
size_t n_res = tp->attr.ma.n_res;
type_dbg_info *db = tp->dbi;
- ir_type *res = new_type(type_method, mode);
+ ir_type *res = new_type(tpo_method, sizeof(mtd_attr), mode);
set_type_dbg_info(res, db);
res->flags = tp->flags;
@@ -710,7 +708,7 @@ int (is_Method_type)(const ir_type *method)
ir_type *new_type_union(ident *name)
{
- ir_type *res = new_type(type_union, NULL);
+ ir_type *res = new_type(tpo_union, sizeof(compound_attr), NULL);
compound_init(res, name);
hook_new_type(res);
return res;
@@ -769,7 +767,7 @@ ir_type *new_type_array(ir_type *element_type)
{
assert(!is_Method_type(element_type));
- ir_type *res = new_type(type_array, NULL);
+ ir_type *res = new_type(tpo_array, sizeof(arr_attr), NULL);
res->attr.aa.element_type = element_type;
res->attr.aa.size = new_r_Unknown(get_const_code_irg(), mode_Iu);
set_type_alignment_bytes(res, get_type_alignment_bytes(element_type));
@@ -846,7 +844,7 @@ int (is_Array_type)(const ir_type *array)
ir_type *new_type_pointer(ir_type *points_to)
{
ir_mode *const mode = mode_P;
- ir_type *const res = new_type(type_pointer, mode);
+ ir_type *const res = new_type(tpo_pointer, sizeof(ptr_attr), mode);
res->attr.pa.points_to = points_to;
unsigned size = get_mode_size_bytes(mode);
res->size = size;
@@ -898,7 +896,7 @@ ir_type *new_type_primitive(ir_mode *mode)
unsigned align = (size > 0 && size != (unsigned)-1)
? ceil_po2(size) : 1;
- ir_type *res = new_type(type_primitive, mode);
+ ir_type *res = new_type(tpo_primitive, 0, mode);
res->size = size;
res->flags |= tf_layout_fixed;
set_type_alignment_bytes(res, align);
@@ -990,21 +988,20 @@ void add_compound_member(ir_type *type, ir_entity *entity)
ARR_APP1(ir_entity *, type->attr.ca.members, entity);
}
-int is_code_type(const ir_type *tp)
+int is_code_type(ir_type const *const type)
{
- assert(is_type(tp));
- return tp->type_op == tpop_code;
+ return get_type_opcode(type) == tpo_code;
}
-int is_unknown_type(const ir_type *tp)
+int is_unknown_type(ir_type const *const type)
{
- assert(is_type(tp));
- return tp->type_op == tpop_unknown;
+ return get_type_opcode(type) == tpo_unknown;
}
-int is_frame_type(const ir_type *tp)
+int is_frame_type(ir_type const *const type)
{
- return tp->flags & tf_frame_type;
+ assert(type->kind == k_type);
+ return (type->flags & tf_frame_type) != 0;
}
ir_type *new_type_frame(void)
@@ -1142,7 +1139,7 @@ void ir_print_type(char *buffer, size_t buffer_size, const ir_type *type)
}
/* we have to construct some name... */
- switch (get_type_tpop_code(type)) {
+ switch (get_type_opcode(type)) {
case tpo_uninitialized:
break;
case tpo_code:
diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h
index dd53dc5..749c4d9 100644
--- a/ir/tr/type_t.h
+++ b/ir/tr/type_t.h
@@ -7,14 +7,13 @@
* @file
* @brief Representation of types -- private header.
* @author Goetz Lindenmaier, Michael Beck
- * @see type.h tpop_t.h tpop.h
+ * @see type.h
*/
#ifndef FIRM_TR_TYPE_T_H
#define FIRM_TR_TYPE_T_H
#include <stdbool.h>
#include "typerep.h"
-#include "tpop_t.h"
#include "firm_common.h"
#include "array.h"
@@ -22,9 +21,7 @@
#define get_master_type_visited() get_master_type_visited_()
#define get_type_link(tp) get_type_link_(tp)
#define set_type_link(tp, l) set_type_link_(tp, l)
-#define get_type_tpop(tp) get_type_tpop_(tp)
-#define get_type_tpop_nameid(tp) get_type_tpop_nameid_(tp)
-#define get_type_tpop_code(tp) get_type_tpop_code_(tp)
+#define get_type_opcode(tp) get_type_opcode_(tp)
#define get_type_mode(tp) get_type_mode_(tp)
#define get_type_alignment_bytes(tp) get_type_alignment_bytes_(tp)
#define get_type_size_bytes(tp) get_type_size_bytes_(tp)
@@ -129,7 +126,7 @@ ENUM_BITSET(type_flags)
*/
struct ir_type {
firm_kind kind; /**< the firm kind, must be k_type */
- const tp_op *type_op; /**< the type operation of the type */
+ tp_opcode opcode;
ident *name; /**< The name of the type */
ir_visibility visibility;/**< Visibility of entities of this type. */
unsigned flags; /**< Type flags, a bitmask of enum type_flags. */
@@ -212,22 +209,10 @@ static inline void set_type_link_(ir_type *tp, void *l)
tp -> link = l;
}
-static inline const tp_op *get_type_tpop_(const ir_type *tp)
+static inline tp_opcode get_type_opcode_(const ir_type *tp)
{
assert(tp->kind == k_type);
- return tp->type_op;
-}
-
-static inline ident *get_type_tpop_nameid_(const ir_type *tp)
-{
- assert(tp->kind == k_type);
- return get_tpop_ident(tp->type_op);
-}
-
-static inline tp_opcode get_type_tpop_code_(const ir_type *tp)
-{
- assert(tp->kind == k_type);
- return get_tpop_code(tp->type_op);
+ return tp->opcode;
}
static inline ir_mode *get_type_mode_(const ir_type *tp)
@@ -289,9 +274,9 @@ static inline void set_type_dbg_info_(ir_type *tp, type_dbg_info *db)
tp->dbi = db;
}
-static inline int is_class_type_(const ir_type *clss)
+static inline int is_class_type_(const ir_type *type)
{
- return clss->type_op == type_class;
+ return get_type_opcode(type) == tpo_class;
}
static inline size_t get_compound_n_members_(const ir_type *type)
@@ -308,83 +293,80 @@ static inline ir_entity *get_compound_member_(ir_type const *const type,
return type->attr.ca.members[pos];
}
-static inline int is_struct_type_(const ir_type *strct)
+static inline int is_struct_type_(ir_type const *const type)
{
- return (strct->type_op == type_struct);
+ return get_type_opcode(type) == tpo_struct;
}
-static inline int is_method_type_(const ir_type *method)
+static inline int is_method_type_(ir_type const *const type)
{
- return (method->type_op == type_method);
+ return get_type_opcode(type) == tpo_method;
}
-static inline int is_union_type_(const ir_type *uni)
+static inline int is_union_type_(ir_type const *const type)
{
- return (uni->type_op == type_union);
+ return get_type_opcode(type) == tpo_union;
}
-static inline int is_array_type_(const ir_type *array)
+static inline int is_array_type_(ir_type const *const type)
{
- return (array->type_op == type_array);
+ return get_type_opcode(type) == tpo_array;
}
-static inline int is_pointer_type_(const ir_type *pointer)
+static inline int is_pointer_type_(ir_type const *const type)
{
- return (pointer->type_op == type_pointer);
+ return get_type_opcode(type) == tpo_pointer;
}
-/** Returns true if a type is a primitive type. */
-static inline int is_primitive_type_(const ir_type *primitive)
+static inline int is_primitive_type_(ir_type const *const type)
{
- assert(primitive->kind == k_type);
- return (primitive->type_op == type_primitive);
+ return get_type_opcode(type) == tpo_primitive;
}
-static inline int is_atomic_type_(const ir_type *tp)
+static inline int is_atomic_type_(ir_type const *const type)
{
- assert(tp->kind == k_type);
- return is_Primitive_type(tp) || is_Pointer_type(tp);
+ return is_Primitive_type(type) || is_Pointer_type(type);
}
static inline size_t get_method_n_params_(const ir_type *method)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
return method->attr.ma.n_params;
}
static inline size_t get_method_n_ress_(const ir_type *method)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
return method->attr.ma.n_res;
}
static inline mtp_additional_properties get_method_additional_properties_(const ir_type *method)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
return method->attr.ma.properties;
}
static inline void set_method_additional_properties_(ir_type *method, mtp_additional_properties properties)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
method->attr.ma.properties = properties;
}
static inline void add_method_additional_properties_(ir_type *method, mtp_additional_properties properties)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
method->attr.ma.properties |= properties;
}
static inline unsigned get_method_calling_convention_(const ir_type *method)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
return method->attr.ma.irg_calling_conv;
}
static inline void set_method_calling_convention_(ir_type *method, unsigned cc_mask)
{
- assert(method->type_op == type_method);
+ assert(is_Method_type(method));
method->attr.ma.irg_calling_conv = cc_mask;
}
diff --git a/ir/tr/typewalk.c b/ir/tr/typewalk.c
index 36d6240..50c8271 100644
--- a/ir/tr/typewalk.c
+++ b/ir/tr/typewalk.c
@@ -115,7 +115,7 @@ static void do_type_walk(ir_type *const tp, ir_entity *const ent,
break;
}
} else {
- switch (get_type_tpop_code(tp)) {
+ switch (get_type_opcode(tp)) {
case tpo_class:
for (size_t i = 0, n_types = get_class_n_supertypes(tp);
i < n_types; ++i) {
@@ -247,8 +247,7 @@ static void type_walk_s2s_2(ir_type *const tp, type_walk_func *pre,
/* iterate */
mark_type_visited(tp);
- switch (get_type_tpop_code(tp)) {
- case tpo_class: {
+ if (is_Class_type(tp)) {
for (size_t i = 0, n = get_class_n_supertypes(tp); i < n; ++i) {
type_walk_s2s_2(get_class_supertype(tp, i), pre, post, env);
}
@@ -263,19 +262,6 @@ static void type_walk_s2s_2(ir_type *const tp, type_walk_func *pre,
/* execute post method */
if (post)
post(tp, NULL, env);
- break;
- }
- case tpo_struct:
- case tpo_method:
- case tpo_union:
- case tpo_array:
- case tpo_pointer:
- case tpo_primitive:
- /* dont care */
- break;
- default:
- printf(" *** Faulty type! \n");
- break;
}
}
@@ -298,8 +284,7 @@ static void type_walk_super_2(ir_type *const tp, type_walk_func *pre,
/* iterate */
mark_type_visited(tp);
- switch (get_type_tpop_code(tp)) {
- case tpo_class:
+ if (is_Class_type(tp)) {
/* execute pre method */
if (pre)
pre(tp, NULL, env);
@@ -311,18 +296,6 @@ static void type_walk_super_2(ir_type *const tp, type_walk_func *pre,
/* execute post method */
if (post)
post(tp, NULL, env);
- break;
- case tpo_struct:
- case tpo_method:
- case tpo_union:
- case tpo_array:
- case tpo_pointer:
- case tpo_primitive:
- /* don't care */
- break;
- default:
- printf(" *** Faulty type! \n");
- break;
}
}
@@ -384,13 +357,13 @@ void class_walk_super2sub(class_walk_func *pre, class_walk_func *post,
void walk_types_entities(ir_type *tp, entity_walk_func *doit, void *env)
{
- switch (get_type_tpop_code(tp)) {
+ switch (get_type_opcode(tp)) {
case tpo_class:
case tpo_struct:
case tpo_union:
for (size_t i = 0, n = get_compound_n_members(tp); i < n; ++i)
doit(get_compound_member(tp, i), env);
- break;
+ return;
case tpo_array:
case tpo_code:
case tpo_method:
@@ -398,6 +371,7 @@ void walk_types_entities(ir_type *tp, entity_walk_func *doit, void *env)
case tpo_primitive:
case tpo_uninitialized:
case tpo_unknown:
- break;
+ return;
}
+ panic("invalid type");
}