예제 #1
0
 public String getTypeString(Type type) {
   if (type instanceof ArrayType) return getTypeString(((ArrayType) type).getElementType()) + "[]";
   else if (type instanceof ClassInterfacesType)
     return getClassString(((ClassInterfacesType) type).getClassInfo());
   else if (type instanceof NullType) return "Object";
   else return type.toString();
 }
 public Expression simplify() {
   if (subExpressions[0].getType().getCanonic().isOfType(Type.tSubType(castType)))
     /*
      * This is an unnecessary widening cast, probably that inserted by
      * jikes for inner classes constructors.
      */
     return subExpressions[0].simplify();
   return super.simplify();
 }
  public void dumpExpression(TabbedPrintWriter writer) throws java.io.IOException {
    writer.print("(");
    writer.printType(castType);
    writer.print(") ");
    writer.breakOp();

    /*
     * There are special cases where a cast isn't allowed. We must cast to
     * the common super type before. This cases always give a runtime error,
     * but we want to decompile even bad programs.
     */
    Type superType = castType.getCastHelper(subExpressions[0].getType());
    if (superType != null) {
      writer.print("(");
      writer.printType(superType);
      writer.print(") ");
      writer.breakOp();
    }
    subExpressions[0].dumpExpression(writer, 700);
  }