SymbolTable.java
5.41 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.formcalc;
import com.adobe.xfa.formcalc.CalcParser;
import com.adobe.xfa.formcalc.CalcSymbol;
import com.adobe.xfa.formcalc.ScopeTable;
import java.util.List;
public final class SymbolTable {
static final int SIZE = 509;
private CalcSymbol[] moTableBase;
private int mnTableSize;
SymbolTable() {
}
int create(int nTableSize) {
this.mnTableSize = nTableSize;
this.moTableBase = new CalcSymbol[nTableSize];
return 1;
}
int getTableSize() {
return this.mnTableSize;
}
/*
* Unable to fully structure code
* Enabled aggressive block sorting
* Lifted jumps to return sites
*/
void init(CalcParser oParser) {
i = 0;
while (i < this.mnTableSize) {
prev = null;
next = null;
p = this.moTableBase[i];
while (p != null) {
next = p.getNext();
store = p.getStore();
if ((store & 16) != 16) ** GOTO lbl17
if (!oParser.mbSyntaxErrorSeen) ** GOTO lbl16
if (p == this.moTableBase[i]) {
prev = this.moTableBase[i] = next;
} else {
prev.setNext(next);
}
** GOTO lbl39
lbl16: // 1 sources:
p.setStore(store &= -17);
lbl17: // 2 sources:
type = p.getType();
if (p.getStore() != 2 && type != 8) ** GOTO lbl25
if (oParser.mbWasInSaveMode) ** GOTO lbl-1000
if (p == this.moTableBase[i]) {
prev = this.moTableBase[i] = next;
} else {
prev.setNext(next);
}
** GOTO lbl39
lbl25: // 1 sources:
if (type != 5 && type != 6) ** GOTO lbl-1000
if (p.getScope() > 1) {
if (p == this.moTableBase[i]) {
prev = this.moTableBase[i] = next;
} else {
prev.setNext(next);
}
} else if (!oParser.mbWasInSaveMode) {
if (p == this.moTableBase[i]) {
prev = this.moTableBase[i] = next;
} else {
prev.setNext(next);
}
} else lbl-1000: // 3 sources:
{
prev = p;
}
lbl39: // 9 sources:
p = next;
}
++i;
}
}
CalcSymbol lookup(String sName) {
assert (sName != null);
CalcSymbol q = null;
int h = this.hash(sName);
for (CalcSymbol p = this.moTableBase[h]; p != null; p = p.getNext()) {
if (!sName.equals(p.getName())) continue;
int type = p.getType();
if (type == 8) {
return p;
}
if (type == 4) {
return p;
}
if (type != 7) continue;
return p;
}
return q;
}
CalcSymbol lookup(String sName, ScopeTable oScope) {
assert (sName != null);
CalcSymbol q = null;
int h = this.hash(sName);
for (CalcSymbol p = this.moTableBase[h]; p != null; p = p.getNext()) {
if (!sName.equals(p.getName())) continue;
int type = p.getType();
if ((type == 5 || type == 6) && oScope.isActive(p.getScope())) {
if (q == null) {
q = p;
continue;
}
if (p.getScope() <= q.getScope()) continue;
q = p;
continue;
}
if (p.getType() != 7) continue;
q = p;
}
return q;
}
CalcSymbol lookup(CalcSymbol oSym) {
assert (oSym != null);
CalcSymbol q = null;
int h = this.hash(oSym.getName());
for (CalcSymbol p = this.moTableBase[h]; p != null; p = p.getNext()) {
int type;
String sName = p.getName();
if (sName == null || !sName.equals(oSym.getName()) || (type = p.getType()) != 5 && type != 6 || p.getScope() != oSym.getScope()) continue;
q = p;
}
return q;
}
CalcSymbol install(String sName) {
assert (sName != null);
int h = this.hash(sName);
CalcSymbol p = new CalcSymbol();
p.setName(sName);
p.setNext(this.moTableBase[h]);
this.moTableBase[h] = p;
return p;
}
public void enumerate(ScopeTable oScope, List<CalcSymbol> oSymbols) {
for (int h = 0; h < this.mnTableSize; ++h) {
for (CalcSymbol p = this.moTableBase[h]; p != null; p = p.getNext()) {
boolean bAdd = false;
int type = p.getType();
if ((type == 5 || type == 6) && oScope.isActive(p.getScope())) {
bAdd = true;
} else if (p.getType() == 7) {
bAdd = true;
}
if (!bAdd) continue;
oSymbols.add(p);
}
}
}
private int hash(String sName) {
assert (sName != null);
int h = 0;
int n = sName.length();
for (int i = 0; i < n; ++i) {
h = h << 1 ^ sName.charAt(i);
}
if ((h %= this.mnTableSize) < 0) {
h = - h;
}
return h;
}
}