private static ExecutionNode spawnChild(ExecutionGraph graph, ExecutionNode parentNode, int childAddress) { Op childOp = graph.getTemplateNode(childAddress).getOp(); ExecutionNode childNode = parentNode.spawnChild(childOp); graph.addNode(childNode); return childNode; }
@Override public void execute(ExecutionNode node, ExecutionContext context) { MethodState mState = context.getMethodState(); HeapItem valueItem = mState.readRegister(valueRegister); HeapItem instanceItem = mState.readRegister(instanceRegister); mState.assignRegister(instanceRegister, instanceItem); }
public ExecutionNode spawnChild(Op childOp) { ExecutionNode child = new ExecutionNode(childOp); child.setContext(context.spawnChild()); child.setParent(this); return child; }
private static StringBuilder getNodeState(ExecutionNode node, ExecutionGraph graph) { MethodState state = node.getContext().getMethodState(); String op = node.toString().replaceAll(DOT, "?").replace("\"", "\\\""); String stateStr = state.toString().replaceAll(DOT, "?").replace("\"", "\\\"").trim(); int nodeIndex = graph.getNodeIndex(node); StringBuilder sb = new StringBuilder(); sb.append("\"@").append(node.getAddress()).append('.').append(nodeIndex).append(" :: "); sb.append(op).append('\n').append(stateStr).append('"'); return sb; } }
public void setParent(ExecutionContext parent) { setShallowParent(parent); MethodState childMethodState = parent.getMethodState().getChild(this); setMethodState(childMethodState); }
@Override public void execute(ExecutionNode node, ExecutionContext context) { // TODO: https://github.com/CalebFenton/simplify/issues/22 MethodState mState = context.getMethodState(); HeapItem instanceItem = mState.readRegister(instanceRegister); String type = fieldDescriptor.split(":")[1]; mState.assignRegister(destRegister, HeapItem.newUnknown(type)); }
public void setShallowParent(ExecutionContext parent) { assert parent.getMethodState() != null; this.parent = parent; callDepth = parent.getCallDepth(); getHeap().setParent(parent.getHeap()); }
public Object getRegisterConsensusValue(int address, int register) { HeapItem item = getRegisterConsensus(address, register); return item.getValue(); }
public @Nullable Op getOp(int address) { return getTemplateNode(address).getOp(); }
public void assignRegister(int register, Object value, String type) { assignRegister(register, new HeapItem(value, type)); }
public void assignReturnRegister(Object value, String type) { pokeRegister(ReturnRegister, new HeapItem(value, type), METHOD_HEAP); }
public void pokeField(VirtualField field, Object value) { int register = 0; String heapId = getHeapId(field); String type = field.getType(); pokeRegister(register, new HeapItem(value, type), heapId); }
public void initializeClass(ClassState cState, SideEffect.Level level) { setClassState(cState); setClassInitialized(cState.getVirtualClass(), level); }
/** * {@see #getRegisterConsensus(int[], int)} * * @return consensus value over all {@code addresses} in {@code register} or {@link * UnknownValue} if a consensus doesn't exist */ public HeapItem getRegisterConsensus(int address, int register) { return getRegisterConsensus(new int[]{ address }, register); }
boolean hasRegister(int register, String heapId) { return context.getHeap().hasRegister(heapId, register); }
public SideEffect.Level getClassSideEffectLevel(VirtualType virtualClass) { ExecutionContext ancestor = getAncestorWithClass(virtualClass); if (ancestor == null) { return null; } return ancestor.classToStatus.get(virtualClass).getSideEffectLevel(); }
public void registerCaller(ExecutionContext callerContext, int callerAddress) { this.callDepth = callerContext.getCallDepth() + 1; this.callerContext = callerContext; this.callerAddress = callerAddress; }
public void assignResultRegister(Object value, String type) { assignRegister(ResultRegister, new HeapItem(value, type)); }
public void pokeRegister(int register, Object value, String type) { pokeRegister(register, new HeapItem(value, type)); }