| 1 19 20 package jode.expr; 21 import jode.type.Type; 22 import jode.decompiler.TabbedPrintWriter; 23 24 public class CheckCastOperator extends Operator { 25 Type castType; 26 27 public CheckCastOperator(Type type) { 28 super(type, 0); 29 castType = type; 30 initOperands(1); 31 } 32 33 public int getPriority() { 34 return 700; 35 } 36 37 public void updateSubTypes() { 38 subExpressions[0].setType(Type.tUObject); 39 } 40 41 public void updateType() { 42 } 43 44 public Expression simplify() { 45 if (subExpressions[0].getType().getCanonic() 46 .isOfType(Type.tSubType(castType))) 47 50 return subExpressions[0].simplify(); 51 return super.simplify(); 52 } 53 54 public void dumpExpression(TabbedPrintWriter writer) 55 throws java.io.IOException { 56 writer.print("("); 57 writer.printType(castType); 58 writer.print(") "); 59 writer.breakOp(); 60 61 65 Type superType = castType.getCastHelper(subExpressions[0].getType()); 66 if (superType != null) { 67 writer.print("("); 68 writer.printType(superType); 69 writer.print(") "); 70 writer.breakOp(); 71 } 72 subExpressions[0].dumpExpression(writer, 700); 73 } 74 } 75 | Popular Tags |