Java Code Examples for com.android.dx.rop.type.StdTypeList#size()

The following examples show how to use com.android.dx.rop.type.StdTypeList#size() . 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 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 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 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 4
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 5
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 6
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 7
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 8
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 9
Source File: Frame.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this frame with the method's parameters. Used for the first
 * frame.
 *
 * @param params Type list of method parameters.
 */
public void initializeWithParameters(StdTypeList params) {
    int at = 0;
    int sz = params.size();

    for (int i = 0; i < sz; i++) {
         Type one = params.get(i);
         locals.set(at, one);
         at += one.getCategory();
    }
}
 
Example 10
Source File: ProtoIdItem.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
    int shortyIdx = file.getStringIds().indexOf(shortForm);
    int returnIdx = file.getTypeIds().indexOf(prototype.getReturnType());
    int paramsOff = OffsettedItem.getAbsoluteOffsetOr0(parameterTypes);

    if (out.annotates()) {
        StringBuilder sb = new StringBuilder();
        sb.append(prototype.getReturnType().toHuman());
        sb.append(" proto(");

        StdTypeList params = prototype.getParameterTypes();
        int size = params.size();

        for (int i = 0; i < size; i++) {
            if (i != 0) {
                sb.append(", ");
            }
            sb.append(params.getType(i).toHuman());
        }

        sb.append(")");
        out.annotate(0, indexString() + ' ' + sb.toString());
        out.annotate(4, "  shorty_idx:      " + Hex.u4(shortyIdx) +
                " // " + shortForm.toQuoted());
        out.annotate(4, "  return_type_idx: " + Hex.u4(returnIdx) +
                " // " + prototype.getReturnType().toHuman());
        out.annotate(4, "  parameters_off:  " + Hex.u4(paramsOff));
    }

    out.writeInt(shortyIdx);
    out.writeInt(returnIdx);
    out.writeInt(paramsOff);
}
 
Example 11
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 12
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 13
Source File: Frame.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this frame with the method's parameters. Used for the first
 * frame.
 *
 * @param params Type list of method parameters.
 */
public void initializeWithParameters(StdTypeList params) {
    int at = 0;
    int sz = params.size();

    for (int i = 0; i < sz; i++) {
         Type one = params.get(i);
         locals.set(at, one);
         at += one.getCategory();
    }
}
 
Example 14
Source File: ProtoIdItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
    int shortyIdx = file.getStringIds().indexOf(shortForm);
    int returnIdx = file.getTypeIds().indexOf(prototype.getReturnType());
    int paramsOff = OffsettedItem.getAbsoluteOffsetOr0(parameterTypes);

    if (out.annotates()) {
        StringBuilder sb = new StringBuilder();
        sb.append(prototype.getReturnType().toHuman());
        sb.append(" proto(");

        StdTypeList params = prototype.getParameterTypes();
        int size = params.size();

        for (int i = 0; i < size; i++) {
            if (i != 0) {
                sb.append(", ");
            }
            sb.append(params.getType(i).toHuman());
        }

        sb.append(")");
        out.annotate(0, indexString() + ' ' + sb.toString());
        out.annotate(4, "  shorty_idx:      " + Hex.u4(shortyIdx) +
                " // " + shortForm.toQuoted());
        out.annotate(4, "  return_type_idx: " + Hex.u4(returnIdx) +
                " // " + prototype.getReturnType().toHuman());
        out.annotate(4, "  parameters_off:  " + Hex.u4(paramsOff));
    }

    out.writeInt(shortyIdx);
    out.writeInt(returnIdx);
    out.writeInt(paramsOff);
}
 
Example 15
Source File: Frame.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this frame with the method's parameters. Used for the first
 * frame.
 *
 * @param params Type list of method parameters.
 */
public void initializeWithParameters(StdTypeList params) {
    int at = 0;
    int sz = params.size();

    for (int i = 0; i < sz; i++) {
         Type one = params.get(i);
         locals.set(at, one);
         at += one.getCategory();
    }
}
 
Example 16
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 17
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 18
Source File: Frame.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize this frame with the method's parameters. Used for the first
 * frame.
 *
 * @param params Type list of method parameters.
 */
public void initializeWithParameters(StdTypeList params) {
    int at = 0;
    int sz = params.size();

    for (int i = 0; i < sz; i++) {
         Type one = params.get(i);
         locals.set(at, one);
         at += one.getCategory();
    }
}
 
Example 19
Source File: ProtoIdItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
    int shortyIdx = file.getStringIds().indexOf(shortForm);
    int returnIdx = file.getTypeIds().indexOf(prototype.getReturnType());
    int paramsOff = OffsettedItem.getAbsoluteOffsetOr0(parameterTypes);

    if (out.annotates()) {
        StringBuilder sb = new StringBuilder();
        sb.append(prototype.getReturnType().toHuman());
        sb.append(" proto(");

        StdTypeList params = prototype.getParameterTypes();
        int size = params.size();

        for (int i = 0; i < size; i++) {
            if (i != 0) {
                sb.append(", ");
            }
            sb.append(params.getType(i).toHuman());
        }

        sb.append(")");
        out.annotate(0, indexString() + ' ' + sb.toString());
        out.annotate(4, "  shorty_idx:      " + Hex.u4(shortyIdx) +
                " // " + shortForm.toQuoted());
        out.annotate(4, "  return_type_idx: " + Hex.u4(returnIdx) +
                " // " + prototype.getReturnType().toHuman());
        out.annotate(4, "  parameters_off:  " + Hex.u4(paramsOff));
    }

    out.writeInt(shortyIdx);
    out.writeInt(returnIdx);
    out.writeInt(paramsOff);
}
 
Example 20
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());
}