- char buf[1024];
- ir_enum_const *ec = get_enumeration_const(tp, pos);
- ident *id = get_enumeration_nameid(ec);
- tarval *tv = get_enumeration_value(ec);
-
- if (tv)
- tarval_snprintf(buf, sizeof(buf), tv);
- else
- strncpy(buf, "<not set>", sizeof(buf));
- fprintf(F, "node: {title: \"");
- PRINT_ITEMID(tp, pos); fprintf(F, "\"");
- fprintf(F, DEFAULT_ENUM_ITEM_ATTRIBUTE);
- fprintf(F, "label: ");
- fprintf(F, "\"enum item %s\" " ENUM_ITEM_NODE_ATTR, get_id_str(id));
- fprintf(F, "\n info1: \"value: %s\"}\n", buf);
-}
-
-/* dumps a type or entity and it's edges. */
-static void
-dump_type_info(type_or_ent *tore, void *env) {
- FILE *F = env;
- int i = 0; /* to shutup gcc */
-
- /* dump this type or entity */
-
- switch (get_kind(tore)) {
- case k_entity:
- {
- ir_entity *ent = (ir_entity *)tore;
- ir_node *value;
- /* The node */
- dump_entity_node(F, ent, 0);
- /* The Edges */
- /* skip this to reduce graph. Member edge of type is parallel to this edge. *
- fprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
- ENT_OWN_EDGE_ATTR "}\n", ent, get_entity_owner(ent));*/
- print_ent_type_edge(F,ent, get_entity_type(ent), ENT_TYPE_EDGE_ATTR);
- if (is_Class_type(get_entity_owner(ent))) {
- for(i = 0; i < get_entity_n_overwrites(ent); i++)
- print_ent_ent_edge(F,ent, get_entity_overwrites(ent, i), 0, ENT_OVERWRITES_EDGE_ATTR);
- }
- /* attached subgraphs */
- if (const_entities && (get_entity_variability(ent) != variability_uninitialized)) {
- if (is_atomic_entity(ent)) {
- value = get_atomic_ent_value(ent);
- if (value) {
- print_ent_node_edge(F, ent, value, ENT_VALUE_EDGE_ATTR, i);
- /* DDMN(value); $$$ */
- dump_const_expression(F, value);
- }
- }
- if (is_compound_entity(ent)) {
- for (i = 0; i < get_compound_ent_n_values(ent); i++) {
- value = get_compound_ent_value(ent, i);
- if (value) {
- print_ent_node_edge(F, ent, value, ENT_VALUE_EDGE_ATTR, i);
- dump_const_expression(F, value);
- print_ent_ent_edge(F, ent, get_compound_ent_value_member(ent, i), 0, ENT_CORR_EDGE_ATTR, i);
- /*
- fprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
- ENT_CORR_EDGE_ATTR "}\n", GET_ENTID(ent),
- get_compound_ent_value_member(ent, i), i);
- */
- }
- }
- }
- }
- } break;
- case k_type:
- {
- ir_type *tp = (ir_type *)tore;
- dump_type_node(F, tp);
- /* and now the edges */
- switch (get_type_tpop_code(tp)) {
- case tpo_class:
- {
- for (i=0; i < get_class_n_supertypes(tp); i++)
- print_type_type_edge(F, tp,get_class_supertype(tp, i),TYPE_SUPER_EDGE_ATTR);
- for (i=0; i < get_class_n_members(tp); i++)
- print_type_ent_edge(F,tp,get_class_member(tp, i),TYPE_MEMBER_EDGE_ATTR);
- } break;
- case tpo_struct:
- {
- for (i=0; i < get_struct_n_members(tp); i++)
- print_type_ent_edge(F,tp,get_struct_member(tp, i),TYPE_MEMBER_EDGE_ATTR);
- } break;
- case tpo_method:
- {
- for (i = 0; i < get_method_n_params(tp); i++)
- print_type_type_edge(F,tp,get_method_param_type(tp, i),METH_PAR_EDGE_ATTR,i);
- for (i = 0; i < get_method_n_ress(tp); i++)
- print_type_type_edge(F,tp,get_method_res_type(tp, i),METH_RES_EDGE_ATTR,i);
- } break;
- case tpo_union:
- {
- for (i = 0; i < get_union_n_members(tp); i++)
- print_type_ent_edge(F,tp,get_union_member(tp, i),UNION_EDGE_ATTR);
- } break;
- case tpo_array:
- {
- print_type_type_edge(F,tp,get_array_element_type(tp),ARR_ELT_TYPE_EDGE_ATTR);
- print_type_ent_edge(F,tp,get_array_element_entity(tp),ARR_ENT_EDGE_ATTR);
- for (i = 0; i < get_array_n_dimensions(tp); i++) {
- ir_node *upper = get_array_upper_bound(tp, i);
- ir_node *lower = get_array_lower_bound(tp, i);
- print_node_type_edge(F, upper, tp, "label: \"upper %d\"", get_array_order(tp, i));
- print_node_type_edge(F, lower, tp, "label: \"lower %d\"", get_array_order(tp, i));
- dump_const_expression(F, upper);
- dump_const_expression(F, lower);
- }
-
- } break;
- case tpo_enumeration:
- {
- for (i = 0; i < get_enumeration_n_enums(tp); ++i) {
- dump_enum_item(F, tp, i);
- print_enum_item_edge(F, tp, i, "label: \"item %d\"", i);
- }
- } break;
- case tpo_pointer:
- {
- print_type_type_edge(F,tp,get_pointer_points_to_type(tp), PTR_PTS_TO_EDGE_ATTR);
- } break;
- case tpo_primitive:
- {
- } break;
- default: break;
- } /* switch type */
- }
- break; /* case k_type */
- default:
- {
- printf(" *** irdump, dump_type_info(l.%i), faulty type.\n", __LINE__);
- } break;
- } /* switch kind_or_entity */
+ char buf[1024];
+ ir_enum_const *ec = get_enumeration_const(tp, pos);
+ ident *id = get_enumeration_const_nameid(ec);
+ tarval *tv = get_enumeration_value(ec);
+
+ if (tv)
+ tarval_snprintf(buf, sizeof(buf), tv);
+ else
+ strncpy(buf, "<not set>", sizeof(buf));
+ fprintf(F, "node: {title: \"");
+ PRINT_ITEMID(tp, pos); fprintf(F, "\"");
+ fprintf(F, DEFAULT_ENUM_ITEM_ATTRIBUTE);
+ fprintf(F, "label: ");
+ fprintf(F, "\"enum item %s\" " ENUM_ITEM_NODE_ATTR, get_id_str(id));
+ fprintf(F, "\n info1: \"value: %s\"}\n", buf);
+}
+
+/**
+ * Dumps a new style initializer.
+ */
+static void dump_entity_initializer(FILE *F, const ir_entity *ent) {
+ /* TODO */
+ (void) F;
+ (void) ent;
+}
+
+/** Dumps a type or entity and it's edges. */
+static void dump_type_info(type_or_ent tore, void *env) {
+ FILE *F = env;
+ int i = 0; /* to shutup gcc */
+
+ /* dump this type or entity */
+
+ switch (get_kind(tore.ent)) {
+ case k_entity: {
+ ir_entity *ent = tore.ent;
+ ir_node *value;
+ /* The node */
+ dump_entity_node(F, ent);
+ /* The Edges */
+ /* skip this to reduce graph. Member edge of type is parallel to this edge. *
+ fprintf(F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+ ENT_OWN_EDGE_ATTR "}\n", ent, get_entity_owner(ent));*/
+ print_ent_type_edge(F,ent, get_entity_type(ent), ENT_TYPE_EDGE_ATTR);
+ if (is_Class_type(get_entity_owner(ent))) {
+ for (i = get_entity_n_overwrites(ent) - 1; i >= 0; --i)
+ print_ent_ent_edge(F,ent, get_entity_overwrites(ent, i), 0, -1, ENT_OVERWRITES_EDGE_ATTR);
+ }
+ /* attached subgraphs */
+ if (const_entities) {
+ if (ent->initializer != NULL) {
+ /* new style initializers */
+ dump_entity_initializer(F, ent);
+ } else if (entity_has_compound_ent_values(ent)) {
+ /* old style compound entity values */
+ for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i) {
+ value = get_compound_ent_value(ent, i);
+ if (value) {
+ print_ent_node_edge(F, ent, value, ENT_VALUE_EDGE_ATTR, i);
+ dump_const_expression(F, value);
+ print_ent_ent_edge(F, ent, get_compound_ent_value_member(ent, i), 0, -1, ENT_CORR_EDGE_ATTR, i);
+ /*
+ fprintf(F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+ ENT_CORR_EDGE_ATTR "}\n", GET_ENTID(ent),
+ get_compound_ent_value_member(ent, i), i);
+ */
+ }
+ }
+ }
+ }
+ break;
+ }
+ case k_type: {
+ ir_type *tp = tore.typ;
+ dump_type_node(F, tp);
+ /* and now the edges */
+ switch (get_type_tpop_code(tp)) {
+ case tpo_class:
+ for (i = get_class_n_supertypes(tp) - 1; i >= 0; --i)
+ print_type_type_edge(F, tp, get_class_supertype(tp, i), TYPE_SUPER_EDGE_ATTR);
+ for (i = get_class_n_members(tp) - 1; i >= 0; --i)
+ print_type_ent_edge(F, tp, get_class_member(tp, i), TYPE_MEMBER_EDGE_ATTR);
+ break;
+ case tpo_struct:
+ for (i = get_struct_n_members(tp) - 1; i >= 0; --i)
+ print_type_ent_edge(F, tp, get_struct_member(tp, i), TYPE_MEMBER_EDGE_ATTR);
+ break;
+ case tpo_method:
+ for (i = get_method_n_params(tp) - 1; i >= 0; --i)
+ print_type_type_edge(F, tp, get_method_param_type(tp, i), METH_PAR_EDGE_ATTR,i);
+ for (i = get_method_n_ress(tp) - 1; i >= 0; --i)
+ print_type_type_edge(F, tp, get_method_res_type(tp, i), METH_RES_EDGE_ATTR,i);
+ break;
+ case tpo_union:
+ for (i = get_union_n_members(tp) - 1; i >= 0; --i)
+ print_type_ent_edge(F, tp, get_union_member(tp, i), UNION_EDGE_ATTR);
+ break;
+ case tpo_array:
+ print_type_type_edge(F, tp, get_array_element_type(tp), ARR_ELT_TYPE_EDGE_ATTR);
+ print_type_ent_edge(F, tp, get_array_element_entity(tp), ARR_ENT_EDGE_ATTR);
+ for (i = get_array_n_dimensions(tp) - 1; i >= 0; --i) {
+ ir_node *upper = get_array_upper_bound(tp, i);
+ ir_node *lower = get_array_lower_bound(tp, i);
+ print_node_type_edge(F, upper, tp, "label: \"upper %d\"", get_array_order(tp, i));
+ print_node_type_edge(F, lower, tp, "label: \"lower %d\"", get_array_order(tp, i));
+ dump_const_expression(F, upper);
+ dump_const_expression(F, lower);
+ }
+ break;
+ case tpo_enumeration:
+ for (i = get_enumeration_n_enums(tp) - 1; i >= 0; --i) {
+ dump_enum_item(F, tp, i);
+ print_enum_item_edge(F, tp, i, "label: \"item %d\"", i);
+ }
+ break;
+ case tpo_pointer:
+ print_type_type_edge(F, tp, get_pointer_points_to_type(tp), PTR_PTS_TO_EDGE_ATTR);
+ break;
+ case tpo_primitive:
+ break;
+ default:
+ break;
+ } /* switch type */
+ break; /* case k_type */
+ }
+ default:
+ printf(" *** irdump, dump_type_info(l.%i), faulty type.\n", __LINE__);
+ } /* switch kind_or_entity */