Use is_Bad() where appropriate
[libfirm] / ir / ir / irdumptxt.c
index 24b91cd..743cd55 100644 (file)
@@ -6,7 +6,7 @@
  * Modified by: Goetz Lindenmaier, Hubert Schmidt
  * Created:
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universität Karlsruhe
+ * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 #ifdef HAVE_CONFIG_H
 
 #define MY_SIZE 1024     /* Size of an array that actually should be computed. */
 
-/* Just opens a file, mangling a file name.
+/**
+ * Just opens a file, mangling a file name.
  *
- * The name consists of the following parts:
- *
- * @arg basename  The basis of the name telling about the content.
- * @arg
+ * The file name results from the concatenation of the following parts:
  *
+ * @param basename  The basis of the name telling about the content.
+ * @param suffix1   The first suffix.
+ * @param suffix2   The second suffix.
+ * @param suffix3   The third suffix.
  */
-static FILE *text_open (const char *basename, const char * suffix1, const char *suffix2, const char *suffix3) {
+static FILE *text_open(const char *basename, const char * suffix1, const char *suffix2, const char *suffix3) {
   FILE *F;
   int len = strlen(basename), i, j;
   char *fname;  /* filename to put the vcg information in */
@@ -57,7 +59,7 @@ static FILE *text_open (const char *basename, const char * suffix1, const char *
   if (!suffix3) suffix3 = ".txt";
 
   /* open file for vcg graph */
-  fname = xmalloc (strlen(basename)*2 + strlen(suffix1) + strlen(suffix2) + 5); /* *2: space for excapes. */
+  fname = xmalloc(strlen(basename)*2 + strlen(suffix1) + strlen(suffix2) + 5); /* *2: space for escapes. */
 
   j = 0;
   for (i = 0; i < len; ++i) {  /* replace '/' in the name: escape by @. */
@@ -70,12 +72,13 @@ static FILE *text_open (const char *basename, const char * suffix1, const char *
     }
   }
   fname[j] = '\0';
-  strcat (fname, suffix1);  /* append file suffix */
-  strcat (fname, suffix2);  /* append file suffix */
-  strcat (fname, suffix3);  /* append the .txt suffix */
+  strcat(fname, suffix1);  /* append file suffix */
+  strcat(fname, suffix2);  /* append file suffix */
+  strcat(fname, suffix3);  /* append the .txt suffix */
 
-  F = fopen (fname, "w");   /* open file for writing */
+  F = fopen(fname, "w");   /* open file for writing */
   if (!F) {
+    perror(fname);
     assert(0);
   }
   free(fname);
@@ -284,6 +287,11 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
       fprintf(F, "  entity: ");
       dump_entity_to_file(F, get_SymConst_entity(n), dump_verbosity_onlynames);
       break;
+    case symconst_ofs_ent:
+      fprintf(F, "  kind:   offset\n");
+      fprintf(F, "  entity: ");
+      dump_entity_to_file(F, get_SymConst_entity(n), dump_verbosity_onlynames);
+      break;
     case symconst_type_tag:
       fprintf(F, "  kind: type_tag\n");
       fprintf(F, "  type: ");
@@ -299,6 +307,10 @@ int dump_irnode_to_file(FILE *F, ir_node *n) {
       fprintf(F, "  type: ");
       dump_type_to_file(F, get_SymConst_type(n), dump_verbosity_onlynames);
       break;
+    case symconst_enum_const:
+      fprintf(F, "  kind: enumeration\n");
+      fprintf(F, "  name: %s\n", get_enumeration_name(get_SymConst_enum(n)));
+      break;
     }
     fprintf(F, "  type of value: %s \n", get_type_name_ex(get_SymConst_value_type(n), &bad));
   } break;
@@ -424,7 +436,7 @@ static void dump_node_list(FILE *F, firm_kind *k, char *prefix,
   fprintf(F, "%s  %s (%d):", prefix, name, n_nodes);
   for (i = 0; i < n_nodes; ++i) {
     int rem;
-    if (i > 7 && !(i & 7)) { /* line break every eigth node. */
+    if (i > 7 && !(i & 7)) { /* line break every eight node. */
       fprintf(F, ",\n%s   ", prefix);
       comma = "";
     }
@@ -453,7 +465,7 @@ static void dump_type_list(FILE *F, ir_type *tp, char *prefix,
 
   fprintf(F, "%s  %s (%d):", prefix, name, n_nodes);
   for (i = 0; i < n_nodes; ++i) {
-    if (i > 7 && !(i & 7)) { /* line break every eigth node. */
+    if (i > 7 && !(i & 7)) { /* line break every eight node. */
       fprintf(F, ",\n%s   ", prefix);
       comma = "";
     }
@@ -557,6 +569,7 @@ void    dump_entity_to_file_prefix (FILE *F, entity *ent, char *prefix, unsigned
         fprintf(F, (cc & cc_last_on_top) ? "last param on top, " : "first param on top, ");
         fprintf(F, (cc & cc_callee_clear_stk) ? "callee clear stack" : "caller clear stack");
       }
+      fprintf(F, "\n%s  vtable number:        %u", prefix, get_entity_vtable_number(ent));
     }
 
     fprintf(F, "\n");
@@ -853,7 +866,7 @@ void    dump_entitycsv_to_file_prefix (FILE *F, entity *ent, char *prefix, unsig
   }
 }
 
-/* A fast hack to dump a csv. */
+/* A fast hack to dump a CSV-file. */
 void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const char *comma) {
   int i;
   char buf[1024 + 10];
@@ -973,12 +986,12 @@ void dump_type_to_file (FILE *F, ir_type *tp, dump_verbosity verbosity) {
       fprintf(F, "  supertypes: ");
       for (i = 0; i < get_class_n_supertypes(tp); ++i) {
         ir_type *stp = get_class_supertype(tp, i);
-        fprintf(F, "\n    %s", get_type_name(stp));
+        fprintf(F, "\n    %d %s", i, get_type_name(stp));
       }
       fprintf(F, "\n  subtypes: ");
       for (i = 0; i < get_class_n_subtypes(tp); ++i) {
         ir_type *stp = get_class_subtype(tp, i);
-        fprintf(F, "\n    %s", get_type_name(stp));
+        fprintf(F, "\n    %d %s", i, get_type_name(stp));
       }
 
       if (get_irp_inh_transitive_closure_state() != inh_transitive_closure_none) {
@@ -1187,10 +1200,10 @@ void dump_types_as_text(unsigned verbosity, const char *suffix) {
   int i, n_types = get_irp_n_types();
 
   basename = irp_prog_name_is_set() ? get_irp_prog_name() : "TextTypes";
-  F = text_open (basename, suffix, "-types", ".txt");
+  F = text_open(basename, suffix, "-types", ".txt");
 
   if (verbosity & dump_verbosity_csv) {
-    CSV = text_open (basename, suffix, "-types", ".csv");
+    CSV = text_open(basename, suffix, "-types", ".csv");
     //fprintf(CSV, "Class, Field, Operation, L0, L1, L2, L3\n");
   }
 
@@ -1205,8 +1218,8 @@ void dump_types_as_text(unsigned verbosity, const char *suffix) {
     }
   }
 
-  fclose (F);
-  if (CSV) fclose (CSV);
+  fclose(F);
+  if (CSV) fclose(CSV);
 }