aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-06-15 22:42:48 +0000
committerKenneth Russel <[email protected]>2009-06-15 22:42:48 +0000
commitc91f003551542c2aab62dd8ef89a7894c7e50689 (patch)
treee49c45b21c3ebeb8d238e8eb96415c745f9427da /src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java
parent90bcb596e88898f807b39c9e7c85485ab8c006b6 (diff)
Copied JOGL_2_SANDBOX r145 on to trunk; JOGL_2_SANDBOX branch is now closed
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@147 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java')
-rw-r--r--src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java b/src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java
new file mode 100644
index 0000000..431af91
--- /dev/null
+++ b/src/java/com/sun/gluegen/cgram/PreprocessorInfoChannel.java
@@ -0,0 +1,73 @@
+package com.sun.gluegen.cgram;
+
+import java.util.*;
+
+public class PreprocessorInfoChannel
+{
+ Hashtable lineLists = new Hashtable(); // indexed by Token number
+ int firstValidTokenNumber = 0;
+ int maxTokenNumber = 0;
+
+ public void addLineForTokenNumber( Object line, Integer toknum )
+ {
+ if ( lineLists.containsKey( toknum ) ) {
+ Vector lines = (Vector) lineLists.get( toknum );
+ lines.addElement(line);
+ }
+ else {
+ Vector lines = new Vector();
+ lines.addElement(line);
+ lineLists.put(toknum, lines);
+ if ( maxTokenNumber < toknum.intValue() ) {
+ maxTokenNumber = toknum.intValue();
+ }
+ }
+ }
+
+ public int getMaxTokenNumber()
+ {
+ return maxTokenNumber;
+ }
+
+ public Vector extractLinesPrecedingTokenNumber( Integer toknum )
+ {
+ Vector lines = new Vector();
+ if (toknum == null) return lines;
+ for (int i = firstValidTokenNumber; i < toknum.intValue(); i++){
+ Integer inti = new Integer(i);
+ if ( lineLists.containsKey( inti ) ) {
+ Vector tokenLineVector = (Vector) lineLists.get( inti );
+ if ( tokenLineVector != null) {
+ Enumeration tokenLines = tokenLineVector.elements();
+ while ( tokenLines.hasMoreElements() ) {
+ lines.addElement( tokenLines.nextElement() );
+ }
+ lineLists.remove(inti);
+ }
+ }
+ }
+ firstValidTokenNumber = toknum.intValue();
+ return lines;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer("PreprocessorInfoChannel:\n");
+ for (int i = 0; i <= maxTokenNumber + 1; i++){
+ Integer inti = new Integer(i);
+ if ( lineLists.containsKey( inti ) ) {
+ Vector tokenLineVector = (Vector) lineLists.get( inti );
+ if ( tokenLineVector != null) {
+ Enumeration tokenLines = tokenLineVector.elements();
+ while ( tokenLines.hasMoreElements() ) {
+ sb.append(inti + ":" + tokenLines.nextElement() + '\n');
+ }
+ }
+ }
+ }
+ return sb.toString();
+ }
+}
+
+
+