summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-07 06:22:00 -0500
committermidipix <writeonce@midipix.org>2016-01-07 06:22:00 -0500
commit3aebba9b602c353f6d9fe053d698d23d3589ee99 (patch)
treec3c2ac37149e0d834d389de999fbe11d55c3608d
parent047bc5b40b4743e0b4c08507c68476b17c5aa016 (diff)
downloadapimagic-3aebba9b602c353f6d9fe053d698d23d3589ee99.tar.bz2
apimagic-3aebba9b602c353f6d9fe053d698d23d3589ee99.tar.xz
struct amgc_entity: add ptrdepth and its initialization bits.
-rw-r--r--include/apimagic/apimagic.h1
-rw-r--r--src/logic/amgc_unit_entities.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/include/apimagic/apimagic.h b/include/apimagic/apimagic.h
index 6762ab2..a93615f 100644
--- a/include/apimagic/apimagic.h
+++ b/include/apimagic/apimagic.h
@@ -113,6 +113,7 @@ struct amgc_entity {
const union entity_t * entity;
const char * altname;
int enumval;
+ int ptrdepth;
bool fmbstr;
bool futf16;
bool fset;
diff --git a/src/logic/amgc_unit_entities.c b/src/logic/amgc_unit_entities.c
index e5b9000..4309d89 100644
--- a/src/logic/amgc_unit_entities.c
+++ b/src/logic/amgc_unit_entities.c
@@ -6,6 +6,7 @@
#include <cparser/ast/ast_t.h>
#include <cparser/ast/entity_t.h>
+#include <cparser/ast/type_t.h>
#include <libfirm/tv.h>
#include <apimagic/apimagic.h>
@@ -40,10 +41,12 @@ int amgc_get_unit_entities(
struct amgc_entity * aentity;
struct amgc_unit_entities * uentities;
union entity_t * entity;
+ union type_t * etype;
struct amgc_unit_entities_impl *entities;
size_t ndefs;
size_t nelements;
int enumval;
+ int ptrdepth;
if (!meta)
meta = &umeta;
@@ -125,7 +128,14 @@ int amgc_get_unit_entities(
break;
case ENTITY_TYPEDEF:
+ etype = entity->declaration.type;
+ ptrdepth = 0;
+
+ for (; etype->kind == TYPE_POINTER; etype=etype->pointer.points_to)
+ ptrdepth++;
+
uentities->typedefs[meta->ntypedefs].entity = entity;
+ uentities->typedefs[meta->ntypedefs].ptrdepth = ptrdepth;
meta->ntypedefs++;
break;