Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.BranchHandle


  // Overwrite current iterator with one that gives us only what we want
  _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()));
  parentNode.setEnd(il.append(new ILOAD(parentNode.getIndex())));

  // Now get the node value and push it on the parameter stack
  il.append(methodGen.loadDOM());
  il.append(methodGen.loadCurrentNode());
  il.append(new INVOKEINTERFACE(getNodeValue, 2));   

  // Finally do the call to add an entry in the index for this key.
  il.append(new INVOKEVIRTUAL(buildKeyIndex));
 
  il.append(classGen.loadTranslet());
  il.append(new PUSH(cpg, getName()));
  il.append(methodGen.loadDOM());
  il.append(new INVOKEVIRTUAL(keyDom));

  nextNode.setTarget(il.append(methodGen.loadIterator()));
  il.append(methodGen.nextNode())

  il.append(DUP);
  il.append(methodGen.storeCurrentNode());
  il.append(new IFGE(loop)); // Go on to next matching node....
View Full Code Here


  il.append(methodGen.loadCurrentNode());
  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());
  il.append(new IFGT(loop));

  // Restore current node and current iterator from the stack
  il.append(methodGen.storeIterator());
  il.append(methodGen.storeCurrentNode());
 
  nextNode.setTarget(skip);
  skipNode.setTarget(skip);
    }
View Full Code Here

    il.append(IXOR);      // not x <-> x xor 1
      }
      return;
  }

  BranchHandle truec, falsec;
 
  if (tleft instanceof ResultTreeType) {
      if (tright instanceof BooleanType) {
    _right.translate(classGen, methodGen);
        if (_op == Operators.NE) {
        il.append(ICONST_1);
        il.append(IXOR); // not x <-> x xor 1
    }
    return;
      }

      if (tright instanceof RealType) {
    _left.translate(classGen, methodGen);
    tleft.translateTo(classGen, methodGen, Type.Real);
    _right.translate(classGen, methodGen);

    il.append(DCMPG);
        falsec = il.append(_op == Operators.EQ ?
           (BranchInstruction) new IFNE(null) :
           (BranchInstruction) new IFEQ(null));
    il.append(ICONST_1);
    truec = il.append(new GOTO(null));
    falsec.setTarget(il.append(ICONST_0));
    truec.setTarget(il.append(NOP));
    return;
      }

      // Next, result-tree/string and result-tree/result-tree comparisons
View Full Code Here

  }

  // Check if field is initialized (runtime)
  il.append(classGen.loadTranslet());
  il.append(new GETFIELD(fieldIndexes[_level]));
  final BranchHandle ifBlock1 = il.append(new IFNONNULL(null));

  // Create an instance of DefaultNodeCounter
  index = cpg.addMethodref(ClassNames[_level],
         "getDefaultNodeCounter",
         "(" + TRANSLET_INTF_SIG
         + DOM_INTF_SIG
         + NODE_ITERATOR_SIG
         + ")" + NODE_COUNTER_SIG);
  il.append(classGen.loadTranslet());
  il.append(methodGen.loadDOM());
  il.append(methodGen.loadIterator());
  il.append(new INVOKESTATIC(index));
  il.append(DUP);

  // Store the node counter in the field
  il.append(classGen.loadTranslet());
  il.append(SWAP);
  il.append(new PUTFIELD(fieldIndexes[_level]));
  final BranchHandle ifBlock2 = il.append(new GOTO(null));

  // Backpatch conditionals
  ifBlock1.setTarget(il.append(classGen.loadTranslet()));
  il.append(new GETFIELD(fieldIndexes[_level]));
 
  ifBlock2.setTarget(il.append(NOP));
    }
View Full Code Here

    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
          BooleanType type) {
  final InstructionList il = methodGen.getInstructionList();
  FlowList falsel = translateToDesynthesized(classGen, methodGen, type);
  il.append(ICONST_1);
  final BranchHandle truec = il.append(new GOTO(null));
  falsel.backPatch(il.append(ICONST_0));
  truec.setTarget(il.append(NOP));
    }
View Full Code Here

  il.append(methodGen.storeIterator());

  // 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());
  il.append(DUP);
  il.append(methodGen.storeCurrentNode());
  il.append(new IFGT(loop));
View Full Code Here

  // Overwrite current iterator with one that gives us only what we want
  _use.translate(classGen, methodGen);
  _use.startResetIterator(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()));

  // Now get the node value and feck it on the parameter stack
  il.append(methodGen.loadDOM());
  il.append(methodGen.loadCurrentNode());
  il.append(new INVOKEINTERFACE(getNodeValue, 2));

  // Finally do the call to add an entry in the index for this key.
  il.append(new INVOKEVIRTUAL(buildKeyIndex));

  nextNode.setTarget(il.append(methodGen.loadIterator()));
  il.append(methodGen.nextNode());

  il.append(DUP);
  il.append(methodGen.storeCurrentNode());
  il.append(new IFNE(loop)); // Go on to next matching node....
View Full Code Here

  il.append(methodGen.loadCurrentNode());
  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(new PUSH(cpg, _name.toString()));
      il.append(methodGen.loadCurrentNode());
      _use.translate(classGen, methodGen);
      il.append(new INVOKEVIRTUAL(key));
  }
 
  // 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());
  il.append(new IFNE(loop));

  // Restore current node and current iterator from the stack
  il.append(methodGen.storeIterator());
  il.append(methodGen.storeCurrentNode());
 
  nextNode.setTarget(skip);
  skipNode.setTarget(skip);
    }
View Full Code Here

     */
    public void synthesize(ClassGenerator classGen, MethodGenerator methodGen) {
  final ConstantPoolGen cpg = classGen.getConstantPool();
  final InstructionList il = methodGen.getInstructionList();
  _trueList.backPatch(il.append(ICONST_1));
  final BranchHandle truec = il.append(new GOTO_W(null));
  _falseList.backPatch(il.append(ICONST_0));
  truec.setTarget(il.append(NOP));
    }
View Full Code Here

      // LOOP STARTS HERE

      // Now we're ready to start traversing the node-set given in
      // the key() function's second argument....
      final BranchHandle nextNode = il.append(new GOTO(null));
      final InstructionHandle loop = il.append(NOP);

      // Push returnIndex on stack to prepare for call to merge()
      il.append(new ALOAD(returnIndex.getIndex()));
     
      // Lookup index using the string value from the current node
      il.append(new ALOAD(searchIndex.getIndex()));
      il.append(DUP);
      il.append(methodGen.loadDOM());
      il.append(methodGen.loadCurrentNode());
      il.append(new INVOKEINTERFACE(getNodeValue, 2));
      if (_name == null) {
    il.append(new INVOKEVIRTUAL(lookupId));
      }
      else {
    il.append(new INVOKEVIRTUAL(lookupKey));
      }

      // Call to returnIndex.merge(searchIndex);
      il.append(new INVOKEVIRTUAL(merge));
   
      // Go on with next node in the 2nd parameter node-set
      nextNode.setTarget(il.append(methodGen.loadIterator()));
      il.append(methodGen.nextNode());
      il.append(DUP);
      il.append(methodGen.storeCurrentNode());
      il.append(new IFNE(loop));
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.BranchHandle

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.