本文整理汇总了Java中org.jf.dexlib2.iface.instruction.SwitchElement类的典型用法代码示例。如果您正苦于以下问题:Java SwitchElement类的具体用法?Java SwitchElement怎么用?Java SwitchElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SwitchElement类属于org.jf.dexlib2.iface.instruction包,在下文中一共展示了SwitchElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newBuilderPackedSwitchPayload
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Nonnull
private BuilderPackedSwitchPayload newBuilderPackedSwitchPayload(@Nonnull MethodLocation location,
@Nonnull int[] codeAddressToIndex,
@Nonnull PackedSwitchPayload instruction) {
List<? extends SwitchElement> switchElements = instruction.getSwitchElements();
if (switchElements.size() == 0) {
return new BuilderPackedSwitchPayload(0, null);
}
MethodLocation switchLocation = findSwitchForPayload(location);
int baseAddress;
if (switchLocation == null) {
baseAddress = 0;
} else {
baseAddress = switchLocation.codeAddress;
}
List<Label> labels = Lists.newArrayList();
for (SwitchElement element : switchElements) {
labels.add(newLabel(codeAddressToIndex, element.getOffset() + baseAddress));
}
return new BuilderPackedSwitchPayload(switchElements.get(0).getKey(), labels);
}
示例2: newBuilderSparseSwitchPayload
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Nonnull
private BuilderSparseSwitchPayload newBuilderSparseSwitchPayload(@Nonnull MethodLocation location,
@Nonnull int[] codeAddressToIndex,
@Nonnull SparseSwitchPayload instruction) {
List<? extends SwitchElement> switchElements = instruction.getSwitchElements();
if (switchElements.size() == 0) {
return new BuilderSparseSwitchPayload(null);
}
MethodLocation switchLocation = findSwitchForPayload(location);
int baseAddress;
if (switchLocation == null) {
baseAddress = 0;
} else {
baseAddress = switchLocation.codeAddress;
}
List<SwitchLabelElement> labelElements = Lists.newArrayList();
for (SwitchElement element : switchElements) {
labelElements.add(new SwitchLabelElement(element.getKey(),
newLabel(codeAddressToIndex, element.getOffset() + baseAddress)));
}
return new BuilderSparseSwitchPayload(labelElements);
}
示例3: write
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
public void write(@Nonnull PackedSwitchPayload instruction) {
try {
writer.writeUbyte(0);
writer.writeUbyte(instruction.getOpcode().value >> 8);
List<? extends SwitchElement> elements = instruction.getSwitchElements();
writer.writeUshort(elements.size());
if (elements.size() == 0) {
writer.writeInt(0);
} else {
writer.writeInt(elements.get(0).getKey());
for (SwitchElement element: elements) {
writer.writeInt(element.getOffset());
}
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
示例4: getSwitchElements
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
return new FixedSizeList<SwitchElement>() {
@Nonnull
@Override
public SwitchElement readItem(final int index) {
return new SwitchElement() {
@Override
public int getKey() {
return firstKey + index;
}
@Override
public int getOffset() {
return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
}
};
}
@Override public int size() { return elementCount; }
};
}
示例5: getSwitchElements
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
return new FixedSizeList<SwitchElement>() {
@Nonnull
@Override
public SwitchElement readItem(final int index) {
return new SwitchElement() {
@Override
public int getKey() {
return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
}
@Override
public int getOffset() {
return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
}
};
}
@Override public int size() { return elementCount; }
};
}
示例6: newBuilderPackedSwitchPayload
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Nonnull
private BuilderPackedSwitchPayload newBuilderPackedSwitchPayload(@Nonnull MethodLocation location,
@Nonnull int[] codeAddressToIndex,
@Nonnull PackedSwitchPayload instruction) {
List<? extends SwitchElement> switchElements = instruction.getSwitchElements();
if (switchElements.size() == 0) {
return new BuilderPackedSwitchPayload(0, null);
}
MethodLocation switchLocation = findSwitchForPayload(location);
int baseAddress;
if (switchLocation == null) {
baseAddress = 0;
} else {
baseAddress = switchLocation.codeAddress;
}
List<Label> labels = Lists.newArrayList();
for (SwitchElement element: switchElements) {
labels.add(newLabel(codeAddressToIndex, element.getOffset() + baseAddress));
}
return new BuilderPackedSwitchPayload(switchElements.get(0).getKey(), labels);
}
示例7: newBuilderSparseSwitchPayload
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Nonnull
private BuilderSparseSwitchPayload newBuilderSparseSwitchPayload(@Nonnull MethodLocation location,
@Nonnull int[] codeAddressToIndex,
@Nonnull SparseSwitchPayload instruction) {
List<? extends SwitchElement> switchElements = instruction.getSwitchElements();
if (switchElements.size() == 0) {
return new BuilderSparseSwitchPayload(null);
}
MethodLocation switchLocation = findSwitchForPayload(location);
int baseAddress;
if (switchLocation == null) {
baseAddress = 0;
} else {
baseAddress = switchLocation.codeAddress;
}
List<SwitchLabelElement> labelElements = Lists.newArrayList();
for (SwitchElement element: switchElements) {
labelElements.add(new SwitchLabelElement(element.getKey(),
newLabel(codeAddressToIndex, element.getOffset() + baseAddress)));
}
return new BuilderSparseSwitchPayload(labelElements);
}
示例8: switchStatement
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
protected Stmt switchStatement(DexBody body, Instruction targetData, Local key) {
PackedSwitchPayload i = (PackedSwitchPayload) targetData;
List<? extends SwitchElement> seList = i.getSwitchElements();
// the default target always follows the switch statement
int defaultTargetAddress = codeAddress + instruction.getCodeUnits();
Unit defaultTarget = body.instructionAtAddress(defaultTargetAddress).getUnit();
List<IntConstant> lookupValues = new ArrayList<IntConstant>();
List<Unit> targets = new ArrayList<Unit>();
for(SwitchElement se: seList) {
lookupValues.add(IntConstant.v(se.getKey()));
int offset = se.getOffset();
targets.add(body.instructionAtAddress(codeAddress + offset).getUnit());
}
switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);
setUnit(switchStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ switchStmt);
DalvikTyper.v().setType(switchStmt.getKeyBox(), IntType.v(), true);
}
return switchStmt;
}
示例9: switchStatement
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
protected Stmt switchStatement(DexBody body, Instruction targetData, Local key) {
SparseSwitchPayload i = (SparseSwitchPayload) targetData;
List<? extends SwitchElement> seList = i.getSwitchElements();
// the default target always follows the switch statement
int defaultTargetAddress = codeAddress + instruction.getCodeUnits();
Unit defaultTarget = body.instructionAtAddress(defaultTargetAddress).getUnit();
List<IntConstant> lookupValues = new ArrayList<IntConstant>();
List<Unit> targets = new ArrayList<Unit>();
for(SwitchElement se: seList) {
lookupValues.add(IntConstant.v(se.getKey()));
int offset = se.getOffset();
targets.add(body.instructionAtAddress(codeAddress + offset).getUnit());
}
switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);
setUnit(switchStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ switchStmt);
DalvikTyper.v().setType(switchStmt.getKeyBox(), IntType.v(), true);
}
return switchStmt;
}
示例10: write
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
public void write( PackedSwitchPayload instruction) {
try {
writer.writeUbyte(0);
writer.writeUbyte(getOpcodeValue(instruction.getOpcode()) >> 8);
List<? extends SwitchElement> elements = instruction.getSwitchElements();
writer.writeUshort(elements.size());
if (elements.size() == 0) {
writer.writeInt(0);
} else {
writer.writeInt(elements.get(0).getKey());
for (SwitchElement element: elements) {
writer.writeInt(element.getOffset());
}
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
示例11: getSwitchElements
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Override
public List<? extends SwitchElement> getSwitchElements() {
final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
return new FixedSizeList<SwitchElement>() {
@Override
public SwitchElement readItem(final int index) {
return new SwitchElement() {
@Override
public int getKey() {
return firstKey + index;
}
@Override
public int getOffset() {
return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
}
};
}
@Override public int size() { return elementCount; }
};
}
示例12: getSwitchElements
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
@Override
public List<? extends SwitchElement> getSwitchElements() {
return new FixedSizeList<SwitchElement>() {
@Override
public SwitchElement readItem(final int index) {
return new SwitchElement() {
@Override
public int getKey() {
return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
}
@Override
public int getOffset() {
return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
}
};
}
@Override public int size() { return elementCount; }
};
}
示例13: newBuilderPackedSwitchPayload
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
private BuilderPackedSwitchPayload newBuilderPackedSwitchPayload( MethodLocation location,
int[] codeAddressToIndex,
PackedSwitchPayload instruction) {
List<? extends SwitchElement> switchElements = instruction.getSwitchElements();
if (switchElements.size() == 0) {
return new BuilderPackedSwitchPayload(0, null);
}
MethodLocation switchLocation = findSwitchForPayload(location);
int baseAddress;
if (switchLocation == null) {
baseAddress = 0;
} else {
baseAddress = switchLocation.codeAddress;
}
List<Label> labels = Lists.newArrayList();
for (SwitchElement element: switchElements) {
labels.add(newLabel(codeAddressToIndex, element.getOffset() + baseAddress));
}
return new BuilderPackedSwitchPayload(switchElements.get(0).getKey(), labels);
}
示例14: newBuilderSparseSwitchPayload
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
private BuilderSparseSwitchPayload newBuilderSparseSwitchPayload( MethodLocation location,
int[] codeAddressToIndex,
SparseSwitchPayload instruction) {
List<? extends SwitchElement> switchElements = instruction.getSwitchElements();
if (switchElements.size() == 0) {
return new BuilderSparseSwitchPayload(null);
}
MethodLocation switchLocation = findSwitchForPayload(location);
int baseAddress;
if (switchLocation == null) {
baseAddress = 0;
} else {
baseAddress = switchLocation.codeAddress;
}
List<SwitchLabelElement> labelElements = Lists.newArrayList();
for (SwitchElement element: switchElements) {
labelElements.add(new SwitchLabelElement(element.getKey(),
newLabel(codeAddressToIndex, element.getOffset() + baseAddress)));
}
return new BuilderSparseSwitchPayload(labelElements);
}
示例15: write
import org.jf.dexlib2.iface.instruction.SwitchElement; //导入依赖的package包/类
public void write(@Nonnull PackedSwitchPayload instruction) {
try {
writer.writeUbyte(0);
writer.writeUbyte(getOpcodeValue(instruction.getOpcode()) >> 8);
List<? extends SwitchElement> elements = instruction.getSwitchElements();
writer.writeUshort(elements.size());
if (elements.size() == 0) {
writer.writeInt(0);
} else {
writer.writeInt(elements.get(0).getKey());
for (SwitchElement element: elements) {
writer.writeInt(element.getOffset());
}
}
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}