com.android.dx.rop.type.Prototype Java Examples
The following examples show how to use
com.android.dx.rop.type.Prototype.
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 |
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: ProtoIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the index of the given prototype, which must have * been added to this instance. * * @param prototype {@code non-null;} the prototype to look up * @return {@code >= 0;} the reference's index */ public int indexOf(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfNotPrepared(); ProtoIdItem item = protoIds.get(prototype); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #3
Source File: ProtoIdsSection.java From buck with Apache License 2.0 | 6 votes |
/** * Gets the index of the given prototype, which must have * been added to this instance. * * @param prototype {@code non-null;} the prototype to look up * @return {@code >= 0;} the reference's index */ public int indexOf(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfNotPrepared(); ProtoIdItem item = protoIds.get(prototype); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #4
Source File: ProtoIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param prototype {@code non-null;} the prototype to intern * @return {@code non-null;} the interned reference */ public synchronized ProtoIdItem intern(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfPrepared(); ProtoIdItem result = protoIds.get(prototype); if (result == null) { result = new ProtoIdItem(prototype); protoIds.put(prototype, result); } return result; }
Example #5
Source File: CstBaseMethodRef.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param definingClass {@code non-null;} the type of the defining class * @param nat {@code non-null;} the name-and-type */ /*package*/ CstBaseMethodRef(CstType definingClass, CstNat nat) { super(definingClass, nat); String descriptor = getNat().getDescriptor().getString(); if (isSignaturePolymorphic()) { // The prototype for signature polymorphic methods is used to // construct call-site information and select the true invocation // target (invoke() or invokeExact(). The prototype is created // without being interned to avoid polluting the DEX file with // unused data. this.prototype = Prototype.fromDescriptor(descriptor); } else { this.prototype = Prototype.intern(descriptor); } this.instancePrototype = null; }
Example #6
Source File: ClassReferenceListBuilder.java From RocooFix with MIT License | 6 votes |
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 #7
Source File: CstBaseMethodRef.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param definingClass {@code non-null;} the type of the defining class * @param nat {@code non-null;} the name-and-type */ /*package*/ CstBaseMethodRef(CstType definingClass, CstNat nat) { super(definingClass, nat); String descriptor = getNat().getDescriptor().getString(); if (isSignaturePolymorphic()) { // The prototype for signature polymorphic methods is used to // construct call-site information and select the true invocation // target (invoke() or invokeExact(). The prototype is created // without being interned to avoid polluting the DEX file with // unused data. this.prototype = Prototype.fromDescriptor(descriptor); } else { this.prototype = Prototype.intern(descriptor); } this.instancePrototype = null; }
Example #8
Source File: ProtoIdsSection.java From buck with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param prototype {@code non-null;} the prototype to intern * @return {@code non-null;} the interned reference */ public synchronized ProtoIdItem intern(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfPrepared(); ProtoIdItem result = protoIds.get(prototype); if (result == null) { result = new ProtoIdItem(prototype); protoIds.put(prototype, result); } return result; }
Example #9
Source File: BaseMachine.java From Box with Apache License 2.0 | 6 votes |
/** {@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 #10
Source File: CstCallSite.java From Box with Apache License 2.0 | 6 votes |
/** * Creates an instance of a {@code CstCallSite}. * * @param bootstrapHandle {@code non-null;} the bootstrap method handle to invoke * @param nat {@code non-null;} the name and type to be resolved by the bootstrap method handle * @param optionalArguments {@code null-ok;} optional arguments to provide to the bootstrap * method * @return a new {@code CstCallSite} instance */ public static CstCallSite make(CstMethodHandle bootstrapHandle, CstNat nat, BootstrapMethodArgumentsList optionalArguments) { if (bootstrapHandle == null) { throw new NullPointerException("bootstrapMethodHandle == null"); } else if (nat == null) { throw new NullPointerException("nat == null"); } List list = new List(3 + optionalArguments.size()); list.set(0, bootstrapHandle); list.set(1, nat.getName()); list.set(2, new CstProtoRef(Prototype.fromDescriptor(nat.getDescriptor().getString()))); if (optionalArguments != null) { for (int i = 0; i < optionalArguments.size(); ++i) { list.set(i + 3, optionalArguments.get(i)); } } list.setImmutable(); return new CstCallSite(list); }
Example #11
Source File: ClassReferenceListBuilder.java From Box with Apache License 2.0 | 6 votes |
private void addDependencies(DirectClassFile classFile) { for (Constant constant : classFile.getConstantPool().getEntries()) { if (constant instanceof CstType) { checkDescriptor(((CstType) constant).getClassType().getDescriptor()); } else if (constant instanceof CstFieldRef) { checkDescriptor(((CstFieldRef) constant).getType().getDescriptor()); } else if (constant instanceof CstBaseMethodRef) { checkPrototype(((CstBaseMethodRef) constant).getPrototype()); } } FieldList fields = classFile.getFields(); int nbField = fields.size(); for (int i = 0; i < nbField; i++) { checkDescriptor(fields.get(i).getDescriptor().getString()); } MethodList methods = classFile.getMethods(); int nbMethods = methods.size(); for (int i = 0; i < nbMethods; i++) { checkPrototype(Prototype.intern(methods.get(i).getDescriptor().getString())); } }
Example #12
Source File: CstBaseMethodRef.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param definingClass {@code non-null;} the type of the defining class * @param nat {@code non-null;} the name-and-type */ /*package*/ CstBaseMethodRef(CstType definingClass, CstNat nat) { super(definingClass, nat); String descriptor = getNat().getDescriptor().getString(); if (isSignaturePolymorphic()) { // The prototype for signature polymorphic methods is used to // construct call-site information and select the true invocation // target (invoke() or invokeExact(). The prototype is created // without being interned to avoid polluting the DEX file with // unused data. this.prototype = Prototype.fromDescriptor(descriptor); } else { this.prototype = Prototype.intern(descriptor); } this.instancePrototype = null; }
Example #13
Source File: BaseMachine.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** {@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 #14
Source File: ProtoIdsSection.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param prototype {@code non-null;} the prototype to intern * @return {@code non-null;} the interned reference */ public synchronized ProtoIdItem intern(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfPrepared(); ProtoIdItem result = protoIds.get(prototype); if (result == null) { result = new ProtoIdItem(prototype); protoIds.put(prototype, result); } return result; }
Example #15
Source File: BaseMachine.java From buck with Apache License 2.0 | 6 votes |
/** {@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 #16
Source File: ProtoIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the index of the given prototype, which must have * been added to this instance. * * @param prototype {@code non-null;} the prototype to look up * @return {@code >= 0;} the reference's index */ public int indexOf(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfNotPrepared(); ProtoIdItem item = protoIds.get(prototype); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #17
Source File: ProtoIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param prototype {@code non-null;} the prototype to intern * @return {@code non-null;} the interned reference */ public synchronized ProtoIdItem intern(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } throwIfPrepared(); ProtoIdItem result = protoIds.get(prototype); if (result == null) { result = new ProtoIdItem(prototype); protoIds.put(prototype, result); } return result; }
Example #18
Source File: CstBaseMethodRef.java From Box with Apache License 2.0 | 5 votes |
/** * Gets the prototype of this method as either a * {@code static} or instance method. In the case of a * {@code static} method, this is the same as the raw * prototype. In the case of an instance method, this has an * appropriately-typed {@code this} argument as the first * one. * * @param isStatic whether the method should be considered static * @return {@code non-null;} the method prototype */ public final Prototype getPrototype(boolean isStatic) { if (isStatic) { return prototype; } else { if (instancePrototype == null) { Type thisType = getDefiningClass().getClassType(); instancePrototype = prototype.withFirstParameter(thisType); } return instancePrototype; } }
Example #19
Source File: ProtoIdItem.java From Box with Apache License 2.0 | 5 votes |
/** * 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 #20
Source File: BaseMachine.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param prototype {@code non-null;} the prototype for the * associated method */ public BaseMachine(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } this.prototype = prototype; args = new TypeBearer[10]; results = new TypeBearer[6]; clearArgs(); }
Example #21
Source File: StdMethod.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param definingClass {@code non-null;} the defining class * @param accessFlags access flags * @param nat {@code non-null;} member name and type (descriptor) * @param attributes {@code non-null;} list of associated attributes */ public StdMethod(CstType definingClass, int accessFlags, CstNat nat, AttributeList attributes) { super(definingClass, accessFlags, nat, attributes); String descStr = getDescriptor().getString(); effectiveDescriptor = Prototype.intern(descStr, definingClass.getClassType(), AccessFlags.isStatic(accessFlags), nat.isInstanceInit()); }
Example #22
Source File: ProtoIdItem.java From Box with Apache License 2.0 | 5 votes |
/** * 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 #23
Source File: BaseMachine.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param prototype {@code non-null;} the prototype for the * associated method */ public BaseMachine(Prototype prototype) { if (prototype == null) { throw new NullPointerException("prototype == null"); } this.prototype = prototype; args = new TypeBearer[10]; results = new TypeBearer[6]; clearArgs(); }
Example #24
Source File: CstInvokeDynamic.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. This constructor is private; use {@link #make}. * * @param bootstrapMethodIndex The index of the bootstrap method in the bootstrap method table * @param nat the name and type */ private CstInvokeDynamic(int bootstrapMethodIndex, CstNat nat) { this.bootstrapMethodIndex = bootstrapMethodIndex; this.nat = nat; this.prototype = Prototype.fromDescriptor(nat.getDescriptor().toHuman()); this.references = new ArrayList<>(); }
Example #25
Source File: StdMethod.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param definingClass {@code non-null;} the defining class * @param accessFlags access flags * @param nat {@code non-null;} member name and type (descriptor) * @param attributes {@code non-null;} list of associated attributes */ public StdMethod(CstType definingClass, int accessFlags, CstNat nat, AttributeList attributes) { super(definingClass, accessFlags, nat, attributes); String descStr = getDescriptor().getString(); effectiveDescriptor = Prototype.intern(descStr, definingClass.getClassType(), AccessFlags.isStatic(accessFlags), nat.isInstanceInit()); }
Example #26
Source File: CstBaseMethodRef.java From buck with Apache License 2.0 | 5 votes |
/** * Gets the prototype of this method as either a * {@code static} or instance method. In the case of a * {@code static} method, this is the same as the raw * prototype. In the case of an instance method, this has an * appropriately-typed {@code this} argument as the first * one. * * @param isStatic whether the method should be considered static * @return {@code non-null;} the method prototype */ public final Prototype getPrototype(boolean isStatic) { if (isStatic) { return prototype; } else { if (instancePrototype == null) { Type thisType = getDefiningClass().getClassType(); instancePrototype = prototype.withFirstParameter(thisType); } return instancePrototype; } }
Example #27
Source File: CstBaseMethodRef.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Gets the prototype of this method as either a * {@code static} or instance method. In the case of a * {@code static} method, this is the same as the raw * prototype. In the case of an instance method, this has an * appropriately-typed {@code this} argument as the first * one. * * @param isStatic whether the method should be considered static * @return {@code non-null;} the method prototype */ public final Prototype getPrototype(boolean isStatic) { if (isStatic) { return prototype; } else { if (instancePrototype == null) { Type thisType = getDefiningClass().getClassType(); instancePrototype = prototype.withFirstParameter(thisType); } return instancePrototype; } }
Example #28
Source File: ProtoIdItem.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * 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 #29
Source File: ClassReferenceListBuilder.java From RocooFix with MIT License | 5 votes |
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 #30
Source File: ProtoIdItem.java From Box with Apache License 2.0 | 5 votes |
/** * 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); }