Commit 58278afc authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

added debug support constructors

[r495]
parent d47038a7
......@@ -98,7 +98,12 @@ new_entity (type *owner, ident *name, type *type)
insert_entity_in_owner (res);
return res;
}
entity *
new_d_entity (type *owner, ident *name, type *type, dbg_info *db) {
entity *res = new_entity(owner, name, type);
set_entity_dbg_info(res, db);
return res;
}
INLINE void free_entity_attrs(entity *ent) {
assert(ent);
if (get_type_tpop(get_entity_owner(ent)) == type_class) {
......
......@@ -50,6 +50,7 @@
# include "ident.h"
# include "type.h"
# include "dbginfo.h"
/*******************************************************************/
/** general **/
......@@ -126,6 +127,7 @@ typedef struct entity entity;
value is a pointer to the method.
Visibility is local, offset -1, and it is not volatile. */
entity *new_entity (type *owner, ident *name, type *type);
entity *new_d_entity (type *owner, ident *name, type *type, dbg_info *db);
/* Copies the entity if the new_owner is different from the
owner of the old entity. Else returns the old entity.
Automatically inserts the new entity as a member of owner. */
......
......@@ -69,6 +69,7 @@ struct entity {
ir_graph *irg; /* If (type == method_type) this is the corresponding irg.
The ir_graph constructor automatically sets this field.
Yes, it must be here. */
struct dbg_info* dbi; /* A pointer to information for debug support. */
};
......
......@@ -512,7 +512,7 @@ bool smaller_type (type *st, type *lt) {
/*******************************************************************/
/* create a new class type */
type *new_type_class (ident *name) {
INLINE type *new_type_class (ident *name) {
type *res;
res = new_type(type_class, NULL, name);
......@@ -525,6 +525,11 @@ type *new_type_class (ident *name) {
return res;
}
type *new_d_type_class (ident *name, dbg_info* db) {
type *res = new_type_class (name);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_class_attrs(type *clss) {
assert(clss && (clss->type_op == type_class));
DEL_ARR_F(clss->attr.ca.members);
......@@ -692,12 +697,17 @@ bool is_subclass_of(type *low, type *high) {
/*******************************************************************/
/* create a new type struct */
type *new_type_struct (ident *name) {
INLINE type *new_type_struct (ident *name) {
type *res;
res = new_type(type_struct, NULL, name);
res->attr.sa.members = NEW_ARR_F (entity *, 1);
return res;
}
type *new_d_type_struct (ident *name, dbg_info* db) {
type *res = new_type_struct (name);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_struct_attrs (type *strct) {
assert(strct && (strct->type_op == type_struct));
DEL_ARR_F(strct->attr.sa.members);
......@@ -749,7 +759,7 @@ bool is_struct_type(type *strct) {
/* Create a new method type.
N_param is the number of parameters, n_res the number of results. */
type *new_type_method (ident *name, int n_param, int n_res) {
INLINE type *new_type_method (ident *name, int n_param, int n_res) {
type *res;
res = new_type(type_method, mode_p, name);
res->state = layout_fixed;
......@@ -760,6 +770,11 @@ type *new_type_method (ident *name, int n_param, int n_res) {
res->attr.ma.res_type = (type **) xmalloc (sizeof (type *) * n_res);
return res;
}
type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db) {
type *res = new_type_method (name, n_param, n_res);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_method_attrs(type *method) {
assert(method && (method->type_op == type_method));
free(method->attr.ma.param_type);
......@@ -808,7 +823,7 @@ bool is_method_type (type *method) {
/*******************************************************************/
/* create a new type uni */
type *new_type_uni (ident *name) {
INLINE type *new_type_uni (ident *name) {
type *res;
res = new_type(type_union, NULL, name);
/*res->attr.ua.unioned_type = (type **) xmalloc (sizeof (type *) * n_types);
......@@ -816,6 +831,11 @@ type *new_type_uni (ident *name) {
res->attr.ua.members = NEW_ARR_F (entity *, 1);
return res;
}
type *new_d_type_uni (ident *name, dbg_info* db) {
type *res = new_type_uni (name);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_union_attrs (type *uni) {
assert(uni && (uni->type_op == type_union));
DEL_ARR_F(uni->attr.ua.members);
......@@ -894,7 +914,7 @@ bool is_union_type (type *uni) {
/* create a new type array -- set dimension sizes independently */
type *new_type_array (ident *name, int n_dimensions,
INLINE type *new_type_array (ident *name, int n_dimensions,
type *element_type) {
type *res;
int i;
......@@ -914,6 +934,12 @@ type *new_type_array (ident *name, int n_dimensions,
new_entity(res, mangle_u(name, id_from_str("elem_ent", 8)), element_type);
return res;
}
type *new_d_type_array (ident *name, int n_dimensions,
type *element_type, dbg_info* db) {
type *res = new_type_array (name, n_dimensions, element_type);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_array_attrs (type *array) {
assert(array && (array->type_op == type_array));
......@@ -1018,7 +1044,7 @@ bool is_array_type (type *array) {
/*******************************************************************/
/* create a new type enumeration -- set the enumerators independently */
type *new_type_enumeration (ident *name, int n_enums) {
INLINE type *new_type_enumeration (ident *name, int n_enums) {
type *res;
int i;
res = new_type(type_enumeration, NULL, name);
......@@ -1031,6 +1057,11 @@ type *new_type_enumeration (ident *name, int n_enums) {
}
return res;
}
type *new_d_type_enumeration (ident *name, int n_enums, dbg_info* db) {
type *res = new_type_enumeration (name, n_enums);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_enumeration_attrs(type *enumeration) {
assert(enumeration && (enumeration->type_op == type_enumeration));
......@@ -1080,7 +1111,7 @@ bool is_enumeration_type (type *enumeration) {
/*******************************************************************/
/* Create a new type pointer */
type *new_type_pointer (ident *name, type *points_to) {
INLINE type *new_type_pointer (ident *name, type *points_to) {
type *res;
res = new_type(type_pointer, mode_p, name);
res->attr.pa.points_to = points_to;
......@@ -1088,6 +1119,11 @@ type *new_type_pointer (ident *name, type *points_to) {
res->state = layout_fixed;
return res;
}
type *new_d_type_pointer (ident *name, type *points_to, dbg_info* db) {
type *res = new_type_pointer (name, points_to);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_pointer_attrs (type *pointer) {
assert(pointer && (pointer->type_op == type_pointer));
}
......@@ -1113,7 +1149,7 @@ bool is_pointer_type (type *pointer) {
/*******************************************************************/
/* create a new type primitive */
type *new_type_primitive (ident *name, ir_mode *mode) {
INLINE type *new_type_primitive (ident *name, ir_mode *mode) {
type *res;
/* @@@ assert( mode_is_data(mode) && (!mode == mode_p)); */
res = new_type(type_primitive, mode, name);
......@@ -1121,6 +1157,11 @@ type *new_type_primitive (ident *name, ir_mode *mode) {
res->state = layout_fixed;
return res;
}
type *new_d_type_primitive (ident *name, ir_mode *mode, dbg_info* db) {
type *res = new_type_primitive (name, mode);
set_type_dbg_info(res, db);
return res;
}
INLINE void free_primitive_attrs (type *primitive) {
assert(primitive && (primitive->type_op == type_primitive));
}
......
......@@ -38,6 +38,7 @@
# include "ident.h"
# include "irmode.h"
# include "bool.h"
# include "dbginfo.h"
#ifndef _ENTITY_TYPEDEF_
......@@ -104,7 +105,10 @@ typedef struct ir_node ir_node;
* class, struct, method, union, array, enumeration, pointer, primitive
* SOURCE
*/
#ifndef _TYPE_TYPEDEF_
#define _TYPE_TYPEDEF_
typedef struct type type;
#endif
# include "type_or_entity.h"
......@@ -304,6 +308,7 @@ bool smaller_type (type *st, type *lt);
*/
/* create a new class type */
type *new_type_class (ident *name);
type *new_d_type_class (ident *name, dbg_info *db);
/** manipulate private fields of class type **/
/* Adds the entity as member of the class. */
......@@ -405,6 +410,7 @@ bool is_subclass_of(type *low, type *high);
*/
/* create a new type struct */
type *new_type_struct (ident *name);
type *new_d_type_struct (ident *name, dbg_info* db);
/* manipulate private fields of struct */
void add_struct_member (type *strct, entity *member);
......@@ -451,6 +457,7 @@ bool is_struct_type(type *strct);
The arrays for the parameter and result types are not initialized by
the constructor. */
type *new_type_method (ident *name, int n_param, int n_res);
type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db);
/* manipulate private fields of method. */
int get_method_n_params (type *method);
......@@ -479,6 +486,7 @@ bool is_method_type (type *method);
*/
/* create a new type union */
type *new_type_union (ident *name);
type *new_d_type_union (ident *name, dbg_info* db);
/* manipulate private fields of struct */
int get_union_n_members (type *uni);
......@@ -492,17 +500,6 @@ void remove_union_member (type *uni, entity *member);
bool is_union_type (type *uni);
/*****/
#if 0
/* We don't need these if the union has entities, which it now
does. The entities are necessary for the analysis algorithms. */
type *get_union_unioned_type (type *uni, int pos);
void set_union_unioned_type (type *uni, int pos, type *type);
ident *get_union_delim_nameid (type *uni, int pos);
const char *get_union_delim_name (type *uni, int pos);
void set_union_delim_nameid (type *uni, int pos, ident *id);
#endif
/****** type/array
* NAME
* Representation of an array type.
......@@ -529,6 +526,8 @@ void set_union_delim_nameid (type *uni, int pos, ident *id);
Set dimension sizes after call to constructor with set_* routines. */
type *new_type_array (ident *name, int n_dimensions,
type *element_type);
type *new_d_type_array (ident *name, int n_dimensions,
type *element_type, dbg_info* db);
/* manipulate private fields of array type */
int get_array_n_dimensions (type *array);
......@@ -574,6 +573,7 @@ bool is_array_type (type *array);
*/
/* create a new type enumeration -- set the enumerators independently */
type *new_type_enumeration (ident *name, int n_enums);
type *new_d_type_enumeration (ident *name, int n_enums, dbg_info* db);
/* manipulate fields of enumeration type. */
int get_enumeration_n_enums (type *enumeration);
......@@ -600,6 +600,7 @@ bool is_enumeration_type (type *enumeration);
*/
/* Create a new type pointer */
type *new_type_pointer (ident *name, type *points_to);
type *new_d_type_pointer (ident *name, type *points_to, dbg_info* db);
/* manipulate fields of type_pointer */
void set_pointer_points_to_type (type *pointer, type *type);
......@@ -620,6 +621,7 @@ bool is_pointer_type (type *pointer);
*/
/* create a new type primitive */
type *new_type_primitive (ident *name, ir_mode *mode);
type *new_d_type_primitive (ident *name, ir_mode *mode, dbg_info* db);
/* typecheck */
bool is_primitive_type (type *primitive);
......
......@@ -109,6 +109,7 @@ struct type {
ir_mode *mode; /* The mode for atomic types */
unsigned long visit; /* visited counter for walks of the type information */
void *link; /* holds temporary data - like in irnode_t.h */
struct dbg_info* dbi; /* A pointer to information for debug support. */
tp_attr attr; /* type kind specific fields. This must be the last
entry in this struct! Varying size! */
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment