summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/cgram
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/gluegen/cgram')
-rw-r--r--src/java/com/jogamp/gluegen/cgram/TNode.java24
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/EnumType.java17
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java15
3 files changed, 49 insertions, 7 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/TNode.java b/src/java/com/jogamp/gluegen/cgram/TNode.java
index a564c54..70dc2c4 100644
--- a/src/java/com/jogamp/gluegen/cgram/TNode.java
+++ b/src/java/com/jogamp/gluegen/cgram/TNode.java
@@ -3,10 +3,14 @@ package com.jogamp.gluegen.cgram;
import antlr.collections.AST;
import antlr.CommonAST;
import antlr.Token;
+
import java.lang.reflect.*;
import java.util.Hashtable;
import java.util.Enumeration;
+import com.jogamp.gluegen.ASTLocusTag;
+import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
+
/**
Class TNode is an implementation of the AST interface
and adds many useful features:
@@ -29,7 +33,8 @@ import java.util.Enumeration;
*/
-public class TNode extends CommonAST {
+@SuppressWarnings("serial")
+public class TNode extends CommonAST implements ASTLocusTagProvider {
protected int ttype;
protected String text;
protected int lineNum = 0;
@@ -40,7 +45,22 @@ public class TNode extends CommonAST {
protected Hashtable<String, Object> attributes = null;
static String tokenVocabulary;
-
+ /**
+ * {@inheritDoc}
+ * <p>
+ * If <i>source</i> is not available,
+ * implementation returns {@code null}.
+ * </p>
+ */
+ @Override
+ public ASTLocusTag getASTLocusTag() {
+ final Object s = getAttribute("source");
+ if( null != s ) {
+ return new ASTLocusTag(s, getLineNum(), -1, getText());
+ } else {
+ return null;
+ }
+ }
/** Set the token vocabulary to a tokentypes class
diff --git a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java b/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
index f0e71dc..7fa22e4 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
@@ -42,12 +42,14 @@ package com.jogamp.gluegen.cgram.types;
import java.util.ArrayList;
import java.util.NoSuchElementException;
+import com.jogamp.gluegen.ASTLocusTag;
+import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
/** Describes enumerated types. Enumerations are like ints except that
they have a set of named values. */
-public class EnumType extends IntType implements Cloneable {
+public class EnumType extends IntType implements Cloneable, ASTLocusTagProvider {
private IntType underlyingType;
@@ -101,23 +103,30 @@ public class EnumType extends IntType implements Cloneable {
}
private ArrayList<Enum> enums;
+ private final ASTLocusTag astLocus;
public EnumType(final String name) {
super(name, SizeThunk.LONG, false, CVAttributes.CONST);
this.underlyingType = new IntType(name, SizeThunk.LONG, false, CVAttributes.CONST);
+ this.astLocus = null;
}
- public EnumType(final String name, final SizeThunk enumSizeInBytes) {
+ public EnumType(final String name, final SizeThunk enumSizeInBytes, final ASTLocusTag astLocus) {
super(name, enumSizeInBytes, false, CVAttributes.CONST);
this.underlyingType = new IntType(name, enumSizeInBytes, false, CVAttributes.CONST);
+ this.astLocus = astLocus;
}
- protected EnumType(final String name, final IntType underlyingType, final int cvAttributes) {
+ protected EnumType(final String name, final IntType underlyingType, final int cvAttributes, final ASTLocusTag astLocus) {
super(name, underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes);
this.underlyingType = underlyingType;
+ this.astLocus = astLocus;
}
@Override
+ public ASTLocusTag getASTLocusTag() { return astLocus; }
+
+ @Override
public Object clone() {
final EnumType n = (EnumType) super.clone();
if(null!=this.underlyingType) {
@@ -244,7 +253,7 @@ public class EnumType extends IntType implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- final EnumType t = new EnumType(getName(), underlyingType, cvAttributes);
+ final EnumType t = new EnumType(getName(), underlyingType, cvAttributes, astLocus);
t.enums = enums;
return t;
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
index ee68b68..2b78e8c 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
@@ -40,6 +40,8 @@ package com.jogamp.gluegen.cgram.types;
import java.util.List;
+import com.jogamp.gluegen.ASTLocusTag;
+import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
import com.jogamp.gluegen.cgram.types.AliasedSymbol.AliasedSymbolImpl;
import com.jogamp.gluegen.cgram.types.TypeComparator.AliasedSemanticSymbol;
import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
@@ -57,15 +59,26 @@ import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
* Deep comparison can be performed via {@link #isCompletelyEqual(Object o)};
* </p>
**/
-public class FunctionSymbol extends AliasedSymbolImpl implements AliasedSemanticSymbol {
+public class FunctionSymbol extends AliasedSymbolImpl implements AliasedSemanticSymbol, ASTLocusTagProvider {
private final FunctionType type;
+ private final ASTLocusTag astLocus;
public FunctionSymbol(final String name, final FunctionType type) {
super(name);
this.type = type;
+ this.astLocus = null;
}
+ public FunctionSymbol(final String name, final FunctionType type, final ASTLocusTag locus) {
+ super(name);
+ this.type = type;
+ this.astLocus = locus;
+ }
+
+ @Override
+ public ASTLocusTag getASTLocusTag() { return astLocus; }
+
/** Returns the type of this function. Do not add arguments to it
directly; use addArgument instead. */
public FunctionType getType() {