@Test public void testImpl_getCellBounds() throws Exception { MethodNode mn = TypeInterpreterTestMethods.impl_getCellBounds(); AbstractInsnNode[] instructions = mn.instructions.toArray(); Analyzer<TypeValue> analyzer = new PhosphorOpcodeIgnoringAnalyzer<>(new TypeInterpreter("javafx/scene/layout/GridPane", mn)); Frame<TypeValue>[] frames = analyzer.analyze("javafx/scene/layout/GridPane", mn); for(int i = 0; i < frames.length; i++) { AbstractInsnNode insn = instructions[i]; Frame<TypeValue> actualFrame = frames[i]; if(insn instanceof FrameNode) { Frame<TypeValue> expectedFrame = TypeInterpreter.convertFrameNode((FrameNode) insn); for(int l = 0; l < expectedFrame.getLocals(); l++) { assertEquals(expectedFrame.getLocal(l), actualFrame.getLocal(l)); } for(int l = expectedFrame.getLocals(); l < actualFrame.getLocals(); l++) { assertEquals(TypeValue.UNINITIALIZED_VALUE, actualFrame.getLocal(l)); } assertEquals(expectedFrame.getStackSize(), actualFrame.getStackSize()); for(int s = 0; s < expectedFrame.getStackSize(); s++) { assertEquals(expectedFrame.getStack(s), actualFrame.getStack(s)); } } } }
public static Frame<TypeValue> convertFrameNode(FrameNode node) { List<TypeValue> local = convertFrameObjects(node.local); List<TypeValue> stack = convertFrameObjects(node.stack); Frame<TypeValue> frame = new Frame<>(local.size(), stack.size()); for(int i = 0; i < local.size(); i++) { frame.setLocal(i, local.get(i)); } for(TypeValue v : stack) { frame.push(v); } return frame; }
TypeInterpreter extends MergeAwareInterpreter<TypeValue> { public static Frame<TypeValue> convertFrameNode(FrameNode node) { List<TypeValue> local = convertFrameObjects(node.local); List<TypeValue> stack = convertFrameObjects(node.stack); Frame<TypeValue> frame = new Frame<>(local.size(), stack.size()); for(int i = 0; i < local.size(); i++) { frame.setLocal(i, local.get(i)); } for(TypeValue v : stack) { frame.push(v); } return frame; } }
TypeInterpreter extends MergeAwareInterpreter<TypeValue> { public static Frame<TypeValue> convertFrameNode(FrameNode node) { List<TypeValue> local = convertFrameObjects(node.local); List<TypeValue> stack = convertFrameObjects(node.stack); Frame<TypeValue> frame = new Frame<>(local.size(), stack.size()); for(int i = 0; i < local.size(); i++) { frame.setLocal(i, local.get(i)); } for(TypeValue v : stack) { frame.push(v); } return frame; } TypeInterpreter(String owner, MethodNode methodNode); }
TypeInterpreter extends MergeAwareInterpreter<TypeValue> { public static Frame<TypeValue> convertFrameNode(FrameNode node) { List<TypeValue> local = convertFrameObjects(node.local); List<TypeValue> stack = convertFrameObjects(node.stack); Frame<TypeValue> frame = new Frame<>(local.size(), stack.size()); for(int i = 0; i < local.size(); i++) { frame.setLocal(i, local.get(i)); } for(TypeValue v : stack) { frame.push(v); } return frame; } TypeInterpreter(String owner, MethodNode methodNode); @Override TypeValue newValue(Type type); @Override TypeValue newOperation(AbstractInsnNode insn); @Override TypeValue copyOperation(AbstractInsnNode insn, TypeValue value); @Override TypeValue unaryOperation(AbstractInsnNode insn, TypeValue value); @Override TypeValue binaryOperation(AbstractInsnNode insn, TypeValue value1, TypeValue value2); @Override TypeValue ternaryOperation(AbstractInsnNode insn, TypeValue value1, TypeValue value2, TypeValue value3); @Override TypeValue naryOperation(AbstractInsnNode insn, java.util.List<? extends TypeValue> values); @Override void returnOperation(AbstractInsnNode insn, TypeValue value, TypeValue expected); @Override TypeValue merge(TypeValue value1, TypeValue value2); @Override void mergingFrame(int instructionIndexOfNextMerge); @Override void mergingLocalVariable(int localIndexOfNextMerge, int numLocals, int stackSize); @Override void mergingStackElement(int stackIndexOfNextMerge, int numLocals, int stackSize); static Frame<TypeValue> convertFrameNode(FrameNode node); }
TypeInterpreter extends MergeAwareInterpreter<TypeValue> { public static Frame<TypeValue> convertFrameNode(FrameNode node) { List<TypeValue> local = convertFrameObjects(node.local); List<TypeValue> stack = convertFrameObjects(node.stack); Frame<TypeValue> frame = new Frame<>(local.size(), stack.size()); for(int i = 0; i < local.size(); i++) { frame.setLocal(i, local.get(i)); } for(TypeValue v : stack) { frame.push(v); } return frame; } TypeInterpreter(String owner, MethodNode methodNode); @Override TypeValue newValue(Type type); @Override TypeValue newOperation(AbstractInsnNode insn); @Override TypeValue copyOperation(AbstractInsnNode insn, TypeValue value); @Override TypeValue unaryOperation(AbstractInsnNode insn, TypeValue value); @Override TypeValue binaryOperation(AbstractInsnNode insn, TypeValue value1, TypeValue value2); @Override TypeValue ternaryOperation(AbstractInsnNode insn, TypeValue value1, TypeValue value2, TypeValue value3); @Override TypeValue naryOperation(AbstractInsnNode insn, java.util.List<? extends TypeValue> values); @Override void returnOperation(AbstractInsnNode insn, TypeValue value, TypeValue expected); @Override TypeValue merge(TypeValue value1, TypeValue value2); @Override void mergingFrame(int instructionIndexOfNextMerge); @Override void mergingLocalVariable(int localIndexOfNextMerge, int numLocals, int stackSize); @Override void mergingStackElement(int stackIndexOfNextMerge, int numLocals, int stackSize); static Frame<TypeValue> convertFrameNode(FrameNode node);  }