private String toTypeUse(Type type) {
    String typeUse = null;

    if (type instanceof ArrayType) {
      ArrayType at = (ArrayType) type;
      typeUse = "";
      int dims = at.getDimensions();
      for (int i = 0; i < dims; i++) {
        typeUse = typeUse.concat("[]");
      }
    } // end if

    return typeUse;
  }
示例#2
0
 public void outAFullIdentNonvoidType(AFullIdentNonvoidType node) {
   String typeName = (String) mProductions.removeLast();
   Type t = RefType.v(typeName);
   int dim = node.getArrayBrackets().size();
   if (dim > 0) t = ArrayType.v(t, dim);
   mProductions.addLast(t);
 }
  private DbOOAdt toAdt(Type type) throws DbException {
    DbOOAdt adt = null;

    if (type instanceof BasicType) {
      BasicType basicType = (BasicType) type;
      adt = toBasicAdt(basicType);
    } else if (type instanceof ObjectType) {
      ObjectType ot = (ObjectType) type;
      String classname = ot.getClassName();
      adt = toAdt(classname, ot);
    } else if (type instanceof ArrayType) {
      ArrayType at = (ArrayType) type;
      adt = toAdt(at.getBasicType());
    } else {
      // other cases?
    } // end if

    return adt;
  }
示例#4
0
 private static ArrayReference createURLArray(EvaluationContext context)
     throws EvaluateException, InvocationException, InvalidTypeException, ClassNotLoadedException,
         IncompatibleThreadStateException {
   DebugProcess process = context.getDebugProcess();
   ArrayType arrayType =
       (ArrayType) process.findClass(context, "java.net.URL[]", context.getClassLoader());
   ArrayReference arrayRef = arrayType.newInstance(1);
   keep(arrayRef, context);
   ClassType classType =
       (ClassType) process.findClass(context, "java.net.URL", context.getClassLoader());
   VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl) process.getVirtualMachineProxy();
   StringReference url = proxy.mirrorOf("file:a");
   keep(url, context);
   ObjectReference reference =
       process.newInstance(
           context,
           classType,
           classType.concreteMethodByName("<init>", "(Ljava/lang/String;)V"),
           Collections.singletonList(url));
   keep(reference, context);
   arrayRef.setValues(Collections.singletonList(reference));
   return arrayRef;
 }
示例#5
0
  private Type getSootType(AnnotationElem e) {
    Type annotationType;
    switch (e.getKind()) {
      case '[': // array
        // Until now we only know it's some kind of array.
        annotationType = ARRAY_TYPE;
        AnnotationArrayElem array = (AnnotationArrayElem) e;
        if (array.getNumValues() > 0) {
          // Try to determine type of the array
          AnnotationElem firstElement = array.getValueAt(0);
          Type type = getSootType(firstElement);
          if (type == null) return null;

          if (type.equals(ARRAY_TYPE)) return ARRAY_TYPE;

          return ArrayType.v(type, 1);
        }
        break;
      case 's': // string
        annotationType = RefType.v("java.lang.String");
        break;
      case 'c': // class
        annotationType = RefType.v("java.lang.Class");
        break;
      case 'e': // enum
        AnnotationEnumElem enumElem = (AnnotationEnumElem) e;
        annotationType = Util.getType(enumElem.getTypeName());
        ;
        break;

      case 'L':
      case 'J':
      case 'S':
      case 'D':
      case 'I':
      case 'F':
      case 'B':
      case 'C':
      case 'V':
      case 'Z':
        annotationType = Util.getType(String.valueOf(e.getKind()));
        break;
      default:
        annotationType = null;
        break;
    }
    return annotationType;
  }
示例#6
0
  public void outAMultiNewExpr(AMultiNewExpr node) {

    LinkedList arrayDesc = node.getArrayDescriptor();

    int descCnt = arrayDesc.size();
    List sizes = new LinkedList();

    Iterator it = arrayDesc.iterator();
    while (it.hasNext()) {
      AArrayDescriptor o = (AArrayDescriptor) it.next();
      if (o.getImmediate() != null) sizes.add(0, (Value) mProductions.removeLast());
      else break;
    }

    Type type = (Type) mProductions.removeLast();
    ArrayType arrayType = ArrayType.v(type, descCnt);

    mProductions.addLast(Jimple.v().newNewMultiArrayExpr(arrayType, sizes));
  }
示例#7
0
 /*
   nonvoid_type =
   {base}   base_type_no_name array_brackets*;
   {quoted} quoted_name array_brackets* |
   {ident}  identifier array_brackets* |
   {full_ident} full_identifier array_brackets*;
 */
 public void outABaseNonvoidType(ABaseNonvoidType node) {
   Type t = (Type) mProductions.removeLast();
   int dim = node.getArrayBrackets().size();
   if (dim > 0) t = ArrayType.v(t, dim);
   mProductions.addLast(t);
 }
示例#8
0
 @Override
 public JsonType visitArray(ArrayType arrayType, Void o) {
   throw new UnsupportedOperationException(arrayType.toString());
 }