MethodState getChild(ExecutionContext childContext) { MethodState child = new MethodState(this, childContext, mutableParameters); return child; }
private static void setupMethodState(ExecutionContext context, Map<Integer, HeapItem> registerToItem, int registerCount) { MethodState mState = new MethodState(context, registerCount); for (Entry<Integer, HeapItem> entry : registerToItem.entrySet()) { Integer register = entry.getKey(); HeapItem item = entry.getValue(); mState.pokeRegister(register, item); } context.setMethodState(mState); }
private ExecutionContext buildNonLocalCalleeContext(ExecutionContext callerContext) { ExecutionContext calleeContext = new ExecutionContext(vm, method); int parameterSize = method.getParameterSize(); int registerCount = parameterSize; MethodState calleeMethodState = new MethodState(calleeContext, registerCount, method.getParameterTypeNames().size(), parameterSize); assignCalleeMethodArguments(callerContext.getMethodState(), calleeMethodState); calleeContext.setMethodState(calleeMethodState); calleeContext.registerCaller(callerContext, getAddress()); return calleeContext; }
public static MethodState forMethod(ExecutionContext context) { VirtualMethod method = context.getMethod(); int registerCount = method.getRegisterCount(); List<String> parameterTypes = method.getParameterTypeNames(); int parameterSize = Utils.getRegisterSize(parameterTypes); MethodState mState = new MethodState(context, registerCount, parameterTypes.size(), parameterSize); int firstParameter = mState.getParameterStart(); int parameterRegister = firstParameter; for (String type : parameterTypes) { HeapItem item; if (parameterRegister == firstParameter && !method.isStatic() && method.getName().equals("<init>")) { UninitializedInstance instance = new UninitializedInstance(method.getDefiningClass()); item = new HeapItem(instance, type); } else { item = HeapItem.newUnknown(type); } mState.assignParameter(parameterRegister, item); parameterRegister += Utils.getRegisterSize(type); } return mState; }