blob: 3ab565fcf644766c1a0f3d0faded59c985b54c44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package com.jogamp.gluegen.cgram;
import java.util.*;
public class PreprocessorInfoChannel
{
Hashtable<Integer, Vector<Object>> lineLists = new Hashtable<Integer, Vector<Object>>(); // indexed by Token number
int firstValidTokenNumber = 0;
int maxTokenNumber = 0;
public void addLineForTokenNumber( final Object line, final Integer toknum )
{
if ( lineLists.containsKey( toknum ) ) {
final Vector<Object> lines = lineLists.get( toknum );
lines.addElement(line);
}
else {
final Vector<Object> lines = new Vector<Object>();
lines.addElement(line);
lineLists.put(toknum, lines);
if ( maxTokenNumber < toknum.intValue() ) {
maxTokenNumber = toknum.intValue();
}
}
}
public int getMaxTokenNumber()
{
return maxTokenNumber;
}
public Vector<Object> extractLinesPrecedingTokenNumber( final Integer toknum )
{
final Vector<Object> lines = new Vector<Object>();
if (toknum == null) return lines;
for (int i = firstValidTokenNumber; i < toknum.intValue(); i++){
final Integer inti = new Integer(i);
if ( lineLists.containsKey( inti ) ) {
final Vector<Object> tokenLineVector = lineLists.get( inti );
if ( tokenLineVector != null) {
final Enumeration<Object> tokenLines = tokenLineVector.elements();
while ( tokenLines.hasMoreElements() ) {
lines.addElement( tokenLines.nextElement() );
}
lineLists.remove(inti);
}
}
}
firstValidTokenNumber = toknum.intValue();
return lines;
}
@Override
public String toString()
{
final StringBuilder sb = new StringBuilder("PreprocessorInfoChannel:\n");
for (int i = 0; i <= maxTokenNumber + 1; i++){
final Integer inti = new Integer(i);
if ( lineLists.containsKey( inti ) ) {
final Vector<Object> tokenLineVector = lineLists.get( inti );
if ( tokenLineVector != null) {
final Enumeration<Object> tokenLines = tokenLineVector.elements();
while ( tokenLines.hasMoreElements() ) {
sb.append(inti + ":" + tokenLines.nextElement() + '\n');
}
}
}
}
return sb.toString();
}
}
|