本文整理汇总了Java中org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction类的典型用法代码示例。如果您正苦于以下问题:Java NarrowLiteralInstruction类的具体用法?Java NarrowLiteralInstruction怎么用?Java NarrowLiteralInstruction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NarrowLiteralInstruction类属于org.jf.dexlib2.iface.instruction包,在下文中一共展示了NarrowLiteralInstruction类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyzeLiteralBinaryOp
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
private void analyzeLiteralBinaryOp(@Nonnull AnalyzedInstruction analyzedInstruction,
@Nonnull RegisterType destRegisterType, boolean checkForBoolean) {
if (checkForBoolean) {
TwoRegisterInstruction instruction = (TwoRegisterInstruction) analyzedInstruction.instruction;
RegisterType sourceRegisterType =
analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterB());
if (BooleanCategories.get(sourceRegisterType.category)) {
int literal = ((NarrowLiteralInstruction) analyzedInstruction.instruction).getNarrowLiteral();
if (literal == 0 || literal == 1) {
destRegisterType = RegisterType.BOOLEAN_TYPE;
}
}
}
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, destRegisterType);
}
示例2: jimplify
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
public void jimplify (DexBody body) {
if(!(instruction instanceof Instruction22s) && !(instruction instanceof Instruction22b))
throw new IllegalArgumentException("Expected Instruction22s or Instruction22b but got: "+instruction.getClass());
NarrowLiteralInstruction binOpLitInstr = (NarrowLiteralInstruction) this.instruction;
int dest = ((TwoRegisterInstruction) instruction).getRegisterA();
int source = ((TwoRegisterInstruction) instruction).getRegisterB();
Local source1 = body.getRegisterLocal(source);
IntConstant constant = IntConstant.v((int)binOpLitInstr.getNarrowLiteral());
expr = getExpression(source1, constant);
assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
int op = (int)instruction.getOpcode().value;
if (op >= 0xd8) {
op -= 0xd8;
} else {
op -= 0xd0;
}
BinopExpr bexpr = (BinopExpr)expr;
//body.dvkTyper.setType((op == 1) ? bexpr.getOp2Box() : bexpr.getOp1Box(), op1BinType[op]);
DalvikTyper.v().setType(((JAssignStmt)assign).leftBox, op1BinType[op], false);
}
}
示例3: analyzeConst
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
private void analyzeConst(@Nonnull AnalyzedInstruction analyzedInstruction) {
NarrowLiteralInstruction instruction = (NarrowLiteralInstruction) analyzedInstruction.instruction;
//we assume that the literal value is a valid value for the given instruction type, because it's impossible
//to store an invalid literal with the instruction. so we don't need to check the type of the literal
setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction,
RegisterType.getRegisterTypeForLiteral(instruction.getNarrowLiteral()));
}
示例4: writeCommentIfLikelyFloat
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
protected void writeCommentIfLikelyFloat(IndentingWriter writer) throws IOException {
writeCommentIfLikelyFloat(writer, ((NarrowLiteralInstruction) instruction).getNarrowLiteral());
}
示例5: writeCommentIfResourceId
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
protected boolean writeCommentIfResourceId(IndentingWriter writer) throws IOException {
return writeCommentIfResourceId(writer, ((NarrowLiteralInstruction) instruction).getNarrowLiteral());
}
示例6: getConstant
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
/**
* Return the literal constant for this instruction.
*
* @param register the register number to fill
* @param body the body containing the instruction
*/
private Constant getConstant(int dest, DexBody body) {
long literal = 0;
if (instruction instanceof WideLiteralInstruction) {
literal = ((WideLiteralInstruction)instruction).getWideLiteral();
} else if (instruction instanceof NarrowLiteralInstruction) {
literal = ((NarrowLiteralInstruction)instruction).getNarrowLiteral();
} else {
throw new RuntimeException("literal error: expected narrow or wide literal.");
}
// floats are handled later in DexBody by calling DexNumtransformer
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case CONST:
case CONST_4:
case CONST_16:
if (IDalvikTyper.ENABLE_DVKTYPER) {
return UntypedIntOrFloatConstant.v((int)literal);
} else {
return IntConstant.v((int) literal);
}
case CONST_HIGH16:
if (IDalvikTyper.ENABLE_DVKTYPER) {
//
//return UntypedIntOrFloatConstant.v((int)literal<<16).toFloatConstant();
// seems that dexlib correctly puts the 16bits into the topmost bits.
//
return UntypedIntOrFloatConstant.v((int)literal);//.toFloatConstant();
} else {
return IntConstant.v((int) literal);
}
case CONST_WIDE_HIGH16:
if (IDalvikTyper.ENABLE_DVKTYPER) {
//return UntypedLongOrDoubleConstant.v((long)literal<<48).toDoubleConstant();
// seems that dexlib correctly puts the 16bits into the topmost bits.
//
return UntypedLongOrDoubleConstant.v((long)literal);//.toDoubleConstant();
} else {
return LongConstant.v(literal);
}
case CONST_WIDE:
case CONST_WIDE_16:
case CONST_WIDE_32:
if (IDalvikTyper.ENABLE_DVKTYPER) {
return UntypedLongOrDoubleConstant.v(literal);
} else {
return LongConstant.v(literal);
}
default:
throw new IllegalArgumentException("Expected a const or a const-wide instruction, got neither.");
}
}
示例7: calConstant
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction; //导入依赖的package包/类
public void calConstant(BasicBlock block){
int start = block.outSet.size();
for (BasicBlock pre: block.pre){ // IN = U OUT
block.inSet.putAll(pre.outSet);
}
block.outSet.putAll(block.inSet);
for (MethodLocation location: block.list){
Instruction instruction = location.getInstruction();
Opcode op = instruction.getOpcode();
if (op.setsRegister()){
Integer key = ((OneRegisterInstruction)instruction).getRegisterA();
block.removeOutSet(key); //IN - kill
}
if (op.name.startsWith("const")) {// IN + GEN
switch (op.format) {
case Format11n:
case Format21s:
case Format31i:
//const-int
Integer reg1 = ((OneRegisterInstruction)instruction).getRegisterA();
Integer number = ((NarrowLiteralInstruction)instruction).getNarrowLiteral();
block.addOutSet(reg1, number);
break;
case Format21c:
//const-string
Integer reg2 = ((OneRegisterInstruction)instruction).getRegisterA();
String value = ((StringReference)((ReferenceInstruction)instruction).getReference()).getString();
block.addOutSet(reg2, value);
break;
default:
break;
}
}
}
int end = block.outSet.size();
if (start != end) { //if we don not add a new <key, value>, it means we can stop now
for (BasicBlock target: block.target){
calConstant(target);
}
}
}