res->attr.ca.subtypes = NEW_ARR_F (ir_type *, 0);
res->attr.ca.supertypes = NEW_ARR_F (ir_type *, 0);
res->attr.ca.peculiarity = peculiarity_existent;
+ res->attr.ca.type_info = NULL;
+ res->attr.ca.final = 0;
res->attr.ca.dfn = 0;
hook_new_type(res);
return res;
return new_d_type_class (name, NULL);
}
+/* free all entities of a class */
void free_class_entities(ir_type *clss) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = get_class_n_members(clss) - 1; i >= 0; --i)
free_entity(get_class_member(clss, i));
+ /* do NOT free the type info here. It belongs to another class */
}
void free_class_attrs(ir_type *clss) {
break;
}
}
+entity *get_class_type_info(const ir_type *clss) {
+ return clss->attr.ca.type_info;
+}
+void set_class_type_info(ir_type *clss, entity *ent) {
+ clss->attr.ca.type_info = ent;
+}
const char *get_peculiarity_string(peculiarity p) {
#define X(a) case a: return #a
clss->attr.ca.peculiarity = pec;
}
-void set_class_dfn (ir_type *clss, int dfn)
-{
- clss->attr.ca.dfn = dfn;
+int (is_class_final)(const ir_type *clss) {
+ return _is_class_final(clss);
}
-int get_class_dfn (const ir_type *clss)
-{
+void (set_class_final)(ir_type *clss, int final) {
+ _set_class_final(clss, final);
+}
+
+void set_class_dfn (ir_type *clss, int dfn) {
+ clss->attr.ca.dfn = dfn;
+}
+
+int get_class_dfn (const ir_type *clss) {
return (clss->attr.ca.dfn);
}
* The following two are dynamic lists that can be grown with an "add_" function,
* but not shrinked:
*
- * - subtypes: A list of direct subclasses.
+ * - subtypes: A list of direct subclasses.
*
- * - supertypes: A list of direct superclasses.
+ * - supertypes: A list of direct superclasses.
*
* - peculiarity: The peculiarity of this class. If the class is of peculiarity
* "description" it only is a description of requirements to a class,
* no value for irg.
* Values: description, existent, inherited. Default: existent.
*
+ * - type_info: An entity representing the type information of this class.
+ * This entity can be of arbitrari type, Firm did not use it yet.
+ * It allows to express the coupling of a type with an entity
+ * representing this type. This information is useful for lowering
+ * of InstOf and TypeChk nodes. Default: NULL
+ *
+ * - final: A final class is always a leaf in the class hierarchy. Final
+ * classes cannot be super classes of other ones. As this information
+ * can only be computed in whole world compilations, we allow to
+ * set this flag. It is used in optimizations if get_opt_closed_world()
+ * is false. Default: false
*/
/** Creates a new class type. */
/** Sets the peculiarity of the class. */
void set_class_peculiarity (ir_type *clss, peculiarity pec);
+/** Returns the type info entity of a class. */
+entity *get_class_type_info(const ir_type *clss);
+
+/** Set a type info entity for the class. */
+void set_class_type_info(ir_type *clss, entity *ent);
+
+/** Returns non-zero if a class is final. */
+int is_class_final(const ir_type *clss);
+
+/** Sets if a class is final. */
+void set_class_final(ir_type *clss, int final);
+
/* Set and get a class' dfn --
@todo This is an undocumented field, subject to change! */
void set_class_dfn (ir_type *clss, int dfn);
* File name: ir/tr/type_t.h
* Purpose: Representation of types -- private header.
* Author: Goetz Lindenmaier
- * Modified by:
+ * Modified by: Michael Beck
* Created:
* CVS-ID: $Id$
* Copyright: (c) 2001-2003 Universität Karlsruhe
entity **members; /**< fields and methods of this class */
ir_type **subtypes; /**< direct subtypes */
ir_type **supertypes;/**< direct supertypes */
- peculiarity peculiarity;
+ peculiarity peculiarity; /**< peculiarity of this class */
+ entity *type_info; /**< a entity representing this class, used for type info */
+ unsigned final; /**< non-zero if this is a final class */
int dfn; /**< number used for 'instanceof' operator */
} cls_attr;
return clss->attr.ca.members[pos];
}
+static INLINE int
+_is_class_final (const ir_type *clss) {
+ assert(clss && (clss->type_op == type_class));
+ return clss->attr.ca.final;
+}
+
+static INLINE void
+_set_class_final (ir_type *clss, int final) {
+ assert(clss && (clss->type_op == type_class));
+ clss->attr.ca.final = final;
+}
+
static INLINE int
_is_struct_type(const ir_type *strct) {
assert(strct);
#define is_Class_type(clss) _is_class_type(clss)
#define get_class_n_members(clss) _get_class_n_members(clss)
#define get_class_member(clss, pos) _get_class_member(clss, pos)
+#define is_class_final(clss) _is_class_final(clss)
+#define set_class_final(clss, final) _set_class_final(clss, final)
#define is_Struct_type(strct) _is_struct_type(strct)
#define is_Method_type(method) _is_method_type(method)
#define is_Union_type(uni) _is_union_type(uni)