Examples of InstructionSearcher


Examples of de.petris.dynamicaspects.util.InstructionSearcher

        targetClass.getMethods()[methodIdx],
        targetClass.getClassName(),
      constPoolGen );

    // a searcher to look for the joinpoints
    InstructionSearcher searcher =
      new InstructionSearcher( constPoolGen, mGen.getInstructionList() );
   
    // look for joinpoints
    List<CallMatch> targets =
      searcher.lookUpMethodCall(
          Pattern.compile( joinpointPattern ) );
   
    // a patcher for the given method
    CallWrapperMethodPatcher mp =
      new CallWrapperMethodPatcher(
View Full Code Here

Examples of de.petris.dynamicaspects.util.InstructionSearcher

          targetClass.getMethods()[methodIdx.intValue()],
          targetClass.getClassName(),
        constPoolGen );
     
      // get a searcher for the joinpoints
      InstructionSearcher searcher =
        new InstructionSearcher( constPoolGen, mGen.getInstructionList() );
           
      // look for joinpoints
      List<CallMatch> targets =
        searcher.lookUpMethodCall( joinpointPattern );
     
      // are there any joinpoints  matching the pattern in this methdod?
      if( !targets.isEmpty() ) {
       
        // yes, so we install a wrapper here
View Full Code Here

Examples of de.petris.dynamicaspects.util.InstructionSearcher

   */
  private void patchMethod() {
   
    // patch before starts here
   
    InstructionSearcher aFinder =
      new InstructionSearcher( constPoolGen, iList );
   
    InstructionHandle first = null;
   
    // respect the super() and this(...)-call at the
    // beginning of constructors
    if( mGen.getName().equals( CONSTRUCTOR_NAME ) ) {
      first = aFinder.lookUpSuperConstructorCall().getNext();
    }
    else
      first = iList.getStart();
    }
   
    // save return statement
    InstructionHandle last = iList.getEnd();

    ExecutionWrapperVariableHandler vHandler
      = new ExecutionWrapperVariableHandler(
          mGen, iList, factory, constPoolGen );
   
    // create variable for argumentList
    int argListVarIdx =
      vHandler.createArgumentList( first );
   
    // create variable for executionwrapper
    int executionWrapperIdx =
      vHandler.createExecutionWrapper( first );
   
    // BEFORE CALL
   
    // load the executionwrapper
    iList.insert( first,
      InstructionFactory.createLoad(
        EXECUTIONWRAPPERTYPE,  executionWrapperIdx ) );
   
    // load parameter for before()-call
    iList.insert(
      first,
      InstructionFactory.createLoad(
        ExecutionWrapperVariableHandler.ARGLIST_TYPE,
        argListVarIdx ) );
     
    // call before()
    iList.insert(
      first,
      factory.createInvoke(
        ExecutionWrapper.class.getName(),
        Wrapper.getBeforeName(),
        Type.VOID,
        new Type[] {
          ExecutionWrapperVariableHandler.ARGLIST_TYPE },
        INVOKEVIRTUAL ) );

   
    // look for all return-statements
    List<InstructionHandle> returnStatements =
      aFinder.lookUpReturnStatements();
    Iterator<InstructionHandle> iter = returnStatements.iterator();
   
    while( iter.hasNext() ) {
     
      InstructionHandle curReturnStatement = iter.next();
View Full Code Here

Examples of de.petris.dynamicaspects.util.InstructionSearcher

   * Unpatches the method.
   */
  private void unpatchMethod() {

    // a finder for instructions
    InstructionSearcher aFinder =
      new InstructionSearcher( constPoolGen, iList );
   
    // lookup before() call
    List<InstructionHandle> beforeList =
      aFinder.lookUpMethodCall(
        ExecutionWrapper.class.getName(),
        Wrapper.getBeforeName(),
        Wrapper.getBeforeSignature() )
   
    // save before() call
    InstructionHandle beforeCall = beforeList.get(0);
   
    // look for all return-statements
    List<InstructionHandle> returnStatements =
      aFinder.lookUpReturnStatementsSkipLast();
    Iterator<InstructionHandle> iter = returnStatements.iterator();

    InstructionHandle exceptionHandler = null;
   
    while( iter.hasNext() ) {
     
      InstructionHandle curReturnStatement = iter.next();
     
      InstructionHandle last = curReturnStatement.getPrev();
      // save the exceptionhandler for the removeExceptionHandler-call,
      // ( we want the statement before the last return )
     
      exceptionHandler = curReturnStatement.getNext();
     
      InstructionHandle first = last;
     
            // after()-call may have been complex or simple
            // depending on the return type of the target method
      if( mGen.getReturnType().equals( Type.VOID ) ) {
        first = first.getPrev();
      }
      else {
                // two instructions backward for cat2type-operation
        if( Reflection.isCat2Type(
            mGen.getReturnType() ) ) {
          first = first.getPrev().getPrev();
        }
        else {
          first = first.getPrev();
        }

        first = first.getPrev();
       
        if( !(mGen.getReturnType() instanceof BasicType) ) {
          first = first.getPrev();
        }
      }
   
      // remove the after()-calls
      try {
        iList.delete( first, last );
      }
      catch( TargetLostException tle ) {
        Logger.debug( "removing after()-calls: %s", tle.toString() );
      }
    }
   
    removeExceptionHandler( exceptionHandler );
   
    // remove catch() block
    try {
      iList.delete(
        exceptionHandler,
        iList.getEnd() );
    }
    catch( TargetLostException tle ) {
      Logger.debug( "removing catch-block: %s", tle.toString() );
    }
   
   
    // remove variable creation and before call
   
    InstructionHandle first = null;
   
    // respect the super() and this(...)-call at the
    // beginning of constructors
    if( mGen.getName().equals( CONSTRUCTOR_NAME ) ) {
      first = aFinder.lookUpSuperConstructorCall().getNext();
    }
    else
      first = iList.getStart();
    }
   
View Full Code Here

Examples of de.petris.dynamicaspects.util.InstructionSearcher

  /**
   * Installs the wrapper for all the target calls within this method.
   */
  private void patchMethod() {
   
    InstructionSearcher aFinder =
      new InstructionSearcher( constPoolGen, iList );
   
    InstructionHandle first = null;
   
    // respect the super() or this(...)-call at the
    // beginning of constructors
    if( mGen.getName().equals( CONSTRUCTOR_NAME ) ) {
      first = aFinder.lookUpSuperConstructorCall().getNext();
    }
    else
      first = iList.getStart();
    }
   
View Full Code Here

Examples of de.petris.dynamicaspects.util.InstructionSearcher

  /**
   * Removes the wrapper from all the target calls within this method.
   */
  private void unpatchMethod() {
   
    InstructionSearcher aFinder =
      new InstructionSearcher( constPoolGen, iList );
   
    CallWrapperVariableHandler vHandler =
      new CallWrapperVariableHandler(
        mGen, iList,
        factory, constPoolGen,
        joinpointPattern );
   
        // the index of the wrapper to be deinstalled
    int callWrapperIdx = vHandler.getCallWrapperVariableIndex();
   
        // get the loads of this wrapper variable
    aFinder.setCallWrapperLoads( callWrapperIdx, targets );
    Iterator<CallMatch> cmIter = targets.iterator();
   
        // loop over the target calls
    while( cmIter.hasNext() ) {
   
      // REMOVE before()-call
     
            // get the argumentList variable
      int curArgListVarIdx =
        vHandler.getNextArgumentListVariableIndex();
      InstructionHandle curArgListInit =
        aFinder.lookUpArgumentListInit( curArgListVarIdx );
     
      CallMatch curCallMatch = cmIter.next();

      InstructionHandle beforeLoad =
        curCallMatch.getBeforeLoad();
     
      try {
        iList.delete( curArgListInit,
          vHandler.getLastReloadInstruction(
            beforeLoad.getNext().getNext(),
            curCallMatch.getCallInfo() ) );
      }
      catch( TargetLostException tle ) {
        Logger.debug( "removing before()-calls: %s", tle.toString() );
      }
     
     
      // REMOVE after-call
      InstructionHandle afterLoad =
        curCallMatch.getAfterLoad();
     
      try {
        iList.delete( afterLoad,
          getLastAfterInstruction(
            afterLoad, curCallMatch.getCallInfo() ) );
      }
      catch( TargetLostException tle ) {
        Logger.debug( "removing after()-calls: %s", tle.toString() );
      }
     
     
      // REMOVE Exception-handler
      InstructionHandle afterExceptionLoad =
        curCallMatch.getAfterExceptionLoad();

      removeExceptionHandler( afterExceptionLoad );
     
      try {
        iList.delete( afterExceptionLoad.getPrev(),
          afterExceptionLoad.getNext().getNext().
            getNext().getNext().getNext() );
      }
      catch( TargetLostException tle ) {
        Logger.debug(
          "removing afterException()-calls: %s", tle.toString() );
      }
    }
   
        // remove the creation of the wrapper variable
    List<InstructionHandle> callWrapperStores =
      aFinder.lookUpCallWrapperStores( callWrapperIdx );
   
    try {
      iList.delete(
          callWrapperStores.get(0).getPrev(),
          callWrapperStores.get(1) );
View Full Code Here

Examples of smart.updater.InstructionSearcher

        ConstantPoolGen cpg = c.getValue().getConstantPool();
        for(Method m : c.getValue().getMethods()){
          if(m.getName().equals("<init>")){
            MethodGen mg = new MethodGen(m, c.getValue().getClassName(), cpg);
            InstructionList il = mg.getInstructionList();
            InstructionSearcher iS = new InstructionSearcher(il, cpg);
            while(iS.next() != null){
              Instruction i = iS.current();
              if(i instanceof LDC){
                if(((LDC) i).getValue(cpg).equals(-32768)){
                  i = iS.nextPUTFIELD();
                  character.addField("GetHeight", ((PUTFIELD) i).getFieldName(cpg));
                  return SearchResult.Success;
                }
              }
            }
View Full Code Here

Examples of smart.updater.InstructionSearcher

          if(m.getName().equals("<init>") && mS.getTypeCount(npc.className) == 1 &&
              mS.getArgCount() == 1){
            RSClass npcnode = data.addClass("NPCNode", c.getValue().getClassName());
            MethodGen mg = new MethodGen(m, cg.getClassName(), cpg);
            InstructionList il = mg.getInstructionList();
            InstructionSearcher iS = new InstructionSearcher(il, cpg);
            Instruction i = iS.nextPUTFIELD();
            npcnode.addField("GetNPC", ((PUTFIELD) i).getFieldName(cpg));
            return SearchResult.Success;
          }
        }
      }
View Full Code Here

Examples of smart.updater.InstructionSearcher

                      InstructionList il = gen.getInstructionList();
                      if (il == null) {
                          continue;
                      }
                      InstructionList iList = gen.getInstructionList();
            InstructionSearcher iS = new InstructionSearcher(iList, cpg);
           
            if(iS.nextLDC("14)") != null){
              FieldInstruction fi = iS.nextFieldInstruction();
              data.addField("LoginIndex", fi.getClassName(cpg)+'.'+fi.getFieldName(cpg));
              return SearchResult.Success;
            }
                  }
              }
View Full Code Here

Examples of smart.updater.InstructionSearcher

            for (Method m : c.getValue().getMethods()){
              MethodSearcher mS = new MethodSearcher(m, cg, cpg);
              if(mS.getTypeCount("java.awt.Canvas") >= 1 && m.getName().equals("<init>")){
                MethodGen mg = new MethodGen(m, c.getValue().getClassName(), cpg);
                InstructionList il = mg.getInstructionList();
                InstructionSearcher iS = new InstructionSearcher(il, cpg);
                Instruction i = iS.nextNEW();
                data.addClass("NodeList", ((NEW)i).getLoadClassType(cpg).getClassName());
                return(((NEW)i).getLoadClassType(cpg).getClassName());
              }
            }
          }
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.