Access routine to tarval
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 28 Jun 2002 10:00:13 +0000 (10:00 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 28 Jun 2002 10:00:13 +0000 (10:00 +0000)
[r423]

ir/tv/tv.c
ir/tv/tv.h

index a69f45d..e0b825f 100644 (file)
@@ -1779,9 +1779,20 @@ get_tv_mode (tarval *tv)
   return tv->mode;
 }
 
-
-entity *get_tv_entity(tarval *tv)
-{
-  /*assert(??? && "not a pointer to an entity");*/
-  return tv->u.p.ent;
+/* Returns the entity if the tv is a pointer to an entity, else
+   returns NULL; */
+entity *get_tv_entity(tarval *tv) {
+  entity *ent = NULL;
+
+  if (tv->mode == mode_p) {
+    if (tv->u.p.xname) {
+      assert(0);
+      /* not an entity */
+    } else if (tv->u.p.ent) {
+      ent = tv->u.p.ent;
+    } else {
+      /* not an entity */
+    }
+  }
+  return ent;
 }
index b38bdf3..3b17160 100644 (file)
@@ -208,6 +208,9 @@ void tarval_stats (void);
 #endif
 
 ir_mode *get_tv_mode (tarval *tv);
+/* Returns the entity if the tv is a pointer to an entity, else
+   returns NULL; */
 entity *get_tv_entity(tarval *tv);
 
+
 #endif