Java Code Examples for com.android.dx.rop.type.Prototype#getParameterTypes()

The following examples show how to use com.android.dx.rop.type.Prototype#getParameterTypes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassReferenceListBuilder.java    From buck with Apache License 2.0 6 votes vote down vote up
private void addDependencies(ConstantPool pool) {
    for (Constant constant : pool.getEntries()) {
        if (constant instanceof CstType) {
            checkDescriptor(((CstType) constant).getClassType());
        } else if (constant instanceof CstFieldRef) {
            checkDescriptor(((CstFieldRef) constant).getType());
        } else if (constant instanceof CstMethodRef) {
            Prototype proto = ((CstMethodRef) constant).getPrototype();
            checkDescriptor(proto.getReturnType());
            StdTypeList args = proto.getParameterTypes();
            for (int i = 0; i < args.size(); i++) {
                checkDescriptor(args.get(i));
            }
        }
    }
}
 
Example 2
Source File: BaseMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void popArgs(Frame frame, Prototype prototype) {
    StdTypeList types = prototype.getParameterTypes();
    int size = types.size();

    // Use the above method to do the actual popping...
    popArgs(frame, size);

    // ...and then verify the popped types.

    for (int i = 0; i < size; i++) {
        if (! Merger.isPossiblyAssignableFrom(types.getType(i), args[i])) {
            throw new SimException("at stack depth " + (size - 1 - i) +
                    ", expected type " + types.getType(i).toHuman() +
                    " but found " + args[i].getType().toHuman());
        }
    }
}
 
Example 3
Source File: BaseMachine.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
public void popArgs(Frame frame, Prototype prototype) {
    StdTypeList types = prototype.getParameterTypes();
    int size = types.size();

    // Use the above method to do the actual popping...
    popArgs(frame, size);

    // ...and then verify the popped types.

    for (int i = 0; i < size; i++) {
        if (! Merger.isPossiblyAssignableFrom(types.getType(i), args[i])) {
            throw new SimException("at stack depth " + (size - 1 - i) +
                    ", expected type " + types.getType(i).toHuman() +
                    " but found " + args[i].getType().toHuman());
        }
    }
}
 
Example 4
Source File: BaseMachine.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void popArgs(Frame frame, Prototype prototype) {
    StdTypeList types = prototype.getParameterTypes();
    int size = types.size();

    // Use the above method to do the actual popping...
    popArgs(frame, size);

    // ...and then verify the popped types.

    for (int i = 0; i < size; i++) {
        if (! Merger.isPossiblyAssignableFrom(types.getType(i), args[i])) {
            throw new SimException("at stack depth " + (size - 1 - i) +
                    ", expected type " + types.getType(i).toHuman() +
                    " but found " + args[i].getType().toHuman());
        }
    }
}
 
Example 5
Source File: ClassReferenceListBuilder.java    From RocooFix with MIT License 6 votes vote down vote up
private void addDependencies(ConstantPool pool) {

        for (Constant constant : pool.getEntries()) {
            if (constant instanceof CstType) {
                checkDescriptor(((CstType) constant).getClassType());
            } else if (constant instanceof CstFieldRef) {
                checkDescriptor(((CstFieldRef) constant).getType());
            } else if (constant instanceof CstMethodRef) {
                Prototype proto = ((CstMethodRef) constant).getPrototype();
                checkDescriptor(proto.getReturnType());
                StdTypeList args = proto.getParameterTypes();
                for (int i = 0; i < args.size(); i++) {
                    checkDescriptor(args.get(i));
                }
            }
        }
    }
 
Example 6
Source File: BaseMachine.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
   @Override
public void popArgs(Frame frame, Prototype prototype) {
       StdTypeList types = prototype.getParameterTypes();
       int size = types.size();

       // Use the above method to do the actual popping...
       popArgs(frame, size);

       // ...and then verify the popped types.

       for (int i = 0; i < size; i++) {
           if (! Merger.isPossiblyAssignableFrom(types.getType(i), args[i])) {
               throw new SimException("at stack depth " + (size - 1 - i) +
                       ", expected type " + types.getType(i).toHuman() +
                       " but found " + args[i].getType().toHuman());
           }
       }
   }
 
Example 7
Source File: ProtoIdItem.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param prototype {@code non-null;} the constant for the prototype
 */
public ProtoIdItem(Prototype prototype) {
    if (prototype == null) {
        throw new NullPointerException("prototype == null");
    }

    this.prototype = prototype;
    this.shortForm = makeShortForm(prototype);

    StdTypeList parameters = prototype.getParameterTypes();
    this.parameterTypes = (parameters.size() == 0) ? null
        : new TypeListItem(parameters);
}
 
Example 8
Source File: ProtoIdItem.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the short-form of the given prototype.
 *
 * @param prototype {@code non-null;} the prototype
 * @return {@code non-null;} the short form
 */
private static CstString makeShortForm(Prototype prototype) {
    StdTypeList parameters = prototype.getParameterTypes();
    int size = parameters.size();
    StringBuilder sb = new StringBuilder(size + 1);

    sb.append(shortFormCharFor(prototype.getReturnType()));

    for (int i = 0; i < size; i++) {
        sb.append(shortFormCharFor(parameters.getType(i)));
    }

    return new CstString(sb.toString());
}
 
Example 9
Source File: ProtoIdItem.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param prototype {@code non-null;} the constant for the prototype
 */
public ProtoIdItem(Prototype prototype) {
    if (prototype == null) {
        throw new NullPointerException("prototype == null");
    }

    this.prototype = prototype;
    this.shortForm = makeShortForm(prototype);

    StdTypeList parameters = prototype.getParameterTypes();
    this.parameterTypes = (parameters.size() == 0) ? null
        : new TypeListItem(parameters);
}
 
Example 10
Source File: ClassReferenceListBuilder.java    From RocooFix with MIT License 5 votes vote down vote up
private void checkPrototype(Prototype proto) {
  checkDescriptor(proto.getReturnType().getDescriptor());
  StdTypeList args = proto.getParameterTypes();
  for (int i = 0; i < args.size(); i++) {
      checkDescriptor(args.get(i).getDescriptor());
  }
}
 
Example 11
Source File: ProtoIdItem.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the short-form of the given prototype.
 *
 * @param prototype {@code non-null;} the prototype
 * @return {@code non-null;} the short form
 */
private static CstString makeShortForm(Prototype prototype) {
    StdTypeList parameters = prototype.getParameterTypes();
    int size = parameters.size();
    StringBuilder sb = new StringBuilder(size + 1);

    sb.append(shortFormCharFor(prototype.getReturnType()));

    for (int i = 0; i < size; i++) {
        sb.append(shortFormCharFor(parameters.getType(i)));
    }

    return new CstString(sb.toString());
}
 
Example 12
Source File: ProtoIdItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param prototype {@code non-null;} the constant for the prototype
 */
public ProtoIdItem(Prototype prototype) {
    if (prototype == null) {
        throw new NullPointerException("prototype == null");
    }

    this.prototype = prototype;
    this.shortForm = makeShortForm(prototype);

    StdTypeList parameters = prototype.getParameterTypes();
    this.parameterTypes = (parameters.size() == 0) ? null
        : new TypeListItem(parameters);
}
 
Example 13
Source File: ClassReferenceListBuilder.java    From Box with Apache License 2.0 5 votes vote down vote up
private void checkPrototype(Prototype proto) {
  checkDescriptor(proto.getReturnType().getDescriptor());
  StdTypeList args = proto.getParameterTypes();
  for (int i = 0; i < args.size(); i++) {
      checkDescriptor(args.get(i).getDescriptor());
  }
}
 
Example 14
Source File: ProtoIdItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the short-form of the given prototype.
 *
 * @param prototype {@code non-null;} the prototype
 * @return {@code non-null;} the short form
 */
private static CstString makeShortForm(Prototype prototype) {
    StdTypeList parameters = prototype.getParameterTypes();
    int size = parameters.size();
    StringBuilder sb = new StringBuilder(size + 1);

    sb.append(shortFormCharFor(prototype.getReturnType()));

    for (int i = 0; i < size; i++) {
        sb.append(shortFormCharFor(parameters.getType(i)));
    }

    return new CstString(sb.toString());
}
 
Example 15
Source File: ProtoIdItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param prototype {@code non-null;} the constant for the prototype
 */
public ProtoIdItem(Prototype prototype) {
    if (prototype == null) {
        throw new NullPointerException("prototype == null");
    }

    this.prototype = prototype;
    this.shortForm = makeShortForm(prototype);

    StdTypeList parameters = prototype.getParameterTypes();
    this.parameterTypes = (parameters.size() == 0) ? null
        : new TypeListItem(parameters);
}
 
Example 16
Source File: ClassReferenceListBuilder.java    From Box with Apache License 2.0 5 votes vote down vote up
private void checkPrototype(Prototype proto) {
  checkDescriptor(proto.getReturnType().getDescriptor());
  StdTypeList args = proto.getParameterTypes();
  for (int i = 0; i < args.size(); i++) {
      checkDescriptor(args.get(i).getDescriptor());
  }
}
 
Example 17
Source File: ProtoIdItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the short-form of the given prototype.
 *
 * @param prototype {@code non-null;} the prototype
 * @return {@code non-null;} the short form
 */
private static CstString makeShortForm(Prototype prototype) {
    StdTypeList parameters = prototype.getParameterTypes();
    int size = parameters.size();
    StringBuilder sb = new StringBuilder(size + 1);

    sb.append(shortFormCharFor(prototype.getReturnType()));

    for (int i = 0; i < size; i++) {
        sb.append(shortFormCharFor(parameters.getType(i)));
    }

    return new CstString(sb.toString());
}