From: Götz Lindenmaier Date: Fri, 28 Jun 2002 10:00:13 +0000 (+0000) Subject: Access routine to tarval X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=a589d14815569918d18568a397995cf6e0b67021;p=libfirm Access routine to tarval [r423] --- 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