Package javassist.bytecode.analysis

Examples of javassist.bytecode.analysis.ControlFlow$Block


    }

    private ArrayList<Block> getBlocksAroundBlockByState(int column, int row, BlockState blockState){
        ArrayList<Block> blocksWithBlockState = new ArrayList<Block>();
        for(Direction direction : Direction.values()){
            Block block = getBlockFromDirection(column, row, direction);
            if(block!=null && block.getBlockState()!=null && block.getBlockState()== blockState)
                blocksWithBlockState.add(block);
        }
        return blocksWithBlockState;
    }
View Full Code Here


    private void generateBlocks(int columns, int rows) {
        blocks = new Block[columns][rows];
        for(int c=0; c<columns; c++)
            for(int r=0; r<rows; r++)
                blocks[c][r] = new Block(c*blockSize, r*blockSize, blockSize, blockSize);
    }
View Full Code Here

                else
                    g.drawImage(emptyFieldImage, 0, 0,null);

                for(int c=0; c<mineSweeper.getBlocks().length; c++)
                    for(int r=0; r<mineSweeper.getBlocks()[0].length; r++) {
                        Block block = mineSweeper.getBlocks()[c][r];

                        if(block.getBlockNumber()!=null){
                            g.setColor(block.getBlockNumber().getColor());
                            g.drawString(""+block.getBlockNumber().getNumber(), block.x+4, block.y+12);
                        }
                        if(block.getBlockState()!=null)
                            switch(block.getBlockState()){
                                case FLAG:      g.drawImage(flagBlock, block.x, block.y, null);
                                    break;
                                case BOMB:      g.drawImage(bombBlock, block.x, block.y, null);
                                    break;
                                case EMPTY:     if(block.getBlockNumber()==null)
                                    g.drawImage(emptyBlock, block.x, block.y, null);
                            }
                    }

            }
View Full Code Here

public class DomTreeTest extends TestCase {
    private ClassPool pool = ClassPool.getDefault();

    public void testDomtree() throws Exception {
        ControlFlow cf = new ControlFlow(pool.get(DomTreeTest.class.getName()).getDeclaredMethod("test1"));
        Block[] blocks = cf.basicBlocks();
        // for (int i = 0; i < blocks.length; i++)
        //    System.out.println(i + ": " + blocks[i]);
        testBlock(blocks[0], new int[] {}, new int[] { 11, 6 } );
        testBlock(blocks[1], new int[] { 0 }, new int[] { 17, 11 } );
        testBlock(blocks[2], new int[] { 0, 6 }, new int[] { 19, 17 });
        testBlock(blocks[3], new int[] { 6, 11 }, new int[] { 19 });
        testBlock(blocks[4], new int[] { 11, 17 }, new int[] {});

        Node[] dom = cf.dominatorTree();
        assertNull(dom[0].parent());
        assertEquals(0, dom[1].parent().block().position());
        assertEquals(0, dom[2].parent().block().position());
        assertEquals(0, dom[3].parent().block().position());
        assertEquals(0, dom[4].parent().block().position());

        Node[] pdom = cf.postDominatorTree();
        assertEquals(19, pdom[0].parent().block().position());
        assertEquals(19, pdom[1].parent().block().position());
        assertEquals(19, pdom[2].parent().block().position());
        assertEquals(19, pdom[3].parent().block().position());
        assertNull(pdom[4].parent());
View Full Code Here

            k = 3 ;
        }
    }

    public void testDomtree2() throws Exception {
        ControlFlow cf = new ControlFlow(pool.get(DomTreeTest.class.getName()).getDeclaredMethod("test2"));
        Block[] blocks = cf.basicBlocks();
        // for (int i = 0; i < blocks.length; i++)
        //    System.out.println(i + ": " + blocks[i]);
        testBlock(blocks[0], new int[] { 7 }, new int[] { 14, 7 } );
        testBlock(blocks[1], new int[] { 0 }, new int[] { 0, 12 } );
        testBlock(blocks[2], new int[] { 7 }, new int[] {});
        testBlock(blocks[3], new int[] { 0 }, new int[] {});

        Node[] dom = cf.dominatorTree();
        assertNull(dom[0].parent());
        assertEquals(0, dom[1].parent().block().position());
        assertEquals(7, dom[2].parent().block().position());
        assertEquals(0, dom[3].parent().block().position());

        Node[] pdom = cf.postDominatorTree();
        assertNull(pdom[0].parent());
        assertNull(pdom[1].parent());
        assertNull(pdom[2].parent());
        assertNull(pdom[3].parent());
    }
View Full Code Here

        return i + 3;
    }

    public void testDomtree3() throws Exception {
        ControlFlow cf = new ControlFlow(pool.get(DomTreeTest.class.getName()).getDeclaredMethod("test3"));
        Block[] blocks = cf.basicBlocks();
        for (int i = 0; i < blocks.length; i++)
            System.out.println(blocks[i]);
    }
View Full Code Here

import javassist.bytecode.analysis.ControlFlow.Node;

public class DomTreePrinter {
    public static void main(String[] args) throws Exception {
        ClassPool pool = ClassPool.getDefault();
        ControlFlow cf = new ControlFlow(pool.get(args[0]).getDeclaredMethod(args[1]));
        Block[] blocks = cf.basicBlocks();
        for (int i = 0; i < blocks.length; i++)
            System.out.println(i + ": " + blocks[i]);

        Node[] dom = cf.dominatorTree();
        for (int i = 0; i < dom.length; i++)
            System.out.println(i + ": " + dom[i]);

        Node[] pdom = cf.postDominatorTree();
        for (int i = 0; i < pdom.length; i++)
            System.out.println(i + ": " + pdom[i]);
    }
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

    else return AlmostBoolean.match(block.material.isSolid());
  }

  @Override
  public AlmostBoolean isBlockLiquid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isLiquid());
  }
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

TOP

Related Classes of javassist.bytecode.analysis.ControlFlow$Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.