@@ -179,98 +179,93 @@ else if (targetObject instanceof String) {
179
179
@ Override
180
180
public boolean isCompilable () {
181
181
if (this .indexedType == IndexedType .array ) {
182
- return exitTypeDescriptor != null ;
182
+ return ( this . exitTypeDescriptor != null ) ;
183
183
}
184
184
else if (this .indexedType == IndexedType .list ) {
185
185
return this .children [0 ].isCompilable ();
186
186
}
187
187
else if (this .indexedType == IndexedType .map ) {
188
- if (this .children [0 ] instanceof PropertyOrFieldReference ) {
189
- // Only the name will be used, so that is OK
190
- return true ;
191
- }
192
- else {
193
- return this .children [0 ].isCompilable ();
194
- }
188
+ return (this .children [0 ] instanceof PropertyOrFieldReference || this .children [0 ].isCompilable ());
195
189
}
196
190
else if (this .indexedType == IndexedType .object ) {
197
191
// If the string name is changing the accessor is clearly going to change (so compilation is not possible)
198
192
if (this .cachedReadAccessor != null &&
199
193
(this .cachedReadAccessor instanceof ReflectivePropertyAccessor .OptimalPropertyAccessor ) &&
200
194
(getChild (0 ) instanceof StringLiteral )) {
201
195
return true ;
202
- };
196
+ }
203
197
}
204
198
return false ;
205
199
}
206
200
207
201
@ Override
208
202
public void generateCode (MethodVisitor mv , CodeFlow codeflow ) {
209
- String s = codeflow .lastDescriptor ();
210
-
211
- if (s == null ) {
212
- // stack is empty, should use context object
203
+ String descriptor = codeflow .lastDescriptor ();
204
+ if (descriptor == null ) {
205
+ // Stack is empty, should use context object
213
206
codeflow .loadTarget (mv );
214
207
}
215
208
216
209
if (this .indexedType == IndexedType .array ) {
217
- if ("I" .equals (exitTypeDescriptor )) {
210
+ if ("I" .equals (this . exitTypeDescriptor )) {
218
211
mv .visitTypeInsn (CHECKCAST ,"[I" );
219
212
SpelNodeImpl index = this .children [0 ];
220
213
codeflow .enterCompilationScope ();
221
214
index .generateCode (mv , codeflow );
222
215
codeflow .exitCompilationScope ();
223
216
mv .visitInsn (IALOAD );
224
217
}
225
- else if ("D" .equals (exitTypeDescriptor )) {
226
- mv .visitTypeInsn (CHECKCAST ,"[D" );
218
+ else if ("D" .equals (this . exitTypeDescriptor )) {
219
+ mv .visitTypeInsn (CHECKCAST , "[D" );
227
220
SpelNodeImpl index = this .children [0 ];
228
221
codeflow .enterCompilationScope ();
229
222
index .generateCode (mv , codeflow );
230
223
mv .visitInsn (DALOAD );
231
224
}
232
- else if ("J" .equals (exitTypeDescriptor )) {
233
- mv .visitTypeInsn (CHECKCAST ,"[J" );
225
+ else if ("J" .equals (this . exitTypeDescriptor )) {
226
+ mv .visitTypeInsn (CHECKCAST , "[J" );
234
227
SpelNodeImpl index = this .children [0 ];
235
228
codeflow .enterCompilationScope ();
236
229
index .generateCode (mv , codeflow );
237
230
codeflow .exitCompilationScope ();
238
231
mv .visitInsn (LALOAD );
239
232
}
240
- else if ("F" .equals (exitTypeDescriptor )) {
241
- mv .visitTypeInsn (CHECKCAST ,"[F" );
233
+ else if ("F" .equals (this . exitTypeDescriptor )) {
234
+ mv .visitTypeInsn (CHECKCAST , "[F" );
242
235
SpelNodeImpl index = this .children [0 ];
243
236
codeflow .enterCompilationScope ();
244
237
index .generateCode (mv , codeflow );
245
238
codeflow .exitCompilationScope ();
246
239
mv .visitInsn (FALOAD );
247
240
}
248
- else if ("S" .equals (exitTypeDescriptor )) {
249
- mv .visitTypeInsn (CHECKCAST ,"[S" );
241
+ else if ("S" .equals (this . exitTypeDescriptor )) {
242
+ mv .visitTypeInsn (CHECKCAST , "[S" );
250
243
SpelNodeImpl index = this .children [0 ];
251
244
codeflow .enterCompilationScope ();
252
245
index .generateCode (mv , codeflow );
253
246
codeflow .exitCompilationScope ();
254
247
mv .visitInsn (SALOAD );
255
248
}
256
- else if ("B" .equals (exitTypeDescriptor )) {
257
- mv .visitTypeInsn (CHECKCAST ,"[B" );
249
+ else if ("B" .equals (this . exitTypeDescriptor )) {
250
+ mv .visitTypeInsn (CHECKCAST , "[B" );
258
251
SpelNodeImpl index = this .children [0 ];
259
252
codeflow .enterCompilationScope ();
260
253
index .generateCode (mv , codeflow );
261
254
codeflow .exitCompilationScope ();
262
255
mv .visitInsn (BALOAD );
263
256
}
264
- else if ("C" .equals (exitTypeDescriptor )) {
265
- mv .visitTypeInsn (CHECKCAST ,"[C" );
257
+ else if ("C" .equals (this . exitTypeDescriptor )) {
258
+ mv .visitTypeInsn (CHECKCAST , "[C" );
266
259
SpelNodeImpl index = this .children [0 ];
267
260
codeflow .enterCompilationScope ();
268
261
index .generateCode (mv , codeflow );
269
262
codeflow .exitCompilationScope ();
270
263
mv .visitInsn (CALOAD );
271
264
}
272
265
else {
273
- mv .visitTypeInsn (CHECKCAST ,"[" +exitTypeDescriptor +(CodeFlow .isPrimitiveArray (exitTypeDescriptor )?"" :";" ));//depthPlusOne(exitTypeDescriptor)+"Ljava/lang/Object;");
266
+ mv .visitTypeInsn (CHECKCAST , "[" + this .exitTypeDescriptor +
267
+ (CodeFlow .isPrimitiveArray (this .exitTypeDescriptor ) ? "" : ";" ));
268
+ //depthPlusOne(exitTypeDescriptor)+"Ljava/lang/Object;");
274
269
SpelNodeImpl index = this .children [0 ];
275
270
codeflow .enterCompilationScope ();
276
271
index .generateCode (mv , codeflow );
@@ -279,15 +274,15 @@ else if ("C".equals(exitTypeDescriptor)) {
279
274
}
280
275
}
281
276
else if (this .indexedType == IndexedType .list ) {
282
- mv .visitTypeInsn (CHECKCAST ,"java/util/List" );
277
+ mv .visitTypeInsn (CHECKCAST , "java/util/List" );
283
278
codeflow .enterCompilationScope ();
284
279
this .children [0 ].generateCode (mv , codeflow );
285
280
codeflow .exitCompilationScope ();
286
- mv .visitMethodInsn (INVOKEINTERFACE ,"java/util/List" ,"get" ,"(I)Ljava/lang/Object;" , true );
287
- CodeFlow .insertCheckCast (mv ,exitTypeDescriptor );
281
+ mv .visitMethodInsn (INVOKEINTERFACE , "java/util/List" , "get" , "(I)Ljava/lang/Object;" , true );
282
+ CodeFlow .insertCheckCast (mv , this . exitTypeDescriptor );
288
283
}
289
284
else if (this .indexedType == IndexedType .map ) {
290
- mv .visitTypeInsn (CHECKCAST ,"java/util/Map" );
285
+ mv .visitTypeInsn (CHECKCAST , "java/util/Map" );
291
286
// Special case when the key is an unquoted string literal that will be parsed as
292
287
// a property/field reference
293
288
if ((this .children [0 ] instanceof PropertyOrFieldReference )) {
@@ -300,16 +295,14 @@ else if (this.indexedType == IndexedType.map) {
300
295
this .children [0 ].generateCode (mv , codeflow );
301
296
codeflow .exitCompilationScope ();
302
297
}
303
- mv .visitMethodInsn (INVOKEINTERFACE ,"java/util/Map" ,"get" ,"(Ljava/lang/Object;)Ljava/lang/Object;" , true );
304
- CodeFlow .insertCheckCast (mv ,exitTypeDescriptor );
298
+ mv .visitMethodInsn (INVOKEINTERFACE , "java/util/Map" , "get" , "(Ljava/lang/Object;)Ljava/lang/Object;" , true );
299
+ CodeFlow .insertCheckCast (mv , this . exitTypeDescriptor );
305
300
}
306
301
else if (this .indexedType == IndexedType .object ) {
307
302
ReflectivePropertyAccessor .OptimalPropertyAccessor accessor =
308
- (ReflectivePropertyAccessor .OptimalPropertyAccessor )this .cachedReadAccessor ;
303
+ (ReflectivePropertyAccessor .OptimalPropertyAccessor ) this .cachedReadAccessor ;
309
304
Member member = accessor .member ;
310
305
boolean isStatic = Modifier .isStatic (member .getModifiers ());
311
-
312
- String descriptor = codeflow .lastDescriptor ();
313
306
String memberDeclaringClassSlashedDescriptor = member .getDeclaringClass ().getName ().replace ('.' ,'/' );
314
307
if (!isStatic ) {
315
308
if (descriptor == null ) {
@@ -320,13 +313,16 @@ else if (this.indexedType == IndexedType.object) {
320
313
}
321
314
}
322
315
if (member instanceof Field ) {
323
- mv .visitFieldInsn (isStatic ?GETSTATIC :GETFIELD ,memberDeclaringClassSlashedDescriptor ,member .getName (),CodeFlow .toJVMDescriptor (((Field ) member ).getType ()));
316
+ mv .visitFieldInsn (isStatic ? GETSTATIC : GETFIELD , memberDeclaringClassSlashedDescriptor ,
317
+ member .getName (), CodeFlow .toJVMDescriptor (((Field ) member ).getType ()));
324
318
}
325
319
else {
326
- mv .visitMethodInsn (isStatic ?INVOKESTATIC :INVOKEVIRTUAL , memberDeclaringClassSlashedDescriptor , member .getName (),CodeFlow .createSignatureDescriptor ((Method )member ),false );
320
+ mv .visitMethodInsn (isStatic ? INVOKESTATIC : INVOKEVIRTUAL , memberDeclaringClassSlashedDescriptor ,
321
+ member .getName (), CodeFlow .createSignatureDescriptor ((Method ) member ), false );
327
322
}
328
323
}
329
- codeflow .pushDescriptor (exitTypeDescriptor );
324
+
325
+ codeflow .pushDescriptor (this .exitTypeDescriptor );
330
326
}
331
327
332
328
@ Override
0 commit comments