Package com.sun.org.apache.bcel.internal.generic

Examples of com.sun.org.apache.bcel.internal.generic.InstructionHandle


        Predicate pred = (Predicate) _predicates.elementAt(0);
        Expression exp = pred.getExpr();
        exp.translateDesynthesized(classGen, methodGen);

        // Backpatch true list and restore current iterator/node
        InstructionHandle restore = il.append(methodGen.storeIterator());
        il.append(methodGen.storeCurrentNode());
        exp.backPatchTrueList(restore);
        BranchHandle skipFalse = il.append(new GOTO(null));

        // Backpatch false list and restore current iterator/node
View Full Code Here


            il.append(classGen.loadTranslet());
        }

        // Compile the step created at type checking time
        _step.translate(classGen, methodGen);
        InstructionHandle iterStore = il.append(new ASTORE(iter.getIndex()));

        // If in the main class update the field too
        if (!classGen.isExternal()) {
            il.append(new ALOAD(iter.getIndex()));
            il.append(new PUTFIELD(iteratorIndex));
            ifBlock.setTarget(il.append(NOP));
        } else {
            // If class is not external, start of range for iter variable was
            // set above
            iter.setStart(iterStore);
        }

        // Get the parent of the node on the stack
        il.append(methodGen.loadDOM());
        il.append(new ILOAD(node.getIndex()));
        int index = cpg.addInterfaceMethodref(DOM_INTF,
                                              GET_PARENT, GET_PARENT_SIG);
        il.append(new INVOKEINTERFACE(index, 2));

        // Initialize the iterator with the parent
        il.append(new ALOAD(iter.getIndex()));
        il.append(SWAP);
        il.append(methodGen.setStartNode());

        /*
         * Inline loop:
         *
         * int node2;
         * while ((node2 = iter.next()) != NodeIterator.END
         *                && node2 < node);
         * return node2 == node;
         */
        BranchHandle skipNext;
        InstructionHandle begin, next;
        node2 = methodGen.addLocalVariable("step_pattern_tmp3",
                                           Util.getJCRefType(NODE_SIG),
                                           null, null);

        skipNext = il.append(new GOTO(null));
View Full Code Here

        mdef.name,
        className,
        ilc.instList,
        instructionFactory.getClassGen().getConstantPool()) ;
    for(Map.Entry<InstructionHandle, Integer> e: ilc.lineNumbers.entrySet()) {
      InstructionHandle h = e.getKey() ;
      Integer linenum = e.getValue() ;
      mgen.addLineNumber(h, linenum.intValue()) ;
    }
    addExceptionHandlers(mgen, ilc);
    return mgen;
View Full Code Here

   * @throws GenerationError
   */
  private void addExceptionHandlers(MethodGen mgen, InstructionListContext ilc)
      throws GenerationError {
    for(ExceptionHandler ehandler: ilc.exceptionHandlers) {
      InstructionHandle handler_pc = ilc.resolveMark(ehandler.handler) ;
      InstructionHandle start_pc = ilc.resolveMark(ehandler.startRegion) ;
      InstructionHandle end_pc = ilc.resolveMark(ehandler.endRegion) ;
      ObjectType catch_type = new ObjectType(ehandler.exceptionType.toString()) ;
      mgen.addExceptionHandler(start_pc, end_pc, handler_pc, catch_type) ;
    }
  }
View Full Code Here

   * @param mark
   * @return The instruction handle for the given maek.
   * @throws GenerationError
   */
  public InstructionHandle resolveMark(Mark mark) throws GenerationError {
    InstructionHandle handle = marks.get(mark) ;
    if (handle == null) {
      throw new MarkNotDefined(mark) ;
    }
    return handle ;
  }
View Full Code Here

   * creates a mark.
   * @param mark
   * @param lineno
   */
  public void addMark(Mark mark,int lineno) {
    InstructionHandle first = instList.append(InstructionConstants.NOP) ;
    if (mark != null) {
      marks.put(mark, first) ;
      ImmutableCollection<MarkResolver> l = markresolvers.remove(mark) ;
      if (l != null) {
        for(MarkResolver ph: l) {
View Full Code Here

   * Add postprocessor for a given mark.
   * @param mark
   * @param p
   */
  public void addPostProcessor(Mark mark,MarkResolver p) {
    InstructionHandle handle = marks.get(mark) ;
    if (handle != null) {
      p.process(this, handle) ;
      return ;
    }
    ImmutableCollection<MarkResolver> l = markresolvers.get(mark) ;
View Full Code Here

                                                        GET_PARENT_SIG);
        final int getType = cpg.addInterfaceMethodref(DOM_INTF,
                                                      "getExpandedTypeID",
                                                      "(I)I");

        InstructionHandle begin = il.append(methodGen.loadDOM());
        il.append(SWAP);
        il.append(new INVOKEINTERFACE(getParent, 2));
        if (_left instanceof AncestorPattern) {
            il.append(methodGen.loadDOM());
            il.append(SWAP);
View Full Code Here

  final BranchHandle ifBlock3 = il.append(new IFEQ(null));
  il.append(methodGen.loadHandler());
  il.append(new ALOAD(name.getIndex()));
  il.append(methodGen.endElement());
 
  final InstructionHandle end = il.append(NOP);
  ifBlock1.setTarget(end);
  ifBlock3.setTarget(end);
  methodGen.removeLocalVariable(name);
  methodGen.removeLocalVariable(length);
    }
View Full Code Here

        _use.translate(classGen, methodGen);
        _use.startIterator(classGen, methodGen);
        il.append(methodGen.storeIterator());

        final BranchHandle nextNode = il.append(new GOTO(null));
        final InstructionHandle loop = il.append(NOP);

        // Prepare to call buildKeyIndex(String name, int node, String value);
        il.append(classGen.loadTranslet());
        il.append(new PUSH(cpg, _name.toString()));
        il.append(new ILOAD(parentNode.getIndex()));
View Full Code Here

TOP

Related Classes of com.sun.org.apache.bcel.internal.generic.InstructionHandle

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.