void
set_entity_irg(entity *ent, ir_graph *irg) {
- assert(ent && is_Method_type(get_entity_type(ent)));
+ assert(ent && is_method_entity(ent));
/* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
* Methode selbst nicht mehr aufgerufen werden kann, die Entität
* aber erhalten bleiben soll? Wandle die Entitaet in description oder
ent->attr.mtd_attr.irg = irg;
}
+unsigned get_entity_vtable_number(entity *ent) {
+ assert(ent && is_method_entity(ent));
+ return ent->attr.mtd_attr.vtable_number;
+}
+
+void set_entity_vtable_number(entity *ent, unsigned vtable_number) {
+ assert(ent && is_method_entity(ent));
+ ent->attr.mtd_attr.vtable_number = vtable_number;
+}
+
int
(is_entity)(const void *thing) {
return _is_entity(thing);
* If (type != method_type) access of this field will cause
* an assertion.
*/
-#ifndef _ENTITY_H_
-#define _ENTITY_H_
+#ifndef _FIRM_TR_ENTITY_H_
+#define _FIRM_TR_ENTITY_H_
#include "firm_types.h"
#include "dbginfo.h"
ir_graph *get_entity_irg(const entity *ent);
void set_entity_irg(entity *ent, ir_graph *irg);
+/** Gets the entity vtable number. */
+unsigned get_entity_vtable_number(entity *ent);
+
+/** Sets the entity vtable number. */
+void set_entity_vtable_number(entity *ent, unsigned vtable_number);
+
/** Return the peculiarity of an entity. */
peculiarity get_entity_peculiarity (const entity *ent);
#define IS_WRITTEN(a) ((a) & ptr_access_write)
#define IS_STORED(a) ((a) & ptr_access_store)
-#endif /* _ENTITY_H_ */
+#endif /* _FIRM_TR_ENTITY_H_ */
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.vtable_size = 0;
res->attr.ca.final = 0;
res->attr.ca.dfn = 0;
hook_new_type(res);
clss->attr.ca.peculiarity = pec;
}
+/* Returns the size of the virtual function table. */
+unsigned (get_class_vtable_size)(const ir_type *clss) {
+ return _get_class_vtable_size(clss);
+}
+
+/* Sets a new size of the virtual function table. */
+void (set_class_vtable_size)(ir_type *clss, unsigned size) {
+ _set_class_vtable_size(clss, size);
+}
+
+/* Returns non-zero if a class is final. */
int (is_class_final)(const ir_type *clss) {
return _is_class_final(clss);
}
+/* Sets if a class is final. */
void (set_class_final)(ir_type *clss, int final) {
_set_class_final(clss, final);
}
+/*
+ * Project: libFIRM
+ * File name: ir/tr/type.h
+ * Purpose: Representation of types.
+ * Author: Goetz Lindenmaier
+ * Modified by: Michael Beck
+ * Created:
+ * Copyright: (c) 2001-2003 Universität Karlsruhe
+ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * CVS-ID: $Id$
+ */
+
/**
* @file type.h
*
- * Project: libFIRM <br>
- * File name: ir/tr/type.h <br>
- * Purpose: Representation of types. <br>
- * Author: Goetz Lindenmaier <br>
- * Modified by: <br>
- * Created: <br>
- * Copyright: (c) 2001-2003 Universität Karlsruhe <br>
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. <br>
- * CVS-ID: $Id$
- *
- *
* Datastructure to hold type information.
*
* This module supplies a datastructure to represent all types
*
* @see tpop.h
*/
-
#ifndef _FIRM_TR_TYPE_H_
#define _FIRM_TR_TYPE_H_
* representing this type. This information is useful for lowering
* of InstOf and TypeChk nodes. Default: NULL
*
+ * - vtable_size: The size of this class vritual function table.
+ * Default: 0
+ *
* - 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 a type info entity for the class. */
void set_class_type_info(ir_type *clss, entity *ent);
+/** Returns the size of the virtual function table. */
+unsigned get_class_vtable_size(const ir_type *clss);
+
+/** Sets a new size of the virtual function table. */
+void set_class_vtable_size(ir_type *clss, unsigned size);
+
/** Returns non-zero if a class is final. */
int is_class_final(const ir_type *clss);
ir_type **supertypes;/**< direct supertypes */
peculiarity peculiarity; /**< peculiarity of this class */
entity *type_info; /**< a entity representing this class, used for type info */
+ unsigned vtable_size;/**< size of the vtable */
unsigned final; /**< non-zero if this is a final class */
int dfn; /**< number used for 'instanceof' operator */
} cls_attr;
/** struct attributes */
typedef struct {
- entity **members; /**< fields of this struct. No method entities allowed. */
+ entity **members; /**< Fields of this struct. No method entities allowed. */
} stc_attr;
/** A (type, entity) pair */
typedef struct {
- ir_type *tp; /**< a type */
- entity *ent; /**< an entity */
+ ir_type *tp; /**< A type. */
+ entity *ent; /**< An entity. */
} tp_ent_pair;
/** method attributes */
typedef struct {
- int n_params; /**< number of parameters */
- tp_ent_pair *param_type; /**< array of parameter type/value entities pairs */
+ int n_params; /**< Number of parameters. */
+ tp_ent_pair *param_type; /**< Array of parameter type/value entities pairs. */
ir_type *value_params; /**< A type whose entities represent copied value arguments. */
- int n_res; /**< number of results */
- tp_ent_pair *res_type; /**< array of result type/value entity pairs */
+ int n_res; /**< Number of results. */
+ tp_ent_pair *res_type; /**< Array of result type/value entity pairs. */
ir_type *value_ress; /**< A type whose entities represent copied value results. */
variadicity variadicity; /**< variadicity of the method. */
- int first_variadic_param; /**< index of the first variadic param or -1 if non-variadic .*/
+ int first_variadic_param; /**< index of the first variadic parameter or -1 if non-variadic .*/
unsigned additional_properties; /**< Set of additional method properties. */
- unsigned irg_calling_conv; /**< this is a set of calling convention flags. */
+ unsigned irg_calling_conv; /**< A set of calling convention flags. */
} mtd_attr;
/** union attributes */
return clss->attr.ca.members[pos];
}
+static INLINE unsigned
+_get_class_vtable_size(const ir_type *clss) {
+ assert(clss && (clss->type_op == type_class));
+ return clss->attr.ca.vtable_size;
+}
+
+static INLINE void
+_set_class_vtable_size(ir_type *clss, unsigned vtable_size) {
+ assert(clss && (clss->type_op == type_class));
+ clss->attr.ca.vtable_size = vtable_size;
+}
+
static INLINE int
_is_class_final (const ir_type *clss) {
assert(clss && (clss->type_op == type_class));
#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 get_class_vtable_size(clss) _get_class_vtable_size(clss)
+#define set_class_vtable_size(clss, size) _set_class_vtable_size(clss, size)
#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)