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

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


        // Give local variables (if any) default values before starting loop
        initializeVariables(classGen, methodGen);

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

        translateContents(classGen, methodGen);

        nextNode.setTarget(il.append(methodGen.loadIterator()));
        il.append(methodGen.nextNode());
View Full Code Here


  // next element will hold a handle to the beginning of next
  // When/Otherwise if test on current When fails
  BranchHandle nextElement = null;
  Vector exitHandles = new Vector();
  InstructionHandle exit = null;

  Enumeration whens = whenElements.elements();
  while (whens.hasMoreElements()) {
      final When when = (When)whens.nextElement();
      final Expression test = when.getTest();

      InstructionHandle truec = il.getEnd();

      if (nextElement != null)
    nextElement.setTarget(il.append(NOP));
      test.translateDesynthesized(classGen, methodGen);

      if (test instanceof FunctionCall) {
    FunctionCall call = (FunctionCall)test;
    try {
        Type type = call.typeCheck(getParser().getSymbolTable());
        if (type != Type.Boolean) {
      test._falseList.add(il.append(new IFEQ(null)));
        }
    }
    catch (TypeCheckError e) {
        // handled later!
    }
      }
      // remember end of condition
      truec = il.getEnd();

      // The When object should be ignored completely in case it tests
      // for the support of a non-available element
      if (!when.ignore()) when.translateContents(classGen, methodGen);

      // goto exit after executing the body of when
      exitHandles.addElement(il.append(new GOTO(null)));
      if (whens.hasMoreElements() || otherwise != null) {
    nextElement = il.append(new GOTO(null));
    test.backPatchFalseList(nextElement);
      }
      else
    test.backPatchFalseList(exit = il.append(NOP));
      test.backPatchTrueList(truec.getNext());
  }
 
  // Translate any <xsl:otherwise> element
  if (otherwise != null) {
      nextElement.setTarget(il.append(NOP));
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

  il.append(methodGen.setStartNode());
  il.append(methodGen.storeIterator());

  // Loop for traversing all nodes in the DOM
  final BranchHandle nextNode = il.append(new GOTO(null));
  final InstructionHandle loop = il.append(NOP);

  // Check if the current node matches the pattern in "match"
  il.append(methodGen.loadCurrentNode());
  _match.translate(classGen, methodGen);
  _match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack
  final BranchHandle skipNode = il.append(new IFEQ(null));
 
  // If this is a node-set we must go through each node in the set
  if (_useType instanceof NodeSetType) {
      // Pass current node as parameter (we're indexing on that node)
      il.append(methodGen.loadCurrentNode());
      traverseNodeSet(classGen, methodGen, key);
  }
  else {
      il.append(classGen.loadTranslet());
      il.append(DUP);
      il.append(new PUSH(cpg, _name.toString()));
      il.append(DUP_X1);
      il.append(methodGen.loadCurrentNode());
      _use.translate(classGen, methodGen);
      il.append(new INVOKEVIRTUAL(key));
     
      il.append(methodGen.loadDOM());
      il.append(new INVOKEVIRTUAL(keyDom));
  }
 
  // Get the next node from the iterator and do loop again...
  final InstructionHandle skip = il.append(NOP);
 
  il.append(methodGen.loadIterator());
  il.append(methodGen.nextNode());
  il.append(DUP);
  il.append(methodGen.storeCurrentNode());
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

              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

  }
  return _right.typeCheck(stable);
    }

    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  InstructionHandle parent;
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();

  /*
   * The scope of this local var must be the entire method since
View Full Code Here

      _trueList.append(exp._trueList);
      _falseList.append(exp._falseList);
  }

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

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

  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

   * 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),
             il.getEnd(), null);

  skipNext = il.append(new GOTO(null));
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.