aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/cgram
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-08 00:06:11 +0100
committerSven Gothel <[email protected]>2015-03-08 00:06:11 +0100
commitda909f84dc8421052c92491baa7dd90e1c78dc8f (patch)
tree60aca793c01b0e56c1628f8ccdac448f96541ad0 /src/java/com/jogamp/gluegen/cgram
parente2d5d6f55794c5e27c3a29dcbbdaf2921506667d (diff)
Bug 1134 - Use ASTLocationTag in Logging (PCPP, Emitter); Refine ASTLocationTag log/exception formatting.
Since commit eca019cdea4017227e951d8a9eb30cb34fca4a07, we have ASTLocationTag available. Hence use it for all logging purposes and emit a standard compiler output, which shall be parsable by other tools.
Diffstat (limited to 'src/java/com/jogamp/gluegen/cgram')
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/ArrayType.java16
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/CompoundType.java5
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/PointerType.java19
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/Type.java69
4 files changed, 53 insertions, 56 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
index 672bccf..cabbcc1 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
@@ -99,20 +99,20 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
}
@Override
- public ArrayType asArray() { return this; }
+ public final ArrayType asArray() { return this; }
public Type getElementType() { return elementType; }
public int getLength() { return length; }
public boolean hasLength() { return length >= 0; }
@Override
- public Type getBaseElementType() {
- ArrayType t = this;
- while (t.getElementType().isArray()) {
- t = t.getElementType().asArray();
- }
- return t.getElementType();
- // return elementType.getBaseElementType();
+ public final Type getBaseElementType() {
+ return elementType.getBaseElementType();
+ }
+
+ @Override
+ public final int arrayDimension() {
+ return 1 + elementType.arrayDimension();
}
/** Recompute the size of this array if necessary. This needs to be
diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
index 264389b..dc5becf 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
@@ -161,11 +161,6 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable
}
@Override
- public void setSize(final SizeThunk size) {
- super.setSize(size);
- }
-
- @Override
public CompoundType asCompound() { return this; }
@Override
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
index 1528f9f..76cb4b3 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
@@ -109,32 +109,31 @@ public class PointerType extends Type implements Cloneable {
}
@Override
- public PointerType asPointer() {
+ public final PointerType asPointer() {
return this;
}
@Override
- public Type getTargetType() {
+ public final Type getTargetType() {
return targetType;
}
@Override
- public Type getBaseElementType() {
- /**
- if(targetType.isPointer()) {
- return ((PointerType)targetType).getBaseElementType();
- } else {
- return targetType;
- } */
+ public final Type getBaseElementType() {
return targetType.getBaseElementType();
}
@Override
- public boolean isFunctionPointer() {
+ public final boolean isFunctionPointer() {
return targetType.isFunction();
}
@Override
+ public final int pointerDepth() {
+ return 1 + targetType.pointerDepth();
+ }
+
+ @Override
public String toString() {
if ( isTypedef() ) {
return super.getCName(true);
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/cgram/types/Type.java
index bc1b155..04ea3a3 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Type.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/Type.java
@@ -134,7 +134,7 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
}
- private StringBuilder append(final StringBuilder sb, final String val, final boolean prepComma) {
+ private static StringBuilder append(final StringBuilder sb, final String val, final boolean prepComma) {
if( prepComma ) {
sb.append(", ");
}
@@ -142,11 +142,11 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
return sb;
}
// For debugging
- public String getDebugString() {
+ public final String getDebugString() {
return getDebugString(false);
}
// For debugging
- public String getDebugString(final boolean withASTLoc) {
+ public final String getDebugString(final boolean withASTLoc) {
final StringBuilder sb = new StringBuilder();
boolean prepComma = false;
sb.append("CType[");
@@ -286,7 +286,7 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
* of hashes.
* </p>
*/
- public void setTypedefName(final String name) {
+ public final void setTypedefName(final String name) {
if( setName(name) ) {
// Capture the const/volatile attributes at the time of typedef so
// we don't redundantly repeat them in the CV attributes string
@@ -326,9 +326,9 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
}
/** SizeThunk which computes size of this type in bytes. */
- public SizeThunk getSize() { return size; }
+ public final SizeThunk getSize() { return size; }
/** Size of this type in bytes according to the given MachineDataInfo. */
- public long getSize(final MachineDataInfo machDesc) {
+ public final long getSize(final MachineDataInfo machDesc) {
final SizeThunk thunk = getSize();
if (thunk == null) {
throw new RuntimeException("No size set for type \"" + getName() + "\"");
@@ -336,7 +336,7 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
return thunk.computeSize(machDesc);
}
/** Set the size of this type; only available for CompoundTypes. */
- void setSize(final SizeThunk size) {
+ final void setSize(final SizeThunk size) {
this.size = size;
clearCache();
}
@@ -363,40 +363,51 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
public VoidType asVoid() { return null; }
/** Indicates whether this is a BitType. */
- public boolean isBit() { return (asBit() != null); }
+ public final boolean isBit() { return (asBit() != null); }
/** Indicates whether this is an IntType. */
- public boolean isInt() { return (asInt() != null); }
+ public final boolean isInt() { return (asInt() != null); }
/** Indicates whether this is an EnumType. */
- public boolean isEnum() { return (asEnum() != null); }
+ public final boolean isEnum() { return (asEnum() != null); }
/** Indicates whether this is a FloatType. */
- public boolean isFloat() { return (asFloat() != null); }
+ public final boolean isFloat() { return (asFloat() != null); }
/** Indicates whether this is a DoubleType. */
- public boolean isDouble() { return (asDouble() != null); }
+ public final boolean isDouble() { return (asDouble() != null); }
/** Indicates whether this is a PointerType. */
- public boolean isPointer() { return (asPointer() != null); }
+ public final boolean isPointer() { return (asPointer() != null); }
/** Indicates whether this is an ArrayType. */
- public boolean isArray() { return (asArray() != null); }
+ public final boolean isArray() { return (asArray() != null); }
/** Indicates whether this is a CompoundType. */
- public boolean isCompound() { return (asCompound() != null); }
+ public final boolean isCompound() { return (asCompound() != null); }
/** Indicates whether this is a FunctionType. */
- public boolean isFunction() { return (asFunction() != null); }
+ public final boolean isFunction() { return (asFunction() != null); }
/** Indicates whether this is a VoidType. */
- public boolean isVoid() { return (asVoid() != null); }
+ public final boolean isVoid() { return (asVoid() != null); }
/** Indicates whether this type is volatile. */
- public boolean isVolatile() { return 0 != ( ( cvAttributes & ~typedefCVAttributes ) & CVAttributes.VOLATILE ); }
+ public final boolean isVolatile() { return 0 != ( ( cvAttributes & ~typedefCVAttributes ) & CVAttributes.VOLATILE ); }
/** Indicates whether this type is const. */
- public boolean isConst() { return 0 != ( ( cvAttributes & ~typedefCVAttributes ) & CVAttributes.CONST ); }
- private boolean isConstTypedef() { return 0 != ( typedefCVAttributes & CVAttributes.CONST ); }
- private boolean isConstRaw() { return 0 != ( cvAttributes & CVAttributes.CONST ); }
+ public final boolean isConst() { return 0 != ( ( cvAttributes & ~typedefCVAttributes ) & CVAttributes.CONST ); }
+
+ private final boolean isConstTypedef() { return 0 != ( typedefCVAttributes & CVAttributes.CONST ); }
+ private final boolean isConstRaw() { return 0 != ( cvAttributes & CVAttributes.CONST ); }
/** Indicates whether this type is a primitive type. */
- public boolean isPrimitive(){ return false; }
+ public boolean isPrimitive(){ return false; }
/** Convenience routine indicating whether this Type is a pointer to
a function. */
public boolean isFunctionPointer() {
- return (isPointer() && asPointer().getTargetType().isFunction());
+ return false;
+ }
+
+ /**
+ * Checks the base type of pointer-to-pointer, pointer, array or plain for const-ness.
+ * <p>
+ * Note: Intermediate 'const' qualifier are not considered, e.g. const pointer.
+ * </p>
+ */
+ public final boolean isBaseTypeConst() {
+ return getBaseElementType().isConst();
}
/** Hashcode for Types. */
@@ -524,22 +535,14 @@ public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTag
type represents (i.e., "void **" returns 2). Returns 0 if this
type is not a pointer type. */
public int pointerDepth() {
- final PointerType pt = asPointer();
- if (pt == null) {
- return 0;
- }
- return 1 + pt.getTargetType().pointerDepth();
+ return 0;
}
/** 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() {
- final ArrayType arrayType = asArray();
- if (arrayType == null) {
- return 0;
- }
- return 1 + arrayType.getElementType().arrayDimension();
+ return 0;
}
/**