本文整理汇总了Java中org.jf.dexlib2.iface.reference.FieldReference类的典型用法代码示例。如果您正苦于以下问题:Java FieldReference类的具体用法?Java FieldReference怎么用?Java FieldReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldReference类属于org.jf.dexlib2.iface.reference包,在下文中一共展示了FieldReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeFieldDescriptor
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public static void writeFieldDescriptor(Writer writer, FieldReference fieldReference,
boolean implicitReference) throws IOException {
if (!implicitReference) {
String clazz = fieldReference.getDefiningClass();
if (DexDiffInfo.getModifiedClasses(clazz) != null) {
if (isStaticFiled(DexDiffInfo.getModifiedClasses(clazz), fieldReference)) {//静态变量要访问以前的
} else {
clazz = TypeGenUtil.newType(clazz);
}
}
writer.write(clazz);
writer.write("->");
}
writer.write(fieldReference.getName());
writer.write(':');
writer.write(fieldReference.getType());
}
示例2: writeReference
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public static void writeReference(IndentingWriter writer, int referenceType,
Reference reference) throws IOException {
switch (referenceType) {
case ReferenceType.STRING:
writeStringReference(writer, ((StringReference)reference).getString());
return;
case ReferenceType.TYPE:
writer.write(((TypeReference)reference).getType());
return;
case ReferenceType.METHOD:
ReferenceUtil.writeMethodDescriptor(writer, (MethodReference) reference);
return;
case ReferenceType.FIELD:
ReferenceUtil.writeFieldDescriptor(writer, (FieldReference)reference);
return;
default:
throw new IllegalStateException("Unknown reference type");
}
}
示例3: getNextFieldOffset
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
private int getNextFieldOffset() {
SparseArray<FieldReference> instanceFields = getInstanceFields();
if (instanceFields.size() == 0) {
return 8;
}
int lastItemIndex = instanceFields.size()-1;
int fieldOffset = instanceFields.keyAt(lastItemIndex);
FieldReference lastField = instanceFields.valueAt(lastItemIndex);
switch (lastField.getType().charAt(0)) {
case 'J':
case 'D':
return fieldOffset + 8;
default:
return fieldOffset + 4;
}
}
示例4: jimplify
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public void jimplify (DexBody body) {
TwoRegisterInstruction i = (TwoRegisterInstruction)instruction;
int dest = i.getRegisterA();
int object = i.getRegisterB();
FieldReference f = (FieldReference)((ReferenceInstruction)instruction).getReference();
InstanceFieldRef r = Jimple.v().newInstanceFieldRef(body.getRegisterLocal(object),
getSootFieldRef(f));
assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), r);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
int op = (int)instruction.getOpcode().value;
DalvikTyper.v().setType(assign.getLeftOpBox(), r.getType(), false);
}
}
示例5: jimplify
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public void jimplify (DexBody body) {
int source = ((OneRegisterInstruction)instruction).getRegisterA();
FieldReference f = (FieldReference)((ReferenceInstruction)instruction).getReference();
StaticFieldRef instanceField = Jimple.v().newStaticFieldRef(getStaticSootFieldRef(f));
Local sourceValue = body.getRegisterLocal(source);
assign = getAssignStmt(body, sourceValue, instanceField);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
int op = (int)instruction.getOpcode().value;
DalvikTyper.v().setType(assign.getRightOpBox(), instanceField.getType(), true);
}
}
示例6: jimplify
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public void jimplify (DexBody body) {
TwoRegisterInstruction i = (TwoRegisterInstruction)instruction;
int source = i.getRegisterA();
int object = i.getRegisterB();
FieldReference f = (FieldReference)((ReferenceInstruction)instruction).getReference();
InstanceFieldRef instanceField = Jimple.v().newInstanceFieldRef(body.getRegisterLocal(object),
getSootFieldRef(f));
Local sourceValue = body.getRegisterLocal(source);
assign = getAssignStmt(body, sourceValue, instanceField);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
int op = (int)instruction.getOpcode().value;
DalvikTyper.v().setType(assign.getRightOpBox(), instanceField.getType(), true);
}
}
示例7: getNextFieldOffset
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
private int getNextFieldOffset() {
SparseArray<FieldReference> instanceFields = getInstanceFields();
if (instanceFields.size() == 0) {
return classPath.isArt() ? 0 : 8;
}
int lastItemIndex = instanceFields.size()-1;
int fieldOffset = instanceFields.keyAt(lastItemIndex);
FieldReference lastField = instanceFields.valueAt(lastItemIndex);
if (classPath.isArt()) {
return fieldOffset + getTypeSize(lastField.getType().charAt(0));
} else {
switch (lastField.getType().charAt(0)) {
case 'J':
case 'D':
return fieldOffset + 8;
default:
return fieldOffset + 4;
}
}
}
示例8: analyze
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
private void analyze(@Nonnull DexBackedMethodImplementation implementation) {
cyclomaticComplexity = calculateComplexity(implementation);
registerCount = implementation.getRegisterCount();
tryCatchCount = implementation.getTryBlocks().size();
debugItemCount = Utils.makeCollection(implementation.getDebugItems()).size();
for (Instruction instruction : implementation.getInstructions()) {
instructionCount++;
Opcode op = instruction.getOpcode();
opCounts.adjustOrPutValue(op, 1, 1);
if (instruction instanceof ReferenceInstruction) {
ReferenceInstruction refInstr = (ReferenceInstruction) instruction;
switch (op.referenceType) {
case ReferenceType.METHOD:
MethodReference methodRef = (MethodReference) refInstr.getReference();
if (fullMethodSignatures) {
apiCounts.adjustOrPutValue(methodRef, 1, 1);
} else {
ShortMethodReference shortMethodRef = new ShortMethodReference(methodRef);
apiCounts.adjustOrPutValue(shortMethodRef, 1, 1);
}
break;
case ReferenceType.FIELD:
FieldReference fieldRef = (FieldReference) refInstr.getReference();
fieldReferenceCounts.adjustOrPutValue(fieldRef, 1, 1);
break;
case ReferenceType.STRING:
StringReference stringRef = (StringReference) refInstr.getReference();
stringReferenceCounts.adjustOrPutValue(stringRef, 1, 1);
break;
}
}
}
}
示例9: getShortFieldDescriptor
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public static String getShortFieldDescriptor(FieldReference fieldReference) {
StringBuilder sb = new StringBuilder();
sb.append(fieldReference.getName());
sb.append(':');
String clazz = TypeGenUtil.newType(fieldReference.getType());
sb.append(clazz);
return sb.toString();
}
示例10: isStaticFiled
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
private static boolean isStaticFiled(DexBackedClassDef classDef, FieldReference reference) {
for (DexBackedField field : classDef.getStaticFields()) {
if (field.equals(reference)) {
return true;
}
}
return false;
}
示例11: of
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
@Nonnull
public static ImmutableFieldReference of(@Nonnull FieldReference fieldReference) {
if (fieldReference instanceof ImmutableFieldReference) {
return (ImmutableFieldReference)fieldReference;
}
return new ImmutableFieldReference(
fieldReference.getDefiningClass(),
fieldReference.getName(),
fieldReference.getType());
}
示例12: equals
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof FieldReference) {
FieldReference other = (FieldReference)o;
return getDefiningClass().equals(other.getDefiningClass()) &&
getName().equals(other.getName()) &&
getType().equals(other.getType());
}
return false;
}
示例13: compareTo
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
@Override
public int compareTo(@Nonnull FieldReference o) {
int res = getDefiningClass().compareTo(o.getDefiningClass());
if (res != 0) return res;
res = getName().compareTo(o.getName());
if (res != 0) return res;
return getType().compareTo(o.getType());
}
示例14: makeInstructionWriter
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
@Nonnull static <StringRef extends StringReference, TypeRef extends TypeReference, FieldRefKey extends FieldReference, MethodRefKey extends MethodReference>
InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>
makeInstructionWriter(
@Nonnull DexDataWriter writer,
@Nonnull StringSection<?, StringRef> stringSection,
@Nonnull TypeSection<?, ?, TypeRef> typeSection,
@Nonnull FieldSection<?, ?, FieldRefKey, ?> fieldSection,
@Nonnull MethodSection<?, ?, ?, MethodRefKey, ?> methodSection) {
return new InstructionWriter<StringRef, TypeRef, FieldRefKey, MethodRefKey>(
writer, stringSection, typeSection, fieldSection, methodSection);
}
示例15: intern
import org.jf.dexlib2.iface.reference.FieldReference; //导入依赖的package包/类
public void intern(@Nonnull FieldReference field) {
Integer prev = internedItems.put(field, 0);
if (prev == null) {
typePool.intern(field.getDefiningClass());
stringPool.intern(field.getName());
typePool.intern(field.getType());
}
}