当前位置: 首页>>代码示例>>Java>>正文


Java SwitchElement类代码示例

本文整理汇总了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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:BuilderMutableMethodImplementation.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:BuilderMutableMethodImplementation.java

示例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);
    }
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:19,代码来源:InstructionWriter.java

示例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; }
    };
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:25,代码来源:DexBackedPackedSwitchPayload.java

示例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; }
    };
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:24,代码来源:DexBackedSparseSwitchPayload.java

示例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);
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:25,代码来源:MutableMethodImplementation.java

示例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);
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:26,代码来源:MutableMethodImplementation.java

示例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;
 }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:26,代码来源:PackedSwitchInstruction.java

示例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;
 }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:26,代码来源:SparseSwitchInstruction.java

示例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);
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:19,代码来源:InstructionWriter.java

示例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; }
    };
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:24,代码来源:DexBackedPackedSwitchPayload.java

示例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; }
    };
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:23,代码来源:DexBackedSparseSwitchPayload.java

示例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);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:24,代码来源:MutableMethodImplementation.java

示例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);
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:25,代码来源:MutableMethodImplementation.java

示例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);
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:19,代码来源:InstructionWriter.java


注:本文中的org.jf.dexlib2.iface.instruction.SwitchElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。