public DexType(String type) { if (type == null) { throw new RuntimeException("error: type is null!"); } this.type = new ImmutableTypeReference(type); this.name = type; }
@Override public void caseStringConstant(StringConstant s) { StringReference ref = new ImmutableStringReference(s.value); stmtV.addInsn(new Insn21c(Opcode.CONST_STRING, destinationReg, ref), origStmt); }
private MethodReference buildMethodReference(java.lang.reflect.Method method) { String className = ClassNameUtils.toInternal(method.getDeclaringClass()); String name = method.getName(); List<String> parameterTypes = ClassNameUtils.toInternal(method.getParameterTypes()); String returnType = ClassNameUtils.toInternal(method.getReturnType()); ImmutableMethodReference immutableMethodRef = new ImmutableMethodReference(className, name, parameterTypes, returnType); MethodReference methodRef = manipulator.getDexBuilder().internMethodReference(immutableMethodRef); return methodRef; }
private void addRegisterAssignmentDebugInfo(LocalRegisterAssignmentInformation registerAssignment, Map<Local, Integer> seenRegisters, MethodImplementationBuilder builder) { Local local = registerAssignment.getLocal(); String dexLocalType = SootToDexUtils.getDexTypeDescriptor(local.getType()); StringReference localName = new ImmutableStringReference(local.getName()); Register reg = registerAssignment.getRegister(); int register = reg.getNumber(); Integer beforeRegister = seenRegisters.get(local); if (beforeRegister != null) { if (beforeRegister == register) { // No change return; } builder.addEndLocal(beforeRegister); } builder.addStartLocal(register, localName, new ImmutableTypeReference(dexLocalType), new ImmutableStringReference("")); seenRegisters.put(local, register); }
protected static FieldReference toFieldReference(SootField f) { FieldReference fieldRef = new ImmutableFieldReference(SootToDexUtils.getDexClassName(f.getDeclaringClass().getName()), f.getName(), SootToDexUtils.getDexTypeDescriptor(f.getType())); return fieldRef; }
type = (reference_type_descriptor86!=null?((smaliTreeWalker.reference_type_descriptor_return)reference_type_descriptor86).type:null); methodReference = new ImmutableMethodReference(type, (SIMPLE_NAME87!=null?SIMPLE_NAME87.getText():null), method_prototype88.getParameterTypes(), method_prototype88.getReturnType());
new ImmutableMethodHandleReference(MethodHandleType.INVOKE_STATIC, method_reference79); callSiteReference = new ImmutableCallSiteReference( callSiteName, methodHandleReference, method_name, method_prototype80, call_site_extra_arguments81);
proto = new ImmutableMethodProtoReference(parameters, returnType);
reference = method_reference83; methodHandle = new ImmutableMethodHandleReference((method_handle_type84!=null?((smaliTreeWalker.method_handle_type_return)method_handle_type84).methodHandleType:0), reference);
for (CharSequence type: method_prototype77.getParameterTypes()) { retval.parameters.add(new SmaliMethodParameter(paramRegister++, type.toString())); char c = type.charAt(0); retval.returnType = method_prototype77.getReturnType();
public static TypeReference toTypeReference(Type t) { ImmutableTypeReference tRef = new ImmutableTypeReference(SootToDexUtils.getDexTypeDescriptor(t)); return tRef; }
protected static FieldReference toFieldReference(SootFieldRef ref) { FieldReference fieldRef = new ImmutableFieldReference(SootToDexUtils.getDexClassName(ref.declaringClass().getName()), ref.name(), SootToDexUtils.getDexTypeDescriptor(ref.type())); return fieldRef; }
protected static MethodReference toMethodReference(SootMethodRef m) { List<String> parameters = new ArrayList<String>(); for (Type t : m.parameterTypes()) { parameters.add(SootToDexUtils.getDexTypeDescriptor(t)); } MethodReference methodRef = new ImmutableMethodReference(SootToDexUtils.getDexClassName(m.declaringClass().getName()), m.name(), parameters, SootToDexUtils.getDexTypeDescriptor(m.returnType())); return methodRef; }
/** * Writes out the information stored in the tags associated with the given statement * * @param builder * The builder used to generate the Dalvik method implementation * @param stmt * The statement for which to write out the tags */ protected void writeTagsForStatement(MethodImplementationBuilder builder, Stmt stmt) { List<Tag> tags = stmt.getTags(); for (Tag t : tags) { if (t instanceof LineNumberTag) { LineNumberTag lnt = (LineNumberTag) t; builder.addLineNumber(lnt.getLineNumber()); } else if (t instanceof SourceFileTag) { SourceFileTag sft = (SourceFileTag) t; builder.addSetSourceFile(new ImmutableStringReference(sft.getSourceFile())); } } }
@Override public void caseClassConstant(ClassConstant c) { TypeReference referencedClass = new ImmutableTypeReference(c.getValue()); stmtV.addInsn(new Insn21c(Opcode.CONST_CLASS, destinationReg, referencedClass), origStmt); }
@Before public void setUp() { vm = mock(VirtualMachine.class); ectx = mock(ExecutionContext.class); mState = mock(MethodState.class); when(ectx.getMethodState()).thenReturn(mState); node = mock(ExecutionNode.class); itemB = mock(HeapItem.class); when(mState.readRegister(REGISTER_B)).thenReturn(itemB); setItem = ArgumentCaptor.forClass(HeapItem.class); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction22c.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction22c) instruction).getRegisterA()).thenReturn(REGISTER_A); when(((Instruction22c) instruction).getRegisterB()).thenReturn(REGISTER_B); FieldReference fieldRef = new ImmutableFieldReference("Lsome/class;", "someMethod", "I"); when(((Instruction22c) instruction).getReference()).thenReturn(fieldRef); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new IGetOpFactory(); }
@Before public void setUp() { vm = mock(VirtualMachine.class); node = mock(ExecutionNode.class); mState = mock(MethodState.class); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction3rc.class, VariableRegisterInstruction.class, ReferenceInstruction.class, RegisterRangeInstruction.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); Reference ref = new ImmutableTypeReference("[I"); when(((ReferenceInstruction) instruction).getReference()).thenReturn(ref); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new FilledNewArrayOpFactory(); }
@Before public void setUp() { vm = mock(VirtualMachine.class); ectx = mock(ExecutionContext.class); mState = mock(MethodState.class); when(ectx.getMethodState()).thenReturn(mState); node = mock(ExecutionNode.class); itemA = mock(HeapItem.class); when(mState.readRegister(REGISTER_A)).thenReturn(itemA); itemB = mock(HeapItem.class); when(mState.readRegister(REGISTER_B)).thenReturn(itemB); setItem = ArgumentCaptor.forClass(HeapItem.class); location = mock(MethodLocation.class); when(location.getCodeAddress()).thenReturn(ADDRESS); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction22c.class)); when(location.getInstruction()).thenReturn(instruction); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction22c) instruction).getRegisterA()).thenReturn(REGISTER_A); when(((Instruction22c) instruction).getRegisterB()).thenReturn(REGISTER_B); FieldReference fieldRef = new ImmutableFieldReference("Lsome/class;", "someMethod", "I"); when(((Instruction22c) instruction).getReference()).thenReturn(fieldRef); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new IPutOpFactory(); }
reference = new ImmutableTypeReference((CLASS_DESCRIPTOR110!=null?CLASS_DESCRIPTOR110.getText():null));
type = (reference_type_descriptor89!=null?((smaliTreeWalker.reference_type_descriptor_return)reference_type_descriptor89).type:null); retval.fieldReference = new ImmutableFieldReference(type, (SIMPLE_NAME90!=null?SIMPLE_NAME90.getText():null), (nonvoid_type_descriptor91!=null?((smaliTreeWalker.nonvoid_type_descriptor_return)nonvoid_type_descriptor91).type:null));