From a589d14815569918d18568a397995cf6e0b67021 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Fri, 28 Jun 2002 10:00:13 +0000 Subject: [PATCH] Access routine to tarval [r423] --- ir/tv/tv.c | 21 ++++++++++++++++----- ir/tv/tv.h | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ir/tv/tv.c b/ir/tv/tv.c index a69f45d8c..e0b825fba 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -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; } diff --git a/ir/tv/tv.h b/ir/tv/tv.h index b38bdf37b..3b17160c1 100644 --- a/ir/tv/tv.h +++ b/ir/tv/tv.h @@ -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 -- 2.20.1