summaryrefslogtreecommitdiffstats
path: root/src/net/java/games/gluegen/cgram
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/games/gluegen/cgram')
-rw-r--r--src/net/java/games/gluegen/cgram/types/Type.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/net/java/games/gluegen/cgram/types/Type.java b/src/net/java/games/gluegen/cgram/types/Type.java
index 531393aa5..440a762e0 100644
--- a/src/net/java/games/gluegen/cgram/types/Type.java
+++ b/src/net/java/games/gluegen/cgram/types/Type.java
@@ -225,7 +225,8 @@ public abstract class Type {
}
/** Helper method for determining how many pointer indirections this
- type represents (i.e., "void **" returns 2). */
+ type represents (i.e., "void **" returns 2). Returns 0 if this
+ type is not a pointer type. */
public int pointerDepth() {
PointerType pt = asPointer();
if (pt == null) {
@@ -234,6 +235,17 @@ public abstract class Type {
return 1 + pt.getTargetType().pointerDepth();
}
+ /** Helper method for determining how many array dimentions this
+ type represents (i.e., "char[][]" returns 2). Returns 0 if this
+ type is not an array type. */
+ public int arrayDimension() {
+ ArrayType arrayType = asArray();
+ if (arrayType == null) {
+ return 0;
+ }
+ return 1 + arrayType.getElementType().arrayDimension();
+ }
+
/** Helper routine for list equality comparison */
static boolean listsEqual(List a, List b) {
return ((a == null && b == null) ||