added a routine to compute array indicees.
[libfirm] / ir / tr / trvrfy.c
index de44d6c..b84fc04 100644 (file)
@@ -9,6 +9,9 @@
  * Copyright:   (c) 2003 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "trvrfy.h"
 #include "irgraph_t.h"  /* for checking whether constant code is allocated
@@ -57,6 +60,17 @@ static int check_class(type *tp) {
   return 0;
 }
 
+/**
+ * Check an array.
+ */
+static int check_array(type *tp) {
+  int i, n_dim = get_array_n_dimensions(tp);
+  for (i = 0; i < n_dim; ++i)
+    assert(has_array_lower_bound(tp, i) || has_array_upper_bound(tp, i));
+
+  return 0;
+}
+
 /**
  * Checks a type.
  *
@@ -66,6 +80,8 @@ static int check_type(type *tp) {
   switch (get_type_tpop_code(tp)) {
   case tpo_class:
     return check_class(tp);
+  case tpo_array:
+    return check_array(tp);
   default: break;
   }
   return 0;
@@ -110,7 +126,7 @@ static int constant_on_wrong_irg(ir_node *n) {
  * Check if constants node are NOT on the constant IR graph.
  */
 static int constants_on_wrong_irg(entity *ent) {
-  if (get_entity_variability(ent) == uninitialized) return 0;
+  if (get_entity_variability(ent) == variability_uninitialized) return 0;
 
   if (is_compound_entity(ent)) {
     int i;
@@ -124,7 +140,7 @@ static int constants_on_wrong_irg(entity *ent) {
       return constant_on_wrong_irg(get_atomic_ent_value(ent));
     else
       assert((is_class_type(get_entity_owner(ent)) &&
-             get_class_peculiarity(get_entity_owner(ent)) == description) &&
+             get_class_peculiarity(get_entity_owner(ent)) == peculiarity_description) &&
             "Value in constant atomic entity not set.");
   }
   return 0;
@@ -144,6 +160,15 @@ static int check_entity(entity *ent) {
     assert(0 && "Contants placed on wrong IRG");
     return error_const_on_wrong_irg;
   }
+
+  if ((get_entity_peculiarity(ent) == peculiarity_existent) &&
+      (get_entity_visibility(ent) != visibility_external_allocated) &&
+      (is_method_type(get_entity_type(ent)))                &&
+      (!get_entity_irg(ent) || !(is_ir_graph(get_entity_irg(ent))))) {
+    assert(0 && "Method ents with pec_exist must have an irg");
+    return error_existent_entity_without_irg;
+  }
+
   return 0;
 }