com.android.dx.rop.cst.CstFieldRef Java Examples
The following examples show how to use
com.android.dx.rop.cst.CstFieldRef.
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: DexFile.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the {@link IndexedItem} corresponding to the given constant, * if it is a constant that has such a correspondence, or return * {@code null} if it isn't such a constant. This will throw * an exception if the given constant <i>should</i> have been found * but wasn't. * * @param cst {@code non-null;} the constant to look up * @return {@code null-ok;} its corresponding item, if it has a corresponding * item, or {@code null} if it's not that sort of constant */ /*package*/ IndexedItem findItemOrNull(Constant cst) { if (cst instanceof CstString) { return stringIds.get(cst); } else if (cst instanceof CstType) { return typeIds.get(cst); } else if (cst instanceof CstBaseMethodRef) { return methodIds.get(cst); } else if (cst instanceof CstFieldRef) { return fieldIds.get(cst); } else if (cst instanceof CstEnumRef) { return fieldIds.intern(((CstEnumRef) cst).getFieldRef()); } else if (cst instanceof CstProtoRef) { return protoIds.get(cst); } else if (cst instanceof CstMethodHandle) { return methodHandles.get(cst); } else if (cst instanceof CstCallSiteRef) { return callSiteIds.get(cst); } else { return null; } }
Example #2
Source File: DexFile.java From Box with Apache License 2.0 | 6 votes |
/** * Interns the given constant in the appropriate section of this * instance, or do nothing if the given constant isn't the sort * that should be interned. * * @param cst {@code non-null;} constant to possibly intern */ /*package*/ void internIfAppropriate(Constant cst) { if (cst == null) { throw new NullPointerException("cst == null"); } if (cst instanceof CstString) { stringIds.intern((CstString) cst); } else if (cst instanceof CstType) { typeIds.intern((CstType) cst); } else if (cst instanceof CstBaseMethodRef) { methodIds.intern((CstBaseMethodRef) cst); } else if (cst instanceof CstFieldRef) { fieldIds.intern((CstFieldRef) cst); } else if (cst instanceof CstEnumRef) { fieldIds.intern(((CstEnumRef) cst).getFieldRef()); } else if (cst instanceof CstProtoRef) { protoIds.intern(((CstProtoRef) cst).getPrototype()); } else if (cst instanceof CstMethodHandle) { methodHandles.intern((CstMethodHandle) cst); } }
Example #3
Source File: DexFile.java From buck with Apache License 2.0 | 6 votes |
/** * Gets the {@link IndexedItem} corresponding to the given constant, * if it is a constant that has such a correspondence, or return * {@code null} if it isn't such a constant. This will throw * an exception if the given constant <i>should</i> have been found * but wasn't. * * @param cst {@code non-null;} the constant to look up * @return {@code null-ok;} its corresponding item, if it has a corresponding * item, or {@code null} if it's not that sort of constant */ /*package*/ IndexedItem findItemOrNull(Constant cst) { IndexedItem item; if (cst instanceof CstString) { return stringIds.get(cst); } else if (cst instanceof CstType) { return typeIds.get(cst); } else if (cst instanceof CstBaseMethodRef) { return methodIds.get(cst); } else if (cst instanceof CstFieldRef) { return fieldIds.get(cst); } else { return null; } }
Example #4
Source File: DexFile.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Gets the {@link IndexedItem} corresponding to the given constant, * if it is a constant that has such a correspondence, or return * {@code null} if it isn't such a constant. This will throw * an exception if the given constant <i>should</i> have been found * but wasn't. * * @param cst {@code non-null;} the constant to look up * @return {@code null-ok;} its corresponding item, if it has a corresponding * item, or {@code null} if it's not that sort of constant */ /*package*/ IndexedItem findItemOrNull(Constant cst) { if (cst instanceof CstString) { return stringIds.get(cst); } else if (cst instanceof CstType) { return typeIds.get(cst); } else if (cst instanceof CstBaseMethodRef) { return methodIds.get(cst); } else if (cst instanceof CstFieldRef) { return fieldIds.get(cst); } else if (cst instanceof CstProtoRef) { return protoIds.get(cst); } else { return null; } }
Example #5
Source File: DexFile.java From buck with Apache License 2.0 | 6 votes |
/** * Interns the given constant in the appropriate section of this * instance, or do nothing if the given constant isn't the sort * that should be interned. * * @param cst {@code non-null;} constant to possibly intern */ /*package*/ void internIfAppropriate(Constant cst) { if (cst instanceof CstString) { stringIds.intern((CstString) cst); } else if (cst instanceof CstType) { typeIds.intern((CstType) cst); } else if (cst instanceof CstBaseMethodRef) { methodIds.intern((CstBaseMethodRef) cst); } else if (cst instanceof CstFieldRef) { fieldIds.intern((CstFieldRef) cst); } else if (cst instanceof CstEnumRef) { fieldIds.intern(((CstEnumRef) cst).getFieldRef()); } else if (cst == null) { throw new NullPointerException("cst == null"); } }
Example #6
Source File: DexFile.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the {@link IndexedItem} corresponding to the given constant, * if it is a constant that has such a correspondence, or return * {@code null} if it isn't such a constant. This will throw * an exception if the given constant <i>should</i> have been found * but wasn't. * * @param cst {@code non-null;} the constant to look up * @return {@code null-ok;} its corresponding item, if it has a corresponding * item, or {@code null} if it's not that sort of constant */ /*package*/ IndexedItem findItemOrNull(Constant cst) { if (cst instanceof CstString) { return stringIds.get(cst); } else if (cst instanceof CstType) { return typeIds.get(cst); } else if (cst instanceof CstBaseMethodRef) { return methodIds.get(cst); } else if (cst instanceof CstFieldRef) { return fieldIds.get(cst); } else if (cst instanceof CstEnumRef) { return fieldIds.intern(((CstEnumRef) cst).getFieldRef()); } else if (cst instanceof CstProtoRef) { return protoIds.get(cst); } else if (cst instanceof CstMethodHandle) { return methodHandles.get(cst); } else if (cst instanceof CstCallSiteRef) { return callSiteIds.get(cst); } else { return null; } }
Example #7
Source File: Form22c.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean isCompatible(DalvInsn insn) { RegisterSpecList regs = insn.getRegisters(); if (!((insn instanceof CstInsn) && (regs.size() == 2) && unsignedFitsInNibble(regs.get(0).getReg()) && unsignedFitsInNibble(regs.get(1).getReg()))) { return false; } CstInsn ci = (CstInsn) insn; int cpi = ci.getIndex(); if (! unsignedFitsInShort(cpi)) { return false; } Constant cst = ci.getConstant(); return (cst instanceof CstType) || (cst instanceof CstFieldRef); }
Example #8
Source File: FieldIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param field {@code non-null;} the reference to intern * @return {@code non-null;} the interned reference */ public synchronized FieldIdItem intern(CstFieldRef field) { if (field == null) { throw new NullPointerException("field == null"); } throwIfPrepared(); FieldIdItem result = fieldIds.get(field); if (result == null) { result = new FieldIdItem(field); fieldIds.put(field, result); } return result; }
Example #9
Source File: FieldIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public IndexedItem get(Constant cst) { if (cst == null) { throw new NullPointerException("cst == null"); } throwIfNotPrepared(); IndexedItem result = fieldIds.get((CstFieldRef) cst); if (result == null) { throw new IllegalArgumentException("not found"); } return result; }
Example #10
Source File: FieldIdsSection.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Gets the index of the given reference, which must have been added * to this instance. * * @param ref {@code non-null;} the reference to look up * @return {@code >= 0;} the reference's index */ public int indexOf(CstFieldRef ref) { if (ref == null) { throw new NullPointerException("ref == null"); } throwIfNotPrepared(); FieldIdItem item = fieldIds.get(ref); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #11
Source File: Form22c.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean isCompatible(DalvInsn insn) { RegisterSpecList regs = insn.getRegisters(); if (!((insn instanceof CstInsn) && (regs.size() == 2) && unsignedFitsInNibble(regs.get(0).getReg()) && unsignedFitsInNibble(regs.get(1).getReg()))) { return false; } CstInsn ci = (CstInsn) insn; int cpi = ci.getIndex(); if (! unsignedFitsInShort(cpi)) { return false; } Constant cst = ci.getConstant(); return (cst instanceof CstType) || (cst instanceof CstFieldRef); }
Example #12
Source File: FieldIdsSection.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param field {@code non-null;} the reference to intern * @return {@code non-null;} the interned reference */ public synchronized FieldIdItem intern(CstFieldRef field) { if (field == null) { throw new NullPointerException("field == null"); } throwIfPrepared(); FieldIdItem result = fieldIds.get(field); if (result == null) { result = new FieldIdItem(field); fieldIds.put(field, result); } return result; }
Example #13
Source File: FieldIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the index of the given reference, which must have been added * to this instance. * * @param ref {@code non-null;} the reference to look up * @return {@code >= 0;} the reference's index */ public int indexOf(CstFieldRef ref) { if (ref == null) { throw new NullPointerException("ref == null"); } throwIfNotPrepared(); FieldIdItem item = fieldIds.get(ref); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #14
Source File: FieldIdsSection.java From buck with Apache License 2.0 | 6 votes |
/** * Gets the index of the given reference, which must have been added * to this instance. * * @param ref {@code non-null;} the reference to look up * @return {@code >= 0;} the reference's index */ public int indexOf(CstFieldRef ref) { if (ref == null) { throw new NullPointerException("ref == null"); } throwIfNotPrepared(); FieldIdItem item = fieldIds.get(ref); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #15
Source File: FieldIdsSection.java From buck with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param field {@code non-null;} the reference to intern * @return {@code non-null;} the interned reference */ public synchronized FieldIdItem intern(CstFieldRef field) { if (field == null) { throw new NullPointerException("field == null"); } throwIfPrepared(); FieldIdItem result = fieldIds.get(field); if (result == null) { result = new FieldIdItem(field); fieldIds.put(field, result); } return result; }
Example #16
Source File: FieldIdsSection.java From buck with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public IndexedItem get(Constant cst) { if (cst == null) { throw new NullPointerException("cst == null"); } throwIfNotPrepared(); IndexedItem result = fieldIds.get((CstFieldRef) cst); if (result == null) { throw new IllegalArgumentException("not found"); } return result; }
Example #17
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 #18
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 #19
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 #20
Source File: Form22c.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean isCompatible(DalvInsn insn) { RegisterSpecList regs = insn.getRegisters(); if (!((insn instanceof CstInsn) && (regs.size() == 2) && unsignedFitsInNibble(regs.get(0).getReg()) && unsignedFitsInNibble(regs.get(1).getReg()))) { return false; } CstInsn ci = (CstInsn) insn; int cpi = ci.getIndex(); if (! unsignedFitsInShort(cpi)) { return false; } Constant cst = ci.getConstant(); return (cst instanceof CstType) || (cst instanceof CstFieldRef); }
Example #21
Source File: Form22c.java From buck with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean isCompatible(DalvInsn insn) { RegisterSpecList regs = insn.getRegisters(); if (!((insn instanceof CstInsn) && (regs.size() == 2) && unsignedFitsInNibble(regs.get(0).getReg()) && unsignedFitsInNibble(regs.get(1).getReg()))) { return false; } CstInsn ci = (CstInsn) insn; int cpi = ci.getIndex(); if (! unsignedFitsInShort(cpi)) { return false; } Constant cst = ci.getConstant(); return (cst instanceof CstType) || (cst instanceof CstFieldRef); }
Example #22
Source File: FieldIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public IndexedItem get(Constant cst) { if (cst == null) { throw new NullPointerException("cst == null"); } throwIfNotPrepared(); IndexedItem result = fieldIds.get((CstFieldRef) cst); if (result == null) { throw new IllegalArgumentException("not found"); } return result; }
Example #23
Source File: FieldIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Interns an element into this instance. * * @param field {@code non-null;} the reference to intern * @return {@code non-null;} the interned reference */ public synchronized FieldIdItem intern(CstFieldRef field) { if (field == null) { throw new NullPointerException("field == null"); } throwIfPrepared(); FieldIdItem result = fieldIds.get(field); if (result == null) { result = new FieldIdItem(field); fieldIds.put(field, result); } return result; }
Example #24
Source File: FieldIdsSection.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the index of the given reference, which must have been added * to this instance. * * @param ref {@code non-null;} the reference to look up * @return {@code >= 0;} the reference's index */ public int indexOf(CstFieldRef ref) { if (ref == null) { throw new NullPointerException("ref == null"); } throwIfNotPrepared(); FieldIdItem item = fieldIds.get(ref); if (item == null) { throw new IllegalArgumentException("not found"); } return item.getIndex(); }
Example #25
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 #26
Source File: DexFile.java From Box with Apache License 2.0 | 6 votes |
/** * Interns the given constant in the appropriate section of this * instance, or do nothing if the given constant isn't the sort * that should be interned. * * @param cst {@code non-null;} constant to possibly intern */ /*package*/ void internIfAppropriate(Constant cst) { if (cst == null) { throw new NullPointerException("cst == null"); } if (cst instanceof CstString) { stringIds.intern((CstString) cst); } else if (cst instanceof CstType) { typeIds.intern((CstType) cst); } else if (cst instanceof CstBaseMethodRef) { methodIds.intern((CstBaseMethodRef) cst); } else if (cst instanceof CstFieldRef) { fieldIds.intern((CstFieldRef) cst); } else if (cst instanceof CstEnumRef) { fieldIds.intern(((CstEnumRef) cst).getFieldRef()); } else if (cst instanceof CstProtoRef) { protoIds.intern(((CstProtoRef) cst).getPrototype()); } else if (cst instanceof CstMethodHandle) { methodHandles.intern((CstMethodHandle) cst); } }
Example #27
Source File: FieldIdsSection.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public IndexedItem get(Constant cst) { if (cst == null) { throw new NullPointerException("cst == null"); } throwIfNotPrepared(); IndexedItem result = fieldIds.get((CstFieldRef) cst); if (result == null) { throw new IllegalArgumentException("not found"); } return result; }
Example #28
Source File: AnnotationsDirectoryItem.java From Box with Apache License 2.0 | 5 votes |
/** * Adds a field annotations item to this instance. * * @param field {@code non-null;} field in question * @param annotations {@code non-null;} associated annotations to add * @param dexFile {@code non-null;} dex output */ public void addFieldAnnotations(CstFieldRef field, Annotations annotations, DexFile dexFile) { if (fieldAnnotations == null) { fieldAnnotations = new ArrayList<FieldAnnotationStruct>(); } fieldAnnotations.add(new FieldAnnotationStruct(field, new AnnotationSetItem(annotations, dexFile))); }
Example #29
Source File: FieldAnnotationStruct.java From Box with Apache License 2.0 | 5 votes |
/** * Constructs an instance. * * @param field {@code non-null;} the field in question * @param annotations {@code non-null;} the associated annotations */ public FieldAnnotationStruct(CstFieldRef field, AnnotationSetItem annotations) { if (field == null) { throw new NullPointerException("field == null"); } if (annotations == null) { throw new NullPointerException("annotations == null"); } this.field = field; this.annotations = annotations; }
Example #30
Source File: FieldId.java From dexmaker with Apache License 2.0 | 5 votes |
FieldId(TypeId<D> declaringType, TypeId<V> type, String name) { if (declaringType == null || type == null || name == null) { throw new NullPointerException(); } this.declaringType = declaringType; this.type = type; this.name = name; this.nat = new CstNat(new CstString(name), new CstString(type.name)); this.constant = new CstFieldRef(declaringType.constant, nat); }