18
18
19
19
import java .util .ArrayDeque ;
20
20
import java .util .Deque ;
21
- import java .util .HashMap ;
22
21
import java .util .List ;
23
- import java .util .Map ;
24
22
import java .util .NoSuchElementException ;
25
23
import java .util .function .Supplier ;
26
24
@@ -64,9 +62,6 @@ public class ExpressionState {
64
62
@ Nullable
65
63
private Deque <TypedValue > contextObjects ;
66
64
67
- @ Nullable
68
- private Deque <VariableScope > variableScopes ;
69
-
70
65
// When entering a new scope there is a new base object which should be used
71
66
// for '#this' references (or to act as a target for unqualified references).
72
67
// This ArrayDeque captures those objects at each nested scope level.
@@ -207,12 +202,10 @@ public Object convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor
207
202
* context object} and a new local variable scope.
208
203
*/
209
204
public void enterScope () {
210
- initVariableScopes ().push (new VariableScope ());
211
205
initScopeRootObjects ().push (getActiveContextObject ());
212
206
}
213
207
214
208
public void exitScope () {
215
- initVariableScopes ().pop ();
216
209
initScopeRootObjects ().pop ();
217
210
}
218
211
@@ -231,15 +224,6 @@ private Deque<TypedValue> initScopeRootObjects() {
231
224
return this .scopeRootObjects ;
232
225
}
233
226
234
- private Deque <VariableScope > initVariableScopes () {
235
- if (this .variableScopes == null ) {
236
- this .variableScopes = new ArrayDeque <>();
237
- // top-level empty variable scope
238
- this .variableScopes .add (new VariableScope ());
239
- }
240
- return this .variableScopes ;
241
- }
242
-
243
227
public TypedValue operate (Operation op , @ Nullable Object left , @ Nullable Object right ) throws EvaluationException {
244
228
OperatorOverloader overloader = this .relatedContext .getOperatorOverloader ();
245
229
if (overloader .overridesOperation (op , left , right )) {
@@ -265,43 +249,4 @@ public SpelParserConfiguration getConfiguration() {
265
249
return this .configuration ;
266
250
}
267
251
268
-
269
- /**
270
- * A new local variable scope is entered when a new expression scope is
271
- * entered and exited when the corresponding expression scope is exited.
272
- *
273
- * <p>If variable names clash with those in a higher level scope, those in
274
- * the higher level scope will not be accessible within the current scope.
275
- */
276
- private static class VariableScope {
277
-
278
- private final Map <String , Object > variables = new HashMap <>();
279
-
280
- VariableScope () {
281
- }
282
-
283
- VariableScope (String name , Object value ) {
284
- this .variables .put (name , value );
285
- }
286
-
287
- VariableScope (@ Nullable Map <String , Object > variables ) {
288
- if (variables != null ) {
289
- this .variables .putAll (variables );
290
- }
291
- }
292
-
293
- @ Nullable
294
- Object lookupVariable (String name ) {
295
- return this .variables .get (name );
296
- }
297
-
298
- void setVariable (String name , Object value ) {
299
- this .variables .put (name ,value );
300
- }
301
-
302
- boolean definesVariable (String name ) {
303
- return this .variables .containsKey (name );
304
- }
305
- }
306
-
307
252
}
0 commit comments