Package org.apache.bcel.util

Examples of org.apache.bcel.util.InstructionFinder.search()


  InstructionHandle ih;
  String pattern;

  // Remove seqences of ALOAD, POP (GTM)
  pattern = "`ALOAD'`POP'`Instruction'";
  for(Iterator iter=find.search(pattern); iter.hasNext();){
      InstructionHandle[] match = (InstructionHandle[])iter.next();
      try {
    if ((!match[0].hasTargeters()) && (!match[1].hasTargeters())) {
                    il.delete(match[0], match[1]);
                }
View Full Code Here


                // TODO: move target down into the list
            }
  }
  // Replace sequences of ILOAD_?, ALOAD_?, SWAP with ALOAD_?, ILOAD_?
  pattern = "`ILOAD'`ALOAD'`SWAP'`Instruction'";
  for(Iterator iter=find.search(pattern); iter.hasNext();){
            InstructionHandle[] match = (InstructionHandle[])iter.next();
            try {
                org.apache.bcel.generic.Instruction iload;
                org.apache.bcel.generic.Instruction aload;
                if ((!match[0].hasTargeters()) &&
View Full Code Here

            }
        }

        // Replace sequences of ALOAD_1, ALOAD_1 with ALOAD_1, DUP
  pattern = "`ALOAD_1'`ALOAD_1'`Instruction'";
        for(Iterator iter=find.search(pattern); iter.hasNext();){
            InstructionHandle[] match = (InstructionHandle[])iter.next();
            try {
          org.apache.bcel.generic.Instruction iload;
                org.apache.bcel.generic.Instruction aload;
                if ((!match[0].hasTargeters()) && (!match[1].hasTargeters())) {
View Full Code Here

     */
    private void peepHoleOptimization(MethodGenerator methodGen) {
  final String pattern = "`aload'`pop'`instruction'";
  final InstructionList il = methodGen.getInstructionList();
  final InstructionFinder find = new InstructionFinder(il);
  for(Iterator iter=find.search(pattern); iter.hasNext(); ) {
      InstructionHandle[] match = (InstructionHandle[])iter.next();
      try {
    il.delete(match[0], match[1]);
      }
      catch (TargetLostException e) {
View Full Code Here

     */
    private void peepHoleOptimization(MethodGenerator methodGen) {
  final String pattern = "`ALOAD'`POP'`Instruction'";
  final InstructionList il = methodGen.getInstructionList();
  final InstructionFinder find = new InstructionFinder(il);
  for(Iterator iter=find.search(pattern); iter.hasNext(); ) {
      InstructionHandle[] match = (InstructionHandle[])iter.next();
      try {
    il.delete(match[0], match[1]);
      }
      catch (TargetLostException e) {
View Full Code Here

                    InstructionList il = gen.getInstructionList();
                    if (il == null) {
                        continue;
                    }
                    InstructionFinder f = new InstructionFinder(il);
                    Iterator e = f.search("GETSTATIC GETFIELD ISTORE (GETSTATIC GETFIELD BIPUSH ISHR GETSTATIC IADD ISTORE)+");
                    if (e.hasNext()) {
                        InstructionHandle[] handles = (InstructionHandle[]) e.next();
                        String myplayer = ((GETSTATIC) handles[0].getInstruction()).getClassName(cpg) + "." + ((GETSTATIC) handles[0].getInstruction()).getFieldName(cpg);
                        String animable = ((GETFIELD) handles[1].getInstruction()).getClassName(cpg);
                        String plane = ((GETFIELD) handles[1].getInstruction()).getFieldName(cpg);
View Full Code Here

                            ConstantPoolGen cpg = c.getValue().getConstantPool();
                            MethodGen gen = new MethodGen(m,c.getValue().getClassName(),cpg);
                            InstructionList il = gen.getInstructionList();
                            if (il == null) continue;
                            InstructionFinder f = new InstructionFinder(il);
                            Iterator e = f.search("GETSTATIC GETSTATIC AALOAD ILOAD AALOAD ILOAD BALOAD ICONST IAND");
                            if (e.hasNext()) {
                              InstructionHandle[] handles = (InstructionHandle[]) e.next();
                                String gba = ((GETSTATIC)handles[0].getInstruction()).getClassName(cpg) + "." + ((GETSTATIC)handles[0].getInstruction()).getFieldName(cpg);
                                data.addField("GroundSettingsArray", gba);
                                e = f.search("GETSTATIC (ICONST)+ GETSTATIC IADD AALOAD");
View Full Code Here

                            Iterator e = f.search("GETSTATIC GETSTATIC AALOAD ILOAD AALOAD ILOAD BALOAD ICONST IAND");
                            if (e.hasNext()) {
                              InstructionHandle[] handles = (InstructionHandle[]) e.next();
                                String gba = ((GETSTATIC)handles[0].getInstruction()).getClassName(cpg) + "." + ((GETSTATIC)handles[0].getInstruction()).getFieldName(cpg);
                                data.addField("GroundSettingsArray", gba);
                                e = f.search("GETSTATIC (ICONST)+ GETSTATIC IADD AALOAD");
                                //System.out.println("Found method. Class: "+c.getValue().getClassName() + ", method: "+m.getName());
                                if (e.hasNext()) {
                                    handles = (InstructionHandle[]) e.next();
                                    String planearray = ((GETSTATIC)handles[0].getInstruction()).getClassName(cpg) + "." + ((GETSTATIC)handles[0].getInstruction()).getFieldName(cpg);
                                    String curplane = ((GETSTATIC)handles[2].getInstruction()).getClassName(cpg) + "." + ((GETSTATIC)handles[2].getInstruction()).getFieldName(cpg);
View Full Code Here

                    ConstantPoolGen cpg = c.getValue().getConstantPool();
                    MethodGen gen = new MethodGen(m,c.getValue().getClassName(),cpg);
                    InstructionList il = gen.getInstructionList();
                    if (il == null) continue;
                    InstructionFinder f = new InstructionFinder(il);
                    Iterator e = f.search("BASTORE GETSTATIC ILOAD ILOAD ILOAD ILOAD INVOKEVIRTUAL");
                    if (e.hasNext()) {
                        InstructionHandle[] handles = (InstructionHandle[]) e.next();
                        String curtoolkit = ((GETSTATIC)handles[1].getInstruction()).getClassName(cpg) + "." + ((GETSTATIC)handles[1].getInstruction()).getFieldName(cpg);
                        String toolkit = ((GETSTATIC)handles[1].getInstruction()).getSignature(cpg).replaceAll("L|;","");
                        data.addClass("Toolkit", toolkit);
View Full Code Here

                        if(count==7){
                          fi = iS.nextGETSTATIC();
                          sDestX = fi.getClassName(cpg)+'.'+fi.getFieldName(cpg);
                          data.addField("DestX", sDestX);
                          InstructionFinder f = new InstructionFinder(il);
                          Iterator e = f.search("IF_ICMPNE ICONST_M1 PUTSTATIC ICONST_M1 PUTSTATIC");
                              if(e.hasNext()){
                                InstructionHandle[] handles = (InstructionHandle[]) e.next();
                                String temp = ((FieldInstruction) ((PUTSTATIC) handles[2].getInstruction())).getClassName(cpg) + "." + ((PUTSTATIC) handles[2].getInstruction()).getFieldName(cpg);
                                if(!temp.equals(sDestX)){
                                  data.addField("DestY", temp);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.