1 package spoon.support.reflect.eval; 2 3 import java.lang.annotation.Annotation ; 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 import spoon.reflect.code.BinaryOperatorKind; 8 import spoon.reflect.code.CtArrayAccess; 9 import spoon.reflect.code.CtAssert; 10 import spoon.reflect.code.CtAssignment; 11 import spoon.reflect.code.CtBinaryOperator; 12 import spoon.reflect.code.CtBlock; 13 import spoon.reflect.code.CtBreak; 14 import spoon.reflect.code.CtCase; 15 import spoon.reflect.code.CtCatch; 16 import spoon.reflect.code.CtCodeElement; 17 import spoon.reflect.code.CtConditional; 18 import spoon.reflect.code.CtContinue; 19 import spoon.reflect.code.CtDo; 20 import spoon.reflect.code.CtExpression; 21 import spoon.reflect.code.CtFieldAccess; 22 import spoon.reflect.code.CtFor; 23 import spoon.reflect.code.CtForEach; 24 import spoon.reflect.code.CtIf; 25 import spoon.reflect.code.CtInvocation; 26 import spoon.reflect.code.CtLiteral; 27 import spoon.reflect.code.CtLocalVariable; 28 import spoon.reflect.code.CtNewArray; 29 import spoon.reflect.code.CtNewClass; 30 import spoon.reflect.code.CtOperatorAssignment; 31 import spoon.reflect.code.CtReturn; 32 import spoon.reflect.code.CtStatement; 33 import spoon.reflect.code.CtStatementList; 34 import spoon.reflect.code.CtSwitch; 35 import spoon.reflect.code.CtSynchronized; 36 import spoon.reflect.code.CtTargetedExpression; 37 import spoon.reflect.code.CtThrow; 38 import spoon.reflect.code.CtTry; 39 import spoon.reflect.code.CtUnaryOperator; 40 import spoon.reflect.code.CtVariableAccess; 41 import spoon.reflect.code.CtWhile; 42 import spoon.reflect.declaration.CtAnnotation; 43 import spoon.reflect.declaration.CtAnnotationType; 44 import spoon.reflect.declaration.CtAnonymousExecutable; 45 import spoon.reflect.declaration.CtClass; 46 import spoon.reflect.declaration.CtConstructor; 47 import spoon.reflect.declaration.CtElement; 48 import spoon.reflect.declaration.CtEnum; 49 import spoon.reflect.declaration.CtExecutable; 50 import spoon.reflect.declaration.CtField; 51 import spoon.reflect.declaration.CtInterface; 52 import spoon.reflect.declaration.CtMethod; 53 import spoon.reflect.declaration.CtPackage; 54 import spoon.reflect.declaration.CtParameter; 55 import spoon.reflect.declaration.CtSimpleType; 56 import spoon.reflect.declaration.CtTypeParameter; 57 import spoon.reflect.declaration.CtTypedElement; 58 import spoon.reflect.declaration.CtVariable; 59 import spoon.reflect.declaration.ModifierKind; 60 import spoon.reflect.eval.PartialEvaluator; 61 import spoon.reflect.reference.CtArrayTypeReference; 62 import spoon.reflect.reference.CtExecutableReference; 63 import spoon.reflect.reference.CtFieldReference; 64 import spoon.reflect.reference.CtGenericElementReference; 65 import spoon.reflect.reference.CtLocalVariableReference; 66 import spoon.reflect.reference.CtPackageReference; 67 import spoon.reflect.reference.CtParameterReference; 68 import spoon.reflect.reference.CtReference; 69 import spoon.reflect.reference.CtTypeParameterReference; 70 import spoon.reflect.reference.CtTypeReference; 71 import spoon.reflect.reference.CtVariableReference; 72 import spoon.reflect.visitor.CtVisitor; 73 import spoon.support.util.RtHelper; 74 75 79 public class VisitorPartialEvaluator implements CtVisitor, PartialEvaluator { 80 81 boolean flowEnded = false; 82 83 CtCodeElement result; 84 85 Number convert(CtTypeReference<?> type, Number n) { 86 if (type.getActualClass() == int.class 87 || type.getActualClass() == Integer .class) { 88 return n.intValue(); 89 } 90 if (type.getActualClass() == byte.class 91 || type.getActualClass() == Byte .class) { 92 return n.byteValue(); 93 } 94 if (type.getActualClass() == long.class 95 || type.getActualClass() == Long .class) { 96 return n.longValue(); 97 } 98 if (type.getActualClass() == float.class 99 || type.getActualClass() == Float .class) { 100 return n.floatValue(); 101 } 102 if (type.getActualClass() == short.class 103 || type.getActualClass() == Short .class) { 104 return n.shortValue(); 105 } 106 return n; 107 } 108 109 @SuppressWarnings ("unchecked") 110 public <R extends CtCodeElement> R evaluate(CtElement parent, R element) { 111 if (element == null) 112 return null; 113 element.accept(this); 114 if (result != null) 115 result.setParent(parent); 116 return (R) result; 117 } 118 119 void setResult(CtCodeElement element) { 120 result = element; 121 } 122 123 public <A extends Annotation > void visitCtAnnotation( 124 CtAnnotation<A> annotation) { 125 throw new RuntimeException ("Unknow Element"); 126 } 127 128 public <A extends Annotation > void visitCtAnnotationType( 129 CtAnnotationType<A> annotationType) { 130 throw new RuntimeException ("Unknow Element"); 131 } 132 133 public void visitCtAnonymousExecutable(CtAnonymousExecutable impl) { 134 throw new RuntimeException ("Unknow Element"); 135 } 136 137 public <T, E extends CtExpression<?>> void visitCtArrayAccess( 138 CtArrayAccess<T, E> arrayAccess) { 139 setResult(arrayAccess.getFactory().Core().clone(arrayAccess)); 140 } 141 142 public <T> void visitCtArrayTypeReference(CtArrayTypeReference<T> reference) { 143 throw new RuntimeException ("Unknow Element"); 144 } 145 146 public void visitCtAssert(CtAssert asserted) { 147 throw new RuntimeException ("Unknow Element"); 148 } 149 150 @SuppressWarnings ("unchecked") 151 public <T> void visitCtBinaryOperator(CtBinaryOperator<T> operator) { 152 CtExpression<?> left = evaluate(operator, operator.getLeftHandOperand()); 153 CtExpression<?> right = evaluate(operator, operator 154 .getRightHandOperand()); 155 if (left instanceof CtLiteral && right instanceof CtLiteral) { 156 Object leftObject = ((CtLiteral<?>) left).getValue(); 157 Object rightObject = ((CtLiteral<?>) right).getValue(); 158 CtLiteral<Object > res = operator.getFactory().Core() 159 .createLiteral(); 160 switch (operator.getKind()) { 161 case AND: 162 res.setValue((Boolean ) leftObject && (Boolean ) rightObject); 163 break; 164 case OR: 165 res.setValue((Boolean ) leftObject || (Boolean ) rightObject); 166 break; 167 case EQ: 168 if (leftObject == null) 169 res.setValue(leftObject == rightObject); 170 else 171 res.setValue(leftObject.equals(rightObject)); 172 break; 173 case NE: 174 if (leftObject == null) 175 res.setValue(leftObject != rightObject); 176 else 177 res.setValue(!leftObject.equals(rightObject)); 178 break; 179 case GE: 180 res 181 .setValue(((Number ) leftObject).doubleValue() >= ((Number ) rightObject) 182 .doubleValue()); 183 break; 184 case LE: 185 res 186 .setValue(((Number ) leftObject).doubleValue() <= ((Number ) rightObject) 187 .doubleValue()); 188 break; 189 case GT: 190 res 191 .setValue(((Number ) leftObject).doubleValue() > ((Number ) rightObject) 192 .doubleValue()); 193 break; 194 case LT: 195 res 196 .setValue(((Number ) leftObject).doubleValue() < ((Number ) rightObject) 197 .doubleValue()); 198 break; 199 case MINUS: 200 res.setValue(convert(operator.getType(), ((Number ) leftObject) 201 .doubleValue() 202 - ((Number ) rightObject).doubleValue())); 203 break; 204 case PLUS: 205 if ((leftObject instanceof String ) 206 || (rightObject instanceof String )) { 207 res.setValue("" + leftObject + rightObject); 208 } else { 209 res.setValue(convert(operator.getType(), 210 ((Number ) leftObject).doubleValue() 211 + ((Number ) rightObject).doubleValue())); 212 } 213 break; 214 case BITAND: 215 if (leftObject instanceof Boolean ) { 216 res.setValue(((Boolean ) leftObject).booleanValue() 217 & ((Boolean ) rightObject).booleanValue()); 218 } else { 219 res.setValue(((Number ) leftObject).intValue() 220 & ((Number ) rightObject).intValue()); 221 } 222 break; 223 case BITOR: 224 if (leftObject instanceof Boolean ) { 225 res.setValue(((Boolean ) leftObject).booleanValue() 226 | ((Boolean ) rightObject).booleanValue()); 227 } else { 228 res.setValue(((Number ) leftObject).intValue() 229 | ((Number ) rightObject).intValue()); 230 } 231 break; 232 case BITXOR: 233 if (leftObject instanceof Boolean ) { 234 res.setValue(((Boolean ) leftObject).booleanValue() 235 ^ ((Boolean ) rightObject).booleanValue()); 236 } else { 237 res.setValue(((Number ) leftObject).intValue() 238 ^ ((Number ) rightObject).intValue()); 239 } 240 break; 241 default: 242 throw new RuntimeException ("unsupported operator " 243 + operator.getKind()); 244 } 245 setResult(res); 246 return; 247 } else if (operator.getKind() == BinaryOperatorKind.INSTANCEOF 248 && (left instanceof CtTypedElement)) { 249 CtLiteral<Boolean > res = operator.getFactory().Core() 250 .createLiteral(); 251 CtTypeReference<?> leftType = ((CtTypedElement<?>) left).getType() 252 .box(); 253 CtTypeReference<?> rightType = ((CtLiteral<CtTypeReference<?>>) right) 254 .getValue(); 255 if (leftType.isSubtypeOf(rightType)) { 256 res.setValue(true); 257 setResult(res); 258 } 259 return; 260 } else if (left instanceof CtLiteral || right instanceof CtLiteral) { 261 CtLiteral<?> literal; 262 CtExpression expr; 263 if (left instanceof CtLiteral) { 264 literal = (CtLiteral<?>) left; 265 expr = (CtExpression) right; 266 } else { 267 literal = (CtLiteral<?>) right; 268 expr = (CtExpression) left; 269 } 270 Object o = literal.getValue(); 271 CtLiteral<Object > res = operator.getFactory().Core() 272 .createLiteral(); 273 switch (operator.getKind()) { 274 case AND: 275 if ((Boolean ) o) { 276 setResult(expr); 277 } else { 278 res.setValue(false); 279 setResult(res); 280 } 281 return; 282 case OR: 283 if ((Boolean ) o) { 284 res.setValue(true); 285 setResult(res); 286 } else { 287 setResult(expr); 288 } 289 return; 290 case BITOR: 291 if (o instanceof Boolean && ((Boolean ) o).booleanValue()) { 292 res.setValue(true); 293 setResult(res); 294 } 295 return; 296 } 297 } 298 CtBinaryOperator<T> op = operator.getFactory().Core() 299 .createBinaryOperator(); 300 op.setKind(operator.getKind()); 301 op.setLeftHandOperand(left); 302 left.setParent(op); 303 op.setRightHandOperand(right); 304 right.setParent(op); 305 op.setType(operator.getType()); 306 setResult(op); 307 } 308 309 public <R> void visitCtBlock(CtBlock<R> block) { 310 CtBlock<?> b = block.getFactory().Core().createBlock(); 311 for (CtStatement s : block.getStatements()) { 312 CtStatement res = evaluate(b, s); 313 if (res != null) { 314 b.getStatements().add(res); 315 } 316 if (flowEnded) 318 break; 319 } 320 if (b.getStatements().size() == 1 321 && (b.getStatements().get(0) instanceof CtBlock)) { 322 setResult(b.getStatements().get(0)); 323 } else { 324 setResult(b); 325 } 326 } 327 328 public void visitCtBreak(CtBreak breakStatement) { 329 setResult(breakStatement.getFactory().Core().clone(breakStatement)); 330 } 331 332 public <E> void visitCtCase(CtCase<E> caseStatement) { 333 throw new RuntimeException ("Unknow Element"); 334 } 335 336 public void visitCtCatch(CtCatch catchBlock) { 337 setResult(catchBlock.getFactory().Core().clone(catchBlock)); 338 } 339 340 public <T> void visitCtClass(CtClass<T> ctClass) { 341 throw new RuntimeException ("Unknow Element"); 342 } 343 344 public void visitCtConstructor(CtConstructor c) { 345 throw new RuntimeException ("Unknow Element"); 346 } 347 348 public void visitCtContinue(CtContinue continueStatement) { 349 setResult(continueStatement.getFactory().Core() 350 .clone(continueStatement)); 351 } 352 353 public void visitCtDo(CtDo doLoop) { 354 CtDo w = doLoop.getFactory().Core().clone(doLoop); 355 w.setLoopingExpression(evaluate(w, doLoop.getLoopingExpression())); 356 w.setBody(evaluate(w, doLoop.getBody())); 357 setResult(w); 358 } 359 360 public <T extends Enum > void visitCtEnum(CtEnum<T> ctEnum) { 361 throw new RuntimeException ("Unknow Element"); 362 } 363 364 public <T> void visitCtExecutableReference( 365 CtExecutableReference<T> reference) { 366 throw new RuntimeException ("Unknow Element"); 367 } 368 369 public void visitCtExpression(CtExpression<?> expression) { 370 throw new RuntimeException ("Unknow Element"); 371 } 372 373 public <T> void visitCtField(CtField<T> f) { 374 throw new RuntimeException ("Unknow Element"); 375 } 376 377 public <T> void visitCtFieldAccess(CtFieldAccess<T> fieldAccess) { 378 if (fieldAccess.getVariable().getSimpleName().equals("class")) { 379 Class c = fieldAccess.getVariable().getDeclaringType() 380 .getActualClass(); 381 if (c != null) { 382 CtLiteral<Class > l = fieldAccess.getFactory().Core() 383 .createLiteral(); 384 l.setValue(c); 385 setResult(l); 386 return; 387 } 388 } 389 if (fieldAccess.getFactory().Type().createReference(Enum .class) 390 .isAssignableFrom(fieldAccess.getVariable().getDeclaringType())) { 391 CtLiteral<CtFieldReference> l = fieldAccess.getFactory().Core() 392 .createLiteral(); 393 l.setValue(fieldAccess.getVariable()); 394 setResult(l); 395 return; 396 } 397 CtField<?> f = fieldAccess.getVariable().getDeclaration(); 398 if (f != null && f.getModifiers().contains(ModifierKind.FINAL)) { 399 setResult(f.getDefaultExpression()); 400 return; 401 } 402 setResult(fieldAccess.getFactory().Core().clone(fieldAccess)); 403 } 404 405 public <T> void visitCtFieldReference(CtFieldReference<T> reference) { 406 throw new RuntimeException ("Unknow Element"); 407 } 408 409 public void visitCtFor(CtFor forLoop) { 410 411 List <CtStatement> lst = forLoop.getForInit(); 413 List <CtStatement> evaluatelst = new ArrayList <CtStatement>(); 414 for (CtStatement s : lst) { 415 CtStatement evaluateStatement = evaluate(forLoop, s); 416 if (evaluateStatement != null) 417 evaluatelst.add(evaluateStatement); 418 } 419 forLoop.setForInit(evaluatelst); 420 421 forLoop.setExpression(evaluate(forLoop, forLoop.getExpression())); 423 424 lst = forLoop.getForUpdate(); 426 evaluatelst = new ArrayList <CtStatement>(); 427 for (CtStatement s : lst) { 428 CtStatement evaluateStatement = evaluate(forLoop, s); 429 if (evaluateStatement != null) 430 evaluatelst.add(evaluateStatement); 431 } 432 forLoop.setForUpdate(evaluatelst); 433 434 setResult(forLoop.getFactory().Core().clone(forLoop)); 435 } 436 437 public void visitCtForEach(CtForEach foreach) { 438 setResult(foreach.getFactory().Core().clone(foreach)); 439 } 440 441 public void visitCtGenericElementReference( 442 CtGenericElementReference reference) { 443 throw new RuntimeException ("Unknow Element"); 444 } 445 446 public void visitCtIf(CtIf ifElement) { 447 CtExpression<Boolean > r = evaluate(ifElement, ifElement.getCondition()); 448 if (r instanceof CtLiteral) { 449 CtLiteral<Boolean > l = (CtLiteral<Boolean >) r; 450 if (l.getValue()) { 451 setResult(evaluate(null, ifElement.getThenStatement())); 452 } else { 453 setResult(evaluate(null, ifElement.getElseStatement())); 454 } 455 } else { 456 CtIf ifRes = ifElement.getFactory().Core().createIf(); 457 ifRes.setCondition(r); 458 r.setParent(ifRes); 459 boolean thenEnded = false, elseEnded = false; 460 ifRes 461 .setThenStatement(evaluate(ifRes, ifElement 462 .getThenStatement())); 463 if (flowEnded) { 464 thenEnded = true; 465 flowEnded = false; 466 } 467 ifRes 468 .setElseStatement(evaluate(ifRes, ifElement 469 .getElseStatement())); 470 if (flowEnded) { 471 elseEnded = true; 472 flowEnded = false; 473 } 474 setResult(ifRes); 475 if (thenEnded && elseEnded) 476 flowEnded = true; 477 } 478 } 479 480 public <T> void visitCtInterface(CtInterface<T> intrface) { 481 throw new RuntimeException ("Unknow Element"); 482 } 483 484 public <T> void visitCtInvocation(CtInvocation<T> invocation) { 485 CtInvocation<T> i = invocation.getFactory().Core().createInvocation(); 486 i.setType(invocation.getType()); 487 i.setExecutable(invocation.getExecutable()); 488 boolean constant = true; 489 i.setTarget(evaluate(i, invocation.getTarget())); 490 if (i.getTarget() != null && !(i.getTarget() instanceof CtLiteral)) 491 constant = false; 492 for (CtExpression e : invocation.getArguments()) { 493 CtExpression re = evaluate(i, e); 494 if (!(re instanceof CtLiteral)) 495 constant = false; 496 i.getArguments().add(re); 497 } 498 if (i.getExecutable().getSimpleName().equals("<init>")) { 500 setResult(i); 501 return; 502 } 503 if (constant) { 504 CtExecutable<?> executable = invocation.getExecutable() 505 .getDeclaration(); 506 if (executable != null 509 && invocation.getType() != null 510 && invocation.getExecutable().getDeclaringType() 511 .isAssignableFrom( 512 ((CtSimpleType<?>) invocation 513 .getParent(CtSimpleType.class)) 514 .getReference())) { 515 CtBlock<?> b = evaluate(invocation.getParent(), executable 516 .getBody()); 517 flowEnded = false; 518 CtStatement last = b.getStatements().get( 519 b.getStatements().size() - 1); 520 if (last != null && (last instanceof CtReturn)) { 521 if (((CtReturn<?>) last).getReturnedExpression() instanceof CtLiteral) { 522 setResult(((CtReturn<?>) last).getReturnedExpression()); 523 return; 524 } 525 } 526 } else { 527 T r = null; 529 try { 530 r = RtHelper.invoke(i); 532 CtLiteral<T> l = invocation.getFactory().Core() 533 .createLiteral(); 534 l.setValue(r); 535 setResult(l); 536 return; 537 } catch (Exception e) { 538 } 541 } 542 } 543 setResult(i); 544 } 545 546 public <T> void visitCtLiteral(CtLiteral<T> literal) { 547 setResult(literal.getFactory().Core().clone(literal)); 548 } 549 550 public <T> void visitCtLocalVariable(final CtLocalVariable<T> localVariable) { 551 CtLocalVariable<T> r = localVariable.getFactory().Core().clone( 566 localVariable); 567 r 568 .setDefaultExpression(evaluate(r, localVariable 569 .getDefaultExpression())); 570 setResult(r); 571 } 572 573 public <T> void visitCtLocalVariableReference( 574 CtLocalVariableReference<T> reference) { 575 throw new RuntimeException ("Unknow Element"); 576 } 577 578 public <T> void visitCtMethod(CtMethod<T> m) { 579 throw new RuntimeException ("Unknow Element"); 580 } 581 582 public <T> void visitCtNewArray(CtNewArray<T> newArray) { 583 setResult(newArray.getFactory().Core().clone(newArray)); 584 } 585 586 public <T> void visitCtNewClass(CtNewClass<T> newClass) { 587 setResult(newClass.getFactory().Core().clone(newClass)); 588 } 589 590 public <T, A extends T> void visitCtOperatorAssignement( 591 CtOperatorAssignment<T, A> assignment) { 592 setResult(assignment.getFactory().Core().clone(assignment)); 593 } 594 595 public void visitCtPackage(CtPackage ctPackage) { 596 throw new RuntimeException ("Unknow Element"); 597 } 598 599 public void visitCtPackageReference(CtPackageReference reference) { 600 throw new RuntimeException ("Unknow Element"); 601 } 602 603 public <T> void visitCtParameter(CtParameter<T> parameter) { 604 throw new RuntimeException ("Unknow Element"); 605 } 606 607 public <R> void visitCtStatementList(CtStatementList<R> statements) { 608 throw new RuntimeException ("Unknow Element"); 609 } 610 611 public <T> void visitCtParameterReference(CtParameterReference<T> reference) { 612 throw new RuntimeException ("Unknow Element"); 613 } 614 615 public void visitCtReference(CtReference reference) { 616 throw new RuntimeException ("Unknow Element"); 617 } 618 619 public <R> void visitCtReturn(CtReturn<R> returnStatement) { 620 CtReturn<R> r = returnStatement.getFactory().Core().createReturn(); 621 r.setReturnedExpression(evaluate(r, returnStatement 622 .getReturnedExpression())); 623 setResult(r); 624 flowEnded = true; 625 } 626 627 public <E> void visitCtSwitch(CtSwitch<E> switchStatement) { 628 setResult(switchStatement.getFactory().Core().clone(switchStatement)); 629 } 630 631 public void visitCtSynchronized(CtSynchronized synchro) { 632 CtSynchronized s = synchro.getFactory().Core().clone(synchro); 633 s.setBlock(evaluate(s, synchro.getBlock())); 634 setResult(s); 635 } 636 637 public <T, E extends CtExpression<?>> void visitCtTargetedExpression( 638 CtTargetedExpression<T, E> targetedExpression) { 639 throw new RuntimeException ("Unknow Element"); 640 } 641 642 public void visitCtThrow(CtThrow throwStatement) { 643 CtThrow r = throwStatement.getFactory().Core().createThrow(); 644 r 645 .setThrownExpression(evaluate(r, throwStatement 646 .getThrownExpression())); 647 setResult(r); 648 flowEnded = true; 649 } 650 651 public void visitCtTry(CtTry tryBlock) { 652 setResult(tryBlock.getFactory().Core().clone(tryBlock)); 653 } 654 655 public void visitCtTypeParameter(CtTypeParameter typeParameter) { 656 throw new RuntimeException ("Unknow Element"); 657 } 658 659 public void visitCtTypeParameterReference(CtTypeParameterReference ref) { 660 throw new RuntimeException ("Unknow Element"); 661 } 662 663 public <T> void visitCtTypeReference(CtTypeReference<T> reference) { 664 throw new RuntimeException ("Unknow Element"); 665 } 666 667 public <T> void visitCtUnaryOperator(CtUnaryOperator<T> operator) { 668 setResult(operator.getFactory().Core().clone(operator)); 669 } 670 671 public <T> void visitCtVariableAccess(CtVariableAccess<T> variableAccess) { 672 CtVariable v = variableAccess.getVariable().getDeclaration(); 673 674 if (v != null && v.hasModifier(ModifierKind.FINAL) 675 && v.getDefaultExpression() != null) 676 setResult(v.getDefaultExpression().getFactory().Core().clone( 677 v.getDefaultExpression())); 678 else 679 setResult(variableAccess.getFactory().Core().clone(variableAccess)); 680 } 681 682 public <T, A extends T> void visitCtAssignment( 683 CtAssignment<T, A> variableAssignment) { 684 CtAssignment<T, A> a = variableAssignment.getFactory().Core().clone( 685 variableAssignment); 686 a.setAssignment(evaluate(a, a.getAssignment())); 687 setResult(a); 688 } 689 690 public void visitCtVariableReference(CtVariableReference reference) { 691 throw new RuntimeException ("Unknow Element"); 692 } 693 694 public void visitCtWhile(CtWhile whileLoop) { 695 CtWhile w = whileLoop.getFactory().Core().clone(whileLoop); 696 w.setLoopingExpression(evaluate(w, whileLoop.getLoopingExpression())); 697 if (whileLoop.getLoopingExpression() instanceof CtLiteral 699 && !((CtLiteral<Boolean >) whileLoop.getLoopingExpression()) 700 .getValue()) { 701 setResult(null); 702 return; 703 } 704 w.setBody(evaluate(w, whileLoop.getBody())); 705 setResult(w); 706 } 707 708 public <T> void visitCtConditional(CtConditional<T> conditional) { 709 setResult(conditional.getFactory().Core().clone(conditional)); 710 } 711 712 } 713 | Popular Tags |