use of com.google.security.zynamics.binnavi.disassembly.IBlockEdge in project binnavi by google.
the class BlockEdgeTest method testConstructor.
@Test
public void testConstructor() {
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
instructions.add(new MockInstruction(0x123));
final INaviBasicBlock bblock = new CBasicBlock(1, "Hannes", instructions);
final IBlockNode node = new CBlockNode(bblock);
final Function pFunction = new Function(ModuleFactory.get(), parentFunction);
final BasicBlock block1 = new BasicBlock(node, pFunction);
final BasicBlock block2 = new BasicBlock(node, pFunction);
final IBlockEdge mockEdge = new CFunctionEdge(node, node, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_UNCONDITIONAL);
final BlockEdge edge = new BlockEdge(mockEdge, block1, block2);
assertEquals(block1, edge.getSource());
assertEquals(block2, edge.getTarget());
assertEquals(block1, block2.getParents().get(0));
assertEquals(block2, block1.getChildren().get(0));
assertEquals(EdgeType.JumpUnconditional, edge.getType());
assertEquals("Block Edge [123 -> 123]", edge.toString());
}
use of com.google.security.zynamics.binnavi.disassembly.IBlockEdge in project binnavi by google.
the class Function method convertData.
/**
* Converts internal function data to API function data.
*/
private void convertData() {
final DirectedGraph<IBlockNode, IBlockEdge> graph = m_function.getGraph();
final List<BasicBlock> blocks = new ArrayList<BasicBlock>();
final List<BlockEdge> edges = new ArrayList<BlockEdge>();
final HashMap<IBlockNode, BasicBlock> blockMap = new HashMap<IBlockNode, BasicBlock>();
for (final IBlockNode block : graph.getNodes()) {
final BasicBlock newBlock = new BasicBlock(block, this);
blockMap.put(block, newBlock);
blocks.add(newBlock);
}
for (final IBlockEdge edge : graph.getEdges()) {
final BasicBlock source = blockMap.get(edge.getSource());
final BasicBlock target = blockMap.get(edge.getTarget());
edges.add(new BlockEdge(edge, source, target));
}
m_graph = new FlowGraph(blocks, edges);
}
Aggregations